Skip to content

Instantly share code, notes, and snippets.

Avatar
🎩
Ballin' outta control.

Caleb Fenton CalebFenton

🎩
Ballin' outta control.
View GitHub Profile
@CalebFenton
CalebFenton / lsm303agr-compas.ino
Created Jan 5, 2020
LSM303AGR Compass Example with calibration and z-axis
View lsm303agr-compas.ino
/*
* LSM303AGR Compass Example
*
* From what I can gather, this shows the proper way to get a compas heading from the LSM303.
* It solves two problems which aren't addressed in the Adafruit example code:
* 1.) Show how to incorporate min and max values from calibration. Makes a HUGE difference in my testing.
* 2.) Take the z-axis into account.
*
* Based heavily off Adafruit example code and https://github.com/pololu/lsm303-arduino.
*/
@CalebFenton
CalebFenton / install_python3.sh
Last active Jul 18, 2019
Create python3 alpine image
View install_python3.sh
#!/bin/sh
# ensure local python is preferred over distribution python
export PATH=/usr/local/bin:$PATH
# http://bugs.python.org/issue19846
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
export LANG=C.UTF-8
# install ca-certificates so that HTTPS works consistently
@CalebFenton
CalebFenton / select_popular_hashes.py
Created Sep 28, 2017
Selecting Popular Android Hashes
View select_popular_hashes.py
@CalebFenton
CalebFenton / DexFileFingerprinter.java
Created Sep 28, 2017
Fingerprinting / Hashing Dalvik Executables
View DexFileFingerprinter.java
import gnu.trove.map.TObjectLongMap;
import gnu.trove.map.hash.TObjectLongHashMap;
import org.jf.dexlib2.Opcode;
import org.jf.dexlib2.iface.ClassDef;
import org.jf.dexlib2.iface.DexFile;
import org.jf.dexlib2.iface.Field;
import org.jf.dexlib2.iface.Method;
import org.jf.dexlib2.iface.MethodImplementation;
import org.jf.dexlib2.iface.instruction.Instruction;
@CalebFenton
CalebFenton / graph.py
Created Sep 28, 2017
Graphing Code Popularity
View graph.py
#!/usr/bin/env python
import ujson as json
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import matplotlib.ticker as plticker
def graph_class_counts():
@CalebFenton
CalebFenton / MarkovChain.java
Created Aug 23, 2017
Markov Chain implementation
View MarkovChain.java
import gnu.trove.map.TCharDoubleMap;
import gnu.trove.map.hash.TCharDoubleHashMap;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
public class MarkovChain implements Serializable {
private static final long serialVersionUID = 986958034001823764L;
@CalebFenton
CalebFenton / ferret_files.py
Created Dec 5, 2016
Recursively find and copy files with some file type.
View ferret_files.py
#!/usr/bin/env python
"""ferret_files.py: Recursively find and copy files with some file type."""
import hashlib
import os
import shutil
import argh
import magic
@CalebFenton
CalebFenton / graph_girdsearch.py
Created Nov 23, 2016
Graph the results of a Sklearn gridsearch
View graph_girdsearch.py
#!/usr/bin/env python
import collections
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
import numpy as np
import sklearn as skl
import itertools
@CalebFenton
CalebFenton / StreamExamples.java
Created Oct 17, 2016
Simple Java Stream and Lambda examples for my sister
View StreamExamples.java
import java.util.Arrays;
import java.util.function.IntUnaryOperator;
import java.util.stream.IntStream;
public class StreamExamples {
public static void main(String[] args) {
int[] myData = new int[]{1, 1, 2, 3, 5, 8, 13, 21, 34};
System.out.println("myData: " + Arrays.toString(myData));
@CalebFenton
CalebFenton / get_dna.py
Created Oct 7, 2016
Convert 23andme raw data to dumb string of G's A's T's and C's
View get_dna.py
import sys
with open(sys.argv[1], 'r') as f:
lines = f.readlines()
for line in lines:
if line.startswith('#'):
continue
parts = line.strip().split('\t')
chem = parts[len(parts) - 1]
sys.stdout.write(chem)
You can’t perform that action at this time.