Sunday, July 17, 2011

VB.net direct http


' EasyHttp.vb class file Public Class EasyHttp Public Enum HTTPMethod As Short HTTP_GET = 0 HTTP_POST = 1 End Enum Public Shared Function Send(ByVal URL As String, _ Optional ByVal PostData As String = "", _ Optional ByVal Method As HTTPMethod = HTTPMethod.HTTP_GET, _ Optional ByVal ContentType As String = "") Dim Request As HttpWebRequest = WebRequest.Create(URL) Dim Response As HttpWebResponse Dim SW As StreamWriter Dim SR As StreamReader Dim ResponseData As String ' Prepare Request Object Request.Method = Method.ToString().Substring(5) ' Set form/post content-type if necessary If (Method = HTTPMethod.HTTP_POST AndAlso PostData >< "" AndAlso ContentType = "") Then ContentType = "application/x-www-form-urlencoded" End If ' Set Content-Type If (ContentType >< "") Then Request.ContentType = ContentType Request.ContentLength = PostData.Length End If ' Send Request, If Request If (Method = HTTPMethod.HTTP_POST) Then Try SW = New StreamWriter(Request.GetRequestStream()) SW.Write(PostData) Catch Ex As Exception Throw Ex Finally SW.Close() End Try End If ' Receive Response Try Response = Request.GetResponse() SR = New StreamReader(Response.GetResponseStream()) ResponseData = SR.ReadToEnd() Catch Wex As System.Net.WebException SR = New StreamReader(Wex.Response.GetResponseStream()) ResponseData = SR.ReadToEnd() Throw New Exception(ResponseData) Finally SR.Close() End Try Return ResponseData End Function End Class

Share Article : VB.net direct http
Share/Save/Bookmark

Friday, June 10, 2011

Getting missing dates in Oracle



WITH DATA AS (
select to_date(to_char(unit_date,'yyyy/mm/dd')) dat from hr_attendance where empid = 'EMP0001'
)
SELECT mi+LEVEL missing FROM(
SELECT MIN(dat) mi,MAX(dat)ma FROM DATA)
CONNECT BY LEVEL <= ma-mi
MINUS
SELECT dat FROM DATA;


  

Share Article : Getting missing dates in Oracle
Share/Save/Bookmark

Tuesday, April 12, 2011

Update Version of Derby



  • shutdown the app replace derby.jar with newer version
  • append following to connection string  
upgrade=true
  • Start the app and that's all 
  • check it with following in sql 
values syscs_util.syscs_get_database_property( 'DataDictionaryVersion' );

Share Article : Update Version of Derby
Share/Save/Bookmark

Monday, April 11, 2011

Derby sequence with Hibernate







Derby sequence

CREATE SEQUENCE MD_USER_SEQ
AS INT
START WITH 1;


Hibernate mapping to get User_id from sequence

<id name="userId" type="integer" column="USER_ID" >
<generator class="sequence">
<param name="sequence">MD_USER_SEQ</param>
</generator>
</id>

[update:]
after all there is an issue with DerbyDialect of hibernate.
So need the following fix. 



package entity;


import org.hibernate.dialect.DerbyDialect;


/**
 *
 * @author Srinath
 */
public class MyDerbyDialect extends DerbyDialect{


    @Override
public String getSequenceNextValString(String sequenceName) {
        return "values next value for " + sequenceName;
}
}


Then in hibernate config

  <property name="hibernate.dialect">entity.MyDerbyDialect</property>




Share Article : Derby sequence with Hibernate
Share/Save/Bookmark

Sunday, March 20, 2011

Google Voice Recognition/TTS


TTS:   http://translate.google.com/translate_tts?q=I%20love%20techcrunch

Voice Recognition : http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/VoiceRecognition.html

Share Article : Google Voice Recognition/TTS
Share/Save/Bookmark

Monday, March 14, 2011

Firefox print hack



about:config

print.show_print_progress;false
print.always_print_silent;true

Share Article : Firefox print hack
Share/Save/Bookmark