Skip to content

Instantly share code, notes, and snippets.

Avatar
😎

Mike Auclair mikeauclair

😎
View GitHub Profile
View a_bit_better.rb
require 'ruby-prof'
def profile_as(name)
if ENV['PROFILE']
RubyProf.start
yield
result = RubyProf.stop
@mikeauclair
mikeauclair / output.txt
Created Jan 4, 2017
Promise union type
View output.txt
± ./node_modules/.bin/flow check 039efe8|add_more_types*
test.js:18
18: getQQ().then(function(val){
^^^^ property `then`. Property not found in
18: getQQ().then(function(val){
^^^^^^^ Array
Found 1 error
View createResolvedPromise_issue.js
describe('example', function() {
beforeEach(function(){
var scheduler = this.scheduler = new Rx.TestScheduler();
this.userEmails = this.scheduler.createHotObservable(
Rx.ReactiveTest.onNext(
210,
{email: 'bob@bob.com'}
),
View keybase.md

Keybase proof

I hereby claim:

  • I am mikeauclair on github.
  • I am mikeauclair (https://keybase.io/mikeauclair) on keybase.
  • I have a public key whose fingerprint is 783C 1A28 9EE3 A88F BE4C 0FFB E2C7 0FC4 D157 FFB3

To claim this, I am signing this object:

View bundlebench.rb
#!/usr/bin/env ruby
require 'benchmark'
REGEXPS = [
/^no such file to load -- (.+)$/i,
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
/^Missing API definition file in (.+)$/i,
/^cannot load such file -- (.+)$/i,
]
@mikeauclair
mikeauclair / gist:de976a2baeb182bdee61
Last active Aug 29, 2015
Post-punk, mod revival, UK New Wave
View gist:de976a2baeb182bdee61

1977

  • The Clash - The Clash
  • Elvis Costello - My Aim Is True
  • The Jam - In the City
  • The Jam - This Is the Modern World
  • Wire - Pink Flag

1978

  • The Clash - Give 'Em Enough Rope
  • Elvis Costello & The Attractions - My Aim Is True
@mikeauclair
mikeauclair / person.scm
Created Jan 18, 2014
Closures are poor man's objects. Objects are poor man's closures.
View person.scm
(define person (lambda (first last)
(define setFirst (lambda (value) (set! first (list-ref value 0))))
(define setLast (lambda (value) (set! last (list-ref value 0))))
(lambda (method . args)
(case method
('first
(if (null? args)
first
(setFirst args)
)
View ProfilingGuide.md

Easy steps for CPU profiling a Rails app

  1. add ruby-prof to your gemfile (https://github.com/ruby-prof/ruby-prof)
  2. grab kcachegrind or qcachegrind (brew install qcachegrind graphviz on os x)
  3. plop development_profiler.rb in lib in your app
  4. wrap your questionable code in a prof block
  5. open the file in qcachegrind (It'll live in tmp/performance in your app)
View gist:5678358
class Account
#blahblah
def external_management
if appdirect?
@external_management ||= OpenStruct.new(:user_url => 'blah', :accont_url => 'blah')
end
end
#blahblah
end
View gist:5586098
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection