Skip to content

Instantly share code, notes, and snippets.

View iamnoah's full-sized avatar

Noah Perks Sloan iamnoah

  • Texas
  • 11:09 (UTC -05:00)
View GitHub Profile
@iamnoah
iamnoah / alpha.js
Created June 4, 2013 18:01
JSShaper script to alphabetize object literals.
/**
* Usage:
* 1. git clone git://github.com/olov/jsshaper.git
* 2. mv alpha.js plugins/
* 3. node run-shaper.js TARGET_FILE plugins/alpha.js --source > ALPHABATIZED_FILE
*/
if (typeof define !== 'function') { var define = require('amdefine')(module); }
define(['../shaper', '../fmt', '../ref', '../tkn'], function(Shaper, Fmt, Ref, tkn) {
"use strict"; "use restrict";
/*
* jQuery++ - 1.0.0 (2012-11-23)
* http://jquerypp.com
* Copyright (c) 2012 Bitovi
* Licensed MIT
*/
(function (window, $, undefined) {
// ## jquery/dom/styles/styles.js
var getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
// The following variables are used to convert camelcased attribute names
@iamnoah
iamnoah / performance.md
Created August 3, 2012 22:18
Performance Best Practices

When it comes to performance, never listen to anyone who tells you using some feature of JavaScript is slow (unless they tell you it's slow in an old version of a browser like IE8). Inevitably, one of the following will be true:

  1. X was slower than Y, but it isn't anymore.

  2. X is slower than Y, but it doesn't matter because that's not where your performance bottleneck is.

  3. X is slower than Y, but when the browsers auto-update tomorrow, X could be faster.

For example, we all know switch is slow. (Go ahead and follow the link. I'll wait.) Ooops. I hope you didn't spend a lot of time removing switches or complicate your code based on someone else's advice. If you did, I hope you did it because you had profiling data that proved that your performance bottleneck was the switch statement. Yea, that didn't happen. Well, at least you were following a [best practice](https://en.wikipedia.org/wiki/Cargo_cult_programmin

@iamnoah
iamnoah / writeCapture2.js
Created July 27, 2012 02:59
Working on <IE9 support
/**
* Totaly rewritten writeCapture, based on element.write.
*
* Usage:
*
* writeCapture(targetElement).
* write(someHtml).
* close(); // must be sure to close()
*
* Script tags in anything written will automatically be captured, such
@iamnoah
iamnoah / sequence-writes.js
Created July 25, 2012 13:58
WriteCapture2 multiple writes in sequence
var lastWrite = $.Deferred();
lastWrite.resolve();
$.fn.write = function(html) {
return this.each(function() {
var def = $.Deferred();
var el = this;
lastWrite.then(function() {
writeCapture(el,function() { def.resolve(); }).close(html);
on run
tell application "Google Chrome"
set allWins to every window
set allTabs to {}
repeat with currWin in allWins
set allTabs to allTabs & every tab of currWin
end repeat
repeat with currTab in allTabs
try
if (title of currTab as string) contains "Google Play" then set musicTab to currTab
@iamnoah
iamnoah / gist:1205147
Created September 9, 2011 00:04
ad code for writeCapture issue #34
document.write('<!-- Copyright 2008 DoubleClick, a division of Google Inc. All rights reserved. -->\r\n<!-- Code auto-generated on Wed Aug 17 00:56:46 EDT 2011 -->\r\n<script src=\"http://s0.2mdn.net/879366/flashwrite_1_2.js\"><\/script>');document.write('\r\n');
function DCFlash(id,pVM){
var swf = "http://s0.2mdn.net/1540282/Tribeca_Snow_300x250.swf";
var gif = "http://s0.2mdn.net/1540282/Tribeca_Snow_300x250.jpg";
var minV = 8;
var FWH = ' width="300" height="250" ';
var url = escape("http://ad.au.doubleclick.net/6k%3Bh%3Dv8/3b7c/3/0/%2a/m%3B245013661%3B0-0%3B0%3B69607616%3B4307-300/250%3B43590106/43607893/1%3Bu%3Dpos%3D1%2Cpagetype%3Dindex%3B%7Eaopt%3D0/ff/27/ff%3B%7Efdr%3D244965911%3B0-0%3B2%3B28037886%3B4307-300/250%3B43590502/43608289/1%3Bu%3Dpos%3D1%2Cpagetype%3Dindex%3B%7Eokv%3D%3Bsec1%3Dtest%3Btile%3D3%3Bpos%3D1%3B%3Bsz%3D300x250%3Bkw%3Dnews%2Cworld%2Casia%3Bk%3Dv%3Bu%3Dpos%3D1%2Cpagetype%3Dindex%3B%7Eaopt%3D2/1/27/2%3B%7Esscs%3D%3fhttp://subaru.com.au/tribeca?utm_source=display&utm_medium=display&u
@iamnoah
iamnoah / EntityBuilder.java
Created May 22, 2011 02:45
Simple DSL for creating GAE Entities
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;
/**
* Example (groovy syntax, but works just as well in Java):
* <pre>
EntityBuilder.build("Library").
key(key). // can create your own Key instance
SERVER=yourdevserver.com
CODE_DIR=/var/www/html/
git diff | ssh $SERVER -C "cd $CODE_DIR; patch -p1"
<?php
$magePath = 'app/Mage.php';
require_once $magePath;
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$types = array("config", "layout", "block_html", "translate", "collections", "eav", "config_api", "full_page");
foreach($types as $type) {
Mage::app()->getCacheInstance()->cleanType($type);
}