Search This Blog

Friday, December 30, 2011

JSOS - servlets office suite (servlets)

Probably the largest collection of
Java(tm) Servlets and filters

Tuesday, December 27, 2011

asp.net XML binding - how to check field/column exist.

The problem:
when dealing with xml binding , in my case i have attributes on each row.
not all the attributes are existing in the row , so when i use the binding method , i get failed.

e.g.
old code

<div id="divDynmic" runat="server" visible='<%# Eval("AllowDynamicParam").ToString().Trim() == "true" %>'></div>

if AllowDynamicParam is not exist in your xml as an attribute , you get failed.

so i solved this like this - i created the next method :

    public string GetData(object o, string key,string defaultValue)
    {  
        GridViewRow gvr = o as GridViewRow;
        XPathNavigator nav = ((IXPathNavigable)gvr.DataItem).CreateNavigator();
        string attribValue = nav.GetAttribute(key, "");
        if (!string.IsNullOrEmpty(attribValue))
            return attribValue;

        return defaultValue;
    }


the main problem was to deal with
gvr.DataItem - its return XmlDataSourceNodeDescriptor   object and its sealed - no docs on it.
so my new code look like this:
<div id="divDynmic" runat="server" visible='<%# GetData(Container,"DynamicParamMandatory","false") == "true" %>'></div>

enjoy
Yaniv Tzanany

Monday, November 14, 2011

MFC CString

very good article about CString Management, and some conversion method .


Gui Prototyping Tools

Many tools for prototype
Gui Prototyping Tools:

Tuesday, November 1, 2011

DOS Command-line reference A-Z

only when you see the command list , you understand how much you missed during the years.
learn it and use it ,it will be with us for a long time.

enjoy

Tuesday, October 25, 2011

How To Capture And Track Clicks On The Facebook “Like” Button

working sample could be found here - but only when user click on the LIKE .

How To Capture And Track Clicks On The Facebook “Like” Button:

very good sample with multiple likes with unlike too
Tracking multiple facebook like buttons and like boxes (using edge.create)

enjoy
Yaniv Tzanany

Facebook testing tool

it is always a good idea to start with

Facebook Getting Started page 

for the testing tools:

JavaScript Test Console 

Input URL or Access Token

Graph API Explorer

Monday, October 24, 2011

JS - Making pop-up windows modal

i liked this article , passing data from/to modal dialog in html page.
beside the Blog looks like very good
Making pop-up windows modal - Article - CodeStore:

on the same issue of modal dialog , you can find this test very usefull.
showModalDialog Method Sample
showModalDialog Method

Enjoy
yaniv T

Wednesday, September 14, 2011

V8Compatible , What is going on with DATE and TIMESTAMP

Suddenly, i could not see the time part in  date column , in my screen.
the time part arrive such 00:00:00

i realized that i am using Data Source Name (ORACLE connection pooling) who used different jdbc driver , and i forget to set the V8Compatible flag.
i suggest you to read the next article that will explain to you what is all about.
What is going on with DATE and TIMESTAMP:

another good explanation with samples could be found here:
Summary of features afftected by oracle.jdbc.V8Compatible 

enjoy
Yaniv Tzanany

Wednesday, August 24, 2011

C++ High Resolution Timer

i used to get timing via GetTickCount API , but the smallest measurement i managed to get was about ~15 ms.
so if you need to measure elapsed time in micro seconds , the next article is for you
High Resolution Timer:


LARGE_INTEGER frequency;        // ticks per second
    LARGE_INTEGER t1, t2;           // ticks
    double elapsedTime;

    // get ticks per second
    QueryPerformanceFrequency(&frequency);

    // start timer
    QueryPerformanceCounter(&t1);

    // do something
    ...

    // stop timer
    QueryPerformanceCounter(&t2);

    // compute and print the elapsed time in millisec
    elapsedTime = (t2.QuadPart - t1.QuadPart) * 1000.0 / frequency.QuadPart;
    cout << elapsedTime << " ms.\n";

