Skip to content

Instantly share code, notes, and snippets.

View shama's full-sized avatar
✍️
writing a status message

Kyle Robinson Young shama

✍️
writing a status message
View GitHub Profile
@shama
shama / promise-no-block.js
Created April 20, 2017 22:49
promises wont block
const p = new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, 5000)
})
let interval
p.then(() => {
clearInterval(interval)
@shama
shama / jquery.fetch.js
Created December 5, 2016 17:26
I wrap jQuery promises in real promises
function fetch (uri) {
return new Promise(function (resolve, reject) {
$.ajax(uri).then(function (data, textStatus, jqXHR) {
resolve([data, textStatus, jqXHR])
}).fail(function (jqXHR, textStatus, errorThrown) {
reject([jqXHR, textStatus, errorThrown])
})
})
}
@shama
shama / index.js
Created May 17, 2016 20:33
requirebin sketch
var yo = require('yo-yo')
var root = render(5)
document.body.appendChild(root)
document.body.style.backgroundColor = 'green'
function roundBox (x, y, w, h, r) {
return `M${x},${y + r} a${r},${r} 0 0,1 ${r},-${r} l${w - r * 2},0 a${r},${r} 0 0,1 ${r},${r} l0,${h - r * 2} a${r},${r} 0 0,1 -${r},${r} l-${Math.max(0, w - r * 2)},0 a${r},${r} 0 0,1 -${r},-${r} l0,-${Math.max(0, h - r * 2)} Z`
}
@shama
shama / index.js
Created April 30, 2016 16:11
requirebin sketch
var yo = require('yo-yo')
var csjs = require('csjs')
var style = csjs`
.enter {
animation-duration: 3s;
animation-name: slidein;
}
.exit {
animation-duration: 3s;
@shama
shama / index.js
Created April 30, 2016 16:11
requirebin sketch
var yo = require('yo-yo')
var csjs = require('csjs')
var style = csjs`
.enter {
animation-duration: 3s;
animation-name: slidein;
}
.exit {
animation-duration: 3s;
@shama
shama / index.js
Created March 30, 2016 03:11
requirebin sketch
var yo = require('yo-yo')
// Adapted from http://codepen.io/tvweinstock/details/MamJjQ/
function checkerboard (data) {
data = data || {}
var size = data.size || 10
var color = data.color || 'rgba(159, 188, 191, 0.4)'
var id = 'checkerboard' + Date.now()
var fill = 'url(#' + id + ')'
@shama
shama / index.js
Created March 17, 2016 18:34
requirebin sketch
var yo = require('yo-yo')
var dance = [
'<("<)',
'<( \' \' )>',
'(> ")>',
'<( \' \' )>'
]
var i = 0
@shama
shama / morphdom_events.js
Last active March 12, 2016 02:05
morphdom with updating event handlers
var yo = require('yo-yo')
var orig = yo`<button onclick=${function () {
console.log('orig clicked!')
}}>click</button>`
setTimeout(function () {
var newbutton = yo`<button onclick=${function () {
console.log('new clicked!')
}}>click new</button>`
@shama
shama / locale_en.json
Last active February 8, 2016 18:33
YNAB Locale EN
Ember.I18n.translations = {
"app.done": "Done",
"app.continue": "Continue",
"app.ok": "OK",
"app.okay": "Okay",
"app.save": "Save",
"app.send": "Send",
"app.delete": "Delete",
"app.cancel": "Cancel",
"app.back": "Back",
@shama
shama / electron-reliable-css-path.html
Created May 25, 2015 17:33
Alternate way to load CSS file to ensure it gets loaded with a correct path with Electron
<html>
<head>
<title></title>
</head>
<body>
Hi
<script>
var link = document.createElement('link')
link.setAttribute('rel', 'stylesheet')
link.setAttribute('href', require('path').join(__dirname, 'css', 'app.css'))