Skip to content

Instantly share code, notes, and snippets.

View sebmarkbage's full-sized avatar

Sebastian Markbåge sebmarkbage

View GitHub Profile
@sebmarkbage
sebmarkbage / moduleFunction.js
Created February 29, 2012 19:58
Module Function Export
module M {
function B(){ return 'B'; };
export this A(){ A = B; return 'A'; };
}
M(); // 'A'
M(); // ?
// If the second call yields 'B' then this should be ok as well:
function require(module){
if (module.cached) return module.cached;
module(module.cached = {});
return module.cached;
};
function MODULE1(exports){
};
function MODULE2(exports){
@sebmarkbage
sebmarkbage / Work.js
Created March 11, 2012 15:12
Module Compilation
(function(){
var a, b, c;
function A(){
if (a) return a;
var exports = a = {};
var n = 'foo';
var x = function(){
@sebmarkbage
sebmarkbage / DeferedModules.js
Created March 12, 2012 20:00
Defered Modules
// Deferred Labeled Modules.js
require: 'Foo';
function LoadSomething(){
var a = 'A'; // Synchronous
alert('Will now start loading the Foo module');
defer: {
@sebmarkbage
sebmarkbage / nothis.js
Created March 22, 2012 17:52
Super calls
var currentInstance;
function parent(){
currentInstance.parent();
}
function wrapMethod(method){
return function(){
var previousInstance = currentInstance;
currentInstance = this;
@sebmarkbage
sebmarkbage / bootstrap.js
Created March 22, 2012 21:16
Using options
var loader = require('../path/to/link');
loader.alias('package', '../path/to/package.js');
loader.alias('package2', '../path/to/package2.js');
loader.base('../path/to/my/root/folder/');
loader.load('main');
public static class UrlHelperExtensions
{
public static string SmartAction(this UrlHelper url, object values)
{
return SmartAction(url, null, values);
}
public static string SmartAction(this UrlHelper url, RouteValueDictionary valueCollection)
{
return SmartAction(url, null, valueCollection);
@sebmarkbage
sebmarkbage / browser-logos.svg
Created October 14, 2012 22:37
Browser Logos
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
var originalFunction = obj.myMethod;
obj.myMethod = function(){
// Before
console.log('before myMethod on ', this);
var result = originalFunction.apply(this, arguments);
// After
console.log('after myMethod on ', this);
return result;
};
@sebmarkbage
sebmarkbage / cat.js
Last active December 14, 2015 14:58 — forked from dherman/cat.js
// EXAMPLE: a compound iterator with sequencing
// Python style
function cat() {
let is = arguments;
return {
next: {
let length;
while ((length = is.length) > 0) {
try {