Skip to content

Instantly share code, notes, and snippets.

@karmadude
karmadude / node-mysql2json.js
Created December 8, 2011 03:34
Using Node to export MySQL query results to a file as JSON
// https://github.com/felixge/node-mysql
// npm install mysql
var mysql = require('mysql');
// http://nodejs.org/docs/v0.6.5/api/fs.html#fs.writeFile
var fs = require('fs');
var client = mysql.createClient({
user: 'root',
password: 'mysqlpassword'
@karmadude
karmadude / scraper.js
Created December 23, 2011 22:36
Web Scraping with Node
// https://github.com/tmpvar/jsdom
// npm install jsdom
var jsdom = require('jsdom');
function scrapeDribbble (url, page) {
dribbbles[page-1] = [];
if (page > 1) {
url = dribbbleURL + '/shots?page=' + page;
}
[
{
"abbr": "in",
"name": "Union",
"revenue": [
{"name":"tax", "value": 574005},
{"name":"non-tax", "value": 356008},
{"name":"grants", "value": 2673}
],
"expenditure": [
@karmadude
karmadude / README.md
Last active October 13, 2015 03:28
India State Finances 2010-2011

A visualization of Indian state finances (revenues and expenditures) for 2010-2011

created for India60

@karmadude
karmadude / README.md
Last active February 7, 2017 08:27
India Population 2011
@karmadude
karmadude / README.md
Last active April 2, 2024 01:41
India Map TopoJSON Files

India Map Data

@karmadude
karmadude / README.md
Last active February 7, 2017 08:24
San Francisco Contours
@karmadude
karmadude / happy.js
Last active August 29, 2015 14:20
Happy Number
// https://en.wikipedia.org/wiki/Happy_number
function happy(n) {
if(typeof n === "undefined") throw new Error("Missing argument n");
var result = {
n: n,
happy: true,
seq: [n],
toString: function() {
return this.happy
@karmadude
karmadude / README.md
Last active August 29, 2015 14:21
How to find JavaScript memory leaks using heap snapshot

How to find JavaScript memory leaks using heap snapshot

  1. Open js-memory-leak.html in Chrome
  2. Open developer tools and select Profiles tab
  3. Select Take Heap Snapshot Take Heap Snapshot
  4. Take a base snapshot Take base snapshot
  5. Click Create App five times
  6. Take another snapshot
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.