Skip to content

Instantly share code, notes, and snippets.

View kpuputti's full-sized avatar

Kimmo Puputti kpuputti

View GitHub Profile
@kpuputti
kpuputti / ios7.md
Last active December 23, 2015 12:39
// http://reaktor.fi/ura/fast_track/
function find(input) {
'use strict';
function toInt(s) {
return parseInt(s, 10);
}
@kpuputti
kpuputti / print-strings.js
Last active December 18, 2015 16:39
Print all string tokens in the given js file in format: path/to/file.js:line:col: 'value'
var esprima = require('esprima');
var fs = require('fs');
function die(err) {
process.stderr.write(err + '\n');
process.exit(1);
}
function format(filename, obj) {
return filename + ':' +
@kpuputti
kpuputti / lazy.md
Last active December 17, 2015 22:49
@import "compass/css3";
@mixin flexbox-container($orientation: horizontal, $align: stretch, $pack: center) {
@include display-box;
@include box-orient($orientation);
@include box-align($align);
@include box-pack($pack);
}
// Usage:
@mixin flexbox {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-direction: normal;
-moz-box-direction: normal;
-webkit-box-orient: horizontal;
-moz-box-orient: horizontal;
/*
Markup:
<ul id="country-selection" class="list-selection">
<li data-content="Deutschland">Germany</li>
<li data-content="Vereinigtes Königreich von Großbritannien und Nordirland">UK</li>
<li data-content="Finnland">Finland</li>
<li data-content="Spanien">Spain</li>
<li data-content="Other">Other</li>
</ul>
emacs main.js

M-x query-replace-regexp Enter $ Enter ; Enter !

@kpuputti
kpuputti / pairs.js
Last active December 16, 2015 18:49
function collectPairs(arr) {
return arr.reduce(function (acc, curr) {
var last = _.last(acc);
if (acc.length === 0 || last.length === 2) {
acc.push([curr]);
return acc;
} else {
last.push(curr);
return acc;
}
@kpuputti
kpuputti / exercise-1.11.clj
Last active December 15, 2015 21:29
SICP exercise 1.11 in Clojure
;; f(n) = n if n < 3
;; f(n) = f(n - 1) + 2f(n - 2) + 3f(n - 3) if n >= 3
(def rounds 30)
(println "== recursive ==")
(defn f-recursive [n]
(if (< n 3)
n