Skip to content

Instantly share code, notes, and snippets.

@kasima
kasima / gist:830977
Created February 17, 2011 04:26
Mongoid references_and_referenced_in association assignment bug
class Game
include Mongoid::Document
field :title
references_and_referenced_in_many :players
end
class Player
include Mongoid::Document
field :name
@kasima
kasima / escaped_unicode.rb
Created March 2, 2011 00:48
Generate unicode escape strings
def escaped_unicode(s)
s.unpack("U*").map do |v|
if v == 10
'\n'
elsif v < 256
v.chr
else
'\u{'+v.to_s(16)+'}'
end
end.join
@kasima
kasima / gist:941464
Created April 25, 2011 23:17
Mongo Office Hours
class DiagnosticReport
include Mongoid::Document
embeds_many :marker_values
end
class MarkerValue
include Mongoid::Document
@kasima
kasima / gist:957582
Created May 5, 2011 18:21
Mongoid $or bug
class Parent
include Mongoid::Document
field :pants
field :shirts
embeds_many :children
end
class Child
include Mongoid::Document
@kasima
kasima / gist:979259
Created May 18, 2011 18:57
Making your js testable
// From http://front-end-testing-talk.elabs.se/
// Seen at RailsConf 2011
// Typical jQuery
$('#whiskies li').each(function() {
var li = $(this);
var price = li.attr('data-price');
var addLink = $('<a class="add-to-cart" href="#">Add to cart</a>');
addLink.appendTo(li);
@kasima
kasima / currently.js
Created November 29, 2012 07:33
Meteor.Router with and without session params
Meteor.Router.add({
'/posts': 'posts',
'/posts/:id': function(id) {
Session.set('postId');
return 'post';
},
'/authors/:id': function(id) {
Session.set('authorId', id);
return 'author';
}
@kasima
kasima / nest.coffee
Created December 14, 2012 22:53
hubot, make it cozy
# Description:
# Control your nest thermostat.
#
# Commands:
# hubot how (warm|cold) is it - current temperature
# hubot it's warm - set the nest 1 degree Fahrenheit lower
# hubot it's cold - set the nest 1 degree Fahrenheit higher
# hubot nest status - current nest setting
# https://github.com/kasima/nesting
@kasima
kasima / gist:7847711
Created December 7, 2013 19:52
Crappybot
int LEFT = A0;
int RIGHT = A1;
int SERVO_MAX = 180.0;
int x_max;
int y_max;
Servo lt_servo;
Servo rt_servo;

Keybase proof

I hereby claim:

  • I am kasima on github.
  • I am kasima (https://keybase.io/kasima) on keybase.
  • I have a public key whose fingerprint is AB4E 1E84 1C7A D4F1 A073 A085 494F A252 6107 D628

To claim this, I am signing this object:

@kasima
kasima / solidity-0_4_18-osx-highsierra.md
Last active April 10, 2018 07:20
Building solidity 0.4.18 on Mac OS X 10.13 (High Sierra)

Building solidity 0.4.18 on Mac OS X 10.13 (High Sierra)

# check out [email protected]
git clone https://github.com/ethereum/solidity.git
cd solidity
git checkout v0.4.21

# install deps
./scripts/install_deps.sh