Skip to content

Instantly share code, notes, and snippets.

@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:

@waleedsamy
waleedsamy / gpg.fingerprint
Last active May 11, 2018 13:55
GPG for file crypting, tag signing and email using 0x680b460f9694e494
3F9E 6349 5EA4 53A8 FF26 FDCD 680B 460F 9694 E494
class Main{
public static void main(String[] args){
print1ToXWithRecursion(100);
}
public static void print1ToXWithRecursion(int num){
if(num > 1)
print1ToXWithRecursion(num -1 );
System.out.println(num);
}
@waleedsamy
waleedsamy / StringItr.scala
Created April 17, 2017 21:22
String Iterator impl
abstract class AbsIterator{
type T
def hasNext:Boolean
def next: T
}
trait RichItr extends AbsIterator{
def foreach(f: T => Unit) = while (hasNext) f(next)
}
@waleedsamy
waleedsamy / flatten.js
Created April 10, 2017 21:55
flatten [1, [2], 3, [4, 5, [6, 7, [8, 9, 10]]]] => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
const flatten = arr => arr.reduce(
(acc, val) => acc.concat(Array.isArray(val) ? flatten(val) : val), []
);
module.exports = {
flatten: flatten
}
// let list = [1, [2], 3, [4, 5, [6, 7, [8, 9, 10]]]]
// console.log(flatten(list));
@waleedsamy
waleedsamy / nxfetch.sh
Last active April 4, 2017 08:42
This script will fetch an artifact from a Nexus server(or any other repository) using maven.
#!/bin/bash
# Argument = -h -v -i groupId:artifactId:version -c classifier -p packaging
#shopt -o -s xtrace
usage()
{
cat <<EOF
usage: $0 options
This script will fetch an artifact from a Nexus server using maven, please make sure maven 3 is installed.