Skip to content

Instantly share code, notes, and snippets.

View jruby-block-super.rb
class A
def bar(*blah)
blah
end
end
class Foo < A
def bar(*)
no_commands { super }
end
@mjc
mjc / widgets.coffee
Created May 29, 2014
Sortable example for ember.js
View widgets.coffee
WidgetsController = Ember.ArrayController.extend
sortProperties: ["user.firstName"]
sortAscending: true
actions:
sortBy: (sortProperties) ->
old = @get("sortProperties")
@set "sortProperties", [sortProperties]
@toggleProperty "sortAscending" if sortProperties in old
return false
@mjc
mjc / Gemfile
Last active Aug 29, 2015 — forked from eirc/.rvmrc
Message format benchmarks
View Gemfile
source 'https://rubygems.org'
gem 'benchmark-ips'
gem 'json'
gem 'multi_json'
gem 'oj', platform: [:mri, :rbx]
gem 'yajl-ruby', platform: [:mri, :rbx], require: 'yajl'
gem 'jrjackson', platform: :jruby
gem 'gson', platform: :jruby
@mjc
mjc / gist:8786371
Created Feb 3, 2014
dtruss -- rbx -e 'puts "hi"'
View gist:8786371
dtrace: 12538 dynamic variable drops with non-empty dirty list
SYSCALL(args) = return
madvise(0x10180A000, 0x3000, 0x5) = 0 0
open("/dev/dtracehelper\0", 0x2, 0x7FFF5EF28100) = 3 0
ioctl(0x3, 0x80086804, 0x7FFF5EF28088) = 0 0
close(0x3) = 0 0
open("/dev/urandom\0", 0x20104, 0x2068) = 3 0
fstat64(0x3, 0x7FFF5EF27F30, 0x0) = 0 0
read(0x3, "\317\221\206\f\340\220T\263\364yz\276\026\001\241\212\0", 0x10) = 16 0
@mjc
mjc / config.ru
Last active Jan 3, 2016 — forked from ngs/config.ru
config.ru for running CakePHP apps under Pow. Includes an app/webroot rewrite and some other things from the rack-legacy example.
View config.ru
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
webroot = File.join(Dir.getwd,'app','webroot')
use Rack::Rewrite do
rewrite %r{/(.*)}, lambda { |match, rack_env|
File.exists?(File.join(webroot,match[1])) ? File.join('app','webroot',match[1]) : '/app/webroot/index.php/%s' % match[1]
}
View README.md

Setup

Add the following gems to your Gemfile:

gem 'activeresource'
gem 'newrelic_api'

Update your bundle:

@mjc
mjc / activemerchant.gemspec.diff
Created Jul 30, 2013
trying to add fake extension to activemerchant to allow conditionally requiring nokogiri based on ruby version at gem install time
View activemerchant.gemspec.diff
index 652e40c..233d9df 100644
--- a/activemerchant.gemspec
+++ b/activemerchant.gemspec
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
s.homepage = 'http://activemerchant.org/'
s.rubyforge_project = 'activemerchant'
- s.files = Dir['CHANGELOG', 'README.md', 'MIT-LICENSE', 'CONTRIBUTORS', 'gem-public_cert.pem', 'lib/**/*', 'vendor/**/*']
- s.require_path = 'lib'
+ s.files = Dir['CHANGELOG', 'README.md', 'MIT-LICENSE', 'CONTRIBUTORS', 'gem-public_cert.pem', 'lib/**/*', 'vendor/**/*', 'ext/nokogiri_conf.rb']
@mjc
mjc / gist:6029781
Created Jul 18, 2013
rbx error differences
View gist:6029781
class Moo
def self.moo
a = 50a
end
end
# require './moo.rb' in pry
# rbx:
# SyntaxError: /usr/local/rvm/rubies/rbx-head/runtime/melbourne.rbc:81: expecting keyword_end
# from /usr/local/rvm/rubies/rbx-head/runtime/melbourne.rbc:81:in `syntax_error'
@mjc
mjc / gist:6029403
Created Jul 18, 2013
fix for HTTParty in rbx 2.0 mode
View gist:6029403
diff --git a/lib/20/net/http.rb b/lib/20/net/http.rb
index fd8c802..2266617 100644
--- a/lib/20/net/http.rb
+++ b/lib/20/net/http.rb
@@ -321,7 +321,7 @@ module Net #:nodoc:
# HTTPResetContent:: 205
# HTTPPartialContent:: 206
# HTTPRedirection:: 3xx
- # HTTPMultipleChoice:: 300
+ # HTTPMultipleChoices:: 300
@mjc
mjc / jetpack-status.php
Created Apr 5, 2013
Super Quick PHP Script to print out status information for the Verizon MiFi JetPack 5510L
View jetpack-status.php
#!/usr/bin/env php
<?php
$statusurl = 'http://my.jetpack/srv/status';
/*
returned data looks like this:
array(
'notificationFlag' => 1,
'statusBarActivityVisible' => 1,