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
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 / 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 => []
}
<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: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)
@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."
class Comment < ActiveRecord::Base
#...
validates_uniqueness_of :body
# ...
end
@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?
// 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; }">');
{"contributors":null,"text":"just testing, dont mind me","geo":null,"place":null,"in_reply_to_screen_name":null,"favorited":false,"source":"web","in_reply_to_user_id":null,"coordinates":null,"created_at":"Wed Jul 28 06:44:15 +0000 2010","user":{"lang":"en","profile_use_background_image":true,"profile_sidebar_fill_color":"efefef","following":null,"geo_enabled":false,"followers_count":106,"location":"San Diego, CA","verified":false,"profile_sidebar_border_color":"eeeeee","follow_request_sent":null,"notifications":null,"friends_count":88,"description":"Bleeding edge Web Applications Developer","favourites_count":0,"profile_background_color":"131516","url":"http://chrischerry.name","profile_image_url":"http://a1.twimg.com/profile_images/94668409/redfeedicon_528_normal.png","listed_count":7,"profile_background_image_url":"http://s.twimg.com/a/1279056489/images/themes/theme14/bg.gif","time_zone":"Pacific Time (US & Canada)","profile_text_color":"333333","protected":false,"statuses_count":2224,"created_at":"Thu Mar
/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i