Skip to content

Instantly share code, notes, and snippets.

View bradclawsie's full-sized avatar

Brad Clawsie bradclawsie

View GitHub Profile
@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:

Keybase proof

I hereby claim:

  • I am bradclawsie on github.
  • I am b7j0c (https://keybase.io/b7j0c) on keybase.
  • I have a public key whose fingerprint is B1C1 F146 2CE7 6E5F 2D99 4FB3 D817 E42D CCB5 AB08

To claim this, I am signing this object:

@bradclawsie
bradclawsie / correct.go
Last active January 26, 2017 03:27
curious correct Go program
package main
import (
"fmt"
"time"
)
func main() {
c := make(chan struct{},1)
go func() {
@bradclawsie
bradclawsie / imapbiff.pl
Created December 5, 2010 06:35
imap biff in perl
#!/usr/bin/env perl
use Net::IMAP::Simple::SSL;
$| = 1;
my $server = 'imap.gmail.com';
my $user = 'YOU@gmail.com';
my $pass = 'PASSWORD';
my $imap = Net::IMAP::Simple::SSL->new($server);
$imap->login($user => $pass) || die "cannot connect";
my $messages = $imap->select('Inbox');
my $count = 0;
@bradclawsie
bradclawsie / panic.go
Created September 12, 2016 04:06
panic.go
package main
import (
"errors"
"log"
)
func final() {
log.Printf("cleaning up")
if c := recover(); c != nil {
@bradclawsie
bradclawsie / httpdshutdown_example.go
Created January 31, 2016 22:05
httpdshutdown_example.go
package main
import (
"log"
"net"
"net/http"
"github.com/bradclawsie/httpdshutdown"
"os"
"os/signal"
"time"
)
@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 / 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 / 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
}