This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const config = require('./config') | |
const knex = require('knex')(config.db) | |
const QueryBuilder = require('knex/lib/query/builder') | |
QueryBuilder.prototype.paginate = function ({ limit = 10, page = 1 }) { | |
const offset = (page - 1) * limit | |
return Promise.all([ | |
this.clone().count('* as count').first(), | |
this.offset(offset).limit(limit) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const is = require('is_js') // require this awesome library | |
const notEmpty = o => | |
is.not.empty(o) && Object.keys(o).map(key => { | |
return is.array(o[key]) | |
? !is.all.empty(o[key]) | |
: is.not.empty(o[key]) | |
}).reduce((a, b) => a && b, true) | |
// empty examples |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file has been auto-generated by i3-config-wizard(1). | |
# It will not be overwritten, so edit it as you like. | |
# | |
# Should you change your keyboard layout some time, delete | |
# this file and re-run i3-config-wizard(1). | |
# | |
# i3 config file (v4) | |
# | |
# Please see http://i3wm.org/docs/userguide.html for a complete reference! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# i3 config file (v4) | |
# Please see http://i3wm.org/docs/userguide.html for a complete reference! | |
# Set mod key (Mod1=<Alt>, Mod4=<Super>) | |
set $mod Mod1 | |
# set default desktop layout (default is tiling) | |
# workspace_layout tabbed <stacking|tabbed> | |
# Configure border style <normal|1pixel|pixel xx|none|pixel> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const capitalize = (s) => s.toLowerCase().split(' ').map((w) => w.replace(/^\w/, (s) => s.toUpperCase())).join(' ') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you come from bash you might have to change your $PATH. | |
# export PATH=$HOME/bin:/usr/local/bin:$PATH | |
# Path to your oh-my-zsh installation. | |
export ZSH=$HOME/.oh-my-zsh | |
# Set name of the theme to load. Optionally, if you set this to "random" | |
# it'll load a random theme each time that oh-my-zsh is loaded. | |
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes | |
ZSH_THEME="robbyrussell" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* convert ojbect into query params format | |
* used for request with content-type application/x-www-form-urlencoded | |
* | |
* e.g | |
* { param: "someVal", param2: "otherVal" } | |
* | |
* is converted into | |
* | |
* param1=someVal¶m2=otherVal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {readFileAsUrl} from './readFileAsUrl' | |
class Example extends React.Component { | |
constructor() { | |
this.state = { | |
previewUrl: '' | |
} | |
} | |
render() { | |
return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "Afghanistan", | |
"number": "93", | |
"code": "AF" | |
}, | |
{ | |
"name": "Albania", | |
"number": "355", | |
"code": "AL" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { withStateHandlers } from 'recompose' | |
import { ReactNode } from 'react'; | |
type Ref = ReactNode | |
type RefsState = {} | |
type RefsHandlers = { | |
setRef: (fieldName: string, ref: Ref) => undefined | |
focusRef: (fieldName: string) => undefined | |
} | |
export type RefsProps = RefsHandlers & RefsState |