This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns learn.ui | |
(:require [seesaw.core :as ui]) | |
(:use seesaw.font) | |
(:require [clj-http.client :as http]) | |
) | |
(def my-frame (ui/frame :title "awesome")) | |
(-> my-frame ui/pack! ui/show!) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns learn.core | |
(:require [clojure.core.async :refer [chan sliding-buffer go go-loop | |
timeout >! <!]]) | |
(:require [clojure.core.reducers :as r]) | |
(:require [clj-http.client :as http]) | |
(:require [org.httpkit.client :as httpkit]) | |
(:require [clojure.java.io :as io]) | |
(:require [net.cgrand.enlive-html :as html]) | |
(:use [clojure.java.shell :only [sh]]) | |
(:require [clojure.string :as str]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;(:require [org.httpkit.client :as httpkit]) | |
;;(:require [clojure.java.io :as io]) | |
;;(:require [net.cgrand.enlive-html :as html]) | |
(defn get-raw-translation-result [src-text ] | |
(apply (comp first :content ) (html/select (html/html-snippet | |
(:body (http/post "http://tilmach.net" | |
{:form-params {:Source src-text}}))) [:textarea#Target]))) | |
(defn translate [src] | |
(.trim (get-raw-translation-result src))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) | |
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/")) | |
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t) ; Org-mode's repository | |
(defun ensure-package-installed (&rest packages) | |
"Assure every package is installed, ask for installation if it’s not. | |
Return a list of installed packages or nil for every skipped package." | |
(mapcar | |
(lambda (package) | |
;; (package-installed-p 'evil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; scraping google scholar | |
(def ^:dynamic scholar-base "http://scholar.google.com/scholar?q=") | |
(def start-url "http://scholar.google.com/scholar?q=machine++learning") | |
(def typical-url "http://scholar.google.com/scholar?q=machine++learning&start=10") | |
(defn rebuild-keywords [keyword] | |
(.replace (.trim keyword) " " "+")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
playWithAFriend=和朋友下棋 | |
دوستۇم بىلەن شاھمات ئوينايمەن | |
playWithTheMachine=和机器下棋 | |
ماشىنا شاھمات ئوينايمەن | |
toInviteSomeoneToPlayGiveThisUrl=要邀请别人下棋,请给他这个网址 | |
باشقىلارنى تەكلڭىپ قىلىمەن , تور ئادرېسىنى يوللا | |
gameOver=游戏结束 | |
ئويۇن ئاخىرلاشتى | |
waitingForOpponent=等待对手 | |
رەقىبنى ساقلاش |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn download-file [url dir] | |
(let [my-file (last (.split url "/"))] | |
(if-not (.exists (io/as-file (str dir my-file))) | |
(try | |
(with-open [ in (io/input-stream url) | |
out (io/output-stream (str dir my-file))] | |
(io/copy in out) | |
(println my-file " has been downloaded.") | |
) | |
(catch Exception e (str "caught exception:" (.getMessage e)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server{ | |
listen 80; | |
proxy_connect_timeout 600; | |
proxy_send_timeout 600; | |
proxy_read_timeout 600; | |
send_timeout 600; | |
server_name asdf; | |
location /{ | |
proxy_set_header X-Real-IP $remote_addr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;iptables,this does not work for docker . You have to set ip explicitly | |
sudo iptables -A INPUT -p tcp -s localhost --dport 9200 -j ACCEPT | |
sudo iptables -A INPUT -p tcp --dport 9200 -j DROP | |
;; starting elasticsearch in a secure fashion | |
sudo docker run --name elastic -d -p 127.0.0.1:9200:9200 -p 127.0.0.1:9300:9300 -v /elastic:/data dockerfile/elasticsearch /elasticsearch/bin/elasticsearch -Des.config=/data/elasticsearch.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun yui-compress () | |
(interactive) | |
(call-process-region | |
(point-min) (point-max) "yuicompressor" t t nil (buffer-file-name))) |
OlderNewer