Skip to content

Instantly share code, notes, and snippets.

Avatar
✍️
writing a status message

Kyle Robinson Young shama

✍️
writing a status message
View GitHub Profile
@shama
shama / promise-no-block.js
Created Apr 20, 2017
promises wont block
View promise-no-block.js
const p = new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, 5000)
})
let interval
p.then(() => {
clearInterval(interval)
@shama
shama / jquery.fetch.js
Created Dec 5, 2016
I wrap jQuery promises in real promises
View jquery.fetch.js
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
requirebin sketch
View index.js
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 Apr 30, 2016
requirebin sketch
View index.js
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 Apr 30, 2016
requirebin sketch
View index.js
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 Mar 30, 2016
requirebin sketch
View index.js
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 Mar 17, 2016
requirebin sketch
View index.js
var yo = require('yo-yo')
var dance = [
'<("<)',
'<( \' \' )>',
'(> ")>',
'<( \' \' )>'
]
var i = 0
@shama
shama / morphdom_events.js
Last active Mar 12, 2016
morphdom with updating event handlers
View morphdom_events.js
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 Feb 8, 2016
YNAB Locale EN
View locale_en.json
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
Alternate way to load CSS file to ensure it gets loaded with a correct path with Electron
View electron-reliable-css-path.html
<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'))