Skip to content

Instantly share code, notes, and snippets.

@ds604
ds604 / gist:3988791
Created October 31, 2012 18:12
Lena_ref
import scipy.misc
lena = scipy.misc.lena()
#convert to PIL
pic = scipy.misc.toimage(lena)
import numpy as np
import matplotlib.pyplot as plt
w = 400
h = 300
def normalize(x):
x /= np.linalg.norm(x)
return x
# A python script which makes emails in all files in current directory and sub-directories anonymous.
# e.g. A file with the following contents:
# siddhartha@gmail.com
# Sid Phn#- 6385833322
# gupta49@illinois.edu
# weee@as.cd
# sid@yahoo.co.in
# Would change to:
@ds604
ds604 / gist:9169428
Created February 23, 2014 10:00 — forked from unconed/gist:4370822

How to capture WebGL/Canvas by writing out PNGs to a sandboxed filesystem

Summary: Write .PNGs to the sandboxed file system in Chrome. Then sneak in and move them out.

1) Set up a sandboxed file system

// Request 40 GB (should be enough for ~5 minutes of 1080p)
var bytes = 1024*1024*1024*40;
<!DOCTYPE html>
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div style="position:absolute;top:50px;left:50px;">
<canvas id="canvas" width="500" height="500"></canvas>
body, html {
height: 100%;
margin: 0;
}
@ds604
ds604 / LICENSE.txt
Created March 4, 2017 17:16 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@ds604
ds604 / gl.js
Created April 14, 2017 02:53 — forked from thomaswilburn/gl.js
Annotated WebGL sample.
/*
We're going to start by adding a canvas to the page and getting a context for it.
*/
var canvas = document.createElement("canvas");
canvas.width = canvas.height = 320;
document.body.appendChild(canvas);
var gl = canvas.getContext("experimental-webgl");
/*
WebGL doesn't know how to draw anything onscreen out of the box. We have to
@ds604
ds604 / EXECUTABLE_MAGIC
Created September 26, 2017 07:38
make `hydrogen` work with remote kernel
#!/usr/bin/env bash
local_json=$1
remote_ip=$2
remote_json=$3
remote_json_on_local=$(jupyter --runtime-dir)/remote.json
scp $remote_ip:$remote_json $remote_json_on_local
for socket_name in hb_port control_port stdin_port iopub_port shell_port; do
local_port=$(sed 's/,/\n/g' $local_json | grep $socket_name | grep -o "[0-9]\+")
remote_port=$(grep $socket_name $remote_json_on_local | grep -o "[0-9]\+")
@ds604
ds604 / nxgebd.markdown
Last active December 17, 2017 04:37
NXGebd