Skip to content

Instantly share code, notes, and snippets.

<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 March 10, 2010 12:11
Convert a string representation of a range into a range (e.g. "22..47" becomes 22..47)
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
require 'test_helper'
class FicTest < ActiveSupport::TestCase
should_belong_to :user
should_belong_to :story
should_validate_presence_of :content
end
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 February 22, 2012 00:45
Codea raycaster
--# 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 April 9, 2012 21:34
Codea Backgammon
--# 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)
<?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" />
@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 June 7, 2013 06:11 — forked from supermarin/gist:5597771
Example of asynchronous testing in Kiwi
//
// 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 August 29, 2015 14:07
iTunes Receipt Email Parser
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