Saturday, March 31, 2012

MPD/MPC - Current song as pidgin status message

It's super simple :)
purple-remote "setstatus?message=np: `mpc current`"
Requires, in addition to pidgin obviously, the dbus-python package (whatever it is called in your distro of choice).

This is my shortest post yet.

Tuesday, March 27, 2012

XBMC - AirPlay, not working

As I've said, I build xbmc from source and use the ubuntu server-version to try and keep it somewhat slim. This might not be a problem on another distro or on the regular desktop-version of ubuntu.

So, xbmc has AirPlay support now, how wonderful...
What's that? It doesn't work when you enable it in the settings? How silly.

Turns out you need to:
apt-get install avahi-daemon
for it to actually work.

The configure script does check for avahi when you ./configure but it seems to enable it regardless if it is installed or not.
I was under the impression that:
--enable-airplay        enable AirPlay support(default is auto)
--enable-airtunes       enable AirTunes support(default is auto)
those autos would enable it if all prerequisites are met. I might be wrong though. :)

Anywho, it works when you get the avahi-daemon installed at least.

Wednesday, March 21, 2012

Get and restore latest SQL backup

@echo off
:: Variables
SET instance=localhost
SET user=backup
SET pwd=sekkrit
SET db=northwind

:: Using mapped drive here, should work with unc as well.
SET remotePath=N:
SET localPath=X:\temp\SqlServer

SET localFile=%localPath%\%db%\%db%_latest.bak

SET dbPath=X:\MSSQL\DATA
SET dbmdf=%db%_data
SET dblog=%db%_log
:: ------------------------------------------------------

:: File transfer. Could preferably use robocopy.
if exist "%localFile%" del "%localFile%"

:: Finding latest backup.
FOR /F "delims=|" %%I IN ('DIR "%remotePath%\%db%\*.bak" /B /O:D') DO SET newestFile=%%I
echo %date% %time% - Getting %remotePath%\%db%\%newestFile%

:: Copy latest backup
copy "%remotePath%\%db%\%newestFile%" "%localFile%"

if not exist "%localFile%" goto fail

echo %date% %time% - Copy done

echo.
echo.

:: Restore
echo %date% %time% - Restoring: %localFile% to database: %db%
echo.
echo Setting single_user (%db)
sqlcmd -S %instance% -U %user% -P %pwd% -d master -Q ^
"ALTER DATABASE [%db%] ^
SET SINGLE_USER WITH ^
ROLLBACK AFTER 60"

echo.
ping localhost /n 90 > nul

echo Restoring %db
sqlcmd -S %instance% -U %user% -P %pwd% -d master -Q ^
"RESTORE DATABASE [%db%] ^
FROM  DISK = N'%localFile%' ^
WITH  REPLACE, FILE = 1, ^
MOVE N'%dbmdf%' TO N'%dbPath%\%db%.mdf', ^
MOVE N'%dblog%' TO N'%dbPath%\%db%_log.ldf', ^
NOUNLOAD, STATS = 10"

echo.
echo %date% %time% - Completed restore of database: %db%
ping localhost /n 10 > nul

:end
goto :eof

:fail
echo Fail
goto :eof

Saturday, March 10, 2012

Flexget - From RSS and files to Deluge

Purely theoretical examples... of course. ;)

RSS-feeds with multiple groups and settings per group