Skip to content

Instantly share code, notes, and snippets.

View aseemk's full-sized avatar

Aseem Kishore aseemk

View GitHub Profile
@aseemk
aseemk / i18n._coffee
Last active January 28, 2019 14:52
Node.js script to extract i18n strings from source code.
#!/usr/bin/env _coffee
#
# Helper script to search all of our files for i18n strings and update our
# strings file. Helpful in case we missed a code path during testing.
#
# Specifically, searches for gettext `__()` calls in our checked-in files.
#
$ = require 'underscore'
echo = console.log
@aseemk
aseemk / app.js
Created September 26, 2013 00:18
Testing the non-blocking behavior of Node.js logging on Heroku.
// http://nodejs.org/api/process.html#process_process_stdout
console.log('Is stdout blocking?', process.stdout.isTTY);
console.log('Is stderr blocking?', process.stderr.isTTY);
console.log('Full stdout:\n', process.stdout);
console.log('Full stderr:\n', process.stderr);
@aseemk
aseemk / npm-shrinkwrap-devdeps1.md
Last active December 26, 2015 10:59
npm shrinkwrap issues w/ de-duped production + dev dependencies

Install a dev dependency, then install a production dependency that (internally) depends on that same dev dependency. (Should you have to know that? Is that not an implementation detail?)

Then shrinkwrap for production, and note the missing nested dependency.

npm init
npm install [email protected] --save-dev
npm install strong-agent --save
npm shrinkwrap
@aseemk
aseemk / npm-shrinkwrap-devdeps2.md
Last active December 26, 2015 10:59
npm shrinkwrap issues w/ de-duped production + dev dependencies

Install a production dependency, then install a dev dependency that the production dependency (internally) depends on as well. (Should you have to know that? Is that not an implementation detail?)

Then shrinkwrap for production, and note that the dev dependency is (correctly) excluded at the top, but present nested under the production dependency.

npm init
npm install strong-agent --save
npm install [email protected] --save-dev
npm shrinkwrap
@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.
@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 / 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 / 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 / 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 / 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"