Skip to content

Instantly share code, notes, and snippets.

View DKunin's full-sized avatar
🎯
Focusing

Dmitri Kunin DKunin

🎯
Focusing
View GitHub Profile
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@DKunin
DKunin / gist:34ea9d14cecf2e93812d
Created January 30, 2015 08:21
Recompose object in arrays to different names
var R = require('ramda')
var arr = [{id:'123123123',name:'smthelse'}, {id:'123123123 2',name:'smthelse 2'}];
var recomposeKeys = function(newNames,oldNames){
return function(d){
return R.zipObj(newNames, R.props(oldNames)(d))
}
}
R.map(recomposeKeys(['text','value'], ['id','name']))
@DKunin
DKunin / gist:9025f0cfad7d7bea44e5
Created January 30, 2015 08:18
Simple MiddleWare intended for Superagent end calls
var MiddleWare = function(cb, cont){
var calb = cb;
return function(err,res){
var result = JSON.parse(res.text);
if(err||result.redirect) {
if(cont)
{
cont.flux.actions.login.signout();
}
@DKunin
DKunin / datepicker.styl
Created January 6, 2015 06:15
DatePicker React.js
.datepicker-dates {
position: relative;
width: 156px;
height: 100%;
margin-top: 0.5em;
}
.datepicker {
position:relative;
@DKunin
DKunin / gist:86e62473e7a991dcb78f
Created November 18, 2014 06:01
Making package a cli
//add to package.json
{
"preferGlobal": "true",
"bin": {
"server" : "./index.js"
}
}
@DKunin
DKunin / .csscomb.json
Created September 11, 2014 18:36
Lint Settings
{
"remove-empty-rulesets": true,
"always-semicolon": true,
"color-case": "lower",
"block-indent": " ",
"color-shorthand": true,
"element-case": "lower",
"eof-newline": true,
"leading-zero": false,
"quotes": "single",
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Building a router</title>
<script>
// Put John's template engine code here...
(function () {
// A hash to store our routes:
@DKunin
DKunin / _spaces_mixin.sass
Last active February 7, 2017 13:40
Sass sizes mixin
$no: 0
$x: 3px
$s: 5px
$m: 10px
$l: 20px
$xl: 25px
$type: p m
$typen: padding margin
$dir: t b l r a h v
$dirname: -top -bottom -left -right '' '' ''
@DKunin
DKunin / new_gist_file
Created October 17, 2013 06:57
4 kyu Strip Url Params
function stripUrlParams(url, paramsToStrip){
var queryArrs = url.split('?');
if(queryArrs.length===1||queryArrs[1]==="") {
return url.replace(/(.+)(\?)$/, '$1');;
}
var params = queryArrs[1].split('&');
var ob = {};
params = params.reverse();
for(el in params) {
var val=params[el].split("=");
@DKunin
DKunin / new_gist_file
Created October 14, 2013 11:24
Form words from array
function formatWords(words){
if (!words) return "";
return words.filter(function(a) { return a !== ''}).join(', ').replace(/(, )+(\S+)$/, ' and $2');
}