Skip to content

Instantly share code, notes, and snippets.

Gordon Diggs gdiggs

Block or report user

Report or block gdiggs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:5160c6e18e9f684eeddf
irb(main):001:0> defined? Object
=> "constant"
irb(main):002:0> defined? Foo
=> nil
irb(main):003:0> defined? bar
=> nil
irb(main):004:0> bar = "sup"
=> "sup"
irb(main):005:0> defined? bar
=> "local-variable"
@gdiggs
gdiggs / gist:c3052f6f91d77d8ad63a
Created Dec 29, 2014
Clear out modqueue on reddit
View gist:c3052f6f91d77d8ad63a
var clickFirst = function() {
var $link = $('.pretty-button.positive:not(.pressed):first');
if($link.length > 0) {
console.log("clicking");
$link.click();
} else {
console.log("no more links");
}
};
@gdiggs
gdiggs / caveatPatchor.js
Created Jan 27, 2015
GIFV Support for Propane
View caveatPatchor.js
/*
From https://gist.github.com/GordonDiggs/9d9eb3007055fa04f0c4
Add this to your caveatPatchor.js file
(located at ~Library/Application Support/Propane/unsupported/caveatPatchor.js)
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
@gdiggs
gdiggs / wfmu.rb
Last active Aug 29, 2015
Get current song and show on WFMU
View wfmu.rb
require 'nokogiri'
require 'open-uri'
url = 'http://wfmu.org/currentliveshows_aggregator.php?ch=1,4,6,7,8&_=1422680555670'
body = open(url)
document = Nokogiri::HTML(body)
song = document.css('.bigline')[0].text.gsub(/[\n\r]/, ' ').strip
show = document.css('.smallline')[0].text.gsub(/[\n\r]/, ' ').strip
View get_weather.rb
require 'weather-api'
woeid = '12761740'
response = Weather.lookup(woeid, Weather::Units::FARENHEIT)
puts "#{response.condition.temp}\u00B0 #{response.condition.text}"
@gdiggs
gdiggs / results
Created Feb 28, 2015
Testing Hash[] instead of #dup
View results
require 'benchmark/ips'
def quux(hash_arg)
hash_arg = hash_arg.dup
10.times { |i| hash_arg.merge!({ "num_#{i}" => i }) }
end
def corge(hash_arg)
hash_arg = Hash[hash_arg]
10.times { |i| hash_arg.merge!({ "num_#{i}" => i }) }
@gdiggs
gdiggs / results
Last active Aug 29, 2015
Adding deep_dup testing
View results
Calculating -------------------------------------
dup 5.339k i/100ms
deep_dup 4.367k i/100ms
Hash[] 5.156k i/100ms
-------------------------------------------------
dup 54.493k (± 7.2%) i/s - 272.289k
deep_dup 45.231k (± 9.1%) i/s - 227.084k
Hash[] 59.868k (± 7.5%) i/s - 299.048k
Comparison:
View theme.terminal
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlueColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NPECYw
LjExMTU1NjIxNzEgMC4xNDQyMDcxMDUgMC41ODIxMTkxNjY5ABABgALSEBESE1okY2xh
c3NuYW1lWCRjbGFzc2VzV05TQ29sb3KiEhRYTlNPYmplY3RfEA9OU0tleWVkQXJjaGl2
View backup.bat
@echo off
set drive=W:\BACKUP_docs
set musicdrive=W:\BACKUP_music
set backupcmd="C:\backup batches\wndsync.exe" /back /r /auto /showA
set cleancmd="C:\backup batches\dirclean.exe" -r -d -s
echo Started Backup: %date% - %time% >> w:\logs\backup.txt
echo ### Backing up Home Folder...
%cleancmd% -i "%drive%"
View Contacts Gem AOL Fix
# lines 11-14 of aol.rb from contacts gem
AOL_NUM = "32319-211" # this seems to change each time they change the protocol
CONTACT_LIST_URL = "http://mail.aol.com/#{AOL_NUM}/aol-6/en-us/Lite/ContactList.aspx?folder=Inbox&showUserFolders=False"
CONTACT_LIST_CSV_URL = "http://mail.aol.com/#{AOL_NUM}/aol-6/en-us/Lite/ABExport.aspx?command=all"
You can’t perform that action at this time.