Skip to content

Instantly share code, notes, and snippets.

View adsr303's full-sized avatar

Artur de Sousa Rocha adsr303

  • Kraków, Poland
View GitHub Profile
@adsr303
adsr303 / bool_yn.go
Created March 6, 2024 21:12
Custom Go bool type with marshaling to Y/N
package main
import (
"encoding/xml"
"fmt"
)
type BoolYN bool
func (b BoolYN) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
@adsr303
adsr303 / rangefunc.go
Last active February 24, 2024 19:08
Minimal example of Go 1.22 experimental rangefunc
package main
import "fmt"
func minimalIncomplete(yield func(int, string) bool) {
for i := range 9 {
// If yield returns false because of break/return and we don't check,
// the calling range loop will panic.
yield(i, fmt.Sprintf("==%d==", i))
}
@adsr303
adsr303 / docker-network.md
Last active August 8, 2019 22:11
Connect two Docker containers using networking

Connect two Docker containers using network

Oversimplified HOWTO based on the Docker networking tutorial.

Create a user-defined bridge network

docker network create --driver bridge redis-net
@adsr303
adsr303 / gimp-whiteboard.md
Last active September 29, 2023 14:56
Clean-up a whiteboard photo with GIMP

How to clean up a whiteboard photo using GIMP

Skipping other possible actions, such as perspective corrections, here is how:

  1. Duplicate the base image layer.
  2. Set the new layer's mode to "Divide".
  3. Apply a Gaussian blur with a radius of about 50 (Filters/Blur/Gaussian Blur...).

If you need to manipulate the resulting image further, create a new layer from visible (Layer/New from Visible).

# Transliterate Unicode to ASCII
print(unicodedata.normalize('NFKD', 'bździągwa').encode('ascii', 'ignore').decode())
[alias]
tree = log --graph --color --decorate --format=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all
@adsr303
adsr303 / uniqpath.awk
Created April 28, 2015 12:49
Remove duplicate entries in UNIX path. Keeps the order of first occurences.
#!/usr/bin/awk -f
BEGIN {
RS = ":|\n"
}
{
if (data[$0]++ == 0)
lines[++count] = $0
}
@adsr303
adsr303 / contrast_mask.sh
Last active April 7, 2016 10:52
Complex image operations using ImageMagick
#!/bin/bash
convert "$1" \( +clone -colorspace gray -negate -blur 0x300 \) \
-compose softlight -composite "$2"
#!/usr/bin/env python
import collections
import os
import sqlite3
import struct
LENSFUN_PARAM_NAMES = """
modify_flags
# Extract full-size previews from Nikon raw files
# Replace '-w' with '-w!' to overwrite existing files
exiftool -JpgFromRaw -b -w %d%f.JPG -ext NEF -r directory-or-files
# Copy all tags from raw to JPEG files (best used after above)
# Use the '-overwrite_original' option to skip backup files
exiftool -tagsfromfile %d%f.NEF -ext JPG -r directory-or-files
# Both operations in one command
# -w without format codes is treated as extension