Skip to content

Instantly share code, notes, and snippets.

@diegorv
diegorv / have_named_scope.rb
Created August 24, 2011 19:37 — forked from bcardarella/have_named_scope.rb
Should Have Named Scope matcher for Rspec
module Shoulda # :nodoc:
module ActiveRecord # :nodoc:
# Examples:
# class Book < ActiveRecord::Base
# named_scope :test, :conditions => { :name => "test" }
# named_scope :by_name, lambda { |n| { :conditions => { :name => n} } }
# end
#
# RSpec:
@brookr
brookr / config.ru
Created April 16, 2012 04:36
Rackup file I use for running WordPress on Pow
# config.ru for Pow + Wordpress, based on http://stuff-things.net/2011/05/16/legacy-development-with-pow/
# added hackery to work around wordpress issues - Patrick Anderson (patrick@trinity-ai.com)
# clearly this could be cleaner, but it does work
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
# patch Php from rack-legacy to substitute the original request so
# WP's redirect_canonical doesn't do an infinite redirect of /
@jondkinney
jondkinney / pivotal_tracker_git_flow.rake
Created May 3, 2012 07:04
Allows listing pivotal tracker stories and selecting one to start a new git flow feature or hotfix
require "rubygems"
require "pivotal-tracker"
namespace :pt do
desc "list avail pivotal tracker tix from which to create a git fea branch"
task :list do
def truncate_words(text, length = 5)
return if text == nil
words = text.split()
words = words - %w(feature scenario for in on a an the of so that they be able to are it its with) #remove non critical words (experiment with this)
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active July 14, 2024 12:40
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
@nkbt
nkbt / .eslintrc.js
Last active May 11, 2024 13:03
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
@rbalman
rbalman / dump_memcache.rb
Last active August 2, 2019 19:48
Dumping and restoring the memcache key values using telnet & dalli gem
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
require 'csv'
headings = %w(id expires bytes key)
rows = []