Skip to content

Instantly share code, notes, and snippets.

View aseemk's full-sized avatar

Aseem Kishore aseemk

View GitHub Profile
@aseemk
aseemk / package.json
Last active August 21, 2017 16:49
FiftyThree Mix (AKA Paper Public Stream) archiver/scraper script
{
"name": "mix-archiver",
"version": "1.0.0",
"description": "Scrape and archive a FiftyThree Mix (Paper Public Stream) profile.",
"bin": "scrape.js",
"author": "Aseem Kishore <aseem.kishore@gmail.com>",
"license": "MIT",
"dependencies": {},
"devDependencies": {
"superagent": "^3.6.0"
@aseemk
aseemk / typescript-static-and-runtime-typing.ts
Last active November 13, 2016 15:32
An example of how to use TypeScript's impressive type inference with both generics and function overloads to achieve robust static typing with runtime type knowledge too! Playground: http://tinyurl.com/hxue2sw
type StaticValueType = string | number | boolean;
type StringValueType = 'string' | 'number' | 'boolean';
function parse(val: string): 'string';
function parse(val: number): 'number';
function parse(val: boolean): 'boolean';
function parse<T extends StringValueType>(val: null, valType: T): T;
function parse(val: StaticValueType | null, valType?: StringValueType): StringValueType {
if (val == null) {
if (valType == null) {
@aseemk
aseemk / 1-trello-sum-bookmarklet.md
Last active November 15, 2017 19:36
Trello bookmarklet to (re-)calculate sums of "points" from cards.

Trello bookmarklet to (re-)calculate sums of "points" from cards.

"Points" can be anything numeric (no units). Just prefix each card you want to count with the points in parentheses. E.g. (3) Investigate options.

It's okay for cards to not have points. They just won't be included in the sums.

The sum of points for each list will get added to the list title in the same way as cards. E.g. (17) To Do. Any existing sum will get updated.

The list's actual title (e.g. if you refresh) will not be updated; only the "display" title at that moment will be.

@aseemk
aseemk / 1-instructions.md
Last active November 5, 2021 06:08
Bookmarklet template!

TODO: Add description of your bookmarklet here.

To add this bookmarklet to your browser, instructions for Chrome:

  1. Right-click your Bookmarks Bar.
  2. Click "Add Page..."
  3. For "Name", type "TODO: Title here".
  4. For "URL", copy-paste the below:
@aseemk
aseemk / neo4j-transaction-test._coffee
Created November 10, 2014 02:41
Neo4j transaction test.
echo = console.log
Request = require 'request'
BASE_URL = 'http://localhost:7474'
# helper to make transactional requests:
req = (_, {query, params, commit, rollback, txId}) ->
method = if rollback then 'DELETE' else 'POST'
url = "#{BASE_URL}/db/data/transaction"
@aseemk
aseemk / async-loading.md
Last active August 29, 2015 14:07
CoffeeScript + Streamline patterns for async loading + caching.

Pattern 1: Pre-fetch the result, and cache it.

The result will hopefully already be available when needed, and the async call will be made only once.

fooFuture = fetchFoo !_

# anytime when needed:
foo = fooFuture _ # supports multiple calls!
@aseemk
aseemk / keybase.md
Created March 22, 2014 22:14
Keybase verification!

Keybase proof

I hereby claim:

  • I am aseemk on github.
  • I am aseemk (https://keybase.io/aseemk) on keybase.
  • I have a public key whose fingerprint is 8FD7 03E6 42A7 B1CD 6D50 07F4 4929 0166 F879 0B95

To claim this, I am signing this object:

@aseemk
aseemk / coffeescript-updates.md
Last active December 2, 2017 20:22
CoffeeScript upcoming changes.

CoffeeScript 1.7 is shaping up to be a pretty kick-ass release with significant improvements. Here are the ones I'm most excited about, in order of my own excitement.

Parentheses-free chaining

jashkenas/coffeescript#3263

Years of being wished for, finally granted!

@aseemk
aseemk / neo4j-cypher-weighted-followers.md
Last active March 21, 2022 13:54
Neo4j Cypher query to get a "normalized" or "weighted" follower count in a social graph.

This is a Neo4j 1.9 (pre-2.0) query:

START user=node:nodes(type='user')
MATCH user <-[:follows]- follower -[?:follows]-> other
WITH user, follower, 1.0 / COUNT(other) AS weighted
WITH user, COUNT(follower) AS numFollowers, SUM(weighted) as totalWeighted
RETURN user, numFollowers,
  ROUND(totalWeighted * 100) / 100.0 AS totalWeighted,
 ROUND(totalWeighted * 100 / numFollowers) / 100.0 AS avgFollowerWeight
@aseemk
aseemk / streamline-guide.md
Last active December 30, 2015 10:49
An excerpt of our internal Node.js style guide at @fiftythree, talking about Streamline patterns, tips, and tricks. Tailored for CoffeeScript.