Skip to content

Instantly share code, notes, and snippets.

@obie
obie / _alert.haml
Created October 15, 2020 03:29
Alerts in Reactive Rails style (with Shoelace web components)
%sl-alert.popup-toast{id: id, type: type, open: false, duration: duration, closable: true}
%sl-icon{slot: "icon", name: icon}
- if title.present?
%strong= title
%br
= text
@pedrocarmona
pedrocarmona / initials_avatar.rb
Last active December 24, 2022 16:50
Initials avatar - create an image with letters for using as the user avatar.
require "mini_magick"
# require "initials_avatar"
# InitialsAvatar.new(initials: "PC").avatar_path
class InitialsAvatar
BACKGROUND_COLORS = [
"#C53030", "#9C4221", "#975A16", "#2F855A", "#2C7A7B", "#2B6CB0", "#434190", "#553C9A", "#97266D"
]
def initialize(initials:)
@przbadu
przbadu / _vue-rails.md
Last active July 16, 2022 21:48
Vue js and Rails integration

Setup Rails and Vuejs

  1. Generate new rails app using --webpack flag
rails new myApp --webpack=vue

Note:

  1. You can use --webpack=angular for angular application and --webpack=react for react.
@umpirsky
umpirsky / ubuntu-raid.sh
Last active April 15, 2024 00:53
Install Ubuntu on RAID 0 and UEFI/GPT system
# http://askubuntu.com/questions/505446/how-to-install-ubuntu-14-04-with-raid-1-using-desktop-installer
# http://askubuntu.com/questions/660023/how-to-install-ubuntu-14-04-64-bit-with-a-dual-boot-raid-1-partition-on-an-uefi%5D
sudo -s
apt-get -y install mdadm
apt-get -y install grub-efi-amd64
sgdisk -z /dev/sda
sgdisk -z /dev/sdb
sgdisk -n 1:0:+100M -t 1:ef00 -c 1:"EFI System" /dev/sda
sgdisk -n 2:0:+8G -t 2:fd00 -c 2:"Linux RAID" /dev/sda
@johanndt
johanndt / upgrade-postgres-9.3-to-9.5.md
Last active July 15, 2022 12:35 — forked from dideler/upgrade-postgres-9.3-to-9.4.md
Upgrading PostgreSQL from 9.3 to 9.5 on Ubuntu

TL;DR

Install Postgres 9.5, and then:

sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main
@mperham
mperham / gist:7d763bdc42465caf17c7
Last active August 29, 2015 14:02
Rule execution

I want to build a system which uses rules. These rules will change hourly (i.e. "this rule is effective from 2pm to 6pm"). The rules must support arbitrarily complex logic on just 2-3 pre-defined variables and result in a boolean:

item.a > 10 && item.b == 0 || item.category == FOOTWEAR

These rules will be executed hundreds of times per second so I can't afford the overhead of plain old eval. I want to reload the current effective ruleset from the database hourly, precompile each rule's logic string and execute it via the quickest method possible. It might look something like this:

class Rule
@alextakitani
alextakitani / post_install.sh
Last active March 15, 2024 15:59
Montagem de ambiente dev linux #linux
#atualizado para Tuxedo OS 2 ( Ubuntu 22.04 )
# como usar:
# Clique ali em cima no botão raw
# salve o arquivo no seu disco.
# abra o terminal na pasta onde vc baixou o arquivo.
# de permissão de execução chmod +x post_install.sh
# rode:
# ./post_install.sh
# coloque sua senha