Skip to content

Instantly share code, notes, and snippets.

View bradclawsie's full-sized avatar

Brad Clawsie bradclawsie

View GitHub Profile
@bradclawsie
bradclawsie / keybase.md
Created March 6, 2014 17:24
keybase.md

Keybase proof

I hereby claim:

  • I am bradclawsie on github.
  • I am bradclawsie (https://keybase.io/bradclawsie) on keybase.
  • I have a public key whose fingerprint is A241 EE39 764B 3F6B 7B8C F45D C518 3746 444A F753

To claim this, I am signing this object:

@bradclawsie
bradclawsie / go_tls_server_conf.go
Created March 6, 2014 05:55
A sample tls server configuration that scored reasonably well on the Qualys SSL test.
srv := &http.Server{
Addr: ":443",
TLSConfig: &tls.Config{
CipherSuites: []uint16{
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
@bradclawsie
bradclawsie / wordchain.cpp
Last active January 4, 2016 05:19
word chain solver
// g++ -g -Wall -Werror -Wextra -pedantic -pedantic-errors -std=c++11 -g -O2 -c wordchain.cpp
// g++ -o wordchain wordchain.o
// example: wordchain cause north
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <climits>
#include <memory>
package org.b7j0c.puzzles;
// http://programmingpraxis.com/2013/11/15/twitter-puddle/
public final class Puddles {
public static void main(String[] args) {
int[] c = {2,5,1,2,3,4,7,7,6,1,1,9,8,8,9,1,1};
int cl = c.length;
int w = -1;
int sub = 0;
@bradclawsie
bradclawsie / honeycomb.java
Created December 4, 2013 06:31
a java solution to the "honeycomb" puzzle
package org.b7j0c.puzzles;
import java.util.EnumMap;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
// the Hex class represents an id with six neighbors. the orientation of the neighbors is irrelevant
// but it is useful to describe them with compass directions as such:
@bradclawsie
bradclawsie / better.go
Created June 5, 2013 05:41
this type can be serialized to json so that uninitialized optional fields are null
type Foo struct {
MandatoryString string
OptionalUInt64 NullableUInt64
OptionalString NullableString
}
@bradclawsie
bradclawsie / nullables.go
Created June 5, 2013 05:37
some "nullable" base types for go
type NullableString string
func (n NullableString) MarshalJSON() ([]byte, error) {
sn := string(n)
if sn == "" {
var i interface{}
return json.Marshal(i)
}
return json.Marshal(sn)
}
@bradclawsie
bradclawsie / accepted.json
Created June 5, 2013 05:26
a json structure that accepts some data as optional
{ "MandatoryString":"somestring", "OptionalUInt64":1, "OptionalString":"anotherstring" }
{ "MandatoryString":"somestring", "OptionalUInt64":1, "OptionalString":null }
{ "MandatoryString":"somestring", "OptionalUInt64":null, "OptionalString":"anotherstring" }
{ "MandatoryString":"somestring", "OptionalUInt64":null, "OptionalString":null }
{ "MandatoryString":"somestring", "OptionalUInt64":1 }
@bradclawsie
bradclawsie / naive_struct.go
Created June 5, 2013 05:22
naive attempt at matching json
type Foo struct {
MandatoryString string
OptionalUInt64 uint64
OptionalString string
}
;; blog.jazzychad.net/2012/08/01/array-iteration-problem.html
(use srfi-1)
(: f ((list-of number) number number -> (list-of number)))
(define f
(lambda (arr n i)
(cond [(< n 0)
;; if we are going right-to-left, reverse the list and use the abs count
(reverse (f (reverse arr) (abs n) i))]