https://blogs.msdn.microsoft.com/asiatech/2011/12/05/how-to-develop-and-deploy-activex-control-in-c/
Author Archives: Etienne Bley
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.
- PowerShell: List processes currently using the most CPU
- Listing processes by cpu
- Moving a process to a new cpu – powershell
- running a sub-shell as an admin user w. a UAC prompt
- Odd Math I required
- flip a bit in a mask
- converting to hex
- How to convert a simple integer to a larger one that can cast to an IntPtr use [Convert]::ToInt32 <- this can then convert to the pointer required by the .ProcessorAffinity property
- “using write-host is almost always the wrong…” … I agree. Use write-output if you want to pipe something to a file using the > operator
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.
- compare function
- can it work on video so I don’t have to convert? There seems to be hope
Filemaker Post – yes it works – somethings you should know
An insert from URL or fetch from URL allows filemaker to hit a rest-ful service apparently since FM 2103. Here are some things you need to know
- don’t pre-encode anything but & and = (and %)
- json? Well – stick with xml if possible
- a FM talk about importing with post. It, under the hood, is really LOOK like a GET inside FM , but outside, it is 100% post.
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.
-
Performance Monitoring Getting Started Guide (2012) perfmon.msc
-
Monitoring Your Windows Server Metrics with WMI WMI (underlying tech) and PerfMon (GUI) are related
- Looks like there are few native apps -not sure how they are connected. Windows Performance Analyzer – WMA
- WQL WMI QUERY FOR DISK I/O
- WMI queries from the command line (Rob van der Woude’s Scripting Pages
- Is there a way to query WMI without using PowerShell or CIM Studio? (recommended wmic, wbemtest, some ps and vbscripts
- what is this WPA? It is NOT WMA. Watch the video at that link
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.
- Passing Parameters To A MYSQL Query Inside A Shell Script
- Using mysql in batch mode
- Passing Parameters To A MYSQL Query Inside A Shell Script
- How do I execute an SQL script in MySQL?
[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};" #&amp;gt;${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
- So, using Sharpoint is good … when you don’t have a database or infrastructure to keep, upload and attach meta data to files, however, I have a customer who has a database in Filemaker with all the meta data already, and Filemaker has drag and drop functionality. VERY slick (quite proud of myself – I might publish that next). Yes you have to script and do a bit of gymnastics, but you can make it do exactly what you require it to do for your own specific task. Well, to extract all the info out of sharepoint to back-annotate the info into Filemaker was made simple by a few people. Here are some powershell scripts that made my life very easy
- SharePoint PowerShell Script to Extract All Documents and Their Versions (I commented the versions part OUT of the script)
- get the value of a managed metadata item
- make it a tab separated value list once it works on the command line
- filtering items out of sharepoint
- Thinking thoughts – 4 ways to extract the data from sharepoint