Skip to content

Instantly share code, notes, and snippets.

View aaronjeline's full-sized avatar

Aaron Eline aaronjeline

  • AWS
  • Baltimore
View GitHub Profile
#lang racket
(require threading)
(require data/bit-vector)
(define src
(~>
(with-input-from-file
"/tmp/input"
(λ () (port->lines (current-input-port))))
(map string->list _)))
#lang racket
(require threading)
(define (parse-line line)
(match (string-split line " ")
[(list dir amnt)
(cons (parse-dir dir) (parse-amnt amnt))]))
@aaronjeline
aaronjeline / 1.rkt
Created December 1, 2021 21:46
Solution for day 1 of aoc
#lang racket
(require threading)
(module+ test
(require rackunit))
;; Parsing
(define src
(~>
(with-input-from-file "total_input"
(lambda () (port->lines (current-input-port))))
@aaronjeline
aaronjeline / random_paper.rkt
Created February 22, 2021 04:57
Generate a random paper from papers-we-love
#lang racket
;; Usage information
;; Clone "https://github.com/papers-we-love/papers-we-love"
;; Use the download script under "scripts"
;; Create a file called "interests.txt" containing a list of
;; topics that you are interested in
;; Fill in the variable pdf-viewer with the path to your
;; pdf application (or #f if you don't want it to automatically oepn
@aaronjeline
aaronjeline / syscall_search.rs
Created January 9, 2021 18:51
Quick little rust script for searching for raw linux syscalls
use std::io::{Read, self};
use std::fs::File;
use std::env::args;
fn main() -> io::Result<()> {
let args : Vec<_> = args().collect();
if args.len() != 3 { panic!("Invalid Args!") }
let filename = &args[1];
let syscall = &args[2];
let syscall_int : u8 = match syscall.parse() {
@aaronjeline
aaronjeline / rand.rs
Created December 25, 2020 22:31
Van Neuman Extractor
use std::fs::File;
use std::io::Read;
use std::mem::{transmute, size_of};
fn get_rand_int() -> u32 {
let mut b = [0;4];
let mut f = File::open("/dev/random").expect("Coulnd't open");
f.read(&mut b).expect("Coulnd't read");
unsafe { transmute(b) }
}
@aaronjeline
aaronjeline / monty.rkt
Created December 25, 2020 22:24
Monty Hall Simulation in Racket
#lang racket
(define (simulate strategy)
(define car (random 3))
(define goats (list (modulo (add1 car) 3)
(modulo (sub1 car) 3)))
(define guess (random 3))
(define reveal (list-ref goats (random 2)))
(define final (strategy guess reveal))
(if (= final car) 'win 'lose))
@aaronjeline
aaronjeline / systemf.rkt
Last active May 30, 2020 16:22
Implementation of System F in Racket
#lang racket
;; Implementation of The Polymorphic Lambda Calculus (AKA System F) in Redex
;; No type inference is supported
;; Fixed-point combinator is implemented
;; Two new terms have been introduced to the calculus, type abstraction and type application
;; Useful Functions
;; typecheck?, computers the type of a given term, or #f is no type exists
;; run, reduces a term to a value
@aaronjeline
aaronjeline / move.py
Last active November 22, 2019 19:26
CommandMover
#!/usr/bin/env python3
import json
with open('./convert_all.sh') as f:
lines = f.readlines()[1:]
lines = [line[:-3] if '\\\n' in line else line for line in lines]
print(lines)
@aaronjeline
aaronjeline / approxpi.rs
Created April 24, 2019 16:24
Approximate pi
use rand::prelude::*;
fn main() {
println!("pi = {}", approx(1000000));
}
fn approx(count: u64) -> f64 {
let mut rng = rand::thread_rng();
let mut circle = 0;
for _ in 0..count {