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
var parameters = url.parse(req.url, true).query; | |
if (req.body) { | |
for (var key in req.body) { | |
parameters[key] = req.body[key]; | |
} | |
} |
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
var parameters = url.parse(req.url, true).query; | |
if (req.body) { | |
for (var key in req.body) { | |
parameters[key] = req.body[key]; | |
} | |
} |
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
## 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 |
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 routes [& handlers] | |
(-> (apply routes* handlers) | |
with-request-params | |
with-cookies)) |
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 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)))) |
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 write-htaccess [ips] | |
(spit "/home/q/htaccess" | |
(join "\n" (concat | |
'("order allow, deny") | |
(map (partial format "deny from %s") ips) | |
'("allow from all"))))) |
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
(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!"))) |
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 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 "/") |
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
#!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 |
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
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 | |
}); |
OlderNewer