Skip to content

Instantly share code, notes, and snippets.

View mcandre's full-sized avatar

Andrew mcandre

  • Milwaukee, WI
View GitHub Profile
@sleepdefic1t
sleepdefic1t / MACOS_CLANG_TIDY.md
Last active May 4, 2024 10:54
brew clang-tidy on macOS
brew install llvm
ln -s "/usr/local/opt/llvm/bin/clang-format" "/usr/local/bin/clang-format"
ln -s "/usr/local/opt/llvm/bin/clang-tidy" "/usr/local/bin/clang-tidy"

use cmake file

  find_program(CLANG_TIDY_BIN clang-tidy)
 find_program(RUN_CLANG_TIDY_BIN /usr/local/Cellar/llvm/10.0.0_3/share/clang/run-clang-tidy.py)
@mcandre
mcandre / dprintf.c
Created January 10, 2019 02:23
crude dprintf() shim for Illumos and Haiku OS
int dprintf(int fd, const char *restrict format, ...) {
va_list ap;
FILE *f = fdopen(fd, "w");
if (!f) {
return -1;
}
va_start(ap, format);
int result = fprintf(f, format, ap);
@DavidBuchanan314
DavidBuchanan314 / cursed_mandelbrot.c
Last active June 28, 2023 15:12
Compile-time mandelbrot in pure C. Outputs a PGM image file to stdout. Output can be seen at https://twitter.com/David3141593/status/1062468528115200001
#include <stdio.h>
#define SQ(x) (x)*(x)
#define M0(x,y) SQ(x)+SQ(y)<4?0:0xe0
#define M1(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M0(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0)):0xc0
#define M2(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M1(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0),x0,y0):0xa0
#define M3(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M2(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0),x0,y0):0x80
#define M4(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M3(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0),x0,y0):0x60
#define M5(x,y,x0,y0) (SQ(x)+SQ(y)<4)?M4(SQ(x)-SQ(y)+(x0),2*(x)*(y)+(y0),x0,y0):0x40
@mohamadaliakbari
mohamadaliakbari / ubuntu-run-dhclient-on-startup.md
Last active November 6, 2023 19:33
Run dhclient on Startup in Ubuntu 18.04

dhclient is the Dynamic Host Configuration Protocol (DHCP) Client one would use to allow a client to connect to a DHCP server.

$ sudo nano /etc/rc.local

#!/bin/bash
dhclient
exit 0
@Ryanb58
Ryanb58 / install.md
Last active May 3, 2024 17:34
How to install telnet into a alpine docker container. This is useful when using the celery remote debugger in a dev environment.
>>> docker exec -it CONTAINERID /bin/sh
/app # telnet
/bin/sh: telnet: not found

/app # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
v3.7.0-243-gf26e75a186 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.0-229-g087f28e29d [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
@mcandre
mcandre / hello.asm
Last active July 4, 2023 15:29
64-bit Windows hello world assembler example, works with Command Prompt, PowerShell, and cygwin-like environments
; Build:
;
; nasm -f win64 hello.asm
; powershell -Command "~\\vsexec.bat link /entry:start /subsystem:console hello.obj kernel32.lib"
;
; The PowerShell wrapper ensures that the linker (either link.exe or golink) receives the correct flags,
; even when the linker command is executed from cygwin-like environments such as Git Bash.
;
; vsexec.bat:
; call "C:\\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" amd64 %*
@xsot
xsot / instructions.md
Last active March 3, 2024 13:42
sed maze solver

Usage

sed -E -f solver.sed input where input is a file containing the maze.

For best results, resize your terminal to match the height of the maze. To disable animations, delete the lines containing p.

Maze format

The solver assumes the following:

  • The maze only contains the characters # \nSE
  • Every line has the same number of characters
  • There is only one start (S) and end (E)
@samm-git
samm-git / Dockerfile
Last active November 13, 2023 17:51
FreeBSD crossbuild with GCC on Linux host
FROM ubuntu:latest
RUN apt-get update
# install dependencies
RUN apt-get install --yes gcc g++ bison make wget xz-utils
# Compile binutils
RUN mkdir /build && cd /build && \
wget https://ftp.gnu.org/gnu/binutils/binutils-2.29.tar.xz && \
tar -xf binutils-2.29.tar.xz && cd binutils-2.29 && \
@mcandre
mcandre / high-sierra.vbox
Created December 1, 2017 19:29
High Sierra VBOX
<?xml version="1.0"?>
<!--
** DO NOT EDIT THIS FILE.
** If you make changes to this file while any VirtualBox related application
** is running, your changes will be overwritten later, without taking effect.
** Use VBoxManage or the VirtualBox Manager GUI to make changes.
-->
<VirtualBox xmlns="http://www.virtualbox.org/" version="1.15-macosx">
<Machine uuid="{b45aa645-60e3-4f5a-81fe-3a6cd249fd56}" name="macOS 10.13" OSType="MacOS_64" snapshotFolder="Snapshots" lastStateChange="2017-12-01T19:26:00Z">
<MediaRegistry>
#!/usr/bin/env bash
# --slave /usr/bin/$1 $1 /usr/bin/$1-\${version} \\
function register_clang_version {
local version=$1
local priority=$2
update-alternatives \
--install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-${version} ${priority} \