пятница, 5 ноября 2010 г.

Service Broker

С помощью следующего скрипта можно посмотреть для каких баз включен Service Broker^

SELECT [name], is_broker_enabled FROM sys.databases Order By [name]

воскресенье, 1 августа 2010 г.

Spreadsheet with majority internet plans

http://spreadsheets.google.com/pub?key=0AgjBqA-27ZjCcloteS0waUNYQ2NpemJUNU52a3V0Snc&gid=6

четверг, 10 июня 2010 г.

Glue files into big one

for %f in (*.cs) do type %f >> ALL.cs

вторник, 25 мая 2010 г.

How to use Araxis Merge with Total Commander

Add following row in "[Configuration]" section in "C:\Program Files\Total Commander\Wincmd.ini" file:

Comparetool=C:\Program Files\Araxis\Araxis Merge\Merge.exe

Keep in mind that mentioned files may be located in different locations.

суббота, 22 мая 2010 г.

Inside my laptop

http://www.insidemylaptop.com/disassemble-ho-530-notebook-pc-remove-top-cover/

среда, 19 мая 2010 г.

Remove all tables from database SQL

Use the following script, if you want to remove all tables from database:

EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"

среда, 12 мая 2010 г.

Тема моего дипломного проекта

Разработка расширения пользовательского интерфейса системы динамического моделирования задымления для целевого потребления

А вот и его адрес, откуда всегда можно скачать последнюю версию кода и документации:

http://fds2acad.codeplex.com/

понедельник, 22 марта 2010 г.

Visual Studio power commands

http://code.msdn.microsoft.com/PowerCommands

My recommendations.

воскресенье, 14 марта 2010 г.

Strong principles of OOP

1 http://www.lostechies.com/blogs/sean_chambers/archive/2008/03/15/ptom-single-responsibility-principle.aspx должна быть единственная причина для изменения
2 http://www.lostechies.com/blogs/joe_ocampo/archive/2008/03/21/ptom-the-open-closed-principle.aspx модуль можно модифицировать, но нельзя изменять
3 http://lostechies.com/blogs/chad_myers/archive/2008/03/11/ptom-the-liskov-substitution-principle.aspx функция, ссылающаяся на базовый класс, должна иметь доступ к объектам производных классов.
4 http://www.lostechies.com/blogs/rhouston/archive/2008/03/14/ptom-the-interface-segregation-principle.aspx изоляция интерфейса(пример про змею и собаку(собаку можно гладить, змею - нет=> отдельный интерфейс для гладить))
5 http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/03/31/ptom-the-dependency-inversion-principle.aspx (модули более высокого уровня не должны зависеть от модулей более ниизкого уровня, но должны зависеть от абстракций, которые не должны зависеть от деталей, детали не должны зависеть от абстракций)

среда, 3 марта 2010 г.

Accessing object properties.

PropertyDescriptorCollection objProperties = TypeDescriptor.GetProperties(myObj);

