Skip to content

Instantly share code, notes, and snippets.

View selfsame's full-sized avatar

Joseph Parker selfsame

View GitHub Profile
(ns sliders)
(defmacro slider [l]
(let [dashes (vec (repeat l "-"))]
`(do ~@(map (fn [i]
`(defn
~(symbol (clojure.string/join (assoc dashes i "*")))
[]
~(/ i (- l 1))))
(range l)))))
@vizanto
vizanto / Function.hx
Last active January 14, 2017 15:41
Haxe / Clojure interop experiments
//
// Nasty code below:
//
package java.internal;
import java.internal.Runtime;
/**
* These classes are automatically generated by the compiler. They are only
* here so there is an option for e.g. defining them as externs if you are compiling
* in modules (untested)
@nasser
nasser / README.md
Last active August 29, 2015 14:22
Execution of range function, implemented in pure Rejoyce

Rejoyce

Rejoyce is a purely functional, persistent, concatenative language

It maintains an In queue and an Out stackThe In queue represents code yet to be executed, and is initially populated with the program to run

The Out stack represents data to be manipulated, and is initially empty

The two record the complete state of execution at any time

To evaluate a token, Rejoyce returns a completely new In and Out stack

@CornuAmmonis
CornuAmmonis / splittwit.sh
Last active June 17, 2018 17:08
Shell script that uses twurl to upload a chunked native video to Twitter.
file=""
tweet=""
if [ -n "$1" ]
then
file="$1"
else
echo "Usage: splittwit /path/to/video.mp4 \"My tweet goes here!\""
exit
fi
@nasser
nasser / doarray.clj
Created October 4, 2015 14:32
doarray clojure iteration
(defmacro doarray [[variable array] & body]
(let [i (with-meta (gensym "i") {:tag Int64})
var-type (or (-> variable meta :tag) 'Object)
arr-type (symbol->array-type var-type)
arr (with-meta (gensym "array") {:tag arr-type})]
`(let [~arr ~array]
(loop [~i 0]
(if (= ~i (.Length ~arr))
nil
(let [~variable (aget ~arr ~i)]
@nasser
nasser / image-spell.js
Created January 20, 2016 06:02
Draggable Google Image Results
var imgs = document.querySelectorAll("div.rg_di.rg_el.ivg-i img")
for(var i=0; i<imgs.length;i++) {
imgs[i].src = imgs[i].parentNode.href.match(/\?imgurl=([^&]+)&/)[1];
imgs[i].parentNode.removeAttribute("href");
}
(defrecord Face [vertices normal]
IHashEq
(hasheq [this] (bit-xor (.hasheq (.vertices this))
(.GetHashCode (.normal this))))
Object
(ToString [this] (str "#Face[" (.normal this) " " (.vertices this) "]"))
IPersistentCollection
(count [this] (count (.vertices this)))
var fs = {
read: (filename, cb, err) => {
navigator.webkitPersistentStorage.requestQuota(0, (bytes) => {
window.webkitRequestFileSystem(PERSISTENT, bytes, (fs) => {
fs.root.getFile(filename, {},
(entry) => {
entry.file((file) => {
var reader = new FileReader();
if(err)
reader.onerror = err;
(import Undo)
(import |System.Collections.Generic.List`1|)
(let [method (.GetMethod Undo "GetRecords" (enum-or BindingFlags/NonPublic
BindingFlags/Static))
undos (|System.Collections.Generic.List`1[System.String]|.)
redos (|System.Collections.Generic.List`1[System.String]|.)]
(.Invoke method Undo (into-array [undos redos]))
[undos redos])
;; [("Selection Change" "Create Empty Game Object" "Selection Change"
;; "Selection Change" "Selection Change" "Selection Change" "Rename GameObject")
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.Collections.Generic;
public class ColorToCSharp : EditorWindow
{
[SerializeField]
private bool _usedColorPickerOnce = false;