Skip to content

Instantly share code, notes, and snippets.

View mpenet's full-sized avatar
🪲
breeding bugs

Max Penet mpenet

🪲
breeding bugs
View GitHub Profile
@pyrtsa
pyrtsa / http-kit-vs-reason-phrase.clj
Created March 10, 2014 09:43
HTTP Kit still fails to handle empty Reason-Phrase in HTTP responses
(import 'org.httpkit.client.Decoder)
(import 'java.nio.ByteBuffer)
(.decode (Decoder. nil nil) (ByteBuffer/wrap (.getBytes "HTTP/1.1 200 \r\n" "UTF-8")))
;;=> ProtocolException not http protocol? HTTP/1.1 200 org.httpkit.client.Decoder.parseInitialLine (Decoder.java:77)
(pst)
;;; ProtocolException not http protocol? HTTP/1.1 200
;;; org.httpkit.client.Decoder.parseInitialLine (Decoder.java:77)
;;; org.httpkit.client.Decoder.decode (Decoder.java:88)
@maxlapshin
maxlapshin / setup_lager_logging.erl
Created November 26, 2013 12:22
How we configure lager for logging
setup_lager_logging() ->
application:load(lager),
ConsoleFormat = [time, " ", pid, {pid, [" "], ""},
{module, [module, ":", line, " "], ""},
message, "\n"
],
FileFormat = [date, " "] ++ ConsoleFormat,
LogDir = os:getenv("LOGDIR"),
@danneu
danneu / 1-codec.clj
Created November 10, 2013 11:58
a rough implementation/dump of the bitcoin wire protocol (codec.clj) and some usage examples (chan.clj). https://github.com/ztellman/gloss/issues/27
(ns blockdude.codec
(:require [clojure.string :as str]
[gloss.core :as gloss-core :refer :all
:exclude [byte-count]]
[blockdude.hash :as hash]
[blockdude.util :refer :all]
[gloss.core.codecs :refer [identity-codec]]
[gloss.io :refer :all
:exclude [contiguous decode encode]])
(:import [java.lang Character]
<!doctype html>
<html>
<head>
<style>
@-webkit-keyframes relocate {
0% { top:16px; }
50% { top: 64px; }
100% { top: 16px; }
}
video{
# coding=UTF-8
import nltk
from nltk.corpus import brown
# This is a fast and simple noun phrase extractor (based on NLTK)
# Feel free to use it, just keep a link back to this post
# http://thetokenizer.com/2013/05/09/efficient-way-to-extract-the-main-topics-of-a-sentence/
# Create by Shlomi Babluki
# May, 2013
(ns create-draw.opencv
(:import
org.opencv.core.Core
org.opencv.core.Mat
org.opencv.core.MatOfRect
org.opencv.core.Point
org.opencv.core.Rect
org.opencv.core.Scalar
org.opencv.highgui.Highgui
org.opencv.objdetect.CascadeClassifier))
@daveray
daveray / astyanax-clj.clj
Last active December 16, 2015 16:40
astyanax clojure binding docs
; will open source in the near future. feedback/questions welcome.
(ns com.netflix.astyanax
"Clojure bindings for Cassandra via Astyanax
# Serializers
Serializer, when used in schemas (see below) are typically specified with a keyword.
The following are available, corresponding to the Astyanax serializers of the same
name:
:ascii, :big-integer, :boolean, :bytes, :char, :date, :double, :float, :integer
@frenchy64
frenchy64 / kw.clj
Created April 11, 2013 16:02
core.typed keyword parameters
(ns clojure.core.typed.test.kw-args
(:require [clojure.core.typed :refer [ann check-ns ann-form cf]]
[clojure.tools.analyzer :refer [ast]]
[clojure.tools.analyzer.emit-form :refer [emit-form]]))
(ann foo-kw [& {:a Number} -> (U nil Number)])
(defn foo-kw [& {:keys [a]}]
(when a
(inc a)))
@joelittlejohn
joelittlejohn / find-unused-clj.sh
Last active November 6, 2020 16:56
Very quick and dirty command to find unused functions and vars in a Clojure project
#!/bin/bash
for f in $(egrep -o -R "defn?-? [^ ]*" * --include '*.clj' | cut -d \ -f 2 | sort | uniq); do
echo $f $(grep -R --include '*.clj' -- "$f" * | wc -l);
done | grep " 1$"
(ns net.cgrand.decay
"Exponentially decaying lists. See http://awelonblue.wordpress.com/2013/01/24/exponential-decay-of-history-improved/
for background and http://clj-me.cgrand.net/2013/02/12/decaying-lists-log-scale-for-lists/ for documentation")
;; PRNG, formulas straight from java.util.Random javadoc
(defn- seed ^long [^long n]
(bit-and (unchecked-multiply n 0x5DEECE66D)
(unchecked-dec (bit-shift-left 1 48))))
(defn- next-seed ^long [^long seed]