Skip to content

Instantly share code, notes, and snippets.

@anderssvendal
anderssvendal / README.md
Created October 29, 2012 10:20
ubuntu + unicorn + sinatra
@anderssvendal
anderssvendal / gist:3749134
Created September 19, 2012 11:21
sublime text settings
{
"auto_complete_commit_on_tab": true,
"color_scheme": "Packages/Color Scheme - Default/Spacedust.tmTheme",
"detect_indentation": true,
"draw_white_space": "selection",
"folder_exclude_patterns":
[
".sass-cache",
"tmp"
],
@anderssvendal
anderssvendal / grid.sass
Created August 19, 2012 17:41
Small sass gridsystem
// 12 column grid
$column-width: 60px !default
$gutter-width: 20px !default
$grid-columns: 12 !default
$grid-width: $column-width * $grid-columns + $gutter-width * ($grid-columns - 1)
@function column-width($n)
@return $column-width * $n + $gutter-width * ($n - 1)
@anderssvendal
anderssvendal / module.coffee
Created July 5, 2012 19:05
Easy namespacing of classes and objects.
# Easy namespacing of classes and objects.
#
# name - The String containing namespaces up to but not including the class
# name.
#
# Examples
# # Using a class
# class module("Foo.Bar").Baz
# doStuff: ->
# console.log "doing stuff"
@anderssvendal
anderssvendal / keyboard.m
Created July 5, 2012 09:50
adjust for keyboard
- (void)adjustViewForTextField:(UITextField*)textField animated:(BOOL)animated {
CGRect frame = self.view.frame;
double screenSize = 480.0;
double topHeight = 20.0;
double keyboardSize = 216.0;
double keyboardPos = screenSize - keyboardSize;
double textFieldPos = topHeight + textField.frame.origin.y;
double textFieldHeight = textField.frame.size.height;
double textFieldBottom = textFieldPos + textFieldHeight;
@anderssvendal
anderssvendal / price.coffee
Created July 4, 2012 11:21
CoffeeScript price formatter
formatPrice = (price)->
return '0' if isNaN(price)
price = price + ''
price = price.split(/\./)
decimals = price[1]
price = price[0]
iterations = price.length / 3
i = price.length
segments = []
@anderssvendal
anderssvendal / sass.rb
Created June 11, 2012 10:19
Simple retina backgrounds with sass
require 'sass_extensions'
@anderssvendal
anderssvendal / Procfile
Created May 3, 2012 13:44
Foreman nginx, php, mysql setup
web: /usr/local/sbin/nginx -p `pwd`/tmp/nginx/ -c ../../nginx.conf
fastcgi: /usr/local/sbin/php-fpm
db: /usr/local/bin/mysqld
@anderssvendal
anderssvendal / tooltip.css
Created April 10, 2012 09:01
Simple tooltip
/* line 3, tooltip.css.sass */
.tooltip {
margin-top: 5px;
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
opacity: 0;
position: absolute;
padding: 7px 0 14px;
}
/* line 10, tooltip.css.sass */
.tooltip i {
@anderssvendal
anderssvendal / time_formatter.coffee
Created November 2, 2011 08:15
Relative time formatting
TimeFormatter =
to_pretty: (date)->
now = new Date()
date = new Date(date)
# Time ago in seconds
a = (now - date) / 1000
if a is 0 then 'akkurat nå'
else if a is 1 then 'ett sekund siden'