Skip to content

Instantly share code, notes, and snippets.

View jaketrent's full-sized avatar
🎹
Coding a power ballad

Jake Trent jaketrent

🎹
Coding a power ballad
View GitHub Profile
@jaketrent
jaketrent / main.js
Created February 23, 2018 14:10
Simple electron main.js
const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
let mainWindow
app.on('ready', _ => {
mainWindow = new BrowserWindow({
height: 400,
@jaketrent
jaketrent / client-usage.js
Created August 7, 2017 19:14
glamorous glamor.css as className
<P className={glamor.css({ color: 'blue' })}>wow</P>
@jaketrent
jaketrent / dom.js
Created March 7, 2016 19:35
jsdom with localStorage
import jsdomGlobal from 'jsdom-global'
import jsdom from 'jsdom'
import localStorage from 'localStorage'
const doc = jsdom.jsdom('<!doctype html><html><body></body></html>')
const win = doc.defaultView
win.localStorage = localStorage
global.document = doc
global.window = win
jsdomGlobal()
.container {
display: flex;
height: 75px;
line-height: 75px;
justify-content: flex-start;
margin-bottom: 30px;
}
.container > div {
overflow: hidden;
white-space: nowrap;
@jaketrent
jaketrent / dom.js
Created March 7, 2016 19:35
jsdom with localStorage
import jsdomGlobal from 'jsdom-global'
import jsdom from 'jsdom'
import localStorage from 'localStorage'
const doc = jsdom.jsdom('<!doctype html><html><body></body></html>')
const win = doc.defaultView
win.localStorage = localStorage
global.document = doc
global.window = win
jsdomGlobal()
@jaketrent
jaketrent / exportsExample.css
Created March 5, 2016 17:59
CSS modules when using exports
:export {
className: 'composedHashedClassName hashedClassName'; 
}
@jaketrent
jaketrent / areaUnderLineAnimation1.js
Created February 5, 2016 18:21
Animate area under line (line and area separate, animate unsync'ed)
import d3 from 'd3'
import css from './index.css'
const rawData = [{'date':'2016-01-06','hours':2.7},{'date':'2016-01-07','hours':1.735},{'date':'2016-01-08','hours':0.5219},{'date':'2016-01-09','hours':0.0},{'date':'2016-01-10','hours':0.0},{'date':'2016-01-11','hours':2.2708},{'date':'2016-01-12','hours':1.2692},{'date':'2016-01-13','hours':0.2219},{'date':'2016-01-14','hours':3.2722},{'date':'2016-01-15','hours':0.3353},{'date':'2016-01-16','hours':0.5389},{'date':'2016-01-17','hours':0.0},{'date':'2016-01-18','hours':1.3308},{'date':'2016-01-19','hours':2.1228},{'date':'2016-01-20','hours':1.0539},{'date':'2016-01-21','hours':0.0},{'date':'2016-01-22','hours':1.2525},{'date':'2016-01-23','hours':1.8133},{'date':'2016-01-24','hours':1.9583},{'date':'2016-01-25','hours':3.3772},{'date':'2016-01-26','hours':0.9175},{'date':'2016-01-27','hours':0.4208},{'date':'2016-01-28','hours':0.0},{'date':'2016-01-29','hours':1.1847},{'date':'2016-01-30','hours':0.0175},{'date':'2016-01-31','hours':0.49},{'date':'2016-0
@jaketrent
jaketrent / simple-promise-retry.js
Created January 14, 2016 17:36 — forked from briancavalier/simple-promise-retry.js
A few general patterns for retries using promises
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);
@jaketrent
jaketrent / gist:7753020
Created December 2, 2013 17:21
Create NSMutableAttributedString
UIFont *textFont = [UIFont fontWithName:@"Helvetica" size:40];
UIColor *textForegroundColor = [UIColor blackColor];
NSMutableParagraphStyle* textParagraphyStyle = [[NSMutableParagraphStyle alloc] init];
textParagraphyStyle.lineSpacing = 15;
NSMutableAttributedString* pageText =
[[NSMutableAttributedString alloc] initWithString:@"Wow, text is being muted."
attributes:@{ NSParagraphStyleAttributeName: textParagraphyStyle,
@jaketrent
jaketrent / d3-gauge.markdown
Last active December 24, 2015 02:19
D3 Gauge