Skip to content

Instantly share code, notes, and snippets.

curl -s https://api.github.com/orgs/iron-io/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
iced@iced test % cat test.worker
exec 'test.rb'
iced@iced test % cat test.rb
puts config.inspect
puts "YO!"
iced@iced test % iron_worker upload test --worker-config test.json
------> Creating client
Project 'Test' with id='517baf16ed3d7607990013a0'
------> Creating code package
Found workerfile with path='test.worker'
# Median of an array of numbers
def median(array)
array.each do |element|
if (array.length/2).to_f == (array.length.to_f)/2
element_even = element.to_i
median_value = (element_even[(array.length/2)].to_f + element_even[(array.length/2) + 1].to_f) / 2
else
element_odd = element.to_i
median_value = element_odd[(array.length/2) + 1].to_i

GitHub OAuth Busy Developer's Guide

This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.

OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.

Web Application Flow

  • Redirect to this link to request GitHub access:

jQuery and jQuery-ujs

When using Rails 3.0 and later we already get jquery-rails for free. Look in the gemfile and you'll see:

gem "jquery-rails"

You can view the full documentation here: source: https://github.com/indirect/jquery-rails

If you take a look in APP_DIR/app/assets/javascripts/application.js, you'll notice the following lines of code:

$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@Stephenitis
Stephenitis / zoo.js
Last active December 16, 2015 22:09 — forked from dbc-challenges/zoo.js
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
function Animal(name, legs){
this.name = name,
this.legs = legs
}
Animal.prototype = {
identify: function(){
@Stephenitis
Stephenitis / index.html
Created May 2, 2013 18:51 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>

Instructions:

  1. Download this application skeleton.
  2. Convert the app to use AJAX.
  3. Add any files you changed to your gist and submit your code.

"SOLID Object-Oriented Design" by Sandi Metz @ GoRuCo 2009

Date: May 30, 2009

Video on confreaks.net

Notes

  • Design is all about dependencies
  • If you refer to something, you depend on it.