Skip to content

Instantly share code, notes, and snippets.

View unimatrixZxero's full-sized avatar
🌱
💎

Sam Figueroa unimatrixZxero

🌱
💎
View GitHub Profile
module ArrayInquirer
def method_missing method, *args
begin
select { |elem| elem.send :"#{method}?", *args }
rescue NoMethodError
super method, *args
end
end
end
@unimatrixZxero
unimatrixZxero / a.md
Created August 23, 2012 06:28 — forked from rkh/a.md

This allows you to use the following video streaming services outside of the US from your Mac without having to use a proxy or VPN, so no big bandwidth issues:

  • Netflix
  • Hulu / HuluPlus
  • CBS
  • ABC
  • MTV
  • theWB
  • CW TV
  • Crackle
module Abyss
ROUNDTRIP = {}.tap { |abyss| abyss.default = abyss }.freeze
def to_abyss(obj = self)
case obj
when Hash
obj.inject({}) { |h,(k, v)| h.update k => to_abyss(v) }.tap { |h| h.default = ROUNDTRIP }
when Array
obj.map { |e| to_abyss(e) }
else
obj
@mindreframer
mindreframer / cleanup_rails_views.rb
Created July 26, 2012 01:13
Cleanup views with tidy (erb)
require 'tidy'
#Tidy.path = '/opt/local/lib/libtidy.dylib' # or where ever your tidylib resides
Tidy.path = '/usr/lib/libtidy.A.dylib'
def generate(files)
tidy = Tidy.open(:show_warnings=>true) do |tidy|
tidy.options.indent = 'auto'
tidy.options.show_body_only = true
tidy.options.output_xhtml = true
# vim FTW
Pry.config.editor = "mvim"
# Prompt with ruby version
Pry.prompt = [proc { |obj, nest_level| "#{RUBY_VERSION} (#{obj}):#{nest_level} > " }, proc { |obj, nest_level| "#{RUBY_VERSION} (#{obj}):#{nest_level} * " }]
if defined?(Rails) && Rails.env
begin
extend Rails::ConsoleMethods if defined?(Rails::ConsoleMethods)
require "rails/console/app"
@vitobotta
vitobotta / resque-recovery.sh
Created May 24, 2012 18:53
Resque: automatically kill stuck workers and retry failed jobs
#!/bin/bash
# Also see: http://vitobotta.com/resque-automatically-kill-stuck-workers-retry-failed-jobs/
[[ -f /tmp/retry-failed-resque-jobs ]] && rm /tmp/retry-failed-resque-jobs
ps -eo pid,command |
grep [r]esque |
grep "Processing" |
while read PID COMMAND; do
@perliedman
perliedman / README.markdown
Created March 26, 2012 12:17 — forked from jrust/README.markdown
Bootstrap's Typeahead plugin extended (AJAX functionality, comma-separated values, autowidth, and autoselect)

This is a fork of a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

  • Support for delaying the lookup (good for preventing too many AJAX requests)
  • Some fixes regarding the data fed to the onselect callback

For the proper source, and other examples, please see the original gist and the extended version

Example showing off all the above features

@coreyhaines
coreyhaines / .rspec
Last active April 11, 2024 00:19
Active Record Spec Helper - Loading just active record
--colour
-I app
/* jQuery Radiofy
* ==============
* Turns a select into a hidden text input and
* a set of radio buttons that resemble the options.
* This is used to enable client_side_validations for radio buttons.
* ---
* Daniel Kirsch
* (c) 2012 Zweitag GmbH
*/
(function($){
@bkimble
bkimble / gist:1365005
Last active May 2, 2024 01:27
List local memcached keys using Ruby
#!/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'
headings = %w(id expires bytes cache_key)
rows = []