Skip to content

Instantly share code, notes, and snippets.

View devth's full-sized avatar
Hacking on @yetibot

Trevor Hartman devth

Hacking on @yetibot
View GitHub Profile
(defmacro l10 [& body]
(doseq [i (range 10)]
`(println 1)))
(macroexpand `(l10 (println i)))
(cmd-hook #"meme"
#"^popular$" (chat-instance-popular)
#"^trending$" (chat-meme-list
(gen-trending))
#"^search\s(.+)" (chat-meme-list
(search-generators (second p)))
#"(\w+)\s(.+)\/(.+)$" (chat-instance
(create-instance
(map-to-query-string
(build-instance-params
mysql 5.5.15
http://dev.mysql.com/doc/refman/5.5/en/
Depends on: cmake, readline, pidof
/usr/local/Cellar/mysql/5.5.15 (6276 files, 217M)
Set up databases to run AS YOUR USER ACCOUNT with:
unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
To set up base tables in another folder, or use a different user to run
(defn meme-hook [callback cmd args]
(if (re-find #"meme" (s/lower-case cmd))
(cond-let [p]
(re-find #"^popular$" args) (chat-instance-popular)
(re-find #"^trending$" args) (chat-meme-list
(gen-trending))
(re-find #"^search\s(.+)" args) (chat-meme-list
(search-generators (second p)))
(re-find #"(\w+)\s(.+)\/(.+)$" args) (chat-instance
(create-instance ; e.g. "meme yuno line1 / line2"
:&javascript
function foo(a) { console.log(a); }
- for(i <- 1 to 10)
:&javascript
foo(#{i});
(defn chat-status [job-name]
"Sends job status info to chat. Sample output:
SUCCESS at Wed Nov 16. Started by trevor.
Currently building? false
Show 6 rumors before truncating"
(let [json (status job-name)]
(println json)
(if-let [building (str (:building json))] ; convert to string so a `false` doesn't give a false-negative
(let [result (str (:result json))
changeset (s/join
@devth
devth / sources.jade
Created October 31, 2011 23:15
Convert Map[String, String] to a sequence and zipWithIndex in order to have a sequential "index" available in scala's for comprehension
- for (((url, source), i) <- similarSources.toSeq.zipWithIndex)
a(href="#{url}" target="_blank")><= source
span><
- if (i < (similarSources.size - 2))
| ,
- else if (i == (similarSources.size - 2))
| and
$('#local_prices_page_contents')
.html(
(offers.size() > 0) ?
($.mustache(localPricesTemplate, {offers: offers.toJSON()})) :
"");
def brackets_valid?(str)
open = []
matches = { '{' => '}', '(' => ')', '[' => ']' }
str.split('').each do |c|
if matches.keys.include? c # it's an opening bracket
open.push c
elsif matches.values.include? c # it's a closing bracket
# must close the last open bracket
return false unless c == matches[open.pop]
" Put default register into system clipboard
nnoremap <leader>yc :let @+=@"<cr>
" Put system clipboard into default register
nnoremap <leader>cy :let @"=@+<cr>