Skip to content

Instantly share code, notes, and snippets.

View miniharryc's full-sized avatar

Harold Combs miniharryc

View GitHub Profile
@miniharryc
miniharryc / gist:1481889
Created December 15, 2011 17:07
Yucky Java5 Syntax
Map<String,String> m = new HashMap<String,String>();
@miniharryc
miniharryc / gist:6143436
Created August 2, 2013 21:02
Go function for switching on which algorithm to use to compare equivalent hands
/**
* Rank equivalent hands based upon appropriate
* algorithms
*/
func rankEquivalentHands( h1, h2 *Hand ) *Hand {
switch h1.rank {
case STRAIGHT_FLUSH, STRAIGHT, HIGH_CARD, FLUSH: return rankHighCard(h1,h2)
case FOUR_OF_A_KIND: return rankFourOfAKind(h1,h2)
case FULL_HOUSE: return rankFullHouse(h1,h2)
case THREE_OF_A_KIND: return rankThreeOfAKind(h1,h2)
@miniharryc
miniharryc / gist:10489099
Created April 11, 2014 18:12
Show the math
require 'date'
birthdays_thus_far = 35
today = Date::today
birthday = Date.new(1978,11,9)
#to get 'unbirthdays', figure out total days then subtract all 'birthdays
# thus far
unbirthdays = (today - birthday - birthdays_thus_far).to_i
@miniharryc
miniharryc / keybase.md
Created September 27, 2014 03:13
keybase.md

Keybase proof

I hereby claim:

  • I am miniharryc on github.
  • I am harryc (https://keybase.io/harryc) on keybase.
  • I have a public key whose fingerprint is 6B71 37DA 9CA5 5FC0 72BF 6C10 52AC C3A1 7A0A B76B

To claim this, I am signing this object:

@miniharryc
miniharryc / quiz.c
Created December 18, 2014 14:55
Seth's Pop Quiz
#include <stdio.h>
int main (int argc, char** argv) {
int i = 5;
int j = 10;
while (--j) { printf("%d %d\n", i, j); } while (--i);
}
@miniharryc
miniharryc / quiz_unoptimized.asm
Created December 18, 2014 15:00
output of cc quiz.c (unoptimized)
(__TEXT,__text) section
_main:
0000000100000ef0 pushq %rbp
0000000100000ef1 movq %rsp, %rbp
0000000100000ef4 subq $0x20, %rsp
0000000100000ef8 movl $0x0, -0x4(%rbp)
0000000100000eff movl %edi, -0x8(%rbp)
0000000100000f02 movq %rsi, -0x10(%rbp)
0000000100000f06 movl $0x5, -0x14(%rbp)
0000000100000f0d movl $0xa, -0x18(%rbp)
@miniharryc
miniharryc / quiz_optimized.asm
Created December 18, 2014 15:08
Optimized quiz.c
a.out:
(__TEXT,__text) section
_main:
0000000100000ea0 pushq %rbp
0000000100000ea1 movq %rsp, %rbp
0000000100000ea4 pushq %rbx
0000000100000ea5 pushq %rax
0000000100000ea6 leaq 0xdd(%rip), %rbx
0000000100000ead movl $0x5, %esi
0000000100000eb2 movl $0x9, %edx
@miniharryc
miniharryc / decide.txt
Created July 27, 2015 20:58
One way to make a technical decision...
"So, why'd we choose technology 'X'?"
"Look, we can do this the easy way or the hard way. We can go through a drawn-out,
two-week process and finally decide to use 'X'. Or, we can just use 'X'."
@miniharryc
miniharryc / .zshrc
Last active February 1, 2016 19:36
Getting the local docker-machine IP to add to no_proxy
#
# This is the (brute force) way I'd thought to do it
eval "$(docker-machine env default)"
# get the IP address of our docker-machine,
# so we can add it to no_proxy below
DOCKER_IP=$(echo $DOCKER_HOST | sed 's#tcp://##' | sed 's#:.*##')
export no_proxy=lexmark.com,localhost,pvi.com,$DOCKER_IP
## this is the actual way to do it
@miniharryc
miniharryc / file.cpp
Created April 9, 2016 21:03
HackerRank compare two linked lists
/*
Compare two linked lists A and B
Return 1 if they are identical and 0 if they are not.
Node is defined as
struct Node
{
int data;
struct Node *next;
}
*/