Visual Leak Detector - Memory Leak Detection for Visual C++

Visual Leak Detector - Enhanced Memory Leak Detection for Visual C++ - CodeProject

newer version for this tool could be found here Visual Leak Detector for Visual C++ 2008/2010

I didn't play with it yet, but good to know especially for Visual c++ 6 (its old and no more tools left).

Yaniv T


Monday, August 22, 2011

Visual C++ 6.0 - Developing Optimized Code

what a good article , its alwyes good to remember what you already forgot , the next link describe
how the Visual C++ compiler can optimize source code for speed and size and examines the reasons why code size matters. We have gone over the code generation and optimization switches and pragmas supported by Visual C++, how to choose the best switches for your project, and why and how to override them at the function level.

Developing Optimized Code with Microsoft Visual C++ 6.0
Profiling Your Application
C++ Optimization Strategies and Techniques



must for Visual c++ 6 developers ( yes i know its old .... )

Yaniv Tzanany

Sunday, August 21, 2011

memcached - distributed memory db

memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.

Memcached is simple yet powerful. Its simple design promotes quick deployment, ease of development, and solves many problems facing large data caches. Its APIis available for most popular languages.

Memcached is in used with the largest sites on earth , so its definitely worth a try , i really hope to test it ASAP.

YanivTzanany

Open Source used by Facebook Developers

study from the experts, what kind of open source are in used via Facebook.

Open Source - Facebook Developers

somehow i got a feeling that such open sources will continue to live longer than other.

Yaniv Tzanany

How to Speed Up Your Javascript or page Load Time

i enjoyed to read the next article
Speed Up Your Javascript Load Time | BetterExplained

Optimizing Page Load Time

Tuesday, August 2, 2011

Eclipse and C/C++

I downloaded the CDT from eclipse site , download cygwin, add some development packages as g++ / gcc / make.

you have two option:
add the bin directory into the path (C:\cygwin\bin).
or goto -> windows->prefrences->c/c++ -> build->environment click add .
 set varibale name to PATH and the VALUE to C:\cygwin\bin, make sure the "Append variable to native" is checked.

Configure the GDB:
Go to Windows->Preference->C/C++ -> Debug -> Common Source Lookup. add following 'Path mapping'.
  • \cygdrive\c -> c:\
 in case you get error like
 "Program not Binary" error while trying to debug  while running your compile program


Go to the project property choose
Make project --> and in the tab Binary Parser
choose :
"Cygwin PE binary parser"

Another option is to use the Mingw, install it with the msys ,

goto -> windows->prefrences->c/c++ -> build->environment click add .
 set varibale name to PATH and the VALUE to C:\mingw\bin;C:\MinGW\msys\1.0\bin, make sure the "Append variable to native" is checked.


some usefull links that can help you developing c++ application via Eclipse IDE:
Setting up Eclipse CDT on Windows, Linux/Unix, Mac OS X

  Setup Cygwin toolchain in Eclipse CDT

Developing applications using the Eclipse C/C++ Development Toolkit

Integrated Development Environment: C/C++ development with the Eclipse Platform


i am sure there are many article even better than the above i mentioned , but i used the above ...

Yaniv Tzanany

Monday, August 1, 2011

Visual C++ 6.0 : Precompiled headers

good article tha twill help you to increase compile time.

Fractal eXtreme: Precompiled headers

Solving memory problems in WebSphere applications

Learn how to identify root causes for and solve memory problems in WebSphere® Commerce during system test.
Solving memory problems in WebSphere applications

Websphere Max memory allocation for JVM

When you set the max memory size on websphere  7 installed on 32 bit machine – you will get the next warning:

 You have set the Maximum heap size field to a value greater than 2 gigabytes. This is only valid on a 64 bit server. You can ignore this warning if the server will run in 64 bit mode; otherwise, the maximum value is 2048.

The server failed to startup on 32 bit machine when I set  the max memory to 2200 (M).
in the startServer.log - you can find such logging:

