Skip to content

Instantly share code, notes, and snippets.

View saucecode's full-sized avatar

Julian saucecode

  • New Zealand
View GitHub Profile
'''
A 'range' in this context is a 2-tuple
(a, b) that represents the set of integers
in the (mathematical) range (a, b].
a must always be less than b.
'''
def range_contains(ra, sub):
@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 / 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[]){
@saucecode
saucecode / postfix.py
Last active December 18, 2020 19:26
postfix calculator in python 2 & 3
# This has been moved to a repo -- https://github.com/saucecode/postfix-calculator
# all future updates found there
#!/usr/bin/env python
# postfix.py - a postfix calculator for python 2 & 3
# version 5 2016-09-20
import string, math
import inspect
import base64, zlib, sys, os, json
inflator = zlib.decompressobj()
bins = sorted([i for i in os.listdir('.') if i.endswith('.in.bin')], key=lambda j:int(j[:-7]))
pretty_print = True
# go through all the *.in.bin files, decompress them sequentially
# and write them to *.in.json files. Optionally pretty print
# them (switch the variable above)
@saucecode
saucecode / linkedlists.c
Created June 15, 2019 21:54
example linked lists implementation
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int x;
int y;
float health;
} monster_t;
typedef struct {
@saucecode
saucecode / Game.cpp
Created June 26, 2018 10:44
attempt at porting mattdesl's 2d pixel perfect shadows
#include "Game.hpp"
#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
From d2ef1e5505a7b3e9b3ad393df344b3cda5e2ad09 Mon Sep 17 00:00:00 2001
From: Julian <cahill.julian@gmail.com>
Date: Tue, 18 Dec 2018 03:34:32 +1300
Subject: [PATCH] added locking of linear and angular velocities with
RigidBody::setLinearVelocityFactor(), RigidBody::setAngularVelocityFactor()
---
src/body/RigidBody.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++-
src/body/RigidBody.h | 42 +++++++++++++++++++++++++++++++++++++----
src/engine/DynamicsWorld.cpp | 14 +++++++++++++-
@saucecode
saucecode / aoc16.py
Created December 16, 2017 07:31
awful and unclean solution
with open('day16challengeinput','r') as f:
data = f.read().split(',')
moves = []
for move in data:
if move[0] == 's':
moves.append( (0, int(move[1:])) )
elif move[0] == 'x':
@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){