Dot2Tex Graphs in LaTex

Using widely supported GraphWiz format:
More information here

Mainokset

AutoHotKey script for controlling multiple music applications easily

With the following AutoHotkey script you can control multiple media players easily. In windows, by default all the keyboard shortcuts (special media buttons play, previous, next and stop) will go to all applications. Obviously, this will cause problems if I have both Spotify and foobar2000 both running at the same time.

The script solves the situation by examining window titles and the active window. The script uses following logic when deciding the window that will receive the keyboard button press:

  1. Window that is active (determined by examined window title, for example)
  2. Media player that is currently playing a song (determined by examining window title, for example)
  3. The default player

The script should be easy enough to expand to more media players; the only hard thing is to figure how to determine if the player is actually playing something. In foobar2000, the window title is customizable to make the detection easy (DUI: Go to Preferences->Display->Default User Interface, CUI: Preferences->Display->Columns UI->->Main tab). You can append the following format string so that it will display [Playing] if a song is playing

$if($and(%isplaying%,$not(%ispaused%)),'[Playing]',)

UPDATE: The following script will use last activated window as the default player (see step 3).

#InstallKeybdHook

SetTitleMatchMode  2
commandSpotify := 0
commandFoobar := 1

detectMusicPlayers()
{
  ; all variables are global unless prefixed with local
  global
  DetectHiddenWindows, On
  WinGetTitle, spotifyTitle, ahk_class SpotifyMainWindow
  WinGetTitle, foobarTitle, foobar2000
  WinGetTitle, currentTitle, A
  DetectHiddenWindows, Off
  spotifyTitleLength := StrLen(spotifyTitle)
  spotifyActive := InStr(currentTitle, "Spotify")
  foobarActive := InStr(currentTitle, "foobar2000")
  spotifyPlaying := spotifyTitleLength > 7
  foobarPlaying := InStr(foobar2000, "[Playing]")

  if spotifyActive or spotifyPlaying{
    commandSpotify := 1
    commandFoobar := 0 
    ;MsgBox spotify active
  } else if foobarActive or foobarPlaying {
    commandSpotify := 0
    commandFoobar := 1  
    ;MsgBox foobar active
  } else {
    ;MsgBox spotify not playing
    ;Use "defaults" as specified by CheckActivations
  }
  
}

; Check for window activation
SetTimer, CheckActivations, 300


CheckActivations:
  if WinActive("Spotify") {
    ;MsgBox Spotify activated
    commandSpotify = 1
    commandFoobar = 0
  } else if WinActive("foobar2000") {
    ;MsgBox foobar activated
    commandSpotify = 0
    commandFoobar = 1
  }
  
return


; 122 = play/pause handling
SC122::
detectMusicPlayers()

if commandSpotify {
  ControlSend, , {Space}, ahk_class SpotifyMainWindow 
} else if commandFoobar {
  Run "C:\program files (x86)\foobar2000\foobar2000.exe" /playpause 
}
return

; 110	 = PREV  handling
SC110	::
detectMusicPlayers()

if commandSpotify {
  ControlSend, , ^{Left}, ahk_class SpotifyMainWindow 
} else if commandFoobar {
  Run "C:\program files (x86)\foobar2000\foobar2000.exe" /prev 
}
return

; 119	 = NEXT handling
SC119	::
detectMusicPlayers()

if commandSpotify {
  ControlSend, , ^{Right}, ahk_class SpotifyMainWindow 
} else if commandFoobar {
  Run "C:\program files (x86)\foobar2000\foobar2000.exe" /next 
}
return

; 124	 = STOP handling
SC124	::
detectMusicPlayers()

if commandSpotify {
  ; there is no stop in spotify, use "play/pause" instead
  if spotifyPlaying {
    ControlSend, , {Space}, ahk_class SpotifyMainWindow 
  }
} else if commandFoobar {
  Run "C:\program files (x86)\foobar2000\foobar2000.exe" /stop 
}
return

Powershell script, executing commands to lots of files

Following powershell script goes recursively the folder ”J:\pictures” and converts all avi file to mp4 files. It uses ffmpeg (remember to download newest binary)

I couldn’t get invoke-expression to work (it gave some error about ”-” operator), so I just sticked all the commands to a text file d:\commands.txt and run it as a normal batch script.

I used this script to convert lots of videos shot with my camera to more compatible format.

