Skip to content

Instantly share code, notes, and snippets.

View drguildo's full-sized avatar

Simon Morgan drguildo

View GitHub Profile
@drguildo
drguildo / the-witcher3-mods.md
Last active December 5, 2021 17:10
The Witcher 3 mods that I recommend.
  • Auto Apply Oils-625-v1-31-2-1594325041.zip
  • AutoLoot AIO 3.0 for Patch 1.31-1996-3-0-5.7z
  • Brothers In Arms Ultimate Bug Fix Collaboration-5752-2-2-1629241468.7z
  • Fast Stash Menu-3931-1-0-1566500962.rar
  • modAxiiFix_1.0.zip-4493-1-0-1584199298.zip
  • modMapQuestObjectives-1.30-v10.zip-943-1-30-10.zip
  • Over 9000 - Weight limit mod v1.31-3-1-31.zip
  • Realistic Weather 2.1-2084-2-1.rar

C data type sizes

C type Intel data type Assembly suffix Bytes
char Byte b 1
short Word w 2
int Double word l 4
long Quad word q 8
char * Quad word q 8
float Single precision s 4
#include <stdio.h>
#include <stdint.h>
typedef struct {
char a;
long b;
char c;
} Struct;
int main(int argc, char const *argv[])
@drguildo
drguildo / bisbic.c
Last active September 16, 2020 21:39
Solution to Practice Problem 2.13 in Computer Systems: A Programmer's Perspective.
#include <stdio.h>
void dump(unsigned int i) {
printf("%#08x = %d\n", i, i);
}
/* Declarations of functions implementing operations bis and bic */
int bis(int x, int m) {
return x | m;
}
fn foo1() {
let foo: Option<i32> = Some(1234);
println!("{}", foo.unwrap_or(4321));
let bar = foo;
}
fn foo2() {
let foo: Option<String> = Some("1234".to_string());
println!("{}", foo.unwrap_or("4321".to_string()));
@drguildo
drguildo / fs.zig
Last active September 19, 2022 18:19
const std = @import("std");
const fs = std.fs;
const warn = std.debug.warn;
pub fn main() !void {
const cwd = try fs.cwd().openDir(".", fs.Dir.OpenDirOptions{
.iterate = true,
});
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
const std = @import("std");
const fs = std.fs;
const warn = std.debug.warn;
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = &arena.allocator;
const cwd = try fs.cwd().openDir(".", fs.Dir.OpenDirOptions{
import os
import streams
import system
import tables
var data: array[30_000, byte]
var dataPointer: int = 0
var instructions: seq[char]
var instructionPointer: int = 0
@drguildo
drguildo / covariance-and-contravariance.cs
Last active February 4, 2020 09:29
Covariance and contravariance.
static void SetObject(object o) { }
void Main()
{
// Assignment compatibility.
string str = "test";
// An object of a more derived type is assigned to an object of a less derived type.
object obj = str;
// Covariance.
class Foo : IEquatable<Foo>
{
public int Id { get; private set; }
public Foo(int id)
{
this.Id = id;
}
public bool Equals(Foo other)