Skip to content

Instantly share code, notes, and snippets.

View saucecode's full-sized avatar

Julian saucecode

  • New Zealand
View GitHub Profile
@saucecode
saucecode / mykitexample.cpp
Last active November 17, 2021 10:00
mykitexample.cpp
#include <Kit/Window.hpp>
#include <Kit/Renderer.hpp>
#include <Kit/Quad.hpp>
#include <Kit/Light.hpp> // Lights..
#include <Kit/Camera.hpp> // Camera..
#include <Kit/Model.hpp> // Action!
int main(int argc, char *argv[]){
std::vector<projectile_t*> projectiles;
// ...
projectiles.erase(
std::remove_if(projectiles.begin(), projectiles.end(),
[](projectile_t *p){ return p->life <= 0.0; }),
projectiles.end()
);
@saucecode
saucecode / compile.sh
Created December 30, 2016 17:44
dlopen example
g++ -fPIC -c hello.cpp
g++ -shared -o hello.so hello.o
g++ main.cpp -ldl
@saucecode
saucecode / my_flask_program.py
Created December 31, 2016 06:50
how to correctly use a letsencrypt cert with flask
...
from OpenSSL import SSL
...
context = SSL.Context(SSL.TLSv1_2_METHOD)
context.use_privatekey_file('/etc/letsencrypt/live/DOMAIN.COM/privkey.pem')
context.use_certificate_chain_file('/etc/letsencrypt/live/DOMAIN.COM/fullchain.pem')
context.use_certificate_file('/etc/letsencrypt/live/DOMAIN.COM/cert.pem')
@saucecode
saucecode / threeshears.py
Created June 12, 2017 09:58
an attempt at the three shears image rotation problem. Reads from first.png, outputs to out.png
import math
from PIL import Image, ImageDraw
input_image = Image.open("first.png")
width,height = input_image.size
second_image = Image.new('RGB', input_image.size)
third_image = Image.new('RGB', input_image.size)
output_image = Image.new('RGB', input_image.size)
# draw = ImageDraw.Draw(output_image)
@saucecode
saucecode / aoc3.c
Created December 3, 2017 11:59
my C99 solution to advent of code 2017 day 3 part 2
#include <stdint.h>
#include <stdio.h>
#include <string.h>
// returns the sum of all 8 adjacent cells to element [cy][cx] in a 2D array, with bounds checking
uint32_t setdata(uint32_t root_max, uint32_t data[][root_max], uint32_t cx, uint32_t cy){
uint32_t counter = 0;
if(cx + 1 < root_max){
counter += data[cy][cx+1];
if(cy - 1 >= 0)
@saucecode
saucecode / aoc4.2.py
Created December 4, 2017 07:27
my AoC day 4 part 2 prime-products solution
import string
challenge = '''nyot babgr babgr kqtu kqtu kzshonp ylyk psqk
iix ewj rojvbkk phrij iix zuajnk tadv givslju ewj bda
-snip-
'''.split('\n')
primes = [int(x) for x in '2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101'.split(', ')]
letters = string.ascii_letters[:26]
@saucecode
saucecode / AoC7Solution.java
Created December 7, 2017 17:36
AoC day 7 part 2 solution
import java.io.File;
-snip-
public class AoC7Solution {
static List<Node> nodes = new ArrayList<>();
public static void main(String[] args) {
// Read input
try {
@saucecode
saucecode / aoc8_ugly.py
Created December 8, 2017 07:16
AoC day 8 feat. the ugliest code I've ever written -- script generates scripts that generate solutions to both parts
# generates a python script which runs the challenge input as code then prints out
# the largest integer in `locals()` and the largest value seen
with open('day8challengeinput','r') as f:
lines = f.read().split('\n')
def generate_code_from_input():
headcode = 'largest = 0'
excode = ''
symbols = []
@saucecode
saucecode / aoc10_part2.c
Created December 10, 2017 15:19
AoC Day 10 Part 2 solution in C
#include <stdio.h>
#include <stdlib.h>
typedef struct {
void *prev;
void *next;
int value;
} Node;
Node* assembleRingNodes(int *nodeValues, int len){