Skip to content

Instantly share code, notes, and snippets.

Avatar

James Frost frosty

View GitHub Profile
View gist:90937
<div id="post">
<h2>{{ post.title }}</h2>
<span class="date">{{ post.date | date_to_string }}</span>
{{ post.content }}
</div>
Results in...
<div id="post">
<h2>Another Test</h2>
@frosty
frosty / gist:327806
Created Mar 10, 2010
Convert a string representation of a range into a range (e.g. "22..47" becomes 22..47)
View gist:327806
class String
def to_r
ends = self.split('..').map{|d| Integer(d)}
if ends.size > 1
ends[0]..ends[1]
else
ends[0]
end
end
end
View gist:341758
require 'test_helper'
class FicTest < ActiveSupport::TestCase
should_belong_to :user
should_belong_to :story
should_validate_presence_of :content
end
View gist:342086
require 'test_helper'
class FicTest < ActiveSupport::TestCase
fixtures :all
should_belong_to :user
should_belong_to :story
test "should validate presence of content" do
assert_raise (ActiveRecord::RecordInvalid) {
@frosty
frosty / gist:1880241
Created Feb 22, 2012
Codea raycaster
View gist:1880241
--# Main
-- based on untextured raycaster example: http://lodev.org/cgtutor/raycasting.html
MAPWIDTH = 24
MAPHEIGHT = 24
worldMap = {
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
@frosty
frosty / Backgammon.lua
Created Apr 9, 2012
Codea Backgammon
View Backgammon.lua
--# Counter
CTYPE_WHITE = 0
CTYPE_BLACK = 1
CTYPE_PLACEWHITE = 2
CTYPE_PLACEBLACK = 3
Counter = class()
function Counter:init(x, y, t)
self.pos = vec2(x,y)
View Flixel Test.nmml
<?xml version="1.0" encoding="utf-8"?>
<project>
<app title="Flixel Test" file="Flixel Test" main="Main" version="0.0.1" company="Zaphod" />
<window width="1024" height="768" fps="30" orientation="portrait" resizable="true" if="target_flash" />
<window width="0" height="0" fps="30" orientation="landscape" fullscreen="true" unless="target_flash" />
<set name="BUILD_DIR" value="Export" />
View gist:4580197
@implementation ADNClient
+ (id)sharedClient
{
static dispatch_once_t pred = 0;
__strong static id _sharedObject = nil;
dispatch_once(&pred, ^{
_sharedObject = [[self alloc] init];
});
return _sharedObject;
@frosty
frosty / gist:5727345
Created Jun 7, 2013 — forked from supermarin/gist:5597771
Example of asynchronous testing in Kiwi
View gist:5727345
//
// BeerTests.m
// Beer
//
// Created by Marin Usalj on 5/16/13.
// Copyright 2013 @mneorr | mneorr.com. All rights reserved.
//
#import "Kiwi.h"
@frosty
frosty / parser.rb
Last active Aug 29, 2015
iTunes Receipt Email Parser
View parser.rb
class ReceiptParser
attr_reader :counts, :prices
def initialize(currency_symbol)
if (currency_symbol == "") then currency_symbol = "£" end
@currency_symbol = currency_symbol
@all_items = []
@counts = { :ios_apps => 0, :iaps => 0 }
@prices = { :ios_apps => 0, :iaps => 0 }
end
You can’t perform that action at this time.