Skip to content

Instantly share code, notes, and snippets.

View aujkis's full-sized avatar
🎯
Focusing

Austris aujkis

🎯
Focusing
  • Riga, Latvia
View GitHub Profile
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
config.error_notification_class = 'alert alert-danger'
config.button_class = 'waves-effect waves-light btn'
config.boolean_label_class = nil
config.wrappers :vertical_form, tag: 'div', class: 'input-field', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
b.optional :maxlength
Initialize Digital Ocean Droplet, add SSH key(s)
ssh root@<IP>
# Fix locales
sudo nano /etc/environment
LANGUAGE=en_US.UTF-8
LC_ALL=en_US.UTF-8
sudo locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales
sudo reboot
@aujkis
aujkis / deploy.rb
Last active January 11, 2016 17:16 — forked from Epigene/deploy.rb
# Mina Deploy
# ===========
#
# Adapted from Creative deploy stack in Manabalss v4, Mar.2015
# On first deploy do: mina setup --verbose
# Then do : mina deploy --trace
#
# Usage:
# mina deploy --verbose # Standard deploy task | mina deploy[hard,seed] to hard-reset and seed
# mina rake[db:seed]
# in config/puma.rb
app = "cpp" # App-specific
root = "/home/deployer/apps/#{app}"
workers 5
threads 1, 1
#preload_app!
rackup DefaultRackup
#port 9292
If you are on windows, start by setting up an Ubuntu in a VirtualBox
= http://www.psychocats.net/ubuntu/virtualbox
First you wanna update Ubuntu
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade
$ sudo reboot
Add repositories
# /config/puma.rb
app = "manabalss" # App-specific
root = "/home/deployer/apps/#{app}"
workers 5
threads 1, 1 # relying on many workers for thread-unsafe apps
rackup DefaultRackup
port 11592
# create a mongo app
flynn create --remote "" mongo
# create a release using the latest (at the time of writing) Docker MongoDB image
flynn -a mongo release add -f config.json "https://registry.hub.docker.com?name=mongo&id=216d9a0e82646f77b31b78eeb0e26db5500930bbd6085d5d5c3844ec27c0ca50"
# scale the server to one process. This may time out initially as the server pulls the image, but watch "flynn -a mongo ps" and it should come up.
flynn -a mongo scale server=1
# mongo should now be running in the cluster at mongo.discoverd:27017
@aujkis
aujkis / module-patterns.js
Last active August 29, 2015 14:24
NodeJS module patterns
// PATTERN 1: DEFINE A GLOBAL
// foo.js
foo = function () {
console.log('foo!');
}
// app.js
require('./foo.js');
foo();
curl get.pow.cx/uninstall.sh | sh
curl get.pow.cx | sh
scutil --dns
sudo touch /etc/resolver/dev
sudo pfctl -f /etc/pf.conf
sudo pfctl -e
touch ~/.pow/rails
@aujkis
aujkis / active_record_marshalable.rb
Created January 5, 2016 08:29 — forked from keichan34/active_record_marshalable.rb
Get Marshal.dump and Marshal.load to load cached association objects ( Whatever.includes(:example_models) ), as well.
module ActiveRecordMarshalable
def marshal_dump
[attributes, self.association_cache, instance_variable_get(:@new_record)]
end
def marshal_load data
send :initialize, data[0]
instance_variable_set :@association_cache, data[1]
instance_variable_set :@new_record, data[2]
end