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
(ns mp3dups.core | |
(:import (org.apache.commons.io FileUtils) | |
(java.io File) | |
(org.jaudiotagger.audio AudioFileIO) | |
(org.jaudiotagger.tag FieldKey))) | |
;; mp3data hash | |
;; [artist, title] -> mp3 filename | |
(def mp3data (atom {})) |
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
problem18> (solve) | |
14 [4 62 98 27 23 9 70 98 73 93 38 53 60 4 23] [63 66 4 68 89 53 67 30 73 16 69 87 40 31] | |
13 (125 164 102 95 112 123 165 128 166 109 122 147 100 54) [91 71 52 38 17 14 91 43 58 50 27 29 48] | |
12 (255 235 154 150 140 179 256 209 224 172 174 176 148) [70 11 33 28 77 73 17 78 39 68 17 57] | |
11 (325 246 187 178 256 329 273 302 263 242 193 233) [53 71 44 65 25 43 91 52 97 51 14] | |
10 (378 317 231 321 354 372 393 354 360 293 247) [41 48 72 33 47 32 37 16 94 29] | |
9 (419 365 393 387 419 425 430 376 454 322) [41 41 26 56 83 40 80 70 33] | |
8 (460 434 419 475 508 470 510 524 487) [99 65 4 28 6 16 70 92] | |
7 (559 499 479 536 514 526 594 616) [88 2 77 73 7 63 67] | |
6 (647 501 613 609 533 657 683) [19 1 23 75 3 34] |
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
(ns e.core | |
(:gen-class) | |
(:use faker.internet)) | |
(defn make-n-emails-file | |
[filename n] | |
(spit filename | |
(apply str (interleave (take n (emails)) (repeat "\n"))))) | |
(defn -main |
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
(ns xor | |
(:use clojure.test)) | |
(defmacro xor | |
"Evaluates exprs one at a time, from left to right. If only one form returns | |
a logical true value (neither nil nor false), returns true. If more than one | |
value returns logical true or no value returns logical true, retuns a logical | |
false value. As soon as two logically true forms are encountered, no | |
remaining expression is evaluated. (xor) returns nil." | |
([] 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
(ns clojure101.game_of_life | |
(:gen-class) | |
(:require [clojure.contrib.swing-utils :as swing] | |
[clojure.java.javadoc :as javadoc]) | |
(:use [clojure.contrib.pprint :only [pprint]]) | |
(:import [javax.swing JFrame JToolBar JButton] | |
[java.util EventObject])) | |
; (set! *warn-on-reflection* true) |
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
logger = Logger.new(STDOUT) | |
logger.level = Logger::DEBUG | |
RAILS_DEFAULT_LOGGER = logger | |
ActiveRecord::Base.logger = logger | |
ActionController::Base.logger = logger | |
ActiveSupport::Cache::MemCacheStore.logger = logger | |
ApplicationController.allow_forgery_protection = false | |
reload! |
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
Non-memoize | |
Cleaning JVM allocations ... | |
Warming up for JIT ... | |
Estimating execution count ... | |
Running ... | |
Checking GC... | |
Cleaning JVM allocations ... | |
Finding outliers ... | |
Bootstrapping ... | |
Checking outlier significance |
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
(clutch/with-db database | |
(clutch/ad-hoc-view | |
(clutch/with-clj-view-server | |
{:map (fn [doc] [[(:person doc) nil]]) | |
:reduce (fn [key values _] nil)}) | |
{:limit 5 :group true}))) |
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 is a monkey patch for MessageVerifier — I need to change Marshal.load to JSON | |
if defined?(ActionController::Flash::FlashHash) | |
class ActionController::Flash::FlashHash | |
def to_json(*args) | |
{}.merge(self).merge({:used => @used}).to_json | |
end | |
end | |
end |
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
I am using rscribd (latest) to store and display private documents. I have no | |
problems displaying private docs but I need more security. | |
I added :secure_document => 1 to upload options hash and use | |
following code to display it: | |
var scribd_doc = scribd.Document.getDoc( doc_id, doc_key ); | |
scribd_doc.addParam("use_ssl", true); | |
scribd_doc.grantAccess('4', '#{session[:session_id]}', signature); | |
scribd_doc.addParam( 'jsapi_version', 1 ); | |
scribd_doc.write( 'embedded_flash' ); |