Skip to content

Instantly share code, notes, and snippets.

View ctcherry's full-sized avatar
🎯
Rusty Gopher

Chris Cherry ctcherry

🎯
Rusty Gopher
View GitHub Profile
// Oneliner JS to add project search to any public github project
$($('.title-actions-bar')[0]).after('Search In Project: <input type="text" onKeyUp="if (event.keyCode == 13) { window.location.href=$($(\'.title-actions-bar h1 strong a\')[0]).attr(\'href\') + \'/search?q=\' + this.value; }">');
@ctcherry
ctcherry / gist:726194
Created December 2, 2010 22:16
Hash combinations
# Get array with all of the combinations of key=>value pairs from an input hash, taking 1 at a time when the value of a pair is an array
def attribute_combinations(original_hash)
field_varitions = []
original_hash.each do |key, value|
if value.is_a?(Array)
field_varitions << {:key => key, :values => value}
end
end
return original_hash if field_varitions.empty?
class Comment < ActiveRecord::Base
#...
validates_uniqueness_of :body
# ...
end
@ctcherry
ctcherry / gist:965261
Created May 10, 2011 20:03
scrabble word finder
require 'rubygems'
require 'raspell'
speller = Aspell.new('en_US')
input = "BLPONEA"
options = input.split('').permutation(5).collect { |*args| args[0].join('') }
puts "Given '#{input}', there are #{options.size} possible combinations of letters."
@ctcherry
ctcherry / gist:1133201
Created August 9, 2011 01:09
VLC deamon command line control with stream bookmarks
#!/usr/bin/ruby
require 'yaml'
require 'socket'
list_file = "~/.music"
vlc_socket = "/tmp/vlc.sock"
vlc_path = "/Applications/VLC.app/Contents/MacOS/VLC"
list_file = File.expand_path(list_file)
<div id="footer-bg">
<div id="footer">
<p align="center"><img src="/images/footer-logos.jpg" alt=""></p>
<ul>
<li class="first"><a href="/" title="Pompano Beach and Coconut Creek - General, Cosmetic, and Restorative Dentistry">Home</a></li>
<li><a href="/html/practice.html" title="About Our Broward County Practice - Cosmetic Dentist Manon Bourque Hutchison, D.D.S.">About the Practice</a></li>
<li><a href="/html/cosmetic-dentistry.html" title="Cosmetic Dentistry - Improve Your Smile with a Dental Makeover">Cosmetic Dentistry</a></li>
<li><a href="/html/restorative-dentistry.html" title="Restorative Dentistry - Repair and Restore Your Teeth">Restorative Dentistry</a></li>
<li><a href="/html/general-dentistry.html" title="General Dentistry - TMJ, Periodontal, and Preventive Care ">General Dentistry</a></li>
<li><a href="/html/impla
@ctcherry
ctcherry / gist:1270878
Created October 7, 2011 17:34
httpgrep - Work with the response codes of URLs from STDIN
#!/usr/bin/env ruby
require 'optparse'
require 'net/http'
require 'uri'
options = {
:annotate => false,
:exclude => []
}
SET @rows = 5;
SET @c = (SELECT COUNT(id) FROM table);
SET @c = @c - @rows;
SET @s = CONCAT("SELECT * FROM table LIMIT ", @c, ",", @rows);
PREPARE stmt FROM @s;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
@ctcherry
ctcherry / iOSclass
Created February 1, 2012 18:28 — forked from KruegerDesigns/ios.html.class.js
Add mobile class to html tag for mobile devices along with the mobile type if known
// adds mobile class, and mobile os to html tag
jQuery(document).ready(function($){
var deviceAgent = navigator.userAgent.toLowerCase();
if (deviceAgent.match(/(iphone|ipod|ipad)/)) {
$('html').addClass('ios');
$('html').addClass('mobile');
}
if (deviceAgent.match(/android/)) {
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}["
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}]"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}"
#Customized git status, oh-my-zsh currently does not allow render dirty status before branch
git_custom_status() {
local cb=$(current_branch)
if [ -n "$cb" ]; then
echo "$ZSH_THEME_GIT_PROMPT_PREFIX$(parse_git_dirty)$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX"