Skip to content

Instantly share code, notes, and snippets.

View minikomi's full-sized avatar
🍕
I like pizza

Adam Moore minikomi

🍕
I like pizza
View GitHub Profile
@minikomi
minikomi / .gitignore
Created November 4, 2011 04:49
Barebones chat based on longpolling demo
*/*.pid
*/*.db
*/*.conf
@minikomi
minikomi / unshred.py
Created November 14, 2011 07:32
Instagram Deshredder
#Takes 2 arguments at command line: filename, shred width.
def unshred(img_name, shred_width):
image = Image.open(img_name)
data = image.getdata()
img_w, img_h = image.size
def get_pixel_value(x, y):
pixel = data[y * img_w + x]
@minikomi
minikomi / lzw.js
Created January 1, 2012 15:01
lzw
var lzw = function(input_string){
var dic = "abcdefghijklmnopqrstuvwzyz ".split("");
var inp = input_string.split("");
var buffer = "";
var encoded = [];
while (inp.length > 0){
var ch = inp.shift();
if(dic.indexOf(buffer + ch) >= 0){
buffer = buffer+ch;
}else{
@minikomi
minikomi / bookmarklet.js
Created January 16, 2012 01:43
Random colors for dark vim scheme at villistrator
javascript:(function(){var divs=["normalBG","normalFG","commentFG","constantFG","strFG","specFG","identFG","keyFG","incFG","typeFG","funFG","repFG","opFG"];for(var i=1;i<myscopes.length;i++){var randcolstring="";for(var j=0;j<3;j++){var randcol=(Math.floor(Math.random()*256)).toString(16);if(randcol.length==1){randcol="0"+randcol;}randcolstring=randcolstring+randcol;myscopes[i]=randcolstring;}$("#"+divs[i]).ColorPickerSetColor(myscopes[i]);$("#"+divs[i]+" div").css("background-color","#"+myscopes[i]);$("."+divs[i]).css("color","#"+myscopes[i]);}})();
@minikomi
minikomi / reductions.clj
Created January 20, 2012 06:38
4Clojure Problem #60
(fn [f init & [args]]
(let [init-args (if (nil? args) init (cons init args))]
(map
#(reduce function (take % init-args))
(map #(inc %2) init-args (range)))))
@minikomi
minikomi / 61.clj
Created January 20, 2012 07:01
4Clojure #61 solution
(fn [a b]
(reduce
#(assoc % (first %2)(last %2))
{} (partition 2 (interleave a b))))
@minikomi
minikomi / 62.clj
Created January 20, 2012 07:16
Solution #62
(fn [f i]
(cons i
(map #((apply comp (repeat (inc %) f)) i) (range))))
(fn f
[func init]
(lazy-seq
(cons init (f func (func init)))))
@minikomi
minikomi / 63.clj
Created January 20, 2012 08:07
4clojure 63
(fn [f a]
(reduce
(fn
[m x]
(assoc m (f x)
(conj (get m (f x) []) x)))
{} a))
@minikomi
minikomi / s.lua
Created January 26, 2012 15:23
lua server
-- -*-mode: C++; style: K&R; c-basic-offset: 4 ; -*- */
--
-- A simple HTTP server written in Lua, using the socket primitives
-- in 'libhttpd.so'.
--
-- This server will handle multiple virtual hosts. The only requirement
-- is that each virtual host must have the documents located beneath
-- a common tree. Note that directory indexes are not (yet) supported.
--
@minikomi
minikomi / chain.js
Created January 30, 2012 05:49
Chaining using underscore
_({first: 1, second: 2, text: 'string here' }) // put object to wrapper
.chain() // chaining enabled
.compact() // now work with: [1,2, 'string here']
.size() // now: 3
.value() // return result