Skip to content

Instantly share code, notes, and snippets.

View elieux's full-sized avatar

David Macek elieux

View GitHub Profile
@elieux
elieux / aws-vault.lua
Last active August 19, 2022 08:46
clink/completions/aws-vault.lua
local map = require("funclib").map
local strings = require("strings")
local sys = require("sys")
local function profile()
return sys.exec("aws-vault list --profiles")
end
local function backend()
local list = {}
@elieux
elieux / What happens
Last active December 19, 2019 21:02
mingw-w64 GCC from MSYS2 fails spectacularly
W:\temp\openconnect\_>gcc -c -g -O2 conftest.c
C:\Users\ether\AppData\Local\Temp\ccfPtxnZ.s: Assembler messages:
C:\Users\ether\AppData\Local\Temp\ccfPtxnZ.s:14: Error: unknown .loc sub-directive `view'
C:\Users\ether\AppData\Local\Temp\ccfPtxnZ.s:14: Error: junk at end of line, first unrecognized character is `-'
C:\Users\ether\AppData\Local\Temp\ccfPtxnZ.s:20: Error: unknown .loc sub-directive `view'
C:\Users\ether\AppData\Local\Temp\ccfPtxnZ.s:20: Error: unknown pseudo-op: `.lvu1'
C:\Users\ether\AppData\Local\Temp\ccfPtxnZ.s:23: Error: unknown .loc sub-directive `view'
C:\Users\ether\AppData\Local\Temp\ccfPtxnZ.s:23: Error: unknown pseudo-op: `.lvu2'
C:\Users\ether\AppData\Local\Temp\ccfPtxnZ.s:24: Error: unknown .loc sub-directive `view'
C:\Users\ether\AppData\Local\Temp\ccfPtxnZ.s:24: Error: unknown pseudo-op: `.lvu3'
@elieux
elieux / index.sql
Created November 20, 2019 12:54
Weird MySQL index thing
SELECT main.id, (
SELECT SUM(group_member.col)
FROM tbl AS group_member
WHERE main.id = group_member.id OR main.parent_id > 0 main.parent_id = group_member.parent_id
) AS col_sum
FROM tbl AS main
ORDER BY id DESC
LIMIT 50;
@elieux
elieux / fifo.c
Created November 19, 2019 09:57
Cygwin vs Linux fifo bug?
/*
* $ gcc -Wall -Wextra -std=c11 fifo.c -o fifo
*
* Linux:
* $ ./fifo
* $ echo $?
* 0
*
* Cygwin:
* $ ./fifo
@elieux
elieux / popt.patch
Last active January 28, 2019 20:57
popt-1.16 opt != NULL patch
--- original/popt-1.16/popt.c 2010-01-19 01:39:10.000000000 +0100
+++ patched/popt-1.16/popt.c 2019-01-28 21:49:43.543620300 +0100
@@ -75,8 +75,7 @@
/*@globals internalState@*/
/*@modifies internalState@*/
{
- if (opt != NULL)
- for (; opt->longName || opt->shortName || opt->arg; opt++) {
+ for (; opt != NULL && (opt->longName || opt->shortName || opt->arg); opt++) {
poptArg arg = { .ptr = opt->arg };
@elieux
elieux / midipix-deps-ubuntu.txt
Created December 24, 2018 12:49
Midipix build dependencies on Ubuntu
Ubuntu 18.04.1 LTS (bionic)
WSL on Windows 10 release 1809 build 17763
sudo apt update
sudo apt upgrade
sudo apt install \
autoconf \
automake \
flex \
g++ \
@elieux
elieux / Dockerfile
Created December 5, 2018 19:37
Why does HTTPd do this?
FROM ubuntu:18.04
COPY ./apt-wrapper.sh /tmp/apt
RUN chmod +x /tmp/apt
RUN /tmp/apt install -y --no-install-recommends apache2='2.4.*'
RUN a2enmod rewrite
RUN a2dissite 000-default
@elieux
elieux / Makefile
Created October 7, 2018 19:42
libweek - something like an enum, but with values not known in the source code
all:
gcc -Wall -Wextra -Werror -std=c99 -shared libweek.c -o libweek.dll
gcc -Wall -Wextra -Werror -std=c99 -L. -I. app.c -o app.exe -lweek
@elieux
elieux / echo.c
Last active April 27, 2017 22:34
Print wide characters
// > gcc -Wall -Wextra -municode -std=c11 -o xecho.exe echo.c
#define WIN32_LEAN_AND_MEAN 1
#define __USE_MINGW_ANSI_STDIO 1
#include <stdio.h>
#include <wchar.h>
#include <io.h>
#include <fcntl.h>
int wmain(int argc, wchar_t *argv[]) {
@elieux
elieux / finddef.php
Created April 2, 2017 16:32
Find preprocessor guards in a C/C++ file
<?php
namespace finddef;
set_error_handler(function($errno, $errstr, $errfile, $errline, $errcontext) { echo "Execution error: {$errstr} on line {$errline} of {$errfile}" . PHP_EOL; exit; });
function make_check_ident($ident) {
$ident = preg_quote($ident, '~');
return function($no, $text) use($ident) { return 1 === preg_match("~\b{$ident}\b~", $text); };
}