Skip to content

Instantly share code, notes, and snippets.

View Ophirr33's full-sized avatar

Ty Coghlan Ophirr33

View GitHub Profile
@Ophirr33
Ophirr33 / results.md
Last active May 16, 2020 00:38
can-you-find-the-best-dungeons-dragons-strategy
roll single dice advantage disadvantage advantage of disadvantage disadvantage of advantage
n = 1 1 1 1 1 1
n = 2 0.95 0.9975 0.9025 0.99500626 0.9904938
n = 3 0.9 0.99 0.81 0.9801 0.9639
n = 4 0.85 0.9775 0.7225 0.95550627 0.9229938
n = 5 0.8 0.96 0.64 0.9216 0.8704
n = 6 0.75 0.9375 0.5625 0.87890625 0.80859375
n = 7 0.7 0.91 0.49 0.8281 0.7399
n = 8 0.65 0.8775 0.422
@Ophirr33
Ophirr33 / demo.scala
Last active August 28, 2019 09:47
Low level vs high level fargate stacks
// =================================================================
// | High level vs Low level "App stacks" |
// =================================================================
//
// This works, but it creates too many resources (security groups, ingress/egress rules) and can't
// be deployed in the locked down environment I work with. Additionally, I would like to pass in
// a log group.
class HighLevelStack(
parent: Construct,
#include <stdio.h>
#define In_the_Name_of_the_Moon struct
#define I_Will_Punish_You int
#define Tuxedo_Max char*
In_the_Name_of_the_Moon Foo {
I_Will_Punish_You X;
Tuxedo_Max Y;
};
@Ophirr33
Ophirr33 / prompt.sh
Created June 5, 2018 01:19
prompt stuff
# User specific aliases and functions
COLOR_RED="\033[0;31m"
COLOR_YELLOW="\033[0;33m"
COLOR_GREEN="\033[0;32m"
COLOR_OCHRE="\033[38;5;95m"
COLOR_BLUE="\033[0;34m"
COLOR_WHITE="\033[0;37m"
COLOR_RESET="\033[0m"
function git_color {
use std::io::prelude::*;
use std::io::{BufReader, BufWriter};
use std::fs::File;
fn main() {
let args: Vec<String> = std::env::args().collect();
assert_eq!(args.len(), 5, "Usage: ./tool <input.csv> <colum-name> <replacement-string> <output.csv>");
let br = BufReader::new(File::open(&args[1]).expect("No input file"));
let mut lines = br.lines().map(|s | s.unwrap().split(',').map(|s| s.to_string()).collect::<Vec<_>>()).peekable();
let col_idx = lines.peek().and_then(|v| v.iter().position(|s| s == &args[2])).expect("Could not find column");
let mut bw = BufWriter::new(File::create(&args[4]).expect("Could not open output file"));
@Ophirr33
Ophirr33 / find-null-files.rs
Created November 30, 2017 18:20
Finds files made of only the null-byte
extern crate walkdir;
extern crate rayon;
use std::fs::File;
use std::io::BufReader;
use std::io::prelude::*;
use std::path::Path;
use std::env::args;
use walkdir::{WalkDir, DirEntry, Result};
use rayon::prelude::*;
@Ophirr33
Ophirr33 / reset-ip.sh
Created October 10, 2017 01:25
New IP
#!/usr/bin/env bash
# WARNING: sed abuse ahead
set -e
# First, find out what interface you're using
INTERFACE=$(ifconfig | grep -e "RUNNING" | grep -v "LOOPBACK" | sed -e "s/:.*//")
# Then, get your current mac address
OLDMAC=$(ifconfig | awk "/$INTERFACE/{f=1} f{print; if (/ether/) exit}" | grep -e "ether" | sed -e 's/^.*ether \(.\{17\}\)\(.*\)/\1/')
# Get a new mac address
END=$(echo $OLDMAC | sed -e "s/.*:\(..$\)/\1/")
if [ "$END" == "ff" ]
@Ophirr33
Ophirr33 / ex.rs
Created August 19, 2017 01:23
rfc 2033 example
let mut v = [-5i32, 4, 1, -3, 2];
v.sort_unstable();
assert!(v == [-5, -3, 1, 2, 4]);
v.sort_unstable_by(|a, b| b.cmp(a));
assert!(v == [4, 2, 1, -3, -5]);
v.sort_unstable_by_key(|k| k.abs());
assert!(v == [1, 2, -3, 4, -5]);
@Ophirr33
Ophirr33 / hello
Created August 18, 2017 00:03
Hello World in Assembly, after being assembled
00400000: 20020004 ; <input:0> li $v0, 4
00400004: 240400c0 ; <input:1> la $a0, hello
00400008: 00042400 ; <input:1> la $a0, hello
0040000c: 24840000 ; <input:1> la $a0, hello
00400010: 0000000c ; <input:2> syscall
00400014: 2002000a ; <input:3> li $v0, 10
00400018: 0000000c ; <input:4> syscall
;
; DATA IN MEMORY
; hello
@Ophirr33
Ophirr33 / hello.py
Created August 17, 2017 12:10
Hello.py
if __name__ == '__main__':
print("Hello, World")