Category: Programming
By admin on Feb 18, 2010 in Programming, windows | 0 Comments
The WMI Code Creator tool allows you to generate VBScript, C#, and VB .NET code that uses WMI to complete a management task such as querying for management data, executing a method from a WMI class, or receiving event notifications using WMI.
The WMI Code Creator tool generates code that uses WMI to obtain management information […]
By admin on Jan 29, 2010 in .NET, Programming | 0 Comments
You can use the style DateTimeStyles.AssumeLocal to parse the date time string if there is no timezone information contained in the string.
E.g.
1: DateTime.ParseExact(dateString, DateFormats, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
If datestring contains no time zone information, the DateTime..::.Parse(String, IFormatProvider, DateTimeStyles) method returns a DateTime value whose Kind property is DateTimeKind..::.Unspecified unless a styles flag indicates otherwise. […]
By admin on Jan 29, 2010 in Oracle, Programming | 1 Comment
Starting version 10.1.3.4, to set time out in seconds for a partner link, it is just configuration in bpel.xml.
E.g. the configuration below sets the timeout to 5 seconds
1: <partnerLinkBinding name="WebService">
2: <property name="timeout">5</property>
3: <property name="optSoapShortcut">false</property>
4: <!– other […]
By admin on Jan 28, 2010 in Oracle, Programming | 0 Comments
In Oracle BPEL, to add a CDATA section to a XML payload looks like not easy.
E.g. if you want to add the CDATA to the XML below, it is not easy as using Java
1: <?xml version = ‘1.0′ encoding = ‘UTF-8′?>
2: <tns:RunTask><xmlRequestDocument><![CDATA[test
3: data]]></xmlRequestDocument></tns:RunTask>
As of version 10.1.3.5, […]
By admin on Jan 24, 2010 in .NET, Programming | 0 Comments
Here is a simple way to convert SByte to Byte in C#. E.g. if you want to convert the value of 129 from data type Byte to –127 in SByte
1: byte byteValue = 129;
2: sbyte sb = unchecked((sbyte)byteValue);
3: Console.WriteLine(sb);
By admin on Jan 18, 2010 in .NET, Programming | 0 Comments
This is a bit tricky to view OLE type of attachment in Outlook .msg file. You need to use MsWord library in order to extract the attachment.
Here is the code snippet that does the trick.
1: for(int loop = 1 ; loop < (mItem.Attachments.Count+1) ; loop++){ […]
By admin on Nov 26, 2009 in .NET, Programming | 0 Comments
The Facebook toolkit is provided as a Facebook Client Library similar to Facebook’s PHP Client Library or Facebook’s JavaScript library. The goal is to enable .NET developers to quickly and easily leverage the various features of the Facebook Platform. This toolkit has evolved over time with input from the community and from Microsoft. The latest […]
By admin on Nov 21, 2009 in Programming | 0 Comments
WS-Addressing provides way to specify message addressing information independent of transport layer. WS-Addressing provides a way to specify delivery, reply-to, and fault-handler addressing information in a SOAP envelope. WS-Addressing can be used in conjunction with other specifications such as WS-Security to authenticate and WS-Policy to define policies for the service.
WS-Addressing has two key constructs or […]
By admin on Nov 14, 2009 in Programming | 0 Comments
Go is a new systems programming language from Google.
The goal of the project, as quoted below
No major systems language has emerged in over a decade, but over that time the computing landscape has changed tremendously. There are several trends:
Computers are enormously quicker but software development is not faster.
Dependency management is a big part […]
By admin on Oct 14, 2009 in Java, Programming | 0 Comments
In previous article, I have written about Java Time Sync Problem. JVM time follows the CPU ticks once it is started even though the application servers are time synced with NTP.
With this in mind, if developer does not use a centralized server to retrieve the time, it would pose a problem.
Image the following scenario,
You […]
By admin on Sep 27, 2009 in Java, Programming | 1 Comment
Here is a Java class that you use to detect and use the system proxy, or direct connection is available to the Internet.
Basically, it uses java.net.useSystemProxies property which is available starting JDK 5.
1: package com.cdp.proxy.plugins;
2:
3:
4: import java.net.InetSocketAddress;
5: import […]
By admin on Sep 20, 2009 in .NET, Programming, freebies, personal | 0 Comments
I just released the community edition of MessagingToolkit
messagingtoolkit is a .NET C# messaging library that can be used to send and receive messages using any ETSI 07.05 compliant GSM modem or phone handset connected to the PC serial port through serial cable, infrared or bluetooth.
Some of the features of the library
Send SMS
Read incoming SMS […]
By admin on Sep 4, 2009 in Programming, freebies | 1 Comment
CHESS is a tool for finding and reproducing Heisenbugs in concurrent programs. CHESS repeatedly runs a concurrent test ensuring that every run takes a different interleaving. If an interleaving results in an error, CHESS can reproduce the interleaving for improved debugging. CHESS is available for both managed and native programs.
By admin on Jul 7, 2009 in Java, Programming | 2 Comments
Predicate in Commons Collection is very useful for logic evaluation. The available predicates should fulfills most of your logic requirements, or you can even write your own custom predicate.
AllPredicate
AndPredicate
AnyPredicate
EqualPredicate
ExceptionPredicate
FalsePredicate
IdentityPredicate
InstanceofPredicate
NonePredicate
NotNullPredicate
NotPredicate
NullIsExceptionPredicate
NullIsFalsePredicate
NullIsTruePredicate
NullPredicate
OnePredicate
OrPredicate
TransformedPredicate
TransformerPredicate,
TruePredicate
UniquePredicate
You can combine predicates together to form a compound predicate and also write custom predicate. E.g
public class PredicateTest {
static class Student {
[…]
By admin on Jun 29, 2009 in .NET, Programming | 0 Comments
In .NET, it is easy to retrieve all existing COM ports and sort them accordingly
string[] portNames = SerialPort.GetPortNames();
var sortedList = portNames.OrderBy(port => Convert.ToInt32(port.Replace(“COM”, string.Empty)));
foreach (string port in sortedList)
{
Console.WriteLine(port);
}
By admin on Mar 24, 2009 in Java, Programming | 0 Comments
When this happened, and you are sure that the connection pool is actually enough to handle all the transactions, then most probably that there is a connection leakage lying within your application. E.g. the connection is not closed properly.
One example in iBATIS is that you start a transaction, but does not end it.
sqlMapClient.startTransaction();
// other codes […]
By admin on Mar 15, 2009 in .NET, Programming | 0 Comments
Here is a simple way to detect if your content is ASCII or Unicode
public void CheckForEncoding(string content)
{
int i = 0;
for (i = 1; i <= content.Length; […]
By admin on Feb 17, 2009 in Java, Oracle, Programming | 0 Comments
There are times that you may want to alter Oracle session information. If you are using iBATIS, this can be done the following way
Create the update statement. E.g.
<?xml version=“1.0″ encoding=“UTF-8″ ?>
<!DOCTYPE sqlMap PUBLIC “-//ibatis.apache.org//DTD SQL Map 2.0//EN” “http://ibatis.apache.org/dtd/sql-map-2.dtd” >
<sqlMap namespace=“TEST”>
<update id=“update_sort_area_size” parameterClass=“int”>
[…]
By admin on Feb 14, 2009 in .NET, Programming | 0 Comments
Normally you cannot use string in enum. However you can bypass using a trick, as shown below.
/// <summary>
/// Response expected from the gateway
/// </summary>
public enum Response
{
/// <summary>
/// No respons expected, just return the result
/// </summary>
[StringValue(“NONE”)]
None,
[…]
By admin on Feb 9, 2009 in Java, Programming | 1 Comment
Performance tuning for embedded system is quite different from conventional programming
Avoid Creating Objects
Use Native Methods
Prefer Virtual Over Interface
Prefer Static Over Virtual
Avoid Internal Getters/Setters
Cache Field Lookups
Declare Constants Final
Use Enhanced For Loop Syntax With Caution
Avoid Enums
Use Package Scope with Inner Classes
Avoid Float
Some Sample Performance Numbers
Closing Notes