Skip to content

Instantly share code, notes, and snippets.

@anderssvendal
anderssvendal / paulirish.user.js
Created November 10, 2010 15:32
Userscript to remove canvas from paulirish.com
// ==UserScript==
// @match http://*.paulirish.com/*
// @match http://www.paulirish.com/*
// ==/UserScript==
(document.getElementsByTagName('canvas')[0]).parentElement.removeChild(document.getElementsByTagName('canvas')[0]);
#!/bin/bash
curl -s http://whatthecommit.com/ | grep "<p>" | sed 's/<p>//' | sed 's/^/"/' | sed 's/$/"/' | xargs git commit -m
@anderssvendal
anderssvendal / alternating.js
Created December 3, 2010 10:48
Make labels alternate between several form fields
(function($)
{
$.fn.extend({
alternating: function(options)
{
var options = options;
var currentElement = -1;
var timeout = 0;
// Create focus and blur events for all inputfields
@anderssvendal
anderssvendal / dbp
Created December 14, 2010 13:04
Copy a file to the dropbox public folder and copy the link
#!/bin/bash
cp $1 ~/Dropbox/Public/
echo "http://dl.dropbox.com/u/USERID/$1" | pbcopy
@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'
@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 / 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 / sass.rb
Created June 11, 2012 10:19
Simple retina backgrounds with sass
require 'sass_extensions'
@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 / 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;