Skip to content

Instantly share code, notes, and snippets.

// @Makefile
// all:
// mkdir -p sprites
// g++ -std=c++11 lodepng/lodepng.cpp sprites.cpp -Wall -pedantic -O3 -o squad
//
// The lib can be found at https://github.com/lvandeve/lodepng
// The output will be stored in ./sprites/ as *.png files
// sprites.cpp - sorbet, https://github.com/Sorebit
#include "lodepng/lodepng.h"
#include <iostream>
#include <iostream>
#include <cmath>
// RGB color struct
struct Color { int r, g, b; };
// Round float to int
int round(float f) { return (f - (int)f >= 0.5) ? (f + 1) : f; }
// Returns an RGB color from an HSV one
@Sorebit
Sorebit / spr.sh
Created November 6, 2016 16:39
Sprawdzarka
#!/bin/bash
DIR="tests"
PRG="./app"
DIFPRG=diff
# Colordiff jeśli jest, inaczej diff
if hash colordiff 2>/dev/null; then
DIFPRG=colordiff
fi
@Sorebit
Sorebit / fastio.cpp
Last active December 4, 2016 21:48
Fast I/O for C++
#include <cstdio>
#define abs(a) ((a < 0) ? -(a) : (a))
template <class T>
void print(T a)
{
if(a == 0)
putchar_unlocked('0');
if(a < 0)
@Sorebit
Sorebit / index.html
Created July 2, 2017 13:05
Node.js file uploader
<!DOCTYPE html>
<html>
<head>
<title>File uploader</title>
</head>
<body>
<form id="uploadForm" enctype="multipart/form-data" action="/api/status" method="post">
<input type="file" name="user-upload" />
<input type="submit" value="Upload File" name="submit">
</form>
@Sorebit
Sorebit / openPopup.js
Last active February 13, 2018 16:02
Simple popup opener for dumps and alike
// Stolen from https://github.com/skilldrick/easy6502/blob/gh-pages/simulator/assembler.js
function openPopup(content, title) {
let w = window.open('', title, 'width=500,height=300,resizable=yes,scrollbars=yes,toolbar=no,location=no,menubar=no,status=no');
let html = "<html><head>";
html += "<link href='style.css' rel='stylesheet' type='text/css' />";
html += "<title>" + title + "</title></head><body>";
html += "<pre><code>";
html += content;
@Sorebit
Sorebit / pong.asm
Last active February 22, 2018 22:53
NES implementation of pong
.inesprg 1 ; 1x 16KB PRG code
.ineschr 1 ; 1x 8KB CHR data
.inesmap 0 ; mapper 0 = NROM, no bank swapping
.inesmir 1 ; background mirroring
;;;;;;;;;;;;;;;
;; DECLARE SOME VARIABLES HERE
.rsset $0000 ;;start variables at ram location 0
gamestate .rs 1 ; .rs 1 means reserve one byte of space
@Sorebit
Sorebit / download.html
Last active August 10, 2018 10:28
Upload and download JSON scene config file. Will be used in Pen & Paper soon
<head>
<meta charset="utf-8">
</head>
<button id="button">Save scene</button>
<script>
// Original source: http://jsfiddle.net/4ooupev9/126/
function handleDownload() {
@Sorebit
Sorebit / digger.au3
Last active June 23, 2020 20:57
AutoIt3 Club Penguin gold digger
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.14.5
Author: https://github.com/sorebit
Script Function:
This is a Club Penguin AFK gold digger.
Usage:
1. Open cponline.pw/play in full window.
2. Scroll down.
@Sorebit
Sorebit / p2o.py
Created October 9, 2022 13:52
Pinboard -> Obsidian migration script
"""
Turns a json exported from pinboard.in into a folder of Obsidian-compliant .md notes
Usage:
python p2o.py <export.json path> <out folder>
"""
import contextlib
import dateutil
from enum import Enum
from pathlib import Path