Skip to content

Instantly share code, notes, and snippets.

View rebolyte's full-sized avatar

James Irwin rebolyte

View GitHub Profile
// Promise.resolve(ids).then(ids => {
// return ids.reduce((cur, next) => {
// return cur.then(() => {
// return doThingThatReturnsPromise(next);
// });
// }, Promise.resolve());
// }).then(() => {
// console.log('all done');
// }).catch(err => {
// console.error(err);
@rebolyte
rebolyte / UserAlerts.js
Last active May 13, 2020 23:18
Webpack script-loader problems
if (Ext4 === undefined) { window.Ext4 = Ext; }
Ext4.define('UserAlerts', (function () {
return {
extend: 'WidgetBase',
height:40,
data: {},
cls: 'UserAlerts',
listeners: {
@rebolyte
rebolyte / index.html
Last active April 12, 2019 01:14
stopwatch exercise
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Cross-timezone stopwatch">
<meta name="keywords" content="time, watch, stopwatch, clock, timer">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Stopwatch</title>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.5.3/css/bulma.min.css">
<style type="text/css">
@rebolyte
rebolyte / index.html
Created October 2, 2017 18:31
Shopping cart exercise
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Make tacos in the browser!">
<meta name="keywords" content="taco, tacos, truck, austin">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Shopping cart</title>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.5.3/css/bulma.min.css">
<style type="text/css">
@rebolyte
rebolyte / jlin.py
Last active November 12, 2018 17:26
def my_reduce(func, lst):
#base case
if (len(lst) == 1):
return lst[0]
#recurse
temp = func(lst[0], lst[1])
return my_reduce(func, [temp] + lst[2:])
@rebolyte
rebolyte / store.js
Created February 23, 2017 16:06
keep properties private in a closure with a getter/setter proxy
'use strict';
// keeping things private
let store = (() => {
let debug = true;
let state = {
isLoggedIn: false,
user: {}
};
@rebolyte
rebolyte / dydb-get-items.js
Created February 22, 2017 15:52
wrapper to get a list of items from DynamoDB
function getItems(opts) {
passMuster(opts, {
table: 'string',
hashkey: 'string',
items: 'array',
_optional: {
rangekey: 'string',
rangeval: 'string',
project: 'string'
}
@rebolyte
rebolyte / case-convert.js
Created February 13, 2017 16:14
Change a string from camelCase to kebab-case or snake_case and vice versa
'use strict';
let DASH_LOWERCASE_REGEX = /-([a-z])/g;
let UNDERSCORE_LOWERCASE_REGEX = /_([a-z])/g;
let UPPERCASE_REGEX = /([A-Z])/g;
// func argument to .replace receives:
// 1) the matched substring
// 2) nth parenthesized substr match (i.e. if the pattern has any `()` group matches,
// those will be passed as the next args)
@rebolyte
rebolyte / abc123.js
Last active September 29, 2017 18:02
print alphabet using char codes
function range(x, y) {
if (typeof y === 'undefined') {
y = x;
x = 0;
}
let out = [];
while (x < y) {
out.push(x++);
}
return out;
@rebolyte
rebolyte / aes.sh
Created September 14, 2016 00:08
Simple CLI file encrypter/decrypter with GPG
#!/bin/bash
mode=""
filename=""
# http://stackoverflow.com/a/7069755
while test $# -gt 0; do
case "$1" in
-h|--help)