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
;;adapted from http://clojurerabbitmq.info/articles/error_handling.html | |
(ns killwabbit.core | |
(:gen-class) | |
(:require [langohr.core :as rmq] | |
[langohr.channel :as lch] | |
[langohr.queue :as lq] | |
[langohr.exchange :as lx] | |
[langohr.consumers :as lc] | |
[langohr.basic :as lb]) | |
(:import java.io.IOException |
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
; variable evaluation: find and substitute | |
; look for Var X in B and substitute a | |
; environment, symbol | |
(def MyEnv {"One" 1 | |
"Two" 2 | |
"Three" 3 | |
"MyAdd" +}) | |
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 scramboni [rack] | |
"Find all playable words in a given Scrabble rack. Use asterisks for blanks." | |
(letfn [(every-but-n? [n pred coll] | |
(->> coll | |
(map (comp (fn [x] (if x :true :false)) pred)) | |
frequencies | |
(merge {:false 0}) | |
:false | |
(>= n)))] | |
(let [scrabble-words (->> "/home/mitchells/Desktop/npr_sunday_puzzle_solutions/resources/ospd3.txt" |
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
(def mystring "my name is stephanie") | |
(def alphabet "abcdefghijklmnopqrstuvwxyz") | |
(def alphabet-chars (map char alphabet)) | |
alphabet-chars | |
(def alphabet-shifted (drop 5 (take 100 (cycle alphabet-chars)))) |
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
A Caesar cipher is a very simple kind of encoding of alphabetic text (like English) | |
in which each letter in the text is replaced by another letter some fixed number of | |
positions down the alphabet. For example, the string | |
"hello" | |
can be replaced by a Caesar cipher one letter down the alphabet to the following: | |
"ifmmp" |
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 sentiment-scorer [& maps] | |
(letfn [(sentiment-scorer-intermediate [m] | |
(let [words (-> (:c m) | |
(clojure.string/lower-case) | |
(clojure.string/replace #"[\.\!\@]" "") | |
(clojure.string/split #"\s+")) | |
rs (repeat (count words) [(:r m)])] | |
(apply hash-map (interleave words rs))))] | |
(let [intermediate-map (->> (apply map sentiment-scorer-intermediate maps) | |
(apply merge-with concat))] |
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 [d {1 "Project #1" | |
2 "Project #2" | |
3 "Project #3" | |
4 "Project #4" | |
5 "Project #5" | |
6 "Project #6"}] | |
(d (-> (rand-int 6) | |
inc))) |
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 [d ["Project #1" | |
"Project #2" | |
"Project #3" | |
"Project #4" | |
"Project #5" | |
"Project #6"]] | |
(rand-nth d)) |
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
; See http://www.szcz.org/blog/?cat=33 for context | |
(let [surnames (->> (slurp "/Users/msszczep1/current_2011-01-2.txt") | |
(clojure.string/split-lines) | |
distinct) | |
points {\A 1 \B 3 \C 3 \D 2 \E 1 \F 4 \G 2 \H 4 \I 1 \J 8 \K 5 \L 1 \M 3 | |
\N 1 \O 1 \P 3 \Q 10 \R 1 \S 1 \T 1 \U 1 \V 4 \W 4 \X 8 \Y 4 \Z 10 \- 0 \' 0} | |
scores (map #(reduce + (map points (seq %))) surnames)] | |
(->> (zipmap surnames scores) | |
(sort-by val) |
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
CloudDeploy[FormFunction[{"article" -> "String"},Show[WordCloud[DeleteStopwords[WikipediaData[#article]], ImageSize -> Large]] &, | |
"GIF", AppearanceRules -> <|"Title" -> "Wikipedia Wordcloud", "Description" -> "Type in the name of a Wikipedia article | |
and get a word cloud of the article."|>, FormTheme -> "Blue" ], Permissions->"Public"] | |
https://www.wolframcloud.com/objects/f7615524-b20b-4427-b4fa-ac4dec8dd651 |
OlderNewer