Wednesday, December 15, 2010

Dave Newman - Leaving .net

It is sad and it is true and this too...

"One of the biggest things I think is missing from .NET is a central place for developers to discuss and collaborate on open source projects. Codeplex proposed to do this and is where a lot of .NET developers look to collaborate, but the problem is it sucks in so many ways…"

- badgrs

How To Safely Store A Password

Found an interesting post about password storage in web app here...

And here is BCrypt.net...

Saturday, December 11, 2010

The Campaign - Save wild fish...

Ask before you buy:
only eat sustainable seafood.
Tell politicians:
respect the science, cut the fishing fleet.
Join the campaign:
for marine protected areas and responsible fishing.

http://endoftheline.com/

What Mono crew are cooking?

What Mono crew are cooking: http://tirania.org/blog/archive/2010/Dec-09-1.html

Thursday, December 9, 2010

Sad news for OpenSource - The ASF Resigns From the JCP Executive Committee

"The Apache Software Foundation concludes that that JCP is not an open specification process - that Java specifications are proprietary technology that must be licensed directly from the spec lead under whatever terms the spec lead chooses; that the commercial concerns of a single entity, Oracle, will continue to seriously interfere with and bias the transparent governance of the ecosystem; that it is impossible to distribute independent implementations of JSRs under open source licenses such that users are protected from IP litigation by expert group members or the spec lead; and finally, the EC is unwilling or unable to assert the basic power of their role in the JCP governance process.

In short, the EC and the Java Community Process are neither.

To that end, our representative has informed the JCP's Program Management Office of our resignation, effective immediately. As such, the ASF is removing all official representatives from any and all JSRs. In addition, we will refuse any renewal of our JCP membership and, of course, our EC position."

Read more here...

Saturday, November 20, 2010

Tiny and beautiful universe in our head



One synapse, by itself, is more like a microprocessor--with both memory-storage and information-processing elements--than a mere on/off switch. In fact, one synapse may contain on the order of 1,000 molecular-scale switches. A single human brain has more switches than all the computers and routers and Internet connections on Earth.

Stephen J Smith

Read more here and here.

Friday, November 12, 2010

Android-Powered Lego Robot Solves Rubik's Cube in 12.5 Seconds



Android-Powered Lego Robot Solves Rubik's Cube in 12.5 Seconds. Read here!

Thursday, November 4, 2010

Microsoft: Our strategy with Silverlight has shifted

Could it bee that Microsoft is moving it's focus from Silverlight to HTML5? Read more...

Wednesday, November 3, 2010

Is your money that good?

Let me ask you one question
Is your money that good
Will it buy you forgiveness
Do you think that it could
I think you will find
When your death takes its toll
All the money you made
Will never buy back your soul


"Masters Of War" by Bob Dylan

Tuesday, November 2, 2010

Small NHibernate example with one-to-one mapping

So we have here database schema. The following database basiclly consists of two tables: my_user and user_profile respectively.
I decided to put small example were I'll demonstrate how to use one-to-one mapping in NHibernate ORM.
We will start by creating two tables. Here it is script for this:
CREATE TABLE [dbo].[my_user](
 [id] [int] IDENTITY(1,1) NOT NULL,
 [user_name] [nvarchar](128) NOT NULL,
 [unique_id] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_users] PRIMARY KEY CLUSTERED 
