Skip to content

Instantly share code, notes, and snippets.

@lsgrep
lsgrep / music.clj
Created February 28, 2015 13:12
Getting mp3 links from music site
(def song-url "http://www.mzhiphop.com/song-17803-Usher---Paradise")
(def song-static "http://www.sharebeast.com/mp3embed-")
(defn get-download-url [url]
(str song-static
(second
(str/split (second
(str/split
(get-in (nth
(html/select
(html/html-resource
@lsgrep
lsgrep / custom.el
Created February 27, 2015 18:50
Emacs Key bings for "reloaded"
(defun nrepl-refresh ()
(interactive)
(call-interactively 'cider-switch-to-relevant-repl-buffer)
(goto-char (point-max))
(insert "(clojure.tools.namespace.repl/refresh)")
(cider-repl-return))
(defun nrepl-reset ()
(interactive)
(call-interactively 'cider-switch-to-relevant-repl-buffer)
@lsgrep
lsgrep / *scratch*.el
Last active August 29, 2015 14:16
Cleanup IPTABLES
#!/bin/sh
echo "Stopping firewall and allowing everyone..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
@lsgrep
lsgrep / bootstrap.js
Created February 15, 2015 13:31
casperjs fix
//libexec/bin/bootstrap.js
system = require('system');
var argsdeprecated = system.args;
argsdeprecated.shift();
phantom.args = argsdeprecated;
@lsgrep
lsgrep / custom.el
Created February 10, 2015 20:20
emacs compress current buffer
(defun yui-compress ()
(interactive)
(call-process-region
(point-min) (point-max) "yuicompressor" t t nil (buffer-file-name)))
@lsgrep
lsgrep / *scratch*.el
Created January 22, 2015 19:34
Run ElasticSearch Docker Container local
;;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
@lsgrep
lsgrep / *scratch*.el
Created January 22, 2015 17:49
Nginx Security and Remote Addr
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;
@lsgrep
lsgrep / core.clj
Created December 22, 2014 13:56
Clojure Download a file
(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))))
@lsgrep
lsgrep / lichess-2.ug
Created December 20, 2014 10:42
Lichess translation
playWithAFriend=和朋友下棋
دوستۇم بىلەن شاھمات ئوينايمەن
playWithTheMachine=和机器下棋
ماشىنا شاھمات ئوينايمەن
toInviteSomeoneToPlayGiveThisUrl=要邀请别人下棋,请给他这个网址
باشقىلارنى تەكلڭىپ قىلىمەن ​,‌ تور ئادرېسىنى يوللا
gameOver=游戏结束
ئويۇن ئاخىرلاشتى
waitingForOpponent=等待对手
رەقىبنى ساقلاش
@lsgrep
lsgrep / core.clj
Last active August 29, 2015 14:11
Google scholar crawler
;; 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) " " "+"))