ADMU7704E: Failed while trying to start the Windows Service associated with server: server1;
probable error executing WASService.exe: Starting Service: YANIVTNode01
Service failed to start.  startServer return code = -1



I test it on 64bit server , I set the max memory to 2500 , and the server startup successfully.
Summary:
If we want more than 2G RAM allocation for websphere on windows  , you must used 64Bit server.

enjoy 
Yaniv Tzanany

Monday, July 25, 2011

Websphere - RSA premaster secret error , Illegal key size or default parameter

When i used signer with strong RSA key greater than 2048 bits on my Websphere 6.1 ( i did not test it on newer version) ,  i get the next exception  - see below.


its looks like websphere 6.1 could not handle stronger cryptography greater than 2048bits, and you need to expand/enhance websphere to allow for it to work with RSA keys greather than 2048.


to fix such behavior,  install the unrestricted policy files following the next steps:
 - Make a backup of the current policy files: local_policy.jar and      
US_export_policy.jar located at "jre\lib\security". The files should be
backed up outside of classpath.                                        
- Remove the current policy files from "jre\lib\security" completely.  
Renaming is not enough.                                                
- Download the unrestricted policy files from                          
https://www14.software.ibm.com/webapp/iwm/web/preLogin.do?source=jcesdk
- Copy the new policy files to "jre\lib\security"                      
- Restart WAS/APP/JVM and verify the results                            


good luck 
Yaniv Tzanany



this is the exception when you used the default setting and try to work with RSA grater than 2048 under webspehere:


javax.net.ssl.SSLKeyException: RSA premaster secret error
   at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
   at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:83)
   at org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRequestEntity.java:84)
   at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:499)
   at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114)
   at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
   at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
   at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)


Caused by: com.ctc.wstx.exc.WstxIOException: Connection has been shutdown: javax.net.ssl.SSLKeyException: RSA premaster secret error
   at com.ctc.wstx.sw.BaseStreamWriter.finishDocument(BaseStreamWriter.java:1692)
   at com.ctc.wstx.sw.BaseStreamWriter.close(BaseStreamWriter.java:288)
   at org.apache.axiom.util.stax.wrapper.XMLStreamWriterWrapper.close(XMLStreamWriterWrapper.java:46)
   at org.apache.axiom.om.impl.MTOMXMLStreamWriter.close(MTOMXMLStreamWriter.java:174)
   at org.apache.axiom.om.impl.llom.OMSerializableImpl.serializeAndConsume(OMSerializableImpl.java:197)
   at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:79)
   ... 79 more
Caused by: javax.net.ssl.SSLException: Connection has been shutdown: javax.net.ssl.SSLKeyException: RSA premaster secret error
   at com.ibm.jsse2.jc.i(jc.java:211)
   at com.ibm.jsse2.jc.j(jc.java:399)
   at com.ibm.jsse2.j.write(j.java:19)
   at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:88)
   at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:146)
   at org.apache.commons.httpclient.ChunkedOutputStream.flush(ChunkedOutputStream.java:191)
   at com.ctc.wstx.io.UTF8Writer.flush(UTF8Writer.java:99)
   at com.ctc.wstx.sw.BufferingXmlWriter.flush(BufferingXmlWriter.java:214)
   at com.ctc.wstx.sw.BufferingXmlWriter.close(BufferingXmlWriter.java:194)
   at com.ctc.wstx.sw.BaseStreamWriter.finishDocument(BaseStreamWriter.java:1690)
   ... 84 more
