Skip to content

Instantly share code, notes, and snippets.

View dnewcome's full-sized avatar

Dan Newcome dnewcome

  • Try.com
  • San Francisco
View GitHub Profile
/**
* Copyright 2017- Mark C. Slee, Heron Arts LLC
*
* This file is part of the LX Studio software library. By using
* LX, you agree to the terms of the LX Studio Software License
* and Distribution Agreement, available at: http://lx.studio/license
*
* Please note that the LX license is not open-source. The license
* allows for free, non-commercial use.
*
@dnewcome
dnewcome / nordstrom.js
Created December 5, 2017 23:34
Nordstrom request signing
var CryptoJS = require("crypto-js");
function pad(number) {
if (number<=999) { number = ("00"+number).slice(-3); }
return number;
}
var timestamp = (Math.floor(new Date() / 1000)) + "." + pad(new Date() % 1000);
var deviceId = "8A6A3699-1527-4E52-8441-7AA9AAD529F4";
var path = "/v2/authorizationservice/shopperauth";
@dnewcome
dnewcome / elcreate.js
Created August 14, 2017 22:42
Quick DOM element creation
function elcreate (tag, styles = {}, attrs = {}, children=[]) {
let el = document.createElement(tag);
Object.keys(styles).forEach((item) => {
el.style[item] = styles[item];
});
Object.keys(attrs).forEach((item) => {
el[item] = attrs[item];
});
@dnewcome
dnewcome / get.js
Last active July 24, 2017 22:00
dependency-free get
// safely get object prop, like lodash get but without any dependencies
// specify path as dot delimited string
// optionally provide default value
function get(obj, path, def) {
path = path.split('.');
let ret = obj || {};
path.forEach((item) => {
ret = ret && ret[item];
});
return ret || def;

JankyBrowser

The only cross-platform browser that fits in a Gist!

One line install. Works on Linux, MacOSX and Windows.

Local Install

$&gt; npm install http://gist.github.com/morganrallen/f07f59802884bcdcad4a/download
@dnewcome
dnewcome / gist:ae6784cc73993e8541a4
Created November 15, 2014 19:48
Shapeoko config
;system settings
$ja 2000000
$st 1
$mt 10
; motor1
$1ma 0
$1sa 1.8
$1tr 40.00
$1mi 8
@dnewcome
dnewcome / gist:828afe64d1204c5e3b03
Last active August 29, 2015 14:01
KeyRemap4Mac config for hjkl navigation
<?xml version="1.0"?>
<root>
<item>
<name>PC Application Key to Extra1 Modifier</name>
<identifier>private.pc_application_to_extra1</identifier>
<autogen>--KeyToKey-- KeyCode::PC_APPLICATION, KeyCode::VK_MODIFIER_EXTRA1</autogen>
</item>
<item>
<name>Extra1+J to CURSOR_DOWN</name>
print "importing local customizations"
print "_list_helpers() to list defined functions"
# TODO: guard this somehow so if we fire up the
# normal python interpreter we don't see an error
from django.db import transaction
@transaction.commit_manually
def flush_transaction():
"""
@dnewcome
dnewcome / gist:6074130
Created July 24, 2013 20:15
Missing commas and Python automatic string concatenation
# omitting a comma after the second field
# does not generate an error
fields = [
'field1',
'field2'
'field3'
]
# in fact
'field1' 'field2' == 'field1field2'
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int offset = 0;
int sinetable[32];
// Precomputed sine table taken from somewhere...
// can't find it now
void setupSintable() {
sinetable[0] = 127;