Skip to content

Instantly share code, notes, and snippets.

View metacritical's full-sized avatar
Creating Black holes.

Pankaj Doharey metacritical

Creating Black holes.
View GitHub Profile
@metacritical
metacritical / core-import.clj
Last active July 29, 2019 18:18
Creating The Game window.
(ns core
(:gen-class))
(assembly-load-from "./extern/OpenTK/lib/net20/OpenTK.dll")
(defn -main[]
(Console/WriteLine "Starting OpenTK Window."))
@metacritical
metacritical / core.clj
Last active July 29, 2019 14:29
Clojure-CLR Hi World!
(ns core
(:gen-class))
(import [System])
(defn -main[]
(System.Console/WriteLine "Hi World"))
@metacritical
metacritical / build.sh
Last active July 30, 2019 14:48
Clojure-CLR build script for hi world.
#!/usr/local/bin/bash
runtime="mono"
cljcomp=$CLOJURE_LOAD_PATH/Clojure.Compile.exe
compile(){
CLOJURE_COMPILE_PATH=build/ $runtime $cljcomp core
}
link_dlls(){
using UnityEngine;
public class BoidBehaviour : MonoBehaviour
{
void Update()
{
Boids.Core.update(transform);
}
}
@metacritical
metacritical / Errors
Created July 24, 2019 10:38
Clojure-1.9.0 Binary Errors with Mono on Mac
>> mono all/net40/Clojure.Main.exe
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'Clojure.CljMain' threw an exception. ---> System.TypeInitializationException: The type initializer for 'clojure.lang.RT' threw an exception. ---> System.IO.FileNotFoundException: Invalid Image
at (wrapper managed-to-native) System.Reflection.Assembly.LoadFrom(string,bool,System.Threading.StackCrawlMark&)
at System.Reflection.Assembly.LoadFrom (System.String assemblyFile) [0x00002] in <f7cedb26ce694cd281e4450870c6fe49>:0
at clojure.lang.RT.DoInit () [0x0000a] in <814990e2d98549148927c9ed5c97f15e>:0
at clojure.lang.RT..cctor () [0x01f89] in <814990e2d98549148927c9ed5c97f15e>:0
--- End of inner exception stack trace ---
at Clojure.CljMain..cctor () [0x0000f] in <f5aa122c398747a0aa41452d219b2965>:0
@metacritical
metacritical / clojure
Created December 28, 2018 12:04
clojure
#!/usr/bin/env bash
# Version = 1.9.0.397
set -e
function join { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; }
# Extract opts
print_classpath=false
@metacritical
metacritical / README.md
Created December 8, 2018 03:19 — forked from bhauman/README.md
ClojureScript minimal dev and prod setup.

Recent improvements to the ClojureScript compiler have greatly simplified setting up development versus production outputs.

This example uses Figwheel as something that you want to exclude for production, but the pattern is general.

With this simple setup you only need one html file/view and it will work for developement and production.

@metacritical
metacritical / js-in-cljs.md
Created December 5, 2018 11:58 — forked from jmlsf/js-in-cljs.md
Using JavaScript modules in ClojureScript

Using JavaScript Libraries from ClojureScript

Using JavaScript libraries from ClojureScript involves two distinct concerns:

  1. Packaging the code and delivering it to the browser
  2. Making ClojureScript code that accesses JavaScript libraries safe for advanced optimization

Right now, the only single tool that solves these probems reliably, optimally, and with minimal configuration is shadow-cljs, and so that is what I favor. In paricular, shadow-cljs lets you install npm modules using npm or yarn and uses the resulting package.json to bundle external dependencies. Below I describe why, what alternatives there are, and what solutions I disfavor at this time.

Packaging and Delivering Code

@metacritical
metacritical / jit.cpp
Created September 19, 2018 23:31 — forked from tomas789/jit.cpp
LLVM JIT Example - Example of very simple JIT using LLVM. It compiles function with prototype `int64_t()` returning value `765`. Build: clang++ `llvm-config --cppflags --ldflags --libs core jit X86` jit.cpp
#include <iostream>
#include <cstdint>
#include <string>
#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/PassManager.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Analysis/Verifier.h"
@metacritical
metacritical / Clang_compilation.md
Last active September 6, 2018 18:36
Clang compilation commands.

CLang -> llvm

  • clang -S -emit-llvm program.c

llvm -> assembly

  • llc program.ll -o program.s

Evaluate llvm bit code

  • lli struct.ll

Make So files from C in clang

  • clang -O3 -dynamiclib -undefined dynamic_lookup runtime.c program.s -o program.so