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 sandbox.cipher | |
(:require [clojure.string :as str])) | |
(def alphabet "abcdefghijklmnopqrstuvwxyz") | |
(defn rotate [n coll] | |
(concat (drop n coll) (take n coll))) | |
(defn caeser-cipher [offset] | |
(-> (zipmap alphabet (rotate offset alphabet)) |
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 levenshtein [thr str1 str2] | |
"Clojure Levenshtein distance which short circuits when the distance is > thr" | |
(let [n (count str1) | |
m (count str2)] | |
(cond | |
(= 0 n) m | |
(= 0 m) n | |
:else | |
(last | |
(reduce (fn [prev-col i] |
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 bar [input] | |
(let [xf1 (partial re-seq #"[-\w]+") | |
xf2 (fn [[x & ys]] | |
[x | |
(->> ys | |
(map-indexed #(if (odd? %1) | |
(read-string %2) | |
%2)) | |
(apply assoc {}))])] | |
(transduce (comp (map xf1) |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
(-> (identity 12) | |
((fn [the-threaded-var] (* the-threaded-var 3))) | |
(/ 3)) |
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
(let [sqs {"AUGUGGAAAG" 4, "CGACCUCGUC" 2, "CCAGCGAACC" 2, "GGGCGAAGCU" 5, "GUUUACUUCA" 1, | |
"UACCAUAGUA" 1, "CGACCAGCAU" 2, "UGAAUUUCGA" 2, "GGUCUUUCUU" 2, "UGAAAUACAU" 1}] | |
(prn :>>) | |
(r/fold (fn ([] {}) | |
([l r] (merge-with + l r))) | |
(fn [M sq cs] | |
(->> (take 2 sq) | |
frequencies | |
(merge-with + M))) | |
sqs)) |
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 mysql-test | |
(:require [clojure.java.jdbc :as jdbc]) | |
(:use [edu.bc.bio.sequtils.files])) | |
(def mysql-ds | |
{:classname "com.mysql.jdbc.Driver" | |
:subprotocol "mysql" |
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 '[clojure.java.jdbc :as jdbc] | |
'[korma.db :as kdb] | |
'[korma.core :as kcore] | |
'[sqlingvo.core :as sql] | |
'[sqlingvo.vendor :as v])) | |
;;;examples here are directly from the sqlingvo, jdbc, korma websites | |
;;;in order to provide a concrete example of using a SQL DSL with jdbc | |
;;;to execute mysql commands |
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 sudoku | |
(:require [clojure.contrib.io :as io] | |
[clojure.contrib.string :as str] | |
[clojure.set :as sets])) | |
;;;example input for testing | |
(def grid01 | |
(list "003020600" | |
"900305001" | |
"001806400" |
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
;;; init.el --- Where all the magic begins | |
;; | |
;; Part of the Emacs Starter Kit | |
;; | |
;; This is the first thing to get loaded. | |
;; | |
;; "Emacs outshines all other editing software in approximately the | |
;; same way that the noonday sun does the stars. It is not just bigger | |
;; and brighter; it simply makes everything else vanish." | |
;; -Neal Stephenson, "In the Beginning was the Command Line" |
NewerOlder