Skip to content

Instantly share code, notes, and snippets.

View 10maurycy10's full-sized avatar
🏠
Working from home

Maurycy 10maurycy10

🏠
Working from home
View GitHub Profile
@10maurycy10
10maurycy10 / str_index.c
Last active October 6, 2020 16:20
an function to index into string
#include <stdlib.h>
#include <stdio.h>
char* strindex(char* src,int start, int end) {
int len = end - start;
char* dst = malloc(len + 2);
for (int i = 0; i < (end - start) + 1; i++)
dst[i] = src[i + start];
dst[len + 1] = 0;
return dst;
@10maurycy10
10maurycy10 / _virtual-key-smash.md
Last active October 13, 2020 18:59
virtual key smash

virtual key smash

This is a way to generate key smash virtually.

Do I need to say more?

@10maurycy10
10maurycy10 / tic-ai.c
Created November 30, 2020 16:52
A tic tac toe ai.
#include <stdio.h>
#include <string.h>
int win(int board[9]) {
int wins[8][3] = {{0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8},{2,4,6}};
for(int i = 0; i < 8; ++i) {
if(board[wins[i][0]] != 0 &&
board[wins[i][0]] == board[wins[i][1]] &&
board[wins[i][0]] == board[wins[i][2]])
return board[wins[i][2]];
@10maurycy10
10maurycy10 / how.rs
Last active December 12, 2020 02:25
sdf
mod line_noise {
pub use core::time::Duration;
pub extern crate nalgebra as na;
pub use na::{Vector3,Vector2};
pub use nalgebra::max;
pub use nalgebra::Rotation3;
pub use nalgebra::Isometry3;
pub use nalgebra::Point;
@10maurycy10
10maurycy10 / stepshading.rs
Created December 12, 2020 01:36
shading by ray matching steps
#![feature(trait_alias)]
mod line_noise {
pub use core::time::Duration;
pub extern crate nalgebra as na;
pub use na::{Vector3,Vector2};
pub use nalgebra::max;
pub use nalgebra::Rotation3;
pub use nalgebra::Isometry3;
@10maurycy10
10maurycy10 / index
Created December 25, 2020 15:43
a grepable index of xkcd (up to 2399)
This file has been truncated, but you can view the full file.
|title Barrel - Part 1| |subtitle Don't we all.| |trascript [[A boy sits in a barrel which is floating in an ocean.]]/Boy: I wonder where I'll float next?/[[The barrel drifts into the distance. Nothing else can be seen.]]/{{Alt: Don't we all.}}| |url https://xkcd.com/1/|
|title Petit Trees (sketch)| |subtitle 'Petit' being a reference to Le Petit Prince, which I only thought about halfway through the sketch| |trascript [[Two trees are growing on opposite sides of a sphere.]]/{{Alt-title: 'Petit' being a reference to Le Petit Prince, which I only thought about halfway through the sketch}}| |url https://xkcd.com/2/|
|title Island (sketch)| |subtitle Hello, island| |trascript [[A sketch of an Island]]/{{Alt:Hello, island}}| |url https://xkcd.com/3/|
|title Landscape (sketch)| |subtitle There's a river flowing through the ocean| |trascript [[A sketch of a landscape with sun on the horizon]]/{{Alt: There's a river flowing through the ocean}}| |url https://xkcd.com/4/|
|title Blown apart| |subtitle Blown into prime
@10maurycy10
10maurycy10 / code.rs
Created January 23, 2021 00:12
a terrible encription.
struct Gen {
key: i32
}
impl Iterator for Gen {
type Item = u8;
fn next(&mut self) -> Option<Self::Item> {
self.key += 1;
Some((
((self.key+3*3)^17)%256
) as u8)
@10maurycy10
10maurycy10 / sort.sh
Created February 7, 2021 18:50
a O(n) sorting algo
#!/bin/bash
#sleep sort
function f() {
sleep "$1"
echo "$1"
}
while [ -n "$1" ]
do
f "$1"&
@10maurycy10
10maurycy10 / prefix.py
Last active April 1, 2021 03:03
A quick and dirty way to format SI units.
import math
prefixes = [
("yotta",24),
("zetta",21),
("exa",18),
("peta",15),
("tera",12),
("giga",9),
("mega",6),
@10maurycy10
10maurycy10 / c64.md
Last active April 17, 2021 01:01
notes form hacking the c64 mini w/ uart

UART:

Pinout

ports up

|
| 0 gnd

| 1 data out