foreach (PropertyDescriptor property in objProperties)
{
Console.WriteLine(string.Format("{0} = {1}", property.DisplayName, property.GetValue(shape));
}

пятница, 26 февраля 2010 г.

!!! NVelocity framework does not support Double data type !!!

!!! NVelocity framework does not support Double data type !!!

It means, that you can't directly add, subtract ... your double values in the template. And it is not good. So to resolve this problem you can use two ways:

1 Create you own arithmetic class, which will work with strings and doubles
2 Move all arithmetic outside your NVelocity template

четверг, 25 февраля 2010 г.

Unfortunately it is impossible (((


namespace ConsoleApplication1
{

public class BaseClass
{
public string Prop1 { get; set; }
}

public class DerivedClass : BaseClass
{
public string GetProp1()
{
return Prop1;
}
}

public class Program
{

private static void Main(string[] args)
{
BaseClass objBase = new BaseClass();

objBase.Prop1 = "Helllo";

DerivedClass objDer = objBase as DerivedClass;

Console.WriteLine(objDer.GetProp1());
}
}
}

вторник, 23 февраля 2010 г.

Выполнение кода под учетной записью другого пользователя

//-----------------------------------------------------------------------
//
// Copyright © Altoros Development. All rights reserved.
//

// Pavel Shkleinik
//-----------------------------------------------------------------------

namespace TeamExpand.Chrono.Install.InstallationHelper
{
using System;
using System.Runtime.InteropServices;
using System.Security.Authentication;
using System.Security.Principal;

///
/// Class for users personalisation.
///

public class ImpersonationHelper
{
#region Constants

///
/// Use the standard logon provider for the system.
/// The default security provider is negotiate, unless you pass NULL for the domain name and the user name
/// is not in UPN format. In this case, the default provider is NTLM.
/// NOTE: Windows 2000/NT: The default security provider is NTLM.
///

private const int LOGON32_PROVIDER_DEFAULT = 0;

///
/// This logon type is intended for users who will be interactively using the computer, such as a user being logged on
/// by a terminal server, remote shell, or similar process.
/// This logon type has the additional expense of caching logon information for disconnected operations;
/// therefore, it is inappropriate for some client/server applications,
/// such as a mail server.
///

private const int LOGON32_LOGON_INTERACTIVE = 2;

#endregion

#region Fields

///
/// Token for new user.
///

private IntPtr tokenHandle = IntPtr.Zero;

///
/// Context for newly impersonated user.
///

private WindowsImpersonationContext impersonatedUser;

///
/// Id for the newly impersonated user.
///

private WindowsIdentity newId;

#endregion

#region Constructors

///
/// Initializes a new instance of the class. Use this constructor to utilize .
///

/// User name which will be used during impersonating.
/// Password which will be used during user impersonating.
/// Specifies your Active Directory domain name(keep empty to use default domain).
public ImpersonationHelper(string userName, string password, string domainName)
{
this.UserName = userName;
this.Password = password;
this.DomainName = domainName;
}

///
/// Prevents a default instance of the class from being created.
///

private ImpersonationHelper()
{
}

#endregion

#region Properties

///
/// Gets or sets
///

public string UserName { get; set; }

///
/// Gets or sets
///

public string Password { get; set; }

///
/// Gets or sets
///

public string DomainName { get; set; }

#endregion

#region Methods
///
/// Impersonates user with provided , and .
///

public void ImpersonateUser()
{
if (this.impersonatedUser != null)
{
return;
}

if (!LogonUser(this.UserName, this.DomainName, this.Password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, out this.tokenHandle))
{
throw new InvalidCredentialException(String.Format("Impersonation failed for \"{0}\".", this.UserName));
}

this.newId = new WindowsIdentity(this.tokenHandle);

this.impersonatedUser = this.newId.Impersonate();
}

///
/// Use this method to return system in previous state.
///

public void UndoImpersonalisation()
{
if (this.impersonatedUser == null)
{
return;
}

this.impersonatedUser.Undo();
}

///
/// Performs full clean up.
///

public void CleanUp()
{
if (this.tokenHandle != IntPtr.Zero)
{
CloseHandle(this.tokenHandle);
}
}

#endregion

#region Imports

[DllImport("advapi32.dll", SetLastError = true)]
private static extern bool LogonUser(string username, string domain, string password, int logonType, int logonProvider, out IntPtr token);

[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool CloseHandle(IntPtr token);

#endregion
}
}

понедельник, 15 февраля 2010 г.

Steal video from youtube

javascript: window.location.href = 'http://youtube.com/get_video?video_id=' + swfArgs['video_id'] + "&l=" + swfArgs['l'] + "&sk=" + swfArgs['sk'] + '&t=' + swfArgs['t'];

XSS

Insert the following snippet into the browser's address bar to switch on jquery on the browsered page.


javascript:(function() {
var script = document.createElement('script');
script.src = 'http://jquery-ui.googlecode.com/svn/tags/1.7.2/jquery-1.3.2.js';
document.body.appendChild(script);

$('a').hide();
})();