Caused by: javax.net.ssl.SSLKeyException: RSA premaster secret error
   at com.ibm.jsse2.cb.(cb.java:57)
   at com.ibm.jsse2.eb.a(eb.java:192)
   at com.ibm.jsse2.eb.a(eb.java:114)
   at com.ibm.jsse2.db.m(db.java:208)
   at com.ibm.jsse2.db.a(db.java:259)
   at com.ibm.jsse2.jc.a(jc.java:271)
   at com.ibm.jsse2.jc.g(jc.java:403)
   at com.ibm.jsse2.jc.a(jc.java:401)
   at com.ibm.jsse2.j.write(j.java:10)
   at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:88)
   at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:146)
   at org.apache.commons.httpclient.ChunkedOutputStream.flush(ChunkedOutputStream.java:191)
   at com.ctc.wstx.io.UTF8Writer.flush(UTF8Writer.java:99)
   at com.ctc.wstx.sw.BufferingXmlWriter.flush(BufferingXmlWriter.java:214)
   at com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:311)
   at org.apache.axiom.util.stax.wrapper.XMLStreamWriterWrapper.flush(XMLStreamWriterWrapper.java:50)
   at org.apache.axiom.om.impl.MTOMXMLStreamWriter.flush(MTOMXMLStreamWriter.java:184)
   at org.apache.axis2.databinding.utils.writer.MTOMAwareXMLSerializer.flush(MTOMAwareXMLSerializer.java:79)
   at org.apache.axis2.databinding.ADBDataSource.serialize(ADBDataSource.java:94)
   at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerialize(OMSourcedElementImpl.java:691)
   at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:965)
   at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.serializeInternally(SOAPEnvelopeImpl.java:283)
   at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:245)
   at org.apache.axiom.om.impl.llom.OMSerializableImpl.serializeAndConsume(OMSerializableImpl.java:193)
   ... 80 more
Caused by: java.security.InvalidKeyException: Illegal key size or default parameters
   at javax.crypto.Cipher.a(Unknown Source)
   at javax.crypto.Cipher.a(Unknown Source)
   at javax.crypto.Cipher.a(Unknown Source)
   at javax.crypto.Cipher.init(Unknown Source)
   at com.ibm.jsse2.cb.(cb.java:8)                                                    

Tuesday, July 19, 2011

getting JDBC version

this is the way to get the jdbc extra version


Connection conn = DriverManager.getConnection(connectionString,m_connectionProperties);
DatabaseMetaData dbmd = conn.getMetaData();

   System.out.println("DriverName: " + dbmd.getDriverName() );
   System.out.println("DriverVersion: " + dbmd.getDriverVersion() );
   System.out.println("DriverMajorVersion: " + dbmd.getDriverMajorVersion() );
   System.out.println("DriverMinorVersion: " + dbmd.getDriverMinorVersion() );


how to get the jar file location for specific loaded class

this how to get the jar file location for specific class


   try {
File jarFile = new File(CLASS_NAME.class.getProtectionDomain().getCodeSource().getLocation().toURI());
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Yaniv T

Friday, July 15, 2011

URL rewriting using ASP.NET routing

very good sample to use the routing way within asp.net 3.5

URL rewriting using ASP.NET routing

in may case when i tried to implement it in the same way , i needed to add into my web.config file the next line in httpModules section , other wise i could not make it work properly.
<add name="RoutingModule" type="System.Web.Routing.UrlRoutingModule,System.Web.Routing,Version=3.5.0.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35"/>

now we can add extra SEO :)

Yaniv Tzanany

Monday, July 11, 2011

Use gSOAP to consume J2EE Web services created by WSAD through HTTP and HTTPS

Use gSOAP as a C/C++ Web services stack to consume Java™ 2 Platform, Enterprise Edition (J2EE) Web services through HTTP and HTTPS.

very good tutorial
Use gSOAP to consume J2EE Web services created by WSAD through HTTP and HTTPS

enjoy
yaniv Tzanany

Saturday, July 9, 2011

amazon API - notes

access to node
http://www.amazon.com/exec/obidos/tg/browse/-/[Browse Node ID]
e.g.
http://www.amazon.com/exec/obidos/tg/browse/-/11060901

The BrowseNodes response group returns the browse node that an item belongs to as well as the ancestry
of that browse node.
Note: If a browse node has multiple ancestors, only one of them is returned in the response.(no logic wghich one will return)
You can use the BrowseNodes response group with ItemLookup, ItemSearch, and SimilarityLookup.