"" > d:\commands.txt
foreach ($file in get-childitem "j:\pictures" -recurse -include "*.avi"){
$ffmpegprog = "`"C:\Program Files (x86)\WinFF\ffmpeg.exe`"";
$ffmpegparams = " -threads 2 -f mp4 -vcodec libx264 -b 1500k -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -b 1500k -maxrate 2000k -bufsize 4M -bt 256k -refs 1 -bf 3 -coder 1 -me_method umh -me_range 16 -subq 7 -partitions +parti4x4+parti8x8+partp8x8+partb8x8 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -qcomp 0.6 -trellis 2 -sc_threshold 40 -i_qfactor 0.71 -acodec aac -ab 256k -ac 2 -ar 44100";
$command = ($ffmpegprog + " -i `"" + $file.FullName + "`"" + $ffmpegparams + " `"" + [System.IO.Path]::ChangeExtension($file.FullName, ".mp4") + "`"");
$("$command") >> D:\commands.txt
}

You can just copy-paste the file to a powershell window.

For some reason direct execution of the commands.txt batch file didn’t work so you can just run it throught type

type d:\commands.txt > d:\commands.bat

USB Drive letters changing in Windows?

Try this program:

USBDLM

It allows user to make ntfs folder mounts automatically, similar to unix systems.


[Settings]
DeleteMountPointsOnRemoval=1
WriteDebugInfo=1
LogLevel=3
WriteLogFile=1
LogFile=D:\Apps\USBDLM\USBDLM.LOG
;
;Remove unused folder mounts
[DeleteUnusedNtfsMountpoints]
Folder1=C:\mount\
;
;If drive has usbdlm.ini file, use it! Otherwise assign drive letter manually
;Not that by default this works only for USB drives, add BusType definitions
;to process Firewire drives too
[DriveLetters]
Letters=%drive%\usbdlm.ini
Letter1=H
Letter2=I
Letter3=J
Letter4=K
Letter5=L
Letter6=N
;
;If you want to hide particular devices from "safe remove" hardware dialog
;[HideFromSafelyRemoveHardware]
;DeviceID1=USB\VID_0424&PID_2228\26020128B005
;DeviceID2=USB\VID_0424&PID_2602\6&1B3E90B3&0&1

Now, the usb drive should have a configuration file, usbdlm.ini, with the following contents:


[DriveLetters]
Letter1=C:\mount\usbdrive

Much more information is found in the program manual.

ASP.NET Tracing ja System.Diagnostics Tracing

Miten saada ASP.Netin trace logit ylös?

Pitää kääntää sivut käyttäen trace define-vipua eli seuraavat attribuutit pitää lisätä kääntäjille (system.codedom/compilers/compiler) web.config-asetustiedostossa

c#: compilerOptions="/d:TRACE"

vb:compilerOptions="/d:Trace=true"

Sen lisäksi tietenkin tracekuuntelijat:

<system.diagnostics>
<trace autoflush="true">
<listeners>
<add name="WebPageTraceListener"
type="System.Web.WebPageTraceListener, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add name="TestTracer"
type="System.Diagnostics.TextWriterTraceListener, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
initializeData="Asptesttrace.log" />
</listeners>
</trace>

lähde:

Walkthrough: Integrating ASP.NET Tracing with System.Diagnostics Tracing

BackgroundWorker ei kaappaa poikkeuksia DoWork-metodin sisällä jos ohjelmaa ajetaan debug-moodissa VS:llä

BackgroundWorker ei kaappaa poikkeuksia DoWork-metodin sisällä jos ohjelmaa ajetaan debug-moodissa VS:llä. Poikkeuksethan pitäisi pystyä käsittelemään RunWorkerCompleted-eventhandlerin avulla (e.Error)

Syynä on se, että VS on kovin innokas varastamaaan lentävän poikkeuksen.

Korjaus:Jotta ohjelma käyttäytyisi debug-moodissa kuten release-moodissa pitää DoWork-metodi koristella [System.Diagnostics.DebuggerNonUserCodeAttribute()] attribuutilla. esim

[System.Diagnostics.DebuggerNonUserCodeAttribute()]
void worker_DoWork(object sender, DoWorkEventArgs e)
{

}

lähde:

BackgroundWorker unhandled error – MSDN Forums

ASP.NET MVC Preview 2

Latasin ja asensin MVC Preview 2:n (saatavilla asp.net -sivulta). Release noteissa sanotaan ettei toimi asp.net AJAX:n kanssa.

Harmi.

sen verran iso puute tuo on, että en tiedä jaksaako leikkiä tuolla pidempään.

featureita, jotka pisti kuitenkin silmään:

  • Viewien cacheaminen yhdellä koodi-attribuutilla.
  • helppo unit testaus

Virallista RTM-päivää ei MVC:lle ole, veikattu on 2008Q3-Q4.