Skip to content

Instantly share code, notes, and snippets.

Aseem Kishore aseemk

Block or report user

Report or block aseemk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@aseemk
aseemk / npm-shrinkwrap-devdeps2.md
Last active Dec 26, 2015
npm shrinkwrap issues w/ de-duped production + dev dependencies
View npm-shrinkwrap-devdeps2.md

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 request@2.x --save-dev
npm shrinkwrap
@aseemk
aseemk / npm-shrinkwrap-devdeps1.md
Last active Dec 26, 2015
npm shrinkwrap issues w/ de-duped production + dev dependencies
View npm-shrinkwrap-devdeps1.md

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 request@2.x --save-dev
npm install strong-agent --save
npm shrinkwrap
@aseemk
aseemk / app.js
Created Sep 26, 2013
Testing the non-blocking behavior of Node.js logging on Heroku.
View app.js
// 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 / i18n._coffee
Last active Jan 28, 2019
Node.js script to extract i18n strings from source code.
View i18n._coffee
#!/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 / httpie-output
Created Jul 30, 2013
Testing `Expect: 100-continue` support in Node.js and HTTPie.
View httpie-output
$ http -v PUT localhost:5100 Expect:100-continue foo=bar
PUT / HTTP/1.1
Accept-Encoding: identity, deflate, compress, gzip
Accept: application/json
User-Agent: HTTPie/0.2.5
Host: localhost:5100
Expect: 100-continue
Content-Type: application/json; charset=utf-8
@aseemk
aseemk / HelloNode.java
Created Jul 19, 2013
Node.java — a faithful port of the asynchronous Node.js platform to the strongly-typed Java language.
View HelloNode.java
import java.util.Map;
import java.util.HashMap;
import com.joyent.node.http;
import com.joyent.node.http.RequestListener;
import com.joyent.node.http.ServerRequest;
import com.joyent.node.http.ServerResponse;
public class HelloNode {
public static void main(string[] args) {
@aseemk
aseemk / app-api.coffee
Created May 20, 2013
Express 2 (Connect 1) vhosting.
View app-api.coffee
express = require 'express'
app = express.createServer()
# ...
module.exports = app
@aseemk
aseemk / gist:5574052
Created May 14, 2013
A homegrown convention for shorthand static access syntax in CoffeeScript.
View gist:5574052

One of CoffeeScript's best features is the @ shorthand for this -- perfect for accessing instance methods and properties:

class Rectangle
  constructor: (@width, @height) ->
  getArea: ->
    @width * @height

But there's no similar shorthand for accessing static members, e.g. @@. So instead, you're forced to either hardcode class names, or type out the long constructor reference to be generic:

@aseemk
aseemk / bookmarklet.js
Last active May 11, 2016
GitHub bookmarklet for toggling outdated diffs, and dotjs script for fixing links to pull request comments on outdated diffs.
View bookmarklet.js
javascript:(function(){[].forEach.call(document.querySelectorAll('.discussion-item-toggle-closed'), (elmt) => elmt.click())})();
@aseemk
aseemk / gist:5191967
Created Mar 18, 2013
Sexy method argument overloading in CoffeeScript.
View gist:5191967
#
# Overloads:
# - fetch(url, callback)
# - fetch(url, opts, callback)
#
fetch = (args...) ->
[arg0, arg1, arg2] = args
[url, opts, callback] = switch args.length
when 0, 1 then throw new Error "Usage: fetch(url[, opts], callback)"
when 2 then [arg0, null, arg1]
You can’t perform that action at this time.