Skip to content

Instantly share code, notes, and snippets.

View emilisto's full-sized avatar

Emil Stenqvist emilisto

  • Stockholm
View GitHub Profile
(function(global) {
// Globals
if(!global.Silp) { global.Silp = {}; };
var Silp = global.Silp;
// To keep track of which embeds we have already processed
if(!Silp.foundEls) Silp.foundEls = [];
var foundEls = Silp.foundEls;
var els = document.getElementsByTagName('script');
var parseQueryString = function(url) {
var a = document.createElement('a');
a.href = url;
str = a.search.replace(/\?/, '');
return deparam(str, true /* coerce values, eg. 'false' into false */);
};
// And in the script tags loop
var info = parseQueryString(el.src);
<script src="//diu127fbe6pn6.cloudfront.net/shootitlive.load.v1.js?project=13&client=greenfield" async></script>
@emilisto
emilisto / pickAll.js
Created October 5, 2012 11:13
pickAll: tiny underscore extension by @svammel
/*
* pickAll: tiny underscore extension by @svammel
*
* Example:
*
* var users = [
* { "user": "john", "email": "[email protected]", "url": "www.john.com" },
* { "user": "pete", "email": "[email protected]", "url": "www.pete.com" }
* ];
*
@emilisto
emilisto / backbone.onenter.js
Created October 11, 2012 08:43
`onenter` event in Backbone.View
/*
* Implements 'onenter' event for `events` object in Backbone.View.
* Author: Emil Stenqvist <[email protected]>
*/
(function(global) {
var Backbone = global.Backbone;
if(!Backbone) throw "this shim needs Backbone";
var delegateEvents = Backbone.View.prototype.delegateEvents;
var $el = $(el);
var width = $el.width();
while($el.length) {
console.log('el: %o width: %o', $el, $el.width());
$el = $($el.parent());
}
@emilisto
emilisto / vimguide.md
Last active December 11, 2015 19:28
Short guide I wrote up for some friends

Emil's short guide to vim

There are two modes in vim:

  1. Command mode – you can't write stuff, keys are interpreted as commands.
  2. Insert mode - it acts like a normal editor, you know you're in insert mode because it says "INSERT" at the bottom.

The most important ones

  • a – enter insert mode from command mode
  • ESCAPE – enter command mode from insert mode
[user]
name = Emil Stenqvist
email = [email protected]
[branch]
autosetuprebase = always
[color]
diff = auto
status = auto
function abbreviate(str, maxlen) {
maxlen = maxlen || 15;
var fullLength = str.length;
str = str.substr(0, maxlen);
if(str.length < fullLength) str += '...';
return str;
}
# This is the default .slate file.
# If no ~/.slate file exists this is the file that will be used.
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
# Resize Bindings
bind right:shift;ctrl resize +10% +0
bind left:shift;ctrl resize -10% +0