Skip to content

Instantly share code, notes, and snippets.

View jeswin's full-sized avatar

Jeswin jeswin

View GitHub Profile
@jeswin
jeswin / .ctags
Created June 28, 2014 14:13 — forked from jesstelford/.ctags
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/(^|=[ \t])*class ([A-Za-z_][A-Za-z0-9_]+\.)*([A-Za-z_][A-Za-z0-9_]+)( extends ([A-Za-z][A-Za-z0-9_.]*)+)?$/\3/c,class/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?@?(([A-Za-z][A-Za-z0-9_.]*)+):.*[-=]>.*$/\3/m,method/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=.*[-=]>.*$/\3/f,function/
--regex-coffee=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=[^->\n]*$/\1/v,variable/
--regex-coffee=/^[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=[^->\n]*$/\1/f,field/
--regex-coffee=/^[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+):[^->\n]*$/\1/f,static field/
--regex-coffee=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+):[^->\n]*$/\1/f,field/
--regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?/\3/f,field/
@jeswin
jeswin / gist:57d7e7df8197e83cfc0a
Last active August 29, 2015 14:07
visit(): Transform a JS object by visiting it recursively with generator functions
/*
visit = function*(obj, fn)
WARN: Not really tested.
Visits a data structure recursively, running transformation fn*(x) on each property.
Returns a transformed data structure.
Params:
obj: Object to visit
/* Created for discussion */
//interfaces/mongodb.js
declare module "mongodb" {
declare class Collection {
insertOne(doc: Object, cb: (err?: Error, result: { insertedId: string }) => void) : void;
}
}
//interfaces/nodefunc-promisify.js
#!/bin/bash
mkdir -p repos
cd repos
runtask() {
curdir=`pwd`
git_url=$1
cmd_after_clone=$2
declare -a projects=("${!3}") #don't we just love bash arrays?
@jeswin
jeswin / gist:639f87c651d8c877dee5
Created December 24, 2015 09:52
git-status-all-my-repos.sh
#!/bin/bash
runtask() {
curdir=`pwd`
declare -a projects=("${!1}") #don't we just love bash arrays?
for proj in "${projects[@]}"
do
echo checking ${proj}...
if [ -d $proj ]; then

As in the following example, I am defining the return type of createServer() to be a MockServer interface (which is empty), instead of "Server" as defined in https://github.com/facebook/flow/blob/master/lib/node.js

Shouldn't this work, since an empty interface can stand in for any class?

/* @flow */
var http = require("http");

interface MockServer {}
@jeswin
jeswin / keybase.md
Created April 11, 2016 05:29
keybase.md

Keybase proof

I hereby claim:

  • I am jeswin on github.
  • I am jeswin (https://keybase.io/jeswin) on keybase.
  • I have a public key whose fingerprint is C0DD 2F6B 53F0 F82A 16EC 8191 F280 210C 6F6D C354

To claim this, I am signing this object:

import { createStore as reduxCreateStore } from "redux";
const initialState = {
selectedReddit: "reactjs",
postsByReddit: {}
};
let store;
export function createStore() {

Basho: Shell pipelines with the goodness of JS templates

Basho evaluates a pipeline of instructions left to right. Instructions can be JavaScript code, reference to an external JS file, or a shell command. To evaluate a JavaScript expression, use the option -j. Let’s start with a single item in the pipeline, a JavaScript constant.

# Prints 100
basho -j 100