Skip to content

Instantly share code, notes, and snippets.

@anatomic
anatomic / Milkshake brings the boys to the yard
Created October 14, 2011 15:18 — forked from brendandawes/Milkshake brings the boys to the yard
Learn to code with Kelis' Milkshake Part 1
/*
Learn to code with Kelis' Milkshake
http://en.wikipedia.org/wiki/Milkshake_(song)
Created by Brendan Dawes brendandawes.com
*/
// "my milkshake brings all the boys to the yard"
if (milkShake) {
@anatomic
anatomic / LinkifyEntities.php
Created November 13, 2011 20:32
Processing entities to linkify a tweet
<?php
public function getLinkifiedText(){
$allEntities = array();
foreach(json_decode($this->entities) as $entityGroup){
foreach($entityGroup as $entity){
$allEntities[$entity->indices[0]] = $entity;
}
}
krsort($allEntities);
$text = $this->text;
@anatomic
anatomic / tddium.rake
Created November 5, 2013 07:07
Hooks for tddium to deploy to heroku that I personally find very useful - with plenty of scope for improvement no doubt!
# RAILS_ROOT/lib/task/tddium.rake
#
# http://blog.tddium.com/2012/05/09/heroku-continuous-deployment/
# https://gist.github.com/semipermeable/2639790
# https://github.com/javierjulio
namespace :tddium do
desc "Tddium pre-worker hook that sets up test db"
task :worker_setup_hook do
Bundler.with_clean_env do
system "rake db:test:prepare"
@anatomic
anatomic / gist:9271995
Created February 28, 2014 14:28
Recursively iterate through folders to document image assets
#!/usr/bin/env node
var fs = require('fs')
, util = require('util')
, path = require('path');
var total = 0;
/**
*
* Iterate through the filesystem and create a file that documents assets created
*
@anatomic
anatomic / _lists.scss
Created July 2, 2014 15:59
Working with !default and maps when creating a CSS framework
@import "main";
$list-margin: $base-spacing-unit!default;
@mixin create-horizontal-list($name: 'ui-list') {
#{$name} {
list-style: none;
margin: 0;
&__item {
@anatomic
anatomic / SassMeister-input.scss
Created July 2, 2014 17:30
Generated by SassMeister.com.
// ----
// Sass (v3.3.9)
// Compass (v1.0.0.alpha.20)
// ----
// Declared as a project global
$breakpoints: (
alpha: 30rem,
beta: 48rem,
gamma: 60rem
@anatomic
anatomic / SassMeister-input.scss
Created July 31, 2014 08:38
Generated by SassMeister.com.
// ----
// libsass (v2.0.0)
// ----
@import "sass-list-maps";
$selector: push;
$modifiers: (left right top bottom);
$space: 2em;
/* In BEM methodology we would want our modifiers to be prefixed with `--`
@anatomic
anatomic / SassMeister-input.scss
Created July 31, 2014 09:11
Generated by SassMeister.com.
// ----
// libsass (v2.0.0)
// ----
@import "sass-list-maps";
$selectors: (push margin, soft padding);
$modifiers: (left right top bottom);
$space: 2em;
/* In BEM methodology we would want our modifiers to be prefixed with `--`
@anatomic
anatomic / gist:8cbe5b0f0ad4227a99fe
Created December 4, 2014 21:16
Stamp Duty Calculator
var range = {
0: { min: 0, max: 125000},
2: { min: 125000, max: 250000},
5: { min: 250000, max: 925000},
10: { min: 925000, max: 1500000},
12: { min: 1500000, max: null}
};
function stampDuty(houseValue) {
return Object.keys(range).reduce(function(duty, percentage) {