Skip to content

Instantly share code, notes, and snippets.

View cgsdev0's full-sized avatar
🐻

sarah schulte cgsdev0

🐻
View GitHub Profile
@cgsdev0
cgsdev0 / fizzbuzz.cpp
Last active January 26, 2024 14:28
FizzBuzz State Machine (C++)
/*
(Dumb) idea to implement the classic FizzBuzz
problem as a state machine with 16 states.
*/
#include <iostream>
#include <vector>
#include <functional>
#include <stdlib.h>
@cgsdev0
cgsdev0 / decToInt.cpp
Created May 12, 2019 02:38
Round argv[1] to the nearest integer
/*
This program rounds argv[1] to the nearest integer.
It was tasked as a college programming assignment to one of my friends,
and written by me (in this horrifying way so he couldn't steal it and
turn it in)
*/
#include <iostream>
@cgsdev0
cgsdev0 / zsh_web_server.md
Last active March 18, 2020 20:28
ZSH Web Server

ZSH Web Server

Have you ever used the command python -m http.server and thought hmm... I really wish this didn't require such a heavy depedency like Python?

Well, now you can accomplish the same goal from the comfort of ZSH! Simply add this line to your zsrhc, then type serve in the folder you'd like to start a HTTP server for.

serve () { rm /tmp/tunnel; mkfifo /tmp/tunnel; echo "Serving $(pwd) on 127.0.0.1:8000..."; while true; do (printf "HTTP/1.0 200 OK\n"; (reqreader() { while IFS= read line;  do [[ $line = $'\r' ]] && break; echo "$line"; done; exit 0; }; var=$(</tmp/tunnel | reqreader); var=$(echo "$var" | grep ^GET | sed 's/GET \(.*\) HTTP\/1\.1.*/\1/'); var=$(echo "$var" | sed 's/^\(.*\)@$/\1/' | sed 's/^\(.*\)\*/\1/'); var=$(echo "<!doctype html><html><head><title>$(pwd)</title></head><body>"; (cat "./$var" 2> /dev/null || (ls -F "./$var" 2> /dev/null | sed 's/\(.*\)/<a href="\1">\1<\/a><br \/>/')); echo "</body></html>"); printf "Content-Length: "; echo "$var" | wc -c; printf "\r\n
@cgsdev0
cgsdev0 / kenken.cpp
Created March 29, 2020 06:26
(C++) KenKen Puzzle Solver
/*
Program that solves a kenken puzzle and pretty prints the result.
Reading the puzzle as input is not currently supported.
*/
#include <fcntl.h>
#include <locale.h>
#include <iomanip>
#include <iostream>
#include <locale>
@cgsdev0
cgsdev0 / twitch_chat.sh
Created January 26, 2022 09:30
Display live twitch chat directly in your terminal
#!/bin/zsh
# depends on 'websocat' https://github.com/vi/websocat
#
# twitch_chat {channel} - opens a websocket for reading chat
twitch_chat () {
rm -f /tmp/twitch_tunnel;
mkfifo /tmp/twitch_tunnel;
clear;
@cgsdev0
cgsdev0 / minecraft_skin_exploder.html
Created March 16, 2022 03:39
slices a minecraft skin into multiple images; currently hosted here https://cgs.dev/minecraft_skin_exploder.html
<!doctype html>
<html>
<head>
<title>Minecraft Skin Exploder</title>
</head>
<script type="text/javascript">
const maskdata = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAZhJREFUeJztm71KA0EURjPaiJAmgitiYbWY3iewsNQm2FjZiZBewVLQUhDFTgR/QFL5HBaCxYattNIFkyYidmstCXcIN3DA/U6dO3P4uLOZ2UlCLcLC4VwZ+4zFx1EveOrLi6Zr/rCXmfNPeQb/DygAWoBGAdACNAqAFqAJ3u95L++L8+T06gAFQAvQKABagEYB0AI0Q2fl9Kww9wV5OzHP143VLde+ov/0YI5frKTm+Ek3H+v9Q+U7QAHQAjQhtuZjfF63J+Uykuzr2VUfeyZUvgMUAC1AowBoARoFQAvQKABagEYB0AI0Q/vkRr1lng36g465ty6bP777/GzGHP929socf/t7R+8DxkEB0AI0IbbmY/SWbiblMpK7t3tXfeyZUPkOUAC0AI0CoAVoFAAtQKMAaAEaBUAL0Aztk+utDfNsMOg8mnvr18K+v19O7Lu6tLD/H5An9u//dw/2zfrL45M/9ZXvAAVAC9CE2JqP8XLedQms16Zd9Wunm676yneAAqAFaBQALUCjAGgBGgVAC9AoAFqA5heamUiO3GpTvwAAAABJRU5ErkJggg==";
const old_colormap = {
"left_arm": "#e92826",
@cgsdev0
cgsdev0 / jam_game_launcher.html
Created October 21, 2022 10:01
A simple launcher for my HTML5 jam games.
<!doctype html>
<html>
<head>
<style>
* {
margin: 0;
overflow: hidden;
}
@cgsdev0
cgsdev0 / movement.cpp
Last active November 21, 2022 03:53
camera control rotation
// Takes in a movement vector and moves the cursor
static void moveHelper(ALevelEditorPawn* t, FVector v) {
if (!t->cursorLocation.Z && v.Z < 0) v.Z = 0; // Min floor
// Adjust input vector for camera rotation
AController* controller = t->GetController();
if (controller) {
FRotator rot = controller->GetControlRotation();
UE_LOG(LogTemp, Warning, TEXT("Rotation: %d"), (int)rot.Yaw);
if (rot.Yaw > 45 && rot.Yaw <= 135) {
@cgsdev0
cgsdev0 / rolly_cubes_bot.js
Last active April 28, 2023 19:16
Rolly Cubes Bot
// Paste in your rollycubes.com console to unleash the rolly bot
let speedMult = 1;
let unsubscribe;
if (unsubscribe) unsubscribe();
let lut={22:2,23:2,24:4,25:4,26:6,27:4,28:6,29:2,30:4,32:2,34:2,36:4,37:2,38:6,
39:4,40:6,41:4,42:4,43:2,44:2,48:2,49:2,50:2,51:2,52:2,53:4,54:4,55:4,56:4,57:6,
58:8,59:10,60:10,61:10,62:8,63:6,64:4,65:2,66:2,67:2,68:2,69:4,70:6,71:8,72:10,
73:10,74:10,75:8,76:6,77:4,78:2,82:2,83:2,84:2,85:4,86:4,87:4,88:4,89:8,90:10,
91:14,92:14,93:14,94:12,95:12,96:6,97:6,98:2,99:2,100:2,101:6,102:6,103:12,104:12,
@cgsdev0
cgsdev0 / fizzbuzz.c
Last active May 22, 2023 20:25
new fizzbuzz just dropped
#include <stdio.h>
#include <stdlib.h>
// boilerplate; ignore this part
#define loop(x) for(int _i=x;_i<=0x64;_i+=x)
#define i c+(_i-1)*012
#define pn sprintf(i,"%d\n",_i)
#define ps(s) strcpy(i,#s"\n")
#define say(s) strcmp(#s,"Number")?ps(s):pn