Skip to content

Instantly share code, notes, and snippets.

View houshuang's full-sized avatar

Stian Håklev houshuang

View GitHub Profile
@houshuang
houshuang / insta.play.clj
Created April 22, 2013 14:05
Trying, trying
(defn do-on-change [func files]
(let [old (atom (map-current files))]
(while true
(do
(Thread/sleep 500)
(let [current (atom (map-current files))]
(println "hi")
(if (hash-diff @old @current)
(do
(func)
test=> (Provider/)
Provider/getCurrentProvider Provider/logger
test=> (Provider/getCurrentProvider)
CompilerException java.lang.NoSuchFieldException: getCurrentProvider, compiling:(NO_SOURCE_PATH:1:1)
keys.core=> listener
#<Object$HotKeyListener$13666434 keys.core.proxy$java.lang.Object$HotKeyListener$13666434@6d7accc9>
keys.core=> keys
#<AWTKeyStroke shift ctrl pressed 1>
keys.core=> a#<CarbonProvider com.tulskiy.keymaster.osx.CarbonProvider@44980228>
keys.core=> (.register a keys listener)
IllegalArgumentException No matching method found: register for class com.tulskiy.keymaster.osx.CarbonProvider clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:80)
Java:
provider.register(KeyStroke.getKeyStroke("control shift 0"), listener);
@houshuang
houshuang / core.clj
Created April 28, 2013 00:11
Gives Don't know how to create ISeq from: clojure.lang.Symbol
(ns keymaster.core
(:gen-class)
(:use seesaw.core)
(:require [keymaster.keymaster :as km]))
@houshuang
houshuang / core.clj
Created April 28, 2013 00:21
Why are these two different?
keymaster.core=> (clojure.core/require '[clojure.java.io :as io])
nil
keymaster.core=> (clojure.core/require '[keymaster.keymaster :as km])
IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Symbol clojure.lang.RT.seqFrom (RT.java:505)
traceroute to clojurewerkz.org (5.9.20.53), 64 hops max, 52 byte packets
1 * * *
2 * *traceroute: sendto: No route to host
traceroute: wrote clojurewerkz.org 52 chars, ret=-1
*
traceroute: sendto: Host is down
3 traceroute: wrote clojurewerkz.org 52 chars, ret=-1
*traceroute: sendto: Host is down
traceroute: wrote clojurewerkz.org 52 chars, ret=-1
*traceroute: sendto: Host is down
#Reproducible example
lik <- structure(list(Relevant = structure(c(6L, 5L, 6L, 2L, 5L, 4L, 5L, 5L, 6L, 2L, 6L, 3L, 5L, 4L, 5L, 3L, 2L, 2L, 4L, NA, 2L, 6L, NA, 5L, 5L, 5L, 5L, 5L, 6L, 6L), .Label = c("0", "Agree", "Disagree", "Neutral", "Strongly Agree", "Strongly Disagree"), class = "factor"), Help.career = structure(c(3L, 5L, 6L, 2L, 5L, 2L, 5L, 5L, 6L, 2L, 6L, 3L, 5L, 4L, 3L, 2L, 2L, 2L, 2L, NA, 6L, 6L, 2L, 5L, 5L, 5L, 5L, 4L, 6L, 6L), .Label = c("0", "Agree", "Disagree", "Neutral", "Strongly Agree", "Strongly Disagree"), class = "factor"), Earn.credential = structure(c(6L, 5L, 2L, 2L, 2L, 4L, 5L, 5L, 6L, 4L, 6L, 2L, 5L, 2L, 3L, 3L, 2L, 4L, 5L, NA, 3L, 6L, NA, 6L, 3L, 4L, 4L, 6L, 6L, 2L), .Label = c("0", "Agree", "Disagree", "Neutral", "Strongly Agree", "Strongly Disagree"), class = "factor"), Prestigious.U = structure(c(6L, 5L, 2L, 2L, 2L, 4L, 5L, 2L, 6L, 3L, 6L, 4L, 5L, 4L, 3L, 3L, 2L, 4L, 2L, NA, 6L, 5L, NA, 2L, 3L, 5L, 2L, 5L, 6L, 6L), .Label = c("0", "Agree", "Disagree", "Neutral", "Strongly Agree", "
> t<-table(prec$usercat,prec$relevant.to.aca.study.Why.enroll)
> f<-as.data.frame(unclass((prop.table(t,1))))
> sum(f$Agree)
[1] 1.744855
> sum(f$Disagree)
[1] 0.6086854
db <- as.data.frame(lapply(db, function(x){
x <- as.character(x)
replace(x, x == "0", NA)
x <- as.factor(x)}))
db <- as.data.frame(lapply(db, function(x){
x <- as.character(x)
replace(x, x == "", NA)
x <- as.factor(x)}))
replace <- list(c("Academic / Professor", "Academic/Professor"),
c("Lifelong learner", "Lifelong Learner"),
c("Student (University/College)", "Student"))
for(e in replace) {
db$usercat <- replacefact(db$usercat, e[1], e[2])}