Skip to content

Instantly share code, notes, and snippets.

@ZJONSSON
ZJONSSON / README.md
Last active Aug 29, 2015
Optimal denominations
View README.md

This small script uses combinatory analysis to figure out the optimal denominations for given number of possible coins to minimize the coins required to produce any amount between 1 cent and 1 dollar. The candidate set of denominations is reduced to keep the combinatory possibilities within reason.

@ZJONSSON
ZJONSSON / app.js
Last active Aug 29, 2015
Happy Birthday
View app.js
function encode64(data) {
var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var PAD = '=';
var ret = '';
var leftchar = 0;
var leftbits = 0;
for (var i = 0; i < data.length; i++) {
leftchar = (leftchar << 8) | data[i];
leftbits += 8;
while (leftbits >= 6) {
View gist:6fc452a19facae4857d0

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
@ZJONSSON
ZJONSSON / index.html
Created Oct 1, 2011
Using data() enter and exit in D3
View index.html
<!DOCTYPE html>
<html>
<head></head>
<body></body>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript">
// Define the SVG domain in a viewbox to get automatic resize to
// window. This is a good alternative to d3.scale for simple stuff
svg=d3.select("body")
@ZJONSSON
ZJONSSON / index.html
Created Oct 5, 2011
SVG slippy map using Viewbox with D3
View index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="svg_interact.js"></script>
<script type="text/javascript" src="svg_map.js"></script>
</head>
<body></body>
@ZJONSSON
ZJONSSON / index.html
Created Oct 14, 2011
Update speed based on number of SVG elements in viewBox
View index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
</head>
<body>
<div id="graph"></div>
<div id="fps">FPS: <SPAN>?</SPAN></DIV>
Number or circles
@ZJONSSON
ZJONSSON / index.html
Created Oct 14, 2011
[separate SVG boxes ] Update speed based on number of SVG elements in viewBox
View index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<STYLE>svg { border: dashed;border-width:1px;}</STYLE>
</head>
<body>
<div id="graph"></div>
<div id="fps">FPS: <SPAN>?</SPAN></DIV>
@ZJONSSON
ZJONSSON / index.html
Created Oct 14, 2011
Update speed based on length of an unrelated static path object
View index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<STYLE>svg { border: dashed;border-width:1px;}</STYLE>
</head>
<body>
<div id="graph"></div>
<div id="fps">FPS: <SPAN>?</SPAN></DIV>
@ZJONSSON
ZJONSSON / index.html
Created Oct 17, 2011
Using D3 to create and animate X3D - with x3dom
View index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="http://x3dom.org/x3dom/example/x3dom.js"></script>
</head>
<body>
</body>
@ZJONSSON
ZJONSSON / index.html
Last active Sep 27, 2015
Simple X3D with D3
View index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://raw.github.com/mbostock/d3/v2.4.3/d3.js"></script>
<script type="text/javascript" src="http://x3dom.org/x3dom/example/x3dom.js"></script>
</head>
<body>
</body>