Skip to content

Instantly share code, notes, and snippets.

James Irwin rebolyte

Block or report user

Report or block rebolyte

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rebolyte
rebolyte / typescript-intro.md
Last active Jun 7, 2018
TypeScript basic intro
View typescript-intro.md

TypeScript intro

James Irwin
7-Jun-2018

TypeScript is a typed superset of JavaScript. All JavaScript is valid TypeScript, and TS transpiles to JS to run in browsers (much like Babel transpiles ES6+ to ES5). In transpilation, all types are stripped out; you get type-checking at compile-time only (but run-time type-checking is needed much less because of it). It is developed by Microsoft, powers apps you know like VS Code, and is in use at companies like Lyft, Reddit, and Slack.

Definition files

TypeScript lets you use existing JavaScript libraries in a strongly-typed manner by providing type definition files, which are separate files that annotate a given library's API. When you go to import lodash, you will likely also want to import @typings/lodash, which will install a lodash/index.d.ts file in your dependencies. So

View await-promise-sequential.js
// 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 Oct 24, 2017
Webpack script-loader problems
View UserAlerts.js
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 Apr 12, 2019
stopwatch exercise
View index.html
<!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 Oct 2, 2017
Shopping cart exercise
View index.html
<!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">
View jlin.py
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 Feb 23, 2017
keep properties private in a closure with a getter/setter proxy
View store.js
'use strict';
// keeping things private
let store = (() => {
let debug = true;
let state = {
isLoggedIn: false,
user: {}
};
@rebolyte
rebolyte / dydb-get-items.js
Created Feb 22, 2017
wrapper to get a list of items from DynamoDB
View dydb-get-items.js
function getItems(opts) {
passMuster(opts, {
table: 'string',
hashkey: 'string',
items: 'array',
_optional: {
rangekey: 'string',
rangeval: 'string',
project: 'string'
}
@rebolyte
rebolyte / case-convert.js
Created Feb 13, 2017
Change a string from camelCase to kebab-case or snake_case and vice versa
View case-convert.js
'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 Sep 29, 2017
print alphabet using char codes
View abc123.js
function range(x, y) {
if (typeof y === 'undefined') {
y = x;
x = 0;
}
let out = [];
while (x < y) {
out.push(x++);
}
return out;
You can’t perform that action at this time.