Skip to content

Instantly share code, notes, and snippets.

@zenon
zenon / JuliaSquared.jl
Last active July 12, 2022 03:15
Julia^2: Julia sets in Julia, using Interact. I'd like it faster.
using Plots, Interact, Base.Threads, BenchmarkTools
# only called by resize.
function batchify(maxIndex, numBatches)
if mod(maxIndex, numBatches) == 0
n = numBatches
else
n = numBatches - 1
end
batchSize = div(maxIndex, n)
#lang racket
(define cyphertext
"")
(define code
#hash(("a" . "_")
("b" . "_")
("c" . "_")
("d" . "_")
@zenon
zenon / gist:d6a6c542a2095d488ab75642aed78079
Created February 12, 2018 13:34
Some sniplets for Thymeleaf
RESTful: /mymock/17
Model:
======
package com.….;
import lombok.Data;
@zenon
zenon / Read.java
Created February 11, 2018 20:11
A rudimentary Java program to read (i.e. simply inflate) git object files.
package gitchen;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.util.Arrays;
import java.util.zip.InflaterInputStream;
// a class to look into the private parts of your git repo
public class Read {
@zenon
zenon / spread3.rb
Created April 7, 2017 05:23
More complete spread function
def spread3(num_accents, size, *args)
args_h = resolve_synth_opts_hash_or_array(args)
beat_rotations = args_h[:rotate]
res = []
# if someone requests 8 or more accents in a bar of 8 beats
# default to filling the output with accents
# (rotation is futile here)
if num_accents >= size # changed to >=, so v2 is not empty below
res = [true] * size
return res.ring
@zenon
zenon / spread2.rb
Created April 6, 2017 20:50
Test and fix for Sonic Pi's spread function, 2nd try
# helper for spread2
def redistribute(v1, v2)
vNew = []
while v1.length > 0 && v2.length > 0
a1 = v1.shift
a2 = v2.shift
vNew.unshift(a1 + a2)
end
if v1.length > 0 then
@zenon
zenon / spread2.rb
Created April 6, 2017 20:47
Test and fix for Sonic Pi's spread function
def redistribute(v1, v2)
vNew = []
while v1.length > 0 && v2.length > 0
a1 = v1.shift
a2 = v2.shift
vNew.unshift(a1 + a2)
end
if v1.length > 0 then
[vNew, v1]
else
@zenon
zenon / shepard.rb
Created March 20, 2017 06:30
Shepard tones example for Sonic Pi
# Want to make it better?
# 1. the volume scale should center about a
# frequency, not an octave
# 2. Check why using saw instead of sine doesn't work somehow.
# 3. The scaling with v and s shall make the overall volume
# sounds right AND smooth the ends.
# This should be seperated.
# 4. The smooting may be easier using subtractive synthesis
# 5. Can I create a complete synthesizer this way? What is missing?
@zenon
zenon / datomic_zero.clj
Created January 16, 2013 22:32
Datomic_zero - What is in an empty Datomic database (and how to find out)?
(ns datomic-zero
(:use [datomic.api :only [q db entity] :as d])
(:use (clojure pprint)))
;; URI as identifyer of the db
(def uri "datomic:mem://trials")
;; create database
(d/create-database uri)
@zenon
zenon / JGitTest.sc
Created November 14, 2012 09:55
Scala Worksheet to test the usage of JGit
object GitTest {
println("Testing JGit with Scala")
/*
- I used the Typesafe Scala IDE (Eclipse and a bit more)
- Downloaded JGit (2.1.0.201209190230-r) from http://eclipse.org/jgit/download/
- Donloaded JSch (Java Secure Channel, jsch-0.1.49.jar) from http://www.jcraft.com/jsch/
- Put both in the build path.