Skip to content

Instantly share code, notes, and snippets.

@michiel
michiel / newton_sqrt.go
Created May 31, 2013 04:11
Newton's sqrt approximation method in Go
func sqrt(x float64) (y float64) {
y = 1
for i := 0; i < 10; i++ {
y = y - ((y*y - x) / (2*y))
}
return
}
@michiel
michiel / json-unmarshal.go
Last active December 17, 2015 22:59
JSON unmarshal in go
package main
import (
"fmt"
"encoding/json"
"os"
"io/ioutil"
)
/*
@michiel
michiel / sh
Created June 12, 2013 16:44
bash rename js files to coffee
#!/bin/bash
for files in *.js
do
mv "$files" "${files%.js}.coffee"
done
var get = Ember.get;
/**
@extends Ember.Mixin
Implements common pagination management properties for controllers.
*/
Ember.PaginationSupport = Ember.Mixin.create({
/**
*/
#!/usr/bin/env node
var code, codeWithoutAsserts, fs, jsAst, map, mkdirp, path, _ref;
fs = require('fs');
path = require('path');
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# you need an updated simple_form gem for this to work, I'm referring to the git repo in my Gemfile
config.input_class = "form-control"
config.wrappers :bootstrap, tag: 'div', class: 'form-group', error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
b.use :input
@michiel
michiel / test_mechanize.rb
Last active December 26, 2015 12:28
Testing Mechanize apps
require 'rubygems'
require 'mechanize'
require 'test/unit'
require 'fakeweb'
def find_links
Mechanize.new.get('http://www.google.com').links
end
class TestGoogle < Test::Unit::TestCase
@michiel
michiel / pulse.css
Created November 14, 2013 15:05
CSS3 pulsating rings
.outer-ring {
border: 3px solid #999;
-webkit-border-radius: 30px;
height: 22px;
width: 22px;
position: absolute;
left:20px;
top:214px;
-webkit-animation: pulsate 1s ease-out;
-webkit-animation-iteration-count: infinite;