Răzvan Cosma's scratchpad

random scripts of random value

DECLARE @db nvarchar(50)
set @db='my.datab.name'
--close all connections
DECLARE @CMD varchar(100)
WHERE DBId = DB_ID(@db) AND SPId <> @@SPId
OPEN my_cursor
SELECT @CMD = 'KILL ' + CAST(@SPId AS varchar(10))
CLOSE my_cursor
DEALLOCATE my_cursor
dbcc checkdb(@db, REPAIR_ALLOW_DATA_LOSS)

try another dbcc checkdb afterwards to be sure it’s fixed

1. %windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis.exe -u
2. %windir%\system32\cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1
3. %windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -i
4. Enable the 32-bit ASP.net extension from IIS Manager

Connect to the source -> Tasks -> Generate Scripts -> check “Script all objects” -> Script Database Create = true -> Script for Server Version = 200x -> Script Logins = false -> Script Data = true -> Script anything else needed (constraints, fulltext, etc) -> Finish -> change the path for CREATE DATABASE if needed -> execute the script on the other server.

There is no ready-made class, so you’ll have to call the Windows API

[DllImport("KERNEL32.DLL", EntryPoint = "GetPrivateProfileStringW",
SetLastError = true,
CharSet = CharSet.Unicode, ExactSpelling = true,
CallingConvention = CallingConvention.StdCall)]
private static extern int GetPrivateProfileString(
string lpAppName,
string lpKeyName,
string lpDefault,
string lpReturnString,
int nSize,
string lpFilename);
[DllImport("KERNEL32.DLL", EntryPoint = "WritePrivateProfileStringW",
SetLastError = true,
CharSet = CharSet.Unicode, ExactSpelling = true,
CallingConvention = CallingConvention.StdCall)]
private static extern int WritePrivateProfileString(
string lpAppName,
string lpKeyName,
string lpString,
string lpFilename);

continue reading...

Option 1: srvany and instsrv from the Windows Resource Kit
Option 2: Start->Run->MMC->Add snap-in->Group policy->Local computer->Computer configuration->Windows settings->Scripts
The applications will run as Local System

perl -MDate::Manip -e 'Date_Init("Language=Romanian","DateFormat=non-US"); print UnixDate(DateCalc("azi","+ 18 zile lucratoare"),"%A, %e %B %Y%n")'

Output: marti, 8 decembrie 2009

perl -MDate::Manip -e 'Date_Init("Language=Romanian","DateFormat=non-US"); @date=ParseRecur("fiecare simbata din decembrie"); foreach (@date) {$d=UnixDate($_, "%A, %e %B %Y%n"); $d=~s/(\w+)/\u\L$1/g; print $d}'

Simbata, 5 Decembrie 2009
Simbata, 12 Decembrie 2009
Simbata, 19 Decembrie 2009
Simbata, 26 Decembrie 2009

select the rows and columns you want to switch, cut, paste special, transpose

@echo off
for /f %%f in ('ls -1 *avi') do c:\mplayer\mencoder.exe -ovc copy -nosound %%f -o %%~nf.dump
for /f %%f in ('ls -1 *wav') do c:\mplayer\ffmpeg.exe -i %%f -acodec libmp3lame -ar 44100 -ab 64k -ac 1 %%~nf.mp3

for /f %%f in ('ls -1 *dump') do c:\mplayer\mencoder.exe -ovc copy -oac copy -audiofile %%~nf.mp3 %%f -o %%~nf.2.flv
flv (couldn’t find a way to remux without reencoding)
for /f %%f in ('ls -1 *dump') do c:\mplayer\mencoder.exe -vf scale=720x576 -af volume=+16db -ovc lavc -lavcopts dia=2:precmp=2:cmp=2:subcmp=2:vcodec=flv:vbitrate=1024 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -of lavf -ffourcc FLV1 -oac copy -audiofile %%~nf.mp3 %%f -o %%~nf.2.flv

ls is a dir replacement from here

Brilliant motherfucker 🙂

I get the impression that the Windows 7 launch is a lot like seeing an old girlfriend suddenly show up on your doorstep wanting to get back together. She’s had some work done, apparently: stomach stapling to take off some of the weight, breast augmentation, and a radical nosejob to make her look as much like your current girlfriend as medical science will allow.
She’s pretty, of course, almost too pretty. She still wears far too much makeup and carries that desperate look in her eyes. The fragrant haze around her is the perfume she overuses to mask the scent of failure.
But standing there in that low-cut top, you’d almost forget for a moment what a psycho she was- how she used to shut down in the middle of a date and forget everything you were talking about and how she was only happy when you were buying her things. You’d almost forget about carrying around her legacy baggage or those nights when, for seemingly no reason at all, she would simply stop speaking to you and when you asked what was wrong she’d just spit a string of hex code at you and expect you to figure it out.
You complained about her for years before finally deciding to get rid of her, and here she is again. Though, somehow she seems like a completely different person now.
“I’m up here,” she says when she catches you staring at her chest.
Tempted though you may be, you know that over time she’ll get bored and slow down on you just like she always does. And then you’ll be right back where you started: trapped. She keeps you by convincing you that you don’t have a choice. You’re just not smart enough for one option or rich enough to afford the other.
“But I’m different now,” she says, batting her eyes innocently. “I’ve changed.”
Indeed she has. Apparently, she’s really into Cabala now or something like that. It’s helped her discover loads of untapped potential in herself. But it also means that you’ll have to buy all new furniture to fit with her understanding of feng shui. That’s not the only change she has in store for you. The minute you let her move in, she’ll have a new alarm system put in that succeeds only in preventing your friends from coming over on poker night.
She doesn’t love you, but she doesn’t hate you, either. The truth is that she couldn’t care less one way or the other. She’s here because she doesn’t want to be alone. Like all human beings, especially those well past their prime, she wants to feel wanted and, after a string of lost jobs and bad investments, she needs a place to stay.
But all in all, she’s OK. She’s a seven. She’ll do, I guess.

Four Romanian characters are missing in Times New Roman and Arial. The characters are: ș Ș ț Ț, the lower- and uppercase letters S and T with comma below, Unicode codes 0219, 0218, 021B, 021A. Windows XP and its Romanian keyboard layout implements them as small and capital letters S or T cedilla Ş ş Ţ ţ (U+015E, U+015F, U+0162, U+0163). Since the Romanian authorities (Academia Română) have decided that a comma should be used instead of the cedilla, Windows Vista and all future versions will use the former.
To display them correctly, you need to install “European Union Expansion Font Update” from here, and enable “extend support of advanced text services to all programs” in Control Panel->Regional and Language Options->Languages->Details->Advanced.
To change the keyboard input and be able to type the new comma ones instead of cedilla:
1. Download the “Microsoft Keyboard Layout Creator 1.4” from here
2. Save this file somewhere.
3. Open Keyboard Layout Creator->load source file->vistakeys.klc. I have changed ; and ‘ to enter the new characters, and also moved y and z to where God intended them to be in the first place.
4. Project->Build DLL and Setup package->run the generated setup
You should now have a “Romanian – Updated” option in the keyboard layouts.
Update 1: this might break spell-checking in some applications. Open Office works fine. Notepad++ doesn’t display them correctly in the editor window, but does so in the search/replace dialog.
Update 2: Some fonts must be updated with the Vista/OS X equivalents, e.g. Courier New. This fixes Notepad++

Bad Behavior has blocked 52 access attempts in the last 7 days.