Skip to content

Instantly share code, notes, and snippets.

Avatar

David Macek elieux

View GitHub Profile
@elieux
elieux / What happens
Last active Dec 19, 2019
mingw-w64 GCC from MSYS2 fails spectacularly
View What happens
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 Nov 20, 2019
Weird MySQL index thing
View index.sql
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 Nov 19, 2019
Cygwin vs Linux fifo bug?
View fifo.c
/*
* $ gcc -Wall -Wextra -std=c11 fifo.c -o fifo
*
* Linux:
* $ ./fifo
* $ echo $?
* 0
*
* Cygwin:
* $ ./fifo
@elieux
elieux / popt.patch
Last active Jan 28, 2019
popt-1.16 opt != NULL patch
View popt.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 Dec 24, 2018
Midipix build dependencies on Ubuntu
View midipix-deps-ubuntu.txt
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 Dec 5, 2018
Why does HTTPd do this?
View Dockerfile
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 Oct 7, 2018
libweek - something like an enum, but with values not known in the source code
View Makefile
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 Apr 27, 2017
Print wide characters
View echo.c
// > 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 Apr 2, 2017
Find preprocessor guards in a C/C++ file
View finddef.php
<?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); };
}
@elieux
elieux / test.c
Created Feb 4, 2017
Cygwin unlinked /proc/self/fd/* is ENOENT
View test.c
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <alloca.h>
int main() {
char path[] = "tmp";
int r;