Skip to content

Instantly share code, notes, and snippets.

View queercat's full-sized avatar
🏳️‍⚧️
horse

Moon queercat

🏳️‍⚧️
horse
View GitHub Profile
#include <vector>
enum NODE_TYPE {
OBJECT_NODE,
PROPERTY_NODE,
ARRAY_NODE,
LITERAL_NODE,
NULL_NODE,
STRING_NODE,
};
import re
class InputStream:
def __init__(self, string):
self.string = string
self.cursor = -1
def peek(self):
return self.string[self.cursor + 1]
@queercat
queercat / knapsack.py
Created December 26, 2021 17:12
a solution to an 0-1 knapsack problem
''' IMPORTANT !!!!
explanation provided entirely by
https://medium.com/@fabianterh/how-to-solve-the-knapsack-problem-with-dynamic-programming-eb88c706d3cf
@fabianterh
i just implemented this in python for bettering my understanding.
'''
class Item:
def __init__(self, value, weight):
#include <stdio.h>
#include <stdlib.h>
typedef struct Vector {
int *arr;
int capacity; // # of elements that can occupy the vector total.
int size; // # of elements in the vector.
} Vector;
Vector vector_init() {
@queercat
queercat / client.py
Last active December 31, 2017 04:34
Server and client to a sort of SSH like python connection.
# Client.py a client component to the server component!
import socket # For network stuff obv.
import argparse # Parse arguments!
parser = argparse.ArgumentParser(description = 'Connect to a server and send commands and files to be executed.') # Create the parser.
parser.add_argument('-u', nargs = 1, type = str, help = 'Target destination, e.g. (192.168.2.1., 127.0.0.1') # Add the target.
parser.add_argument('-p', nargs = 1, type = int, help = 'The port for the target destination e.g. 80, 22, 8080.') # Add the port.
@queercat
queercat / Ports.py
Created December 29, 2017 09:04
A simple port scanner. Written in Python.
import argparse
import socket
parser = argparse.ArgumentParser(description='Query a host address of all ports, returns open or closed.')
parser.add_argument('-u', type=str, help='The host address (e.g.) example.com')
args = vars(parser.parse_args())
host = args['u']
@queercat
queercat / DrawTriangle.cpp
Created May 9, 2017 01:26
Draw's a triangle in SDL and prints Hello World when it's done.
#include <iostream>
#include <string.h>
#include <SDL.h>
/*
*
* Hello World in SDL2.
*
*/