Skip to content

Instantly share code, notes, and snippets.

View jeremyckahn's full-sized avatar

Jeremy Kahn jeremyckahn

View GitHub Profile
@jeremyckahn
jeremyckahn / fix-lateralus-file-names.sh
Created February 10, 2015 21:31
Rename Lateralus component files to reference the component to which they belong.
#!/bin/bash
COMPONENTS_PATH="app/scripts/components"
TEMP_FILE="/tmp/temp.js"
for COMPONENT in `ls $COMPONENTS_PATH`; do
COMPONENT_PATH="$COMPONENTS_PATH/$COMPONENT"
git mv $COMPONENT_PATH/main.js $COMPONENT_PATH/$COMPONENT.js
git mv $COMPONENT_PATH/view.js $COMPONENT_PATH/$COMPONENT-view.js
git mv $COMPONENT_PATH/template.mustache $COMPONENT_PATH/$COMPONENT-template.mustache
@jeremyckahn
jeremyckahn / stylie-data-format.json
Last active August 29, 2015 14:12
The JSON format for Stylie localStorage data.
{
"savedAnimations": {
"__transientAnimation": {
"actorModel": {
"transformPropertyCollection": [
{
"x": 50,
"y": 489,
"millisecond": 0,
"isCentered": true,
/* global console: true */
var module = (function () {
function privateFn () {
console.log('I am a private function!');
return 8;
}
var privateVar;
return {
/* global global: true */
function Constructor () {
this.instanceMethod();
Constructor.staticMethod();
function privateFunction () {
global.console.log('Hello, I am an internal function! XD');
}
}
------------------------------------------------------------
/usr/local/bin/pip run on Mon Dec 1 09:37:52 2014
Downloading/unpacking tamper
Getting page https://pypi.python.org/simple/tamper/
URLs to search for versions for tamper:
* https://pypi.python.org/simple/tamper/
Analyzing links from page https://pypi.python.org/simple/tamper/
Skipping link https://pypi.python.org/packages/any/t/tamper/tamper-0.10.macosx-10.9-intel.exe#md5=536fad086837b19def97f5a97b2f64cb (from https://pypi.python.org/simple/tamper/); unknown archive format: .exe
Skipping link https://pypi.python.org/packages/any/t/tamper/tamper-0.11.macosx-10.9-intel.exe#md5=19d1c8f8f5c34d372b61ba7a570dfa19 (from https://pypi.python.org/simple/tamper/); unknown archive format: .exe
Skipping link https://pypi.python.org/packages/any/t/tamper/tamper-0.12.macosx-10.9-intel.exe#md5=b38c08843afbde2b7f8aaa7946060db0 (from https://pypi.python.org/simple/tamper/); unknown archive format: .exe
@jeremyckahn
jeremyckahn / log-local-storage.js
Created November 21, 2014 16:15
Browse localStorage more easily.
// #protip: Save this as a Chrome Devtools snippet!
// http://www.briangrinstead.com/blog/devtools-snippets
Object.keys(window.localStorage).forEach(function (key) {
console.log(key, JSON.parse(window.localStorage[key]));
});
@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);
@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 / 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 / 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'))();
})();