Skip to content

Instantly share code, notes, and snippets.

View Breefield's full-sized avatar

Bree Hoffman Breefield

View GitHub Profile
has_attached_file :foreground,
:convert_options => {
:background_strip => :lambda {|s| ((s.from_side == 'right') ? '-gravity NorthEast ' : '') + '-crop 10x10000+0+0'}
}
@Breefield
Breefield / LICENSE.txt
Created May 25, 2011 07:25 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@Breefield
Breefield / Animation.js
Created June 18, 2011 00:29
JS Animation class
var Animator = function(a, b) {
var clear_frame = true;
var current_frame = 0;
var auto_repeat = true;
var refresh_ms = 30;
var callbacks = [];
initialize(a, b);
function initialize(canvas) {
var self = this;
@Breefield
Breefield / gist:1454316
Created December 10, 2011 02:20
Bounce
box = {x: 10, y: 10, width: 40, height: 50, vX: 5, vY: 5};
bounds = {left: 0, right: 800, top: 0, bottom: 400};
frame() {
box.nX = box.x + box.vX;
box.nY = box.y + box.vY;
if(box.nX < bounds.left) box.vX *= -1;
if(box.nX + box.width > bounds.right) box.vX *= -1;
@Breefield
Breefield / tile.rb
Created August 9, 2012 01:47
Make a Tile Layout
def generate_tiles
# Pass the number of tiles into the main hash
tiles = {
ore: 3, # Ore
brick: 3, # Brick
wheat: 4, # Wheat
lumber: 4, # Trees
wool: 4, # Wool, Robber
robber: 1}.map { |k, v|
# After creating tile count, lets map them
@Breefield
Breefield / board.rb
Created August 9, 2012 01:54
Generate Board on Initialize
class Board < ActiveRecord::Base
belongs_to :game
# After initialize we generate new tiles and store them in the objects tiles accessor
# When this model is retrieved through ActiveRecord the tiles are not generated and we get the
# tile set that was saved in the database.
after_initialize :place_tiles
def place_tiles
# The tiles hash is stored in a text field, Rails handles this
@Breefield
Breefield / spine-game.js
Created August 9, 2012 20:37
Game Model in Spine.js
// Create model extending from Spine Model
window.Game = Spine.Model.sub({
// No documentation about this, refered to in controller documenation
init: function() {
this.players = 2;
}
});
// What accessors does it have?
Game.configure('Game', 'players');
@Breefield
Breefield / backbone-game.js
Created August 9, 2012 20:42
Game Model in Backbone.js
window.Game = Backbone.Model.extend({
// Must define this for API endpoint
urlRoot: '/games',
// Set defaults like so
defaults: {
'players': 2
}
});
@Breefield
Breefield / ember-binding.html
Created August 10, 2012 20:36
Ember.js Mustache Binding Example
<script type="text/x-handlebars">
The President of the United States is {{MyApp.president.fullName}}.
</script>
@Breefield
Breefield / backbone-bind.js
Created August 10, 2012 20:43
Backbone.js Template Binding
var TodoView = Backbone.View.extend({
tagName: 'li',
template: _.template($('#item-template').html()),
// Ensure our view knows about the association to it's model
initialize: function() {
this.model.bind('change', this.render, this);
},
// Drop that model into the template and have the template re-render