Skip to content

Instantly share code, notes, and snippets.

View ramseyboy's full-sized avatar

Walker Hannan ramseyboy

  • Austin, Tx, USA
View GitHub Profile
@ramseyboy
ramseyboy / partial.py
Created March 30, 2024 23:54
Partial Stream Discharge Calculation
L = [.075, .225, .375, .525, .675]
d = [.1, .14, .13, .03, 0]
V = [.88, .75, .35, .07, 0]
i = 0
partials = []
def discharge(L: list[float], d: list[float], V: list[float], i: int, partials: list[float]):
if len(L) != len(d) != len(V):
@ramseyboy
ramseyboy / .sh
Created November 3, 2016 17:48
awk string-array one liner
awk -F/, 'BEGIN{print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<string-array name=\"food\">"}{print " <item>" $0 "</item>"}END{print "</string-array>\n"}' food.txt > food-array.xml
class BooleanSerializerSpecs : Spek() { init {
val gson = GsonBuilder()
.registerTypeAdapter(Boolean::class.java, BooleanSerializer())
.create()
given("a valid json string with a boolean field as Y and one as N") {
val json =
"""
{
import java.util.ArrayDeque;
import java.util.Deque;
public class StackQueue<T> {
private Deque<T> in;
private Deque<T> out;
public StackQueue() {
this.in = new ArrayDeque<>();
@ramseyboy
ramseyboy / Maybe.kt
Created August 26, 2016 02:50
Optional/Maybe type in Kotlin
package me.ramseyboy.function
import java.util.*
/**
* A container object which may or may not contain a non-null value. If a value is defined, `isdefined()` will return `true` and `get()` will return the value.
*
* Additional methods that depend on the presence or absence of a contained value are provided,
* such as [orElse()][.orElse] (return a default value if value not defined)
function collapse_pwd {
echo $(pwd | sed -e "s,^$HOME,~,")
}
function prompt_char {
git branch >/dev/null 2>/dev/null && echo '±' && return
hg root >/dev/null 2>/dev/null && echo '☿' && return
echo '○'
}
@ramseyboy
ramseyboy / gist:5f66dc33bfa77c07d58e
Created August 20, 2014 20:17
Duration and Period
/*
P is the duration designator (historically called "period") placed at the start of the duration representation.
Y is the year designator that follows the value for the number of years.
M is the month designator that follows the value for the number of months.
W is the week designator that follows the value for the number of weeks.
D is the day designator that follows the value for the number of days.
T is the time designator that precedes the time components of the representation.
H is the hour designator that follows the value for the number of hours.
M is the minute designator that follows the value for the number of minutes.
S is the second designator that follows the value for the number of seconds.