Skip to content

Instantly share code, notes, and snippets.

@evaletolab
Last active April 20, 2019 09:13
Show Gist options
  • Save evaletolab/4946d2b50f387c3393a6 to your computer and use it in GitHub Desktop.
Save evaletolab/4946d2b50f387c3393a6 to your computer and use it in GitHub Desktop.

Apt

  • find package that belong to file dpkg -S /path/to/file

bash Net

  • find application that listen port 4200 lsof -i :4200

bash replace txt

sed -i -- 's/foo/bar/g' directory/*
find . -type f -exec sed -i 's/foo/bar/g' {} +

CPU

echo powersave | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

Git

git branch --no-merged
git branch --merged
git branch -D <name>
git reset --hard origin/<branch>  # then local branch is identical to origin/branch
git stash show "stash@{0}" -p > name.patch
git apply name.patch
  • changer les messages dans l'historique (le 8 indique le nb de commits)
git log --pretty=format:"%h %s" HEAD~8..HEAD
git rebase -i HEAD~8
>ici il faut modifier les lignes qu\'on souhaite éditer: pick=>edit, ensuite on sauve
git commit --amend
git rebase --continue

Stash (push/pop current changes)

git stash
git checkout other-branch
git stash pop

Squashing a commit means combining two or more commits into one.

Stashing

Consider using git stash to temporarily store uncommitted work. So, for example, if I find myself working on the wrong branch - I may run the following sequence of commands.

git stash
git checkout <correct_branch>
git stash apply

Undo

git reflog
0cf1172 HEAD@{0}: commit: new version 08.2016
e6737c2 HEAD@{1}: commit: new release, optimise product rendering
10e2192 HEAD@{2}: checkout: moving from select_products_by_date to develop

If the commit you want to get rid of was the last commit, and you have not done any additional work you can simply use,

git reset HEAD~1
git reset HEAD^2
git reset --hard|--soft HEAD~1
  • ~2 means up two levels in the hierarchy, via the first parent if a commit has more than one parent
  • ^2 means the second parent where a commit has more than one parent (i.e. because it's a merge)
  • --hard , --soft explanation, http://stackoverflow.com/a/3528483/680373

video

ffmpeg -i in.avi -vcodec copy -acodec copy -ss 01:06:13 -t 00:01:03 out.avi

mongo

dump

mongodump -h <host>:27017 -d <db> -u <user> -p <password> -o path/to/

restore

mongorestore (--drop) -h <host>:27017 -d <db> -u <user> -p <password> karibou-prod/

Youtube dowload (Arte)

sudo curl -L https://yt-dl.org/latest/youtube-dl -o /usr/bin/youtube-dl`
youtube-dl -F https://www.arte.tv/fr/videos/071465-002-A/aux-origines-des-civilisations-2-4/
youtube-dl -f HTTPS_EQ_1 https://www.arte.tv/fr/videos/071465-002-A/aux-origines-des-civilisations-2-4/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment