Monday, July 20, 2009

converting IP address to IP number

Ip number is a numerical representation of the ip address we are all used to .
For instance 1.2.3.4 = 1690960 ;

It is good for some reasons, like conveting the Ip address to geographical position, or rule manupulation like firewalls and network devices.

How do you do that ?

Here is a little method that shows how to do that in c #

public static uint convertIP(string sIp)
{
string[] sOctecs;
char[] cSeperator = { '.' };
int[] iOctet = new int[4];
uint iReturnIPNumber = 0;
if (sIp != "")
{
bool bConvertOK;
sOctecs = sIp.Split(cSeperator, 4);//split the string to the octets
for (int i = 0; i <>
{
bConvertOK = int.TryParse(sOctecs[i], out iOctet[i]);
if (!bConvertOK)
{
return 0;
}
}//end for
// iOctecs contain integers , lets do the magic

//some math
iReturnIPNumber = (uint)iOctet[3];
iReturnIPNumber = iReturnIPNumber + ((uint)iOctet[2] * (uint)256);
iReturnIPNumber = iReturnIPNumber + ((uint)iOctet[1] * (uint)256 * (uint)256);
iReturnIPNumber = iReturnIPNumber + ((uint)iOctet[0] * (uint)256 * (uint)256 * (uint)256);

}
return iReturnIPNumber;
}


If you need it in the database , then mySQL has a built in functions of converting

mysql> SELECT INET_ATON('192.168.10.50');
+----------------------------+
| INET_ATON('192.168.10.50') |
+----------------------------+
| 3232238130 |
+----------------------------+
1 row in set (0.00 sec)

mysql> SELECT INET_NTOA(839559360);
+----------------------+
| INET_NTOA(839559360) |
+----------------------+
| 50.10.168.192 |
+----------------------+
1 row in set (0.00 sec)

Thursday, July 16, 2009

Vista Speech Regognition API

This will teach your program to read text from the voice it "hears" using .NET 3

so this is how it goes :
  1. Go to the references of your project and add System.Speech.Recognition
  2. Create a new instance of the SpeechRecognitionEngine
    SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new CultureInfo("en-US"));
  3. Set a file to read from and a dictionary to use:
    sre.SetInputToWaveFile("c:\\test.wav");
    sre.LoadGrammar(new DictationGrammar());
  4. Now read
    RecognitionResult rr = sre.Recognize();
  5. If something fails inside the Recognize() then it returns null , otherwise rr.Text will get you the text you are looking for ;
now the problem is and it stays unsolved , that out of the box , the engine does not usually hit the correct text . Good luck and mail me if you have ideas


SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new CultureInfo("en-US"));
sre.SetInputToWaveFile("c:\\test.wav");
sre.LoadGrammar(new DictationGrammar());
RecognitionResult rr = sre.Recognize();
if (rr != null)
{
Console.WriteLine(rr.Text);
}
else
{
Console.WriteLine("Recognition failed");
}
Console.ReadKey();



Sunday, July 12, 2009

Walkthrough: Creating a Windows Service Application in the Component Designer

The full step-by-stem straightforward guide from MSDN to create a Windows Service, all with Eventlog registration, action handling, Setup Project, installation and testing.

http://msdn.microsoft.com/en-us/library/zt39148a.aspx

For all your Visual Studio service-creation needs!

Wednesday, July 8, 2009

Semicolon after the if statement

Too frequent mistake to stay quiet about : the semicolon ";" after the if statement

consider the code

if (booleanMethod(s1,s2));
{
return true; // will be executed anyway
}

The code will return true in every case , because there is a semicolon after the if statement. The problem lays in the definition of the semicolon in modern languages such as C# and JAVA semicolon defines the ending of the statement and since the If statement doen't have to be followed by any other statement the true meaning of the upper code is :
if booleanMethod is true
do - nothing;
return true;

so if we want the code to return true only if booleanMethod is true the correct form would be without the semicolon after the if

if (booleanMethod(s1,s2))
{
// only if the if is true
return true;
}

Tuesday, July 7, 2009

Copying Microsoft SQL table to MySQL


Performing and Performing once again; today, we need much quicker database access than we currently have: we have some Windows servers contacting with the sql database using Microsoft's SQLClient driver for accessing it.

