Skip to content

Instantly share code, notes, and snippets.

View neumachen's full-sized avatar
🏠
Working from home

Kareem H neumachen

🏠
Working from home
  • Bergen, Norway
  • 19:26 (UTC -12:00)
View GitHub Profile
@neumachen
neumachen / conventional-json.go
Created April 11, 2021 01:35 — forked from Rican7/conventional-json.go
Marshal JSON in Golang using common lower-snake-case object key conventions
package main
import (
"bytes"
"encoding/json"
"fmt"
"regexp"
"time"
)
@neumachen
neumachen / cheatsheet-elasticsearch.md
Created March 5, 2021 04:01 — forked from ruanbekker/cheatsheet-elasticsearch.md
Elasticsearch Cheatsheet : Example API usage of using Elasticsearch with curl
@neumachen
neumachen / docker-image-size.sh
Created August 12, 2020 00:49 — forked from andyrbell/docker-image-size.sh
Sort docker images by size desc
#!/bin/sh
docker images --format '{{.Size}}\t{{.Repository}}\t{{.Tag}}\t{{.ID}}' | sed 's/ //' | sort -h -r | column -t
@neumachen
neumachen / sed cheatsheet
Created July 1, 2020 21:15 — forked from un33k/sed cheatsheet
magic of sed -- find and replace "text" in a string or a file
FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'

Assuming this table definition:

CREATE TABLE segments (segments_id serial PRIMARY KEY, payload jsonb);
With JSON values like this:

INSERT INTO segments (payload)
VALUES ('{
     "a": [
        {

"kind": "person",

@neumachen
neumachen / roman_numerals.rb
Created March 12, 2020 21:48 — forked from mecampbellsoup/roman_numerals.rb
Awesome roman numeral algorithm in Ruby :)
require 'pry'
# ```
# 1 => I
# 10 => X
# 7 => VII
# ```
# There is no need to be able to convert numbers larger than about 3000. (The Romans themselves didn't tend to go any higher)
@neumachen
neumachen / main.go
Created March 11, 2020 11:44 — forked from pteich/main.go
Example for using go's sync.errgroup together with signal detection signal.Notify to stop all running goroutines
package main
import (
"fmt"
"time"
"golang.org/x/sync/errgroup"
"context"
"os"
"syscall"
"os/signal"
@neumachen
neumachen / tmux.md
Created October 19, 2019 20:06 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@neumachen
neumachen / logger.py
Created October 14, 2019 14:15 — forked from impredicative/logger.py
Python json logging using structlog and stdlib logging
"""
Usage example:
from logger import get_logger
log = get_logger()
log.info('my_event', my_key1='val 1', my_key2=5, my_key3=[1, 2, 3], my_key4={'a': 1, 'b': 2})
List of metadata keys in each log message:
event
_func
@neumachen
neumachen / gist:09d9389526811bef092cc22fccccb8a3
Created August 14, 2019 19:24 — forked from kirley/gist:3913166
Setting up PostGIS for Timezone Lookup