I hereby claim:
- I am HairyFotr on github.
- I am hairyfotr (https://keybase.io/hairyfotr) on keybase.
- I have a public key whose fingerprint is 462F C665 7BB9 743A 5561 31D7 E6EC 6964 42BA 5B10
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
#!/bin/bash | |
#usage: readWeather [IMAGE URL or FILE] | |
#example: readWeather http://www.eurometeo.com/english/meteomed/img_014M | |
#dependencies: wget, imagemagick, tesseract-ocr | |
pic="$(mktemp)" | |
if [[ "$1" == http:* ]] || [[ "$1" == https:* ]]; then wget -q -O "$pic" "$1"; else cp "$1" "$pic"; fi | |
convert "$pic" -scale 252%x266% -fill grey61 -fuzz 39% -floodfill 75%x75% grey10 -fuzz 53% -trim -brightness-contrast 0x-10 -fill gray4 -adaptive-sharpen 1x0.73 -swirl 0.52 -swirl 0.11 -solarize 14% -white-threshold 75% -negate "$pic" && | |
tesseract "$pic" stdout |
def encode(a: String, zero: Char = '0'): String = { | |
val bits = a.split("\n").map { line => line.map { _ != zero }.toArray } | |
val offsets = Array.ofDim[Int](bits.size/4+1, bits.head.size/2+1) | |
for(i <- 0 until bits.size; j <- 0 until bits.head.size) if(bits(i)(j)) offsets(i/4)(j/2) += (if(i%4 == 3) 0x40*(j%2 + 1) else math.pow(2, i%4 + (j%2)*3).toInt) | |
offsets.map { row => row.map { off => Character.toChars(0x2800 + off).head }.mkString }.mkString("\n") | |
} |
class ClojureWrap(ns: String, objName: String) { | |
import clojure.lang.{RT,Var} | |
import scala.collection.mutable.HashMap | |
RT.loadResourceScript(objName+".clj") | |
val obj = ns+"."+objName | |
val funcs = new HashMap[String, Var] | |
def /(func: String, a: Any): Object = | |
funcs.getOrElseUpdate(func, RT.`var`(obj, func)).invoke(a.asInstanceOf[Object]) |
#usage: readMeme [IMAGE URL or FILE] | |
#dependencies: wget imagemagick cuneiform | |
readMeme() { | |
pic="`mktemp`" | |
txt="`mktemp`" | |
in="$1" | |
if [[ $in == http:* ]] || [[ $in == https:* ]]; then wget -q -O $pic $1; else cp $1 $pic; fi | |
mogrify -resize '640x640>' -negate -sigmoidal-contrast 14x12% -scale 115%x102% -threshold 24% -background gray0 -deskew 9% -threshold 47% $pic && | |
cuneiform $pic -o $txt &> /dev/null && |
import collection.mutable._;object A{type S=String;def main(a:Array[S]){val s=a(0);val p=a.size==2;val e=if(p)a(1)else s.sorted;val c=new java.util.Scanner(System.in);while(c.hasNextLine){val w=c.nextLine;i(new N(w,if(p)w==e else w.sorted==e&&w!=s))};val q=Queue[N]();val k=y(s);k.c=0;def x(z:N){if(z.t)return;if(!z.v){z.e.map{e=>if(e.c>z.c+1)e.p.clear;if(e.c>z.c){e.c=z.c+1;e.p.append(z)};if(!e.v)q.enqueue(e)}};z.v=true;if(q.size>0)x(q.dequeue)};x(k);for{n<-y.values if(n.p.size>0&&n.t)}n.P("")};val y=Map[S,N]();def i(n:N)=for(m<-y.values;if(d(m.k,n.k)==1)){m.e.append(n);n.e.append(m)};def d(r:S,s:S)=r.zip(s).filter{t=>t._1!=t._2}.size;class N(val k:S,val t:Boolean){val e,p=ListBuffer[N]();var c=2147483647;var v=false;def P(a:S){if(p.isEmpty)println(k+a)else p.map(_.P("->"+k+a))}}} |