Skip to content

Instantly share code, notes, and snippets.

View freakhill's full-sized avatar

freakhill

  • tokyo
View GitHub Profile
@freakhill
freakhill / user-reader-dispatch-macro.clj
Created January 22, 2020 13:10
because i was curious, also keywords not supporting spaces is puzzling, why?
(ns keyword-reader-macro.core
(:import [clojure.lang LispReader LispReader$StringReader]))
(defn field []
(.getDeclaredField LispReader "dispatchMacros"))
(defn dispatch-macros []
(.get (field) LispReader))
(defn dispatch-reader!
@freakhill
freakhill / conf
Created September 29, 2016 07:44
haproxy lua script for superserver (to use with s6)
global
lua-load '/servers/haproxy/superserver.lua'
frontend tailon-frontend
bind :9090
tcp-request content set-var(txn.service_dir) str("/s6-supervised-servers/tailon")
tcp-request content lua.extend-life
default_backend tailon-backend
backend tailon-backend
@freakhill
freakhill / .gitignore
Last active November 19, 2015 06:01
leiningen public profile stuff
self-installs
@freakhill
freakhill / .gitignore
Last active August 29, 2015 14:27
core typed protocol check method too large
/target
/classes
/checkouts
pom.xml
pom.xml.asc
*.jar
*.class
/.lein-*
/.nrepl-port
@freakhill
freakhill / core.clj
Last active August 29, 2015 14:06
problem with optional parameters in protocols with core typed
(ns test.core
(:require [ clojure.core.typed :as t ]))
(t/ann-protocol P2
olol (t/IFn [P2 Kw * -> t/Any]))
(t/defprotocol> P2
(olol [this & rest]))
(t/ann-record R2 [])
(defrecord R2 []
@freakhill
freakhill / .gitignore
Last active December 24, 2016 10:11
emacs init script
*~
.*
*.dat
*.eld
.smex-items
.emacs_workgroups_*
tmp*
places
ede-projects.*
ac-dict/
@freakhill
freakhill / CouponActivity.java
Last active December 26, 2015 02:39
Wakuwaku SDK client
package jp.ne.wakuwaku.test;
import jp.ne.wakuwaku.sdk.Wakuwaku;
import jp.ne.wakuwaku.sdk.Wakuwaku.Coupon;
import jp.ne.wakuwaku.sdk.Wakuwaku.InitException;
import jp.ne.wakuwaku.sdk.Wakuwaku.NoEmailProvidedException;
import jp.ne.wakuwaku.sdk.Wakuwaku.NoWalletInstalledException;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
@freakhill
freakhill / typetag_to_runtime_class.scala
Last active December 22, 2015 12:38
Compare static TypeTag to runtime Class
import scala.reflect.runtime.universe._
class A[E](e:E)(implicit t: TypeTag[E]){
def c(o:Any) = {
val TypeRef(_, klass_symbol, _) = t.tpe
println(s"ClassSymbol extracted from TypeTag[E] '${klass_symbol.asClass}' : ClassSymbol")
println(s"Class extracted from o:Any parameter = '${o.getClass}' : Class[??]")
runtimeMirror(getClass.getClassLoader).runtimeClass(klass_symbol.asClass) == o.getClass
}
}
@freakhill
freakhill / epub_to_mobi_gutenberg.rb
Created June 28, 2013 07:03
working on redownloading my gutenberg epub file to mobi files
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
`find "/Users/freakhill/Dropbox/アプリ/gutenberg" -name "*.epub"`.split("\n").each do |f|
File.basename(f) =~ /^(.*)\.epub$/
title = $1
if File.exists? File.join(File.dirname(f), "#{title}.mobi")
puts "skipping #{$1}"
next
end
@freakhill
freakhill / rename.rb
Last active December 19, 2015 02:19
rename pdf files i downloader around the internet
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# easy to break use at your own risk
# this script renames pdf files in a folder (and subfoler) (on unixy machines)
# with a naive heuristic to find the title (that unfortunately is never in the *title* metadata)
require 'pdf-reader'