Skip to content

Instantly share code, notes, and snippets.

View sabman's full-sized avatar
😀
Building, Shiping, Sharing!

Shoaib Burq sabman

😀
Building, Shiping, Sharing!
View GitHub Profile
@booo
booo / gist:1115871
Created July 30, 2011 19:10
sort on the value of an hstore
SELECT id, tags->'amenity' AS value, tags FROM nodes WHERE tags ? 'amenity' ORDER BY tags->'amenity';
@cdown
cdown / gist:1163649
Last active July 7, 2025 00:58
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
@ernie
ernie / results.txt
Created August 24, 2011 00:04
Script used to benchmark Valium
============================================================
Benchmarking with Ruby 1.9.3 and ActiveRecord 3.2.0.beta
============================================================
user system total real
============================================================
RSS : 31432k (31432k)
Objects : 102195 (102195)
============================================================
SINGLE-VALUE TEST
@metaskills
metaskills / wait_until.rb
Last active May 2, 2024 01:51
Never sleep() using Capybara!
# WAIT! Do consider that `wait` may not be needed. This article describes
# that reasoning. Please read it and make informed decisions.
# https://www.varvet.com/blog/why-wait_until-was-removed-from-capybara/
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations?
describe 'Modal' do
should 'display login errors' do
visit root_path
@alexeckermann
alexeckermann / oauth_mocking.rb
Created September 8, 2011 12:56
OmniAuth testing in RSpec + Capybara
module OauthMocking
def login_with_oauth(provider = :twitter)
visit "/auth/#{provider}"
end
end
require "resque"
require "resque_mailer"
require 'resque/failure'
require 'resque/failure/redis'
require 'resque/failure/multiple'
require "resque/failure/airbrake"
require 'resque/plugins/retry'
require "resque-retry"
require "resque-loner"
require "resque_scheduler"
@kinsteronline
kinsteronline / rails31init.md
Created December 29, 2011 14:16 — forked from dallas/rails31init.md
Rails 3.1 with Rspec, Factory Girl, Haml, Simple Form, Database Cleaner, Spork, and Guard

Install Rails 3.1

gem install rails

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@bkeepers
bkeepers / .gitignore
Created January 11, 2012 20:17
My Sublime settings
*
@kashif
kashif / hstore_to_json.sql
Created January 20, 2012 22:14
Another hstore to JSON function by Andrew Dunstan
create or replace function hstore_to_json(h hstore) returns text language sql
as $f$
select '{' || array_to_string(array_agg(
'"' || regexp_replace(key,E'[\\"]',E'\\\&','g') || '":' ||
case
when value is null then 'null'
when value ~ '^true|false|(-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?)$' then value
else '"' || regexp_replace(value,E'[\\"]',E'\\\&','g') || '"'
end