Skip to content

Instantly share code, notes, and snippets.

View mohsen1's full-sized avatar

Mohsen Azimi mohsen1

View GitHub Profile
@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 / keybindings.json.yaml
Last active November 4, 2018 19:23
Sublime Text key bindings for Visual Studio Code
[
{
"key": "shift+cmd+d",
"command": "editor.action.copyLinesDownAction"
},
{
"key": "cmd+l",
"command": "expandLineSelection"
},
@mohsen1
mohsen1 / domenic.js
Last active August 29, 2015 14:20
Promises and callback
function add (arg1, arg2, cb) {
return (new Promise(reject, resolve) {
if (typeof arg1 !== 'number') {
reject(new TypeError('arg1 should be a number'));
}
if (typeof arg2 !== 'number') {
reject(new TypeError('arg2 should be a number'));
@mohsen1
mohsen1 / 1.json
Last active August 29, 2015 14:16
{
"apiVersion": "1.0.0",
"swaggerVersion": "1.2",
"basePath": "http://swagger.io",
"resourcePath": "/people/@me",
"produces": [
"application/xml",
"application/json"
],
"consumes": [
@mohsen1
mohsen1 / _
Last active August 29, 2015 14:15
Proof of concept using lodash for Backbone by cherry-picking all _.{method}s that Backbone uses from Lodash
keys
uniqueId
isEmpty
bind
once
each
extend
defaults
result
clone
@mohsen1
mohsen1 / download.js
Last active March 30, 2019 05:13
Download Chromecast backgrounds
var https = require('https');
var fs = require('fs');
var url = 'https://raw.githubusercontent.com/dconnolly/chromecast-backgrounds/master/backgrounds.json';
Array.prototype.getLast = function() {
return this[this.length - 1];
};
function logFail(err){
console.log('Failed!');
@mohsen1
mohsen1 / consolidated.json
Created May 21, 2014 18:01
Consolidated JSON Spec
{
"opts": {
"properties": {
"modelPackage": "com.reverb.models",
"apiPackage": "com.reverb.apis",
"groupId": "com.reverb.swagger",
"artifactId": "swagger-client",
"artifactVersion": "1.0.0"
},
"uri": "http://petstore.swagger.wordnik.com/api/api-docs"
@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');
});