Skip to content

Instantly share code, notes, and snippets.

@mulderp
mulderp / gist:9249336
Created Feb 27, 2014
put all images in a html img tags
View gist:9249336
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:9186648
Created Feb 24, 2014
basic HTML template
View gist:9186648
<!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:9051804
Created Feb 17, 2014
A resizing command
View gist:9051804
convert large_image.png -resize "100x200" small_image.png
View gist:8825657
t = Tracer.new
t.add_filter { |t, b, *c| b.match(/app/) }
t.on {
...
}
View D3.js-Force-Layout-with-Labels-.markdown

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.

View jquery.oauth.js
/*
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
View gist:8364236
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)
View gist:8007500
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");
})
View gist:7796615
f = File.new("u.item_utf8")
ls = f.readlines
puts "["
ls.each do |l|
fs = l.split("|")
/(.*) \((\d+)\)$/.match(fs[1])
title = $1
year = $2
View gist:7115197
1) SignupPresenter#save saves records when there are valid
Failure/Error: User.count.should be 1
expected #<Fixnum:3> => 1
got #<Fixnum:5> => 2
Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.
You can’t perform that action at this time.