Skip to content

Instantly share code, notes, and snippets.

@waleedsamy
waleedsamy / Dockerfile
Created October 13, 2017 11:27
Run docker inside Jenkins container
From jenkins
USER root
RUN apt-get update && apt-get install -y vim nano zsh curl git sudo
@waleedsamy
waleedsamy / artist.sh
Created October 2, 2017 14:38
update my mp3's to have only the artist information
l=Bob\ Marley
d=/songs/$l
find "$d" -type f -iname "*.mp3" -exec ls '{}' +
find "$d" -type f -iname "*.mp3" -exec mid3v2 -D '{}' +
find "$d" -type f -iname "*.mp3" -exec mid3v2 --delete-frames=TALB,TCON,TPE1,TDRC,TIT2,AENC,ASPI,COMM,COMR,ENCR,EQU2,ETCO,GEOB,GRID,LINK,MCDI,MLLT,OWNE,PRIV,PCNT,POPM,POSS,RBUF,RVA2,RVRB,SEEK,SIGN,SYLT,SYTC,TBPM,TCOM,TCOP,TDEN,TDLY,TDOR,TDRL,TDTG,TENC,TEXT,TFLT,TIPL,TIT3,TKEY,TLAN,TLEN,TMCL,TMED,TMOO,TOAL,TOFN,TOLY,TOPE,TOWN,TPE3,TPE4,TPOS,TPRO,TPUB,TRSN,TRSO,TSOA,TSOP,TSOT,TSRC,TSSE,TSST,TXXX,UFID,USER,USLT,WCOM,WCOP,WOAF,WOAR,WOAS,WORS,WPAY,WPUB,WXXX '{}' +
find "$d" -type f -iname "*.mp3" -exec mid3v2 -l '{}' +
find "$d" -type f -iname "*.mp3" -exec id3tag --artist="$l" '{}' +
@waleedsamy
waleedsamy / bindasync.js
Created August 8, 2017 15:28
why bind async.js? because I can.
const async = require('async');
let ob = {
'x': 8,
'y': 16
}
function ci(callback) {
console.log('ci', this.x, this.y);
callback(null, 'berlin')
@waleedsamy
waleedsamy / git worktree
Created August 3, 2017 08:16
Run test for your project and continue working on the code in same time
git worktree add -b run-test-for-fix-bug-x ../fix-bug-x origin/fix-bug-x
rm -rf ../fix-bug-x && git worktree prune
@waleedsamy
waleedsamy / Function.scala
Created August 1, 2017 13:39
Function and PartialFunction Scala classes
// func1 and func2 are synonyms
val func1 = (x: String) => "hello %s".format(x)
func1("world")
func1.apply("world")
val func2 = new Function1[String, String] {
def apply(x: String) = "hello %s".format(x)
}
func2("world")
func2.apply("world")
@waleedsamy
waleedsamy / rollout.sh
Created July 25, 2017 18:45
kubernetes rollout command in nutshell
#record revision with clear information
kubectl create -f xDeployment.yaml --record
# interactive command to get the status for a deployment, you can check it's result with $?
kubectl rollout status deploy/x
# show revisions
kubectl rollout history deploy/x
# details about revision 1
kubectl rollout history deploy/x --revision 1
#rollback to to previous version
kubectl rollout undo deploy/x
@waleedsamy
waleedsamy / grepchars
Created July 13, 2017 13:54
grep with 1 character before string and 6 character after
grep -E -o ".{0,1}string.{0,6}" afile
@waleedsamy
waleedsamy / find-git-object-sizes.sh
Created July 3, 2017 13:55
find which files have the biggest size in git repo
# https://stackoverflow.com/a/42544963/5318264
brew install coreutils findutils gnu-tar gnu-sed gawk gnutls gnu-indent gnu-getopt
git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
| awk '/^blob/ {print substr($0,6)}' \
| sort --numeric-sort --key=2 \
| gcut --complement --characters=8-40 \
| gnumfmt --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
@waleedsamy
waleedsamy / Run docker 1.9.1 on aws ec2 ubuntu 16.4 instance
Created June 22, 2017 13:44
Run docker 1.9.1 on aws ec2 ubuntu 16.4 instance
<p><a href="https://asciinema.org/a/14"><img src="https://asciinema.org/a/14.png" alt="asciicast" title=""></a></p>
<h5 id="download-docker-binary">Download docker binary</h5>
<p><code>bash <br>
ssh ubuntu@ec2-54-154-81-176.eu-west-1.compute.amazonaws.com <br>
sudo su - &amp;&amp; <br>
wget https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 &amp;&amp; <br>
chmod +x docker-1.9.1 <br>
mv ./docker-1.9.1 /usr/bin/docker <br>

Keybase proof

I hereby claim:

  • I am waleedsamy on github.
  • I am waleedsamy (https://keybase.io/waleedsamy) on keybase.
  • I have a public key ASAWXFhRpUySgDNxVAXdZKCz9RbYLHNfBhCe11kNYh1XFwo

To claim this, I am signing this object: