Skip to content

Instantly share code, notes, and snippets.

View Chris-Johnston's full-sized avatar
🆒

Chris Johnston Chris-Johnston

🆒
View GitHub Profile
@Chris-Johnston
Chris-Johnston / nugget_permutations.py
Created December 29, 2020 04:35
how many nuggets can I buy??
import itertools
nuggets = {
4: 2.39,
6: 3.49,
10: 4.89,
20: 6.19,
40: 11.99,
}
upper_price = 50
max_orders = upper_price // 1 # upper price / cheapest item
@Chris-Johnston
Chris-Johnston / bmp_to_csv.py
Created July 15, 2020 17:22
Converts a BMP image to a CSV file, so that we can apply conditional formatting on each of the cols to make it look like an image. Mildly cursed.
# bmp to csv
# only mildly cursed
FILENAME = "image.bmp"
DIMENSIONS = (100, 100)
HEADER_END = 0x36 # the address where the header ends, too lazy to read all of that
def bmp_to_csv_text(img_bytes) -> str:
out = ""
all_bytes = img_bytes.read(3 * DIMENSIONS[0] * DIMENSIONS[1])
@Chris-Johnston
Chris-Johnston / cipher.py
Created January 31, 2019 01:12
Caesar Cipher Script
def rotate(key: int, character: chr) -> chr:
if character == ' ':
return ' '
character = character.upper()
v = ord(character[0]) - ord('A')
v -= key
v %= 26
v += ord('A')
@Chris-Johnston
Chris-Johnston / SpiralShader.shader
Created January 26, 2019 01:05
Colored spiral shader that I used for a neat effect.
Shader "ChrisJ/SpiralShader"
{
Properties
{
}
SubShader
{
Tags { "RenderType"="Opaque" }
Pass
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Text;
using System.Threading.Tasks;
namespace Discord.Commands
{
internal static class CommandParser
{