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
(ns proc | |
(:import [java.lang ProcessBuilder]) | |
(:use [clojure.java.io :only [reader writer]])) | |
(defn spawn [& args] | |
(let [process (-> (ProcessBuilder. args) | |
(.start))] | |
{:out (-> process | |
(.getInputStream) | |
(reader)) |
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
# Clojure syntax highlighting for GNU source-highlight | |
# rocks with SHJS | |
comment start ";" | |
include "number.lang" | |
vardef SPECIALCHAR = '\\.' | |
environment string delim "\"" "\"" begin |
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
import time | |
import socket | |
def collect_metric(name, value, timestamp): | |
sock = socket.socket() | |
sock.connect( ("localhost", 2003) ) | |
sock.send("%s %d %d\n" % (name, value, timestamp)) | |
sock.close() | |
def now(): | |
return int(time.time()) |
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
(ns clj-client.core | |
(import [java.net Socket] | |
[java.io PrintWriter])) | |
(defn now [] | |
(int (/ (System/currentTimeMillis) 1000))) | |
(defn write-metric [name value timestamp] | |
(with-open [socket (Socket. "localhost" 2003) | |
os (.getOutputStream socket)] |
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
import sys | |
import signal | |
from threading import Thread | |
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler | |
class PUTHandler(BaseHTTPRequestHandler): | |
def do_PUT(self): | |
print "----- SOMETHING WAS PUT!! ------" | |
print self.headers | |
length = int(self.headers['Content-Length']) |
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
(ns bogus.core | |
(import java.util.Date) | |
(import java.net.Socket) | |
(import java.io.PrintWriter)) | |
(def metric "bogus.metric") | |
(defonce power (atom 0)) | |
(defn pow! [] | |
(swap! power 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
(ns challange.test.core | |
(:use [challange.core] :reload) | |
(:use [midje.sweet])) | |
(fact | |
(solve "AA" ["A"]) => "" | |
(solve "ABA" ["A" "B"]) => "" | |
(solve "AB" ["A" "X"]) => "B") | |
(fact |
NewerOlder