Skip to content

Instantly share code, notes, and snippets.

View kpeu3i's full-sized avatar
🕶️

Andrii kpeu3i

🕶️
View GitHub Profile
@gadelkareem
gadelkareem / Hash.go
Created March 9, 2018 06:37
Hash model values to enable partial update for the ORM
package main
import (
"strings"
"reflect"
"github.com/mitchellh/hashstructure"
"fmt"
)
type Hash struct {
@subfuzion
subfuzion / Makefile.md
Last active January 9, 2025 21:50
Makefile for Go projects

Go has excellent build tools that mitigate the need for using make. For example, go install won't update the target unless it's older than the source files.

However, a Makefile can be convenient for wrapping Go commands with specific build targets that simplify usage on the command line. Since most of the targets are "phony", it's up to you to weigh the pros and cons of having a dependency on make versus using a shell script. For the simplicity of being able to specify targets that can be chained and can take advantage of make's chained targets,

@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@klmr
klmr / Makefile
Last active July 30, 2025 14:29
Self-documenting makefiles
# Example makefile with some dummy rules
.PHONY: all
## Make ALL the things; this includes: building the target, testing it, and
## deploying to server.
all: test deploy
.PHONY: build
# No documentation; target will be omitted from help display
build:
@nivv
nivv / PHP 7 - Installing imagick on Ubuntu 14.04.md
Last active May 26, 2025 08:41
Guide - Enable imagick on PHP7

Guide

Note The extension Imagick is now included in Ondrej's PPA. All you need to do now is $ sudo apt-get install php-imagick, and you're done. I'll keep the guide here because a lot of it is still true for other extensions

======

I've installed PHP7 via Ondrej's PPA. He maintains these PPA's on his free time, consider donating

Install dependencies

@smileart
smileart / db_backup.sh
Last active November 2, 2015 16:35
MySQL DB backup script
#! /usr/bin/env bash
PRESERVE_FILES_COUNT=3
ARCHIVE_EXTENSION='.sql.bz2'
if [ ! -z $1 ] && [ ! -z $2 ] && [ ! -z $3 ] && [ ! -z $4 ]; then
backup_dir=$1
db_user=$2
db_pass=$3
db_name=$4
archive_name="$(date +\%m\%d\%Y-\%H\%M\%S)_$db_name.sql.bz2"
@squarism
squarism / iterm2.md
Last active October 15, 2025 21:48
An iTerm2 Cheatsheet

In the below keyboard shortcuts, I use the capital letters for reading clarity but this does not imply shift, if shift is needed, I will say shift. So + D does not mean hold shift. + Shift + D does of course.

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
@patik
patik / how-to-squash-commits-in-git.md
Last active October 13, 2025 09:47
How to squash commits in git

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

@smileart
smileart / ini_edit
Last active January 2, 2022 14:36
A little bash functions set to work with *.ini files
#!/usr/bin/env bash
# param_1: string | param_2: file
is_option_in_file () {
if [[ ! -z "$1" && ! -z "$2" ]]; then
egrep -q "$1" "$2"
if [[ $? = '0' ]]
then
echo '1'
@rcmachado
rcmachado / Makefile
Last active September 28, 2024 13:29
Add a help target to a Makefile that will allow all targets to be self documenting
.SILENT:
.PHONY: help
# Based on https://gist.github.com/prwhite/8168133#comment-1313022
## This help screen
help:
printf "Available targets\n\n"
awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \