Skip to content

Instantly share code, notes, and snippets.

View aa21's full-sized avatar

Alex Arul aa21

  • Hatcher, Blk 71
  • singapore
View GitHub Profile
@aa21
aa21 / MySql - Index all columns
Last active August 29, 2015 14:10
Bruteforce. Index all the columns in all tables of a db.
-- Bruteforce. Index all the columns in all tables of a db.
-- Find the data types
-- select distinct data_type from information_schema.columns where table_schema="DATABASE";
select
concat( "ALTER TABLE `DATABASE`.`", table_name , "` ADD INDEX ( `",column_name ,"` );" )
from information_schema.columns where table_schema='DATABASE' and
data_type not in ('text', 'longtext', 'mediumtext','tinytext' );
//source: http://www.toao.net/48-replacing-smart-quotes-and-em-dashes-in-mysql
//By Mango, March 5th, 2009
//clean charset
function c($text){
// First, replace UTF-8 characters.
$text = str_replace(
array("\xe2\x80\x98", "\xe2\x80\x99", "\xe2\x80\x9c", "\xe2\x80\x9d", "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x80\xa6"),
array("'", "'", '"', '"', '-', '--', '...'),
$text
@aa21
aa21 / HTML - Mobile - Prevent page scaling
Last active August 29, 2015 14:19
Meta, Tell Mobile Browser: don't scale this page!
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0 maximum-scale=1.0" />
@aa21
aa21 / SEC - common passwords
Last active March 27, 2019 16:04
Common Passwords & Usernames
password
123456
12345678
1234
qwerty
12345
dragon
pussy
baseball
football
<?php
error_reporting(-1); // reports all errors
ini_set("display_errors", "1"); // shows all errors
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
?>
@aa21
aa21 / Debian 8 new setup
Last active August 29, 2015 14:20
Common setup for new Debian 8
apt-get update
#lamp
apt-get install apache2 mysql-server
mysql_secure_installation
apt-get install php5 php-pear php5-mysql git vim locate
updatedb
vim /etc/vim/vimrc
syntax on
@aa21
aa21 / PHP - MySql - Dynamic Table Columns
Last active January 23, 2018 03:38
Create table columns on the fly on a mysql db
<?php
$conn = mysqli_connect($ht, $ur, $pd);
mysqli_select_db($conn, $db);
//foreach req, check if the column exists, otherwise create it
foreach($_POST as $k => $v){
$key = trim(mysqli_real_escape_string($conn, $k));
@aa21
aa21 / MySql - tuning
Last active August 29, 2015 14:27
Mysql tuning
mysqltuner.pl
https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
tuning primer sh
http://www.day32.com/MySQL/tuning-primer.sh
calculator
http://www.mysqlcalculator.com/
@aa21
aa21 / Bash_commands_etc.sh
Last active May 3, 2016 08:24
Bash Commands & tricks
###### ~/.bash_profile ######
alias a='vim ~/.bash_profile && source ~/.bash_profile'
alias gpp='git pull && git push'
# FIND PROCESS
function p(){
ps aux | grep -i $1 | grep -v grep
}
If frontpage:
https://ecommerce.shopify.com/c/ecommerce-design/t/if-home-variable-5824