Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/expect -f
# sudo apt-get install expect
spawn ssh [email protected]
expect "assword:"
send "xxxx\$xxxxxx\r"
interact
package main
import "github.com/disintegration/imaging"
import "fmt"
func main() {
srcImage, err := imaging.Open("/home/itang/Downloads/logo.jpg")
if err != nil {
fmt.Printf("%v", err)
}
@itang
itang / shell.clj
Last active August 29, 2015 14:11
Scala as shell
(ns tools.dist
(:require [me.raynes.fs :as fs]
[clojure.java.shell :as shell]
[app.util :refer :all]))
(def ^:const JAR_FILE "target/tdb-0.1.0-SNAPSHOT.jar")
(def ^:const TARGET_DIR "/tmp/mex")
(def ^:const TARGET_LIB_DIR (str TARGET_DIR "/lib"))
@itang
itang / juxt.clj
Created November 29, 2014 10:43
clojure function: juxt
#_(defn select-values-ordered
""
[m keys]
(loop [ks keys ret []]
(if (seq ks)
(recur (next ks) (conj ret (get m (first ks))))
ret)))
(defn select-values-ordered
"获取指定keys的值序列"
#_(defhandler do-login [username password req t locale]
(v/rule (v/is-email? username) [:username (t locale :validation.passport/email)])
(v/rule (v/has-value? password) [:password (t locale :validation.passport/password)])
(v/rule (>= (count password) 6) [:password "密码至少6位"])
(if (v/errors?)
(do
(views/flash-put! "warning" (v/get-errors))
(response/redirect "/passport/login"))
(do
(session/put! :user username)
@itang
itang / tdb_core.clj
Created October 26, 2014 03:54
test korma
(ns tdb.core
(:gen-class)
(require [korma.db :refer :all])
(require [korma.core :refer :all])
(require [clojure.string :as str]))
(defdb prod
(postgres {:db "dbname"
:user "xxx"
:password "xxxx"
@itang
itang / lein_ancient.sh
Created October 25, 2014 08:37
离开Clojure的日子
lein ancient
[org.clojure/core.match "0.2.2"] is available but we use "0.2.0"
[org.clojure/core.typed "0.2.72"] is available but we use "0.2.17"
[org.clojure/tools.nrepl "0.2.6"] is available but we use "0.2.3"
[org.clojure/tools.reader "0.8.10"] is available but we use "0.7.10"
[commons-codec "1.9"] is available but we use "1.8"
[environ "1.0.0"] is available but we use "0.4.0"
[me.raynes/conch "0.7.0"] is available but we use "0.5.1"
[me.raynes/fs "1.4.6"] is available but we use "1.4.5"
[crypto-random "1.2.0"] is available but we use "1.1.0"
<!--[if lte IE 9]>
<div id="warning_info" class="text-warning fade in mb_0">
<button data-dismiss="alert" class="close" type="button">×</button>
<strong>您正在使用低版本浏览器,</strong> 在本页面的显示效果可能有差异。
建议您升级到
<a href="http://www.google.cn/intl/zh-CN/chrome/" target="_blank">Chrome</a>
或以下浏览器:
<a href="www.mozilla.org/en-US/firefox/‎" target="_blank">Firefox</a> /
<a href="http://www.apple.com.cn/safari/" target="_blank">Safari</a> /
<a href="http://www.opera.com/" target="_blank">Opera</a> /
@itang
itang / lein_exec.clj
Last active August 29, 2015 14:07
Try lein-exec
#!/bin/bash lein-exec
(use '[leiningen.exec :only [deps]])
(deps '[[clj-http "1.0.0"]
[cljtang "0.1.6"]])
(require '[clj-http.client :as client])
(require '[cljtang.lib :refer [repeat-str]])
(defn request-get-baidu []
@itang
itang / Main.java
Last active August 29, 2015 14:07
SCALA Single Abstract Method(SAM) support
public class Main {
public static void main(String[] args) {
new Thread(() -> {
System.out.println("Hello");
sleep(1000);
System.out.println("Exit!");
}).start();
}