Skip to content

Instantly share code, notes, and snippets.

View akiva's full-sized avatar

Akiva Levy akiva

View GitHub Profile
function fizzbuzz(n) {
var output = '';
if (n % 3 === 0) output += 'Fizz';
if (n % 5 === 0) output += 'Buzz';
if (!output) output = n;
return output;
}
for (var i = 1; i < 100; i++) {
console.log(fizzbuzz(i));
// users.js
exports.list = function (options) {
return function (req, res, ...) {
// ...
}
}
// app.js
var users = require('./routes/users');
var request = require('request');
var JSONStream = require('JSONStream');
request({ url: 'http://reddit.com/.json' })
.pipe(JSONStream.parse('data.children.*.data.title'))
.on('data', function (data) {
console.log(data);
});

Installing Arch Linux on the Dell XPS 13 (2015)

Preparation

First, create a bootable USB stick using the latest Arch Linux installation image.[1][1]

Since the Dell XPS 13 ships with a Broadcom wireless adapter, this will not be supported with the included drivers within the Arch Linux image. To get around this, first download the [broadcom-wl][2] package from

@akiva
akiva / caesar.js
Last active October 8, 2015 07:00
var caesar = {
encode: function encode(plainText, shift) {
if (!plainText) throw new Error('No plaintext provided');
shift = Number(shift) || 0;
return encryptText(plainText, shift);
}
};
function encryptText(str, shift) {
str = str.toUpperCase().replace(/[^\w\s]/gi, '');
var h = require('virtual-dom/h')
var diff = require('virtual-dom/diff')
var patch = require('virtual-dom/patch')
var createElement = require('virtual-dom/create-element')
var Delegator = require('dom-delegator')
var sendChange = require('value-event/change')
Delegator()
var state = main({ actions: {} }, update)
@akiva
akiva / msconvert.js
Created March 16, 2017 06:54 — forked from remino/msconvert.js
JavaScript: Convert milliseconds to object with days, hours, minutes, and seconds
function convertMS(ms) {
var d, h, m, s;
s = Math.floor(ms / 1000);
m = Math.floor(s / 60);
s = s % 60;
h = Math.floor(m / 60);
m = m % 60;
d = Math.floor(h / 24);
h = h % 24;
return { d: d, h: h, m: m, s: s };
const app = require('choo')()
const html = require('choo/html')
app.use(function (state, emitter) {
state.loggedIn = false
emitter.prependListener('DOMContentLoaded', function () {
if (state.route !== '/shazam' && !state.loggedIn) {
emitter.emit('pushState', '/shazam')
emitter.emit('render')
@akiva
akiva / myweechat.md
Created January 16, 2018 04:13 — forked from pascalpoitras/1.md
My always up-to-date WeeChat configuration (weechat-dev)

WeeChat Screenshot

Enable mouse support

/mouse enable

Encrypted password in sec.conf

@akiva
akiva / myweechat.md
Created January 16, 2018 04:13 — forked from pascalpoitras/1.md
My always up-to-date WeeChat configuration (weechat-dev)

WeeChat Screenshot

Enable mouse support

/mouse enable

Encrypted password in sec.conf