Skip to content

Instantly share code, notes, and snippets.

View jeremyckahn's full-sized avatar

Jeremy Kahn jeremyckahn

View GitHub Profile
@jeremyckahn
jeremyckahn / gist:8833629
Created February 5, 2014 21:34
Have OS X read every word in the dictionary
curl https://raw2.github.com/atebits/Words/master/Words/en.txt | while read line; do say $line; done
@jeremyckahn
jeremyckahn / responsive-rekapi.js
Created February 22, 2014 18:38
An example of a potential way to use Rekapi in a responsive design
var rekapi = new Rekapi(document.body);
var actor = rekapi.addActor({context: document.getElementById('my-actor')});
// Assumes isMobile is defined somewhere
if (isMobile()) {
actor
.keyframe(0, {
transform: 'translateX(0px) translateY(0px)'
})
@jeremyckahn
jeremyckahn / kineticjs-rekapi.js
Last active August 29, 2015 13:56
A potential way to use KineticJS with Rekapi.
var rekapi = new Rekapi();
var textPathActor = rekapi.addActor({
// This actor setup function performs some initial preparation work. This is
// where KineticJS is set up and given an initial state.
setup: function () {
var stage = new Kinetic.Stage({
container: 'container',
width: 578,
height: 220
});
@jeremyckahn
jeremyckahn / gist:9339820
Last active August 29, 2015 13:56
Shifty/Date.js compatibility fix
<!DOCTYPE html>
<html>
<script src="shifty.js"></script>
<script src="date.js"></script>
<script>
var tweenable = new Tweenable();
tweenable.tween({
from: { 'x': 0 },
var backcoloractortxt = rekapi.addActor(
new Rekapi.Actor({
'render': function (context, state) {
context.beginPath();
var titleheight = 40;
context.font = titleheight*state.scale+"px Arial";
context.measureText("Bardon Update").width;
var w = context.measureText("HomePrezzo").width;
context.font = (titleheight/2)*state.scale+"px Arial";
var w2 = context.measureText("Bardon Update").width;
{
"paths": {
"text": "path/to/text",
"underscore": "empty:",
"extra-module": "empty:",
"main-module": "main"
},
"baseUrl": "./",
"out": "out.js",
"optimize": "uglify",
@jeremyckahn
jeremyckahn / get_global.js
Last active August 29, 2015 13:57
Access the global JavaScript object from any context, even in strict mode.
(function () {
// Strict mode is not necessary here, it's just used to demonstrate that this works.
'use strict';
return (new Function ('return this'))();
})();
@jeremyckahn
jeremyckahn / merge-objects.js
Created June 2, 2014 16:07
Merge two objects, similar to $.extend(true). Requires underscore.js.
function mergeObjects (target, source) {
var prop;
for (prop in source) {
if (source.hasOwnProperty(prop)) {
if (_.isObject(target[prop]) && _.isObject(source[prop])) {
mergeObjects(target[prop], source[prop]);
} else {
target[prop] = source[prop];
}
@jeremyckahn
jeremyckahn / downloadTextAsFile.js
Created September 23, 2014 19:30
downloadTextAsFile.js
function downloadTextAsFile(text, fileName) {
var a = document.createElement('a');
var url = window.URL.createObjectURL(new Blob([text], { type: 'text/plain' }));
a.href = url;
a.download = fileName || 'file.txt';
a.click();
window.URL.revokeObjectURL(url);
}
@jeremyckahn
jeremyckahn / script.js
Created November 13, 2014 04:05
A Pen by Jeremy Kahn.
var tween = new Tweenable({}, {
from: { x: 0 },
to: { x: 10 },
duration: 1000,
step: function (state) {
console.log(state);
}
});
tween.seek(50);