Skip to content

Instantly share code, notes, and snippets.

@shoaibali
shoaibali / database-migrate.php
Created June 2, 2018 23:41
php script to migrate database from one server to another, does not work on large databases/tables
<?php
/* Credit: Copied from https://www.howtoforge.com/community/threads/php-script-to-copy-mysql-tables-from-one-server-to-another-by-database.58303/
* However fixed up for it to actually work! Also datapted it to work with Mysqli instead of Mysql deprecated library
*/
ini_set('memory_limit', '10000M'); // breaks on large databases
// old server mysql id
@shoaibali
shoaibali / _ss_environment.php
Created April 25, 2018 00:26
a template _ss_environment.php file for SS Elastic Beanstalk
// Totally open sourcing this motha fuka
define("SS_ENVIRONMENT_TYPE", $envType);
define("SS_DATABASE_SERVER", $dbServer);
define("SS_DATABASE_USERNAME", $dbUserName);
define("SS_DATABASE_PASSWORD", $dbPassword);
define("SS_DATABASE_PORT", $dbPort);
define("SS_DATABASE_CLASS", "MySQLPDODatabase");
define('SS_DATABASE_NAME', $dbName);
define('SS_DATABASE_TIMEZONE', $dbTimezone);
@shoaibali
shoaibali / _ss_environment.php
Last active March 26, 2018 04:02
To be used with buttbucket pipelines.
// Totally open sourcing this motha fuka
define("SS_ENVIRONMENT_TYPE", $envType);
define("SS_DATABASE_SERVER", $dbServer);
define("SS_DATABASE_USERNAME", $dbUserName);
define("SS_DATABASE_PASSWORD", $dbPassword);
define("SS_DATABASE_PORT", $dbPort);
define("SS_DATABASE_CLASS", "MySQLPDODatabase");
define('SS_DATABASE_NAME', $dbName);
@shoaibali
shoaibali / 0 push to talk.md
Created March 15, 2018 22:03 — forked from caseywatts/0 push to talk.md
Push To Talk - Google Meet Bookmarklet

Short link to this page: http://caseywatts.com/ptt

Other gists & tricks: http://caseywatts.com/gists-and-tricks

Push To Talk in a Google Hangout (Meet)

  1. Save this bookmarklet. Right-click on boomarks toolbar Add Page...
    • Name: PTT (push to talk) or whatever you'd like (maybe short so it stays on your bookmarks toolbar)
    • URL: (paste in the bookmarklet.js contents below)
  2. In a Meet, click on the bookmarklet
@shoaibali
shoaibali / virtualhost.sh
Created January 7, 2017 08:51
This is a shell script that automatically adds a vhost entry and /etc/hosts entry for a given project
#!/bin/bash
### Author: Shoaib Ali <shoaib@webstrike.co.nz>
### This is a shell script that automatically adds a vhost entry and /etc/hosts entry for a given project
### Usage: ./virtualhost.sh mywebsite.dev mywebsite
### Future Enhancements: SSL Support, Configuration based on Nginx/Apache2, git clone etc.
### Set default parameters
domain=$1
project=$2
rootDir='/usr/local/var/www/htdocs/'
@shoaibali
shoaibali / intersect.sql
Created June 23, 2016 20:11
INTERSECT of two tables in MySQL database File_dev and File_broken are the two tables
SELECT Filename FROM File_dev WHERE Filename NOT IN (SELECT Filename FROM File_broken);
//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated. All rights reserved.
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
function ControlVersion()
{
@shoaibali
shoaibali / gems_install_list.pl
Created May 7, 2016 12:03
convert gem list to gem install reference: https://www.krzywanski.net/archives/451
#!/usr/bin/perl -w
# We're strict
use strict;
# Get list of installed gems
my @gems = qx(gem list);
chomp(@gems);
# Create commands
@shoaibali
shoaibali / gist:1ba410bb42d8d9cff160635f7ad79efa
Created May 1, 2016 23:53
multiple versions of php on Ubuntu Xenial 16.04 down grade to php5.6 from php7
# reference1: https://by-example.org/ubuntu-16-04-xenial-downgrade-php-7-to-php-5-6/
# reference2: https://askubuntu.com/questions/761713/how-can-i-downgrade-from-php-7-to-php-5-6-on-ubuntu-16-04/761735
# reference2 (recommended)
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring php-xdebug libapache2-mod-php5.6 libapache2-mod-php7.0
@shoaibali
shoaibali / gist:e89998a01439c6fe1bc02e8a52ec7f11
Created May 1, 2016 05:19
how to see progress of mysql import gzip
zcat filename.sql.gz | pv --progress --size `gzip -l filename.sql.gz | sed -n 2p | awk '{print $2}'` --name ' Importing.. ' | mysql -uroot databasename