Skip to content

Instantly share code, notes, and snippets.

View pkage's full-sized avatar
🛠️
writing

Patrick Kage pkage

🛠️
writing
View GitHub Profile
@pkage
pkage / pkb.h
Created May 14, 2014 04:45
oh god why
//
// codebot : virtual robotics programming
// by patrick kage
// pkb.h : pkbasic interpreter
//
// this file was created from a mainfile of an old program. this file is a goddamn mess.
#ifndef CB_INTRP
#define CB_INTRP
package org.kagelabs;
import java.awt.Color;
import java.awt.geom.Point2D;
import java.util.HashMap;
import java.util.Random;
import robocode.AdvancedRobot;
import robocode.ScannedRobotEvent;
from PIL import Image
import numpy as np
import glob, os
g3 = 'g3'
g4c = 'g4c'
g4nc = 'g4nc'
np = 'np'
filename = 'Prostate_Cancer_Data'
# json pretty print with compacted leaf arrays
# @author patrick kage
import json
def makeindent(level):
return '\t' * level;
# check if argument needs to be exploded
def contains_complex(arr):
@pkage
pkage / baseconvert.hs
Created October 16, 2017 23:40
Change bases in haskell
--- utilities for converting base
-- @author patrick kage
module BaseConvert where
import Data.Char
import Data.List
import Data.Maybe
import Data.Tuple
import Control.Monad
#! /usr/bin/env python3
# this requires packages requests, beautifulsoup4
import requests
from datetime import datetime
from bs4 import BeautifulSoup
# download the webpage, assuming it's using HTTP Basic Auth
r = requests.get('http://192.168.0.1/#!/home/status', auth=('user', 'pass'))
@pkage
pkage / basichttp.c
Last active March 31, 2018 04:55
a really basic http server in C for POSIXy systems - messy and in progress
/**
* Networking learning project - static server
* @author Patrick Kage
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
@pkage
pkage / bff.c
Last active June 9, 2018 07:04
Brainfuck JIT compiler
/**
* BFF - jit compiled bf
* @author Patrick Kage
*/
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#define MEMORY_SIZE 30000
@pkage
pkage / .bash_profile
Last active June 10, 2018 08:33
Dotfiles
alias l="ls -AFG"
alias ll="ls -lAFGh"
alias vi="nvim"
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias res="cd ~/repositories"
# get the git branch
parse_git_branch() {
@pkage
pkage / 2darrayexample.py
Created July 16, 2018 19:41
A very simple example of how to use 2d arrays in Python.
#! /usr/bin/env python3
#
# 2-Dimensional Array Example
# @author Patrick Kage
#
# pretty-printing module, so that printing the array looks nice
from pprint import pprint