Skip to content

Instantly share code, notes, and snippets.

@countingpine
countingpine / ascme.c
Last active April 25, 2020 13:09
ascme.c - convert stdin to printable string with C/bash-style escape sequences
#include <stdio.h>
#define IN(a, z) (c >= (a) && c <= (z))
int main() {
int count=0;
int c;
while (!feof(stdin)) {
c = getc(stdin);
// EOF?
@countingpine
countingpine / tcpwindow.cpp
Last active December 18, 2019 17:09
TCP window calculator
// tcpwindow.cpp : Defines the entry point for the console application.
// Fixed from https://blogs.technet.microsoft.com/neilcar/2004/10/26/quick-figuring-optimal-tcp-window-size/#comment-263
//
//#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
float pingRTT;
@countingpine
countingpine / abclogic.c
Last active October 16, 2023 13:55
ABC Logic solver
// 2023-10-15 ran it through ChatGPT (Bing Chat) to suggest improvements
#include <stdio.h>
// Define a structure to represent a 5x5 grid of cells
typedef struct {
char cells[25]; // Each cell can have a value of 0, 1, 2, or 3
} Grid;
// Define an array to store all the possible grids that match the clues
@countingpine
countingpine / mbr2script.sh
Last active April 2, 2021 19:34
Convert MBR (or any 512-byte binary input) into a script that outputs the data but with editable partition fields
#!/bin/bash
# wget https://gist.githubusercontent.com/countingpine/78d198b2f3d7271427d3fa49c787b135/raw/mbr2script.sh
set -e
set -u
echo '#!/bin/bash'
echo 'set -e'
echo 'set -u'
# Hexdump 512 bytes from stdin
@countingpine
countingpine / NIV 1984 Page Numbers.txt
Last active June 13, 2019 14:18
NIV (1984 Edition) Page numberings
Holy Bible, New International Version
Copyright 1973, 1978, 1984 by International Bible Society
First published in Great Britain 1979
This Edition 2000
======
This is a list of the first verse contained on each page of this edition of the Bible.
The hope is that this will be a useful reference for any church events where people are asked to follow along with
scripture readings from a standard Bible.
@countingpine
countingpine / deflate_file.c
Created February 21, 2019 13:45
Simple, uncompressed DEFLATE compressor
#include <stdint.h>
/* block size must be 65535 or less */
#define MAX_BLOCK_SIZE 65535
#define START 1
#define FINISH 2
#define writebyte(c) do {if (outleft) {*out++ = (c); outleft--;} else return 1;} while (0)
# sha256sum vbetest.exe
02083bb2fad888cc763fb0691d136118ffe250fe7754bd98fcd92b27d341acc5 vbetest.exe
# md5sum vbetest.exe
0d3ec4370725bb24afe08aeb56c1f8b8 vbetest.exe
# strings vbetest.exe
B23X
Fatal error, DPMI host does not support 32 bit applications$
Fatal error, 80386 processor is required$
@countingpine
countingpine / vbetest.txt
Created January 16, 2019 22:20
Information about vbetest.exe, downloaded from http://dll-rehab.com/file/vbetest.exe/7793.html
# sha256sum vbetest.exe
40374bb91ea15f3e44684a78a6683e13627e0cc578d3a961dd8e72bda64e7b25 vbetest.exe
# md5sum vbetest.exe
7c7a5fa776ac4e4ee14e90e34dc3fbd6 vbetest.exe
# strings /vbetest.exe
CC&8
>8-3
tn<%tm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252"/>
<title></title>
<meta name="generator" content="LibreOffice 4.3.0.4 (Windows)"/>
<meta name="created" content="00:00:00"/>
<meta name="changed" content="00:00:00"/>
<style type="text/css">
@page { size: 21.59cm 27.94cm; margin-left: 3.18cm; margin-right: 3.18cm; margin-top: 2.54cm; margin-bottom: 2.54cm }
@countingpine
countingpine / truncatefile.bas
Last active November 18, 2019 14:32
Truncate file in VB6
'' see also https://stackoverflow.com/questions/6334917/how-can-i-trim-the-end-of-a-binary-file
'' based in part on http://vbnet.mvps.org/index.html?code/fileapi/truncaterandomfile.htm
Option Explicit
'' constants for CreateFile
Private Const OPEN_ALWAYS As Long = 4, GENERIC_WRITE As Long = &H40000000, GENERIC_READ As Long = &H80000000, FILE_ATTRIBUTE_NORMAL As Long = &H80, INVALID_HANDLE_VALUE As Long = -1
'' constants for SetFilePointer
Private Const FILE_BEGIN As Long = 0, INVALID_SET_FILE_POINTER As Long = -1