Skip to content

Instantly share code, notes, and snippets.

@yakirn
yakirn / DateFormatter.js
Created October 17, 2017 08:29
Intl API react date format example
function DateFormatter(props, context) {
return (
<div>{props.date.toLocaleString(context.locale, { year: 'numeric', month: 'short', day: 'numeric' })}</div>
);
}
import React from 'react';
import {render} from 'react-dom';
import {useStrict, computed, action, observable} from 'mobx';
import {Provider, observer, inject} from 'mobx-react';
useStrict(true);
class DataStore {
@observable name;
constructor(name) {
@yakirn
yakirn / .zlogin.bash_profile
Last active August 31, 2016 07:05
Conveniant aliases and functions for your shell
alias ll='ls -la'
alias cd..='cd ..'
alias ..='cd ..'
alias mkdir='mkdir -pv'
alias h='history'
alias gs='git status'
alias gl='git log --oneline'
mkcdir () {
mkdir $1 && cd $1
@yakirn
yakirn / ES6PromiseExt
Created April 7, 2016 10:14
add JQuery's Promise like abilities to ES6's Promise
const noChange = (promise, done, fail) => {
promise.then(done, fail)
return promise
}
if(Promise.prototype.done == undefined)
Promise.prototype.done = function(fn){
return noChange(this,fn)
}
if(Promise.prototype.fail == undefined)
@yakirn
yakirn / param serialize
Last active November 14, 2019 09:58
A modified version of serialize and param methods from zeptos, that depends on _ as a global var (tested on [email protected])
/* the following serialize and param methods are a version of zepto's
* https://github.com/madrobby/zepto/blob/601372ac4e3f98d502c707bf841589fbc48a3a7d/src/ajax.js#L344-L370
* modified to use _ (tested on [email protected], should also work in underscore)
* to use with github's fetch:
fetch(urrl, {
method: 'post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded'
}