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
| function mapObject<K extends keyof any, T, TResult>(obj: Record<K, T>, makeResult: (val: T, key?: K) => TResult): Record<K, TResult> { | |
| return (Object.keys(eventMap) as K[]).reduce( | |
| (acc, key) => ({ | |
| ...acc, | |
| [key]: makeResult(obj[key]), | |
| }), | |
| {} as Record<K, TResult> | |
| ); | |
| } |
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
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
| sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
| sudo apt-get update | |
| sudo apt-get -y install docker-ce | |
| sudo service docker restart | |
| sudo rm /usr/local/bin/docker-compose | |
| curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose | |
| chmod +x docker-compose | |
| sudo mv docker-compose /usr/local/bin |
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 Immutable from 'immutable'; | |
| import {reduce} from 'lodash'; | |
| type ErrorMap = Immutable.Map; | |
| type Validator = (value, path, form) => ErrorMap; | |
| function validationRules(rules) { | |
| return (value, path, form) => { | |
| return reduce(rules, (result, fn, key) => { | |
| if (path.contains(key)) { |
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
| watch() { while inotifywait --exclude .swp -e modify -r .; do $@; done; } |
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
| interface Group<TKey, TValue> { | |
| key: TKey; | |
| values: TValue[]; | |
| } | |
| function groupBy<TKey, TValue>(array: TValue[], keyFn: (t: TValue) => TKey): Group<TKey,TValue>[] { | |
| const result: Group<TKey, TValue>[] = []; | |
| const map = new Map<TKey, Group<TKey, TValue>>(); | |
| array.forEach(t => { | |
| const k = keyFn(t); |
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
| cwd=$PWD | |
| for d in */ ; do | |
| dirname="$cwd/$(basename "${d}")" | |
| cd $dirname | |
| if [ -d ".git" ]; then | |
| git pull | |
| fi | |
| if [ -d ".hg" ]; then | |
| hg pull -u | |
| fi |
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
| go get -u golang.org/x/tools/... | |
| go get -u github.com/golang/lint/golint/... | |
| go get -u github.com/rogpeppe/godef/... | |
| go get -u github.com/Unknwon/bra/... | |
| go get -u github.com/constabulary/gb/... | |
| go get -u github.com/nats-io/gnatsd/... | |
| go get -u github.com/nsqio/nsq/... | |
| go get -u github.com/blevesearch/bleve/... | |
| go get -u github.com/onsi/ginkgo/ginkgo/... | |
| go get -u github.com/kisielk/godepgraph/... |
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
| // WARNING this gist is an example with potentially non-compilable code! | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Threading.Tasks; | |
| namespace Owin.Routing | |
| { | |
| using AppFunc = Func<IDictionary<string, object>, Task>; |
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
| <template name="example"> | |
| <div class="gist"> | |
| {{{gist "sergeyt" "173f8a5dff83a3b5858a"}}} | |
| </div> | |
| </template> |
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
| <template name="langs"> | |
| <div> | |
| <h2>Array of objects without value property.</h2> | |
| <div class="form-group"> | |
| <input class="form-control typeahead" name="lang" type="text" placeholder="Programming language" | |
| autocomplete="off" spellcheck="off" data-source="list" data-value-key="name"/> | |
| </div> | |
| </div> | |
| </template> |