Skip to content

Instantly share code, notes, and snippets.

Dan Sosedoff sosedoff

Block or report user

Report or block sosedoff

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
@sosedoff
sosedoff / gs-favorites.rb
Created Mar 19, 2011
Download your grooveshark favorites
View gs-favorites.rb
require 'rubygems'
require 'grooveshark'
gs = Grooveshark::Client.new
user = gs.login('USER', 'PASSWORD')
user.favorites.each do |s|
name = "#{s.id}_#{s.artist} - #{s.name}"
puts name
url = gs.get_song_url(s)
View genpassword
#!/bin/bash
charspool=('a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p'
'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z' '0' '1' '2' '3' '4' '5' '6' '7'
'8' '9' '0' 'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O'
'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z' '-' '_');
len=${#charspool[*]}
if [ $# -lt 1 ]; then
@sosedoff
sosedoff / restrict.rb
Created Apr 10, 2011
Rake middleware to bounce off mobile devices and bots
View restrict.rb
module Rack
class Restrict
REGEX_MOBILE = /(blackberry|motorokr|motorola|sony|windows ce|240x320|176x220|palm|mobile|iphone|ipod|symbian|nokia|samsung|midp)/i
REGEX_BOTS = /(google|yahoo|baidu|bot|webalta|ia_archiver)/
attr_reader :options
def initialize(app)
@app = app
end
@sosedoff
sosedoff / sphinxclient.c
Created Apr 19, 2011
Sphinxclient.c path
View sphinxclient.c
__END__
--- a/api/libsphinxclient/sphinxclient.c
+++ b/api/libsphinxclient/sphinxclient.c
@@ -277,7 +277,7 @@
}
-void sock_close ( int sock );
+static void sock_close ( int sock );
@sosedoff
sosedoff / text_markup.rb
Created May 10, 2011
TextMarkup module for Ruby 1.9.2
View text_markup.rb
require 'RedCloth'
require 'rdiscount'
require 'rdoc/markup/to_html' # ruby1.9.2 specific
module TextMarkup
extend self
# Auto-detect format from filename and render content
def render(filename, content)
name = File.basename(filename.to_s.strip)
@sosedoff
sosedoff / google2.rb
Created May 19, 2011
Goole OAuth2 omniauth strategy
View google2.rb
require 'omniauth/oauth'
require 'multi_json'
module OmniAuth
module Strategies
class Google2 < OAuth2
def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
client_options = {
:site => 'https://accounts.google.com/o/oauth2',
:authorize_url => 'https://accounts.google.com/o/oauth2/auth',
@sosedoff
sosedoff / agents.txt
Created Jun 27, 2011
List of unique user-agents
View agents.txt
-
./pma2/0.1 libwww-perl/5.805
Aghaven/Nutch-1.2
Baiduspider+(+http://www.baidu.com/search/spider.htm)
BlackBerry9000/4.6.0.167 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/102 ips-agent
BlackBerry9330/5.0.0.857 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/105
EMail Exractor
Gigabot/3.0 (http://www.gigablast.com/spider.html)
Gimmie60/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.11)
Googlebot-Image/1.0
@sosedoff
sosedoff / mkmf.log
Created Sep 7, 2011
charlock_holmes failed build
View mkmf.log
have_library: checking for main() in -licui18n... -------------------- yes
"/usr/bin/gcc-4.2 -o conftest -I/Users/sosedoff/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-darwin10.8.0 -I/Users/sosedoff/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/Users/sosedoff/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. -I/usr/local/Cellar/icu4c/4.4.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -fno-common -pipe conftest.c -L. -L/Users/sosedoff/.rvm/rubies/ruby-1.9.2-p290/lib -L/usr/local/Cellar/icu4c/4.4.1/lib -L. -L/usr/local/lib -lruby.1.9.1-static -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */
@sosedoff
sosedoff / rack_revision.rb
Created Dec 12, 2011
Add X-Revision headers from capistrano deployment
View rack_revision.rb
module Rack
class Revision
@@revision = nil
File = ::File
def initialize(app, &block)
@app = app
@block = block
@file = File.join(Dir.pwd, 'REVISION')
end
@sosedoff
sosedoff / yelp.rb
Created Feb 8, 2012
Fetch business price range from Yelp
View yelp.rb
require 'faraday'
module Yelp
PRICE_RANGE_REGEX = /<span id="price_tip" \b[^>]*>(.*?)<\/span>/i
def self.restaurant_price_range(id)
url = "http://www.yelp.com/biz/#{id}"
body = Faraday.get(url).body
body.scan(PRICE_RANGE_REGEX).flatten.first.to_s.length
end
You can’t perform that action at this time.