Assigning exclusivity and evicting processes from a CPU core

I have a need to move one process to a vacant core – but is the core vacant? Does it stay vacant? Step 1 – move the process to a core, Step 2 (which should happen before Step 1) is to see what core has least activity, evict the squatters to another core, then move the relevant process.

Image Processing to detect differences in flashing frames

I have a need to detect when a screen “stops changing” and that time will then be considered “done”. So first, the flashing is every 1 seconds, so if we average out frames in 2 seconds and use that “rolling averaged” frame vs. the subsequent rolling average (so 1 averaged frame later) and do some math to say “how much different” then we can look for when the changes stop and be happy we have an answer. So average 48 frames if you are using 24fps.

Where to start? ImageMagick I think is a good place.

Performance monitoring on windows – a cursory lookWQL WMI QUERY FOR DISK I/O

I am trying to understand some performance metrics. To start, I am looking at disk i/o between 2 timestamps. Lets see how that goes.

 

Powershell – is it a crime not to use it? Looping over files and running commands

So, I HAVE to bite the bullet. A colleague of mine started using it 3 months ago, another SQL mentor has been badgering me to use it (and to love bitcoin) for a LONG while. Today, I will record links to some basic looping structures. This is like unix (a good thing) but object oriented with full API access it seems. Neat! And … I am hooked now even if I am a late adopter and am finally giving up dos scripts (yet I am a unix shell junkie) 🙁

My final commands were

dir -recurse -include *.xec | %{pdt -fo $_.FullName}
dir -recurse -include *.xe* | %{migratedsp -f $_.FullName -dest $_.DirectoryName}

where pdt is the .exe file that does something to the filenames. Note that % is a short form of foreach. The object that has the methods FullName and DirectoryName are listed on msdn and is the FileInfo class that we know and love in other scripting languages.

 

scripting mysql on unix to clean tables

One could clean the table, but on hostgator’s phpmyadmin in cpanel which is REALLY REALLY REALLY SLOW, it times out and loses connection before it is done cleaning. So – on another server which is lickity split, I have root access. To overcome the slowness, I first, copy the table which cleans it, then rename the original and rename the copy. This allows me to also have a backup table. Below is my unix bash script:

Here is a list of my heros who helped get me to my script below.

[c]

#!/bin/bash

## script name; cleanDirtyTable.sh
## wrapper script to execute mysql script with variables

ARGS=2

if [ $# -ne "$ARGS" ]
then

echo "you passed $# parameters"
echo "Usage: `basename $0` sql_table sql_password"

exit
fi

sqltable=$1
sqlpassword=$2
sql_script=cleanDirtyTable.sql
data_file=cleanDirtyTable_results.txt

#run mysql query with paramenters

echo "set @origTable=${sqltable}"

#/usr/bin/mysql –uUserName -pXXXXXXXXXX –h localhost -D my_dBname -A -e "set @origTable=’${sqltable}’; source ${sql_script};" #>${data_file};

/usr/bin/mysql -uUsername -p${sqlpassword} -h localhost -D my_dBname -A -e "set @origTable=’${sqltable}’; SOURCE ${sql_script};"
exit

[/c]

Now here is the sql portion

[sql]
USE fcs_jo151;

— SET @origTable = ‘jos_fcls_masterquotewjobs’;

SET @ds1 = CONCAT(‘CREATE table `’,@origTable, ‘_copy` LIKE `’,@origTable,’`’);
SET @b =1;
SET @ds2 = CONCAT(‘INSERT `’, @origTable, ‘_copy` SELECT * FROM `’,@origTable,’`;’);
SET @rename1 = CONCAT(‘RENAME TABLE `’,@origTable,’` TO `’, @origTable ,’_bak_’,CURDATE(),’`;’);

SET @rename2 = CONCAT(‘RENAME TABLE `’,@origTable,’_copy` TO `’, @origTable ,’`;’);

PREPARE stmt FROM @ds1;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

PREPARE stmt FROM @ds2;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

PREPARE stmt FROM @rename1;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

PREPARE stmt FROM @rename2;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

[/sql]

No time to wonder if updates are rebooting your server? Put an email event on a log file

This is for windows. One customer would log in (and me several times) and you are immediately assaulted with windows threatening you that you have 5 minutes and the system will reboot. No recourse, no mercy – for you OR those working on the server. Great – good customer service right? Well – it is windows that is causing the issue of course, not me. First, there are 2 GPO’s (link one, link two) that must be configured to ensure that the use has up to 180 minutes of warning, next to allow the reboot to happen at 3am for pete’s sake. Next, you should set up a log to emall you when events 6005/6006 to see when the even log was started and stopped. This is the same as you computer rebooting. Next, look for event 491 so see when patches are downloaded. Another blog article I wrote has a few other handy GPO’s as well that I suggest.

Extracting sharepoint Library Data and attached files