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
# vi: set ft=ruby : | |
VAGRANTFILE_API_VERSION = "2" | |
$script = <<SCRIPT | |
apt-get install -y git maven openjdk-7-jdk | |
( | |
cd /usr/local/bin | |
wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein -O lein | |
chmod +x lein | |
) |
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- send-udp [s port] | |
(with-open [socket (java.net.DatagramSocket.)] | |
(let [group (java.net.InetAddress/getByName "localhost") | |
bytes (.getBytes s) | |
packet (java.net.DatagramPacket. bytes (count bytes) group port)] | |
(.send socket packet) | |
(.close socket)))) | |
(deftask anybar [p port VAL int "AnyBar port"] | |
(let [port (or port 1738)] |
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
#! /usr/bin/env racket | |
; Euler problem #1. Sum of integers between 1 and N which are | |
; divisible by i, j, k, ..., or l. | |
; | |
; The sum 1+2+3+...+n = (n^2 + n)/2, call this sum-range(n). | |
; | |
; Then the sum of i+2i+3i+...+qi = i * sum-range(floor(n/i)), where | |
; qi is the greatest multiple of i such that i <= n. | |
; |
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
(load-file "./watch_service.clj") | |
(refer 'watch-service) | |
(defn print-ev | |
[ev ctx] | |
(println "[foo]" ev " --> " ctx) | |
(println "Parent Dir:" (.getParent ctx))) | |
(defn print-ev-2 | |
[ev ctx] |
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
#!/bin/bash | |
wholefile=$(cat $1) | |
filelen=${#wholefile} | |
idx=0 | |
chunk=0 | |
chunksz=500 | |
while true; do | |
if (( ${#str} < ( chunksz / 2) )) && (( chunk < filelen )); then |
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
;; Simple example of MQTT message publish using Common Lisp and ABCL | |
;; | |
;; Uses the Eclipse Paho client | |
;; | |
;; Author: Frederico Munoz <frederico.munoz@pt.ibm.com> | |
;; Date: 22-Jun-2013 | |
;; Keywords: mqtt, messaging, m2m, telemetry, abcl, iot, paho, lisp | |
;; | |
;; Copying and distribution of this file, with or without modification, | |
;; are permitted in any medium without royalty provided the copyright |
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
#' R implementation of `cond` from Lisp | |
#' allows for arbitrary numbers of conditionals without ugly nested if statements | |
#' conditionals are entered as pairs of expressions (clauses), | |
#' first the expression to be evaluated and second the return value if the expression is true | |
#' @param ... an even number of expressions as pairs (see example) | |
#' @param true the `else` expression (Taken from the Lisp (T resultN) see http://www.cis.upenn.edu/~matuszek/LispText/lisp-cond.html) | |
#' @return The paired value of the first true conditional expression or the value of true | |
#' @examples | |
#' x <- runif(1) | |
#' cond(x < 0.2, "lower tail", |
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
namespace Graph | |
// Implementation based on https://gist.github.com/alandipert/1263783 | |
module Map = | |
let keys map = | |
map |> Map.toSeq |> Seq.map fst |> Set.ofSeq | |
let values map = | |
map |> Map.toSeq |> Seq.map snd |> Set.ofSeq |
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
library(curl) | |
library(httpuv) | |
req_rook_to_curl <- function(req, host) { | |
# browser() | |
# Rename headers. Example: HTTP_CACHE_CONTROL => Cache-Control | |
r <- as.list(req) | |
# Uncomment to print out request headers | |
cat("== Original ==\n") |
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
# Check Package Size | |
# | |
# Thanks to Alan Dipert for the help with this one. | |
# | |
# This function is used to calculate size of package and report size in | |
# README.md | |
pkg_size <- function(package) { | |
root <- find.package(package) | |
rel_paths <- list.files(root, all.files = TRUE, recursive = TRUE) | |
abs_paths <- file.path(root, rel_paths) |
OlderNewer