Skip to content

Instantly share code, notes, and snippets.

@takscape
takscape / gist:4736182
Created February 8, 2013 02:38
Splunk settings for LTSV
# props.conf
[ltsv]
NO_BINARY_CHECK = 1
SHOULD_LINEMERGE = false
REPORT-ltsv = ltsv-extractions
TIME_FORMAT=%d/%b/%Y:%H:%M:%S %z
TIME_PREFIX=time:
# transforms.conf
[ltsv-extractions]
@takscape
takscape / gist:5056279
Created February 28, 2013 12:01
libnids, printall.c
static struct nids_chksum_ctl chksum_ctl;
int
main ()
{
chksum_ctl.netaddr = 0;
chksum_ctl.mask = 0;
chksum_ctl.action = NIDS_DONT_CHKSUM;
nids_register_chksum_ctl(&chksum_ctl, 1);
@takscape
takscape / gist:5083554
Created March 4, 2013 16:36
Bro script for extracting all TCP stream contents.
@load base/utils/files
global conn_files: table[string] of file &synchronized;
redef tcp_content_deliver_all_orig = T;
redef tcp_content_deliver_all_resp = T;
event tcp_contents(c: connection, is_orig: bool, seq: count, contents: string)
{
local fname: string;
@takscape
takscape / gist:7067373
Last active December 26, 2015 00:49
Stream.fromを無理やり使ったフィボナッチ数列
open Core.Std
let rec fib () =
let tmp = ref (0, 1) in
let fib_next n =
match !tmp with
| (cur, next) -> begin
tmp := (next, cur+next);
Some cur
end
@takscape
takscape / gist:3328a99227ab73c8221b
Last active August 29, 2015 14:01
Quick workaround for vim-ocp-index on Wodi environment
" ocp-index support for vim
" Maintainer: INAJIMA Daisuke <[email protected]>
" Version: 0.1
let s:ocaml_lib_dir = ""
let s:jump_history = []
let s:max_jump_history = 100
function! ocpindex#init()
@takscape
takscape / gist:96d154b022176455be3c
Created September 4, 2014 11:13
ocamlscript with inline unit tests
#!/usr/bin/env ocamlscript
Ocaml.ocamlflags := ["-g"; "-thread"];
Ocaml.ppopt := ["-pa-ounit-lib"; "fibo"];
Ocaml.packs := ["core"; "cfstream"; "num"; "pa_ounit.syntax"]
--
open Core.Std
open CFStream
let fibo_stream () =
@takscape
takscape / gist:df9925d0f18b2942feb2
Created September 13, 2014 02:52
Parsing with Sedlex and BatParserCo
#!/usr/bin/env ocamlscript
Ocaml.ocamlflags := ["-g"; "-thread"];
Ocaml.use_camlp4 := false;
Ocaml.packs := ["batteries"; "sedlex"]
--
open Batteries
(* Sedlex lexer definitions *)
type token =
| Number of int
defmodule Foo do
use Pipe
def maybe({:ok, val}, f), do: f.(val)
def maybe({:bad, _} = lhs, f), do: lhs
def maybe(_, _), do: raise ArgumentError
def dec(num) do
if num > 0 do
{:ok, num-1}
@takscape
takscape / gist:957ca588251bf1f64c77
Created October 31, 2014 19:19
Fibonacci Sequence in Kotlin
import java.math.BigInteger
import kotlin.math.plus
fun main(args: Array<String>) {
fibo().take(10).forEach { println(it) }
}
private fun fibo() : FunctionStream<BigInteger> {
var cur = BigInteger.ZERO
var next = BigInteger.ONE
@takscape
takscape / gist:8147e068a554d3ad537b
Created October 31, 2014 19:27
Fibonacci Sequence in Kotlin (2)
import java.math.BigInteger
import kotlin.math.plus
fun main(args: Array<String>) {
fibo().take(10).forEach { println(it) }
}
data class FiboEntry(val cur : BigInteger, val next : BigInteger)
private fun fibo() : FunctionStream<BigInteger> {
var tmp = FiboEntry(BigInteger.ZERO, BigInteger.ONE)