Skip to content

Instantly share code, notes, and snippets.

View shahzaibalikhan's full-sized avatar

Shahzaib Ali Khan shahzaibalikhan

  • Berlin, Germany
View GitHub Profile
@shahzaibalikhan
shahzaibalikhan / awkings.md
Last active May 15, 2020 12:54
Using AWK to dissect ELB logs

Take slice of logs by time

zgrep 'T18:' -r $PWD >> /tmp/logs

Print logs (time, request_url, elb status, target_status)

awk '{print $2 "\t" $14 "\t" $9 "\t" $10}' /tmp/logs

Filter logs by 5XX status of ELB

@shahzaibalikhan
shahzaibalikhan / 00-about-search-api-examples.md
Created July 28, 2016 05:38 — forked from jasonrudolph/00-about-search-api-examples.md
5 entertaining things you can find with the GitHub Search API
@shahzaibalikhan
shahzaibalikhan / redis-server.service
Created May 10, 2016 06:23 — forked from geschke/redis-server.service
Ubuntu systemd service file for Redis. The server was updated to a Ubuntu 15.04 (Vivid Vervet) distribution. Redis was installed from the PPA from Roman Wookey (https://launchpad.net/~rwky/+archive/ubuntu/redis). After the switch to systemd instead of Upstart, Redis was not started by default. So I've hacked the following systemd config file. It…
[Unit]
Description=Redis Datastore Server
After=network.target
[Service]
Type=forking
PIDFile=/var/run/redis/redis.pid
ExecStartPre=/bin/mkdir -p /var/run/redis
ExecStartPre=/bin/chown redis:redis /var/run/redis
@shahzaibalikhan
shahzaibalikhan / redis.markdown
Created May 9, 2016 06:50 — forked from bdotdub/redis.markdown
Running redis using upstart on Ubuntu

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
setuid ubuntu
chdir /opt/myAplicacion
env PORT=3000
description "Server Name
author "author"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
respawn
exec sudo -u ubuntu sh -c "NODE_ENV=production node /var/sites/stuff/app.js >> /var/log/stuff.log 2>&1"
@shahzaibalikhan
shahzaibalikhan / README.md
Created May 2, 2016 21:12 — forked from toadkicker/README.md
The Perfect Nginx / Node Server

The Perfect Node / Nginx Server

  • Ubuntu 14.10 64 bit
  • Node 0.10.x from source
  • Nginx from source with SPDY & Pagespeed support

Assumes you're doing everything under /home/ubuntu

OS configuration

@shahzaibalikhan
shahzaibalikhan / fooapp.service
Created May 2, 2016 21:04 — forked from DeadAlready/fooapp.service
Systemd configuration file
[Unit]
Description=Our cool Node.js App
After=network.target
[Service]
Type=forking
Restart=always
User=fooapp
ExecStart=/var/appdata/fooapp/node_modules/pm2/bin/pm2 start /var/appdata/fooapp/app.js
ExecStop=/var/appdata/fooapp/node_modules/pm2/bin/pm2 stop /var/appdata/fooapp/app.js
@shahzaibalikhan
shahzaibalikhan / mutationObserver.js
Created April 16, 2016 17:01
HTML nodes mutation observer
var container = document.querySelector('body');
var observer = new MutationObserver(function(mutations){
// Do something here
mutations.forEach(function(mutation) {
console.log('mutation.type = ' + mutation.type);
for (var i = 0; i < mutation.addedNodes.length; i++) {
console.log(' "' + mutation.addedNodes[i].textContent + '" added');
}
@shahzaibalikhan
shahzaibalikhan / .bashrc
Created March 29, 2016 09:49
General Linux .bashrc
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
xhost +local:root > /dev/null 2>&1
complete -cf sudo
shopt -s cdspell
shopt -s checkwinsize