Skip to content

Instantly share code, notes, and snippets.

/**
* i have an idea.
*
* Background:
*
* The flow was designed at first to encompass all flow control, loops and
* branches, etc. later during Cursed development, I had the idea to simplify
* some types of flow control where a single action was completely "embedded"
* within another. I called these "follow-ups". They used a simple mechanism
* where at any point during the execution of a player action, you could call
@aghull
aghull / forms.js
Created September 6, 2017 12:25
Form conventions
class FormContainer extends React.Component {
componentWillMount() {
this.props.fetchForm();
}
render() {
<MyForm onChange={this.props.updateForm}/>
<Submit onClick={this.props.submitForm}/>
}
}
// list_app.js
Slick = require('slick');
listItem = require('./data/list_item');
list = require('./data/list');
var MyListApp = module.exports = new Slick.App({
// init is called by the node after node starts up and hits addApplication which propagates the Node reference on this.node
init: function() {
// we register our data type containing field info and any custom logic
this.addModel('listItem', listItem);
var Q = require('../game.js');
describe("Q", function() {
var game;
beforeEach(function() {
game = new Q.Game();
});
hearts = new Game();
var cards = new Pieces(['2C',]).attributes({
suit: hearts.suitOf,
value: hearts.valueOf,
points: hearts.pointsOf
});
hearts.deck = new Space({cards: cards});
hearts.players = new Players(4).attributes({
@aghull
aghull / gist:5889081
Last active December 19, 2015 03:18
gem 'activerecord', '3.2.13'
require 'active_record'
require 'minitest/autorun'
require 'logger'
require 'debugger'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
class Fixnum
def factors
(1..self).select { |f| modulo(f) == 0 }.uniq
end
def prime?
equal? 1 or factors == [1, self]
end
def coprime?(b)
@aghull
aghull / gist:4141190
Created November 24, 2012 19:52
routing
# long-hand create routes directly
path 'users' do
get { User.all }
post { User.create params }
var (/\d/) do |id|
get { User.find(id) }
...
end
...
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<div id="map" style="position:relative">
<img src="http://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=2&scale=2&size=640x400&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.714728,-76.211794&markers=color:green%7Clabel:G%7C42.922217,-76.211794&markers=color:red%7Ccolor:red%7Clabel:C%7C42.922217,-73.998672&sensor=false">
</div>
<script>
mapToCoord(42.922217,-73.998672, 40.714728, -73.998672, 6, 2, 640, 400, 'red');