Skip to content

Instantly share code, notes, and snippets.

View svecon's full-sized avatar

Ondřej Švec svecon

View GitHub Profile
/**
* Breaksdown a timestamp into an array of days, months, etc since the current time
* @author http://milesj.me/snippets/php/timeBreakdown
* @param int $timeStamp
* @return array
*/
function timeBreakdown($timeStamp) {
if (!is_int($timeStamp)) $timeStamp = strtotime($timeStamp);
$currentTime = time();
/*
backup_tables('localhost','root','root','esvec');
*/
/* backup the db OR just a table */
function backup_tables($host,$user,$pass,$name,$tables = '*')
{
$return = null;
$link = mysql_connect($host,$user,$pass);
function _color_rgb2hsl($rgb) {
$r = $rgb[0];
$g = $rgb[1];
$b = $rgb[2];
$min = min($r, min($g, $b));
$max = max($r, max($g, $b));
$delta = $max - $min;
$l = ($min + $max) / 2;
$s = 0;
if ($l > 0 && $l < 1) {
WARNING! Be very careful that you do not accidentally disable all ways that you can click. If you have reassigned your left click button to another function, and then you uncheck "Enable" on one finger tapping in the GUI, you will have to plug in an external USB mouse or remote into the machine with remote desktop (or something similar) or use Windows Speech Recognition or figure out some other way to re-check the "Enable" box under one finger tapping in the GUI in order to restore click functionality. I will not be held responsible if you do not have any of these methods available and you end up (temporarily) bricking your laptop. You have been warned. (But really, just don't uncheck that box and you will be fine).
HKEY_CURRENT_USER\Software\Elantech\SmartPad:
Button_Left; Button_Right; Tap_Two_Finger; Tap_Three_Finger; ThreeFingerMoveUp_Func; ThreeFingerMoveDown_Func:
0 Click/Select
Left click default
1 Pop-up Menu
Right Click default
2 Middle Button
@svecon
svecon / ValidateDate
Last active December 21, 2015 06:49
Validates user's input date.
protected function checkInputDate($string)
{
$try = date_parse($string);
if ($try['error_count'] > 0)
return false;
try { $try = new DateTime($string); }
catch (Exception $e) { return false; }
$sep = '-.\/';