The idea was to cache some frequently used data on the servers in the in memory databases. The problem was copying the tables' schema from the sql server to the mysql without doing in manually. So:

I wanted to recommend the Michael Kofler software . I used the gui versions and had only one problem : they both require the correct MySQL ODBC driver. I used the last version located at http://dev.mysql.com/downloads/connector/odbc/3.51.html#winx64 and nothing worked , because the MySql server version installed was not 64 bit (what a pitty ) therefore, reinstalling the Windows MSI Installer (x86) version solved the issue and the table had been copyed in notime

Thanks Micael

MySQL Memory Table Size

If you're doing some Real Time processing with MySQL, you probably better use a Memory table and only eventually commit the results to a disk table.

But if you do that with the default setting, you'll soon run out of memory on a 16MB table!!

Don't worry, it is configurable!
http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_max_heap_table_size
(Note: this refers to MySQL 5.1 version, you may have another version. Also see page for other system configuration options)

And to make a long story short, open MySQL Administrator --> Health --> System Variables --> Memory --> max_heap_table_size
and set it to 268435456 (=256MB)

Monday, June 29, 2009

Preventing Auto Postbacks

Ever felt like ASP.NET web pages doing postback by themselves? Or better, someone click on Enter and instead clicking on the default button on the webpage, the page just "refreshing" itself.

Well, try
this great code snippets in your body tag:
BODY onkeydown = "return (event.keyCode!=13)"
This code will prevent auto postback of your page when user clicks on Enter. More options are available in the mentioned webpage.

Keep Performing!


Sunday, June 21, 2009

How to choose a PHP IDE?

Check out this great review of PHP IDE features, what you need, and which product has one.

The Big PHP IDE Test: Why Use One And Which To Choose

Tuesday, June 16, 2009

Shrinking Your SQL Server Log File

Well, did you ever found out that your MS SQL Server transaction log is just too large and its utilization is just too low (lets say 60GB size and only 100MB are used...) and SQL Server just don't let you shrink it?

Well
Andrew Arnott found a great solution to get rid of this wasted space and truncate the log:

backup log [dbname] with truncate_only
go
DBCC SHRINKDATABASE ([dbname], 10, TRUNCATEONLY)
go


Keep Performing
RockeTier 1 Billion Events per Day Development Team

Wednesday, June 10, 2009

Eclipse plugins

Morning there
Yesterday I visited the Aluna's "how to buid development enviroment in the Java / JavaEE world"; couple of words about it firstly:
On the other side of the Whale center there was a dentists congress of something,
and the most surreal thing there was an exhibition of the 3M tools for dentists right next to the ice cream and sweets...


Now to business: I would like to write about some interesting eclipse plugins
1. Tptp - Eclipse Test & Performance Tools Platform Project
o Test and performance tools platform
o Does not work with java 6 out of the box
o For java 6 you need to download special agent.
o Supports unitests
o More info - http://www.eclipse.org/tptp/


2. EMF - Eclipse Modeling Framework
o Provides the ability to create UML diagram \ class diagram and other design tools
o Provides simple modeling tools development framework


3. Bird
o Provides the ability to create reports


4. Log4e
o Enriches your environment with the ability to create logging mechanism in your code .
o More info - http://log4e.jayefem.de/


5. FileSync
o Automatically copy every change in the eclipse to the file path.
o More info -http://andrei.gmxhome.de/filesync/index.html

Sunday, June 7, 2009

Hibernate Mapping Cheat Sheet

Ever been developing with Hibernate, and wished something would save your Time and Sanity? Here it is!

http://ndpsoftware.com/HibernateMappingCheatSheet.html

Thursday, June 4, 2009

Java Types and Annotations for Web Services

Sometimes you want to send data between different applications, different programming languages, different machines etc.

One of the standard ways of doing so is using SOAP. Java has built in support for it, just define the following. And then call Endpoint.publish(url, new myClass()) and you're done.

@WebService()
@SOAPBinding(parameterStyle=ParameterStyle.WRAPPED,style=Style.RPC)
public class myClass {
@WebMethod(action="myMethod")
public myOutput myMethod(myInput p_input) {
}
}

