Skip to content

Instantly share code, notes, and snippets.

View qharlie's full-sized avatar

charlie qharlie

  • USA
View GitHub Profile
var parameters = url.parse(req.url, true).query;
if (req.body) {
for (var key in req.body) {
parameters[key] = req.body[key];
}
}
var parameters = url.parse(req.url, true).query;
if (req.body) {
for (var key in req.body) {
parameters[key] = req.body[key];
}
}
## First install the stuff
# sudo apt-get install xvkbd xbindkeys-config tk
# Then put this in your ~/.xbindkeysrc
"xvkbd -xsendevent -text "(""
Caps_Lock
"xvkbd -xsendevent -text ")""
Super_L
(defn routes [& handlers]
(-> (apply routes* handlers)
with-request-params
with-cookies))
(defn search-log [log term]
(with-open [rdr (java.io.BufferedReader.
(java.io.FileReader. log ))]
(let [seq (line-seq rdr)]
(let [matched (filter #(not (= -1 (.indexOf % term)) ) seq)]
matched))))
(defn write-htaccess [ips]
(spit "/home/q/htaccess"
(join "\n" (concat
'("order allow, deny")
(map (partial format "deny from %s") ips)
'("allow from all")))))
(defroutes main-routes
(GET "/" [] (show-search-page))
(GET "/search" [term] (handle-search term))
(GET "/ban" [ip] (handle-ban ip)
(GET "/unban" [ip] (handle-unban ip))
(route/resources "/")
(route/not-found "page _Not_ !FOUND!")))
(defn handle-ban [ip]
(ban-ip ip)
(str ip " BANNED!"))
(defroutes main-routes
(GET "/" [] (show-search-page))
(GET "/search" [term] (handle-search term))
(GET "/ban" [ip] (handle-ban ip))
(GET "/unban" [ip] (handle-unban ip))
(route/resources "/")
#!upstart
description "MyApp"
author "MyApp by charlie"
env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
respawn
start on runlevel [23]
stop on shutdown
process.on('uncaughtException', function (err) {
var stack = err.stack.replace(/^[^\(]+?[\n$]/gm, '')
.replace(/^\s+at\s+/gm, '')
.replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@')
.split('\n');
logger.log('Uncaught exception', stack);
// Email somebody
});