Skip to content

Instantly share code, notes, and snippets.

View sergeyt's full-sized avatar
:electron:
There is a time for everything, a time to search and, a time to give up...

Sergey Todyshev sergeyt

:electron:
There is a time for everything, a time to search and, a time to give up...
View GitHub Profile
@sergeyt
sergeyt / gogs.conf
Created October 17, 2014 17:04
gogs upstart script
#
# upstart script for gogs (Go Git Service)
#
author "tsv"
description "gogs upstart script"
start on (local-filesystems and net-device-up)
stop on shutdown
@sergeyt
sergeyt / typeahead-langs.js
Created October 19, 2014 15:31
dataset without value
Template.langs.helpers({
list: function() {
return [
{"name": "C#"},
{"name": "JavaScript"},
{"name": "CoffeeScript"}
];
}
});
@sergeyt
sergeyt / typeahead-langs.html
Last active August 29, 2015 14:07
typeahead langs template
<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>
@sergeyt
sergeyt / meteor-gist.html
Created October 26, 2014 15:34
meteor-gist example
<template name="example">
<div class="gist">
{{{gist "sergeyt" "173f8a5dff83a3b5858a"}}}
</div>
</template>
@sergeyt
sergeyt / DynamicRouting.cs
Created July 18, 2015 12:13
owin dynamic routing idea
// 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>;
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/...
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
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);
@sergeyt
sergeyt / watch.sh
Created July 4, 2016 13:49
helper bash function to run any script on any change in current directory
watch() { while inotifywait --exclude .swp -e modify -r .; do $@; done; }
@sergeyt
sergeyt / validate.js
Created April 16, 2017 10:09
Form Validation
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)) {