Skip to content

Instantly share code, notes, and snippets.


Kimmo Brunfeldt kimmobrunfeldt

View GitHub Profile
View react-music.jsx
<Song tempo={90}>
<Sequencer resolution={16} bars={1}>
[0, 4, "c3"],
[4, 4, "c4"],
kimmobrunfeldt / react-router.jsx
Created Dec 25, 2016
Example of react-router configuration
View react-router.jsx
<Router history={browserHistory}>
<Route path=/ component={App}>
<Route path=”users” component={Users}>
<Route path=/user/:userId” component={User}/>
<Route path=* component={NoMatch}/>
kimmobrunfeldt / react-router.jsx
Last active Dec 25, 2016
Example of how react-router configuration could look like as a JS object
View react-router.jsx
const routes = [
{ path: '/', component: App },
{ path: '/users/', component: UserList },
{ path: '/users/:userId', component: User },
{ path: '*', component: Default },
<Router history={browserHistory} routes={routes} />
kimmobrunfeldt / cpu-profile-trigger.js
Last active Oct 26, 2016
Helper to record node CPU profiles, which can be easily viewed as CPU flame graphs using Chrome debugger
View cpu-profile-trigger.js
// Helper to record CPU profiles
// Usage:
// 1. npm install v8-profiler
// 2. require('./cpu-profile-trigger') once in your app code
// 3. Start CPU profiling with kill -PIPE <pid>. Instructions will be logged to stdout.
// 4. Stop CPU profiling with running again kill -PIPE <pid>
// 5. Go to Chrome debugger, open Profiles tab. Click Load and
// open the <timestamp>.cpuprofile. It was saved to the same dir
kimmobrunfeldt /
Last active Jul 6, 2016
Hapi for Express developers
kimmobrunfeldt /
Created Jun 19, 2016
Älä koskaan kirjota omaa cryptoa.. paitsi ekan kerran
# -*- coding: UTF-8 -*-
import random
from math import floor
kirjaimet = {u' ': u'00', u'!': u'01', u'"': u'02', u'#': u'03', u'$': u'04', u'%': u'05', u'&': u'06', u'\'': u'07', u'(': u'08', u')': u'09', u'*': u'10', u'+': u'11', u',': u'12', u'-': u'13', u'.': u'14', u'/': u'15', u'0': u'16', u'1': u'17', u'2': u'18', u'3': u'19', u'4': u'20', u'5': u'21', u'6': u'22', u'7': u'23', u'8': u'24', u'9': u'25', u':': u'26', u';': u'27', u'<': u'28', u'=': u'29', u'>': u'30', u'?': u'31', u'@': u'32', u'A': u'33', u'B': u'34', u'C': u'35', u'D': u'36', u'E': u'37', u'F': u'38', u'G': u'39', u'H': u'40', u'I': u'41', u'J': u'42', u'K': u'43', u'L': u'44', u'M': u'45', u'N': u'46', u'O': u'47', u'P': u'48', u'Q': u'49', u'R': u'50', u'S': u'51', u'T': u'52', u'U': u'53', u'V': u'54', u'W': u'55', u'X': u'56', u'Y': u'57', u'Z': u'58', u'[': u'59', u'\\': u'60', u']': u'61', u'^': u'62', u'_': u'63', u'`': u'64', u'a': u'65', u'b': u'66', u'c': u'67', u'd': u'68', u'e': u'69', u'f': u'70', u'g':
kimmobrunfeldt / Matikka
Last active Jun 19, 2016
One of my earliest experiences with coding in 2007 (In Finnish)
View Matikka
print "Matikka ohjelma"
print "-----------------------"
print "Valitse vaihtoehto:"
print "1 Simppelit laskut"
print "2 Pinta-alat ja tilavuudet"
print "3 Muita laskuja"
ehto = input("> ")
View monkey-patch-console.js
console.warn('- console.(debug|info|log|warn|error) monkey-patched');
const methods = ['debug', 'info', 'log', 'warn', 'error'];
// We have to take the direct references to the actual function like this
// instead of doing just: originalConsole = console
const originalConsole = _.reduce(methods, (memo, methodName) => {
memo[methodName] = _.bind(console[methodName], console);
return memo;
}, {});
kimmobrunfeldt / unique-generator.js
Created Feb 29, 2016
Small example of a generator
View unique-generator.js
function* uniqueId() {
var i = 0;
while (true) {
yield i;
var idGenerator = uniqueId();