Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am bringhurst on github.
  • I am jb (https://keybase.io/jb) on keybase.
  • I have a public key ASDzNeeb8DY80qzaN_B8e46sTNQqeIUXwml0d1jjZHzLBQo

To claim this, I am signing this object:

@bringhurst
bringhurst / hello-softmax.py
Created January 25, 2016 00:35
my first attempt at softmax
def softmax(x):
"""Compute softmax values for each sets of scores in x."""
exps = np.exp(x)
total_exp = reduce(operator.add, exps, 0)
return np.array([(i / total_exp) for i in exps])
@bringhurst
bringhurst / log4j.xml
Created August 6, 2015 16:53
An example of using the KafkaLog4jAppender with the JSONEventLayoutV1 for logstash/elasticsearch
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
<log4j:configuration>
<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
</layout>
</appender>
<appender name="KAFKA" class="kafka.producer.KafkaLog4jAppender">
@bringhurst
bringhurst / dcp-handle-remainder
Created November 5, 2014 19:15
dcp handle remainder
} elif( last_argument_is_directory ) {
set_base(last_argument)
for(src in srcs) {
push_work_queue(src.path)
}
} else {
error(unsupported_filetype);
}
@bringhurst
bringhurst / dcp-last-argument-is-file
Created November 5, 2014 19:14
dcp last argument is file
if( last_argument_is_file ) {
if( number_of_source_files == 1 &amp;&amp; is_file(src_path) ) {
set_base(basename_of_last_argument)
push_work_queue(src_path);
} else {
error(impossible_condition)
}
@bringhurst
bringhurst / dcp-check-recursion
Created November 5, 2014 19:13
dcp check recursion
} else {
if(allow_recursion) {
last_argument_is_file = true
for(src in srcs) {
if (is_dir(src)) {
last_argument_is_file = false
}
}
@bringhurst
bringhurst / dcp-exists-at-dest
Created November 5, 2014 19:11
dcp exists at dest
if(is_file(last_argument) {
last_argument_is_file = true
last_argument_is_dir = false
} elif( is_dir(last_argument) {
last_argument_is_dir = true
last_argument_is_file = false
@bringhurst
bringhurst / dcp-usage
Last active August 29, 2015 14:08
dcp usage
usage: dcp [CdfhpRrv] [--] source_file target_file
dcp [CdfhpRrv] [--] source_file ... target_directory

Keybase proof

I hereby claim:

  • I am bringhurst on github.
  • I am jb (https://keybase.io/jb) on keybase.
  • I have a public key whose fingerprint is 4192 5CFF 336D 6AC3 542F B17A 2AE2 B5FF 997E 5899

To claim this, I am signing this object:

@bringhurst
bringhurst / CipherTest.java
Created August 20, 2013 16:23
A basic sanity test of the local AES key length.
import javax.crypto.Cipher;
class CipherTest {
public static void main(String args[]) {
try {
int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES");
if(maxKeyLen < 256) {
System.out.println("FAILED: Max key length too small! (" + maxKeyLen + ").");
} else {
System.out.println("PASSED: Max key length OK! (" + maxKeyLen + ").");
}