Skip to content

Instantly share code, notes, and snippets.

View hshoff's full-sized avatar
📊

Harrison Shoff hshoff

📊
View GitHub Profile
@nathansmith
nathansmith / module_pattern_init.js
Created January 11, 2010 17:08
Init + Module Pattern JS
// JS Module Pattern:
// http://j.mp/module-pattern
// Redefine: $, window, document, undefined.
var APP = (function($, window, document, undefined) {
// Automatically calls all functions in APP.init
$(document).ready(function() {
APP.go();
});
@hshoff
hshoff / Blackbored2.xml
Created February 5, 2011 01:11
Textmate's Blackboard theme for RubyMine round 2.
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="Blackbored" version="1" parent_scheme="Default">
<option name="LINE_SPACING" value="1.25" />
<option name="EDITOR_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Monaco" />
<colors>
<option name="ANNOTATIONS_COLOR" value="3e83e7" />
<option name="CARET_COLOR" value="" />
<option name="CARET_ROW_COLOR" value="40436" />
<option name="CONSOLE_BACKGROUND_KEY" value="0" />
@cowboy
cowboy / ba-detach.js
Created April 23, 2011 16:43
JavaScript detach: detach a node from the DOM, optionally reattaching it when done.
/*!
* JavaScript detach - v0.2 - 5/18/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
function detach(node, async, fn) {
@reissbaker
reissbaker / selectKeys.js
Created January 12, 2012 19:04
key selection, remapping
var selectKeys = function(hash, keys) {
var output, prop, index;
output = {};
if(!keys) return {};
if(keys instanceof Array) {
for(index = 0; index < keys.length; index++) {
output[keys[index]] = hash[keys[index]];
}
return output;
if (typeof (AC) === "undefined") {
AC = {}
}
AC.ImageReplacer = Class.create({
_defaultOptions: {
listenToSwapView: true,
filenameRegex: /(.*)(\.[a-z]{3}($|#.*|\?.*))/i,
filenameInsert: "_☃x",
ignoreCheck: /(^http:\/\/movies\.apple\.com\/|\/105\/|\/global\/elements\/quicktime\/|_(([2-9]|[1-9][0-9]+)x|nohires)(\.[a-z]{3})($|#.*|\?.*))/i,
attribute: "data-hires",
@alandipert
alandipert / reinvoke.cljs
Last active June 22, 2019 00:20
It's sweet that IFn is a protocol in ClojureScript
(extend-type js/RegExp
cljs.core/IFn
(-invoke ([this s] (re-matches this s))))
(#"foo.*" "foobar") ;=> "foobar"
(#"zoo.*" "foobar") ;=> nil
(filter #".*foo.*" ["foobar" "goobar" "foobaz"]) ;=> ("foobar" "foobaz")
@toolmantim
toolmantim / router.coffee
Created April 25, 2012 14:46
A Backbone.js router subclass that disables the hash fallback mechanism in favour of just navigating to the location (just like a normal link would behave)
class MyApp.Router extends Backbone.Router
hasPushState: window.history and window.history.pushState
# Override the navigate function to remove Backbone's #hash fallback for
# non-pushState browsers. Instead we just navigate to the new location using
# window.location
navigate: (fragment, trigger) ->
if @hasPushState
super(arguments...)
@mattdesl
mattdesl / electron-hurdles.md
Last active August 31, 2016 14:22
Electron + Node hurdles

A short list of hurdles to get Electron working more like Node, and how I'm tackling them.

  • using renderer process.stdin with Buffer seems difficult/impossible
    • alternative: send buffered stdin as a string to the renderer
  • renderer process.argv needs to be require('remote').process.argv
    • should be patched in preload script to ensure your Node dependencies work correctly
  • syntax errors in <script src="index.js"> do not print to terminal
    • window.onerror in a preload script can be used to detect these problems
    • only provides file, line number and a minimal error message
  • stderr gets cluttered with Chromium logs