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

Keybase proof

I hereby claim:

  • I am dacort on github.
  • I am dacort (https://keybase.io/dacort) on keybase.
  • I have a public key whose fingerprint is 0931 E57B 9A91 8338 5B93 201B F594 2FCD 9F8D 1C6D

To claim this, I am signing this object:

@dacort
dacort / gist:f480bb3b99817dbbefdb
Created April 23, 2015 06:19
Extract Github URL counts from Chrome history
sqlite3 ~/Library/Application\ Support/Google/Chrome/Default/History "SELECT date(visit_time/1000000-11644473600, 'unixepoch'),urls.url,count(*) FROM visits INNER JOIN urls ON visits.url = urls.id WHERE urls.url LIKE '%github.com/%' GROUP BY date(visit_time/1000000-11644473600, 'unixepoch'),urls.url ORDER BY date(visit_time/1000000-11644473600, 'unixepoch') DESC,count(*);"
--- 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) {
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:...]