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 '[paprika.core] :as adn) | |
;; Assume t is your access token. | |
(def at {:access-token t}) | |
;; The simple case allows the first argument to be a string. | |
(adn/create-post "This is a test" at) | |
;; For every other case, pass in a map. | |
(adn/create-post {:text "This is a test" :reply-to "123"} at) |
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
;; Straighforward | |
(defn handle-helo | |
[session command] | |
[(-> session | |
(reset-session) | |
(assoc :client-host (:domain command))) | |
{:code 250 :text (:server-host session)}]) | |
;; State monad style | |
;; Not sure if command needs to be closed over, though. |
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 get-line | |
[reader] | |
(loop [last-cr? false line (StringBuilder.)] | |
(let [i (.read reader)] | |
(if (neg? i) | |
(str line) | |
(let [c (char i)] | |
(if (and last-cr? (= c \newline)) | |
(.substring line 0 (dec (.length line))) | |
(recur (= c \return) (.append line c)))))))) |
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
package main | |
import "code.google.com/p/go-tour/tree" | |
import "fmt" | |
func Walk2(t *tree.Tree, ch chan int) { | |
if t.Left != nil { | |
Walk2(t.Left, ch) | |
} | |
ch <- t.Value |
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
#include <stdio.h> | |
#include <errno.h> | |
int main(int argc, char **argv) | |
{ | |
if (argc == 1) return 0; | |
if (argc == 2) { | |
char *filename = argv[1]; | |
FILE *fp = fopen(filename, "r"); | |
if (!fp) { |
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
#include <string.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define BUFFER_SIZE 5 | |
struct reqdata | |
{ | |
char *data; | |
size_t len; |
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
; Missionaries and Cannibals | |
;------------------------------------------------------------------------------- | |
; main method | |
( defmethod mc () | |
( establish-operators ) | |
( setup ) | |
( solve ) | |
) |
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 apply (f arr) | |
`(f ~@arr)) | |
(apply str ["foo" "bar" "baz"]) | |
;; macroexpands to: | |
(str "foo" "bar" "baz") |
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
;; javascripty | |
(var foo 42) | |
(var inc (function (x) (+ x 1))) | |
(function dec (x) (- x 1)) | |
;; clojurey | |
(def foo 42) | |
(def inc (fn [x] (x + 1))) | |
(defn dec [x] (- x 1)) |
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 foo = bar = 42; | |
{ | |
"type": "Program", | |
"body": [ | |
{ | |
"type": "VariableDeclaration", | |
"declarations": [ | |
{ | |
"type": "VariableDeclarator", | |
"id": { |