Skip to content

Instantly share code, notes, and snippets.

' This is file libzib-0.9.3_TJF.bi.
'
' FreeBasic-Header file for libzip, translated with help of h_2_bi.bas by
' Thomas.Freiherr@gmx.net.
'
' Licence:
'
' libzib-0.9.3_TJF.bi is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by the
' Free Software Foundation, either version 3 of the License, or (at your
<h3>This article has been tested for the following Ubuntu versions:</h3>
<p>&nbsp;</p>
<ul>
<li>
<p><a href="https://wiki.ubuntuusers.de/Trusty_Tahr/">Ubuntu 14.04</a> Trusty Tahr</p>
</li>
<li>
<p><a href="https://wiki.ubuntuusers.de/Precise_Pangolin/">Ubuntu 12.04</a> Precise Pangolin</p>
@countingpine
countingpine / inflate.c
Last active May 14, 2017 13:48
Skeleton code for zlib inflate routine
#include "inflate.h"
int inflate(char *output, int *output_length, const char *input, int input_length) {
final_block = 0;
do {
get_block_type();
switch(block_type) {
@countingpine
countingpine / lngmath.c
Last active September 9, 2017 14:58
lngmath
void lngcpy(unsigned char *dst, int dst_length, unsigned char *const src, int src_length) {
if (dst_length <= src_length) {
memcpy(dst, src, dst_length);
} else {
/* src_length < dst_length */
memcpy(dst, src, src_length);
memset(dst + src_length, 0, dst_length - src_length);
}
}
@countingpine
countingpine / dragon.c
Last active October 21, 2017 22:37
[WIP] dragon.c: Try to find the fastest strategy to guess the ordering of four items.
/* Game: given four different items, try to put them in order.
With each try, a number is returned indicating how many items are in their correct position. (As in a recent Crystal Maze game)
Challenge: find a strategy that minimises the (worst-case) number of moves needed to guess the order.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef unsigned char move_count;
@countingpine
countingpine / tinybasic.bas
Last active October 21, 2017 22:41
yetifoot's Tiny Basic (small version), originally found at streetcds.co.uk/tinybasic.bas, discussion thread at https://freebasic.net/forum/viewtopic.php?t=12788, full project at https://github.com/countingpine/tinybasic
#include once "crt.bi"
#undef Rem
#define Rem
Dim Shared As Integer CHAR_DBLQUOTE = 34
Dim Shared As Integer SYM_BAD = 0
Dim Shared As Integer SYM_DATATYPE = 1
Dim Shared As Integer SYM_VAR = 2
Dim Shared As Integer SYM_PROC = 3
#include "crt.bi"
function merge(c1 as ulong, c2 as ulong, w as single) as ulong
dim as integer r1, g1, b1, r2, g2, b2
dim as integer m = int(w * 256)
assert(m >= 0 and m < 256)
r1 = c1 shr 16 and 255: r2 = c2 shr 16 and 255
g1 = c1 shr 8 and 255: g2 = c2 shr 8 and 255
b1 = c1 and 255: b2 = c2 and 255
#!/bin/bash
# sha256sum each (megabyte-sized) block of /dev/sda, prepend the block number
# intent is to compare two drivesum lists and then dd out the changed blocks and send them to the other drive
device=/dev/sda
bs=1048576
size=$(blockdev --getsize64 $device)
sumsfile=/tmp/sums_$(date +%s).txt
blocks=$(( ($size+$bs-1)/$bs ))
@countingpine
countingpine / GetVMHardDiskParents.ps1
Last active March 29, 2018 09:16
Powershell script to get each VM, and list its disks, and list the chain of differencing disks for each one
Foreach ($VM in Get-VM){
Write-Output $VM.name
Foreach ($HardDrive in $VM.HardDrives){
$VHDPath = $HardDrive.path
Do {
Write-Output ("- " + $VHDPath)
$VHDPath = (Get-VHD -Path $VHDPath).ParentPath
} While ($VHDPath)
}
}
@countingpine
countingpine / 50_isos
Last active April 12, 2018 19:31
grub menuentries for booting from different ISO files
# To use: adjust as needed, place in /etc/grub.d, make executable, run 'sudo update-grub'
# Ubuntu
# https://help.ubuntu.com/community/Grub2/ISOBoot/Examples
menuentry 'Ubuntu 12.04 (64-bit)' {
set isofile="/iso/ubuntu-12.04-desktop-amd64.iso"
loopback loop (hd0,1)$isofile
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject keyboard-configuration/layoutcode=gb
initrd (loop)/casper/initrd.lz
}