Skip to content

Instantly share code, notes, and snippets.

@fay59
fay59 / Quirks of C.md
Last active January 23, 2024 04:24
Quirks of C

Here's a list of mildly interesting things about the C language that I learned mostly by consuming Clang's ASTs. Although surprises are getting sparser, I might continue to update this document over time.

There are many more mildly interesting features of C++, but the language is literally known for being weird, whereas C is usually considered smaller and simpler, so this is (almost) only about C.

1. Combined type and variable/field declaration, inside a struct scope [https://godbolt.org/g/Rh94Go]

struct foo {
   struct bar {
 int x;
@ihciah
ihciah / set_route.py
Last active February 13, 2020 12:53
Set route script for tinc on windows
#!/bin/python
# -*- coding: utf-8 -*-
# I found the interface id is not a fixed value...
import subprocess
INTERFACE = "tincvpn"
ROUTE = "route add 10.0.0.0 mask 255.0.0.0 192.168.102.199 metric 1 if %s"
def get_interface_id():
interfaces = subprocess.check_output("netsh int ipv4 show interfaces")
@Preston-Landers
Preston-Landers / pyuac.py
Last active June 16, 2023 04:09
pyuac - elevate a Python process with UAC on Windows
#!/usr/bin/env python
# -*- coding: utf-8; mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vim: fileencoding=utf-8 tabstop=4 expandtab shiftwidth=4
"""
THIS CODE IS OUTDATED! Please use this instead:
https://pypi.org/project/pyuac/
https://github.com/Preston-Landers/pyuac