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:7953509c52524a466fe4
[1] pry(main)> class Fixnum
[1] pry(main)* def !=(o)
[1] pry(main)* true
[1] pry(main)* end
[1] pry(main)* end
=> :!=
View gist:17b7f858629916931769
[1] pry(main)> class Fixnum
[1] pry(main)* def +(o)
[1] pry(main)* o
[1] pry(main)* end
[1] pry(main)* end
=> :+
[1] pry(main)> 2 + 5
=> 5
View gist:91e4e8db411bd5ed550d
[12] development(main)> class A
[12] development(main)* def !@
[12] development(main)* 'sup'
[12] development(main)* end
[12] development(main)* end
=> :!
[13] development(main)> !A.new
=> "sup"
View gist:9bc2b97954a9983d536a
$('svg').each(function(i, e) {
var currentClass = e.getAttribute('class');
e.setAttribute('class', currentClass + ' newClass');
});
View gist:11197688
~/git_repos/rayons (upgrade) 🐖 bundle exec mutant -r ./config/environment Item
Mutant configuration:
Matcher: #<Mutant::Matcher::Scope cache=#<Mutant::Cache> scope=Item(id: integer, title: text, artist: text, year: integer, label: text, format: text, condition: text, price_paid: text, created_at: datetime, updated_at: datetime, color: text, deleted: boolean, discogs_url: text)>
Strategy: #<Mutant::Strategy::Null>
Expect Coverage: 100.000000%
Cannot find definition of: Item._create_callbacks in /usr/local/var/rbenv/versions/rbx-2.2.6/gems/gems/activesupport-4.1.0/lib/active_support/core_ext/class/attribute.rb:86
Cannot find definition of: Item._save_callbacks in /usr/local/var/rbenv/versions/rbx-2.2.6/gems/gems/activesupport-4.1.0/lib/active_support/core_ext/class/attribute.rb:86
Cannot find definition of: Item._update_callbacks in /usr/local/var/rbenv/versions/rbx-2.2.6/gems/gems/activesupport-4.1.0/lib/active_support/core_ext/class/attribute.rb:86
Cannot find definition of: Item._validate_ca
@gdiggs
gdiggs / tempserver.go
Created Apr 16, 2014
One Line Go server to serve static assets from current folder
View tempserver.go
echo "package main; import \"net/http\"; import \"os\"; import \"os/exec\"; import \"os/signal\"; func main() { go func() { sigchan := make(chan os.Signal, 2); signal.Notify(sigchan, os.Interrupt); <-sigchan; cmd := exec.Command(\"rm\", \"tempserver.go\"); cmd.Run(); os.Exit(0) }(); panic(http.ListenAndServe(\":8000\", http.FileServer(http.Dir(\".\")))) }" > tempserver.go && go run tempserver.go
View gifs.rb
require 'typhoeus'
class Array; def in_groups(num_groups)
return [] if num_groups == 0
slice_size = (self.size/Float(num_groups)).ceil
self.each_slice(slice_size).to_a
end; end
gifs = []
threads = []
@gdiggs
gdiggs / gist:7565902
Created Nov 20, 2013
Kelly's Stuffed Mushrooms
View gist:7565902

Ingredients

  • 20ish large mushrooms (baby bellas)
  • ½ bunch chopped green onions
  • 16 oz. container of chopped clams (they have frozen ones at whole foods)
  • 2-3 cloves minced garlic
  • 1/2 cup seasoned bread crumbs
  • pinch of black pepper
  • tablespoon of dried parsley
  • some basil and oregano
View gist:7112727
-----> Ruby/Rails app detected
-----> Using Ruby version: ruby-2.1.0-rbx-2.1.1
-----> Installing dependencies using Bundler version 1.4.0.rc.1
Ruby version change detected. Clearing bundler cache.
Old: rubinius 2.0.0.m8 (1.9.3 0849828f 2013-08-02 JI) [x86_64-unknown-linux-gnu]
New: rubinius 2.1.1 (2.1.0 be67ed17 2013-10-18 JI) [x86_64-linux-gnu]
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
An exception occurred running vendor/bundle/rbx/2.1/bin/bundle:
@gdiggs
gdiggs / test_response_speed.rb
Created Sep 16, 2013
Test response speed (somewhat poorly)
View test_response_speed.rb
#!/usr/bin/env ruby
# Given a URL, hit it a bunch of times and record the time it takes
# please dont use this for DDOS
TRIALS = 100
url = ARGV[0]
if !url
You can’t perform that action at this time.