Skip to content

Instantly share code, notes, and snippets.

View aujkis's full-sized avatar
🎯
Focusing

Austris aujkis

🎯
Focusing
  • Riga, Latvia
View GitHub Profile
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 / 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
@aujkis
aujkis / Gemfile
Created August 12, 2017 12:43 — forked from frank-who/Gemfile
Postgres Arrays in Active Admin
ruby '2.2.0'
source 'https://rubygems.org'
...
gem 'font-awesome-rails'
@aujkis
aujkis / README.md
Created January 29, 2019 20:47 — forked from fredrikhenne/README.md
A simple key/value store model for Rails using the database and memcache

Rails Setting model

This is a semi-quick key/value store I put together for a quick way to store temporary data related to what's in my database, in a reliable way. For example, I'm using it to keep track of where a hourly and a daily crontask that processes statistics left off, so it can resume only processing and summarizing new data on the next run.

Code quality most likely is not great, but it works. And I will update this gist as I update my project.

How It Works

The settings table has two columns, a key and a value column. The value column is serialized, so you can technically store almost anything in there. Memcache is also used as a caching layer to minimize database calls.

@aujkis
aujkis / README.md
Created January 29, 2019 20:47 — forked from jimeh/README.md
A simple key/value store model for Rails using the database and memcache

Rails Setting model

This is a semi-quick key/value store I put together for a quick way to store temporary data related to what's in my database, in a reliable way. For example, I'm using it to keep track of where a hourly and a daily crontask that processes statistics left off, so it can resume only processing and summarizing new data on the next run.

Code quality most likely is not great, but it works. And I will update this gist as I update my project.

How It Works

The settings table has two columns, a key and a value column. The value column is serialized, so you can technically store almost anything in there. Memcache is also used as a caching layer to minimize database calls.