Skip to content

Instantly share code, notes, and snippets.

View snichme's full-sized avatar

Magnus Landerblom snichme

View GitHub Profile
@snichme
snichme / Scroller.js
Created October 25, 2013 01:22
Scroller service for Angular
(function() {
'use strict';
angular.module('ngExtensionsApp')
.factory('Scroll', function($window, $timeout) {
var wait = 100,
callbacks = [],
timeout_identifier = null;
function onScroll(event) {
$timeout.cancel(timeout_identifier);
@snichme
snichme / foo.js
Created December 5, 2013 20:35
Requirejs + Angular Injectable modules
// Blank file, will be removed during build
@snichme
snichme / Maybe.js
Last active August 29, 2015 13:57
Maybe.js
class Maybe {
constructor(val) {
this.val = val;
}
map(f) {
return this.val ? new Maybe(f(this.val)) : new Maybe();
}
toString() {
@snichme
snichme / g
Created June 18, 2014 12:33
Grunt or Gulp or Broccoli
#!/bin/zsh
if [ -s gruntfile.js ]; then
grunt $@
elif [ -s gulpfile.js ]; then
gulp $@
elif [ -s brocfile.js ]; then
broccoli $@
else
echo "No build file found, checked for gruntfile.js, gulpfile.js and brocfile.js"
exit -1
@snichme
snichme / impossible.js
Created September 18, 2014 18:28
Impossible js
var a = {
v: false,
valueOf: function() {
return this.v = !this.v;
}
};

Keybase proof

I hereby claim:

  • I am snichme on github.
  • I am mange (https://keybase.io/mange) on keybase.
  • I have a public key whose fingerprint is 1932 4B35 EC8A 5A99 421F 5384 B6D3 5474 91A5 1E7D

To claim this, I am signing this object:

@snichme
snichme / models.js
Created November 5, 2014 21:04
JS model with mixins
(function() {
'use strict';
/** Helper methods */
function merge(obj1, obj2) {
Object.keys(obj2).forEach(function(key) {
obj1[key] = obj2[key];
});
return obj1;
}
@snichme
snichme / di.js
Created October 14, 2015 18:48
Dependency Injection in JavaScript
var di = (function Dein() {
var FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m;
var FN_ARG_SPLIT = /,/;
var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/;
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
var _register = {};
function anno(fn, strictDi, name) {
var fnText, argDecl, args;
(ns om-tutorial.mini
(:require [goog.dom :as gdom]
[om.next :as om :refer-macros [defui]]
[om.dom :as dom]))
(enable-console-print!)
(def init-data
{:cards [{:id 1 :title "Title 1"}
{:id 2 :title "Title 2"}
(ns chestnut-app.core
(:require [om.next :as om :include-macros true]
[om.dom :as dom :include-macros true]
[compassus.core :as c]
[pushy.core :as pushy]
[goog.dom :as gdom]
[chestnut-app.ui :as ui]
[chestnut-app.parser :refer [read mutate]]
[chestnut-app.util :refer [transit-post]]
[chestnut-app.router :as router]))