Skip to content

Instantly share code, notes, and snippets.

View elieux's full-sized avatar

David Macek elieux

View GitHub Profile
@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 / gist:fd63e62fda6a05778004
Created May 5, 2015 23:29
SCons MSYS2/mingw platform patch
--- /usr/lib/python2.7/site-packages/SCons/Platform/msys.py.orig 2014-11-04 23:23:28.000000000 +0100
+++ /usr/lib/python2.7/site-packages/SCons/Platform/msys.py 2015-05-06 01:27:32.333448600 +0200
@@ -39,6 +39,12 @@
posix.generate(env)
env['ENV']['PATH'] = os.getenv('PATH')
+ import_env = [ 'SystemDrive', 'SystemRoot', 'TEMP', 'TMP' ]
+ for var in import_env:
+ v = os.environ.get(var)
+ if v:
@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); };
}
@elieux
elieux / pacman.conf
Created November 16, 2014 14:21
pacman config
#
# /etc/pacman.conf
#
# See the pacman.conf(5) manpage for option and repository directives
#
# GENERAL OPTIONS
#
[options]
# The following paths are commented out with their default values listed.
@elieux
elieux / 10morespace
Last active April 2, 2017 14:56
morespace.sh
#!/system/bin/sh
#
# MORESPACE - init script to use an ext4-formatted sdcard for both app installations and user data
# Revision: 3
# Author: github.com/elieux
# Device: Huawei Ascend G300 [U8815] with CM11
#
# Warning: The script does not reformat your sdcard. That needs to be done manually before installing the script.
# Warning: The script is not designed for multiple-partition sdcards (sd-ext).
#
@elieux
elieux / Makefile
Last active April 2, 2017 14:56
DLL troubles
all: main.exe
foo.o: foo.c
gcc -c foo.c -o foo.o
libfoo.a: foo.o
ar sr libfoo.a foo.o
bar.o: bar.c
gcc -c bar.c -o bar.o
libbar.dll: bar.o libfoo.a
@elieux
elieux / segfault.c
Created March 7, 2015 14:20
Instant crash
typedef int(*fn)();
int main() {
return ((fn)0)();
}
@elieux
elieux / make.sh
Last active April 2, 2017 14:46
Debugging makefiles
#/usr/bin/sh
#http://www.drdobbs.com/tools/debugging-makefiles/197003338
make --eval='print-%: ; @echo $* is $($*)' --eval='OLD_SHELL := $(SHELL)' --eval='SHELL = $(warning [$@ ($^) ($?)])$(OLD_SHELL) -x'
make V=1 VERBOSE=1
make --dry-run