For instance 1.2.3.4 = 1690960 ;
Monday, July 20, 2009
converting IP address to IP number
For instance 1.2.3.4 = 1690960 ;
Thursday, July 16, 2009
Vista Speech Regognition API
- Go to the references of your project and add System.Speech.Recognition
- Create a new instance of the SpeechRecognitionEngine
SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new CultureInfo("en-US")); - Set a file to read from and a dictionary to use:
sre.SetInputToWaveFile("c:\\test.wav");
sre.LoadGrammar(new DictationGrammar()); - Now read
RecognitionResult rr = sre.Recognize(); - If something fails inside the Recognize() then it returns null , otherwise rr.Text will get you the text you are looking for ;
Sunday, July 12, 2009
Walkthrough: Creating a Windows Service Application in the Component Designer
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
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.
MySQL Memory Table Size
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
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?
The Big PHP IDE Test: Why Use One And Which To Choose
Tuesday, June 16, 2009
Shrinking Your SQL Server Log File
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
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
http://ndpsoftware.com/HibernateMappingCheatSheet.html
Thursday, June 4, 2009
Java Types and Annotations for Web Services
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
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
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
Sunday, May 10, 2009
Hibernate - how to add a new table
- foreign keys
- pictures
- more detailed how to
Thursday, April 16, 2009
How to cause 'div' to behave like a button
<div id="BuyCredits2" style="this.style.cursor='pointer'">
<label style="this.style.cursor='pointer'">Buy Credits</label>
</div>
- 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
- Stop the Tomcat
- Go to "/home/USERNAME/apache-tomcat-6.0.18/work/Catalina/localhost"
here are the files that will be deleted. - DELETE : \rm -rf *
- you have to change the USERNAME to your coresponding username
- be careful deleting
Tuesday, March 31, 2009
Need a quick and cheap website design ?
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.
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
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
Wednesday, March 18, 2009
Sun plans to make the cloud cumputing service avalible
JavaScript Ad Rotation
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
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)
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()
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
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
http://www.gigaspaces.com/wiki/display/XAP66NET/.NET-Java+Interoperability
Database Connection Open/Close
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
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
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
};
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 }
};
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));
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
#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
OnCreated();
}
and finally might be used like this
NorthwindDataContext ctx = new NorthwindDataContext();
ctx.DeferredLoadingEnabled = false;
DataLoadOptions opts = new DataLoadOptions();
opts.LoadWith
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
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
There are two methods to do that:
1. Enable hiberante logging
2. Enable the RDBMS log files, for example: Enable MySQL SQL logging
Tuesday, February 3, 2009
Thursday, January 22, 2009
Security Development guide
Monday, January 19, 2009
Learn CSS Positioning in Ten Steps
Sunday, January 18, 2009
Adding new popup window (modal) to a webpage
- We create an asp:Panel
- We create an modalPopupExtender. It is located in the AjaxControlToolkit
- 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">
- Configuration
- 1-ModalPopupExtender :TargetControlID should point to the button or the control we want to trigger the popupPopupControlID 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 - Then, we add the script that shows up the modal , something like :
function onLoad(){
$find('behID').show();
} - 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
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
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
The video talks about using Polymorphism instead of IF's and Cases