Skip to content

Instantly share code, notes, and snippets.

View vicapow's full-sized avatar

Victor vicapow

View GitHub Profile
@vicapow
vicapow / README.md
Last active February 13, 2017 23:07
MLP Neural Network for O.C.R.
@vicapow
vicapow / _.md
Last active August 29, 2015 14:11
test
<b>Hello world</b>
@vicapow
vicapow / index.html
Last active August 29, 2015 14:05
laser!
<!DOCTYPE html>
<html>
<script src="http://d3js.org/d3.v3.js" charset="utf-8"></script>
<body>
<script>
var w = 800, h = 800, n = 40
var svg = d3.select('body').append('svg')
.attr({width: w, height: h})
@vicapow
vicapow / main.go
Created July 31, 2014 07:29
noise in go lang
package main
import _ "image/png"
import (
"os"
"image"
"image/draw"
"image/color"
"image/png"
@vicapow
vicapow / README.md
Last active April 5, 2023 12:45
getStyles function from NYT's Crowbar

Get all the styles as a string from a given document. useful for creating a PNG from an SVG. SVG's need to have all of their style information embedded within their document to be properly exported.

Example usage:

var styles = getStyles(window.document);

Try it by going to [http://bl.ocks.org/vicapow/raw/9904319/](this block) and running the above usage example in the console.

@vicapow
vicapow / README.md
Last active December 3, 2024 13:11
An example of creating a PNG from an SVG in D3.

This is an example of creating a PNG from an SVG. (You should notice that you're able to right click on the last image and save it as a PNG image.) It has been Tested in Firefox and Chrome but doesn't work in Safari as of 2014-07-20.

Normally, you'll create your SVG in D3 but to make the example a bit more readable, the SVG is already placed in the document. There are a few important points. Namely:

  1. All the styles of the SVG need to be self contained in side of the <defs> tags. (These styles should be escaped using the <![[CDATA[ ... ]] tag.)
  2. The SVG needs to have the proper namespaces and document types.
  3. The SVG needs to be saved to an image, then read from an canvas element, then saved to an image again.

Note: Portions of this demo where taken from The New York Times' excellent Crowbar SVG extractor.

<!DOCTYPE html>
<html>
<script src="http://d3js.org/d3.v3.js" charset="utf-8"></script>
<style>
body, html{
margin: 0;
}
</style>
<body>
<script>
@vicapow
vicapow / index.html
Created July 8, 2014 16:30
testing newlines in svg
<!DOCTYPE html>
<html>
<body>
<h1> svg text with multiple text elements</h1>
<svg width="400" height="400">
<text y="100">
<tspan x="0" dy="1.4em">
wow this is cool
</tspan>
@vicapow
vicapow / index.html
Created June 3, 2014 06:46
two way data binding in reactjs
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="http://fb.me/react-0.10.0.js"></script>
<script src="http://fb.me/JSXTransformer-0.10.0.js"></script>
</head>
<body>
<script type="text/jsx">
/** @jsx React.DOM */