The BrowseNodeInfo response group returns browse node names, IDs, children and parent browse nodes
You can use the BrowseNodeInfo response group only with BrowseNodeLookup.
Note: If a browse node has multiple ancestors, only one of them is returned in the response.

In contrast, BrowseNodeLookup only returns child browse nodes that are the direct descendant of the browse node in the request.

item sort keys by language
http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.html?CASortValuesArticle.html

Wednesday, July 6, 2011

Xerces Serialize XML data and encoding

the next code works fine on Xerces 2.6 - helper function to convert bytes  to utf8 format.

void convertToUTF8(const XMLCh* buffer, CString &utf8_string)
{
XMLTranscoder* utf8Transcoder;
XMLTransService::Codes failReason;
utf8Transcoder = XMLPlatformUtils::fgTransService->makeNewTranscoderFor("UTF-8", failReason, 16*1024);
size_t len = XMLString::stringLen(buffer);
XMLByte* utf8 = new XMLByte[(len*MB_LEN_MAX)+1];
unsigned int eaten;
unsigned int utf8Len = utf8Transcoder->transcodeTo((buffer), len, utf8, len*MB_LEN_MAX, eaten, XMLTranscoder::UnRep_Throw);
utf8[utf8Len] = '\0';
utf8_string = (char*)utf8;
delete[] utf8;
delete utf8Transcoder;
}
good article 
Serialize XML data

Thursday, June 23, 2011

SAVING CHANGES IS NOT PERMITTED - SQL Server Management Studio

if you get such error on every table changes:
Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.

on the  Management Studio -> go to Tools -> Options then go to the Designer Page and uncheck "Prevent saving changes that require table re-creation".

thats all
Yaniv tzanany

Sunday, June 5, 2011

WebSphere MQ Queue Load / Unload Utility

here you can find a very good utility from IBM to use with MQ product.
Possible Uses:
• To save the messages that are on a queue, to a file, perhaps for archiving purposes and the possibility of later reload back onto a queue.
• To reload a queue with messages you previously saved to a file.
• To remove messages from a queue which are old.
• To ‘replay’ test messages from a stored location – even maintaining time spacing if required.

IBM MO03: WebSphere MQ Queue Load / Unload Utility -
United States

enjoy
Yaniv Tzanany

Tuesday, May 31, 2011

WebSphere "IBM End user tried to act as a CA"

When i tried to access a secured web services i get the next error:

org.apache.axis2.AxisFault: Connection has been shutdown: javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.h: End user tried to act as a CA
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:83)
at org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRequestEntity.java:84)
at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:499)


the CA in this case is Entrust company.
after some hours , i found the next article that helped me to solved it out , and this way i understood i am not alone here.
the fix is described here:
IBM End user tried to act as a CA - United States.
summery:
update the java.security file , set the
ssl.TrustManagerFactory.algorithm to use IbmPKIX insteaf of IbmX509 .

this article gave me the clue that its somthing with entrust CA as well

and restart your server.
enjoy
Yaniv Tzanany


Saturday, May 28, 2011

Facebook Likes Analyzer App for iPhone

A new and exciting way to browse Facebook has just hit the AppStore - The Facebook
Likes Analyzer App for your iPhone. Using this Appyou will be able to see All the
Pages you Like’d on Facebook, will let you Un-Like them in case you did not mean to
Like them and also will show you What you friends’ Likes are… this way you may also
Like those new Pages.

Facebook Likes Analyzer for iPhone is more comprehensive than just Facebook Pages,
it actually can act as a better way to browse Topics on a Facebook, by going directly to
the Page you Like, and browse through it with no interference of irrelevant stories that
appear on a regular Facebook wall !

With Facebook Likes Analyzer you can be sure to stay on top of the stories in facebook
that you are interested in, instead on relaying on facebook to feed you with what they
believe are the stories you’d be interested in, just take a look at the picture here, you can
go directly to CNN and update on the hot upcoming stories, then switch to Hulu to check
what is new with your favorite TV-Show or movies.

