Skip to content

Instantly share code, notes, and snippets.

View jeswin's full-sized avatar

Jeswin jeswin

View GitHub Profile
@jeswin
jeswin / router-article-startup.js
Last active February 9, 2019 11:00
router-article-startup
if (document.readyState === "loading") {
// Loading hasn't finished yet
document.addEventListener("DOMContentLoaded", startup);
} else {
// `DOMContentLoaded` has already fired
startup();
}
function startup() {
ReactDOM.render(
@jeswin
jeswin / router-article-create-todos.js
Created February 9, 2019 08:11
router-article-create-todos
const todos = [
{ id: 1, text: "Buy Milk" },
{ id: 2, text: "Pay Bills" },
{ id: 3, text: "Write Article" },
{ id: 4, text: "Sleep Early" }
];

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
import { createStore as reduxCreateStore } from "redux";
const initialState = {
selectedReddit: "reactjs",
postsByReddit: {}
};
let store;
export function createStore() {
@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:

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 / 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
#!/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?
/* 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