This file contains hidden or 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
| -module(twitter_stream). | |
| -author("gdamjan@gmail.com"). | |
| %% Depends on: | |
| %% ibrowse for http | |
| %% couchbeam for couchbeam_json_stream (a fork of damienkatz json_stream_parse) | |
| %% mochiweb for mochiweb_util:urlencode | |
| -export([start/0]). |
This file contains hidden or 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
| Solution without PowerMock | |
| -- | |
| import ch.qos.logback.classic.*; | |
| import ch.qos.logback.classic.spi.LoggingEvent; | |
| import ch.qos.logback.core.Appender; | |
| import org.junit.*; | |
| import org.junit.runner.RunWith; | |
| import org.mockito.*; | |
| import org.mockito.runners.MockitoJUnitRunner; |
This file contains hidden or 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
| ;Print "Hi" every 2 seconds: | |
| (defn t [] | |
| (go (loop [] (<! (timeout 2000)) (prn "hi") (recur)))) | |
| ;or as a macro |
This file contains hidden or 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
| Scenario: Repost a 3D Post | |
| Given there is user A | |
| And there is user B following user A | |
| And there is user C following user B | |
| And there is user D following user A and B | |
| And user A posted a photo P1 | |
| And user A posted a 3D photo P2 | |
| When user B reposted P2 as P3 | |
| Then the feeds should be like: | |
| | feed | of | count | contains | because | |
This file contains hidden or 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
| checkbox :: Bool -> IO (Elem, Signal Bool) | |
| checkbox checked = do | |
| c <- newElem "input" | |
| (p,s) <- emptyPipe | |
| setProp c "type" "checkbox" | |
| sink (\isChecked -> do | |
| setProp c "checked" $ if isChecked then "true" else "" | |
| ) s | |
| setCallback c OnChange (do | |
| checked <- getProp c "checked" |
This file contains hidden or 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
| 1) make sure you actually HAVE postgres AND postgis AND plsql! | |
| 2) enable postgis extension (may be in a different path or already coming from your distribution) | |
| psql -U YOURUSER -d YOURDB -f /usr/share/postgresql/contrib/postgis-2.0/postgis.sql | |
| or, on psql shell: | |
| CREATE extension postgis; |
This file contains hidden or 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 test-core-typed.core | |
| (:import (clojure.lang Symbol)) | |
| (:require [clojure.core.typed :refer [ann]])) | |
| (ann foo-bar [Symbol -> Number]) | |
| (defn foo-bar [a] | |
| (+ a 1)) | |
| (ann barbar [Number -> Boolean]) | |
| (defn barbar [a] |
This file contains hidden or 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 tokenring.core | |
| (:require [lamina.core :as lamina]) | |
| (:require [aleph.tcp :as aleph]) | |
| (:require [gloss.core :as gloss])) | |
| (defn connect-and-send [message] | |
| (println (str "connecting and sending: " message)) | |
| (let [ch (lamina/wait-for-result | |
| (aleph/tcp-client {:host "192.168.48.35" | |
| ;;:host "localhost" |
This file contains hidden or 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
| ;; by John Lawrence Aspden - http://www.learningclojure.com/2013/04/destructuring.html | |
| ;; Destructuring | |
| ;; One of Clojure's great strengths is the ability to create maps ad-hoc and to deal with them easily. | |
| ;; You can create an ad-hoc structure with named fields: | |
| {:a 3 :b 1} | |
| ;; And unpack it, providing defaults for its values if they are not present, as easily as: |
This file contains hidden or 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
| /* | |
| * Dependencies: Apache POI Library from http://poi.apache.org/ | |
| */ | |
| package poi_excels; | |
| import java.io.FileInputStream; | |
| import java.io.FileNotFoundException; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.util.logging.Level; |