Skip to content

Instantly share code, notes, and snippets.

View nicbet's full-sized avatar

Nicolas Bettenburg nicbet

View GitHub Profile
@nicbet
nicbet / load-env.sh
Created February 22, 2018 14:17
Load all variables set in .env file into current shell session environment
export $(grep -v "^#" .env | xargs)
@nicbet
nicbet / notes-rails-polymorphic-associations.md
Created November 12, 2018 15:17
Rails polymorphic associations
class Person < ActiveRecord::Base
  has_one :address, :as => :addressable
end

class Company < ActiveRecord::Base
  has_one :address, :as => :addressable
end

class Address &lt; ActiveRecord::Base
@nicbet
nicbet / gtk.css
Created January 5, 2019 19:44
Gnome 3.28 - Better Focus Window Visibility
/* File ~/.config/gtk-3.0/gtk.css */
.titlebar {
color:white;
}
.titlebar:backdrop {
background: #333;
color:#666;
}
@nicbet
nicbet / simple_authentication_rails_5_bcrypt_and_has_secure_password.md
Created February 8, 2019 02:59 — forked from iscott/simple_authentication_rails_5_bcrypt_and_has_secure_password.md
Cheat Sheet: Simple Authentication in Rails 5 with has_secure_password

Cheat Sheet: Simple Authentication in Rails 5 with has_secure_password

The goal of this cheatsheet is to make it easy to add hand-rolled authentication to any rails app in a series of layers.

First the simplest/core layers, then optional layers depending on which features/functionality you want.

Specs
AUTHOR Ira Herman
LANGUAGE/STACK Ruby on Rails Version 4 or 5
@nicbet
nicbet / run_db.sh
Created February 11, 2019 19:29
Development Database (postgresql) with Docker
#!/bin/bash
docker run --name $@ \
-d \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_USER=postgres \
-v $(pwd)/database:/var/lib/postgresql/data \
-p 5432:5432 \
postgres:11
@nicbet
nicbet / disable-autodiscover.applescript
Created March 6, 2019 13:59
Disable Autodiscover for Outlook 2019 on Mac OS X
tell application "Microsoft Outlook"
set background autodiscover of exchange account "ACCOUNT_NAME" to false
end tell
@nicbet
nicbet / install-nvidia-docker.sh
Last active March 27, 2019 19:03
Install Nvidia-Docker on NVIDIA GPU Cloud Machine Ubuntu 18.04
#!/bin/bash
# Check for Hardware, GCC, Kernel
lspci | grep -i nvidia
gcc --version
uname -r
sudo apt-get install linux-headers-$(uname -r)
# Install Docker CE
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
@nicbet
nicbet / database.yml
Created April 3, 2019 01:56
DRY Database Config for Rails
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: <%= ENV.fetch("DB_USER") { "postgres" } %>
password: <%= ENV.fetch("DB_PASSWORD") { "postgres" } %>
host: <%= ENV.fetch("DB_HOST") { "localhost" } %>
@nicbet
nicbet / .rubocop.yml
Created April 3, 2019 02:02
Rubocop sane defaults for Rails 5.2
Rails:
Enabled: true
AllCops:
TargetRubyVersion: 2.5
Exclude:
- bin/*
- Gemfile
- vendor/**/*
- node_modules/**/*
- db/schema.rb
@nicbet
nicbet / notes-rails-generators-config.md
Last active April 8, 2019 16:33
Declutter Rails Generators
# config/application.rb

# Generators
    config.generators do |g|
      g.test_framework(false)
      g.stylesheets(false)
      g.javascripts(false)
      g.helper(false)
 g.channel(assets: false)