Skip to content

Instantly share code, notes, and snippets.

View anytizer's full-sized avatar

Bimal Poudel anytizer

View GitHub Profile
@anytizer
anytizer / encode-decode.sql
Last active December 28, 2015 18:18
Base 64 Encode/Decode in MySQL and URL encode decode
http://wi-fizzle.com/downloads/base64.sql
Corrections at: http://stackoverflow.com/questions/358500/base64-encode-in-mysql
Urlencode/urldecode As MySQL Stored Functions
http://www.dzone.com/snippets/urlencodeurldecode-mysql
http://jeremythomerson.com/2013/05/30/urlencoder-function-for-mysql/
@anytizer
anytizer / resources.php
Created November 25, 2013 09:12
Extract src and href
<?php
$path = '/home/USER/public_html';
function resources($path)
{
$resources = array(
'file' => $path,
'href' => array(),
'src' => array(),
'success' => false,
@anytizer
anytizer / error-logging.php
Created November 27, 2013 06:55
Enable error logging mode in PHP
<?php
ini_set('log_errors', 'On');
ini_set('display_errors', 'On');
ini_set('error_log', dirname(__FILE__).'/error_log');
error_reporting(E_ALL|E_STRICT);
?>
@anytizer
anytizer / large-php-scripts.sh
Created November 27, 2013 06:59
Large PHP scripts
find /PATH -type f -name "*.php" -size +50 > /tmp/large-scripts.log
@anytizer
anytizer / drop-triggers.sql
Created November 30, 2013 06:51
SQL to drop all triggers from your selected database
SELECT CONCAT('DROP TRIGGER `', trigger_name, '`;') FROM information_schema.triggers WHERE trigger_schema = 'DATABASE_NAME';
@anytizer
anytizer / dmy.php
Created November 30, 2013 07:10
Format date into your desired pattern
<?php
/**
* Converts YYYY-MM-DD format into DD/MM/YYYY
*/
function _dmy($yyyymmddhhiiss='0000-00-00 00:00:00')
{
$date = substr($yyyymmddhhiiss, 0, 10);
list($yyyy, $mm, $dd) = explode('-', $date);
$dmy = "{$dd}/{$mm}/{$yyyy}";
return $dmy;
@anytizer
anytizer / functions.php
Created November 30, 2013 07:36
Finds out functions in files
<?php
header('Content-Type: text/plain');
$path = '/home/USER/public_html';
chdir($path);
$files = glob('*.php');
$total = 0;
$catches = array();
@anytizer
anytizer / md5_dir.php
Created November 30, 2013 07:49
Simulation of md5 hash of files in linux; helps to find out any files modified after you gave them to someone else. Calculates md5 hash of files under directory.
<?php
function md5_dir($path='/tmp')
{
global $counter;
global $skip_directories;
global $skip_extensions;
$handle = opendir($path);
while(false!==($file=readdir($handle)))
{
if(in_array($file, $skip_directories)) continue;
@anytizer
anytizer / mysql-events.sql
Last active December 29, 2015 19:29
Events in MySQL (works like cron feature in Linux server)
CREATE TABLE `_dt` (
`dt` DATETIME DEFAULT NULL
);
DROP EVENT IF EXISTS e_minutely;
DELIMITER $$
CREATE EVENT e_minutely
ON SCHEDULE
EVERY 1 MINUTE
@anytizer
anytizer / encrypt-decrypt-checker.sql
Created November 30, 2013 11:17
Encode/Decode verification in MySQL
SELECT ENCODE('mytext', 'mykey');
SELECT AES_ENCRYPT('mytext', 'mykey');
SELECT DECODE(ENCODE('mytext', 'mykey'), 'mykey')='mytext' ok;
SELECT AES_DECRYPT(AES_ENCRYPT('mytext', 'mykey'), 'mykey')='mytext' ok;