Wednesday, February 25, 2015

Great way to uninstall all Java products

I have developed script to uninstall some product which matching specified keyword for example uninstall all skype will uninstall all products which includes name "Skype".

Turns out that there is another method to do the same using wmic command.
This is quite impressive that windows has built in method to uninstall application.
This will uninstall all products which starts with name "Java":
wmic product where "name like 'Java%'" call uninstall
Result will be similar to this:
C:\Windows\System32>wmic product where "name like 'Java%'" call uninstall
Executing (\\WINORGA-FKEJIFH\ROOT\CIMV2:Win32_Product.IdentifyingNumber="{26A24AE4-039D-4CA4-87B4-2F03217075FF}",Name="Java 7 Update 75",Version="7.0.750")->Uninstall()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 0;
};

Executing (\\WINORGA-FKEJIFH\ROOT\CIMV2:Win32_Product.IdentifyingNumber="{4A03706F-666A-4037-7777-5F2748764D10}",Name="Java Auto Updater",Version="2.1.75.13")->Uninstall()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 1603;
};
If you do not open command prompt with administrator rights you will receive ReturnValue = 1618

wmic will not work for keywords:
Mozilla, VLC, Notepad++, ImgBurn, Opera, SumatraPDF, WinRAR

Works also for keywords:
7-zip, Apple

Monday, February 23, 2015

Insert div content only on full post page, blogger

This is brilliant way how to modify blogger template and let to inset some content only on full post page:
<b:if cond='data:blog.pageType == &quot;item&quot;'>
<div>
content
</div>
</b:if>

Sunday, February 22, 2015

Scrabble cat

Thursday, February 19, 2015

sed lv char kodi, āčēģīķļņšūž

160 Ā
131 ā
182 Č
209 č
237 Ē
137 ē
149 Ģ
133 ģ
161 Ī
140 ī
232 Ķ
233 ķ
234 Ļ
235 ļ
238 Ņ
236 ņ
190 Š
213 š
199 Ū
215 ū
207 Ž
216 ž
sed "s/\d160/A/g;s/\d131/a/g;s/\d182/C/g;s/\d209/c/g;s/\d237/E/g;s/\d137/e/g;s/\d149/G/g;s/\d133/g/g;s/\d161/I/g;s/\d140/i/g;s/\d232/K/g;s/\d233/k/g;s/\d234/L/g;s/\d235/l/g;s/\d238/N/g;s/\d236/n/g;s/\d190/S/g;s/\d213/s/g;s/\d199/U/g;s/\d215/u/g;s/\d207/Z/g;s/\d216/z/g;"

Do not let Windows 7 to use standard display adapter driver

I have this device VEN_8086&DEV_3582 wchich stands for "Intel(R) 82852/82855 GM/GME Graphic Controller".

This device by defalt is not supported by Windows 7 x86 operating system

The true is that there is actual work around to force windows use older driver
sevenforums.com/drivers/86711-intel-82852-82855-gm-gme-graphics-driver-windows-7-final-solution.html

Open Command Prompt in "Run As Administrator" mode

Take ownership of vgapnp.sys file
takeown /f c:\windows\system32\drivers\vgapnp.sys
Frand full permisission to user administrator
cacls c:\windows\system32\drivers\vgapnp.sys /G administrator:F
Sabotage the actual driver. On the same command promt window launch
notepad c:\windows\system32\drivers\vgapnp.sys
Add at the beggining of file any character for example "x"
Save the file.

Uninstall standard display adapter from Device manager

Restart computer.

Now it will fail to install Standart Display Adapter driver which is good :)

Force to use driver which by default has been replaced with "standard display adapter" driver.
Since this standard driver are destroyed the windows will let you continue with custom driver
http://download.cnet.com/win2k_xp1361-exe/3000-2108_4-104048.html

Direct link (rename to exe):
https://drive.google.com/uc?export=download&id=0B9lXbtZ2650KNHVMR29vUGFBNUE
e9598f4d65c419c4d6c6762af356caa5
16d2f2588039304d2ba195ec747ab1344b0321e0

Monday, February 16, 2015

Unlink OneDrive from on Windows 8.1

Hit Windows+C
Select "Settings"

Select "Change PC Settings"

Go for "OneDrive"

Under "Sync Settings" set "Sync your settings on this PC" switch to "Off"

Sunday, February 15, 2015

Tuesday, February 10, 2015

Configure zabbix agent under KickStart

rm -f /etc/zabbix/zabbix_agentd.conf
cat <<EOT >> /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
DebugLevel=3
EnableRemoteCommands=1
Server=zabbix.catonrug.net
ServerActive=zabbix.catonrug.net
EOT
Host=$(hostname)
echo "Hostname=$Host" >> /etc/zabbix/zabbix_agentd.conf
chconfig zabbix-agent on
Another example to deploy zext_ssl_cert.sh:
#!/bin/sh
mkdir -p /etc/zabbix/externalscripts
cat <<EOT > /etc/zabbix/externalscripts/zext_ssl_cert.sh
#!/bin/sh
#------------------------------------------------------------
# zext_ssl_cert.sh
# Script checks for number of days until certificate expires or the issuing authority
# depending on switch passed on command line.
#
#Based on script from aperto.fr (http://aperto.fr/cms/en/blog/15-blog-en/15-ssl-certificate-expiration-monitoring-with-zabbix.html)
#with additions by racooper@tamu.edu.
#------------------------------------------------------------

