Skip to content

Instantly share code, notes, and snippets.

Damon Muma thedamon

View GitHub Profile
thedamon / 'other' selection
Created Jun 8, 2012
Toggles an input after any <select> item with a value of 'other' is chosen
View 'other' selection
if($("select").length) {
$("select").live("change", function(){
if($(this).val() == "Other") {
$(this).after('<input name="'+$(this).attr('name')+'[other]" class="other">');
thedamon / validationbookmarklet
Created Jun 28, 2012
Bookmarklet to validate local file with W3C by RobW (
View validationbookmarklet
javascript:(function(){function c(a,b){var c=document.createElement("textarea");;c.value=b;d.appendChild(c)}var e=function(a){for(var b="",a=a.firstChild;a;){switch(a.nodeType){case Node.ELEMENT_NODE:b+=a.outerHTML;break;case Node.TEXT_NODE:b+=a.nodeValue;break;case Node.CDATA_SECTION_NODE:b+="<![CDATA["+a.nodeValue+"]]\>";break;case Node.COMMENT_NODE:b+="<\!--"+a.nodeValue+"--\>";break;case Node.DOCUMENT_TYPE_NODE:b+="<!DOCTYPE "' PUBLIC "'+a.publicId+'"':"")+(!a.publicId&&a.systemId? " SYSTEM":"")+(a.systemId?' "'+a.systemId+'"':"")+">\n"}a=a.nextSibling}return b}(document),d=document.createElement("form");d.method="POST";d.action="";d.enctype="multipart/form-data";"_blank";c("fragment",e);c("doctype","HTML5");c("group","0");document.body.appendChild(d);d.submit()})();
thedamon / inlinelinks.js
Created Nov 27, 2012
small jquery function to auto-focus inline-linked inputs. Only works for in-page links so far. Feel like this should be default browser behaviour
View inlinelinks.js
thedamon / gist:4158016
Created Nov 27, 2012
1px by 1px square transparent png binary
View gist:4158016
<img width="1" height="1" title="" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABBJREFUeNpi+P//PwNAgAEACPwC/tuiTRYAAAAASUVORK5CYII=" />
View Preferences.sublime-settings
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"detect_slow_plugins": false,
"font_size": 8,
"highlight_modified_tabs": true,
thedamon / MacSublimeKeyboard
Created Feb 16, 2014
Mac OS ST3 keyboard mappings diff
View MacSublimeKeyboard
["super+alt+up"]: "switch_file", "args": {"extensions": ["cpp", "cxx", "cc", "c", "hpp", "hxx", "h", "ipp", "inl", "m", "mm"]} },
["super+alt+s"]: "save_all" },
["super+ctrl+f"]: "toggle_full_screen" },
["super+ctrl+shift+f"]: "toggle_distraction_free" },
["super+option+v"]: "paste_from_history" },
["ctrl+alt+left"]: "move", "args": {"by": "subwords", "forward": false} },
["ctrl+alt+right"]: "move", "args": {"by": "subword_ends", "forward": true} },
["ctrl+alt+shift+left"]: "move", "args": {"by": "subwords", "forward": false, "extend": true} },
["ctrl+alt+shift+right"]: "move", "args": {"by": "subword_ends", "forward": true, "extend": true} },
["ctrl+left"]: "move", "args": {"by": "subwords", "forward": false} },
thedamon / backbutton close bootstrap modal
Created Feb 28, 2014
Cause back button to close Bootstrap modal windows
View backbutton close bootstrap modal
$('div.modal').on('show', function() {
var modal = this;
var hash =;
window.location.hash = hash;
window.onhashchange = function() {
if (!location.hash){
thedamon / glozzarizer-test.json
Created Jun 12, 2015
Glossarizer testing json file
View glozzarizer-test.json
{"term": "black cat", "description":"a black feline"},
{"term": "cat", "description": "meow"}
thedamon / webpack.config.js
Last active Nov 5, 2015
Redux/React/Babel webpack config w production variables
View webpack.config.js
var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var sassLoaders = [
'autoprefixer-loader?browsers=last 2 version',
'sass-loader?includePaths[]=' + __dirname + '/app/styles&sourceMap=true'
//set entry-points and plugins that are the same across dev and prod.
thedamon / domInitor.js
Last active Nov 2, 2018
Vue components on demand; anywhere in your weird/old/headful CMS
View domInitor.js
In a large CMS site (or sites), where content authors can add any component to any page at any time, it's sometimes tricky to figure out how to integrate Vue apps and components in a way that plays well together, especially when we don't want to need to bundle all our javascript on pageload and load stuff that's not necessary on one page or another.
Whatever the backend, DomInitor will take care of initializing Vue (and/or JS coomponents) based on data attributes, but only load the javascript it needs for a given page AND work in IE11.
It works by scanning the HTML of your page for data attributes and using the values of them + webpack to asynchronously load all the js chunks.
There is a lot of code specific to my use case here, but it gives a good example of how to achieve the dream of being able to have Vue components built as SFCs and bundled by webpack easily used within a massive 'legacy'/'oldschool' website while only loading the components used on any given page. (Caveat: because this is run onc
You can’t perform that action at this time.