Skip to content

Instantly share code, notes, and snippets.

@wbadart
wbadart / main.cpp
Created February 19, 2016 15:52
Shows the applications and behaviors of pure and regular virtual functions. Demonstrates the in-instantiability of abstract classes.
#include <iostream>
using namespace std;
class AbstractBase{
public:
virtual void virtfunc(void) = 0;
void regfunc(void);
};
class ConcreteBase{
@wbadart
wbadart / see.sh
Created February 28, 2016 08:41
Curious to see who's logged on with you? Run this shell script to identify your fellow users.
#!/bin/bash
passwdPattern="(\w+ ){1,3}\w+"
finalCmds=false
while getopts u arg; do
case $arg in
u)
passwdPattern="^\w+.*(\w+ ){1,3}\w+"
finalCmds=true
#put me in your .$(SHELL)rc file
if [ -z "$(tokens | grep AFS)" ]; then
kinit -l 30d
aklog
fi
#include <iostream>
#include <vector>
template<typename T>
class container{
public:
container();
T* begin();
T* end();
void push_back(T);
@wbadart
wbadart / paint.py
Last active October 4, 2016 03:51
Simulate the "fill color" operation of programs like MS with lists.
'''
' paint.py
'
' Simulate the "fill color" operation of
' programs like MS with lists.
'
' Will Badart
' SEP 2016
'
'''
#include <stdio.h>
int main(void){
printf("char: %d\n", sizeof(char));
printf("short: %d\n", sizeof(short));
printf("int: %d\n", sizeof(int));
printf("long: %d\n", sizeof(long));
printf("long long: %d\n", sizeof(long long));
printf("float: %d\n", sizeof(float));
printf("double: %d\n", sizeof(double));
@wbadart
wbadart / Dockerfile
Created September 25, 2018 13:08
OpenPose compilation environment
FROM bvlc/caffe:gpu
RUN git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose.git
RUN cd openpose && mkdir -p build && cd build \
&& cmake -DBUILD_CAFFE=OFF -DBUILD_PYTHON=ON \
-DCaffe_INCLUDE_DIRS="/opt/caffe/include;/opt/caffe/build/include;" \
-DCaffe_LIBS=/opt/caffe/build/lib/libcaffe.so .. \
&& make && make install
RUN pip install opencv-python
CMD bash
@wbadart
wbadart / Makefile
Created October 8, 2018 14:51
Comparing two recursive ways to test linked list equivalence
N=1000000
M=1000000
M2=1000001
compare: node.o compare.o main.o
$(CC) $^ -o $@
compare_tail: node.o compare_tail.o main.o
$(CC) $^ -o $@
module Graph where
import Data.Function (on)
import Data.List (deleteBy)
data Edge v id_ payload = Edge (v, v) id_ payload
deriving Show
data Graph v id_ payload = Graph [v] [Edge v id_ payload]
deriving Show
@wbadart
wbadart / Main.hs
Last active April 13, 2020 17:08
Probability newtype with smart constructor and unidirectional pattern example
module Main where
import Data.Probability
main :: IO ()
main = do
s <- readLn
case probability s of
-- This pattern match wouldn't work w/o PatternSynonyms
-- (you could still pattern match on the Maybe, but not on