Skip to content

Instantly share code, notes, and snippets.

@bryc
bryc / checksums.js
Last active December 15, 2022 09:03
CHECKSUMS!
// BSD-16
// From: en.wikipedia.org/wiki/BSD_checksum
function bsd16(data) {
for(var i = 0, c = 0; i < data.length; i++) {
c = (c>>1) + ((c&1) << 15);
c += data[i];
c &= 0xffff;
}
return c;
}
@bryc
bryc / MidiNoteDropper.cs
Last active December 10, 2016 05:29
C# Code
//Compile using csc test.cs
using System;
using System.IO;
using System.Text;
using System.Linq;
public class Program
{
static void Main(string[] args)
{
@bryc
bryc / GBS.ps1
Last active December 10, 2016 05:29
Various CMD Batch, Powershell and Visual Basic Script files
$Files = Get-ChildItem -Path ".\*.m3u"
$Total = $Files.count
$Text = ""
for ($i = 0; $i -lt $Total; $i++) {
$Path = Get-Content $Files[$i]
Write-Host $Path
$Text += $Path + "`n"
}
<style>body{margin:0}div{padding:8px;color:rgba(255,255,255,.5);text-align:center;font:bold 48px sans-serif; -webkit-text-stroke: 0.8px rgba(0,0,0,.75);}</style>
<script>
var colourNames = ["Pink","LightPink","HotPink","DeepPink","PaleVioletRed","MediumVioletRed","LightSalmon","Salmon","DarkSalmon","LightCoral","IndianRed","Crimson","FireBrick","DarkRed","Red","OrangeRed","Tomato","Coral","DarkOrange","Orange","Yellow","LightYellow","LemonChiffon","LightGoldenrodYellow","PapayaWhip","Moccasin","PeachPuff","PaleGoldenrod","Khaki","DarkKhaki","Gold","Cornsilk","BlanchedAlmond","Bisque","NavajoWhite","Wheat","BurlyWood","Tan","RosyBrown","SandyBrown","Goldenrod","DarkGoldenrod","Peru","Chocolate","SaddleBrown","Sienna","Brown","Maroon","DarkOliveGreen","Olive","OliveDrab","YellowGreen","LimeGreen","Lime","LawnGreen","Chartreuse","GreenYellow","SpringGreen","MediumSpringGreen","LightGreen","PaleGreen","DarkSeaGreen","MediumSeaGreen","SeaGreen","ForestGreen","Green","DarkGreen","MediumAquamarine","Aqua","Cyan"
@bryc
bryc / Metrics.js
Last active December 18, 2019 22:42
Reading NonClientMetrics and IconMetrics data in C. Access inaccessible variables for modifying the metrics of desktop icons.
/* Just a tool for converting space-delimited decimal values to hex. */
var NonclientMetrics = "88 1 0 0 7 0 0 0 17 0 0 0 17 0 0 0 18 0 0 0 23 0 0 0 240 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 188 2 0 0 1 0 0 0 0 0 5 0 85 98 117 110 116 117 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0 0 0 8 0 0 0 253 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 144 1 0 0 0 0 0 0 0 0 5 0 83 109 97 108 108 32 70 111 110 116 115 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 18 0 0 0 18 0 0 0 248 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 144 1 0 0 0 0 0 0 0 0 5 0 85 98 117 110 116 117 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 244 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 188 2 0 0 1 0 0 0 0 0 5 0 85 98 117 110 116 117 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 235 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 188 2 0 0 1 0 0 0 0 0 5 0 85 98 117 110 116 117 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 0 0 0";
var IconMetrics = "76 0 0 0 122 0 0 0 46 0 0 0 1 0 0 0 247 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 144 1
@bryc
bryc / zelschk.c
Created March 16, 2015 15:55
legend of zelda (nes) sram checksum updater/checker
/*
zelschk
legend of zelda (nes) sram checksum updater/checker
16/03/2015 - bryc
*/
#include <stdio.h>
unsigned char data[8192];
FILE *fp;
@bryc
bryc / build.bat
Last active August 29, 2015 14:16
g++ 4.8.1 (mingw) - setting registry keys
windres reg.rc -O coff -o reg.res
g++ -c reg.cpp
g++ -o reg.exe reg.o reg.res
@bryc
bryc / arrstr.js
Last active May 6, 2024 03:15
Various useful js JavaScript snippets I use often - Credit = bryc.github.io
// #### ARRAY <-> STRING CONVERSION ####
// b62 - reversible base62 encoder/decoder in two lines.
function b62(n,c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"){var r="",l=c.length,i=0;
if(n.trim)while(i<n.length)r=l*r+c.indexOf(n[i++]);else while(n>0)r=c[n%l]+r,n=Math.floor(n/l);return r}
// arst is a reversible string<>array utility in one line. It converts a string to an array of integers and back.
// ES6 (shorter)
arst=a=>{return a.trim?[...a].map(a=>a.charCodeAt()):String.fromCharCode.apply(0,a)}
@bryc
bryc / Compiler.cmd
Last active December 10, 2016 05:59
C Code Snippets Archive #1 - mostly EEPROM parsing and checksum stuff
REM 2016 NOTE: USE fscanf() in future C projects!
@echo off
echo Compiling...
cd C:\mingw\bin
gcc -s -O3 -o ..\src\build\%~n1.exe %1
echo Done.
pause