Skip to content

Instantly share code, notes, and snippets.

@dkordik
dkordik / Terminal.sublime-settings
Created May 2, 2012 15:36
Sublime Text 2 Terminal config with Console2/cygwin/bash to open a terminal in the current directory
{
"terminal": "C:/Program Files/Console2/Console.exe",
// In Console2 "Shell" section, have just "bash" with no args in a profile called "Terminal"
"parameters": ["-t", "Terminal", "-r", "/bin/xhere /bin/bash.exe", "`%CWD%`"]
}
@dkordik
dkordik / Terminal.sublime-settings
Created May 3, 2012 18:02
Sublime Text 2 Terminal config with mintty/cygwin/bash to open a terminal in the current directory
{
"terminal": "C:/cygwin/bin/mintty.exe",
"parameters": ["/bin/env", "CHERE_INVOKING=1", "/bin/xhere", "/bin/bash", "`%CWD%`"]
}
@dkordik
dkordik / highlightCompleted.js
Created May 29, 2012 06:04
Ebay completed listings: make unsold items REALLY red and sold items REALLY green. to see what's gettin bought!
$(".binsold").each(function () {$(this).closest("td").css("backgroundColor","red")});
$(".bidsold").each(function () {$(this).closest("td").css("backgroundColor","green")});
@dkordik
dkordik / pitchforkfestival2012bands.js
Created July 5, 2012 22:59
Pitchfork Festival 2012 bands
//http://pitchfork.com/festivals/chicago/2012/
$(".appearance a").map(function () { return $(this).html().split("<")[0].trim() })
@dkordik
dkordik / ackref.rb
Created November 21, 2012 15:25
Check if each JS file is referenced in our Views, log unreferenced and referenced files - ACK required
#!/usr/bin/env ruby
class String
def -(other)
self.index(other) == 0 ? self[other.size..self.size] : nil
end
end
if ARGV.length < 2
puts
@dkordik
dkordik / .bash_profile
Created November 26, 2012 23:03
Bash profile to set up SSH authentication only once per session for environments like Cygwin that suck at using SSH keys and normally require you to type in your password every time you authenticate
SSH_ENV="$HOME/.ssh/environment"
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV"
echo succeeded
chmod 600 "$SSH_ENV"
. "$SSH_ENV" > /dev/null
@dkordik
dkordik / nowplaying.rb
Created December 6, 2012 08:49
Sniff network for iTunes #nowplaying mDNS announces via ngrep. Requires Ruby 1.9 for the awesome named-group regexes. Expand to do interesting things based on what you're playing.
match = 'nowplaying'
ngrep_command = "ngrep -W byline '#{match}' port 5353"
puts "Watching network for iTunes mDNS #nowplaying announces..."
IO.popen(ngrep_command).each do |line|
if line.match(/\##{match}/)
pattern = /nowplaying-title=(?<title>[\w ]+).+nowplaying-artist=(?<artist>[\w ]+).+nowplaying-album=(?<album>[\w ]+)/
@dkordik
dkordik / nowplaying-store.rb
Created December 6, 2012 09:12
Sniff network for iTunes Store updateNowPlaying requests via ngrep. Expand to do interesting things based on what you're playing.
require 'cgi'
match = 'track.updateNowPlaying'
ngrep_command = "ngrep -W byline '#{match}'"
puts "Watching network for iTunes Store now playing previews..."
IO.popen(ngrep_command).each do |line|
if line.match(/\=#{match}/)
@dkordik
dkordik / dupeids.js
Created January 21, 2013 21:29
Smoke test for dupe CSS IDs
var dupeIds = [], dupeIdsString;
$('[id]').each(function(){
var ids = $('[id="' + this.id + '"]');
if (ids.length > 1 && ids[0] == this) {
dupeIds.push(this.id);
}
});
dupeIdsString = dupeIds.concat(", ");
@dkordik
dkordik / git-repo-merging.sh
Last active December 14, 2015 22:09
An example of merging 3 git repos into 1, and preserving all the history.
#setting the stage... creating 3 separate repos
mkdir animals; cd animals/; echo "Animals" > README; git init; git add .; git commit -m "Animals readme"; cd ..
mkdir dogs; cd dogs/; echo "Dogs" > README; git init; git add .; git commit -m "Dogs readme"; cd ..
mkdir cats; cd cats/; echo "Cats" > README; git init; git add .; git commit -m "Cats readme"; cd ..
#putting stuff in boxes for the move...
cd cats; mkdir cats #making /cats inside of cats, because in /animals we want /cats to be a subdir
git mv README cats #this line needs to me more appropriate to the contents of your actual child repo
git commit -m "Prepare cats for merge into animals"; cd ..