Skip to content

Instantly share code, notes, and snippets.

View igal's full-sized avatar

Igal Koshevoy igal

  • Pragmaticraft
  • Portland, Oregon, USA
View GitHub Profile
@igal
igal / .bashrc_prompt.sh
Created August 28, 2012 06:59
Fancy, re-configurable prompt.
# The code below provides an elaborate system for composing custom prompts.
# Of these the `myprompt`, `devprompt` and `longprompt` are the most useful.
# Fancy, reconfigurable prompt.
multiprompt () {
parse_git_branch () {
if [[ -n $promptgit ]] && which git 2>&1 > /dev/null; then
ref=$(git symbolic-ref HEAD 2> /dev/null) || return 0
ref="${ref#refs/heads/}"
if [[ $ref != 'master' ]]; then
@igal
igal / .gitconfig
Created August 28, 2012 06:51
Git configuration
#---[ Includes ]--------------------------------------------------------
[include]
# Load private information from a separate file, e.g. name, email, global
# ignores, tokens, etc.
path = ~/.gitconfig.local
#---[ Settings ]--------------------------------------------------------
[core]
@igal
igal / 99.pl
Created August 10, 2012 04:17 — forked from notbenh/99.pl
ben goofs off with 99 bottles ... now with moar minimalism.
#!/usr/bin/env perl
use strict;
use warnings;
use feature qw{say};
sub bottles() { sprintf qq{%s bottle%s of beer}
, $_ || 'No'
, $_==1 ? '' : 's';
}
sub store() { $_=99; qq{Go to the store, buy some more...\n}; }
@igal
igal / gist:983749
Created May 20, 2011 20:39
Resque: possible way to add durability

Resque durability

Resque (https://github.com/defunkt/resque) is nice, but doesn't provide durability. When a worker "reserves" a job, it actually just pops it from the data store, which deletes the job. If anything happens to the worker after it pops the job, the job is lost forever. However, the author of Resque, defunkt, doesn't want reservation or retries added, and has rejected such patches in the past. Therefore, this may not be worth doing with Resque unless someone wants to maintain a fork of it forever.

Background

  1. https://github.com/defunkt/resque/issues/16 -- where defunkt writes "Resque is explicitly designed to never re-try jobs. Ever, under any circumstance." and "If you need jobs to never fail and never slip through the cracks due to failure you may want [something else]".
  2. https://github.com/defunkt/resque/issues/93 -- where defunkt write "Resque
@igal
igal / gist:944934
Created April 27, 2011 18:59
Etherpad: find the URL for a page if you can only remember some of its contents

Etherpad: find the URL for a page if you can only remember some of its contents

  1. Connect to the Etherpad database, the credentials are in a file like src/etherpad/trunk/etherpad/etc/etherpad.localdev-default.properties

  2. Execute SQL similar to that below, replacing Phantom Chicken with your search term:

     SELECT DISTINCT(m.ID) FROM `PAD_REVMETA_META` AS m LEFT JOIN
       (`PAD_REVMETA_TEXT` AS t) ON (m.NUMID = t.NUMID) WHERE t.DATA 
       LIKE '%Phantom Chicken%';
    
  3. Use the IDs shown to compose a URL, e.g. if ID is omgkittens and your Etherpad server is at etherpad.mysite.com, then your URL is http://etherpad.mysite.com/omgkittens.

@igal
igal / sunspot_eg.rb
Created March 2, 2011 02:08
Sample Sunspot full-text search code
class Post < ActiveRecord::Base
# Define index
searchable do
text :title, :body
string :author_name
integer :blog_id
integer :category_ids
float :average_rating, :using => :ratings_average
time :published_at
string :sort_title do
@igal
igal / git-meld.rb
Created August 21, 2010 07:04
git-meld
#!/usr/bin/env ruby
# FIXME provide flexible way of choosing tool
DIFF = ENV['DIFF'] || 'meld'
########################################################################################################
# Usage: #
# gitopendiff [-r<left rev>:<right-rev>] [repository] #
# #
# Example: #
# This gist describe's the OpenConferenceWare data structures
# related to user favorites.
#
# The hope is that this will help with creating an algorithm that
# can schedule sessions in an optimal way based on:
#
# * User favorites: Don't schedule talks at same time if many
# users favorite them together.
# * Tracks: Balance out tracks so that there aren't, for example,
# only "cooking" track talks happening at the same time.
# Tell controller not to check for authenticity token:
Rails.configuration.action_controller.allow_forgery_protection = false
# Create a session:
app = ActionController::Integration::Session.new
# Setup parameters from log:
params = {"start_date"=>"2010-04-15", "end_date"=>"2010-04-15", "commit"=>"Create", "event"=>{"title"=>"Brain Silo Hackfest/Open House", "url"=>"http://brainsilo.org", "venue_id"=>"202392003", "description"=>"The silo is open to any interested parties who want to hack or just check out the space during the welcome meeting. <b>This is an Open House meeting</b>\r\n\r\nNOTE: The entrance for the space is on the backside of the building in the alley -- NOT at the mailing address. See this satellite view for clarification: http://bit.ly/8Arvpt\r\n\r\nThe outside door is at the top of a set of stairs. The space is marked with a small sticker that is labeled \"BrainSilo\"\r\n", "tag_list"=>"brainsilo, hackfest"}, "venue_name"=>"bRainSilo", "trap_field"=>"", "start_time"=>"07:00 PM", "end_time"=
@igal
igal / .vimperatorrc.local.vim
Created March 11, 2010 21:19
My Vimperator configuration
"===[ Settings ]========================================================
" Autocomplete using Firefox Awesomebar subsystem
set complete=l
" Show completions as you type? '' waits for tab, 'auto' shows them immediately
set wildoptions=''
" Select the longest autocomplete match
set wildmode='list:full'