Skip to content

Instantly share code, notes, and snippets.

Zidni Mubarock barockok

Block or report user

Report or block barockok

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@jacqui
jacqui / gist:983051
Created May 20, 2011 — forked from pauldix/gist:981916
Redis SORT command examples
View gist:983051
# Optimized for writes, sort on read
# LVC
redis.hset("bonds|1", "bid_price", 96.01)
redis.hset("bonds|1", "ask_price", 97.53)
redis.hset("bonds|2", "bid_price", 95.50)
redis.hset("bonds|2", "ask_price", 98.25)
redis.sadd("bond_ids", 1)
redis.sadd("bond_ids", 2)
@jasoncodes
jasoncodes / create_item_children_count.rb
Created Oct 23, 2011
Create ActiveRecord models for database views
View create_item_children_count.rb
class CreateItemChildrenCountView < ActiveRecord::Migration
def self.up
execute <<-SQL
CREATE VIEW item_children_count AS
SELECT parent_id AS item_id, COUNT(*) as children_count
FROM items GROUP BY parent_id;
SQL
end
def self.down
@otaviomedeiros
otaviomedeiros / alias_matcher.rb
Created Mar 1, 2012
RSpec matcher for alias_method
View alias_matcher.rb
# RSpec matcher for alias_method.
# https://gist.github.com/1950961
# Usage:
#
# describe User do
# it { should alias_from(:username).to(:email) }
# end
RSpec::Matchers.define :alias_from do |alias_method|
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@jrafanie
jrafanie / gist:3011499
Created Jun 28, 2012
ActiveRecord::Base doesn't serialize instance variables
View gist:3011499
~/Code/playground/rails-3-2-stable $ cat app/models/person.rb
class Person
attr_accessor :abc
end
~/Code/playground/rails-3-2-stable $ cat app/models/story.rb
class Story < ActiveRecord::Base
attr_accessor :abc
end
@linjian
linjian / deferred_garbage_collection_all_in_one.rb
Created Jul 19, 2012
Deferred Garbage Collection All in One
View deferred_garbage_collection_all_in_one.rb
# http://ariejan.net/2011/09/24/rspec-speed-up-by-tweaking-ruby-garbage-collection
#
# Usage:
# DEFER_GC=10 rspec spec/
# DEFER_GC=10 cucumber features/
#
# put it to spec/support/deferred_garbage_collection_all_in_one.rb
# or feature/support/hooks.rb
class DeferredGarbageCollection
DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || -1).to_f
@d11wtq
d11wtq / let.js
Created Aug 18, 2012
RSpec style let() in Jasmine/Mocha
View let.js
/**
* Get RSpec-style let() in your Mocha/Jasmine specs.
*/
var let = function (callback) {
var value, called = false;
var memoizer = function() {
if (called) {
return value;
} else {
called = true;
View gist:3444459
# no config
Time.now is localtime
1.second.from_now is UTC
Timestamp stored in UTC
AR not translated
Time.now: Fri Aug 24 10:22:25 +0930 2012
1.second.from_now 2012-08-24 00:52:26 UTC
@barockok
barockok / saad_al_ghamidi.rb
Last active Jun 10, 2016
Al-quran 30 Juz 114 surah downloader reciter : Saad Al Ghamidi
View saad_al_ghamidi.rb
require 'mechanize'
require 'nokogiri'
require 'active_support/all'
class SaadAlGhamidi
def initialize
@page_agent = Mechanize.new
@file_agent = Mechanize.new
@file_agent.pluggable_parser.default = Mechanize::Download
end
You can’t perform that action at this time.