Skip to content

Instantly share code, notes, and snippets.

View akiva's full-sized avatar

Akiva Levy akiva

View GitHub Profile
@akiva
akiva / gist:6500042
Last active December 22, 2015 16:29
Vim regex to convert hash rocket syntax to modern colon style syntax for hashes with symbol-based keys
%s/:\(\w*\)\(\s\+\)\?=>/\1:/gc
DEVELOPMENT LIFE CYCLE
Plan feature
Write tests
Implement functionality
Update README (if required)
Get code reviewed and ensure all your tests pass
Merge your feature
{
"browser": true,
"camelcase": true,
"eqeqeq": true,
"eqnull": true,
"esnext": true,
"forin": false,
"indent": 2,
"lastsemic": false,
"latedef": true,
@akiva
akiva / main.js
Created September 11, 2014 23:15
'use strict';
var TL = require('timeline-core');
// var LoginView = require('./views/login')(TL);
// var CreateStoryView = require('./views/create-story')(TL);
// var StoriesView = require('./views/featured-stories')(TL);
TL.Router
.add('/', function() {

Keybase proof

I hereby claim:

  • I am akiva on github.
  • I am akiva (https://keybase.io/akiva) on keybase.
  • I have a public key whose fingerprint is F05B 121F 6E07 3216 BE35 E425 5524 34F0 F754 BE67

To claim this, I am signing this object:

function fibonacci(n) {
return (n < 2) ? n : fibonacci(n - 1) + fibonacci(n - 2);
}
// F0 = 0, F1 = 1, F2 = 1, F3 = 2, F10 = 55
for (var i = 1; i <= 10; i++) {
console.log(fibonacci(i));
}
var human = { race: 'human' };
var person = { name: 'Jim', age: 26 };
function mixin(target, source, props) {
props = props || Object.keys(source);
props.forEach(function(prop) {
target[prop] = source[prop];
});
// Create a function that accepts 2 arguments. Both arguments
// should be arrays of integers. The function should return the
// differences between the first and second arrays.
//
// Example:
//
// Array One [1, 2, 4]
// Array Two [2, 3]
//
// [1, 2, 4] => [2, 3]
// Find which line number a 0-based index falls on by splitting a line
// of text delimited by '\n'
function getLineNumberByCharIndex(index) {
var TEXT = 'abc\ndef\nghijkl\nmnop';
var line = 0;
var i;
for (i = 0; i <= index; i++) {
if (TEXT[i] === '\n') line++;
// Merge arrays into single array, removing duplicates. This version
// removes objects that are duplicates by values, not memory pointers,
// ie. `{ foo: 'bar' }` and `{ foo: 'bar' }` are seen as duplicates
function mergeArrays() {
var args = arguments;
var hash = {};
var arr = [];
for (var i = 0; i < args.length; i++) {