Skip to content

Instantly share code, notes, and snippets.

View anytizer's full-sized avatar

Bimal Poudel anytizer

View GitHub Profile
@anytizer
anytizer / session.php
Created March 26, 2014 14:24
https sessions tester
<?php
/**
* Script to test session data sharing in http and https versions
* Theme: session initiated by HTTP should be accessible to HTTPS and vice-versa
* http://localhost/https/session.php
* https://localhost/https/session.php
*/
session_start();
header('Content-Type: text/plain');
@anytizer
anytizer / server.php
Created March 27, 2014 09:32
Server variables safety
if(emtpy($_SERVER['REMOTE_ADDR']))
{
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
}
if(emtpy($_SERVER['SERVER_NAME']))
{
$_SERVER['SERVER_NAME'] = 'localhost';
}
@anytizer
anytizer / index.php
Created April 30, 2014 07:25
Reset user password in Mantis Bug Tracker
UPDATE mantis_user_table SET PASSWORD=MD5('PASSWORD'), enabled=1, protected=0, access_level=90 WHERE username='USERNAME';
mysqldump --routines --no-data --no-create-info -hHOSTNAME -uUSERNAME -pPASSWORD DATABASE> ROUTINES.dmp
@anytizer
anytizer / f_distance.sql
Created May 5, 2014 09:17
Distance calculator
-- http://www.sqlexamples.info/SPAT/mysql_distance.htm
DROP FUNCTION IF EXISTS fn_distance;
DELIMITER $$
CREATE FUNCTION fn_distance(
p_x1 FLOAT, p_y1 FLOAT,
p_x2 FLOAT, p_y2 FLOAT
)
RETURNS FLOAT
DETERMINISTIC
BEGIN
@anytizer
anytizer / missing-integrity.php
Created May 12, 2014 09:32
Finds out missing number in an auto-incremented column of a table
<?php
/**
* Finds out any missing ID in an auto-increment column of a table
*/
error_reporting(E_ALL | E_STRICT);
$auto_increment_column = 'id';
$table = '_sample_table';
mysql_connect('HOSTNAME', 'USERNAME', 'PASSWORD') or die('Error connecting the database');
@anytizer
anytizer / random-digit.sql
Created May 13, 2014 05:49
Extract the last digit of a random number, thus making it an integer value
SELECT SUBSTR(RAND(), -1, 1);
@anytizer
anytizer / one-liner-define.php
Created May 13, 2014 08:21
One lined defintion of a constant that does not clash on multiple calls.
!defined('CONSTANT_NAME') || define('CONSTANT_NAME', 'CONSTANT_VALUE');
@anytizer
anytizer / p_generate_random_numbers.sql
Created May 14, 2014 05:43
Generate random numbers in MySQL and check for randomness for non-repeating behaviour.
CREATE TABLE `random_numbers` (
`random_number` VARCHAR(20) NOT NULL COMMENT 'Random Number',
PRIMARY KEY (`random_number`),
KEY `random_number_key` (`random_number`)
);
SELECT LENGTH(RAND()); # Length varies
DROP PROCEDURE IF EXISTS p_generate_random_numbers;
DELIMITER $$
No Machine
Teamviwer
AmmyAdmin
CrossLoop
imPcRemote
Shareme
Log Me In
Join.me
WebEx Free
Real VNC