Skip to content

Instantly share code, notes, and snippets.

View aseemk's full-sized avatar

Aseem Kishore aseemk

View GitHub Profile
@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 / 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 / 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 / README.md
Last active February 14, 2018 16:41
A bookmarklet for "selecting all" (technically, "toggling all") checkboxes on the Amazon AWS S3 console.
@aseemk
aseemk / randomStr.js
Created July 12, 2012 05:00
Random alphanumeric (base-62) strings in Node.js, cryptographically strong
var bases = require('bases');
var crypto = require('crypto');
// Returns a base-62 (alphanumeric only) string of the given length:
function randomStr(length) {
// We generate a random number in a space at least as big as 62^length,
// and if it's too big, we just retry. This is still statistically O(1)
// since repeated probabilities less than one converge to zero. Hat-tip to
// a Google interview for teaching me this technique! ;)
@aseemk
aseemk / app.js
Created January 9, 2013 21:58
Node.js cluster support on Heroku — freaking sweet!
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
var pid = process.pid;
var port = process.env['PORT'] || 8000;
if (cluster.isMaster) {
console.log('Master:', pid);
// Fork workers -- one less than the number of CPUs.
@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 / 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 / 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 / 500.html
Created January 9, 2013 23:47
Thingdom's error and maintenance pages for Heroku. (Built with Jekyll and served by GitHub Pages.)
---
title: 500 Internal Server Error
---
<article>
<h1>500 Internal Server Error</h1>
<p>
Sorry, something’s gone wrong on our end.
We apologize for the inconvenience.
</p>