There are new features that are planned and will be released to this App, such as
comparing your Likes to your friends’ Likes and push notifications on friends changing
their Likes.

You can download Facebook Likes Analyzer using the follwing link:
http://itunes.apple.com/app/facebook-likes-analyzer/id438038912

Tuesday, May 17, 2011

ORACLE locks report script

the next script works on oracle 11g , report on all DB locks.


select s.osuser "O/S-User", s.username "Ora-User",s.sid "Session-ID",s.serial# "Serial",
s.process "Process-ID", s.status "Status",l.name "Obj_Locked",l.mode_held "Lock_Mode",
t.used_ublk "Left undo block"
from v$session s,dba_dml_locks l,v$process p,v$transaction t
 where l.session_id = s.sid and p.addr = s.paddr

Yaniv Tzanany

Tuesday, May 3, 2011

IBM Recommended values for Web server plug-in config

Recently i solved a problem when making a call to a Websphere that took about 70 seconds to response.
The client get web service invocation error after 60 seconds.
we try to find out where such parameter is set , because its obvious that someone is dropping our client connection ( its very long time but at least get the client be happy its worked), i found such parameter in the server http plug -in config file , the parameter is :

ServerIOTimeout means "how long should the plug-in wait for a response from the application". and its was set to 60 seconds , i increase it to 120 seconds.
now i need to find out why its take 70 seconds...................

the next link is the recommended values for such plug in with explanation.
IBM Recommended values for Web server plug-in config - United States

enjoy
Yaniv Tzanany

Monday, April 25, 2011

XMLDataDocument from DataSet has incorrect hierarchy

with this thread i found out , why my xml data is flat , and how to fix it and make it hierarchy.

XMLDataDocument from DataSet has incorrect hierarchy

works well

Saturday, April 16, 2011

Custom Facebook Page Tab With Iframes

since static fbml is no longer support the only way to create a tab on fan page is via iframe, the next article is a good description how to do that .

How to Make a Custom Facebook Page Tab With Iframes | WordPress and Facebook Consultant | (Anti) Social Development

enjoy
YanivT

Sunday, April 3, 2011

Thursday, March 17, 2011

JNI and C++ FindClass method

JNI is a great way to use java class in your c++ code, in case you really need it, a good article with full sample could be found in the next topic.
How to Call Java Functions from C Using JNI - CodeProject
when consuming a class in jar file dont forget to:
supply the jar file in the option:
-Djava.class.path=D:\myJar.jar

and when you need to use the FindClass methos supply the full path:
jclass myClass = env->FindClass("mm/test/HelloWorld");

when you need a pointer to the method id , use full path to the parameter as well , in case you need it:
in java its define such:
public static WorkOrder2 ChangeTheObj(WorkOrder2 obj);
in your c++:
jmethodID myMethod = env->GetStaticMethodID(clsH,"ChangeTheObj","(Lmm/test/WorkOrder2;)Lmm/test/WorkOrder2;");
Yaniv Tzanany

Thursday, March 10, 2011

jTDS with sqlserver instance

jTDS is an open source 100% pure Java (type 4) JDBC 3.0 driver for Microsoft SQL Server (6.5, 7, 2000, 2005 and 2008).
when connecting to sqlserver instance instance a valid jdbc url should looks like this:
jdbc:jtds:sqlserver://YanivServer:1433/mydb;instance=myInstance;user=sa;password=xyz

make sure the next stuff is configured and running:
open the "sql server configuration manager "

  • sql browser service (its turn off by default) is running 
  • goto sqlserver network configuration  -> 
    •  the protocol of the instance , and make sure the  TCP/IP  is enabled.

enjoy 
Yaniv Tzanany

Thursday, March 3, 2011

character converter - LibIconv for Windows

LibIconv converts from one character encoding to another through Unicode conversion (see Web page for full list of supported encodings). It has also limited support for transliteration, i.e. when a character cannot be represented in the target character set, it is approximated through one or several similar looking characters. It is useful if your application needs to support multiple character encodings, but that support lacks from your system
LibIconv for Windows

you can use it in your app , via is API , works well , multi platform solution.
enjoy
Yaniv Tzanany

SSO - WebSphere with a side of SPNEGO

This document is intended to provide instructions to configure SPNEGO for WebSphere Application Server in standalone and clustered configurations using Microsoft Active Directory as the Kerberos security server. It is meant to be a ‘quick-start’ guide, providing the minimum steps and default options required to get up and running quickly in both WAS 6.1 and WAS 7.0 environments

Sunday, February 27, 2011

Consume C# DataSet from .Net webservice

Hi
you wish to consume DataSet from .NET webservices , anyway i could not find an easy way to do it , as you do it within c# code, you must deal with XML parsers.
any way, a very good explanation and description could be found here Web Services and DataSets.

In short .. it is most recommended to expose the results as array of objects ,when you want your Java consumer be happy.
.... i used axis 2 to generate webservice proxies .

good luck
Yaniv Tzanany

Tuesday, February 22, 2011

How to get Facebook friends status ? - online or not

just found this post , i didn't test it yet , and i cant promise anything about it.
you need the next Extended permission: friends_online_presence

To actively query the online presence of your friends use the next graph call:

https://api.facebook.com/method/fql.query?access_token='((INSERT ACCESSTOKEN HERE))'&query= SELECT online_presence FROM user WHERE uid = '((UID OF FRIEND))'

That should return the info.
i hope it will work, i will report when it will work for me.

enjoy
Yaniv Tzanany

Wednesday, February 16, 2011

MyLikesBox - You must have this facebook application

See ALL You Facebook LIKE's!
Manage your facebook likes with this App.

see how its looks like at Techcrunch , and you can use it direct from here MyLikesBox.
you will LOVE it !!!
Don't forget to LIKE us too.


enjoy
Yaniv Tzanany

Wednesday, February 9, 2011

C++ code description in XML

The GCC-XML, the XML output extension to GCC! 
Development tools that work with programming languages benefit from their ability to understand the code with which they work at a level comparable to a compiler. C++ has become a popular and powerful language, but parsing it is a very challenging problem. This has discouraged the development of tools meant to work directly with the language.
There is one open-source C++ parser, the C++ front-end to GCC, which is currently able to deal with the language in its entirety. The purpose of the GCC-XML extension is to generate an XML description of a C++ program from GCC's internal representation. Since XML is easy to parse, other development tools will be able to work with C++ programs without the burden of a complicated C++ parser.

more could be found here GCC-XML

Yaniv Tzanany

Predefined Macros in c++

In ANSI c++ , there are some predefined macro that you can used , for example to write to your logs.

 __DATE__ 
A character string literal containing the date when the source file was compiled. The date will be in the form:
   "Mmm dd yyyy"
 __FILE__ 
Defined as a character string literal containing the name of the source file.
 __LINE__ 
Defined to be an integer representing the current source line number.
 __STDC_
Defined if the C compiler conforms to the ANSI standard. This macro is undefined if the language level is set to anything other than ANSI.
 __TIME__ 
Defined as a character string literal containing the time when the source file was compiled. The time will be in the form:
   "hh:mm:ss"
__FUNCTION_
access the name of a currently executing function programmatically.

more macros could be found here Standard Predefined Macro, more about __FUNCTION__  could be found here Retrieve a Function's Name Programmatically

Code sample:
#include 
#ifdef __STDC__
# define CONFORM "conforms"
#else
# define CONFORM "does not conform"
#endif
int main(void)
{
printf("Line %d of file %s has been executed\n", __LINE__, __FILE__);
printf("This file was compiled at %s on %s\n", __TIME__, __DATE__);
printf("This program %s to ANSI standards\n", CONFORM);
}



Yaniv Tzanany

Monday, January 17, 2011

