Skip to content

Instantly share code, notes, and snippets.

View euhmeuh's full-sized avatar
🌈
Harvesting rainbows

Zoé Martin euhmeuh

🌈
Harvesting rainbows
View GitHub Profile
@euhmeuh
euhmeuh / asciitoxbm.py
Created May 3, 2017 15:59
Generate a XBM image from an ASCII art string
def ascii_to_xbm(string, black='#', white=' '):
"""Generate a XBM image from an ascii art string"""
# purify input by removing all empty lines
# and all lines that contains illegal characters
lines = []
for line in string.split('\n'):
if not line:
continue
if not all([c in (black, white) for c in line]):
@euhmeuh
euhmeuh / ShutUpVisual.bat
Created May 10, 2017 13:58
In case of fire... rebuild your Visual Studio cache
del %LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe" /setup
pause
@euhmeuh
euhmeuh / takeown.bat
Last active May 10, 2017 14:07
Take the ownership of a folder on Windows
REM sometimes you need to kill explorer.exe
psexec -i -s cmd.exe
takeown /F directory /R /A
@euhmeuh
euhmeuh / compress_video.sh
Last active May 10, 2017 14:13
Use ffmpeg to compress a video using x264
# crf is the quality between 0 (lossless) and 51 (worst)
ffmpeg -i input.mp4 -vcodec libx264 -crf 20 output.mp4
@euhmeuh
euhmeuh / Program.cs
Created June 15, 2017 08:56
Initialize a WCF web server with SOAP support
using System;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.Web;
using System.Threading;
namespace SoapServer
{
public class Program
{
@euhmeuh
euhmeuh / brainfuck.c
Created July 30, 2017 21:16
Brainfuck interpreter in C
/*
Brainfuck interpreter by euhmeuh
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <errno.h>
#include <string.h>
@euhmeuh
euhmeuh / test.wast
Created October 6, 2017 14:35
WebAssembly
(module
(import "console" "log" (func $log (param i32) (param i32)))
(import "game" "update" (func $update))
(memory 1)
(func $init (export "init") (param $width i32) (param $height i32)
get_local $width
get_local $height
i32.mul
@euhmeuh
euhmeuh / anaphoric.scm
Created October 19, 2017 11:18
Anaphoric macros
;; Scheme hygienic aif is too long :(
;;
;; (define-syntax aif
;; (lambda (x)
;; (syntax-case x ()
;; ((_ test then else)
;; (with-syntax ((it (datum->syntax x 'it)))
;; (syntax
;; (let ((it test))
;; (if it then else))))))))
@euhmeuh
euhmeuh / regex.md
Created November 17, 2017 10:10
Regex syntax memo

Name grouping and replacement

Named group is formed with (?<name>).
Captured text can be inserted in result using $+{name}.

Example text: <foo><bar>Hello</bar> <baz>World!</baz></foo>
In the regex: <foo><bar>(?<message>.+)</bar> <baz>(?<object>.+)</baz></foo>
Replace by: <message object="$+{object}">$+{message}</message>

@euhmeuh
euhmeuh / ai.rkt
Last active November 22, 2017 22:29
Machine learning
#lang racket
(require math racket/trace)
(define T matrix-transpose)
(define (sigmoid x)
(/ (+ 1.0 (exp (- x)))))
(define (sigmoid-deriv x)