Then of course you want your input and output to have some structure, so the other application and/or programming language would understand the WSDL.
For that, see the following reference
Mapping Java Types to XML and WSDL Types

Wednesday, June 3, 2009

Hibernate again

This time , i'm posting here something that did not work for me , however i have found a nice workaround.

The hibernate projection will have to wait

SELECT NAME FROM PRODUCT

Here, the Projection class comes into play. The above query can be rewritten into a Criteria query as:

List products=session.createCriteria(Product.class)
. setProjection(Projection.property(\"name\"))
.list();



Monday, May 25, 2009

Working on two computers using Synergy

I'm working on my laptop, and have another computer next to me which I'm using as an debug server, and sometimes as an extra screen.
The only physical connection between the two computer is being on the same LAN, but for me they are sitting together on the same desk.
So after working a few hours with two keyboards and two mice, I realized there must be a better solution, someone had to have thought of one already!

And so I found Synergy! :-)
Just a few minutes of configuration (inc. figuring out what all those ports, computer names, and screen edged mean), and I have my keyboard and mouse shared with the computer next to me.

Like having multi-monitor configuration, just without ability to move windows between them, and with the processing power of both computer and physical separation between them!

Wednesday, May 20, 2009

Date format


Recently we have had a problem in csv export, that showed the dates in a different format after exporting some rows.
The problem file looked ok, but Microsoft Excel did not show it as we expected ,as showed up , because of the reason that the dates where in the en-US format ,and since we are Israelis, our computers work in he-IL , which is actually almost en-UK
When a date is 5/10 , excel assumes that it is fith of october (wich is still wrong but we don't care as long as it is a date) ;) , however when the date is 5/16 excel files to recognize the 16-th month (hextober, duh !) and shows the date as a string , wich driving our clients nuts

Great so far, because we know what is the problem but the solution was a little triky , because the whole application has culture preset to en-US and actually i was a little bit scarred to change it , therefore we used the dtColData.ToString("yyyy'-'MM'-'dd' 'HH':'mm':'ss") wich worked allright

Sunday, May 10, 2009

Hibernate - how to add a new table

hibernate creating new table

checklist

1. create the table in the database
2. create the class only members this time
3. create the hbm.xml file with mapping of the class members to the
4. update the hibernate.cfg.xml with the new hbm file you have created
5. create the test - and make it fail (c'mon in never works on the first time )

more is comming
  • foreign keys
  • pictures
  • more detailed how to

Thursday, April 16, 2009

How to cause 'div' to behave like a button

Our graphics guys decided that is it a neat idea to use divs instead of normal html buttons at bugsondemand.com. Actually, I prefer buttons but hey.. I'm a stupid man , I would never appreciate a masterpice , a top of the design for me is google.com just boring input and two buttons..

Anyway if you want to let your divs to behave like buttons when the mouse passes over, you need to change the mouse cursor to the pointer

This is how it is done :


<div id="BuyCredits2" style="this.style.cursor='pointer'">
<label style="this.style.cursor='pointer'">Buy Credits</label>
</div>


There are some more pointer options

  • default
  • auto
  • crosshair
  • hand
  • wait
  • help
  • text
  • move
  • n-resize
  • s-resize
  • e-resize
  • w-resize
  • ne-resize
  • nw-resize
  • se-resize
  • sw-resize
  • pointer

Monday, April 13, 2009

Apache Tomcat's Cache Fushing

We have had a problem updating our site content that at the end turned to be Tomcat cache.

Apearently, Apache Tomcat web server hat it own's cache and doenst refresh it too often. we fund that out asking Shahar Zehavi , our new Development Team Leader.

What was done :

  1. Stop the Tomcat
  2. Go to "/home/USERNAME/apache-tomcat-6.0.18/work/Catalina/localhost"
    here are the files that will be deleted.
  3. DELETE : \rm -rf *
I belive that removing the file only will do the job as well , but hey .. when you are putting a new code you should let the old one go ..

please note :
  • you have to change the USERNAME to your coresponding username
  • be careful deleting
Good luck

Tuesday, March 31, 2009

Need a quick and cheap website design ?

This is a site that gives lot's of nice designs (html and CSS ) for free

Please don't forget to check the license for the design: most of them are under

You are free to copy, distribute, display, and perform the work, to make derivative works and to make commercial use of the work under the following conditions:

You must attribute the work in the manner specified by the author or licensor. For any reuse or distribution, you must make clear to others the license terms of this work. Any of these conditions can be waived if you get permission from the copyright holder.

Public domain

You are free to copy, distribute, display, and perform the work, to make derivative works and to make commercial use of the work.

Or GNU GPL

Monday, March 30, 2009

Eclipse .classpath file relative paths

Hello All.

One of the most annoying aspects of eclipse is the fact that you have to add jar files to your project if you want to use external libraries.
Further more the configuration of these jar file is by default only using absolute paths, so when you try to move the project from one machine to another you need to delete pointers to old jars and add the new jar locations.

We solved this problem by:
1. putting all the project external jar files in a single library called lib in the project top level folder (trunk).
2. Setup an eclipse classpath varible (see this link http://www.informit.com/articles/article.aspx?p=367962 and look for figure 6-5

In addition I added the .classpath file to the svn. We can now all use this file without modifications.

Sunday, March 29, 2009

From my security consulting days

It seems that I'm getting rusty and forgetting the system structure of the mycrosoft database, however, my lazyness as my fame keeps me going

This afretnoon, after the database has been changed once again due to the customers requirements (why oh why !?) and your servant had to update the webservice for supplying what the custommer wanted (remember the webcomic right?) ...

So here I sit and checking the the table that had to update .. it seems that it is [tblByyyyReeee] that has a new collumn but grrr : the CopyPaste does not work here . Romi offers clicking on the table's name in the Object Explorer , but hey , there is a nice way to that

Scratching my old security consulting days memories back there in Comsec here is

select *
from syscolumns
where id in(
select id
from sysobjects
where name = 'tblByyyyReeee'
)

P.S. this is how you steal the database using the simple SQL Injection Vulnerability

Wednesday, March 18, 2009

Sun plans to make the cloud cumputing service avalible

http://www.sun.com/solutions/cloudcomputing/index.jsp

At Sun, we envision a world of many clouds, both public and private, that are open and compatible. With our open cloud initiative, we plan to offer an extensive portfolio of products and services and to foster open communities and partner ecosystems, to make this vision a reality. It all starts with the delivery of the Sun Cloud, a public compute and storage cloud, which is due out later this year. they say 

We will wait and see. Wish them a lot of luck

JavaScript Ad Rotation

We just tried to implement a small mini ad rotation for a demo. There so many examples for doing it on client side using JavaScript, but so many are just not working. Therefore, please find attached how to implement it in 3 steps:

1. Place the following code is jsRotate.js
function init() { // Specify the image files window.Pic = new Array(); window.Pic[0] = './images/ulogo0.jpg'; window.Pic[1] = './images/ulogo1.jpg'; window.Pic[2] = './images/ulogo2.jpg'; window.Pic[3] = './images/ulogo3.jpg'; window.Pic[4] = './images/ulogo4.jpg'; // Set slideShowSpeed (milliseconds) window.slideShowSpeed = 3000; // Duration of crossfade (seconds) var crossFadeDuration = 3; // No need to edit var t; window.j = 0; window.p = window.Pic.length; } function runSlideShow(){ if (document.all){ document.images.SlideShow.style.filter="blendTrans(duration=2)"; document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"; document.images.SlideShow.filters.blendTrans.Apply(); } document.images.SlideShow.src = window.Pic[j];//./images/ulogo3.jpg';//; if (document.all) { document.images.SlideShow.filters.blendTrans.Play(); } window.j = window.j + 1; if (window.j > (window.Pic.length-1)) { window.j = 0; } t = setTimeout('runSlideShow()', window.slideShowSpeed); }

2. Add a reference to js file inside the head tag using the script tag:
...script language="javascript" src="./scripts/jsRotate.js"...

3. Place the following code just before the /body tag (ya, where you can find the Google Analytics code...)

script language="JavaScript" type="text/javascript"... init(); runSlideShow(); ...script...

It's so simple as 1,2,3...

Setup PHP Dev. environmnet with IIS 7

Hello All.

Here is what need to be done to setup php with eclipse IDE and run things with IIS
1. Download php latest version and install it in a pah without blanks http://www.php.net/downloads.php make sure that you select the IIS ISAPI deployment method when promted in the installation
2. Setup the PHPRC environment variable to point to your installation
3. Make sure that the PHP executables are added to your PATH
4. update the php.ini in your php dir to allow short open tag (set short_open_tag = On)
5.follow the instructions in http://brh.numbera.com/blog/index.php/2008/03/09/setting-up-iis7-with-bonus-php-instructions/

Have fun

How to setup Java Dev. Environmernt (Java, Eclipse, Tomcat)

Hello All.

You basically need two things:
1. The Java JDK that can be downloaded from http://java.sun.com/javase/downloads/index.jsp
2. Install JDK on your machine (in a path without blanks!!!).
3. Setup the environment var JAVA_HOME to point to your new installation.
3. download eclipse (choose the Eclipse IDE for Java EE Developers (163 MB)) package and unzip it in some folder http://www.eclipse.org/downloads/
4. download tomcat from the apache site http://tomcat.apache.org/download-60.cgi
5. Follow the instructions here to setup your env http://www.ibm.com/developerworks/opensource/library/os-eclipse-tomcat/index.html

Enjoy

Tuesday, February 24, 2009

Getting output paramater with ExecuteReader()

When you have a stored procedure that return both a result set and a return value, and you use ExecuteReader() to get the result set, you can only get the output parameter when you close the reader!

http://support.microsoft.com/kb/310070

SqlCommand sqcMyProc = new SqlCommand("[dbo].spMyProc", sqDBConnection);
sqcMyProc.CommandType = CommandType.StoredProcedure;
sqcMyProc.Parameters.Add(new SqlParameter("@nSomeParam", SqlDbType.BigInt));
sqcMyProc.Parameters["Result"].Direction = ParameterDirection.ReturnValue;
sqcMyProc.Prepare();
SqlDataReader sqrMyProcReader = sqcMyProc.ExecuteReader();
if (sqrMyProcReader.Read())
{
// read data
}
sqrMyProcReader.Close(); // output param only available after closing reader

(int)sqcMyProc.Parameters["Result"].Value; // here is the return value

Sunday, February 22, 2009

How to Implement a Join between 2 Tables in T-SQL/SQL Server UPDATE Statement

Thanks for WineIsGood:

UPDATE tblA
SET tblA.a_myField = tblB.b_newField
FROM tblA, tblB
WHERE tblA.a_b_id = tblB.b_id

GigaSpaces XAP .NET-Java Interoperability

For all kind of data that you move between .NET and Java code that connects to GigaSpaces, please refer to this page to match types correctly:

http://www.gigaspaces.com/wiki/display/XAP66NET/.NET-Java+Interoperability

Database Connection Open/Close

It seems trivial that you first open your connection, and eventually close it, but what happens when you're doing it in a loop, and one miss causes havoc forever until restart?

Make sure you open only if it's not closed, you close only if it's not open, and handle every exception. See following code example:

try //catch (Exception E)
{
try //finally close DB
{
// open only if not already open
if (oSqlConn.State!=ConnectionState.Open)
oSqlConn.Open();

// *** READ FROM DATABASE ***

}
finally
{
// close only if not already closed
if (oSqlConn.State != ConnectionState.Closed)
oSqlConn.Close();
}
}
catch (Exception E)
{
// handle exception
}

Microsoft Visual Studio Error

After reintalling the pc I have faced an error while attempting to connect to the database (Microsoft SQL Server) from the Visual Studio.

The Error said:
'Microsoft.SqlServer.Managment.Sdk.Sfc, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of it's dependencies. The system cannot find the file specified 

The solution was very simple and I found it on Agha Usman Ahmed's blogg
you just have to install some components from here "Microsoft SQL Server 2008 Feature Pack, August 2008"

let's see if it works 

Wednesday, February 18, 2009

C sharp 3 and LINQ


This morning I was in the Israeli office of some small start-up company from Seattle to listen to Pavel Yosifovich from "Hi-Tech College". The guy showed some interesting stuff about C# 3. Some of them are well known, the others are less known and very useful.

· Implicitly Typed Local Variables

Just like in javascript :
var keys = data.Keys; // Dictionary.KeyCollection

· Automatic Properties

public class Person { // C# 3.0

public string FirstName { get; set; }

public string LastName { get; set; }

public int Age { get; set; }

}

· Object Initializers

Person p = new Person() {

FirstName = "Bart", LastName = "Simpson", Age = 12

};

· Collection Initializers

var people = new List() {

new Person() { FirstName = "Bart", LastName = "Simpson", Age = 12 },

new Person() { FirstName = "Clark", LastName = "Kent", Age = 35 },

new Person() { FirstName = "Peter", LastName = "Parker", Age = 30 }

};

· Anonymous Types

ar people = new[] {

new { FirstName = "Clark", LastName = "Kent", Age = 36 },

new { FirstName = "Peter", LastName = "parker", Age = 26 },

new { FirstName = "Bart", LastName = "Simpson", Age = 11 }

};

foreach (var i in people)

Console.WriteLine("{0} {1} ({2})", i.FirstName, i.LastName, i.Age);

· And my favorite : Extension Methods

public static class MyExtensions {

public static string UpperLower(this string str, bool upperFirst) {

StringBuilder newString = new StringBuilder(str.Length);

for (int i = 0; i <>

newString.Append(upperFirst ? char.ToUpper(str[i]) :

char.ToLower(str[i]));

upperFirst = !upperFirst;

}

return newString.ToString();

}

}

…..

string input = Console.ReadLine();

Console.WriteLine("calling extension method for {0}: {1}", input,

input.UpperLower(true));

all those things look nice and handy , but they become really usefull when we are talking about LINQ :

The LINQ Project is a codename for a set of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations. It extends C# and Visual Basic with native language syntax for queries and provides class libraries to take advantage of these capabilities.

.. and what does it mean ?


Does it mean that we can finally quit using SQL. We are programmes! We know objects and hate sql!!!


This is how the famous Northwind database looks like

..each box ,is translated to a class and then translated to something like this


[Table(Name="dbo.Categories")]

public partial class Category : INotifyPropertyChanging, INotifyPropertyChanged

{

private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

private int _CategoryID;

private string _CategoryName;

private string _Description;

private System.Data.Linq.Binary _Picture;

private EntitySet _Products;

#region Extensibility Method Definitions

partial void OnLoaded();

partial void OnValidate(System.Data.Linq.ChangeAction action);

partial void OnCreated();

partial void OnCategoryIDChanging(int value);

partial void OnCategoryIDChanged();

partial void OnCategoryNameChanging(string value);

partial void OnCategoryNameChanged();

partial void OnDescriptionChanging(string value);

partial void OnDescriptionChanged();

partial void OnPictureChanging(System.Data.Linq.Binary value);

partial void OnPictureChanged();

#endregion

public Category()

{

this._Products = new EntitySet(new Action(this.attach_Products), new Action(this.detach_Products));

OnCreated();

}

and finally might be used like this


NorthwindDataContext ctx = new NorthwindDataContext();

ctx.DeferredLoadingEnabled = false;

DataLoadOptions opts = new DataLoadOptions();

opts.LoadWith(c => c.Products);

ctx.LoadOptions = opts;

-------

var categories = from c in ctx.Categories

select c;


foreach (var category in categories) {

Console.WriteLine(category.Products.Count());

}


var result = ctx.SalesByCategory("Beverages", "1998");

foreach(var r in result)

Console.WriteLine("{0}, {1}", r.ProductName, r.TotalPurchase);

Monday, February 16, 2009

Hibernate Unique Ids

It seems that hibernate does not really like working with unique ids in the database (we experiemented it when using the embedded version in Gigaspaces).

A way to overcome the issue, is adding a new field to the database, which will be used as unique field, and its value will be generated on the fly in the application level.

The unique value can be generated using the relevant API (GUID in MS) and UUID in Java:

import java.util.UUID;

public class GenerateUUID {
public static final void main(String... aArgs) {
//generate random UUIDs
UUID idOne = UUID.randomUUID();
UUID idTwo = UUID.randomUUID();
log("UUID One: " + idOne);
log("UUID Two: " + idTwo);
}
private static void log(Object aObject){
System.out.println( String.valueOf(aObject) );
}
}

Thursday, February 12, 2009

Hibernate: Log SQL Statements

It's very useful when debbuging Hiberante based system to be aware of the SQL output that is being sent to the database (like the old phrase Garbage In Garbage Out)
There are two methods to do that:
1. Enable hiberante logging
2. Enable the RDBMS log files, for example: Enable MySQL SQL logging

Thursday, January 22, 2009

Security Development guide

it's about time that i've done that :) 

here are security best practices named "OWASP Development Guide 2.0"

http://prdownloads.sourceforge.net/owasp/OWASPGuide2.0.1.pdf?download

it is highly recommended to at least review the documet since it has been written by Real proffecionals who are not being paid directly for writing this 

Monday, January 19, 2009

Learn CSS Positioning in Ten Steps

http://www.barelyfitz.com/screencast/html-training/css/positioning/
 

This tutorial examines the different layout properties available in CSS: position:static, position:relative, position:absolute, and float.

just read it 

Sunday, January 18, 2009

Adding new popup window (modal) to a webpage

Adding new popup window (modal) to a webpage is not that hard, but can be a little tricky.
let's describe how it should be done :

  1. We create an asp:Panel 
  2. We create an modalPopupExtender. It is located in the AjaxControlToolkit 
  3. We Create a Hidden Button . Something has to be a trigger for a popup to show up. If you do that as I do , meaning you make a modal to show up on screen using a Javascript (latter) you still have to create a control to trigger the modal. That's why we create a asp:button.
    <asp:button id="openModal1" runat="server">
     
  4. Configuration 
  5. 1-ModalPopupExtender :  
    TargetControlID should point to the button or the control we want to trigger the popup
    PopupControlID should point to the panel we want to open (step 2 )
    BehaviorID is the clientside name of the popup .. if we want to call it from  the HTML\javascript $find('behID').show(); will show up the popup . 
    2-Panel the Id has to the the value in the PopupControlID
  6. Then, we add the script that shows up the modal , something like :
    function onLoad(){
    $find('behID').show();
    }
  7. note that the value in the brackets points to the behaviorID proterty of the ModalPopupExtender

Sunday, January 11, 2009

How to handle ampersands in webconfig

The problem:
inserting a value with ampersand in webconfig results with an error

The solution:
Try using & in place of the ampersand character or thedecimal code equivalent, when inserting variables to web config

Tuesday, January 6, 2009

The latest Microsoft Academy III Presentations

See all here

ALM301 - Web Sites Testing with Visual Studio Team System (Level 300)
ALM302 - Test Driven Development (TDD) with Visual Studio Team System (Level 300)
ALM303 - Professional Developer Tools in Visual Studio Team System (Level 300)
ARC202 - Architecting Real-World Enterprise Application – Considerations and Dilemmas (Level 200)
ARC301 - "Velocity": Distributed Cache for Performance, Scalability and Availability (Level 300)
DEV301 - HTTP Web Services with Windows Communication Foundation 3.5 (Level 300)
DEV302 - Building Your First Great Silverlight 2 Application (Level 300)
DEV303 - Integrating Silverlight 2 into Existing Web Sites (Level 300)
DEV305 - Leverage SQL Server 2008 in Your .Net Code with Visual Studio 2008 SP1 (Level 300)
DEV306 - Windows Azure: Building Web Sites and Services in the Cloud (Level 300)
DEV308 - Internet Explorer 8 : What's New for Developers? (Level 300)
DEV309 - Building Web Sites with ASP.NET MVC Framework (Level 300)
DEV311 - Building Windows 7 and Windows Vista Compatible Applications (Level 300)
DEV312 - Dynamic Languages and the .Net Framework (Level 300)
DEV313 - Building Composite Applications in WPF (Level 300)
DEV314 - Design Patterns – Learn From the Experience of Others (Level 200)
DEV401 - ASP.NET Ajax Internals (Level 400)
DEV402 - Concurrent Programming: From Thread Pool to Parallel Extensions (Level 400)
DEV403 - A Deep Dive into LINQ (Level 400)
DEV404 - Hardcore C#: Hidden Power and Flexibility (Level 400)

Wednesday, December 31, 2008

Refactoring -Inheritance, Polymorphism, & Testing

This is a video "The Clean Code Talks -- Inheritance, Polymorphism, & Testing"
The video talks about using Polymorphism instead of IF's and Cases