Adding custom http header to each request with FireFox and IE

Sometimes you need to add an extra http header for each request , to simulate requests from third parties or clients.
in my case i needed to add an extra header for each request to simulate "single sign on" to my system, so an extra header added by the client with the user id , and i wanted to test such solution, without the need to develop a proxy or any test tool, so i found this.
For Firefox -  use the add on Modify header to Add, modify and filter http request headers.
For IE browser - it more complicated:

  • you have to download Fiddler
  • Open the 'Customize Rules' window (Rules->Customize Rules...)
  • Find this function: static function OnBeforeRequest(oSession: Session)
  • inside this function, add the header values that you would like to add, in this format: oSession.oRequest["headerName"] = "headerValue";
To get your new header on each request , open your IE , and make sure Fiddler is running.

enjoy 
Yaniv Tzanany

Tuesday, January 4, 2011

Working with WebSphere MQ JMS Under WebSphere app server

i struggled allot to make this JMS  sample working .
follow the next instruction to use JMS under web sphere.

1. get into admin console
2. get into JMS->connection factories  -> new
    choose web sphere MQ , click OK .
give it a logic name , and a jndi name such as jms/myMqFactory, and set the correct parameters during the wizard.
click finish and save.

3. goto Resources -> JMS ->queues
4. click new , and choose websphere MQ message provider
set the name and jndi name such as jms/mqRequestQ
and set the queue name
5. click apply and save.

some resources i used :
Developing a JMS client

IBM WebSphere Developer Technical Journal: Building an Enterprise Service Bus with WebSphere Application Server V6 -- Part 3
A java.lang.ClassCastException error occurs during a JNDI lookup of a queue connection factory


How to extract Queue Manager Name from CF / QCF in your J2EE JMS application



here is the code snippets, i used tp send message to mqRequestQ and get result from mqResponseQ , and pick the message with the same msg id:

private void testJMS(String qIn,String qOut )
{

    String  outString                 = "I am a string from JMS";
    String  qcfName                   = "jms/myMqFactory";
    String  qnameIn                   = "jms/mqRequestQ";
    String  qnameOut                  = "jms/mqResponseQ";
    boolean verbose                   = false;

    Session           session    = null;


    Connection        connection = null;
    ConnectionFactory   qcf  = null;

    Queue                  inQueue    = null;
    Queue                  outQueue   = null;
    InitialContext context = null;
    try {
context = new InitialContext();
qcf = (ConnectionFactory)context.lookup( qcfName );
inQueue = (Queue)context.lookup( qnameIn );
outQueue = (Queue)context.lookup( qnameOut );

   if(qcf != null)
   {
connection = qcf.createConnection();  
connection.start();
boolean transacted = false;
session = connection.createSession( transacted,
Session.AUTO_ACKNOWLEDGE);
((MQQueue)inQueue).setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ); //its 1
MessageProducer  queueSender = session.createProducer(inQueue);
queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
queueSender.setTimeToLive(60000); // in milli seconds 0 - unlimited
TextMessage outMessage = session.createTextMessage(outString);
outMessage.setJMSCorrelationID("Alis0000");
queueSender.send(outMessage);
queueSender.close();

String msgID  = outMessage.getJMSMessageID();
String selector1 = "JMSMessageID='"+msgID+"'";
MessageConsumer queueReciever =  session.createConsumer(outQueue, selector1);
javax.jms.Message inMessage =  queueReciever.receive(2000);
if ( inMessage instanceof TextMessage )
{
String replyString = ((TextMessage) inMessage).getText();
}
queueReciever.close();

session.close();
session = null;
connection.close();
connection = null;
   }

} catch (NamingException e) {
// there is no such DSN lets report it and will try to work without the DataSource name

} catch (JMSException je) {
      System.out.println("JMS failed with "+je);
      Exception le = je.getLinkedException();
      if (le != null)
      {
  System.out.println("linked exception "+le);
      }
}
}

enjoy
Yaniv Tzanany