Skip to content

Instantly share code, notes, and snippets.


Sebastian Markbåge sebmarkbage

View GitHub Profile
sebmarkbage /
Last active Aug 29, 2015
Object Rest Destructuring and Spread Initializer (ES7 proposal)
sebmarkbage / Before.js
Last active Aug 29, 2015
Google DCE Method
View Before.js
// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @output_file_name default.js
// ==/ClosureCompiler==
* @constructor
function Foo(name) { = name;
View Element.truncate.js
truncates element text to fit in element width.
end (bool) defaults false. True = cuts string at end, False = cuts string in middle
str (string) truncation string default : '...'
truncate : function(end,str){
str = str || '...';
var style =;
var originalStyles = { overflow: style.overflow, 'white-space': style.whiteSpace, padding: style.padding };
View animation.js
name: Animation
description: Simple animations implementation that work with standard-sized browsers (using Fx) and use webkit css animations where available.
license: MooTools MIT-Style License (
copyright: Valerio Proietti (
authors: Valerio Proietti (
requires: MooTools 1.2.3+ (Core) (
var Animation = new Class({
View MyLocalArrayCopy.js
original: 'urn:Sheer:Lang:Array',
require: {
'urn:Sheer:Lang': ['Type', 'Object', 'Function']
}, function(Type, Object, Function) {
View Element.Draggable.js
@import Event.Drag.js
Script: Element.Draggable.js
Enables HTML 5 drag operation events in legacy browsers.
MIT-style license.
View EnumFix.js
var dontEnum = ['toString', 'toLocaleString', 'valueOf', 'toSource', 'watch', 'unwatch', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable'];
var failsEnumTest = (function(){
for (var k in { toString: {} }) return false;
return true;
Object.each = function(obj, fn){
for (var key in obj) fn(obj[key], key);
if (failsEnumTest)
for (var i=0,l=dontEnum.length;i<l;i++){
View Request.XDR.js
if (window.XDomainRequest) (function(){
var onLoad = function(){
this.response = {text: this.xhr.responseText, xml: this.xhr.responseXML};
this.success(this.response.text, this.response.xml);
var onError = function(){
View Array.Reduce.js
script: Array.Reduce.js
description: Extends Array with reduce and reduceRight methods in browsers that don't support them.
license: MIT-style license.
View ReallyOldAutoCompleterPatch.js
choiceOver: function(choice, selection){
if (!selection && this.options.forceSelect) this.selectedValue = this.opted = choice.inputValue;
return this.parent.apply(this, arguments);
hideChoices: function(clear){
if (clear && this.options.forceSelect && (!this.visible || !this.selected) && this.element.value != this.opted) {
this.opted = "";