Skip to content

Instantly share code, notes, and snippets.

View misantronic's full-sized avatar

David Schkalee misantronic

View GitHub Profile
import { observable, computed } from 'mobx';
type WrapRequestState = 'loading' | 'fetched' | 'error';
/** @see https://stackoverflow.com/a/4994244/1138860 */
// tslint:disable-next-line:cyclomatic-complexity no-any
function isEmpty(obj: any): boolean {
if (!obj) return true;
if (obj > 0) return false;
if (obj.length > 0) return false;
import { db, binding, vm, misc } from 'baqend';
import {
observable,
decorate,
isObservableArray,
reaction,
IReactionDisposer
} from 'mobx';
function isObject(obj): boolean {
@misantronic
misantronic / Backbone.Model.js
Last active December 3, 2015 17:37
Make Backbone.Model's fetch() return the model ifself
Backbone.Model.extend({
/**
* Return the model itself instead of fetched-data object
* @param {Object} [options]
* @returns {jQuery}
*/
fetch: function (options) {
options = options || {};
var self = this;
@misantronic
misantronic / Backbone.Model.js
Last active December 3, 2015 11:29
Functional attributes in Backbone
var Model = Backbone.Model.extend({
get: function (attribute) {
var value = Backbone.Model.prototype.get.call(this, attribute);
if(_.isFunction(value)) {
value = value.call(this);
}
return value;

Keybase proof

I hereby claim:

  • I am misantronic on github.
  • I am misantronic (https://keybase.io/misantronic) on keybase.
  • I have a public key whose fingerprint is F301 523A 7317 9F3C 1BDA 42E8 36C1 CF7A DF2B 3A16

To claim this, I am signing this object:

@misantronic
misantronic / Typemaster.markdown
Last active August 29, 2015 14:12
Typemaster