Skip to content

Instantly share code, notes, and snippets.

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

Sven Hennessen sventropy

🏠
Working from home
View GitHub Profile
@sventropy
sventropy / move-git-subfolder-to-other-repo-with-history.sh
Created November 22, 2022 12:44
Move sub-folder of a git repository to other folder of new git repository without losing the history.
# In case multiple folders must be moved, repeat steps per folder
git clone <old-repo> old-repo-temp # clone old repo in temp folder
python3 git-filter-repo.py --path <target-dir>/ # filter down to one sub-path, e.g. src/<my-project>
python3 git-filter-repo.py --path-rename <from-dir>/:<to-dir>/ # move sub-path to new place in new repository folder struture
git remote add newrepo <url> # add new repo as remote
git checkout -b <branch-name> # branch to working branch
git fetch newrepo # fetch all info from new repo remote
git merge newrepo/main --allow-unrelated-histories # merge current state of new repo into working branch
git push newrepo <branch-name> # push merged state to new repo remote
@sventropy
sventropy / standard_bottom_sheet.dart
Last active May 24, 2021 07:29
Material Design standard bottom sheet built in Flutter
import 'package:flutter/material.dart';
import 'package:flutter/physics.dart';
const double kMinimumDragDistanceThreshold = 8.0;
const double kMinimumDragCollapseDistance = 52.0;
abstract class StandardBottomSheetListener {
expandUpdated(bool isExpanded);
}
@sventropy
sventropy / rename-images-exif-createdate.sh
Created January 8, 2020 18:43
Rename all pictures in a folder according to their #EXIF Create Date
exiftool "-FileName<CreateDate" -d "%Y%m%d_%H%M%S.%%e" $1
@sventropy
sventropy / fix-json-trailing-commas.ts
Last active August 2, 2019 04:04
TypeScript: Remove trailing commas in JSON
private fixJson(json: string) {
/*
/(.*?),\s*(\}|])/g
1st Capturing Group (.*?)
.*? matches any character (except for line terminators)
*? Quantifier — Matches between zero and unlimited times, as few times as possible, expanding as needed (lazy)
, matches the character , literally (case sensitive)
\s* matches any whitespace character (equal to [\r\n\t\f\v ])
* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)