DEBUG=0
if [ \$DEBUG -gt 0 ]
then
    exec 2>>/tmp/my.log
    set -x
fi

f=\$1
host=\$2
port=\$3

case \$f in
-d)
end_date=\`openssl s_client -host \$host -port \$port -showcerts -prexit </dev/null 2>/dev/null |
          sed -n '/BEGIN CERTIFICATE/,/END CERT/p' |
          openssl x509 -text 2>/dev/null |
          sed -n 's/ *Not After : *//p'\`

if [ -n "\$end_date" ]
then
    end_date_seconds=\`date '+%s' --date "\$end_date"\`
    now_seconds=\`date '+%s'\`
    echo "(\$end_date_seconds-\$now_seconds)/24/3600" | bc
fi
;;

-i)
issue_dn=\`openssl s_client -host \$host -port \$port -showcerts -prexit </dev/null 2>/dev/null |
          sed -n '/BEGIN CERTIFICATE/,/END CERT/p' |
          openssl x509 -text 2>/dev/null |
          sed -n 's/ *Issuer: *//p'\`

if [ -n "\$issue_dn" ]
then
    issuer=\`echo \$issue_dn | sed -n 's/.*CN=*//p'\`
    echo \$issuer
fi
;;
*)
echo "usage: \$0 [-i|-d] hostname port"
echo "    -i Show Issuer"
echo "    -d Show valid days remaining"
;;
esac
EOT
chmod +x /etc/zabbix/externalscripts/zext_ssl_cert.sh

Monday, February 9, 2015

services.exe eats much RAM


Check SecEvent.Evt size at
C:\WINDOWS\system32\config

Solution is to go under Computer Managment and clear all Security Events

Sunday, February 8, 2015

Friday, February 6, 2015

Count similar MySQL records by date or hits

This will group top messages by freshness!
SELECT count(*), ErrorMessage FROM DataBaseName.TableWithErrors
WHERE CreateDate > DATE_SUB(NOW(), INTERVAL 18 HOUR) 
GROUP BY ErrorMessage ORDER BY CreateDate DESC
This will group top messages by hits!
SELECT count(*), ErrorMessage FROM DataBaseName.TableWithErrors
WHERE CreateDate > DATE_SUB(NOW(), INTERVAL 18 HOUR) 
GROUP BY ErrorMessage ORDER BY count(*) DESC
zabbix_agentd.conf for remote database connection looks like:
EnableRemoteCommands=1
UserParameter=CustomError[*],mysql -h hostname -u zabbix -p password -P 3306 -s <<< 'SELECT count(*), ErrorMessage FROM DataBaseName.TableWithErrors WHERE CreateDate > DATE_SUB(NOW(), INTERVAL $2 HOUR) GROUP BY ErrorMessage ORDER BY CreateDate DESC' | sed "s/\t/ /g" | awk 'NR==$1'
Note that hour and line value (in awk) are replaced with $2 and $1

Item who will retrieve first line of last 20 hours will look like this:
Name: CustomError1
Key: CustomError[1,20]
For second place with 20 hours interval use CustomError[2,20]. For third place - CustomError[3,20].

The trigger is very clever wich counts the characters of reported string and if it is more than zero then output the error string in zabbix dashboard:
Our situation: {ITEM.LASTVALUE}
{servername:CustomError[1,20].strlen()}>0

Thursday, February 5, 2015

Extract videos from Zumba Fitness World Party, Xbox 360 DVD

Create an iso file of DVD

Download command line utility for 64-bit windows:
https://drive.google.com/uc?export=download&id=0BxmEiwnrWfmmdHBpenBSRms2MGs
29b3b8c1fff35a934d02485b135ebe8b
fe7070d20611c3ff91300f203560b7ef6526e183

Thanks to panzi for creating this beautiful utility:
https://github.com/panzi/mediaextract

Now use:
mediaextract.exe --formats=audio,-tracker icon-zumba-world-x360.iso -m 1M
Not luckily for you the dance videos only include the main character and no audio.
Other dancers are included in another video with black backgroun and works as another layer
Audio is only included in hiden bonus videos ;)

If want dance video with audio included you have to stick to this playlist :D
https://www.youtube.com/playlist?list=PL_6ye_-Ihm1ush-uWpL0yF2y950mlAQZ5
You can download all the videos with 4k video downloader and as i do - play Zumba Fitness World Party with XBMC on Raspberry Pi

Sunday, February 1, 2015