Skip to content

Instantly share code, notes, and snippets.

View leonlaser's full-sized avatar
🍪

Leon Dietsch leonlaser

🍪
View GitHub Profile
@leonlaser
leonlaser / remove_dangling_images
Last active October 24, 2020 14:54
[Docker helper] Handling container and images #docker #bash #sh #terminal #console
#!/bin/sh
docker rmi -f $(docker images -f "dangling=true" -q)
@leonlaser
leonlaser / replace_user_by_id
Created May 1, 2019 10:43
[Replace user by uid] #shell #unix #find #permission
#!/bin/sh
sudo find /usr/local -uid $oldUserId -exec chown $newUser {} +
@leonlaser
leonlaser / phpmd.xml
Last active January 14, 2020 10:41 — forked from dimamix/phpmd.xml
phpmd.xml example
<?xml version="1.0"?>
<ruleset>
<description>Custom ruleset for Behance code standards</description>
<!-- Rues are imported individually to allow for easy configuration -->
<!-- Property names and values can be found here: http://phpmd.org/rules/index.html -->
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
<properties>
@leonlaser
leonlaser / ideolog_pattern.txt
Last active July 12, 2024 06:32
[logfmt regex] Split your logfmt logfile into key value pairs #golang #go #regex #regularexpression #logfmt #intellij #ideolog
Message pattern: ^time="(.*)" level=([^\s]+) .*$
Message start pattern: ^time=
Time format: yyyy-MM-dd'T'HH:mm:ssXXX
Time capture group: 1
Serverity capture group: 2
Reference: https://github.com/JetBrains/ideolog/wiki/Custom-Log-Formats
@leonlaser
leonlaser / delete_old.sh
Last active November 27, 2020 09:43
[Delete files older than 30 days] #shell #bash
#/usr/bin/env bash
find ./ -type f -mtime +30 -exec rm -f {} +
@leonlaser
leonlaser / git_cleanup_branches.sh
Created July 8, 2020 08:19
[Remove merged local branches] #git #shell #branch
#/bin/env bash
git branch --merged | egrep -v "(^\*|master|develop) | xargs git branch -d
@leonlaser
leonlaser / split_text.js
Created August 20, 2020 06:21
[Split text after x chars] #javascript #regex
// Source: https://stackoverflow.com/questions/27758483/split-text-string-at-closest-space-in-javascript
// Author: https://stackoverflow.com/users/1215106/%e2%84%a6mega
// If you are interested in just the first part, then use
var a = fulltext.match(/^.{47}\w*/)
// If you want to split the entire string to multiple substrings, then use
var a = fulltext.match(/.{47}\w*|.*/g);
@leonlaser
leonlaser / docker_clean_up_none.sh
Created October 24, 2020 11:51
[Docker remove <none> images] #docker
docker images -a | grep none | awk '{print $3}' | xargs docker rmi
@leonlaser
leonlaser / cleanup.sh
Created December 10, 2020 15:12
[Local Repostiroy Cleanup] #git #cli #bash
# source: https://gitbetter.substack.com/p/how-to-clean-up-the-git-repo-and
git remote prune origin && git repack && git prune-packed && git reflog expire --expire=1.month.ago && git gc --aggressive
@leonlaser
leonlaser / fix_gitkraken_bigsur.sh
Created December 14, 2020 10:34
[Fix slow GitKraken on BigSur] #git #gitkraken #bigsur #macaos #shell
# source: https://stackoverflow.com/questions/64925749/gitkraken-is-very-slow-since-macos-big-sur-update
codesign --remove-signature /Applications/GitKraken.app/Contents/Frameworks/GitKraken\ Helper\ \(Renderer\).app