Skip to content

Instantly share code, notes, and snippets.

@ronny
ronny / check_box.js.coffee
Created August 17, 2014 05:04
ReactJS CheckBox component that works like Rails' `f.check_box`
_ = require('underscore')
React = require('React')
{span, input} = React.DOM
# Check box that always submits a value, even if unchecked. This uses the same
# trick as Rails's `f.check_box`: a hidden input with the same name as the
# checkbox but with a value of 0 that appears before the actual checkbox. When
# the checkbox is checked, the checkbox's value will be submitted, when it's
# unchecked, then the hidden input value of 0 will be submitted.
@ronny
ronny / fat-vs-thin-arrows.coffee
Last active August 29, 2015 14:04
The main difference between fat and thin arrows for instance methods in CoffeeScript
# Try running this in http://coffeescript.org 's "Try CoffeeScript" tab while having the DevTools console open.
class Foo
thin: (arg) ->
console.log 'thin', this, @value?(), arg
fat: (arg) =>
console.log 'fat', this, @value?(), arg
value: ->
'foobar'
@ronny
ronny / install-ruby-via-homebrew.sh
Last active December 29, 2015 09:49
Install ruby using rbenv, ruby-build, homebrew on Mac, with support for brew readline (history and unicode support on irb) and brew openssl.
brew update
brew install readline openssl rbenv ruby-build
# follow the instructions in `brew info rbenv` to set up rbenv
# or, if you already have those installed, just upgrade ruby-build to get the latest list of rubies
brew update
brew upgrade ruby-build
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta content="yes" name="apple-mobile-web-app-capable">
<title>iOS Web App</title>
<!-- iPhone -->
@ronny
ronny / ants.clj
Last active December 18, 2015 12:19 — forked from michiakig/ants.clj
Ant colony simulation written in Clojure by Rich Hickey, from his presentation on Clojure Concurrency – http://www.youtube.com/watch?v=dGVqrGmwOAw – modified by me to work in Clojure 1.5, and also to make it look nicer.
(ns ants)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
; which can be found in the file CPL.TXT at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
@ronny
ronny / gist:5035800
Last active February 10, 2016 19:05
Nokogiri with libxml2 installed via homebrew -- should fix "WARNING: Nokogiri was built against LibXML version 2.7.8, but has dynamically loaded 2.9.0"
brew install libxml2 libxslt libiconv
brew link --force libxml2 libxslt libiconv
gem install nokogiri -v 1.6.2 -- --use-system-libraries
brew unlink libiconv libxml2 libxslt
@ronny
ronny / Gemfile
Last active December 11, 2015 04:28
A simple jQuery lightbox plugin that works with Turbolinks (https://github.com/rails/turbolinks)
source :rubygems
# Turbolinks and jQuery.turbolinks without Rails dependencies
gem 'turbolinks', :git => 'git://github.com/ronny/turbolinks.git', :branch => 'lite'
gem 'jquery-turbolinks', :git => 'git://github.com/ronny/jquery.turbolinks.git', :branch => 'lite'
@ronny
ronny / async-images-loader.js
Created September 17, 2012 01:09
Async image loading
// Loads images asynchronously so that the page would be displayed quicker.
//
// Define images with <img class="async" data-src="http://example.com/img.jpg">,
// and when load is called, all of the images' src attribute will be set from
// their data-src attribute.
var AsyncImagesLoader = {
init: function() {
AsyncImagesLoader.timeout = setTimeout(AsyncImagesLoader.load, 0);
},
@ronny
ronny / backbone-0.5.3-with-update.js
Created March 19, 2012 22:41
Backbone 0.5.3 with Collection.update and options.index on add/remove callbacks — originally from https://github.com/documentcloud/backbone/pull/446
// Backbone.js 0.5.3
// (c) 2010 Jeremy Ashkenas, DocumentCloud Inc.
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://documentcloud.github.com/backbone
(function(){
// Initial Setup
// -------------
@ronny
ronny / gist:1290343
Created October 16, 2011 00:13
Stevey's Google Platforms Rant
Stevey's Google Platforms Rant
I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.
I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't really have SREs and they make engi