Skip to content

Instantly share code, notes, and snippets.


Harrison Shoff hshoff

View GitHub Profile
mattdesl /
Last active Aug 31, 2016
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
toolmantim /
Created Apr 25, 2012
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
alandipert / reinvoke.cljs
Last active Jun 22, 2019
It's sweet that IFn is a protocol in ClojureScript
View reinvoke.cljs
(extend-type js/RegExp
(-invoke ([this s] (re-matches this s))))
(#"foo.*" "foobar") ;=> "foobar"
(#"zoo.*" "foobar") ;=> nil
(filter #".*foo.*" ["foobar" "goobar" "foobaz"]) ;=> ("foobar" "foobaz")
View image_replacer.js
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",
reissbaker / selectKeys.js
Created Jan 12, 2012
key selection, remapping
View selectKeys.js
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;
cowboy / ba-detach.js
Created Apr 23, 2011
JavaScript detach: detach a node from the DOM, optionally reattaching it when done.
View ba-detach.js
* JavaScript detach - v0.2 - 5/18/2011
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
function detach(node, async, fn) {
hshoff / Blackbored2.xml
Created Feb 5, 2011
Textmate's Blackboard theme for RubyMine round 2.
View Blackbored2.xml
<?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" />
<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" />
View module_pattern_init.js
// JS Module Pattern:
// Redefine: $, window, document, undefined.
var APP = (function($, window, document, undefined) {
// Automatically calls all functions in APP.init
$(document).ready(function() {
You can’t perform that action at this time.