Skip to content

Instantly share code, notes, and snippets.

Jared314 /
Last active Aug 16, 2018
Remaster Tiny Core Linux Core for x64
# Ubuntu 12.04
# sudo apt-get -y install p7zip-full genisoimage
# extract files
7z x Core-current.iso -ocore-current
Jared314 / gist:1443201
Created Dec 7, 2011
Parslet Transform Mod
View gist:1443201
require 'parslet'
class Parslet::Transform
def transform_elt(elt, context) # :nodoc:
rules.each do |pattern, block|
if bindings=pattern.match(elt, context)
# Produces transformed value
return call_on_match({:node => elt}.merge(bindings), block)
Jared314 / gist:1918865
Created Feb 26, 2012
Z-Type Game Backbone.js Custom Dictionary
View gist:1918865
//Run this while at the main menu
var w = 'at el id on add cid get has off set url make save sort sync clear clone fetch model parse pluck reset route start unset create escape extend length models remove render router routes setdom tojson changed destroy emulate history isvalid library trigger urlroot defaults delegate getbycid navigate previous validate attributes collection comparator haschanged initialize noconflict setelement undelegate constructor idattribute'
.toLowerCase().split(' ');
for (var i = w.length - 1; i >= 0; i--) { if(w[i].length < 13 && w[i].length > 1) WORDS[w[i].length].push(w[i]); }
Jared314 / gist:1928789
Created Feb 28, 2012
Z-Type Game Clojure.Core Custom Dictionary
View gist:1928789
//Run this while at the main menu,ent){if(this.targets[letter]===undefined)this.targets[letter]=[];this.targets[letter].push(ent);};,ent){(this.targets[letter]||[]).erase(ent);};
window.removeEventListener('keydown',; (event){if('text'||event.ctrlKey||event.altKey||this.mode!=ZType.MODE.GAME||{return true;}var c=event.which;if(c==189)c=45;if(event.shiftKey&&c==191)c=63;if(event.shiftKey&&c==56)c=42;if(event.shiftKey&&c==49)c=33;if(c==187)c=61;if(!((c>64&&c<91)||(c>96&&c<123)||(c==45||c==33||c==63||c==42||c==61))||c==16){return true;} event.stopPropagation();event.preventDefault();var letter=String.fromCharCode(c).toLowerCase();if(!this.currentTarget){var potentialTargets=this.targets[letter];var nearestDistance=-1;var nearestTarget=null;for(var i=0;i<potentialTargets.length;i++){var distance=this.player.distanceTo(potentialTargets[i]);if(distance<n
Jared314 / gist:5028617
Last active Dec 14, 2015
Basic CSS3 Selector to Clojure Enlive vector format converter
View gist:5028617
;[org.jodd/jodd-lagarto "3.4.2"]
;(:import [jodd.csselly CSSelly CssSelector Combinator Selector$Type])
(defn format-attr-selector [x]
(case (.getName x)
"id" (str "#" (.getValue x))
"class" (str "." (.getValue x))
(defn format-selector [x]
Jared314 / get-indent.clj
Last active Dec 14, 2015
A get-indent function to get the amount of indention for the next line of clojure code, based on the previous line.
View get-indent.clj
(def closing {\) \(
\} \{
\] \[})
(def opening [\( \{ \[])
(defn zero-or-more [x] (if (>= x 0) x 0))
(defn indent-exception? [[a b]] (not (and (= a \') (= b \())))
; warning: Very basic clojure language parsing. It does not handle strings.
(defn reverse-parse
([data] (reverse-parse data []))
Jared314 / instaparse-enlive-parsing.clj
Created May 19, 2013
Using Instaparse and Enlive for simple parsing and tree transformation / rewriting
View instaparse-enlive-parsing.clj
(ns test1
(:require [instaparse.core :as insta]
[net.cgrand.enlive-html :as enlive]
[clojure.walk :as walk]))
(defn render [nodes]
(walk/postwalk #(if (and (map? %) (:tag %))
(with-meta (hash-map (:tag %) (:content %)) (:attrs %))
%) nodes))
Jared314 / TreeIterator.clj
Last active Dec 17, 2015
Storing a parse tree, or AST, in a git repository with Clojure and JGit
View TreeIterator.clj
(ns gittree.TreeIterator
(:import [org.eclipse.jgit.lib Repository FileMode]
[org.eclipse.jgit.treewalk WorkingTreeIterator WorkingTreeIterator$Entry WorkingTreeOptions]
[ ByteArrayInputStream])
(:gen-class :extends org.eclipse.jgit.treewalk.WorkingTreeIterator
:init init2
:post-init postinit
:state state
:constructors {[org.eclipse.jgit.lib.Repository Object] [org.eclipse.jgit.treewalk.WorkingTreeOptions]
[org.eclipse.jgit.lib.Repository Object org.eclipse.jgit.treewalk.WorkingTreeIterator] [org.eclipse.jgit.treewalk.WorkingTreeIterator]}))
Jared314 / async1.clj
Created Jul 20, 2013
Clojure core.async example 1
View async1.clj
(ns async1
(:require [clojure.core.async :as async]))
(defn alice [c]
(async/>!! c "Carol Carolson's House @ 10pm"))
(defn bob [c]
(async/go (println "Bob received: " (async/<! c))))
(let [phonenumber-555-555-9292 (async/chan)]
Jared314 / async2.clj
Created Jul 21, 2013
Clojure core.async example 2
View async2.clj
(ns async2
(:require [clojure.core.async :as async]
[clojure.core.async.lab :as lab]))
(defn make-fb-group [& members]
(apply lab/broadcast members))
(defn alice [c]
(async/>!! c "Dave Davenson's House @ 10pm"))