Skip to content

Instantly share code, notes, and snippets.

@shoaibali
shoaibali / select.js
Created May 9, 2013 01:59
select first option from all drop downs on any form. Requires jQuery pre loaded
$('select').prop('selectedIndex',1);
@shoaibali
shoaibali / watch.sh
Last active December 25, 2015 23:19
#!/bin/bash
# Written by Shoaib Ali hacker.nz@gmail.com
# Paid by your tax money
# This script watches a site for changes by creating a md5 hash of it, if that hash changes means site/url is changed
# then it sends a notification via twitter. see twitter.sh
status=""
url=$1
keyword=$2
original_hash=`curl -s --compress --user-agent "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.0 Safari/537.36" $url | openssl md5 | cut -d' ' -f2`
@shoaibali
shoaibali / .bash_profile
Created August 10, 2014 22:24
colorise terminal shell showing git branch
parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
parse_git_tag () {
git describe --tags 2> /dev/null
}
parse_git_branch_or_tag() {
local OUT="$(parse_git_branch)"
@shoaibali
shoaibali / spam.sh
Created September 4, 2014 03:51
remove spam from mailq
mailq|fgrep spammer@spam.com|sed 's/\*.*//' | awk '{print $1}' | postsuper -d -
/* This is a quick jquery hack to click all the Delete action on SilverStripe GridField. Need topen up Console in browser using F12 and paste this in */
jQuery("[title=Delete]").each(function() { jQuery(this).click(); });
@shoaibali
shoaibali / notes
Created November 28, 2014 01:27
SimpleSAMLphp NOSTATE error hyperlinks in Microsoft Office Word
Just put this in the .htaccess or apache2 configuration virtual host entry, just below alias /simplesaml
RewriteCond %{HTTP_USER_AGENT} ms-office [NC]
RewriteRule ^/(.*) $1 [R=301,L,QSA]
RewriteCond %{HTTP_USER_AGENT} OfficeLiveConnector [NC]
RewriteRule ^/(.*) $1 [R=301,L,QSA]
@shoaibali
shoaibali / backup.sh
Created February 26, 2015 04:26
mysql all database backup
#!/bin/bash
# Simple script to backup MySQL databases
# Parent backup directory
backup_parent_dir="/var/backups/mysql"
# MySQL settings
mysql_user="root"
mysql_password="******"
# Disclaimer - Please don't just execute it blindly, this was ran on Ubuntu 14.04.2 LTS
# I am not responsible for whatever harm this shell script may cause.
# Look at the wget requests in the shell script to make sure you are putting in configuration
# files as they should be.
# Many commands are run as sudo and permissions are changed to www-data etc
# The existing user whose running this shell script also becomes part of www-data user group
# Files downlaoded for this shell script to work - example configuration files
# 1. nginx default sites-available config
# 2. php5-fpm to listen on 9000
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
server {
listen 80;
listen 127.0.0.1:443 ssl;
root /sites/deploynaut/www;
server_name mgmt 127.0.0.1;
; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[www]
; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'