Skip to content

Instantly share code, notes, and snippets.

View metaskills's full-sized avatar
🐙
Being Inkcellent to Each Other

Ken Collins metaskills

🐙
Being Inkcellent to Each Other
View GitHub Profile
@KevinTriplett
KevinTriplett / capybara_wait_until.rb
Last active December 14, 2015 12:38
Adding back the #wait_until to Capybara v2+ gem. Can probably be adapted for cucumber tests.
# add this file capybara_wait_until.rb to your /test directory
module Capybara
class Session
##
#
# Retry executing the block until a truthy result is returned or the timeout time is exceeded
#
# @param [Integer] timeout The amount of seconds to retry executing the given block
#
@pragdave
pragdave / gist:4981930
Created February 19, 2013 00:13
The Ruby 2 prepend() method makes method chaining a lot easier.
module SystemHook
private
def system(*args)
super.tap do |result|
puts "system(#{args.join(', ')}) returned #{result.inspect}"
end
end
end
class Object
@domenic
domenic / interop.md
Last active July 7, 2022 19:47
`module.exports =` and ES6 Module Interop in Node.js

module.exports = and ES6 Module Interop in Node.js

The question: how can we use ES6 modules in Node.js, where modules-as-functions is very common? That is, given a future in which V8 supports ES6 modules:

  • How can authors of function-modules convert to ES6 export syntax, without breaking consumers that do require("function-module")()?
  • How can consumers of function-modules use ES6 import syntax, while not demanding that the module author rewrites his code to ES6 export?

@wycats showed me a solution. It involves hooking into the loader API to do some rewriting, and using a distinguished name for the single export.

This is me eating crow for lots of false statements I've made all over Twitter today. Here it goes.

@ryandotsmith
ryandotsmith / hack-reactor.md
Last active November 24, 2022 07:01
Hack Reactor Talk

Tales From a Heroku User

Here are some things I have learned along the way.

Last Updated: 2013-02-08

Original Audience: Hack Reactor

About

@metaskills
metaskills / bug.rb
Last active December 15, 2015 16:38
# Odd behavior in BigDecimal's util for Float#to_d
# on Ruby 1.9.3 and 2.0?
#
require 'bigdecimal'
require 'bigdecimal/util'
puts "85.26.to_d.to_s('F') # => #{85.26.to_d.to_s('F')}"
puts "BigDecimal.new('85.26').to_s('F') # => #{BigDecimal.new('85.26').to_s('F')}"
oddities = ('0.00'..'99.99').to_a.select do |v|
@metaskills
metaskills / gist:4065702
Last active September 2, 2016 22:17
Example Of Other/Legacy DB Connection Management & Query Cache
# Assuming you champioin your other DB connection with a class.
module OtherDb
class Connection < ActiveRecord::Base
establish_connection :other_db
self.abstract_class = true
end
end
# Alway use the connection for other/legacy connections.
@adamlogic
adamlogic / compass_and_css_sprites.md
Created September 1, 2012 15:26
Compass and CSS Sprites, Explained

Compass and CSS Sprites, Explained

Last week I attempted to use the CSS sprites feature of Compass for the second or third time. It's been a struggle each time, but the power and potential is there, so I keep coming back. This time was a bit different, though, because I finally decided to stop relying on the docs and dive into the code.

Before I go into the nitty-gritty, let's take a step back and talk about why I

@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@mperham
mperham / after.rb
Created July 4, 2012 19:30
Thread-friendly shared connection
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || ConnectionPool::Wrapper.new(:size => 1) { retrieve_connection }
end
end
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
(function($){
var insertAtCaret = function(value) {
if (document.selection) { // IE
this.focus();
sel = document.selection.createRange();
sel.text = value;
this.focus();
}
else if (this.selectionStart || this.selectionStart == '0') {
var startPos = this.selectionStart;