Skip to content

Instantly share code, notes, and snippets.

View mohsen1's full-sized avatar

Mohsen Azimi mohsen1

View GitHub Profile
declare module 'mobx-remotedev' {
/**
* Connect MobX Remote Dev
*
* @param store observable or class to be monitored. In case you want to change its values
* (to time travel or cancel actions), you should export its result as in the example
* above (so we can extend the class).
* @param config Configuration
*
* @return store
@mohsen1
mohsen1 / mobx-router.ts
Created September 26, 2016 01:20
MobX Router idea
import {merge} from 'lodash';
import {autorun} from 'mobx';
// TODO: find a good polyfill for this
declare const URLSearchParams;
const routeMatcher = require("route-matcher").routeMatcher;
const createBrowserHistory = require('history/createBrowserHistory').default;
/*
* A store have to implement these two getters to be routable
@mohsen1
mohsen1 / words.js
Last active December 31, 2015 11:49
1000 most frequently used words
names = [
"A",
"ABLE",
"ABOUT",
"ABOVE",
"ACCORDING",
"ACCOUNT",
"ACROSS",
"ACT",
"ACTION",
@mohsen1
mohsen1 / style.css
Last active December 18, 2015 10:19
Github dark theme This theme uses webkit filters to achive a consistent dark theme across all Github pages.
/* Invert all the things! */
html
{
-webkit-filter: invert(1) grayscale(0.6);
}
/* Execpt these guys... */
img,
.minibutton,
.state-indicator,
@mohsen1
mohsen1 / fs.js
Created May 29, 2013 14:51
Wrong node
var fs = require('fs');
var random = (~~(Math.random() * 1e9)).toString(2);
fs.writeFile('./random.txt', random, function(err){
if(err) console.error(err);
else console.log('file has been written');
});
@mohsen1
mohsen1 / classical.md
Last active December 14, 2015 15:09
Classical Inheritance in JavaScript which never uses prototype object. This is bad code. It's here to demonstrate how bad Classical Inheritance is!

Let me introduce you to Classical Inheritance that never uses prototype. This is a bad coding exercise but will teach you the real Classical Inheritance which always compared to prototypal inheritance:

Make a custructor:

function Person(name, age){
  this.name = name;
  this.age = age;
  this.sayHello = function(){return "Hello! this is " + this.name;}
}
@mohsen1
mohsen1 / js1ks.js
Last active December 14, 2015 06:18
My JS1K submission
Number.prototype.pow = function(n){return Math.pow(this,n)}
function C(u){
return document.createElement(u)
}
z = 50;
d = C('div')
i = C('input')
@mohsen1
mohsen1 / bash_profile
Last active December 12, 2015 02:08
My bash_profile
###########
# Aliases #
###########
alias ll='ls -l'
alias js='node'
alias subl='/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl'
alias ls='ls -G'
alias gadd="git add .; git add -u .; git status;"
alias nook='cd ~/Projects/NookWeb/nook.com'
Random Gist
@mohsen1
mohsen1 / levenshteinDistance.js
Created October 14, 2012 11:06
Levenshtein Distance calculator
function levenshteinDistance (s, t) {
if (!s.length) return t.length;
if (!t.length) return s.length;
return Math.min(
levenshteinDistance(s.substr(1), t) + 1,
levenshteinDistance(t.substr(1), s) + 1,
levenshteinDistance(s.substr(1), t.substr(1)) + (s[0] !== t[0] ? 1 : 0)
);
}