Skip to content

Instantly share code, notes, and snippets.

View veeenu's full-sized avatar

Andrea Venuta veeenu

View GitHub Profile
@veeenu
veeenu / FsWatcher.java
Created July 5, 2017 07:59
Simple Java file watcher
import java.io.*;
import java.nio.file.*;
import java.awt.event.*;
import java.util.*;
import java.util.function.*;
public class FsWatcher {
private Thread t;
private File file;
@veeenu
veeenu / xorNeuralNetwork.m
Created July 22, 2016 16:11
Neural network learning XOR function
clear;
clc;
sigmoid = @(x) 1 ./ (1 + exp(-x));
tset = [
0, 0, 0 ; % 0 xor 0 = 0
0, 1, 1 ; % 0 xor 1 = 1
1, 0, 1 ; % 1 xor 0 = 1
1, 1, 0 % 1 xor 1 = 1
@veeenu
veeenu / build.js
Created January 26, 2016 16:58
Minimal node.js parallel task runner
const exec = require('child_process').exec;
const conf = require('./package.json').buildjs || {};
const C0 = '\033[0m',
C1 = '\033[1;34m',
C2 = '\033[1;32m',
C3 = '\033[1;31m';
const runCmd = (function() {
@veeenu
veeenu / index.html
Last active October 10, 2015 11:49
Particle System - I
<!DOCTYPE html>
<html>
<head>
<link rel='stylesheet' href='style.css'/>
</head>
<body>
<script type='application/x-shader' id='vertex'>
attribute vec3 Position;
attribute float Size, Life;
@veeenu
veeenu / avgvri-rvdi.js
Created February 9, 2015 19:53
Avgvri Rvdi - happy birthday demo card
c = document.createElement('canvas');
c.width=innerWidth;c.height=innerHeight;
document.body.appendChild(c);
d = c.getContext('2d');
d.font='64px\x20Times\x20New\x20Roman';
d.shadowColor='white'
d.shadowBlur=8;
p = []
setInterval(function() {
p.push([ Math.random()*innerWidth, Math.random()*innerHeight,
@veeenu
veeenu / fragment.glsl
Last active August 29, 2015 14:13
Isosurface polygonization with chunked voxels
precision highp float;
varying vec3 fnormal, flight, fpos;
varying vec2 ftextureCoordinate;
varying vec3 fogv;
uniform sampler2D textureSampler;
void main(void) {
vec3 ldir = normalize(flight);
@veeenu
veeenu / fezrotate.js
Created December 25, 2014 10:23
Fez-like world rotation
/*
* Procedurally generated Minecraft dirt texture.
*/
(function() {
var ctx, imgd;
ctx = document.getElementById('texture').getContext('2d');
imgd = ctx.createImageData(64, 64);
@veeenu
veeenu / index.html
Created December 4, 2014 17:07
Thema Regium
<!DOCTYPE html>
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Ubuntu+Mono' rel='stylesheet' type='text/css'>
<style>
body {
padding: 9rem;
font-size: 4rem;
font-family: 'Ubuntu Mono', monospace;
line-height: 6rem;
@veeenu
veeenu / ortho.hs
Created November 7, 2014 18:47
Haskell orthograpic projection
import qualified Graphics.UI.GLUT as GLUT
import Data.IORef
type Mat3 = (
GLf, GLf, GLf,
GLf, GLf, GLf,
GLf, GLf, GLf
)
type Vec3 = ( GLf, GLf, GLf )
type GLf = GLUT.GLfloat
@veeenu
veeenu / cellular-automaton.hs
Last active August 29, 2015 14:07
Haskell cellular automaton
import System.Random
getCell :: Int -> Int -> [Int] -> Int
getCell x y vec = head $ drop ((clamp y) * 32 + (clamp x)) vec
where clamp i = min 31 (max 0 i)
generation :: Int -> [Int] -> [Int]
generation 0 vec = vec
generation i vec = map step [0 .. length vec]
where