Skip to content

Instantly share code, notes, and snippets.

View shoaibi's full-sized avatar

Shoaibi shoaibi

View GitHub Profile
@shoaibi
shoaibi / .bash_pfm
Last active January 10, 2017 15:29
#export COMPOSE_FILE="docker-compose.yml:docker-compose.vbe.yml"
alias b='brew'
alias bs='brew services'
alias bsr='bs restart'
alias bssr='bs start'
alias bsst='bs stop'
alias bsl='bs list'
alias bupt='b update'
alias bupg='b upgrade'
alias bup='bupt; bupg'
@shoaibi
shoaibi / sublime-cli.sh
Created October 28, 2016 07:20
Opening files in sublime from terminal in macosx
ln -s /Applications/Sublime\ Text\.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime
@shoaibi
shoaibi / fix-docker-symfony-exception-source-urls.sh
Last active September 28, 2016 14:41
Making the file links work on symfony exception pages with docker
# the first 2 steps are needed if the project dir inside container is inside /home.
sudo vi "+g/^\/home/s/\//#\//" "+x" /etc/auto_master
diskutil umount /home
sudo ln -s ~/Path/to/projects/on/host /path/to/projects/inside/docker/container
# say:
# sudo ln -s ~/projects/company/ /home/www-data
@shoaibi
shoaibi / docker-sync-unison-fix.sh
Created August 31, 2016 18:29
Fixing docker-sync's unison error about "cannot add a watcher: system limit reached"
sudo sysctl -w kern.maxfilesperproc=524288
sudo sysctl -w kern.maxfiles=524288
ulimit -n 524288
docker run --rm --privileged --entrypoint sysctl eugenmayer/unison:unox -w fs.inotify.max_user_watches=524288
@shoaibi
shoaibi / Dockerfile.cleanup
Created August 19, 2016 19:26
Reducing Docker alpine container size
find /usr/local \
\( -type d -a -name test -o -name tests \) \
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
-exec rm -rf '{}' + \
&& runDeps="$( \
scanelf --needed --nobanner --recursive /usr/local \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
@shoaibi
shoaibi / HTTP-Cache.md
Last active December 13, 2015 16:36
Few notes regarding how to work with HTTP Cache

General

  • Works only for safe HTTP methods, say like GET and HEAD, methods that shouldn't mutate application state.

Places where caching can occur

  • Browser (private and public)
  • Proxy (public)
  • Gateway/Reverse Proxy (public)

Caching Strategy

@shoaibi
shoaibi / LevelDb-notes.md
Created October 17, 2015 05:47
LevelDb notes

LevelDb

Features

  • embedded
  • light weight
  • thread safe
  • fast
  • good compression
  • arbitrary byte arrays
  • sorted by keys
@shoaibi
shoaibi / MongoDb-notes.md
Last active October 14, 2015 14:41
MongoDb notes

MongoDb

  • Dynamic schema, not schema-free.
  • Database
    • Collection
      • Document
        • Field

BSON

@shoaibi
shoaibi / Redis-notes.md
Last active October 13, 2015 04:03
Redis notes

#Redis

  • Binary Safe Strings
  • More than just a kv store
  • Most insert commands are variadic

Keys

  • Bit arrays so could be nice and shiny strings like app:user:group or binary data from png.
  • Long keys aren't a good idea
  • Keys are like urls and hence should be readable and pretty
@shoaibi
shoaibi / jira-ticket-title-to-gitflow-branch.sh
Created September 3, 2015 10:36
A simple script script to generate a git-flow like branch name and check it out
#!/bin/bash
# Change this to your name initials
user_initials="ms"
E_BADARGS=65
if [ $# -lt 1 -a $# -gt 3 ]; then
>&2 echo "Usage: $0 jira_ticket_title [ticket_type_or_branch_prefix=feature] [checkout=1]"
exit $E_BADARGS
fi