Skip to content

Instantly share code, notes, and snippets.

View erming's full-sized avatar
Tinkering.

Mattias Erming erming

Tinkering.
  • Software Contractor
  • Sweden
View GitHub Profile
@erming
erming / test.txt
Last active August 29, 2015 13:58
test.txt
This is just a test.
@erming
erming / jquery.bringToTop.js
Last active August 29, 2015 14:00
jquery.toTop.js
/*!
* bringToTop
* https://gist.github.com/erming/11193183
*/
(function($) {
var highest = 1;
$.fn.bringToTop = function() {
return this.css('z-index', highest++);
};
})(jQuery);
@erming
erming / lodash_model.js
Last active August 29, 2015 14:00
lodash_model.js
var _ = require("lodash");
function Model(attr) {
_.merge(this, _.extend({
id: 1, // this.id
text: "", // this.text
}, attr));
};
var m = new Model({
@erming
erming / jquery.uniqueClass.js
Last active August 29, 2015 14:00
jquery.uniqueClass.js
/*!
* uniqueClass
* https://gist.github.com/erming/11212325
*/
(function($) {
$.fn.uniqueClass = function(name) {
return this.addClass(name).siblings().removeClass(name).end();
};
})(jQuery);
@erming
erming / String.contains.js
Last active August 29, 2015 14:00
String.contains.js
//
// Check if string contains any of the supplied words.
//
// Usage:
// "".contains(a, b, ...);
//
// Returns [true|false]
//
String.prototype.contains = function() {
var args = arguments;
@erming
erming / .bash_aliases
Created May 1, 2014 16:25
.bash_aliases
alias t1='tree -L 1'
alias t2='tree -L 2'
alias t3='tree -L 3'
@erming
erming / last.js
Created May 5, 2014 23:47
last.js
// Get the last word of a string.
function last(str) {
return str.trim().split(" ").pop();
}
@erming
erming / overflow-scrolling.html
Last active August 29, 2015 14:02
-webkit-overflow-scrolling
<!doctype html>
<html>
<head>
<title>-webkit-overflow-scrolling</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no">
<style>
@erming
erming / mustache.render.js
Last active August 29, 2015 14:02
Render helper with template caching.
// Requires:
// <script src="mustache.js"></script>
// Template cache
var tpl = [];
//
// Render templates.
//
// Usage:
@erming
erming / escape.js
Created June 3, 2014 16:52
escape.js
function escape(text) {
var e = {
"<": "&lt;",
">": "&gt;"
};
return text.replace(/[<>]/g, function (c) {
return e[c];
});
}