Skip to content

Instantly share code, notes, and snippets.

View lukewilson2002's full-sized avatar

Luke Wilson lukewilson2002

View GitHub Profile
@lukewilson2002
lukewilson2002 / Camera.gd
Last active June 2, 2018 03:11
3D Godot GDScript camera shake script.
extends Camera
func shake(length, magnitude):
var time = 0
var camera_pos = translation
while time < length:
time += get_process_delta_time()
var offset = Vector3()
offset.x = rand_range(-magnitude, magnitude)
@lukewilson2002
lukewilson2002 / ascii_table.rs
Created April 17, 2018 22:35
Tiny Rust ASCII table printer
fn main() {
println!("| {:^5} | {:>3} | {:>4} | {:03} |", "Char", "Dec", "Hex", "Oct");
println!("|-------|-----|------|-----|");
for c in 0u8..128u8 {
println!("| {:^5} | {:>3} | {:>#4X} | {:03o} |", get_char_name(c), c, c, c);
}
}
fn get_char_name(c: u8) -> String {
assert!(c < 128);
@lukewilson2002
lukewilson2002 / brainfuck.odin
Created March 29, 2018 23:04
Brainfuck interpreter written in Odin.
import "core:fmt.odin"
interpret :: proc(program: string) {
tape: [30000]u8 = 0;
ptr := 0;
index := 0;
for index < len(program) {
switch program[index] {
@lukewilson2002
lukewilson2002 / hw.ox
Created March 24, 2018 06:14
A test for a language im designing.
<!-- Preprocessor -->
<!--
In this form, the preprocessor presented is LaTeX code,
that is specific to the LaTeX backend only.
Every backend will have to have its own implementation for preprocessor.
The preprocessor can be used for things like scripting environment variables, page numbers, and more.
-->
@title Hello World
@lukewilson2002
lukewilson2002 / main.rs
Last active January 14, 2021 16:43
Simple Brainfuck to C compiler written in Rust.
// "Hello, world!"
static PROGRAM: &'static str = "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.";
fn main() {
let tokens = tokenize(PROGRAM);
//println!("{:?}", tokens);
let generated_code = generate(&tokens);
println!("{}", generated_code);
}
@lukewilson2002
lukewilson2002 / port_scanner.rs
Created February 27, 2018 02:36
Over-engineered job-stealing multithreaded port scanner in Rust.
extern crate rayon;
use std::io::{stdout, Write};
use std::net::{IpAddr, Ipv4Addr, TcpStream};
use rayon::prelude::*;
static MAX_PORT: u16 = 65535;
fn main() {
let address = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));