Skip to content

Instantly share code, notes, and snippets.

@rodamber
rodamber / uninstall.sh
Created May 27, 2016 14:11 — forked from klarstil/uninstall.sh
Uninstall git on Mac OS X
#!/bin/bash
if [ ! -r "/usr/local/git" ]; then
echo "Git doesn't appear to be installed via this installer. Aborting"
exit 1
fi
echo "This will uninstall git by removing /usr/local/git/**/*, /etc/paths.d/git, /etc/manpaths.d/git"
printf "Type 'yes' if you sure you wish to continue: "
read response
if [ "$response" == "yes" ]; then
sudo rm -rf /usr/local/git/
@rodamber
rodamber / convert.lex
Created May 31, 2016 01:50
CamelCase to lower_with_underscore conversion for C/C++ files
%option 8bit noyywrap yylineno stack
%{
#include <algorithm>
#include <iostream>
#include <cctype>
bool all_caps(const std::string &s) {
return std::none_of(s.begin(), s.end(), ::islower);
}
@rodamber
rodamber / graphcol.cpp
Last active October 19, 2016 22:01
Graph coloring (bitwise encoding)
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/iteration_macros.hpp>
#include <boost/range/irange.hpp>
#include <minisat/core/Dimacs.h>
#include <minisat/core/Solver.h>
#include <zlib.h>
moneys = [50, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.02, 0.01]
def ex5(quantity):
quantities = {m: 0 for m in moneys}
for m in moneys:
while quantity >= m:
quantity -= m
quantities[m] += 1
return quantities