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 instant-avg [nums] | |
[(apply + nums) | |
(/ (float (apply + nums)) (count nums)) | |
(count nums)]) | |
;; assumes nums is a vector of integers |
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
// https://www.facebook.com/WondersofEngineering/photos/a.255298751271223.61509.255293124605119/701667366634357/?type=3&theater | |
Coffee coffee = new Coffee(); | |
if (coffee.Empty) { | |
coffee.Refill(); | |
} else { | |
coffee.Drink(); | |
} | |
;; I can rewrite it in Clojure in two lines: |
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 subanagram-generator [submitted-word] | |
(let [words (->> (slurp "/Users/msszczep1/Scripts/npr_puzzle_scripts/ni2.txt") | |
(clojure.string/split-lines)) | |
submitted-word-freqs (merge | |
(zipmap "abcdefghijklmnopqrstuvwxyz" (repeat 26 0)) | |
(frequencies (clojure.string/lower-case submitted-word)))] | |
(->> words | |
(filter (fn [word] | |
(let [lc-word (clojure.string/lower-case word)] | |
(every? #(<= ((frequencies lc-word) %) |
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
(->> (slurp "ni2.txt") | |
clojure.string/split-lines | |
(map clojure.string/lower-case) | |
(map #(map char %)) | |
flatten | |
frequencies | |
(map #(vector (key %) | |
(read-string | |
(format "%.2f" (* 100 (/ (val %) 2251877.0)))))) | |
(sort-by last) |
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
for (i=0; i< 2; i++) { | |
if (i == 0) {printf "naming";} | |
if (i == 1) {invalidate_cache;} | |
if (i == 2) {printf "off by 1 error";} | |
} |
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> | |
<head> | |
<script type='text/javascript' src='https://www.google.com/jsapi'></script> | |
<script type='text/javascript'> | |
google.load('visualization', '1', {'packages': ['geochart']}); | |
google.setOnLoadCallback(drawMarkersMap); | |
function drawMarkersMap() { | |
var data = google.visualization.arrayToDataTable([ | |
['City', 'Time', 'Size'], |
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
#!/usr/bin/python | |
# Source: http://ubuntuforums.org/showthread.php?t=1215158 | |
import urllib2 | |
import sys | |
from BeautifulSoup import BeautifulSoup | |
file = sys.argv[1] | |
# assumes file is a list of valid URLs, one URL per line |
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[APIFunction[{"p" -> "String"}, DateString[Interpreter["Person"][#p]["DeathDate"], {"MonthName", " ", "DayShort", ", ", "Year"}] &]] | |
-- e.g., https://www.wolframcloud.com/objects/29dd4c7b-77f3-49ff-84be-fc557ddfc9a0?p=Michael+Jackson | |
-- https://www.wolframcloud.com/objects/fa2cf38e-b000-4762-b249-8d19bfaef1a0?p=Doris+Day | |
CloudDeploy[APIFunction[{"p" -> "String"}, Which[ | |
FailureQ[Interpreter["Person"][#p]], | |
"I'm sorry, but I cannot determine that.", | |
MissingQ[Interpreter["Person"][#p]["DeathDate"]], | |
StringJoin[#p, " is still alive, and is ", ToString[Floor[DateDifference[Interpreter["Person"][#p]["BirthDate"], Now, "Year"]]], " old." ], |
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[WordCloud[Flatten[TextCases[StringCases[URLFetch["www.nytimes.com"], Shortest["<p class=\"summary\" ~~ x__ ~~ "</p>"] -> x], "Noun"]]]] | |
https://www.wolframcloud.com/objects/aad30d4c-cce8-45c2-b0c3-afa03f606f64 |
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
Round {question: {}, responses: []} // initial state | |
Actions Actions {answerQuestion(choice) advanceQuestion()} | |
Redux Act |