SHOW VARIABLES LIKE '%license%';That's it! (of course one needs first to connect to the instance like : mysql -u your_username -p )
luni, 26 septembrie 2016
What is the current mysql license, how to find it?
Hi,
You're wondering how to find the current mysql license?
One should just query the instance variables, it's as easy as this:
vineri, 19 august 2016
ASP Classic Recursively Delete Files (older than) and folders
In ASP Classic (VBScript), this piece of script will recursively walk through all subfolders and remove all files older than 6 hours (change it to days, weeks, months), and all empty subdirectories.
DeleteFiles("C:\cleanThisSub")
dim fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")
' recursively deletes files older than 6 hours and the empty directories
Sub DeleteFiles(ByVal sFolder)
Set folderObj = fso.GetFolder(sFolder)
dim aFiles, aSubFolders, aSubFolders2, file, folder, folderObj2
Set aFiles = folderObj.Files
Set aSubFolders = folderObj.SubFolders
For Each file in aFiles
if ( DateDiff("s", file.DateLastModified, Now()) > 6 * 3600 ) then
'delete files older than 6 hours
response.write "del " & file.Path & "<br>"
fso.deleteFile(file.Path)
End If
Next
For Each folder in aSubFolders
Set folderObj2 = fso.GetFolder(folder.Path)
DeleteFiles(folder.Path)
Set aFiles = folderObj2.Files
if aFiles.Count<1 then
set asubfolders2 = folderObj2.SubFolders
if aSubFolders2.Count<1 then
' subfolder is empty, can be removed
response.write "rmdir " & folder.Path & "<br>"
fso.deleteFolder(folder.Path)
end if
end if
Next
End Sub
vineri, 13 mai 2016
Windows 10 Unable to open Link in Mail
For a while now, every time i clicked a link inside any email , within the Windows 10 Mail app,
this failed with the warning 'Unable to open Link: http://... '.
After some research i've figured it is due to the fact that i stopped&disabled the windows Firewall service.
As soon as i opened services.msc , scrolled down to windows firewall, and started it - all windows 10 mail Links started opening up immediately, like magic!
Thanks Microsoft + Windows 10.
You're doing a great job.
this failed with the warning 'Unable to open Link: http://... '.
After some research i've figured it is due to the fact that i stopped&disabled the windows Firewall service.
As soon as i opened services.msc , scrolled down to windows firewall, and started it - all windows 10 mail Links started opening up immediately, like magic!
Thanks Microsoft + Windows 10.
You're doing a great job.
joi, 6 august 2015
Backup Database and Website in PHP without MYSQLDUMP
On some configurations, mysqldump is not available.
So how does one backup his database without mysqldump, but only PHP at hand?
Here is a workaround in pure PHP (just a little additional help from tar and zip - can be completely skipped). This piece of script will create its own backup directories if they don't exist (yes it needs write rights to the destination directory), get a backup of the database (in chunks, not to break or stall the database), tar-zips the backups, and the cherry on top: it will delete old files - so they don't build up to use your whole disk space.
To run it, of course you need to configure it correctly with your database name, username, password, hostname, authorization password, and perhaps the paths to the directories to the backup output files.
If you're gonna use this piece of script, please drop me a line, i'll be happy to hear about it!
So how does one backup his database without mysqldump, but only PHP at hand?
Here is a workaround in pure PHP (just a little additional help from tar and zip - can be completely skipped). This piece of script will create its own backup directories if they don't exist (yes it needs write rights to the destination directory), get a backup of the database (in chunks, not to break or stall the database), tar-zips the backups, and the cherry on top: it will delete old files - so they don't build up to use your whole disk space.
To run it, of course you need to configure it correctly with your database name, username, password, hostname, authorization password, and perhaps the paths to the directories to the backup output files.
If you're gonna use this piece of script, please drop me a line, i'll be happy to hear about it!
<?php
// set up a password access - so to prevent abuses
if ( $_GET['p']=='SOMe_Str0ng_Pa55word')
{
set_time_limit(60*6); // 6 minutes
$dbname = 'PuT_Your_DB_Name_Here'; // like wordpress
$user = 'PuT_Your_Username_Here'; // like root
$pass = 'PuT_Your_Password_Here'; // like 12345
$host = 'PuT_Your_DB_HOST_Here'; // like localhost or db.mysql.server.org
// check or create directory for DB backup
if ( !is_dir('/backup/DB') ) {
mkdir('/backup/DB');
chmod('/backup/DB', 0755);
}
// check or create directory for site backup
if ( !is_dir('/backup/html') ) {
mkdir('/backup/html');
chmod('/backup/html', 0755);
}
/************************************
CREATE A BACKUP OF THE DATABASE
************************************/
// check if a recent backup exists and clean up old files
$haveRecent = false;
$dp = opendir('/backup/DB');
while ( $fname = readdir($dp) )
{
if ( $fname && $fname!='.' && $fname!='..' )
{
if ( substr($fname, -11)=='.sql.tar.gz' && preg_match('/^[0-9]{14}_/i', $fname) && !preg_match('/[^a-z0-9\_\.]/i', $fname) )
{
$dt = substr($fname, 0, 8);
if ( $dt<=date("Ymd", time()-(86400*30*2) ) )
{
// delete all older than 90 days
@unlink('/backup/DB/'.$fname);
}
elseif ( (int)$dt>date("Ymd", time()-86400*15) )
{
// we have a recent backup (last 15 days)
$haveRecent = true;
}
}
}
}
//if ( !$haveRecent )
{
// dump the DB in the appropriate DB backup directory
$fn = '/backup/DB/'.date("YmdHis") . '_' . $dbname . '.sql';
$tfn = $fn . '.tar.gz';
if ( !is_file($fn) && !is_file($tfn) )
{
$MB = new mysqlBackup();
$MB->backup_tables($host, $user, $pass, $dbname, '*', $fn);
exec('tar -czf ' . $tfn . ' -C ' . dirname($tfn) . ' ' . basename($fn));
@unlink($fn);
}
}
/************************************
END CREATE A BACKUP OF THE DATABASE
************************************/
/************************************
CREATE A BACKUP OF THE WEBSITE FILES
************************************/
// check if a recent backup exists and clean up old files
$haveRecent = false;
$dp = opendir('/backup/html/');
while ( $fname = readdir($dp) )
{
if ( $fname && $fname!='.' && $fname!='..' )
{
if ( preg_match('/^[0-9]{14}\.tar\.gz$/', $fname) )
{
$dt = substr($fname, 0, 8);
if ( (int)$dt<=(int)date("Ymd", time()-(86400*30*2) ) )
{
// delete all older than 90 days
@unlink('/backup/html/'.$fname);
}
elseif ( (int)$dt>(int)date("Ymd", time()-86400*15) )
{
// we have a recent backup (last 15 days)
$haveRecent = true;
}
}
}
}
//if ( !$haveRecent )
{
// dump the DB in the appropriate DB backup directory
$fn = '/backup/html/' . date("YmdHis") . '.tar.gz';
if ( !is_file($fn) )
{
exec('tar -czf ' . $fn . ' -C / html');
}
}
/************************************
END CREATE A BACKUP OF THE WEBSITE FILES
************************************/
}
class mysqlBackup
{
//backup_tables('localhost','username','password','blog');
/* backup the db OR just a table */
function backup_tables($host, $user, $pass, $name, $tables = '*', $ofile ='')
{
$link = mysql_connect($host, $user, $pass) or die("could not connect");
mysql_select_db($name, $link);
//save file
$handle = fopen($ofile, 'w');
//get all of the tables
if($tables == '*')
{
$tables = array();
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_row($result))
{
$tables[] = $row[0];
}
}
else
{
$tables = is_array($tables) ? $tables : explode(',',$tables);
}
//cycle through
foreach($tables as $table)
{
$exhaustedTable = false; $iteration = 0; $pageSize = 1000; // to dump the tables in batches of 1000 lines
$colsRes = mysql_query('SHOW COLUMNS FROM `'.$table.'`');
$cols = array(); $colsStr = '';
while ( $colRow = mysql_fetch_row($colsRes) )
{
$cols[] = $colRow[0];
$colsStr.= ($colsStr!=''?',':'') . '`' . $colRow[0] . '`';
}
$num_fields = count($cols);
$n1 = ($num_fields-1);
fwrite($handle, 'DROP TABLE IF EXISTS `'.$table.'`;'. "\n");
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE `'.$table.'`'));
fwrite($handle, $row2[1].";\n");
while (!$exhaustedTable)
{
$result = mysql_query('SELECT * FROM `'.$table. '` LIMIT '.($iteration*$pageSize).','.$pageSize);
if ( mysql_num_rows($result) )
{
fwrite($handle, 'INSERT INTO `'.$table.'` (' . $colsStr . ') VALUES');
$nc = false;
while($row = mysql_fetch_row($result))
{
if ( $nc )
{
fwrite($handle, ', ');
}
fwrite($handle, '(');
for($j=0; $j<$num_fields; $j++)
{
if ( $row[$j] === NULL )
{
fwrite($handle, 'NULL');
}
elseif ( $row[$j]==='' )
{
fwrite($handle, '""');
}
else
{
$row[$j] = mysql_real_escape_string(stripslashes($row[$j]));
$row[$j] = preg_replace("/\n/m","\\n",$row[$j]);
fwrite($handle, '"'.$row[$j].'"');
}
if ($j<$n1)
{
fwrite($handle, ',');
}
}
fwrite($handle, ')');
$nc = true;
}
fwrite($handle, ";\n");
}
else
{
$exhaustedTable = true;
}
$iteration++;
}
}
fclose($handle);
}
}
?>
// set up a password access - so to prevent abuses
if ( $_GET['p']=='SOMe_Str0ng_Pa55word')
{
set_time_limit(60*6); // 6 minutes
$dbname = 'PuT_Your_DB_Name_Here'; // like wordpress
$user = 'PuT_Your_Username_Here'; // like root
$pass = 'PuT_Your_Password_Here'; // like 12345
$host = 'PuT_Your_DB_HOST_Here'; // like localhost or db.mysql.server.org
// check or create directory for DB backup
if ( !is_dir('/backup/DB') ) {
mkdir('/backup/DB');
chmod('/backup/DB', 0755);
}
// check or create directory for site backup
if ( !is_dir('/backup/html') ) {
mkdir('/backup/html');
chmod('/backup/html', 0755);
}
/************************************
CREATE A BACKUP OF THE DATABASE
************************************/
// check if a recent backup exists and clean up old files
$haveRecent = false;
$dp = opendir('/backup/DB');
while ( $fname = readdir($dp) )
{
if ( $fname && $fname!='.' && $fname!='..' )
{
if ( substr($fname, -11)=='.sql.tar.gz' && preg_match('/^[0-9]{14}_/i', $fname) && !preg_match('/[^a-z0-9\_\.]/i', $fname) )
{
$dt = substr($fname, 0, 8);
if ( $dt<=date("Ymd", time()-(86400*30*2) ) )
{
// delete all older than 90 days
@unlink('/backup/DB/'.$fname);
}
elseif ( (int)$dt>date("Ymd", time()-86400*15) )
{
// we have a recent backup (last 15 days)
$haveRecent = true;
}
}
}
}
//if ( !$haveRecent )
{
// dump the DB in the appropriate DB backup directory
$fn = '/backup/DB/'.date("YmdHis") . '_' . $dbname . '.sql';
$tfn = $fn . '.tar.gz';
if ( !is_file($fn) && !is_file($tfn) )
{
$MB = new mysqlBackup();
$MB->backup_tables($host, $user, $pass, $dbname, '*', $fn);
exec('tar -czf ' . $tfn . ' -C ' . dirname($tfn) . ' ' . basename($fn));
@unlink($fn);
}
}
/************************************
END CREATE A BACKUP OF THE DATABASE
************************************/
/************************************
CREATE A BACKUP OF THE WEBSITE FILES
************************************/
// check if a recent backup exists and clean up old files
$haveRecent = false;
$dp = opendir('/backup/html/');
while ( $fname = readdir($dp) )
{
if ( $fname && $fname!='.' && $fname!='..' )
{
if ( preg_match('/^[0-9]{14}\.tar\.gz$/', $fname) )
{
$dt = substr($fname, 0, 8);
if ( (int)$dt<=(int)date("Ymd", time()-(86400*30*2) ) )
{
// delete all older than 90 days
@unlink('/backup/html/'.$fname);
}
elseif ( (int)$dt>(int)date("Ymd", time()-86400*15) )
{
// we have a recent backup (last 15 days)
$haveRecent = true;
}
}
}
}
//if ( !$haveRecent )
{
// dump the DB in the appropriate DB backup directory
$fn = '/backup/html/' . date("YmdHis") . '.tar.gz';
if ( !is_file($fn) )
{
exec('tar -czf ' . $fn . ' -C / html');
}
}
/************************************
END CREATE A BACKUP OF THE WEBSITE FILES
************************************/
}
class mysqlBackup
{
//backup_tables('localhost','username','password','blog');
/* backup the db OR just a table */
function backup_tables($host, $user, $pass, $name, $tables = '*', $ofile ='')
{
$link = mysql_connect($host, $user, $pass) or die("could not connect");
mysql_select_db($name, $link);
//save file
$handle = fopen($ofile, 'w');
//get all of the tables
if($tables == '*')
{
$tables = array();
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_row($result))
{
$tables[] = $row[0];
}
}
else
{
$tables = is_array($tables) ? $tables : explode(',',$tables);
}
//cycle through
foreach($tables as $table)
{
$exhaustedTable = false; $iteration = 0; $pageSize = 1000; // to dump the tables in batches of 1000 lines
$colsRes = mysql_query('SHOW COLUMNS FROM `'.$table.'`');
$cols = array(); $colsStr = '';
while ( $colRow = mysql_fetch_row($colsRes) )
{
$cols[] = $colRow[0];
$colsStr.= ($colsStr!=''?',':'') . '`' . $colRow[0] . '`';
}
$num_fields = count($cols);
$n1 = ($num_fields-1);
fwrite($handle, 'DROP TABLE IF EXISTS `'.$table.'`;'. "\n");
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE `'.$table.'`'));
fwrite($handle, $row2[1].";\n");
while (!$exhaustedTable)
{
$result = mysql_query('SELECT * FROM `'.$table. '` LIMIT '.($iteration*$pageSize).','.$pageSize);
if ( mysql_num_rows($result) )
{
fwrite($handle, 'INSERT INTO `'.$table.'` (' . $colsStr . ') VALUES');
$nc = false;
while($row = mysql_fetch_row($result))
{
if ( $nc )
{
fwrite($handle, ', ');
}
fwrite($handle, '(');
for($j=0; $j<$num_fields; $j++)
{
if ( $row[$j] === NULL )
{
fwrite($handle, 'NULL');
}
elseif ( $row[$j]==='' )
{
fwrite($handle, '""');
}
else
{
$row[$j] = mysql_real_escape_string(stripslashes($row[$j]));
$row[$j] = preg_replace("/\n/m","\\n",$row[$j]);
fwrite($handle, '"'.$row[$j].'"');
}
if ($j<$n1)
{
fwrite($handle, ',');
}
}
fwrite($handle, ')');
$nc = true;
}
fwrite($handle, ";\n");
}
else
{
$exhaustedTable = true;
}
$iteration++;
}
}
fclose($handle);
}
}
?>
marți, 21 aprilie 2015
How to add a toolbar to your Windows 8.1 taskbar (for example, QuickLaunch)
I personally was missing in my rather new Windows 8.1, the Quick Launch Toolbar - that used to exist in older Windows versions. So i created my own, new, custom QuickLaunch toolbar. Here's how:
Basically any valid Windows folder can become a new toolbar. So all you need to do is create a folder, wherever you wish on your hard-disk, with any name of your choice. I personally went to the Documents folder (start screen, type Documents, press enter), right-clicked and created a New -> Folder, which i have named 'QuickLaunch'.
Right-Click on an empty area of your Win 8.1 taskbar. From the menu, choose Toolbars -> New Toolbar and just select the folder of your choice - in my case it was C:\Users\luciancostin\Documents\QuickLaunchToolbar
There it goes - the toolbar already appears on our taskbar. Whatever shortcuts or programs we put in there, they will be automatically displayed (here's how to create for example, a 'show desktop' icon).
For adding my Firefox icon, i've browsed to C:\Program Files (x86)\Mozilla Firefox , right-clicked on the 'firefox' program, chose 'Create shortcut' from the context-menu, cut (ctrl+x) this shortcut, and pasted it in my newly created folder.
For further customization of the toolbar (because by default, it has a rather strange appearance, showing the title, and the names of the links in here), one must:
1. unlock the taskbar: right-click your taskbar ,make sure the 'Lock the taskbar' menu item is not checked.
2. feel free to drag the margins and the whole toolbar wherever you like it, and to your preferred size.
3. right-click the toolbar for options, uncheck the 'show title' and 'show text' menu items - to get to the original 'quicklaunch' toolbar look & feel.
4. lock back the taskbar: preferably you'd want it to stay in place, so better to lock it back. Just right-click your taskbar and check the menu item 'Lock the taskbar'
That's it! :-) our new toolbar:
Basically any valid Windows folder can become a new toolbar. So all you need to do is create a folder, wherever you wish on your hard-disk, with any name of your choice. I personally went to the Documents folder (start screen, type Documents, press enter), right-clicked and created a New -> Folder, which i have named 'QuickLaunch'.
Right-Click on an empty area of your Win 8.1 taskbar. From the menu, choose Toolbars -> New Toolbar and just select the folder of your choice - in my case it was C:\Users\luciancostin\Documents\QuickLaunchToolbar
There it goes - the toolbar already appears on our taskbar. Whatever shortcuts or programs we put in there, they will be automatically displayed (here's how to create for example, a 'show desktop' icon).
For adding my Firefox icon, i've browsed to C:\Program Files (x86)\Mozilla Firefox , right-clicked on the 'firefox' program, chose 'Create shortcut' from the context-menu, cut (ctrl+x) this shortcut, and pasted it in my newly created folder.
For further customization of the toolbar (because by default, it has a rather strange appearance, showing the title, and the names of the links in here), one must:
1. unlock the taskbar: right-click your taskbar ,make sure the 'Lock the taskbar' menu item is not checked.
2. feel free to drag the margins and the whole toolbar wherever you like it, and to your preferred size.
3. right-click the toolbar for options, uncheck the 'show title' and 'show text' menu items - to get to the original 'quicklaunch' toolbar look & feel.
4. lock back the taskbar: preferably you'd want it to stay in place, so better to lock it back. Just right-click your taskbar and check the menu item 'Lock the taskbar'
That's it! :-) our new toolbar:
Re-create "Show Desktop" Icon in Windows 8.1
I'm a rather new user of Windows 8.1, and this operating system is cracking me day by day. One of the functions i miss most of older Windows versions is the "Show Desktop" icon.
Of course it exists in the lower-right corner of the taskbar, but i miss it in my 'QuickLaunch' toolbar - just as actually i missed my QuickLaunch toolbar altogether (its default appearance is quite obscure anyway). The Quick Launch toolbar doesn't exist by default in Windows 8.1 (i believe also Win 8 and Win 7).
Luckily, Win 8.1 provides a way to create custom toolbars, and i named mine exactly 'Quick Launch' (here's how to create your personal, customized win 8 "quick launch" toolbar).
And creating a "show desktop" icon is also fairly easy.
- Find out the path of your toolbar folder (i've mine under C:\Users\luciancostin\Documents\QuickLaunchToolbar). If you don't know where it is - just right-click your taskbar, make sure the 'Lock the taskbar' menu item is not checked. Then right-click on an empty-area of your toolbar and select "Open Folder".
- Open Notepad. Go to your Start screen and type "Notepad" to find and open it. Or go to Start ->Programs->Accessories->Notepad, if you have a start menu installed.
- Paste these contents in your new file:
[Shell]
Command=2
IconFile=explorer.exe,3
[Taskbar]
Command=ToggleDesktop - Save your new file in the toolbar folder (found at point 1. above), with the following name: "Show desktop.scf" - use the doublequotes too - so that Notepad does not append a default .txt extension to your file and render it useless
- Have fun! :) Windows (at least mine) also adds the old, nice 'Show Desktop' icon to this new button :)
* The content of the file comes directly from Microsoft - more info at this link: https://support.microsoft.com/en-us/kb/190355
miercuri, 8 aprilie 2015
Git trouble on Windows with tilde filenames
I've had apparently unresolvable problems with tilde filenames .
On windows 8.1, immediately as i clone a repository to my hard drive, some filenames containing tilde (interestingly enough, not all of them) - instantly throw out an error. They immediately appear as deleted, and i cannot do anything to add them to the git index, ignore, delete from cache or whatever.
Apparently this is a fairly recent change in Git, dating since December 2014, and yes, the solution is as stated on the given link, to configure git with the following:
Here's the link to the author's reply:
http://stackoverflow.com/questions/29294910/unable-to-add-files-with-name-containing-tilde-followed-by-a-number
On windows 8.1, immediately as i clone a repository to my hard drive, some filenames containing tilde (interestingly enough, not all of them) - instantly throw out an error. They immediately appear as deleted, and i cannot do anything to add them to the git index, ignore, delete from cache or whatever.
Apparently this is a fairly recent change in Git, dating since December 2014, and yes, the solution is as stated on the given link, to configure git with the following:
git config core.protectNTFS false
As the author says, i also recommend putting it back once the files are added to the index, with:
git config core.protectNTFS true
Here's the link to the author's reply:
http://stackoverflow.com/questions/29294910/unable-to-add-files-with-name-containing-tilde-followed-by-a-number
Abonați-vă la:
Postări (Atom)
