Javascript to dynamically insert CSS

<script type="text/javascript">
var css='b table tbody tr td img { transition: all 1s ease-in-out 0s; } b table tbody tr td img:hover{ transform:rotate(720deg) scale(2);}';
if (style.styleSheet) style.styleSheet.cssText=css;
else style.appendChild(document.createTextNode(css));
</script>   // 

VBScript Example: Convert a Word document to PDF / Replace a string in a file using regular expressions

' Transforms a doc to a pdf (props to Rafael Winterhalter)
Function DocToPdf( docInputFile, pdfOutputFile )
	Dim fileSystemObject
	Dim wordApplication
	Dim wordDocument
	Dim wordDocuments
	Dim baseFolder

	Set fileSystemObject = CreateObject("Scripting.FileSystemObject")
	Set wordApplication = CreateObject("Word.Application")
	Set wordDocuments = wordApplication.Documents

	docInputFile = fileSystemObject.GetAbsolutePathName(docInputFile)
	baseFolder = fileSystemObject.GetParentFolderName(docInputFile)

	If Len(pdfOutputFile) = 0 Then
	pdfOutputFile = fileSystemObject.GetBaseName(docInputFile) + ".pdf"
	End If

	If Len(fileSystemObject.GetParentFolderName(pdfOutputFile)) = 0 Then
	pdfOutputFile = baseFolder + "\" + pdfOutputFile
	End If

	' Disable any potential macros of the word document.

	On Error Resume Next
	' Open readonly
	Set wordDocument = wordDocuments.Open(docInputFile,,True)
	' See
	wordDocument.SaveAs pdfOutputFile, wdFormatPDF
	wordDocument.Close WdDoNotSaveChanges
	wordApplication.Quit WdDoNotSaveChanges
	Set wordApplication = Nothing
	Set fileSystemObject = Nothing
End Function
' Fill with leading zeros
Function LPad (str, pad, length)
    LPad = String(length - Len(str), pad) & str
End Function
' Get date string in the form 2000-03-31
Function getIsoDateString()
    getIsoDateString = Year(Now) & "-" & LPad(Month(Now), "0", 2)  & "-" & LPad(Day(Now), "0", 2)
End Function
Function replacePatternInFile(file, pattern, replacement)
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	Set objFile = objFSO.OpenTextFile(file, ForReading)

	source = objFile.ReadAll

	Set objRegEx = CreateObject("VBScript.RegExp")
	objRegEx.Global = True   
	objRegEx.IgnoreCase = True
	objRegEx.Pattern = pattern
	source = objRegEx.Replace(source, replacement)

	Set objFile = objFSO.OpenTextFile(file, ForWriting)
	objFile.Write source
End Function
 ' See
Const wdFormatPDF = 17  ' PDF format.
Const wdFormatXPS = 18  ' XPS format.
Const WdDoNotSaveChanges = 0
Const ForReading = 1
Const ForWriting = 2 

' Execute script
Call DocToPdf( "c:\mydocument.docx", "\\strangenetworkpath\" & getIsoDateString & " document.pdf" )
If Err.Number = 0 Then
	Call replacePatternInFile("\\strangenetworkpath\content.html", "/.{0,11} document.pdf", "/" & getIsoDateString & " document.pdf" )
	WScript.Echo "Success!"
End If

Network printer and standby problems

It is strange: If you have a network printer in your network it might be blocking the standby mode of your PC (Thanks to Kramy to point that out):

So my loved standby script was not working properly anymore; setting up the printer using a “local port” was not possible either – scanning was not working that way.

What fixed my script was to disable a service temporarily, the “PnP-X IP Bus Enumerator” service (fancy name, isn’t it?) – so I could create a batch file like this:

net stop IPBusEnum
powercfg /hibernate off
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
net start IPBusEnum

Et voilà, no more annoying fan noises anymore!

Delphi XE 6 – Get currently playing title from Winamp

const   IPC_GETPLAYLISTFILE  : integer = 214;
        IPC_GETPLAYLISTTITLE : integer = 213;
        IPC_GETLISTPOS :integer = 125;

        WINAMP_BUTTON2   : integer = 40045; // play
        WINAMP_BUTTON4   : integer = 40047; // stop
        WINAMP_BUTTON5   : integer = 40048; // next title


procedure Refresh();
    hWinamp: THandle;
    rawString: array[0..500] of Char;
    playlistEntryPointer, hProcessId: Cardinal;
  hWinamp:= FindWindow('Winamp v1.x',nil);
  if hWinamp<> 0 then
      playlistEntryPointer:= SendMessage(hWinamp,WM_USER,SendMessage(hWinamp,WM_USER,0 , IPC_GETLISTPOS), IPC_GETPLAYLISTFILE);

      GetWindowThreadProcessId(hWinamp, hProcessId);
      hWinamp:= OpenProcess(PROCESS_VM_READ,False,hProcessId);

      ReadProcessMemory(hWinamp, Pointer(playlistEntryPointer), @rawString, 500, uselessDummy);

      result:= String(rawString)

    Edit_input.Text := result;

Resize VirtualBox disk size

“Increase VM size.bat”

@echo off
set vboxpath=c:\Program Files\Oracle\VirtualBox
set imgpath=c:\Users\mw\VirtualBox VMs\bananavm\
set imgname=banana.vmdk

cd %imgpath%
"%vboxpath%\VBoxManage" clonehd "%imgname%" "cloned.vdi" --format vdi
ren "%imgname%" "%imgname%.bak"
"%vboxpath%\VBoxManage" modifyhd "cloned.vdi" --resize 25600
"%vboxpath%\VBoxManage" clonehd "cloned.vdi" "%imgname%" --format vmdk
"%vboxpath%\VBoxManage" internalcommands sethduuid "%imgpath%%imgname%"

Copy the putput UUID and open your *.vbox file with an editor. Replace all “old” UUIDs with your copied (this were in my case 2 times)

Sony Z1 Compact “Repair” Bluetooth file transfer

So I was trying to transfer files with Bluetooth:

  • from Sony Z1 Compact to my old phone: this worked flawlessly
  • from my old phone to my Sony Z1 Compact: not at all

I checked all settings and I came up with a really easy solution:

The problem is: the notification “Would you like to accept the incoming file blah blah” is suppressed by a default setting – so if you try send a file to the Z1… it will time out.

So how to restore the notifications for Bluetooth and make file transfers possible:

  1. From your Home screen, tap points
  2. Find and tap Settings > Personalisation> Manage notifications.
  3. Select from “All”: Bluetooth Share