Skip to content

Instantly share code, notes, and snippets.

View vadviktor's full-sized avatar
🍀
Mining Ruby 💎 ⛏️

Viktor (Icon) VAD 🍀 vadviktor

🍀
Mining Ruby 💎 ⛏️
View GitHub Profile
## INHERIT from a base class
# -----------------------------------------
class Product < ActiveRecord::Base
belongs_to :category
def self.lookup(item_code)
where(:item_code => item_code).first
end
end
upstream app {
server unix:/srv/app/current/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name www.app.com;
rewrite ^/(.*) http://app.com/$1 permanent;
}
server {
@vadviktor
vadviktor / _test.rb
Created February 23, 2014 16:11 — forked from jcoglan/_test.rb
$VERBOSE = nil
require File.expand_path('../rooby', __FILE__)
Person = Rooby::Class.new 'Person' do
define :initialize do |name|
@name = name
end
define :name do
# rbenv
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
source ~/.rbenv/completions/rbenv.bash
# prompt with ruby version
# rbenv version | sed -e 's/ .*//'
__rbenv_ps1 ()
{
rbenv_ruby_version=`rbenv version | sed -e 's/ .*//'`
wget --recursive --no-clobber --page-requisites --adjust-extension --convert-links --restrict-file-names=unix --domains guides.rubyonrails.org --no-parent http://guides.rubyonrails.org/v2.3.11/
@vadviktor
vadviktor / onchange.sh
Last active August 29, 2015 14:06 — forked from senko/onchange.sh
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
# Download and Install the Latest Updates for the OS
apt-get update && apt-get upgrade -y
# Set the Server Timezone to CST
echo "America/Chicago" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
# Enable Ubuntu Firewall and allow SSH & MySQL Ports
ufw enable
ufw allow 22
@vadviktor
vadviktor / fork_with_new_connection.rb
Last active August 29, 2015 14:25 — forked from danieldbower/fork_with_new_connection.rb
Forking Processes In Ruby On Rails
# Logic for forking connections
# The forked process does not have access to static vars as far as I can discern, so I've done some stuff to check if the op threw an exception.
def fork_with_new_connection
# Store the ActiveRecord connection information
config = ActiveRecord::Base.remove_connection
pid = fork do
# tracking if the op failed for the Process exit
success = true
@vadviktor
vadviktor / puma_rails_heroku.rb
Created February 26, 2017 00:05 — forked from subelsky/puma_rails_heroku.rb
Setting up Puma and Rails on Heroku
# Gemfile
gem "puma"
# Procfile
web: bundle exec puma -p $PORT -e $RACK_ENV -C config/puma.rb
# add to config block config/environments/production.rb
config.threadsafe!
# get rid of NewRelic after_fork code, if you were doing this: