Skip to content

Instantly share code, notes, and snippets.

var fs = require("fs");
var stream = fs.createReadStream("test.xml", {encoding: "UTF-8"});
var out = fs.createWriteStream("out.json", {encoding: "UTF-8"});
var sax = require("sax");
var parser = sax.createStream(true);
parser.on("opentag", function (node) {
console.log(node.name);
out.write("\n");
})
var iconv_latin1 = new Iconv('latin1', 'utf-8');
assert.deepEqual(iconv_latin1.convert("L��nitz"), "Lößnitz");
assert.js:92
throw new assert.AssertionError({
^
AssertionError: [76,195,175,194,191,194,189,195,175,194,191,194,189,110,105,116,122] deepEqual "Lößnitz"
at Object.<anonymous> (/Users/pmu/projects/github/node-iconv/test/test-basic.js:37:8)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
/*
MIT License (MIT)
Copyright (c) 2011 Andy Edinborough
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH TH

D3.js Force Layout with Labels

Force driven layout in the awesome D3 JavaScript library. The mouse hides as you click and drag on the elements. Using the equally awesome solarized palette. I'm using this in one of my lynda.com classes.

A Pen by Patrick Mulder on CodePen.

License.

t = Tracer.new
t.add_filter { |t, b, *c| b.match(/app/) }
t.on {
...
}
@mulderp
mulderp / gist:9051804
Created February 17, 2014 14:39
A resizing command
convert large_image.png -resize "100x200" small_image.png
@mulderp
mulderp / gist:9186648
Created February 24, 2014 11:20
basic HTML template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PAGE TITLE</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/normalize.css" rel="stylesheet" media="all">
<link href="css/styles.css" rel="stylesheet" media="all">
@mulderp
mulderp / gist:9249336
Created February 27, 2014 12:42
put all images in a html img tags
f = File.new("index.html","w") ; Dir["*.jpg"].each do |n| ; f.write(%Q(<h3>#{n}</h3>\n <img src="#{n}" />\n <hr>)) ; end; f.close
@mulderp
mulderp / gist:9740253
Created March 24, 2014 13:40
serverbone test
global.serverbone = require("serverbone");
global.BaseModel = serverbone.models.BaseModel;
global.redis = require("redis");
global.RedisDb = require('backbone-db-redis');
global.store = new RedisDb('mymodel', redis.createClient());
global.movieSchema = {
id: 'schemas/movies',
type: 'object',
@mulderp
mulderp / gist:11349911
Created April 27, 2014 16:33
returns undefined ?
var Sync = function(syncing, options) {
this.syncing = syncing;
this.url = syncing.url;
this.delay = syncing.delay;
}
_.extend(Sync.prototype, {
findAll: Promise.method(function() {
var sync = this;
return Promise.bind(this).then(function() {