Skip to content

Instantly share code, notes, and snippets.

View sarbajitc's full-sized avatar

Sarbajit Chatterjee sarbajitc

  • Bangalore, India
View GitHub Profile
@sarbajitc
sarbajitc / tail_log.py
Created June 23, 2018 05:35
Tail log file in python
def _reset(self):
"""Internal method; reopen the internal file handle (probably
because the log file got rotated/truncated)."""
self.f.close()
# modified by sarbajit
localtime1 = localtime(time())
year = str(localtime1[0])
if localtime1[1] < 9:
month = "0"+str(localtime1[1])
@sarbajitc
sarbajitc / dialog.html
Created June 23, 2018 05:40
jQuery dialog
<div id="login_div" title="Login" style="display:none;">
<form id="login_form" name="login_form" action="LoginServlet?action=login" method="post">
<table>
<tbody>
<tr>
<td>Username: </td>
<td><input type="text" name="username" id="username" size="20"></td>
</tr>
<tr>
<td >Password:</td>
@sarbajitc
sarbajitc / dialog.js
Created June 23, 2018 05:51
JQuery dialog
$( "#login_div" ).dialog({
autoOpen: false,
height: 'auto',
width: 400,
modal: true,
buttons: {
"Submit": function() {
// form submission code goes here
},
"close": function() {
@sarbajitc
sarbajitc / cherrypy_cgi.py
Created June 23, 2018 05:55
Cherrypy webserver in android
import cherrypy
class HelloWorld:
""" Sample request handler class. """
def index(self, **params):
# CherryPy will call this method for the root URI ("/") and send
# its return value to the client.
for key in params:
print key, '=', params[key]
@sarbajitc
sarbajitc / flexigrid_table.js
Created June 23, 2018 05:59
Flexigrid table
//add block
g.block.className = 'gBlock';
var gh = $(g.bDiv).height();
var gtop = g.bDiv.offsetTop;
$(g.block).css(
{
width: g.bDiv.style.width,
height: gh,
background: 'white',
position: 'relative',
@sarbajitc
sarbajitc / flexigrid_table.js
Created June 23, 2018 06:00
Flexigrid unblock
// unblock flexigrid
$("div .gBlock").css("zIndex", 0);
@sarbajitc
sarbajitc / hibernate.cfg.xml
Created June 23, 2018 06:03
Hibernate cfg
<property name="c3p0.min_size">5</property>
<property name="c3p0.max_size">20</property>
<property name="c3p0.timeout">1800</property>
<property name="c3p0.max_statements">50</property>
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
@sarbajitc
sarbajitc / HelloRest.java
Created June 23, 2018 06:06
Hello Service
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/hello")
public class HelloRest {
@GET @Produces(MediaType.TEXT_PLAIN)
public String helloText()
{
@sarbajitc
sarbajitc / HelloRestWithPath.java
Created June 23, 2018 06:08
Hello service with path
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@Path("/hellowithpath")
public class HelloRestWithPath {
@GET @Path("/text")
public String helloText()
{
return "Hello world";
}
@sarbajitc
sarbajitc / web.xml
Created June 23, 2018 06:10
Servlet mapping in web.xml
<servlet>
<description></description>
<display-name>ServletContainer</display-name>
<servlet-name>ServletContainer</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletContainer</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>