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
(custom-set-variables | |
'(web-mode-attr-indent-offset nil) | |
'(web-mode-code-indent-offset 2) | |
'(web-mode-markup-indent-offset 2) | |
'(web-mode-indentation-params '("lineup-calls" . nil)) | |
) |
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
(defmacro record | |
"Dynamic factory for defrecords." | |
([name] `(record ~name {}) ) | |
([name vals-map] | |
`(let [con# (first (.getDeclaredConstructors ~name)) | |
num# (alength (.getParameterTypes con#))] | |
(merge (.newInstance con# (make-array Object num#)) ~vals-map)))) |
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 intercept | |
"Call the function body-fn, by installing bindings to intercept all functions with a generic handler. The handler is called with the Var to the original function, its original value and original arguments." | |
[functions handler body-fn] | |
(with-bindings | |
(reduce | |
(fn [bs fn-var] | |
(let [f (deref fn-var)] | |
(merge bs | |
{fn-var | |
(fn [& args] (handler fn-var f args))}))) |
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
;; recentf | |
(require 'recentf) ;; save recently used files | |
(setq | |
recentf-save-file "~/.emacs.d/cache/recentf" | |
recentf-max-saved-items 1000 ;; max save 100 | |
recentf-max-menu-items 15) ;; max 15 in menu | |
(recentf-mode t) ;; turn it on |
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 'ruote/storage/base' | |
module Ruote | |
module ActiveRecord | |
class Document < ::ActiveRecord::Base | |
set_table_name :documents | |
def self.before_fork | |
::ActiveRecord::Base.clear_all_connections! |
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
''=~+( | |
('('). | |
('?'). (( | |
'{')). ("\`"| | |
'%').( ('[')^ '-').( ('`')| | |
'!').( ('`')| "\,"). '"'.( | |
('[')^ '+'). ("\["^ "\)").( ('`')| |
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
# -*- coding: utf-8 -*- | |
require 'rubygems' | |
require 'active_support/core_ext/module/aliasing' | |
require 'active_record' unless defined?(ActiveRecord) | |
require 'mysql2' #0.2.7 | |
require 'active_record/connection_adapters/mysql2_adapter' | |
require 'meta_where' unless defined?(MetaWhere) | |
require 'rufus/json' |
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
;; http://pragprog.com/magazines/2012-03/comparing-java-and-scalas-expressiveness | |
;; first attempt for impl in clojure.. a lot to be improved! :) | |
(let [lines (map #(clojure.string/split % #" ") | |
(line-seq (clojure.java.io/reader (clojure.java.io/file "textfile.txt")))) | |
grouped (group-by #(second %) lines) | |
parse-long (fn [log] (Long/parseLong (first log))) | |
diff-times (fn [longs] (for [x (range (count longs)) :let [ts (nth longs x)] ] | |
(if (= 0 x) ts | |
(- ts (nth longs (- x 1)))))) |
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
// Modified SpamLord.java to call clojure code | |
public List<Contact> processFile(String fileName, BufferedReader input) { | |
List<Contact> contacts = new ArrayList<Contact>(); | |
// for each line | |
Matcher m; | |
String email; | |
try { | |
List results = new spamlord().process(input); |
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
<html> | |
<body> | |
<script type="text/javascript" | |
src="http://echo.gomus.com.br/player/mb.js?id=<##### ID DO PLAYER ######> "> | |
</script> | |
OlderNewer