Skip to content

Instantly share code, notes, and snippets.

View selfsame's full-sized avatar

Joseph Parker selfsame

  • Clover Food Lab
View GitHub Profile
@munificent
munificent / generate.c
Last active March 18, 2024 08:31
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
(import [UnityEditor RagdollBuilder])
;-)
(defn- invoke-private [obj meth & args]
(.Invoke
(.GetMethod
(type obj) meth
(enum-or BindingFlags/Instance
BindingFlags/NonPublic))
obj
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditorInternal;
#endif
@nasser
nasser / realize.clj
Last active November 18, 2016 03:18
Hiccup-inspired Unity Scene Graph DSL
(ns realize.core
(:use arcadia.core)
(:require [clojure.string :as string]))
(defn- reflective-set! [obj field value]
(if-let [^System.Reflection.FieldInfo info (.GetField (type obj) (str field))]
(.SetValue info obj value)
(if-let [^System.Reflection.PropertyInfo info (.GetProperty (type obj) (str field))]
(.SetValue info obj value nil)
(throw (Exception. (str "No field or property '" field "' on object of type " (type obj)))))))
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.Collections.Generic;
public class ColorToCSharp : EditorWindow
{
[SerializeField]
private bool _usedColorPickerOnce = false;
(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")
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;
(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)))
@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");
}