Skip to content

Instantly share code, notes, and snippets.

View zmaril's full-sized avatar
🌹
Crawling the web

Zack Maril zmaril

🌹
Crawling the web
View GitHub Profile
@zmaril
zmaril / Authorship.clj
Created July 27, 2011 02:14
Messing around with authorship triangle in clojure
(defmulti my-print class)
(defmethod my-print clojure.lang.IPersistentVector [c]
(.write *out* "[")
(.write *out* (str-join " " c))
(.write *out* "]"))
(defmethod my-print java.util.Collection [c]
(.write *out* "(")
(.write *out* (str-join " " c))
@zmaril
zmaril / gist:1131095
Created August 8, 2011 02:15
astar search
(def world [[ 1 1 1 1 1]
[999 999 999 999 1]
[ 1 1 1 1 1]
[ 1 999 999 999 999]
[ 1 1 1 1 1]])
(defn estimate-cost [step-cost-est size y x]
(* step-cost-est (- (+ size size) y x 2)))
(defn path-cost [node-cost cheapest-nbr]
@zmaril
zmaril / gist:1159955
Created August 21, 2011 01:29
Primes infinite sequence
(defn primes []
(map #(last (last %))
(iterate
(fn [[n prime-list]]
(if (every? false? (map #(= 0 (mod n %)) prime-list))
[(inc n) (conj prime-list n)]
(recur [(inc n) prime-list])))
[3 [2]])))
@zmaril
zmaril / gist:1516537
Created December 24, 2011 06:15
Readable hello_world
; ModuleID = 'tests/hello_world.f'
target datalayout = "e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-f128:128:128-n8:16:32:64"
target triple = "x86_64-apple-darwin11"
%struct.__st_parameter_dt = type { %struct.__st_parameter_common, i64, i64*, i64*, i8*, i8*, i32, i32, i8*, i8*, i32, i32, i8*, [256 x i8], i32*, i64, i8*, i32, i32, i8*, i8*, i32, i32, i8*, i8*, i32, i32, i8*, i8*, i32, [4 x i8] }
%struct.__st_parameter_common = type { i32, i32, i8*, i32, i32, i8*, i32* }
@.cst = linker_private constant [20 x i8] c"tests/hello_world.f\00", align 8
@.cst1 = linker_private constant [12 x i8] c"Hello World!", align 8
@options.1.1541 = internal constant [8 x i32] [i32 68, i32 511, i32 0, i32 0, i32 0, i32 1, i32 0, i32 1], align 32
@zmaril
zmaril / gist:1516538
Created December 24, 2011 06:17
Unreadable hello_world
????? 8???__text__TEXT??X ?__const__TEXT?`?__eh_frame__TEXT x?
p? h?
UH??H???H?? ???H?H??(???Dž0???Dž ????Dž$????H?? ???H?5?
?H?? ????H???]?UH??H?? ?}?H?u?}?H?u?}?H?u?}?H?u??H?5???E??E?H?? ]?tests/hello_world.fHello World!D?zRx
?-??????-?-c ?,????????p?
-W
-M?
-??????? ?8Rp?hXl9__gfortran_st_write__gfortran_transfer_character_write__gfortran_st_write_done_main__gfortran_set_args__gfortran_set_options_main.eh_MAIN__l_.cstl_.cst1_options.1.1541EH_frame0_MAIN__.eh
@zmaril
zmaril / JavascriptGook.js
Created December 29, 2011 02:17
Functions to turn any number into ++[[]]][+[]] Javascript Gobbledygook
//Used to bootstrap way up.
var zero = "+[]";
//Puts the goob into an array.
var intoArray = function(goobString){
return "["+goobString+"]";
};
//Uses the zero variable to grab the zeroth element of the array.
var zeroIndex= function (goobString){
@zmaril
zmaril / gist:1552985
Created January 3, 2012 01:26
Emscripten errors
Zacks-MacBook-Air:emscripten zackmaril$ ./emfortran tests/hello_world.f
(Emscripten: Running sanity checks)
WARNING: Closure compiler (/Users/zackmaril/Dev/closure-compiler/compiler.jar) does not exist, check the paths in ~/.emscripten. -O2 and above will fail
llvm_nm ?
/Users/zackmaril/Projects/Ravascrip/clang+llvm-3.0-x86_64-apple-darwin11/bin/llvm-nm: /var/folders/dy/7_v800lx5ss16j5m9yddq08m0000gn/T/tmpa_V25V/hello_world.o: unrecognizable file type
llvm_nm ?
/Users/zackmaril/Projects/Ravascrip/clang+llvm-3.0-x86_64-apple-darwin11/bin/llvm-dis: Invalid bitcode signature
Traceback (most recent call last):
File "/Users/zackmaril/Projects/Ravascrip/emscripten/emscripten.py", line 278, in <module>
temp_files.run_and_clean(lambda: main(keywords))
@zmaril
zmaril / gist:1563349
Created January 5, 2012 02:15
Results of taking the word freqs of an okcupid profile
I 0.061428573
to 0.045714285
and 0.04142857
the 0.03
of 0.021428572
in 0.015714286
a 0.014285714
am 0.012857143
as 0.011428571
have 0.011428571
@zmaril
zmaril / isMeasureable.js
Created January 10, 2012 03:14
isMeasureable
//Increase the list by one and does carry over between digits.
var increaseByOne = function(listOfWeights){
var newList = listOfWeights;
newList[newList.length-1] += 1;
for(var i = listOfWeights.length-1; i>0; i--){
var newWeight= listOfWeights[i];
if(newWeight==2){
newWeight=-1;
newList[i-1]+= 1;
}
@zmaril
zmaril / peano.js
Last active September 30, 2015 02:17
Turning any number into +[]'s with javascript
"use strict";
// This is one of my favorite javascript tricks. It shows off some of the weird
// parts of the language in a pretty straightforward way. With only three
// characaters, '+', '[' and ']', we can encode any natural number we want in javascript. For
// the math minded, this was inspiried by Peano's Axioms and javascript's type conversions.
// http://mathworld.wolfram.com/PeanosAxioms.html
// This file uses es6, run it by doing `node --harmony peano.js`