CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets for: lesnikowski
C#
//This code outputs: 1234
 
const string s = "1234567890";
for(int i = 0; i < s.Length; i++ )
{
    if (s[i] == '5')
        break;
    Console.Write(s[i]);
}
Console.ReadLine();
by lesnikowski   October 04, 2010 @ 12:00am
Tags:
190 Views
no comments
 
C#
const string s = "1234567890";
for(int i = 0; i < s.Length; i++ )
{
    if (s[i] == '5')
        break;
}
 
 
// Covert to switch on if statement produces infinite loop:
by lesnikowski   October 03, 2010 @ 11:54pm
Tags:
127 Views
no comments
 
C#
internal class SafeFileName
{
    private static readonly List<char> _invalidPathChars = new List<char>(Path.GetInvalidPathChars());
    private static readonly List<char> _invalidFileNameChars = new List<char>(Path.GetInvalidFileNameChars());
    private readonly string _unsafePath;
 
    public SafeFileName(string unsafeFileName)
    {
        _unsafePath = unsafeFileName;
    }
by lesnikowski   September 22, 2010 @ 5:52am
Tags:
156 Views
no comments
 
[Test]
public void AlghoritmUnderTest_2_Returns2Files()
{
     FileInfo[] result = AlghoritmUnderTest();
     CollectionAssert.AreEqual(new[] { "1.zip", "2.zip" }, result.Select(x => x.Name ));
}
by lesnikowski   September 09, 2010 @ 2:15am
Tags:
246 Views
no comments
 
C#
[Test]
public void AlghoritmUnderTest_2_Returns2Files()
{
     FileInfo[] result = AlghoritmUnderTest();
     CollectionAssertExt.AreEqual(new[] { "1.zip", "2.zip" }, result, (x, y) => x == y.Name);
}
 
 
 
by lesnikowski   September 08, 2010 @ 11:42am
Tags:
104 Views
no comments
 
[Test]
public void AlghoritmUnderTest_2_Returns2Files()
{
     FileInfo[] result = AlghoritmUnderTest();
     CollectionAssertExt.AreEqual(new[] { "1.zip", "2.zip" }, result, (x, y) => x == y.Name);
}
 
 
 
by lesnikowski   September 08, 2010 @ 11:41am
Tags:
74 Views
no comments
 
C#
[Test]
public void Idle_ServerDisconnects_NoUnhandeledException()
{
    bool unhandeledException = false;
    UnhandledExceptionEventHandler fail = (sender, args) => unhandeledException = true;
 
    try
    {
        AppDomain.CurrentDomain.UnhandledException += fail;
        WithLogin(client =>
by lesnikowski   August 31, 2010 @ 7:40am
Tags:
123 Views
no comments
 
C#
[Test]
public void Method_Condition_Result()
{
    using(TcpClient client = new TcpClient())
    {
        // set timeout
        client.ReceiveTimeout = (int)TimeSpan.FromSeconds(1).TotalMilliseconds;                
        
        // connect to perfectly working imap server
        client.Connect("mail.lesnikowski.com", 143);
by lesnikowski   April 09, 2010 @ 2:45pm
Tags:
593 Views
no comments
 
C#
using (Imap client = new Imap())
{
    client.Connect(_server);
    client.Login(_user, _password);
    client.SelectInbox();
 
    client.GetAll()
        .ConvertAll(uid => client.GetHeadersByUID(uid))
        .ConvertAll(eml => new MailBuilder().CreateFromEml(eml).Subject)
        .ForEach(Console.WriteLine);
by lesnikowski   March 30, 2010 @ 12:46pm
Tags: Mail.dll
157 Views
no comments
 
C#
[TestFixture]
public class ObjectFactoryTests
{
    [Test]
    public void ResetMemoryLeak()
    {
        for (int i = 1; i < 1000; i++)
        {
            ObjectFactory.Reset();
            if (i % 10 == 0)
by lesnikowski   March 03, 2010 @ 2:12am
Tags:
131 Views
no comments
 
PS C:\Users\Pawel> $builder = New-Object Lesnikowski.Mail.SimpleMailMessageBuilder
PS C:\Users\Pawel> $uids = $imap.Search().Where([Lesnikowski.Client.IMAP.Expression]::Subject("link")).GetUIDList()
PS C:\Users\Pawel> foreach ($uid in $uids ) { $builder.CreateFromEml($imap.GetMessageByUID($uid)).Date }
 
5 lutego 2010 21:50:29
 
 
PS C:\Users\Pawel> foreach ($uid in $uids ) { $builder.CreateFromEml($imap.GetMessageByUID($uid)).From }
 
Address                                                     Name
by lesnikowski   March 02, 2010 @ 1:42pm
Tags:
185 Views
no comments
 
PS C:\Users\Pawel> [Reflection.Assembly]::LoadFile("c:\mail.dll")
PS C:\Users\Pawel> $imap = new-object Lesnikowski.Client.IMAP.Imap
PS C:\Users\Pawel> $imap.Connect("mail.lesnikowski.com")
PS C:\Users\Pawel> $imap.User = "user"
PS C:\Users\Pawel> $imap.Password = "password"
PS C:\Users\Pawel> $imap.Login()
PS C:\Users\Pawel> $imap.SelectInbox()
 
                 MessageCount                        Recent Flags                                           UIDValidity
                 ------------                        ------ -----                                           -----------
by lesnikowski   March 02, 2010 @ 1:33pm
Tags:
242 Views
no comments
 
C#
[Test]
public void Render_Foreach_CanUseRootData()
{
    Assert.AreEqual(
        "List: Pawel Pawel.",
        Template
            .Create("List:{foreach Orders} {FirstName}{end}.")
            .DataFrom(_contact)
            .Render());
}
by lesnikowski   February 23, 2010 @ 5:14am
Tags:
197 Views
no comments
 
<html>
<body>
    Hi {FirstName} {LastName},
    <br />
    <p>
    Your account {if Verified}has{else}<strong>has not</strong>{end} been verified<br />
    Your password is: {Password}
    </p>
    Here are your orders:
    <p>
by lesnikowski   February 19, 2010 @ 5:54am
Tags:
161 Views
no comments
 
C#
Contact contact = ...;
 
string html = Template
     .FromFile("template.txt")
     .DataFrom(contact)
     .Render();
 
 
 
by lesnikowski   February 19, 2010 @ 5:53am
Tags:
193 Views
1 comments
 
C++
void dopelnienie(macierz_t *macierz)
{
    int p,q,m,n,i,j;
    
    macierz_t dopElementu;
    dopElementu.lw = macierz->lw - 1;    // has always one row less
    dopElementu.lk = macierz->lk - 1;    // has always one column less
    alokuj_tablice_macierzy(&dopElementu);
 
    macierz_t dop;
by lesnikowski   January 24, 2010 @ 12:44am
Tags:
173 Views
no comments
 
C++
int wyznacznik(macierz_t *macierz)
{
    macierz_t macierz1;
    macierz1.lw = macierz->lw;
    macierz1.lk = macierz->lk;
    alokuj_tablice_macierzy(&macierz1);
 
    for(int i=0; i<macierz->lw; i++)  
        for(int j=0; j<macierz->lk; j++)
            macierz1.macierz[i][j] = macierz->macierz[i][j];
by lesnikowski   January 24, 2010 @ 12:43am
Tags:
136 Views
no comments
 
C#
Application application = Application.Launch("XXX.exe");
Window window = application.GetWindow("XXX", InitializeOption.NoCache);
by lesnikowski   January 11, 2010 @ 1:27am
Tags:
269 Views
no comments
 
C#
private static void ConfigureShell(IInitializationExpression config)
{
    switch (Environment.OSVersion.Platform)
    {
        case PlatformID.Win32S:
        case PlatformID.Win32Windows:
        case PlatformID.Win32NT:
        case PlatformID.WinCE:
        case PlatformID.Xbox:
            config.ForRequestedType<ISystemShell>().TheDefaultIsConcreteType<WindowsShell>();
by lesnikowski   January 08, 2010 @ 9:56am
Tags:
199 Views
3 comments
 
C#
public class Task
{
    private bool _cancel;
    private IService _service;
 
    public Task(IService service)
    {
        _service = service;
    }
    
by lesnikowski   January 08, 2010 @ 4:52am
Tags:
158 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate