Skip to content

Instantly share code, notes, and snippets.

View arose13's full-sized avatar
🎯
Focusing

Stephen Anthony Rose arose13

🎯
Focusing
View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- google's material design colours from
http://www.google.com/design/spec/style/color.html#color-ui-color-palette -->
<!--reds-->
<color name="md_red_50">#fde0dc</color>
<color name="md_red_100">#f9bdbb</color>
<color name="md_red_200">#f69988</color>
@arose13
arose13 / build.gradle
Created September 28, 2015 17:45
This snippet is used to generate a pom.xml that heroku can use from your gradle file
// Put this where plugins are at
apply plugin: 'maven'
// Put this at the bottom of the build.gradle file
task generatePom << {
pom {
project {
inceptionYear = '2015'
}
}.writeTo("pom.xml")
@arose13
arose13 / build.gradle
Last active September 28, 2015 18:26
This is a base build.gradle for a Heroku spring-boot-gradle application
// Variables
def javaVersionLang = 1.8
// Buildscript
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
# Number of Combinations for pool size (n) and choosing (k) number per set.
# Author arose13
import math
def number_of_combinations(n, k):
numer = n
denom = k
for i in range(1, k):
numer = numer * (n - i)
@arose13
arose13 / genotype_combinations.py
Created January 19, 2016 17:43
Genotype Combinations
import pandas as pd
from collections import Counter
from itertools import combinations_with_replacement
population = [
'pp',
'pp',
'qq',
'pq',
@arose13
arose13 / swarm.py
Last active May 29, 2016 13:21
Particle Swarm
import numpy as np
def swarm(func, bounds, ieqcons=[], f_ieqcons=None, args=(), kwargs={},
swarmsize=100, omega=0.5, phip=0.5, phig=0.5, maxiter=100,
minstep=1e-12, minfunc=1e-12, debug=False):
"""
Perform a particle swarm optimization (PSO)
Parameters
@arose13
arose13 / UniqueCharacters.java
Created June 5, 2016 21:16
Gets all the unique characters from a string in Java
// Find all unique characters in the string
String uniqueLettersInTestString = "";
for (int i = 0; i < testString.length(); i++) {
if (!uniqueLettersInTestString.contains(String.valueOf(testString.charAt(i)))) {
uniqueLettersInTestString = uniqueLettersInTestString + String.valueOf(testString.charAt(i));
}
}
System.out.println("Unique Letters are: " + uniqueLettersInTestString);
@arose13
arose13 / findSerialPorts.py
Created September 13, 2016 02:33
Find all the connected serial ports (only tested on Linux)
import glob
import serial
def serial_ports():
ports = glob.glob('/dev/tty[A-Za-z]*')
working_ports = []
for port in ports:
try:
import warnings
import numpy as np
import pandas as pd
import scipy.stats as st
from tqdm import tqdm
from scipy.stats import iqr
def solve_n_bins(x):
"""
@arose13
arose13 / normal_inverse_cdf.py
Created December 27, 2016 19:41
Scipy free implementation of Normal distribution inverse CDF
def inverse_normal_cdf(p, mean, std):
"""
This is the inverse to a normal distribution's CDF.
While much slower this means you do not need Scipy as a project requirement.
:param p: list of p = (0, 1)
:param mean:
:param std:
:return:
"""