Skip to content

Instantly share code, notes, and snippets.

View miniharryc's full-sized avatar

Harold Combs miniharryc

View GitHub Profile
@miniharryc
miniharryc / results.txt
Created December 3, 2020 21:56
Run of the pragprog 20th edition Sorting comparison rust code
target/release - [master] » ./pragprog
Using Bubble Sort
10000, 143
20000, 591
30000, 1308
40000, 2343
50000, 3662
60000, 5691
70000, 7559
@miniharryc
miniharryc / xorAnagram.java
Created December 16, 2019 16:37
An O(n) solution to anagrams in constant space using XOR
boolean isAnagram( String s1, String s2) {
if (s1.length() != s2.length()) return false;
int x = 0;
for (int i = 0; i<s1.length(); i++) {
x ^= s1.charAt(i) ^ s2.charAt(i);
}
return x == 0;
}
@miniharryc
miniharryc / kata1.clj
Created August 23, 2019 23:32
Code Kata1 in Clojure
(defn _midpoint [vec]
(quot (+ (.start vec) (.end vec)) 2))
(defn _chop [item list]
(cond
(empty? list) -1
(= 1 (count list) ) (if (= item (first list)) (.start list) -1)
:else (let [mid (_midpoint list)]
(let [val (get (.v list) mid)]
(cond
@miniharryc
miniharryc / eachDir.sh
Created May 24, 2017 22:42
eachDir funcction
#
# quick command line alias to do something to each directory under
# the current path
#
# For example:
#
# > eachDir "git status"
#
func_Each_dir() {
import java.io.*;
import java.util.*;
import java.util.stream.*;
public class Solution {
private static final String INSERT = "Insert";
private static final String DELETE = "Delete";
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
@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;
}
*/
@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 / 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 / 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 / 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)