Skip to content

Instantly share code, notes, and snippets.

View badeball's full-sized avatar

Jonas Amundsen badeball

View GitHub Profile
@badeball
badeball / package.json
Last active December 12, 2016 23:25
Rendering virtual component tree
{
"scripts": {
"test": "mocha test.js"
},
"dependencies": {
"mocha": "^3.2.0",
"react": "^15.4.1",
"react-addons-test-utils": "^15.4.1",
"react-dom": "^15.4.1",
"react-test-renderer": "^15.4.1",
@badeball
badeball / store.jsx
Created November 17, 2016 08:51 — forked from anonymous/store.jsx
import {updateItemReducer} from './todo/reducerToDo';
import {manageUser} from './user/userReducer';
import {createStore, combineReducers } from 'redux';
import * as Actions from './user/userActions'
const reducers = combineReducers ({
updateItemReducer,
manageUser
})
function benchmark (callback) {
var start = new Date().getMilliseconds();
callback(function () {
var end = new Date().getMilliseconds();
console.log("This operation took " + (end - start) + " milliseconds.");
});
}
benchmark(function (done) {
var oldInnerHTML = document.body.innerHTML;
a = [1, 2, 3, 4, 5]
a.collect { |n| next if n % 2 == 1; n * 2 }.compact # => [4, 8]
a.select { |n| n % 2 == 0 }.map { |n| n * 2 } # => [4, 8]
if defined?(Rails)
IRB.conf[:IRB_RC] = Proc.new do
$: << 'path-to-your-hirb-installation'
require 'hirb'
Hirb.enable
end
end
@badeball
badeball / devise_invitable.no.yml
Created June 1, 2013 05:55
Norwegian translations for devise_invitable. Completely adheres to the format of the generated devise_invitable.en.yml as of 1.1.8.
# Additional translations at https://github.com/scambra/devise_invitable/wiki/I18n
'no':
devise:
invitations:
send_instructions: 'En epost med invitasjon er sent til %{email}.'
invitation_token_invalid: 'Autentiseringskoden er ikke gyldig!'
updated: 'Passordet ble oppdatert suksessfullt. Du er nå logget inn.'
no_invitations_remaining: 'Ingen gjenværende invitasjoner.'
invitation_removed: 'Din invitasjon ble fjernet.'
@badeball
badeball / gist:5048810
Created February 27, 2013 15:36
Command prompt with colors, full working directory and current git branch.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/'
}
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;35m\]$(parse_git_branch)\[\033[00m\]\$ '
@badeball
badeball / gist:5040222
Last active December 14, 2015 06:09
The Basic Izhikevich Spiking-Neuron Model.
for i in range(args.n_timesteps):
spike_train.append(v)
if v > 0.035:
v = c
u = u + d
spikes.append(i)
d_v = (1 / 10.0) * (k * v**2 + 5 * v + 140 - u + 1)
@badeball
badeball / devise.no.yml
Last active December 13, 2015 21:38
Norwegian translations for Devise. Completely adheres to the format of the generated devise.en.yml as of 2.2.3.
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
'no':
devise:
confirmations:
confirmed: "Din konto er aktivert og du er nå innlogget."
send_instructions: "Du vil innen få minutter motta en epost med instruksjoner for å aktivere din konto."
send_paranoid_instructions: "Hvis epostadressen din finnes i vår database vil du innen få minutter motta en epost med instruksjoner for å aktivere din konto."
failure:
already_authenticated: "Du er allerede logget inn."
ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML)