Skip to content

Instantly share code, notes, and snippets.

View nbeloglazov's full-sized avatar

Mikita Belahlazau nbeloglazov

View GitHub Profile
@nbeloglazov
nbeloglazov / packer.clj
Last active March 7, 2023 06:49
Creates fat jar for jogl and gluegen.jar.
(ns quil-utils.packer
(:require [cemerick.pomegranate.aether :as p]
[clojure.java.io :as io])
(:import [java.util.zip ZipFile ZipEntry ZipOutputStream]
org.apache.commons.io.IOUtils))
(defn jars [artifact version]
(->> [[artifact version]]
(p/resolve-dependencies :repositories {"JogAmp" "https://jogamp.org/deployment/maven/" "central" "https://repo1.maven.org/maven2/"} :coordinates)
@nbeloglazov
nbeloglazov / rhino_script.js
Last active July 11, 2020 22:05
setTimeout, clearTimeout, setInterval, clearInterval implementations for Rhino that works in 1.7R4
var setTimeout, clearTimeout, setInterval, clearInterval;
(function () {
var executor = new java.util.concurrent.Executors.newScheduledThreadPool(1);
var counter = 1;
var ids = {};
setTimeout = function (fn,delay) {
var id = counter++;
var runnable = new JavaAdapter(java.lang.Runnable, {run: fn});
@nbeloglazov
nbeloglazov / flipping.clj
Created July 20, 2017 03:38
Flipping drawing
(ns test.core
(:require [quil.core :as q]))
(defn draw []
(q/background 255)
(q/fill 0)
(q/with-translation [(/ (q/width) 2)
(/ (q/height) 2)]
(q/apply-matrix
@nbeloglazov
nbeloglazov / README.md
Last active April 12, 2017 06:25
Example of using Processing.selectInput() from Quil.
@nbeloglazov
nbeloglazov / longtask.clj
Created April 5, 2017 06:03
Example of using long-running background tasks with Quil. Quil's UI thread only displays data while background task perform CPU-intensive work (multiplying matrices) without blocking UI thread.
(ns longtask.core
(:require [quil.core :as q]
[quil.middleware :as m]))
; This program shows an example how to integrate long-running
; background tasks into Quil sketch. Clicking on the left or
; right half of the screen starts a new background task which does following:
; 1. Generates random square matrix of size rand of [100, 200, 500, 1000]
; 2. Multiplies matrix by itself. During the multiplication background thread
; updates (:progress state) value so Quil can display the progress.
@nbeloglazov
nbeloglazov / play_all_audio_files.js
Last active December 11, 2016 20:32
Script for Rachel's English site to play all audio recordings in soundboards session. Each recording will be played 3 times with pauses for you to repeat. How to use: 1. go to page with audio recordings 2. in url type "javascript:" and paste this script after colon 3. hit enter, it should start playing recordings one by one
function playAndWait(el) {
return new Promise((resolve) => {
el.play().then(() => {
setTimeout(resolve, (el.duration * 2.5) * 1000);
});
});
}
function swapEveryPair(els) {
const elements = Array.from(els);
(defproject drawing "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0"]
[quil "2.4.0"]])
From 3e49631e23f20c784fe70fc0d76bb3a58c4b8da6 Mon Sep 17 00:00:00 2001
From: Nikita Beloglazov <nikelandjelo@gmail.com>
Date: Sat, 12 Mar 2016 11:35:10 -0800
Subject: [PATCH] Optimize dump. Reduces size of optimizations SIMPLE binary
from 6.4M to 2.7M
---
src/main/cljs/cljs/js.clj | 2 +-
src/main/cljs/cljs/js.cljs | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
(ns my.core
(:require [cljs.nodejs :as nodejs]
cljs.js
[clojure.string :as cstr]))
(nodejs/enable-util-print!)
(def bar-source
"(ns my.bar)