(
 [id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

CREATE TABLE [dbo].[user_profile](
 [user_id] [int] NOT NULL,
 [is_vip] [bit] NULL,
 [unique_id] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Profiles] PRIMARY KEY CLUSTERED 
(
 [user_id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
Now will create new console program project in Microsoft VisualStudio. Structure of project should be like in the picture above.
Pay attention to references. You should download NHibernate ORM framework from here. In time then I was writing this post I used NHibernate-2.1.2.GA-bin.zip version. Now we will create two classes which will represents our domain objects.
MyUser.cs file:
using System;

namespace NHOneToOneMapping
{
    public class MyUser
    {
        private Guid _uniqueID = Guid.Empty;
        private int _id = 0;
        private string _userName = null;
        private UserProfile _userProfile = null;
        private int _hashCode = 0;

        public MyUser()
        {
            UniqueID = Guid.NewGuid();
        }
        public Guid UniqueID
        {
            get { return _uniqueID; }
            internal set { _uniqueID = value; }
        }

        public int Id
        {
            get { return _id; }
            internal set { _id = value; }
        }

        public string UserName
        {
            get { return _userName; }
            set { _userName = value; }
        }

        public UserProfile UserProfile
        {
            get { return _userProfile; }
            set { _userProfile = value; }
        }
        
        protected virtual bool OnEquals(object other)
        {
            MyUser obj = other as MyUser;
            if (obj != null)
            {
                if (UniqueID != obj.UniqueID)
                    return false;

                return true;
            }

            return false;
        }

        public override int GetHashCode()
        {
            if (_hashCode == 0)
                _hashCode = _uniqueID.GetHashCode();

            return _hashCode;
        }

        public override bool Equals(object obj)
        {
            if (Object.ReferenceEquals(this, obj))
                return true;

            if (obj == null || !(obj is MyUser))
                return false;

            return OnEquals(obj);
        }

        public static bool operator ==(MyUser a, MyUser b)
        {
            if (Object.ReferenceEquals(a, b))
                return true;

            if ((object)a == null || (object)b == null)
                return false;

            return a.OnEquals(b);
        }

        public static bool operator !=(MyUser a, MyUser b)
        {
            return !(a == b);
        }
    }
}
UserProfile.cs file:
sing System;

namespace NHOneToOneMapping
{
    public class UserProfile
    {
        private Guid _uniqueID = Guid.Empty;
        private int _userId = 0;
        private bool _isVip = false;
        private MyUser _myUser = null;
        private int _hashCode = 0;

        public UserProfile()
        {
            UniqueID = Guid.NewGuid();
        }
        public Guid UniqueID
        {
            get { return _uniqueID; }
            internal set { _uniqueID = value; }
        }

        public int UserId
        {
            get { return _userId; }
            internal set { _userId = value; }
        }

        public bool IsVip
        {
            get { return _isVip; }
            set { _isVip = value; }
        }

        public MyUser MyUser
        {
            get { return _myUser; }
            set { _myUser = value; }
        }
        
        protected virtual bool OnEquals(object other)
        {
            UserProfile obj = other as UserProfile;
            if (obj != null)
            {
                if (UniqueID != obj.UniqueID)
                    return false;

                return true;
            }

            return false;
        }

        public override int GetHashCode()
        {
            if (_hashCode == 0)
                _hashCode = _uniqueID.GetHashCode();

            return _hashCode;
        }

        public override bool Equals(object obj)
        {
            if (Object.ReferenceEquals(this, obj))
                return true;

            if (obj == null || !(obj is UserProfile))
                return false;

            return OnEquals(obj);
        }

        public static bool operator ==(UserProfile a, UserProfile b)
        {
            if (Object.ReferenceEquals(a, b))
                return true;

            if ((object)a == null || (object)b == null)
                return false;

            return a.OnEquals(b);
        }

        public static bool operator !=(UserProfile a, UserProfile b)
        {
            return !(a == b);
        }
    }
}
We will create NHibernate xml mapping files.
MyUser.hbm.xml file:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
  <class
  name="NHOneToOneMapping.MyUser, NHOneToOneMapping"
  table="my_user"
  lazy="false"
 >
    <id name="Id" access="field.camelcase-underscore" column="id">
      <generator class="identity" />
    </id>
    <property
      name="UniqueID"
      type="Guid"
      access="field.camelcase-underscore"
      column="unique_id"
      not-null="true"
  />
    <property
   name="UserName"
   type="String"
   access="field.camelcase-underscore"
   column="user_name"
   not-null="true"
  />
     <one-to-one
   name="UserProfile"
      class="NHOneToOneMapping.UserProfile, NHOneToOneMapping"
      cascade="all"
  />
  </class>
</hibernate-mapping>
UserProfile.hbm.xml file:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
  <class
  name="NHOneToOneMapping.UserProfile, NHOneToOneMapping"
  table="user_profile"
  lazy="false"
 >
    <id name="UserId" access="field.camelcase-underscore" column="user_id">
      <generator class="foreign">
        <param name="property">MyUser</param>
      </generator>
    </id>

    <property
      name="UniqueID"
      type="Guid"
      access="field.camelcase-underscore"
      column="unique_id"
      not-null="true"
  />
    <property
      name="IsVip"
      type="Boolean"
      access="field.camelcase-underscore"
      column="is_vip"
      not-null="false"
  />
    <one-to-one
      name="MyUser"
      class="NHOneToOneMapping.MyUser, NHOneToOneMapping"
      constrained="true"
      foreign-key="none"
    />
  </class>
</hibernate-mapping>
No go and create SessionManager.cs file in Infrastructure folder.
using System;

using NHibernate;
using NHibernate.Cfg;

namespace NHOneToOneMapping
{
    public sealed class SessionManager
    {
        private readonly ISessionFactory _sessionFactory;

        public static ISessionFactory SessionFactory
        {
            get { return Instance._sessionFactory; }
        }

        private ISessionFactory GetSessionFactory()
        {
            return _sessionFactory;
        }

        public static SessionManager Instance
        {
            get { return NestedSessionManager.sessionManager; }
        }

        public static ISession OpenSession()
        {
            return Instance.GetSessionFactory().OpenSession();
        }

        private SessionManager()
        {
            if (_sessionFactory == null)
            {
                Configuration cfg = new Configuration().Configure();
                _sessionFactory = cfg.BuildSessionFactory();

                if (_sessionFactory == null)
                    throw new InvalidOperationException("Failed to create session factory.");
            }
        }

        internal class NestedSessionManager
        {
            internal static readonly SessionManager sessionManager = new SessionManager();
        }
    }
}
You will also need configuration file “App.config” and NHibernate configuration section in it.
<?xml version="1.0"?>
<configuration>
  <configSections>
    <!-- custom sections -->
    <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler,NHibernate"/>
  </configSections>

  <!-- NHibernate section -->
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory name="HelloNHibernate">
      <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
      <property name="connection.connection_string">
        Data Source=127.0.0.1;Initial Catalog=HelloNHibernate;Integrated Security=True;Pooling=True
      </property>
      <property name="show_sql">true</property>
      <property name="adonet.batch_size">10</property>
      <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
      <property name="use_outer_join">false</property>
      <property name="command_timeout">60</property>
      <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
      <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
      <property name="current_session_context_class">NHibernate.Context.ThreadStaticSessionContext, NHibernate</property>
      
      <property name="generate_statistics">true</property>
      <!-- add mapping assemblies -->
      <mapping assembly="NHOneToOneMapping"/>
      
    </session-factory>
  </hibernate-configuration>
  <!-- END NHibernate section -->

<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
And the final peace program itself.
Program.cs
using System;
using System.Collections.Generic;

using NHibernate;
using NHibernate.Context;

namespace NHOneToOneMapping
{
    class Program
    {
        static void Main(string[] args)
        { 
            ISession session = SessionManager.SessionFactory.OpenSession();
            CallSessionContext.Bind(session);

            session.Transaction.Begin();

            IList users = session.CreateCriteria().List();
            foreach (MyUser u in users)
            {
                Console.WriteLine("id: " + u.Id +
                    "| UserName: " + u.UserName +
                    "| Profile.IsVip: " + u.UserProfile.IsVip);
            }

            UserProfile profile = new UserProfile();
            profile.IsVip = true;

            MyUser user = new MyUser();
            user.UserName = "Jhon";
            user.UserProfile = profile;
            user.UserProfile.MyUser = user;

            session.Save(user);

            users = session.CreateCriteria().List();
            foreach (MyUser u in users)
            {
                Console.WriteLine("id: " + u.Id +
                    "| UserName: " + u.UserName +
                    "| Profile.IsVip: " + u.UserProfile.IsVip);
            }

            session.Delete(user);

            users = session.CreateCriteria().List();
            foreach (MyUser u in users)
            {
                Console.WriteLine("id: " + u.Id +
                    "| UserName: " + u.UserName +
                    "| Profile.IsVip: " + u.UserProfile.IsVip);
            }

            session.Transaction.Commit();

            Console.ReadLine();

            session = CallSessionContext.Unbind(SessionManager.SessionFactory);
            if (session != null)
            {
                if (session.Transaction != null && session.Transaction.IsActive)
                    session.Transaction.Rollback();
                else
                    session.Flush();

                session.Close();
            }

            session.Dispose();
        }
    }
}
Now run it!
First results. As you can see we query for MyUser but also get UserProfile.
id: 3| UserName: Bond  | Profile.IsVip: True
id: 4| UserName: Joe  | Profile.IsVip: False
id: 5| UserName: Supermen | Profile.IsVip: True
Here is results after we added Jhon.
id: 3| UserName: Bond  | Profile.IsVip: True
id: 4| UserName: Joe  | Profile.IsVip: False
id: 5| UserName: Supermen | Profile.IsVip: True
id: 8| UserName: Jhon  | Profile.IsVip: True
And here are results after we removed Jhon.
id: 3| UserName: Bond  | Profile.IsVip: True
id: 4| UserName: Joe  | Profile.IsVip: False
id: 5| UserName: Supermen | Profile.IsVip: True
P.S. You can extract common things from MyUser and UserProfile classes and move those to new DomainObject base class. I left this intentionally as exercise for reader :)
My NHibernate session creation and binding code is for testing only, please don't use it in production code. Read about this here.
Good reading for one-to-one mapping is here.

Thank you for reading. If you have any idea you like to share or discus, leave it in comments.

Thursday, October 28, 2010

SET STATISTICS IO - Sql Server - tune performance

Say hello to one of may friends: SET STATISTICS IO [ON|OFF]
Information it provides helps identify problems and tune performance. Though you will have to have a lot of practice before this info will became useful. I am still not 100% sure I fully understand data this statement provides. Example:
SET STATISTICS IO ON

SELECT my_user.*, user_profile.*
FROM my_user 
 JOIN user_profile on my_user.id = user_profile.user_id

SET STATISTICS IO OFF
Results:
(3 row(s) affected)
Table 'user_profile'. Scan count 0, logical reads 6, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'my_user'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Syntax and explanation of results read here...

Wednesday, October 27, 2010

NEW YORK (CNNMoney.com) - Microsoft is a dying consumer brand

NEW YORK (CNNMoney.com) -- Consumers have turned their backs on Microsoft. A company that once symbolized the future is now living in the past.Read more...

Tuesday, October 26, 2010

Your time is limited, so don’t waste it living someone else’s life...

Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma, which is living with the results of other people’s thinking. Don’t let the noise of others’ opinions drown out your own inner voice, heart and intuition. They somehow already know what you truly want to become. Everything else is secondary...

Amazing Speech by Steve Jobs at Stanford University Stay Hungry Stay Foolish!

Monday, October 25, 2010

Jogging again...

It is amazing how jogging cleans your thoughts... I will try to start jogging regular again...

Tuesday, October 19, 2010

Facebook in Privacy Breach

Top-Ranked Applications Transmit Personal IDs, a Journal Investigation Finds

Therefore they attempt the impossible – and achieve it

The young do not know enough to be prudent,
and therefore they attempt the impossible – and achieve it,
generation after generation.

Pearl S. Buck

Wednesday, October 13, 2010

Why I hate Entity Framework - EF is tied to specific Net framework version

One big issue the Entity Framework that it is tied to specific version of Net framework. Say if I started using EF1 which is tied to Net framework 3.5 sp1 and Visual Studio 2008 you just can't switch to EF4 which fixes many EF1 annoyances (one of them is lack of POCO support). You would have to switch to Net 4 framework and buy Visual Studio 2010. However I must admit Linq to Entities is nice feature.

Using SELECT to INSERT records – SQL

How to populate one table with data from other table by using one SQL statement?
Normally you would use INSERT statement to populate table with data like this:

INSERT INTO books_csharp(id, title)
VALUES (1, 'Agile Principles, Patterns, and Practices in C#');

but suppose we have already populated table books like this:
id: integertitle: nvarchar(256)tag: nvarchar(32)
1Agile Principles, Patterns, and Practices in C#C#
2Pro C# 2010 and the .NET 4 Platform, Fifth EditionC#
3Agile Testing: A Practical Guide for Testers and Agile TeamsTesting
and we would like to populate similar table books_csharp. So here we go:
INSERT INTO books_csharp (id, title)
SELECT id, title
FROM books
WHERE tag = 'C#'
results:
id: integertitle: nvarchar(256)
1Agile Principles, Patterns, and Practices in C#
2Pro C# 2010 and the .NET 4 Platform, Fifth Edition

P.S. Test and works on Microsoft SQL Server 2008 & PostgreSQL 9

Tuesday, October 12, 2010

Portable way for setting all bits to true in C

I found this discussion in stackoverflow.com Short summary:
unsigned int flags = -1; /* is portable. */
unsigned int flags = ~0; /*isn't portable because it relies on a two's-complement representation.*/
unsigned int flags = 0xffffffff; /* isn't portable because it assumes 32-bit ints. */
If you want to set all bits in a way guaranteed by the C standard, use the first one.

What would happen if you stuck your hand into the Large Hadron Collider - ANSWERED or not?

So finally we have clear answer to the following question:
What would happen if you stuck your hand into the Large Hadron Collider?

Here is the answer or not?

mssql: insert values into table with identity column

You should use IDENTITY_INSERT command like this:
SET IDENTITY_INSERT YourTableName ON

INSERT INTO YourTableName (YourIdentityColumn, ValueCoulmn)
VALUES (1, 'Value')

SET IDENTITY_INSERT YourTableName OFF

Saturday, October 9, 2010

Silverlight and WCF CommunicationException (Cross Domain Issue)

Recently I got the following error while trying to execute Silverlight project:
“An error occurred while trying to make a request to URI '…'. This could be due to
attempting to access a service in a cross-domain way without a proper cross-domain
policy in place, or a policy that is unsuitable for SOAP services. You may need to
contact the owner of the service to publish a cross-domain policy file and to ensure
it allows SOAP-related HTTP headers to be sent. This error may also be caused by
using internal types in the web service proxy without using the
InternalsVisibleToAttribute attribute. Please see the inner exception for more
details.”
After hours of troubleshooting finally I managed to solved problem. It was a silly mistake of launching the Silverlight project directly (as the default start up project when hitting F5) instead of the web project that references the Silverlight project.

I hope this post will save others some time :)

Wikileaks publishes documents on plan to curb free software in the European Union

Wikileaks publishes documents on plan to curb free software in the European Union

Thursday, September 30, 2010

Wednesday, August 11, 2010

C# ?? (null-coalescing) operator

Hi, yesterday I learned something new: meet my new friend it is little known C# ?? (null-coalescing) operator. Now you think what it can do for you? Well this:
// xObject = null;
XClass xNewObject  = xObject ?? new XClass();
:) Read here and here.

Friday, August 6, 2010

HELP WANTED: Unix and Linux StackExchange

Help create a non-tribal version of StackOverflow for Unix and Linux questions. As we know, tribalism makes you stupid. So let us commit to the Linux and Unix Q&A site powered by StackOverflow that will help answer questions for Unix and Linux users of all distributions and blends. At the time of this writing, only 91 users have committed. Tell your Solaris, FreeBSD, NetBSD, OpenBSD, Unix, OSX, Linux, Red Hat, Fedora, Ubuntu, Debian, Mandrake, Mint, Arch, Slackware, CentOS, Gentoo, OpenSUSE, friends to commit to it and help create a global community of Unix love. Miguel de Icaza

Thursday, July 29, 2010

Ir tada žinai, kad gyvenime slypi dar kažkas...

Žinai , vade, aš visuomet buvau racionalistas, neabejojau, kad po mirties nelieka nieko, kad žmogus užgęsta kaip užpūsta žvakė. Tačiau atsidūrus ten, tarp tų žmonių, kur šventųjų giesmės persipina su paprastų mirtingųjų dainomis ir maldomis - ten tave apima visai kitoks jausmas. Ten, tarp šiaurėje stūksančių kalnų, kartais pajunti, kad galėtum ištiesti ranką, nusiraškyti žvaigždę nuo dangaus ir parsinešti... Ir tada žinai, kad gyvenime slypi dar kažkas...

Kankinių kaukės, Jack L. Chalker

Thursday, June 17, 2010

How To Imagine The Tenth Dimension (link)

Very good explanation movie about how to imagine tenth dimensions. Watch here.

Thursday, May 27, 2010

Why I hate Entity Framework (Version 1) – Importing stored procedures with scalar results

Lets start by writing the following simple store procedure example which returns count. Millions of those are used all over the web for paging:
CREATE PROCEDURE sp_CountProducts
(
 @ProductTypeID AS INT
)
AS
SELECT COUNT(*) FROM Products WHERE ProductTypeID = @ProductTypeID
Now you should add this stored procedure to your data layer. Importing stored procedures into you project data layer is simple with Entity Framework, isn't it? If you import stored procedure which returns entity type as results then yes.
  1. update model to include your procedure
  2. make function import
  3. define result type
But what about stored procedures which returns scalars as results? (Now you are F***ED) Then you have the same steps as with previous procedure plus you should write additional code. You will have to extend your Entity Data Model to be able to use you procedure: (I use separate file: EntityDataModel.cs)
public partial class EntityDataModel: global::System.Data.Objects.ObjectContext
{
        private T ExecuteScalarFunction<T>(string functionName, DbParameter[] parameters)
        {
            DbCommand cmd = ((EntityConnection)this.Connection).CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddRange(parameters);
            cmd.CommandText = this.DefaultContainerName + "." + functionName;
            try
            {
                if (cmd.Connection.State != ConnectionState.Open)
                    cmd.Connection.Open();
                var obj = cmd.ExecuteScalar();
                return (T)obj;
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                cmd.Connection.Close();
            }
        }

        // And now your stored procedure
        public int sp_CountProducts(global::System.Nullable<int> regionId)
        {
            EntityParameter ProductTypeIDParameter;
            ProductTypeIDParameter = new EntityParameter("ProductTypeID", DbType.Int32);
            if (regionId.HasValue)
            {
                ProductTypeIDParameter.Value = regionId;
            }

            return ExecuteScalarFunction<int>(
                "sp_CountProducts",
                new EntityParameter[]{ ProductTypeIDParameter });
        }
}
Now you can use your procedure in the application code like this:
using (EntityDataModel context = new EntityDataModel(ConnectionString))
{
    RowCount = context.sp_CountProducts(productTypeId);
}
What is wrong with EF team? What are you drinking at work guys? Thanks GOD you fixed this stupid flaw in EF 4. (One tiny note: to be able to use EF 4 I will have to buy Visual Studio 2010. Isn't it wonderful?)

When you hear of an opportunity you want, you have to go for it completely

Excerpt from story:
  • being in the middle of things increases your chances for opportunities
  • everything great that happens in your career starts with someone you know
  • when you hear of an opportunity you want, you have to go for it completely, over-the-top, not casual, and work your ass off to get it
  • the tiniest detail can derail everything
Very good story about opportunity with moral read full story here

Thursday, May 20, 2010

Finally I contributed to Open Source

Finally I contributed to Open Source. One little bug report but it is a start.

P.S. "Do it F***ing Now" program really works!

Wednesday, May 19, 2010

Vidunaktį dažnai aš pabundu... (Vytautas Mačernis)

Vidunaktį dažnai
Aš pabundu,
Kada keistai, keistai
Visuos namuos tylu,

Ir aš nebežinau,
Kas daros su manim,
Bet man kaskart sunkiau
Tokiom naktim

Išspręst gyvybės ir mirties lygtis
Su begale nežinomųjų.
Veltui aš laukiu: niekas man nepasakys,

Atėjęs iš erdvių giliųjų,
Kodėl kas nors yra? Kodėl aš pats esu
Didžiausia paslaptis visatos slėpinių?

[Šarnelė, 1943.X.17]

Tuesday, May 11, 2010

Using GetVersionEx from C#

using System;
using System.Runtime.InteropServices;

namespace TestGetVersionEx
{
 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
 public struct OSVERSIONINFOEX
 {
  public static int SizeOf
  {
   get
   {
    return Marshal.SizeOf(typeof(OSVERSIONINFOEX));
   }
  }
      
  public uint dwOSVersionInfoSize;
  public uint dwMajorVersion;
  public uint dwMinorVersion;
  public uint dwBuildNumber;
  public uint dwPlatformId;     
  [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
  public string szCSDVersion;
  public ushort wServicePackMajor;
  public ushort wServicePackMinor;
  public ushort wSuiteMask;
  public byte wProductType;
  public byte wReserved;
 }

 class MainClass
 {
  [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  [return: MarshalAs(UnmanagedType.Bool)]
  public static extern bool GetVersionEx (ref OSVERSIONINFOEX lpVersionInfo);
  
  public static void Main (string[] args)  
  {
   string OsInfo = string.Empty;
   OSVERSIONINFOEX info = new OSVERSIONINFOEX ();
   info.dwOSVersionInfoSize = (uint)OSVERSIONINFOEX.SizeOf;
   if (OS.GetVersionEx (ref info)) 
   {
    OsInfo = "\n1. Is Windows: " + PlatformDetection.IsWindows + 
    "\n2. dwOSVersionInfoSize: " + info.dwOSVersionInfoSize + 
    "\n3. dwMajorVersion: " + info.dwMajorVersion + 
    "\n4. dwMinorVersion: " + info.dwMinorVersion + 
    "\n5. dwBuildNumber: " + info.dwBuildNumber + 
    "\n6. dwPlatformId: " + info.dwPlatformId + 
    "\n7. wServicePackMajor: " + info.wServicePackMajor + 
    "\n8. wServicePackMinor: " + info.wServicePackMinor + 
    "\n9. wSuiteMask: " + info.wSuiteMask + 
    "\n10. wProductType: " + info.wProductType + 
    "\n11. wReserved: " + info.wReserved + 
    "\nszCSDVersion: " + info.szCSDVersion;
    Console.WriteLine (OsInfo);
   }
  }
 }
}

Path to true happiness 'revealed' (link)

The 10 steps to happiness
  • Plant something and nurture it
  • Count your blessings - at least five - at the end of each day
  • Take time to talk - have an hour-long conversation with a loved one each week
  • Phone a friend whom you have not spoken to for a while and arrange to meet up
  • Give yourself a treat every day and take the time to really enjoy it
  • Have a good laugh at least once a day
  • Get physical - exercise for half an hour three times a week
  • Smile at and/or say hello to a stranger at least once each day
  • Cut your TV viewing by half
  • Spread some kindness - do a good turn for someone every day
(Read here more.)

Monday, May 10, 2010

Do it F***ing Now.

Do it F***ing Now. Don't wait. Don't procrastinate. The winners in this world are not the ones who find the greatest excuses to put off doing what they know will make them more money. The winners are the ones that prioritize and seize the day. Create a list of action items to make sure your important tasks get accomplished. Every project you're working on should be in action. If you're not moving, you're standing still. Your next step towards making money must not be "something I'll take care of maybe sometime next week." If it's going to help make you money: Do it F***ing Now. Some of you may think that you don't need the "f***ing" in "do it f***ing now". You do. You need that impact, that force, that call to action, that kick in the ass to get you moving. Otherwise, you'll end up another loser that had a great idea a long time ago but never did anything about it. Dreamers don't make money. Doers make money. And doers "Do it F***ing Now." Quote from this blog Read here

Wednesday, April 21, 2010

Don't Give Up #1

Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better. Samuel Beckett

Tuesday, April 20, 2010

Wednesday, March 31, 2010

Game of life (link)

http://www.youtube.com/watch?v=8FSsztwbRW0

Much ado about NULL: An introduction to virtual memory (link)

Good short article: http://blog.ksplice.com/2010/03/null-pointers-part-i/

Thursday, March 11, 2010

20 years of freedom...

Fifty years of communist rule ended with Lithuania, led by Sąjūdis, an anti-communist and anti-Soviet independence movement, reestablished its independence on March 11, 1990.

Dar vis nueina šiurpuliukai nugara kai prisimenu tuos laikus, man velniškai pasisekė, kad viską galėjau matyti savomis akimis. Gal tuo metu nevisai suvokiau ką tai reiškia, niek tokio, dabar praėjus 20 metų, daug geriau tai suvokiu. Kai eilinį kartą bambėsiu kaip sunku gyventi Lietuvoj priminkit man apie tai kas įvyko prieš 20metų. :) Su švente visus!

Mano Matrica Tu...

ANT SLENKSČIO

Atsisėdam ant slenksčio ąžuolinio.
Tu – kojomis į lauką, aš – į vidų.
Pusiau pasauli pasidalinam,
Tu paimi meilę, aš – pavydą.

Tavo akys gėrisi vasara,
Geria šviesą, skraido po dangų.
Mano akys vaikšto po aslą.
Jos tamsiausias kertes aplanko.

Tavo žvilgsnis nubėga į tolį,
Mano žvilgsnis nepramuša sienos.
Tu iš mano kančių kvatoji,
Aš paliest nedrįstu tavo sielos.

Mes ant slenksčio – tarytum ant tilto.
Jis ir jungia krantus, ir skiria.
Tavo nugara manąją šildo,
Mano nugara tavąją tiria.

Tu juokies: „Pasikeiskime vietom,
Padalinkim iš naujo pasauli...“
Ir tada mes kitaip atsisėdam.
Tu – į tamsą, o aš – į saulę.

1969 m. sausis

Baltakis, Algimantas. Dedikacijos: Eilėraščiai. – Vilnius: Vaga, 1975.

Wednesday, February 3, 2010

real developers ship

As we know, There are known knowns. There are things we know we know. We also know There are known unknowns. That is to say We know there are some things We do not know. But there are also unknown unknowns, The ones we don't know We don't know. http://www.codinghorror.com/blog/archives/000773.html

JetBrains PyCharm Preview - New Shiny Python IDE

http://www.jetbrains.net/confluence/display/PYH/JetBrains+PyCharm+Preview

The State of the Internet

Here we take a look at exactly who is using the Internet the most, how they are using it and how much the amount of usage is increasing. At a glance, we can see that there are the same number of men and women who use the Internet. However, their age, educational background and level of income may influence how much time they spend online. http://www.focus.com/fyi/information-technology/state-internet/

Tuesday, February 2, 2010

HipHop for PHP

HipHop for PHP isn't technically a compiler itself. Rather it is a source code transformer. HipHop programmatically transforms your PHP source code into highly optimized C++ and then uses g++ to compile it. HipHop executes the source code in a semantically equivalent manner and sacrifices some rarely used features — such as eval() — in exchange for improved performance... (http://developers.facebook.com/news.php?blog=1&story=358) Hmm, sound interesting... simular to http://code.google.com/p/shedskin/

Monday, February 1, 2010