Skip to content

Instantly share code, notes, and snippets.

View anytizer's full-sized avatar

Bimal Poudel anytizer

View GitHub Profile
@anytizer
anytizer / database-backup.sh
Created December 25, 2013 09:38
Hassle free database dump: Trick is to remove the DEFINER.
HOSTNAME=localhost
USERNAME=username
PASSWORD=password
DATABASE=database
cd /tmp
mysqldump --routines -h${HOSTNAME} -u${USERNAME} -p${PASSWORD} ${DATABASE} > ${DATABASE}.dmp
sed -E 's/DEFINER=`[^`]+`@`[^`]+`/DEFINER=CURRENT_USER/g' ${DATABASE}.dmp > ${DATABASE}-clean.dmp
rm -f ${DATABASE}-clean.dmp.gz
gzip -9 ${DATABASE}-clean.dmp
@anytizer
anytizer / mysql-triggers.sql
Last active November 11, 2023 13:20
The mysql triggers examples
# INSERT
# -- before: Check uniqueness
# -- after:
# UPDATE
# -- before: Log old data
# -- after: Email admin queue
# DELETE
# -- before: check for dues
# -- after: System cleanup
http://yysource.com/2012/09/mysql-delete-drop-tables-with-prefix/
USE `test`; # Jump to the database
SET @table_prefix = '_';
# Load current database into the variable
SET @database_name = DATABASE();
SET @tables_to_drop = (
SELECT
@anytizer
anytizer / links.txt
Last active April 28, 2016 20:44
Good Links for PHP/MySQLs and design things
@anytizer
anytizer / foods.txt
Created December 28, 2013 07:28
Foods (Acidic and Alkaline)
Foods
http://www.weallnepali.com/recipe/nepali-food-dictionary/nepali-vegetable-english-name
http://www.alkalinesisters.com/alkaline-food-chart/
http://www.rense.com/1.mpicons/acidalka.htm
http://www.onegreenplanet.org/vegan-health/healthy-alkaline-foods-to-include-in-your-diet/
https://www.surveymonkey.com/mp/medical-research-surveys
@anytizer
anytizer / digits-cleaner.php
Created January 10, 2014 07:59
Cleanups the digits surrounded by braces
<?php
$string="Invalid (0) entries";
# Removes the braces and digits like "(10)" from the string without the quotations
$string = preg_replace('/\(\d+\)/', '', $string);
echo $string;
?>
@anytizer
anytizer / jquery-modal.html
Last active January 2, 2016 19:39
jQuery Modal Window creating
One:
http://www.paulund.co.uk/how-to-create-a-simple-modal-box-with-jquery
http://www.paulund.co.uk/playground/demo/jquery_modal_box/
Two:
http://www.jacklmoore.com/notes/jquery-modal-tutorial/
http://www.jacklmoore.com/demo/modal/modal2.html
@anytizer
anytizer / accessing-configurations.php
Created January 10, 2014 14:13
Accessing PHP configurations in different ways
Absolute path
'/home/USER/public_html/config.php'
Dynamic path
dirname(__FILE__).'/config.php'
Configured path
$path.'/config.php'
@anytizer
anytizer / jquery-post.php
Created January 10, 2014 14:42
jquery post handling
<?php
if($_POST)
{
$data = array(
'time' => time().'-'.mt_rand(1000, 9999),
'username' => $_POST['username'],
'password' => $_POST['password'],
);
echo '<pre>', print_r($data, true), '</pre>';
die();
@anytizer
anytizer / drop-all-functions-of-database.sql
Created January 11, 2014 15:39
Drop all functions from 'your_database' database.
SELECT
CONCAT('DROP FUNCTION ', `SPECIFIC_NAME`, ';') drop_function
FROM `INFORMATION_SCHEMA`.`ROUTINES`
WHERE
`ROUTINE_SCHEMA` = 'your_database'
AND ROUTINE_TYPE = 'FUNCTION'
;