Skip to content

Instantly share code, notes, and snippets.

View SchumacherFM's full-sized avatar

Cyrill Schumacher SchumacherFM

View GitHub Profile
@SchumacherFM
SchumacherFM / .bash_profile
Last active December 4, 2023 13:07
Remove all empty values from a JSON file with CLI program jq
# removes all null, false, "", 0, [], {} and "0001-01-01T00:00:00Z values from a json
# files and writes the data back to the original file via program sponge (brew install moreutils jq)
# date time string because of GoLang empty time encoding 🙈
jsonRemoveEmpty() {
for file in *.json; do
cat "$file" | jq 'walk( if type == "object" then with_entries(select(.value != null and .value != false and .value != "" and .value != 0 and .value != [] and .value != {} and .value != "0001-01-01T00:00:00Z") ) else . end)' | sponge "$file"
done
}

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@SchumacherFM
SchumacherFM / binarySearch.go
Created December 1, 2016 19:21
Binary Search vs Loop Search
// /usr/local/go-master/libexec/bin/go test -v . -bench ^BenchmarkSearch$ -run ^$
// Loop 20000 68347.0 ns/op 0 B/op 0 allocs/op
// Binary 30000000 47.9 ns/op 0 B/op 0 allocs/op
// PASS
// ok 3.584s
package main_test
func BenchmarkSearch(b *testing.B) {
@SchumacherFM
SchumacherFM / csv.go
Created September 2, 2016 06:04
Craig Weber Streaming CSV Parser Prototype | Source https://bitbucket.org/snippets/weberc2/goEb7
package main
import (
"fmt"
"io"
"unicode/utf8"
)
type bufferedReader struct {
r io.Reader
@SchumacherFM
SchumacherFM / magento-nginx.conf
Created October 12, 2015 06:40 — forked from gwillem/magento-nginx.conf
Battle-tested Nginx configuration for Magento (source: www.hypernode.com)
# This is an annotated subset of the Nginx configuration from our Magento production platform @ www.hypernode.com
# See https://www.byte.nl/blog/magento-cacheleak-issue
user app;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
}
@SchumacherFM
SchumacherFM / Trackingnumber.php
Created May 6, 2015 08:12
Magento1: How not to load models/collections in a grid renderer. This shows a very bad example 😞. Do not use it or 🔫.
<?php
/*
@SchumacherFM: The render() method is executed in each row
*/
/**
* Product: Vendor_GridActions
* ID:
* File: app/code/local/Vendor/GridActions/Block/Adminhtml/Sales/Order/Grid/Widget/Renderer/Trackingnumber.php
/*
bolt 5000 277963 ns/op
redis 30000 48081 ns/op
pg 10000 149691 ns/op
Yes, the Bolt transactions could be batched. But so too could the PG transactions,
and the Redis work could be pipelined. And that isn't always a workable solution.
*/
import (
@SchumacherFM
SchumacherFM / db.go
Created February 15, 2015 00:13
GoLang Database SQL: Selecting an unknown amount of columns from a query. Benchmark results in db_test.go
package main
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
"log"
)
const (
@SchumacherFM
SchumacherFM / DISpeedTest.php
Created December 28, 2014 09:25
Magento2 Dependency Injection Speed Tester
<pre><?php
// call via http://mage2.dev/DISpeedTest.php
// change settings in app/etc/config.php
require('app/autoload.php');
Zend_Debug::dump(ini_get('memory_limit')); // should be > 1536MB
$start = microtime(true);
@SchumacherFM
SchumacherFM / local.xml
Last active August 29, 2015 14:08 — forked from alistairstead/local.xml
Magento local.xml skip_process_modules_updates
<?xml version="1.0"?>
<config>
<global>
<skip_process_modules_updates>1</skip_process_modules_updates>
</global>
</config>