Skip to content

Instantly share code, notes, and snippets.

View padi's full-sized avatar

Marc Ignacio padi

View GitHub Profile

Literate Ruby

Inspired by Literate CoffeeScript.

$ cat hello.rb.md
Here's a simple program

    puts "Hello, world"
$ ruby litrb.rb < hello.rb.md

Hello, world

=> #<OpenStruct site_id="7018", currency_decimals="2", tax_decimals="2", tax_rate_1="7.0000", tax_rate_2="0.0000", regional_options="0", unit_type_id="28", unit_type_name="Drive Up Unit", has_charge_tax_1=true, has_charge_tax_2=true, def_lease_num="1", is_mobile=true, is_inside=true, floor="1", width="9.5000", length="20.0000", area="190.0000", push_rate="80.0000", standard_rate="100.0000", standard_weekly_rate="0.0000", total_units="1", total_units_occupied="1", total_units_vacant="0", total_units_reserved="1", first_available_unit_id="2972", first_available_unit_name="100", first_available_unit_description="This is a test. Ramp access, Elevator, interior", representative_unit_id="2972", representative_unit_name="100", representative_unit_description="This is a test. Ramp access, Elevator, interior", admin_fee="0.0000", reservation_fee="10.0000", is_first_available_unit_rented=true>
=> #<OpenStruct site_id="7018", currency_decimals="2", tax_decimals="2", tax_rate_1="7.0000", tax_rate_2="0.0000", regional_op
@padi
padi / README.txt
Created September 12, 2013 05:48 — forked from rdetert/README.txt
The purpose of all this is to see if sphinx, thinking sphinx and thinking sphinx delayed delta are all working properly.
I created a test controller on a separate monit subdomain that simply generates and posts a test value and then uses curl to retrieve it. If the two values match, then sphinx is working properly with delayed delta.
This example assumes a Linux installation.
The file 'delayed_delta.sh' spawns the `rake ts:dd` process in the background, saving its PID to tmp/pids in your Rails project. You can start and stop it by running '/etc/init.d/delayed_delta.sh start' and '/etc/init.d/delayed_delta.sh stop'. You will use these in your monitoring to, see the monitrc snippet.
In a crontab, every X seconds or minutes, run 'ar_sphinx_mon.sh' to see if records are properly being inserted and indexed. If they aren't, then kill all Thinking Sphinx processes and monit should restart them.
@padi
padi / ansible.md
Created November 27, 2013 07:48 — forked from rstacruz/ansible.md
# inspired by http://ariejan.net/2010/08/23/resque-how-to-requeue-failed-jobs
# retry all failed Resque jobs except the ones that have already been retried
# This is, for instance, useful if you have already retried some jobs via the web interface.
Resque::Failure.count.times do |i|
Resque::Failure.requeue(i) unless Resque::Failure.all(i, 1)['retried_at'].present?
end
# retry all :)
Resque::Failure.count.times do |i|
@padi
padi / tmux.md
Created February 19, 2014 07:09 — forked from andreyvit/tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

build_package_combined_patch() {
local package_name="$1"
{
curl https://raw.github.com/gist/4136373/falcon-gc.diff | patch -p1
autoconf
./configure --prefix="$PREFIX_PATH" $CONFIGURE_OPTS
make -j 8
make install
} >&4 2>&1
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 4.4.4 (https://www.androidfilehost.com/?w=files&flid=15801)
Google Apps for Android 4.3 (http://goo.im/gapps/gapps-jb-20130813-signed.zip)
Google Apps for Android 4.2 (http://goo.im/gapps/gapps-jb-20130812-signed.zip)
Google Apps for Android 4.1 (http://goo.im/gapps/gapps-jb-20121011-signed.zip)