Skip to content

Instantly share code, notes, and snippets.

View gerhard's full-sized avatar

Gerhard Lazu gerhard

View GitHub Profile
@maxlapshin
maxlapshin / systemd.erl
Last active December 24, 2022 17:28
Systemd support
-module(systemd).
% This is what you need to adopt systemd in erlang
%
% Do whatever you want license. If you want, you can take this code under terms of MIT license.
-export([ready/0, reloading/0, stopping/0, watchdog/0]).
-export([start_link/0]).
-export([init/1, handle_info/2, terminate/2]).
@xaviershay
xaviershay / build_frontend.sh
Last active December 24, 2015 20:49
SASS + Coffee + Concatenation in prod
#!/bin/bash
set -exo pipefail
BUILD_ENV=$1
if [ `uname` == 'Darwin' ]; then
OSX=1
JSCOMPRESSOR="yuicompressor --type js"
else
OSX=
@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@gerhard
gerhard / aa_instructions.md
Created May 23, 2012 10:38 — forked from NZKoz/aa_instructions.md
Back Up All Your Gmail
  • Install getmail (aptitude install getmail4)
  • Set Up Your Imap Server (tl;dr)
  • getmail
  • ruby date_based_archive.rb ~/Maildir/.Archive
@gerhard
gerhard / gist:2517250
Created April 28, 2012 08:43 — forked from kyledrake/gist:2120107
Rainbows! config file for use with EventMachine
# This is a configuration script for using Rainbows with EventMachine. I'm providing it incase somebody finds it useful. But honestly, you
# should stop using EventMachine and use threads instead. The ThreadPool version of this is also in my gist list, and I recommend taking a look at that instead.
# NO, SERIOUSLY, STOP USING EVENTMACHINE.
Rainbows! do
name = 'yourappname'
use :EventMachine
client_max_body_size nil # This is set in nginx
# keepalive_timeout 1
@gerhard
gerhard / total_rss.sh
Created March 22, 2012 17:09
Find total RSS memory used by all ruby processes
$ ps aux | awk '/[0-9] ruby/ { print $0; rss += $6 } END { print "TOTAL RSS: " rss/1024 " MB" }'
# Don't forget about resque ones
$ ps aux | awk '/[0-9] ruby|[0-9] resque/ { print $0; rss += $6 } END { print "TOTAL RSS: " rss/1024 " MB" }'
<<-LRUG Hola El Rug,
Here's a little teaser for you...
I have two sets of photos; we'll call them urban and nature. Both sets contain about 6-9 photos, but not necessarily the same number.
I also have about 15-20 pages on a site, spread more or less evenly across three sections. Each page has a title unique to its section (and, if it helps, we can assume unique across all the pages).
On each page I want to display one photo from each set.
#!/bin/bash
#
# General all-covering MediaTomb transcoding script.
#
#############################################################################
# Edit the parameters below to suit your needs.
#############################################################################
# Subtitles imply transcoding; set to 1 to disable subtitle rendering.
# For divx this doesn't matter much but for mp4, mkv and DVD it does.
require 'irb/completion'
require 'pp'
IRB.conf[:AUTO_INDENT]=true
if defined?(Rails) == 'constant'
spec_helper = Rails.root + "spec/spec_helper.rb"
require spec_helper if File.exists?(spec_helper)
end
@gerhard
gerhard / etc_default_php-fastcgi
Created March 18, 2010 13:44
setting up an ubuntu box for ruby & php stuff. Includes nginx and php-fcgi daemons
#
# Settings for php-cgi in external FASTCGI Mode
#
# Should php-fastcgi run automatically on startup? (default: no)
START=yes
# Which user runs PHP? (default: www-data)