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
package tbl3rd.provider; | |
import tbl3rd.provider.Api_2015_04_01; | |
import tbl3rd.provider.Api_2015_04_01.NetworkInformation; | |
import java.io.BufferedWriter; | |
import java.io.File; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.OutputStreamWriter; |
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
package tbl3rd.provider; | |
import tbl3rd.provider.Api_2015_04_01; | |
import tbl3rd.provider.Api_2015_04_01.NetworkInformation; | |
import java.io.BufferedReader; | |
import java.io.BufferedWriter; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.IOException; |
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
package tbl3rd.provider; | |
import tbl3rd.provider.Api_2015_04_01; | |
import java.io.IOException; | |
import java.net.Inet4Address; | |
import java.net.InetAddress; | |
import java.net.NetworkInterface; | |
import java.net.UnknownHostException; | |
import java.nio.ByteBuffer; |
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
#ifndef COMPLEX_MAT_H_INCLUDED | |
#define COMPLEX_MAT_H_INCLUDED | |
#include <opencv2/core/core.hpp> | |
// Because C++ forbids std::complex<cv::Mat> for who knows what reason ... | |
// | |
// ComplexMat and CompExpMat are just two suggestive names for the same | |
// type. ComplexMat has real and imaginary parts. ComplexExp has cosine |
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 kerry) | |
(defn make-rand-x-to-y | |
"A function that uses rand-x to generate rand-y, | |
where (rand-n) has the integer range [0, n)." | |
[x y] | |
(let [randx (fn [] (rand-int x)) | |
size (* x y) | |
choices (into [] (take size (cycle (range y))))] | |
(fn [] |
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
/* Write at result the hardware (MAC) address of the network interface name. | |
Return -1 on failure or 0 on success. | |
*/ | |
static int macForInterface(const char *name, struct sockaddr *result) | |
#ifdef __APPLE__ | |
{ | |
int failed = -1; | |
struct ifaddrs *ifap = NULL; | |
if (0 == getifaddrs(&ifap)) { | |
struct ifaddrs *p = ifap; |
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
#!/bin/bash | |
# This script is designed to make sure that a signal delivered to it | |
# is propagated to a subshell running the program feeding the lines to | |
# be timestamped. The usual command line is: | |
# | |
# timestamp command ... arguments ... | |
# The 'builtin' specifications are not necessary, but are included to | |
# convey that what follows them are internal shell commands, so bash |
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
(defn call-periodically-when-visible | |
"Call f with args every ms milliseconds when document is visible." | |
([ms f] | |
(letfn [(call [id] | |
(let [id (if (.-hidden js/document) | |
(and id (js/clearInterval id) nil) | |
(js/setInterval f ms))] | |
(goog.events/listenOnce | |
js/document "visibilitychange" #(call id))))] | |
(call nil))) |
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
(defn drop-nth-tbl3rd | |
"coll with every nth element removed" | |
[n coll] | |
(letfn [(drop-when [coll drops] | |
(lazy-seq | |
(when-let [s (seq coll)] | |
(let [more (drop-when (rest s) (rest drops))] | |
(if (first drops) more (cons (first s) more))))))] | |
(drop-when coll (rest (cycle (cons true (repeat (dec n) false))))))) |
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 responder.core | |
(:import [com.google.common.collect ImmutableMap$Builder])) | |
(def responses | |
(letfn [(+ [& lines] (clojure.string/join " " lines))] | |
(-> (new ImmutableMap$Builder) | |
(. put "weather" (+ "There is an 80% chance of rain this afternoon." | |
"The high will be 8 and the low 2.")) | |
(. put "window" "Sensors indicate that all windows are closed.") | |
(. put "heat" "Your thermostat is currently set to 20.") |