Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am The6P4C on github.
  • I am the6p4c (https://keybase.io/the6p4c) on keybase.
  • I have a public key whose fingerprint is 9231 C26F 30D2 C300 2C10 BDB7 56DA 106A A090 A846

To claim this, I am signing this object:

import os, sys
import Image, ImageGrab, ImageOps
import time, random
from random import randrange
import win32api, win32con
from numpy import *
#LEGEND:
#-----------------------
#Day 1 Goal: 800Yen - Bot Score: 1440Yen
@the6p4c
the6p4c / graph_generator.py
Last active January 10, 2017 05:50
Graph generator for looking at functions as mentioned in standupmaths' "Four has Four Letters"
def create_graph(classification_function, values, highlight_fixed_points=True):
connections = {}
for n in values:
if n not in connections.keys():
connections[n] = classification_function(n)
fixed_points = [item[0] for item in connections.items() if item[0] == item[1]]
fixed_point_styles = ['\t{0} [style=filled, fillcolor=red, fontcolor=white, fontsize=30];'.format(fixed_point) for fixed_point in fixed_points if highlight_fixed_points]
relationships = ['\t{0} -> {1}'.format(item[0], item[1]) for item in connections.items()]
class Sandpile:
def __init__(self, size, data=None):
self.size = size
if data:
assert(isinstance(data, list))
assert(len(data) == size)
for row in data:
assert(isinstance(row, list))
def generate_stacks(n):
if n == 1:
yield (True,)
yield (False,)
else:
for stack in generate_stacks(n - 1):
yield stack + (True,)
yield stack + (False,)
def stack_flip(stack, n):
from nmigen import *
from nmigen.cli import main
class Test:
def __init__(self):
self.out = Signal(8)
def get_fragment(self, platform):
data = list(range(10))
arr = Array(data)
/* !heavily! work in progress */
MEMORY {
ram (rwx) : org = 0x00000000, l = 64K
user (rx) : org = 0xFFF80000, l = 512K
}
SECTIONS {
.text : {
*(.text)
*(.text*)
@the6p4c
the6p4c / bug.c
Created September 27, 2019 11:28
// Build with gcc -o bug bug.c
//
// Prints non-NULL address of y when executed outside of valgrind, and a NULL
// (rendered as "(nil)" by printf) when executed inside valgrind.
#include <stdio.h>
#include <stdlib.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include <sys/types.h>
@the6p4c
the6p4c / top.v
Created October 1, 2019 13:08
a dodgy uart, without the r
`default_nettype none
module top(input CLK, output PIN_24);
wire tx_buf_empty;
reg tx_data_ready;
reg [7:0] tx_data;
uart_tx #(
.BAUD_DIVISOR(16000000 / 115200)
) uart_tx_inst (
import sys
def main():
input_file = sys.argv[1]
output_file = sys.argv[2]
with open(input_file, 'rb') as f_in, open(output_file, 'wb') as f_out:
decompressed_length = int.from_bytes(f_in.read(4), 'little')
bytes_written = 0