Skip to content

Instantly share code, notes, and snippets.

View madflow's full-sized avatar

madflow madflow

  • QOSSMIC
  • Cologne, Germany
View GitHub Profile
@madflow
madflow / testing_init.go
Created June 25, 2024 07:01
Go Testing Init
package testing
import (
"os"
"path"
"runtime"
)
func init() {
_, filename, _, _ := runtime.Caller(0)
@madflow
madflow / Makefile
Created June 16, 2024 18:16
Makefile for a Go project
# Makefile for a Go project
# Binary output name
BINARY_NAME=hallo-welt
# Default make command
all: help
# Build the binary
build:
@madflow
madflow / sort_script.jq
Created June 3, 2024 15:24 — forked from rockydd/sort_script.jq
A jq script for comprehensive sorting of JSON objects. It recursively sorts keys in objects, orders arrays by simple types, and sorts arrays of objects by 'name' or 'id'. Ideal for standardizing complex JSON structures for APIs, configurations, or data processing. Usage: jq -f sort_script.jq input.json with input.json as your target JSON file.
def recursive_sort:
if type == "object" then
to_entries
| sort_by(.key)
| map( {key: .key, value: (.value | recursive_sort)} )
| from_entries
elif type == "array" then
map( if type == "object" or type == "array" then . | recursive_sort else . end )
| if length == 0 or (first | type) != "object" then
sort
@madflow
madflow / file.log
Created September 6, 2019 11:46
Android Log Stream
09-06 13:35:02.189 D/LclPlaybackSvcMPlayer(26399): getPosition() -> 2933962
09-06 13:35:02.190 D/PlaybackService(26399): Saving current position to 2933962
09-06 13:35:02.914 W/UsageStatsService(1378): Event reported without a package name
09-06 13:35:02.920 D/StatusBar(1898): disable<e i a s b h r c s > disable2<q i n >
09-06 13:35:02.941 V/chatty (1898): uid=10023(com.android.systemui) identical 2 lines
09-06 13:35:02.942 D/StatusBar(1898): disable<e i a s b h r c s > disable2<q i n >
09-06 13:35:03.115 D/StatusBar(1898): disable<e i a s b H!R!c s > disable2<q i n >
09-06 13:35:07.195 D/LclPlaybackSvcMPlayer(26399): getPosition() -> 2938925
09-06 13:35:07.198 D/PlaybackService(26399): Saving current position to 2938925
09-06 13:35:11.135 I/noeh.antennapo(26399): Background concurrent copying GC freed 4358(4MB) AllocSpace objects, 0(0B) LOS objects, 50% free, 5MB/10MB, paused 318us total 102.345ms
@madflow
madflow / Dockerfile
Last active October 2, 2017 07:27
Quick and dirty php-cs-fixer
FROM php:5.6-alpine
RUN apk update --no-cache \
&& apk add --no-cache tini \
&& rm -rf /var/cache/apk/* /var/tmp/* /tmp/*
ENV COMPOSER_HOME /composer
ENV COMPOSER_ALLOW_SUPERUSER 1
RUN echo "memory_limit=-1" > $PHP_INI_DIR/conf.d/memory-limit.ini
<?php
require_once __DIR__.'/vendor/autoload.php';
use Box\Spout\Writer\WriterFactory;
use Box\Spout\Reader\ReaderFactory;
$testData = [
['Hi', 'There', ''],
[null, null, null],
@madflow
madflow / spout_test_bg_colors.php
Created August 6, 2016 14:05
Test BG colors in spout
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Box\Spout\Writer\Style\StyleBuilder;
use Box\Spout\Writer\WriterFactory;
use Box\Spout\Common\Type;
use Box\Spout\Writer\Style\Color;
use Box\Spout\Reader\Wrapper\XMLReader;
<?php
require_once __DIR__.'/vendor/autoload.php';
use Box\Spout\Writer\WriterFactory;
use Box\Spout\Reader\ReaderFactory;
use Box\Spout\Common\Type;
$rows = 2000;
$columns = 50;
local ret_status="%(?:%{$fg_bold[green]%}%{$fg_bold[green]%}%m%{$reset_color%} ➜:%{$fg_bold[red]%}➜ )"
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
@madflow
madflow / sauce_connect_setup.sh
Last active December 13, 2015 10:23 — forked from santiycr/sauce_connect_setup.sh
A small bash script to download and start Sauce Connect as part of a Travis Build.
#!/bin/bash
# Setup and start Sauce Connect for your Codeship Build
CONNECT_URL="http://saucelabs.com/downloads/Sauce-Connect-latest.zip"
CONNECT_DIR="/tmp/sauce-connect-$RANDOM"
CONNECT_DOWNLOAD="Sauce_Connect.zip"
READY_FILE="connect-ready-$RANDOM"
# Get Connect and start it