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
package main
import (
"encoding/json"
"fmt"
)
var jsonStr = []byte(`
{
"things": [
@dacort
dacort / leavenotifications.rb
Created June 14, 2011 17:56
Twitter Mass Notification Disable
client = Grackle::Client.new(:auth => {
:type => :oauth,
:consumer_key => CONSUMER_KEY, :consumer_secret => CONSUMER_SECRET,
:token => TOKEN, :token_secret => TOKEN_SECRET
})
users = []
(client.friends.ids?).each_slice(100) do |uids|
users |= (client.users.lookup? :user_id => uids.join(','))
end
@dacort
dacort / gist:770242
Created January 7, 2011 22:46
#BSidesSF Poem
Twas the night before #BSidesSF, when all through the tubes
Not a hacker was stirring, not even the newbs;
Twas the night before launch, when all through the server
Not a process was stirring, not even a crawler;
The init scripts were stored in rc.d,
In hopes that the sys admin soon would be free;
The Damon was nestled all snug in his bed,
While visions of multi-tenant architecture danced in his head;
And nginx all configured, and cap deploy at the ready,
#mongostat
insert/s query/s update/s delete/s getmore/s command/s mapped vsize res % locked % idx miss conn time
0 0 0 0 0 1 468876 469281 5763 0.998 0 1 12:58:06
0 0 0 0 0 1 468876 469281 5764 0.991 0.0417 1 12:58:07
0 0 0 0 0 1 468876 469281 5765 1 0 1 12:58:08
0 0 0 0 0 1 468876 469281 5765 1.01 0 1 12:58:10
0 0 0 0 0 1 468876 469281 5766 0.997 0 1 12:58:11
0 0 0 0 0 1 468876 469281 5766 0.811 0 1 12:58:12
0 0 0 0 0 1 468876 469281 5767 0.997 0 1 12:58:13
0 0 0 0 0 1 468876 469281 5767 1 0 1 12:58:14
# In here, we monkey-patch Net::SSH. Beware, there be dragons.
# Net::SSH can add hosts to the known_hosts file, but can't remove
module Net; module SSH
class KnownHosts
# Looks in all user known host files (see KnownHosts.hostfiles) and tries to
# remove an entry for the given host and key to the first file it is able to.
def self.remove(host, options={})
hostfiles(options, :user).each do |file|
begin
javascript:$.getJSON("http://twitter.com/statuses/user_timeline.json?screen_name="+$("meta[name='page-user-screen_name']").attr('content')+"&include_rts=true&count=100", function(data){e = new Date(data[0]['created_at']); s = new Date(data[data.length - 1]['created_at']); alert(Math.round(data.length/((e-s)/(1000*60*60*24))) + " tweets/day.")});void(0);
riak-0.9.1 dpc$ bin/riak start
dyld: unknown required load command 0x80000022
dyld: unknown required load command 0x80000022
bin/riak: line 51: 81400 Trace/BPT trap $ERTS_PATH/run_erl -daemon $PIPE_DIR $RUNNER_LOG_DIR "exec $RUNNER_BASE_DIR/bin/$SCRIPT console" 2>&1
require 'rubygems'
require 'yajl/http_stream'
require 'uri'
require 'open-uri'
USERNAME = 'username'
PASSWORD = 'password'
# If you've got a ton of either, you'll have to fork and cursor through
fr_ids = Yajl::HttpStream.get(URI.parse("http://#{USERNAME}:#{PASSWORD}@api.twitter.com/1/friends/ids/#{USERNAME}.json"))
# This example shows how to setup an environment with a 'riak' gem set
# running Rails 3 (beta) + ripple (for riak) under ruby 1.9.1 .
∴ rvm update --head
# ((Open a new shell))
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.1
# Use the ruby + gem set