Skip to content

Instantly share code, notes, and snippets.

@neftaly
neftaly / btssearch.js
Last active November 30, 2015 14:22
Binary search on time-series database
// inst: unix epoch
const hist = {
"channel1": [
{ inst: 10000, id: "a" },
{ inst: 20000, id: "b" },
{ inst: 30000, id: "c" },
{ inst: 30000, id: "d" },
{ inst: 40000, id: "e" }
]
};
@neftaly
neftaly / curry.js
Last active April 10, 2022 18:47
ES6 Auto-curry
const curry = (fn, ...oldArgs) => (...newArgs) => {
const args = [...oldArgs, ...newArgs];
return (args.length < fn.length) ? curry(fn, ...args) : fn(...args);
};
@neftaly
neftaly / compose.js
Last active December 5, 2021 14:24
ES6 Compose
const compose = (...args) => initial => args.reduceRight(
(result, fn) => fn(result),
initial
);
set -e
# fw_type will always be developer for Mario.
# Alex and ZGB need the developer BIOS installed though.
fw_type="`crossystem mainfw_type`"
if [ ! "$fw_type" = "developer" ]
then
echo -e "\nYou're Chromebook is not running a developer BIOS!"
echo -e "You need to run:"
echo -e ""
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ title }}</title>
<link href="./app.min.css" rel="stylesheet">
<script src="./app.min.js" defer></script>
@neftaly
neftaly / reduceToObject.js
Last active August 29, 2015 14:16
Functional object creation
var keys = ["foo", "bar", "baz"];
object = keys.reduce(function (partialObject, key) {
partialObject[key] = 1;
return partialObject;
}, {});
//=> { foo: 1, bar: 1, baz: 1 }
@neftaly
neftaly / helpers.js
Created February 22, 2015 20:48
extractExtension
/**
* Extract whatever comes after the last '.' in a string.
*
* @param {string} string - input path/URL
* @return {string} chars after last '.', else `undefined`.
*/
var extractExtension = function (string) {
var ext = string.match(/\.[0-9a-z]+$/i);
if (ext && ext[0]) {
return ext[0].replace('.', '').toLowerCase();
@neftaly
neftaly / core-init.min.js
Created February 18, 2015 11:53
Hydro (1.0.0)? - unminified
/*! HYDRO 1.0.0 (2014-10-27) | (c) 2014 hydroweb.co.nz */
Array.prototype.forEach || (Array.prototype.forEach = function(a, b) {
var c, d;
if (null == this) throw new TypeError(" this is null or not defined");
var e = Object(this),
f = e.length >>> 0;
if ("function" != typeof a) throw new TypeError(a + " is not a function");
for (arguments.length > 1 && (c = b), d = 0; f > d;) {
var g;
d in e && (g = e[d], a.call(c, g, d, e)), d++
@neftaly
neftaly / config
Last active March 30, 2016 06:59
i3 config
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
@neftaly
neftaly / xorg.conf
Created February 17, 2015 03:30
QNIX QX2710
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig: version 331.113 (buildmeister@swio-display-x64-rhel04-03) Mon Dec 1 21:15:34 PST 2014
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0" #0 0
#Option "Xinerama" "0"
#InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
EndSection