Skip to content

Instantly share code, notes, and snippets.

@indy
indy / improved-perlin-noise.java
Created February 6, 2010 12:22
Perlin noise - Java implementation
// JAVA REFERENCE IMPLEMENTATION OF IMPROVED NOISE - COPYRIGHT 2002 KEN PERLIN.
public final class ImprovedNoise {
static public double noise(double x, double y, double z) {
int X = (int)Math.floor(x) & 255, // FIND UNIT CUBE THAT
Y = (int)Math.floor(y) & 255, // CONTAINS POINT.
Z = (int)Math.floor(z) & 255;
x -= Math.floor(x); // FIND RELATIVE X,Y,Z
y -= Math.floor(y); // OF POINT IN CUBE.
z -= Math.floor(z);
@indy
indy / play_midi_file.java
Created April 8, 2010 21:10
java code to play a midi file
/* http://blog.taragana.com/index.php/archive/how-to-play-a-midi-file-from-a-java-application/ */
import javax.sound.midi.*;
import java.io.*;
/** Plays a midi file provided on command line */
public class MidiPlayer {
public static void main(String args[]) {
// Argument check
if(args.length == 0) {
@indy
indy / git-unpushed
Created January 31, 2012 10:47
git-unpushed
function git-unpushed {
brinfo=$(git branch -v | grep $(git-branch-name))
if [[ $brinfo =~ ("[ahead "([[:digit:]]*)) ]]
then
echo "(${BASH_REMATCH[2]})"
fi
}
(ns work.a1215-cljs-orbit
(:use [art.canvas :only (filled-rect filled-circle)]
[art.util :only (canvas-2d-animation)]))
(defn draw
[ctx]
(let [time (* (. (js/Date.) (getTime)) 0.002)
x (+ 128 (* 96 (. js/Math sin time)))
y (+ 128 (* 96 (. js/Math cos (* 0.9 time))))]
(-> ctx

Keybase proof

I hereby claim:

  • I am indy on github.
  • I am indy (https://keybase.io/indy) on keybase.
  • I have a public key whose fingerprint is 62B1 B28D 20A2 AB26 E1CF A3EE 3B21 C515 9F6F 4946

To claim this, I am signing this object:

Verifying that +inderjit is my blockchain ID. https://onename.com/inderjit
@indy
indy / gist:c8bfac88b3be79a1fb7c48d41d280542
Created November 20, 2019 19:54
HTML with broken CSS media query
<head>
<style type = text/css>
body{background:yellow;}@media only screen and(max-width:700px){body{background:red;}}
</style>
</head>
<body>
<h1>The background should turn red when the window is narrow</h1>
</body>
@indy
indy / index.html
Created November 21, 2019 11:36
CSS that breaks if the whitespace after closing brackets is removed
<head>
<style type = text/css>
#main[data-behavior = "1"] .styledheader {
background: yellow;
}
#main[data-behavior = "1"] ul.styledlist {
background: red;
}