Skip to content

Instantly share code, notes, and snippets.

@RaphaelAudet
RaphaelAudet / base_presenter.rb
Created March 12, 2012 01:20
base_presenter.rb
class BasePresenter
def initialize(object, template)
@object = object
@template = template
end
private
def self.presents(name)
define_method(name) do
#!/usr/bin/env ruby
# == Synopsis
# This is a sample description of the application.
# Blah blah blah.
#
# == Examples
# This command does blah blah blah.
# ruby_cl_skeleton foo.txt
#
@RaphaelAudet
RaphaelAudet / resque_alert.rb
Last active December 29, 2015 00:09
resque_alert.rb
require 'date'
require 'redis'
require 'net/smtp'
require 'resque'
require 'resque/version'
class App
VERSION = '0.0.1'
def initialize
@RaphaelAudet
RaphaelAudet / gist:7988631
Last active December 31, 2015 12:49
80-senttoci.conf
$LocalHostName myhost
# load module to read from local files
$ModLoad imfile
# for each local log file path, duplicate the 6 lines below and edit lines 2-4
$RuleSet sendtoci # use a non-default ruleset (keeps logs out of /var/log/)
$InputFileName /var/www/app/shared/log/production.log
$InputFileTag unicorn:
$InputFileStateFile sendtoci-unicorn
function tab-red() { tab-color 203 111 111; }
function tab-green() { tab-color 6cc276; }
function tab-yellow() { tab-color "#e8e9ac"; }
function tab-blue() { tab-color 6f8ccc; }
function tab-purple() { tab-color a789d4; }
function tab-orange() { tab-color fbbc79; }
function tab-white() { tab-color fff; }
function tab-gray() { tab-color c3c3c3c; }
tg() {tab-blue; ssh $1.europe-west1-b.MYPROJECT -t sudo tmux attach -t main;}
@RaphaelAudet
RaphaelAudet / new_swap.sh
Last active August 29, 2015 14:04
add swap from scratch
#!/bin/bash
# http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/
dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
mkswap /swapfile1
chmod 0600 /swapfile1
echo '/swapfile1 swap swap defaults 0 0' >> /etc/fstab
#swapon -a
@RaphaelAudet
RaphaelAudet / settz.sh
Created July 25, 2014 13:01
set timezone
echo "Europe/Paris" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
@RaphaelAudet
RaphaelAudet / filelimits.sh
Last active August 29, 2015 14:04
set open file limit
#!/bin/bash
cp /etc/sysctl.conf /etc/sysctl.conf.20140808
echo 'fs.file-max = 64000'>>/etc/sysctl.conf
echo 'root soft nofile 64000'>>/etc/security/limits.conf
echo 'root hard nofile 64000'>>/etc/security/limits.conf
# echo 'mongodb soft nofile 64000'>>/etc/security/limits.conf
# echo 'mongodb hard nofile 64000'>>/etc/security/limits.conf
sysctl -p
@RaphaelAudet
RaphaelAudet / clearredis.rb
Created August 28, 2014 12:58
clear sidekiq broken failed job after upgrading to sidekiq 3.1.4
redis = Redis.new(:host => 'xxxxx', :port => xxxxx, :password => 'xxxxxx', :thread_safe => true)
redis.llen("sidekiq:xxxxxxx:failed")
10.times {redis.lpop("sidekiq:xxxxxxx:failed")}
@RaphaelAudet
RaphaelAudet / unicorn_production.conf
Created September 17, 2014 08:06
unicorn_production.conf
check process unicorn_production with pidfile /var/www/az_app_2_production/shared/pids/unicorn.pid
if totalmem > 2.6 GB for 5 cycles then restart
start = "/etc/az-scripts/unicorn_production.sh start" with timeout 90 seconds
stop = "/etc/az-scripts/unicorn_production.sh stop"