Skip to content

Instantly share code, notes, and snippets.

@raecoo
raecoo / gist:2429429
Created April 20, 2012 15:04 — forked from Sutto/gist:943752
Resque Daemon Controller
#!/usr/bin/env ruby
ENV['RAILS_ENV'] ||= 'development'
require File.expand_path('../../config/environment', __FILE__)
require 'daemon_spawn'
class ResqueWorkerDaemon < DaemonSpawn::Base
def start(args)
@worker = Resque::Worker.new('*') # Specify which queues this worker will process
@raecoo
raecoo / rbenv-install-system-wide.sh
Created July 4, 2012 07:00 — forked from v1nc3ntlaw/rbenv-install-system-wide.sh
rbenv install ruby 1.9.3-p194 on Debian 6 Squeeze
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential git-core curl libssl-dev \
libreadline5 libreadline5-dev \
zlib1g zlib1g-dev \
libmysqlclient-dev \
libcurl4-openssl-dev \
libxslt-dev libxml2-dev
@raecoo
raecoo / array_dupplicate_counter.js
Created December 7, 2012 02:42 — forked from ralphcrisostomo/array_dupplicate_counter.js
Javascript: Count duplicates in an array
/**
Problem:
You have a javascript array that likely has some duplicate values and you would like a count of those values.
Solution:
Try this schnippet out.
*/
/*
This script is for updating the auto_increment field by an offset. The logic applied is
max(AUTO_INCREMENT) + current value in the table.
*/
SET @db:='id_new';
select @max_id:=max(AUTO_INCREMENT) from information_schema.tables;
select concat('update ',table_name,' set ', column_name,' = ',column_name,'+',@max_id,' ; ') from information_schema.columns where table_schema=@db and column_name like '%id' into outfile 'update_ids.sql';
class CreateImports < ActiveRecord::Migration
def self.up
create_table :imports do |t|
t.string :datatype
t.integer :processed, :default => 0
t.string :csv_file_name
t.string :csv_content_type
t.integer :csv_file_size
t.timestamps
end
.btn-group-radio input[type=radio] {
visibility: hidden;
position: absolute !important;
top: -9999px !important;
left: -9999px !important;
}
.btn-group-radio input[type=radio]:checked + .btn {
color: #333333;
background-color: #e6e6e6;
# Big thank you to Scott Wheeler and BBG in the Shopify API Forums
# http://ecommerce.shopify.com/c/shopify-apis-and-technology/t/paginate-api-results-113066
module ShopifyAPI
class Base
RETRY_AFTER = 60
def self.find_all(params = {}, &block)
params[:limit] ||= 50
params[:page] = 1
@raecoo
raecoo / README.md
Last active August 29, 2015 14:17 — forked from jpantuso/README.md

Deploying Rails to Linode

Installing Ruby Enterprise Edition, Apache, MySQL, and Passenger for deploying Rails 3.0 applications.

Get a Linode, and set it up with Ubuntu 10.04 LTS so that you have till April 2013 to get updates. Once the Linode is formatted, boot it and continue on.

Set up an 'A' record in your DNS, pointing to the IP of your Linode. I'm using demo.napcs.com here.

Initial setup

@raecoo
raecoo / monit_sidekiq
Last active August 29, 2015 14:20 — forked from jlecour/monit_sidekiq
check process sidekiq_01
with pidfile /path/to/app/current/tmp/pids/sidekiq.pid
start program = "/bin/sh -c 'cd /path/to/app/current; PATH=bin:/path/to/rbenv/shims:/path/to/rbenv/bin:$PATH nohup bundle exec sidekiq -e production -i 0 -P tmp/pids/sidekiq.pid >> log/sidekiq.log 2>&1 &'" as uid app_user and gid app_group with timeout 90 seconds
stop program = "/bin/sh -c 'cd /path/to/app/current; PATH=bin:/path/to/rbenv/shims:/path/to/rbenv/bin:$PATH bundle exec sidekiqctl stop tmp/pids/sidekiq.pid'" as uid app_user and gid app_group with timeout 90 seconds
if totalmem is greater than 500 MB for 2 cycles then restart # eating up memory?
group sidekiq
check process sidekiq_02
with pidfile /path/to/app/current/tmp/pids/sidekiq.pid-1
start program = "/bin/sh -c 'cd /path/to/app/current; PATH=bin:/path/to/rbenv/shims:/path/to/rbenv/bin:$PATH nohup bundle exec sidekiq -e production -i 1 -P tmp/pids/sidekiq.pid-1 >> log/sidekiq.log 2>&1 &'" as uid app_user and gid app_group with timeout 90 seconds
@raecoo
raecoo / sidekiq.sh
Last active August 29, 2015 14:28 — forked from ponchik/sidekiq.sh
#!/bin/bash
SCRIPT='cd /web/vcms/; bundle exec sidekiq'
RUNAS=dimon
NAME=vcms-sidekiq
PIDFILE=/web/vcms/tmp/pids/sidekiq.pid
LOGFILE=/web/vcms/log/sidekiq.log
start() {