Skip to content

Instantly share code, notes, and snippets.

View hhsnopek's full-sized avatar
Working from home

Henry Snopek hhsnopek

Working from home
View GitHub Profile
function SaferHTML(templateData) {
var s = templateData[0];
for (var i = 1; i < arguments.length; i++) {
var arg = String(arguments[i]);
// Escape special characters in the substitution.
s += arg.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;");
@hhsnopek
hhsnopek / gist:9067bbe94ba029c58e96
Last active August 29, 2015 14:22
encode url parameters from obj
var newUrl = "http://localhost:1111/?",
objKeys = [];
objKeys = Object.keys(obj);
for (var u = 0; u < objKeys.length; u++) {
var key = objKeys[u];
newUrl += key + "=" + escape(obj[key]) + "&";
}
var url = "",
obj = {};
url = window.location.href.split('?')[1].split('&');
for (var u = 0; u < url.length; u++) {
var items = url[u].split('=')
obj[items[0]] = unescape(items[1]);
};
@hhsnopek
hhsnopek / gist:3955c5a42f77eecf4375
Last active August 29, 2015 14:22
multiple inheritance
// Coffee
class Animal
this.species;
class Human extends Animal
this.species = "mammal";
this.sex;
class Woman extends Human
this.sex = "female";

Anchors in Markdown?

To create an anchor to a heading in github flavored markdown. Add - characters between each word in the heading and wrap the value in parens (#some-markdown-heading) so your link should look like so:

[create an anchor](#anchors-in-markdown?)

class Settings
constructor: ->
@localStorage = window.localStorage
if @localStorage?
@localStorage =
repo_name: false,
desktop_notifications: true,
oauth_token: ''
@hhsnopek
hhsnopek / aspect-ratio.styl
Last active August 29, 2015 14:04
keeping your aspect ratio with css
// This gist will keep your image or video's aspect ratio at 16:9 and horizontally centered
// [support](//caniuse.com/#feat=viewport-units): IE9+, Firefox 21+, Chrome 27+, Safari 6+, Android 4.4+, BlackBerry 10+
// [credit](//stackoverflow.com/a/20593342)
.video
position: relative
max-height: 100vh
max-width: 177.78vh
width: 100vw
height: 56.25vw
background-color: black
@hhsnopek
hhsnopek / roots-component-hack.md
Last active August 29, 2015 14:03
roots component

Roots Component working hack

  1. create component.json NOTE: Whatever you use as the name in this will be same name you use in step 3
  2. add your components and list /public/js/main.js as your script
  3. in layout.jade remove the require.js script and add:

script(src="js/build.js")
script.
require('name-from-component.js')
### Keybase proof
I hereby claim:
* I am hhsnopek on github.
* I am hhsnopek (https://keybase.io/hhsnopek) on keybase.
* I have a public key whose fingerprint is DBC8 8FD3 DD50 AA75 FF1F F349 63D1 7861 D3ED 8EA1
To claim this, I am signing this object: