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
<body> | |
<script> | |
var colors = ["#F7977A","#F9AD81","#FDC68A","#FFF79A","#C4DF9B","#A2D39C","#82CA9D","#7BCDC8","#6ECFF6","#7EA7D8","#8493CA","#8882BE","#A187BE","#BC8DBF","#F49AC2","#F6989D"]; | |
var i = 0; | |
setInterval(function(){ | |
i++ | |
if (i>=colors.length) { | |
i=0; | |
} |
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
<body> | |
<script src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js'></script> | |
<script> | |
var colors = ["#F7977A","#F9AD81","#FDC68A","#FFF79A","#C4DF9B","#A2D39C","#82CA9D","#7BCDC8","#6ECFF6","#7EA7D8","#8493CA","#8882BE","#A187BE","#BC8DBF","#F49AC2","#F6989D"]; | |
var i = 0; | |
setInterval(function(){ | |
i++ | |
if (i>=colors.length){ | |
i=0; |
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
var express = require('express'); | |
var app = express(); | |
app.get('/', function(req, res){ | |
res.send('hello world'); | |
}); | |
app.listen(3000); |
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
// problem 05 every some | |
/* | |
Return a function that takes a list of valid users, and returns a function that returns true | |
if all of the supplied users exist in the original list of users. | |
You only need to check that the ids match. | |
## Example | |
var goodUsers = [ |
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
(time | |
(dosync | |
(ensure newswire) | |
(ref-set ref2 {:titles (:titles @newswire) | |
:urls (:urls @newswire) | |
:sentiments (pmap #(find-sentiment (get-nyt-article-contents %)) (:urls @newswire))}))) |
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
; Rough implementation of Normalized Google Distance algorithm | |
; Assumed total number of indexed pages = 42,000,000,000 | |
(defn get-ngd | |
"Returns the normalized google distance of two searchable terms. Returns nil if no results available for either query, or if there is no overlap for either query. The closer the result trends to 0, the more closely 'related' the terms are." | |
[term1 term2] | |
(let [m 42000000000 | |
fx (Integer. (:totalResults (:searchInformation (google-search term1)))) | |
fy (Integer. (:totalResults (:searchInformation (google-search term2)))) | |
fxy (Integer. (:totalResults (:searchInformation (google-search (str term1 "+" term2))))) | |
ngdnumerator (- (max (math/log10 fx) (math/log10 fy)) (math/log10 fxy)) |
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 nlp | |
(let [props (new java.util.Properties)] | |
(.setProperty props "annotators" "tokenize,ssplit,parse,sentiment") | |
(new edu.stanford.nlp.pipeline.StanfordCoreNLP props))) | |
(defn find-sentiment | |
"Determines the sentiment of each sentence in a given glob of text. Results in a collection of integers ranging from [0-4]: where 0 is 'Very negative', 2 is 'neutral', and 4 is 'Very positive'" | |
[blob] | |
(let [glob (apply str blob)] | |
(let [main-sentiment 0 |
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 postfix-notation | |
"I'm too indie for prefix notation" | |
[expression] | |
(conj (butlast expression) (last expression))) |
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 iter-seq | |
"Takes a Scala iterable, and turns it into a lazy-seq" | |
[iter] | |
(lazy-seq | |
(when (.hasNext iter) | |
(cons (.next iter) | |
(iter-seq iter))))) | |
(defn iterable-seq | |
"Takes a Scala iterable s, and returns a lazy-seq of its contents." |
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 reverse-haversine | |
"Implementation of the reverse of Haversine formula. Takes one set of latitude/longitude as a start point, a bearing, and a distance, and returns the resultant lat/long pair." | |
[{lon :long lat :lat bearing :bearing distance :distance}] | |
(let [R 6378.137 ; Radius of Earth in km | |
lat1 (Math/toRadians lat) | |
lon1 (Math/toRadians lon) | |
angdist (/ distance R) | |
theta (Math/toRadians bearing) | |
lat2 (Math/toDegrees (Math/asin (+ (* (Math/sin lat1) (Math/cos angdist)) (* (Math/cos lat1) (Math/sin angdist) (Math/cos theta))))) | |
lon2 (Math/toDegrees (+ lon1 (Math/atan2 (* (Math/sin theta) (Math/sin angdist) (Math/cos lat1)) (- (Math/cos angdist) (* (Math/sin lat1) (Math/sin lat2))))))] |
OlderNewer