Developers notebook

Start MySQL on Yosemite

sudo /usr/local/mysql/support-files/mysql.server start

Orignal source:

Monitor MySQL restore progress with pv

pv {source_database.sql} | mysql -u{user} -p {destination_database}


Duplicate a directory structure.

From the root of structure you want to duplicate run find . -maxdepth 2 -type d | sed 's/$/"/' | sed 's/^/mkdir "/' >

-maxdepth sets the recursion level.
-type d identifies only directories.
sed commands wrap the output in mkdir “{Path}”

Output is redirected to a file.

MS Access Sum a date time field

Example data

id TimeElapsed User
1 00:01:44 Bob
2 00:01:46 Bob

To sum a date time field first convert the field data to double with an expression using the CDbl Function.

exp1: CDbl([TimeElapsed])

Set the total type to Sum.

Then create another expression to convert the data from the first expression back to a date time field using the CVDate function.

exp2: CVDate([exp1])

Set the total value to Expression.

TimeElapsed User
00:03:30 Bob

UNIX timestamp and Active Directory timestamp for given date and time

/** Returns UNIX timestamp and Active Directory timestamp for given date and time */


//Format dd-mm-yyyy
$dateFromForm = '24-05-2020';

//Format hh:mm:ss
$timeFromForm = "00:00:00";

$CLI = 1;
if ($CLI = 0) { $LF = "<br>";} else {$LF = "\r\n";}
$dateWithTime = $dateFromForm." ".$timeFromForm;

function convertDateToUnix($input) {
$format = 'd-m-Y H:i:s';
$date = DateTime::createFromFormat($format, $input);
$UNIXTimestamp = $date->getTimestamp();
return $UNIXTimestamp;

function convertUnixtoWin($input) {
return ($input+11644473600)*10000000;

echo "*** Welcome to the Timestamp converter ***".$LF;
echo $LF."You entered: ".$dateWithTime.$LF;
echo $LF."UNIX Timestamp is ".$UNIX.$LF;
echo $LF."Windows Timestamp is ".convertUnixtoWin($UNIX).$LF;
echo $LF."**************************************".$LF;

Amazon ec2 CLI – Return instance public DNS by tag

aws ec2 describe-instances –output=json –filter Name=tag:{TAG NAME},Values=”{TAG VALUE}” –query “Reservations[].Instances[].PublicDnsName”

For example if you have some ec2 instances with a tag key “Name” and the value “Webserver Auto Scaling Group”

aws ec2 describe-instances –output=json –filter Name=tag:Name,Values=”Webserver Auto Scaling Group” –query “Reservations[].Instances[].PublicDnsName”

Find and replace a line with sed

sed -i “/;Thing to find/c\Thing to replace it with” /path/to/file

sed -i “/;date.timezone =/c\date.timezone = Europe/London” /etc/php.ini

Load data in to Maria DB from csv file

Place your import data file inside the database data directory e.g /var/lib/mysql/{database name}

Give the mysql user permission.  chown mysql:mysql {data.csv}

mysql -uroot -p –local-infile=1 {database name}

Load the data:

LOAD DATA INFILE ‘{data.csv}’
INTO TABLE  {table name}

If your data has a field headings row, this can be omitted from the import with.

NTLM error on openSUSE 13.2

When setting up NTLM on openSUSE I was getting a 500 server error from Apache.

In the error log: ntlm_auth reports Broken Helper: BH NT_STATUS_ACCESS_DENIED NT_STATUS_ACCESS_DENIED

Solved with setfacl -m u:wwwrun:rx /var/lib/samba/winbindd_privileged

Windows Update error 80244022

My PC wasn’t getting it’s updates from our on site Windows update server.  Follow these steps to get the updates directly from Microsoft.  This worked for me on Windows 8, should be good for Windows 7 too.

1. Open registry editor (Start menu –> Run –> regedit)

2. Find the following path HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU

3. Change the value of the UseWUServer from 1 to 0 (double click on it, change the value and click OK)

4. Restart Windows Update service (Start menu –> Run –> services.msc –> find the Windows Update service and click on Restart)

You may find group policy sets it back next time they are applied

Orignal source

« Older posts

© 2016

Theme by Anders NorenUp ↑