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 / 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 / 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 / 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 / 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] &lt; 9:
month = "0"+str(localtime1[1])
@sarbajitc
sarbajitc / tail_log.py
Created June 23, 2018 04:17
Tail log file in python
# maybe the log got rotated out from under us?
if stat(self.path)[ST_SIZE] &lt;= self.pos: # modified by sarbajit
# file got truncated and/or re-created
self._reset()
@sarbajitc
sarbajitc / trigger.sql
Last active June 28, 2019 05:47
Mysql trigger creation
DELIMITER @@
CREATE TRIGGER Test_Trigger
AFTER INSERT ON MyTable
FOR EACH ROW
BEGIN
DECLARE cmd CHAR(255);
DECLARE result int(10);
SET cmd=CONCAT('sudo /home/sarbac/hello_world ','Sarbajit');
SET result = sys_exec(cmd);
@sarbajitc
sarbajitc / find_time.py
Created June 23, 2018 04:01
Find time in python
import calendar, datetime
current_utc_time_in_sec = calendar.timegm(datetime.datetime.utcnow().utctimetuple())
@sarbajitc
sarbajitc / time_check.py
Created June 23, 2018 04:00
Find time in python
import time
epoch_time_in_local_timezone = time.time()
@sarbajitc
sarbajitc / template.html
Last active June 23, 2018 03:53
Django template for OpenStack Horizon
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Table Display" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Employee Table Display") %}
{% endblock page_header %}
{% block main %}
{{ table.render }}
@sarbajitc
sarbajitc / tables.py
Last active June 23, 2018 03:54
Django tables.py for OpenStack Horizon
from horizon import tables
from django.utils.translation import ugettext_lazy as _
class TabledisplayTable(tables.DataTable):
name = tables.Column("name",
verbose_name=_("Employee Name"))
salary = tables.Column("salary", verbose_name=_("Salary in Rs"))
addr = tables.Column("addr",
verbose_name=_("Address"))