Skip to content

Instantly share code, notes, and snippets.

View KaceCottam's full-sized avatar

Kace Cottam KaceCottam

  • Pullman, WA
View GitHub Profile
@KaceCottam
KaceCottam / Makefile
Created April 18, 2022 20:38
dll import with c interop using c#
a.so: a.c
gcc -fPIC -shared -o a.so a.c
.PHONY: run
run: a.so Program.cs
LD_LIBRARY_PATH="./;$$LD_LIBRARY_PATH" dotnet run
@KaceCottam
KaceCottam / git-ignore.sh
Last active June 20, 2021 18:35
various extra git commands
#!/bin/bash
# A git command for adding files to the gitignore
for i in $*; do echo $i >> .gitignore; done
git add .gitignore
@KaceCottam
KaceCottam / HashTable.rs
Last active May 4, 2021 01:43
Linear Probing HashTable Implementation in Rust
// Created by Kace Cottam, 5/3/2021
use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher;
use std::cmp::PartialEq;
pub trait Hashable {
// good looking way to hash an item
fn hash(&self) -> u64;
}
@KaceCottam
KaceCottam / chaininghashtable.cpp
Created April 22, 2021 23:11
Various rehashing tables made in C++
// Created by Kace Cottam, 4/20/2021
#include <array>
#include <list>
#include <utility> // std::pair
// std::unordered_map<Key, Value, Hash=std::hash<Key>>
template<class Key, class Value, int NumberOfBuckets = 117, class Hash = std::hash<Key>>
class ChainingHashTable {
private:
@KaceCottam
KaceCottam / csvparserdemo.cpp
Last active May 5, 2021 00:05
Simple parsing of a CSV file's line. Also includes a utility file repr.hpp and a main for testing.
#include <iostream> // std::ostream, std::cout, std::cin
#include "simpleCSVParse.hpp" // parseCSVLine, option
#include "repr.hpp" // Repr
// need to make representation for a optional value
template<class T>
struct Repr<option<T>> {
const option<T>& value;
explicit Repr(const option<T>& v) : value{v} {}
@KaceCottam
KaceCottam / Makefile
Last active February 3, 2020 22:39
My standard project makefiles
# I use the .cxx extension for source files that define main.
CXX := g++## What compiler we are using
CXXFLAGS := -std=c++17 -Wall -Wextra -Wpedantic -Werror## Compiler flags for all operations
# Directories
SRCDIR := src## Where the source files are located
OBJDIR := build## Where the object files will be placed
BINDIR := bin## Where the finished executable will be placed
INCDIR := include## Additional include directories
# File GLOBs
@KaceCottam
KaceCottam / printf.asm
Created November 15, 2019 19:33
simple printf implemented in MIPS assembly architecture.
printf: # a0: address of format string
# a1, a2, a3: arguments 1, 2 and 3
# example: printf("this is a format string with %d %s",int,string address)
# example: printf("this is another format string with %c %f\n",char,double address)
# %<indicator> will be replaced by the value of the argument.
addi $sp, $sp, -28
sw $t0, ($sp)
sw $t1, 4($sp)
sw $t2, 8($sp)
sw $a0, 12($sp)
@KaceCottam
KaceCottam / .clang-format
Created November 8, 2019 03:36
My preferred clang-format
---
BasedOnStyle: Google
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'true'
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortBlocksOnASingleLine: 'true'
AllowShortCaseLabelsOnASingleLine: 'true'
AllowShortIfStatementsOnASingleLine: 'true'