Skip to content

Instantly share code, notes, and snippets.

@countingpine
countingpine / winsock-server.bas
Last active October 28, 2022 12:52
Complete Winsock Server Code, translated to FreeBASIC
' https://docs.microsoft.com/en-us/windows/desktop/winsock/complete-server-code
#define WIN32_LEAN_AND_MEAN
#include "win/winsock2.bi"
#include "win/ws2tcpip.bi"
const DEFAULT_BUFLEN = 512
const DEFAULT_PORT = 27015
const NEWLINE = !"\n"
'' compile with fbc example1.bas gifwriter.bas
#include once "gifwriter.bi"
screen 13
dim s as string = !"Hello\nWorld!"
dim g as GifWriter = GifWriter("hello.gif")
g.setDefaultFrameDuration(10)
@countingpine
countingpine / savegif.bas
Last active May 17, 2020 21:44
Save GIF file from Screen in FreeBASIC (TODO: error handling, tidy up, etc.)
'' https://gist.github.com/countingpine/4e70fc94aab6aae041ade9a443863ba0
'' see also http://giflib.sourceforge.net/gif_lib.html
'' see also https://gassend.net/spaceelevator/breaks/index.html -> https://gassend.net/spaceelevator/breaks/oscil2.c
'' see also https://cpp.hotexamples.com/examples/-/-/gif_save/cpp-gif_save-function-examples.html ?
#include "crt.bi"
#include "gif_lib.bi"
#define WID 100
#define HEI 32
@countingpine
countingpine / zopflipng-inplace.sh
Created April 25, 2020 13:14
zopflipng-inplace - run zopflipng (no parameters) on a set of input files, shrinking if possible
#!/bin/bash
for i in "$@";
do
tmpfile=$(mktemp -u --suffix=.png)
zopflipng "$i" "$tmpfile" && mv "$tmpfile" "$i"
done
#!/bin/bash
# install necessary tools/libraries for building/testing FreeBASIC, and git for cloning repository
sudo apt-get install git gcc make lib{ncurses5,gpm,x11,xext,xpm,xrandr,xrender,gl1-mesa,ffi,cunit1}-dev
wget https://downloads.sourceforge.net/project/fbc/Binaries%20-%20Linux/More/FreeBASIC-1.05.0-linux-x86.tar.xz -nc -O ~/Downloads/FreeBASIC-1.05.0-linux-x86.tar.xz
tar -xf ~/Downloads/FreeBASIC-1.05.0-linux-x86.tar.xz --directory /tmp/
git clone https://git.code.sf.net/p/fbc/code ~/fbc-code
@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.