Skip to content

Instantly share code, notes, and snippets.

View mfn's full-sized avatar

Markus Podar mfn

View GitHub Profile
@mfn
mfn / phpunit_xml_class_to_file.php
Last active March 11, 2021 15:33
Take the output of https://gist.github.com/mfn/256636242cbe8a51252ce28181a6b074 and rewrite an existing phpunit.xml to use only these test classes (mapped to files)
#!/usr/bin/env php
<?php declare(strict_types = 1);
$command = array_shift($argv);
if (3 !== count($argv)) {
echo <<<USAGE
Usage: $command path/to/composer.json path/to/phpunit.xml path/to/slice.xml > new_phpunit.xml
Based on your composer PSR-4 autoload configuration, the classes referenced
@mfn
mfn / endomondo_json2gpx.php
Last active January 9, 2021 15:45
Convert endomondo json tracking data to gpx
<?php declare(strict_types=1);
/*
Usage: php endomondo_json2gpx.php <path_to_file.json> […<path_to_other_file.json>]
The endomondo json format parsed here; only the fields actually used by this converted:
[
{"sport": "…"},
@mfn
mfn / phpunit_xml_slicer.php
Last active March 11, 2021 15:18
Feed the output of `phpunit --list-tests-xml <file.xml>` and slice it up into smaller chunks
#!/usr/bin/env php
<?php declare(strict_types = 1);
// Source: https://gist.github.com/mfn/256636242cbe8a51252ce28181a6b074
$command = array_shift($argv);
if (2 !== count($argv)) {
echo "Please provide a XML file and a slice like `$command tests.xml 2/4`\n";
@mfn
mfn / cmp404poka.html
Last active August 29, 2015 14:24
#camp404 "poker chip" code challenge: enter a number, tell the number the minimum number of chips required to represent them
<!-- challenge description:
- a given set of infinite poker chips in theses sizes: 500, 100, 50, 25, 10, 5, 2, 1
- enter a number
- tell the user the minimum number of chips necessary to represent the value
-->
<!-- initial 91 char solution ; thx to @neuling for the inspiration and @johannesnagl saving me one extra char -->
<p onclick="i=prompt();for(a of[500,100,50,25,10,5,2,1])if(e=~~(i/a))alert(e+' '+a,i%=a)">.
<!-- since it wasn't specified that spitting out 0 chips would be prohibited, another solution -->
@mfn
mfn / mysql_strip_fulltext_index.php
Last active August 29, 2015 14:07
Filters a mysql dump to remove all FULLTEXT indices and does its best to keep the SQL syntax error-free
#!/usr/bin/env php
<?php
/**
* Filters MySQL dumps to remove FULLTEXT index creation from stdin to stdout.
*
* Has logic to adjust the line *before* the FULLTEXT to not create invalid SQL.
*
* @author Markus Fischer <markus@fischer.name>
* @license Do what you want, credit but don't blame me
*/
@mfn
mfn / .tmux.conf
Created September 29, 2014 15:31
set -g default-terminal "screen-256color"
# Behave like screen; at least the stuff I use
unbind-key C-b
set-option -g prefix C-a
bind-key C-a last-window
set-window-option -g mode-keys vi
# Make window splitting more intuitive
unbind %
bind-key | split-window -h
@mfn
mfn / indent.js
Last active August 29, 2015 14:06 — forked from catearcher/indent.js
(function() {
var
someVariable = {
foo: 42
},
someString = 'Well hello there.',
someOtherVariable = {
isThisVeryConfusing: true
},
@mfn
mfn / indent.js
Last active August 29, 2015 14:06 — forked from catearcher/indent.js
(function() {
var someVariable = {
foo: 42
},
someString = 'Well hello there.',
someOtherVariable = {
isThisVeryConfusing: true
},
// okay, please imagine 200 more lines of more declarations here
@mfn
mfn / redis.diff
Created September 30, 2013 19:02
Primitive patch against logstash 1.2.1 to fight utf-8 encoding problems from logfiles you can't control
diff --git a/lib/logstash/outputs/redis.rb b/lib/logstash/outputs/redis.rb
index 7aab4f2..cb5c4aa 100644
--- a/lib/logstash/outputs/redis.rb
+++ b/lib/logstash/outputs/redis.rb
@@ -148,10 +148,11 @@ class LogStash::Outputs::Redis < LogStash::Outputs::Base
# if they fail to convert properly.
begin
payload = event.to_json
- rescue Encoding::UndefinedConversionError, ArgumentError
+ rescue Exception => e
@mfn
mfn / Elite_Matrix.icls
Last active October 2, 2020 09:39
PhpStorm Elite Matrix editor color scheme
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="Elite_Matrix" version="124" parent_scheme="Default">
<option name="LINE_SPACING" value="1.0" />
<option name="EDITOR_FONT_SIZE" value="14" />
<option name="CONSOLE_FONT_NAME" value="Monospaced" />
<option name="CONSOLE_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Consolas" />
<colors>
<option name="CARET_COLOR" value="db33" />
<option name="CARET_ROW_COLOR" value="90" />