Skip to content

Instantly share code, notes, and snippets.

@jweir
jweir / protovis_to_link.js
Created November 19, 2010 19:23
How to save SVG data to a file from a web browser
@indexzero
indexzero / base64.js
Created November 27, 2010 23:38
An extremely simple implementation of base64 encoding / decoding using node.js Buffers
//
// Super simple base64 encoding / decoding with node.js
//
var base64 = exports = {
encode: function (unencoded) {
return new Buffer(unencoded).toString('base64');
},
decode: function (encoded) {
return new Buffer(encoded, 'base64').toString('utf8');
@kamui
kamui / annotate_image.rb
Created March 22, 2011 16:42
Annotate text that auto fits within an image and benchmark on both graphicsmagick and imagemagick. Uses mini_magick
#!/usr/bin/env ruby
# Convert command line
#
#gm convert -font helvetica -fill white -pointsize 20 -draw "text 500,600 'WALLPAPERZ ARE GOOD'" test.jpg output.jpg
#
#convert -background transparent -fill white -gravity center -size 1024x200 -font Helvetica -pointsize 20 #caption:"I'm a wallpaper, you know what to do" test.jpg +swap -gravity south -composite output.jpg
#
# Mogrify command line
#
@ghiden
ghiden / nodejs_decode_sample.js
Created June 29, 2011 05:11
decode a base64 encoded image file with node.js
var fs = require('fs'),
decode64 = require('base64').decode;
var data = fs.readFileSync('./encode.png', 'base64');
var buffer = new Buffer(data, 'base64');
fs.writeFileSync('./decode.png', decode64(buffer), 'binary')
@henningjensen
henningjensen / gist:1145089
Created August 14, 2011 17:22
Join/merge PDF files with pdftoolkit
sudo apt-get install pdftk
pdftk file1.pdf file2.pdf cat output newFile.pdf
@mbostock
mbostock / .block
Last active March 19, 2018 02:57
getBBox
license: gpl-3.0
@marocchino
marocchino / gist:1305972
Created October 22, 2011 13:01
nodejs - simple calculator server
sys = require 'sys'
http = require 'http'
host = "0.0.0.0"
port = 3000
http.createServer (request,response) ->
[_, op, a, b] = request.url.split "/"
a = parseInt a
b = parseInt b
result = {
"add": (a, b) -> a + b
@robnyman
robnyman / blob-filereader-localStorage.js
Last active January 29, 2025 05:17
Get file as a blob, read through FileReader and save in localStorage
// Getting a file through XMLHttpRequest as an arraybuffer and creating a Blob
var rhinoStorage = localStorage.getItem("rhino"),
rhino = document.getElementById("rhino");
if (rhinoStorage) {
// Reuse existing Data URL from localStorage
rhino.setAttribute("src", rhinoStorage);
}
else {
// Create XHR and FileReader objects
var xhr = new XMLHttpRequest(),
@musubu
musubu / gist:2202583
Created March 26, 2012 03:01
escape and unescape in node.js
var querystring = require('querystring');
var original = 'http://example.com/product/abcde.html';
var escaped = querystring.escape(original);
console.log(escaped);
// http%3A%2F%2Fexample.com%2Fproduct%2Fabcde.html
var unescaped = querystring.unescape(escaped);
console.log(unescaped);
@blitline-dev
blitline-dev / Blitoverlay
Created April 16, 2012 05:06
Simple Blitline Overlay
{
"application_id":"YOUR_APP_ID",
"src":"https://s3.amazonaws.com/img.blitline/blog/jelly_bean.jpg",
"functions":[
{
"name":"composite",
"params":{
"src":"https://s3.amazonaws.com/img.blitline/blog/frame.png"
},
"save":{