Posts

Showing posts from 2011

Start with apache httpd module development...

Image
Apache by name is the start of a giant in http server which is more than 50% of the web world. currently known as httpd, its on such useful because of its popularization architecture where anyone can do there own changes by just  mounting a module. So, today i'm going to demonstrate how to start with apache httpd dynamic module development with a hello world sample. This tutorial is done on linux Mint destro. But any linux version will be no problem. Developing apache modules for windows is pretty straight forward, but need to prepare some tools which is not directly downloadable. The tool used is c/c++ compiler and apxs[APache eXtenSion] tool. apxs for windows is a purl module, and it need to have some configurations. But there wont be any change on application source of on development procedure. For the moment i'll continue for linux and will hope to continue windows instructions later. Required components: Apache httpd server[remember its not tomcat] Apache Ext...

On the way for my own thread pool [Semaphore] for multi-threaded applications

In Linux environment, there is a lack of ready made Database connection pool object or even a easily usable connection object invokees. So, i supposed to write my own implementations for the subject. But still there are some pretty good libraries to ease the implementations [eg: boost C++ lib]. But i thought to continue with standard way. Still this code is under development. The following code is still usable, but with lot of cavities. I'v implemented mutex mode here. But need to implement Semaphore  and avoid Blocked Waiting. That require to implement pThread. Your ideas are always welcome. /**get a new connection from the pool*/ sql::Connection* DBConnector::getConnection(void) { bool gotaconnection = false; for(;!gotaconnection;) { sql::Connection* tmpConnection = NULL; /*if lock is free, lock it and go inside*/ if(DBConnector::isFreeThenLock()) { /*if there are free connections in the pool go and get it then fr...

Useful Abstract Methods

This is somewhat older and useful set of code, but i can't remember where it was... may be when i was using ehCache for data pre-loading in says at MIT. /** * Get Object Type * * @return */ public Class getObjectType() { return (this != null ? this.getClass() : CacheManagerEventListener.class); }

C# Simple drag and drop example

Sometimes back i wanted to create a XML design tool to development with some GUI based tool kit. But unfortunately i had no time to continue with the project. I tried with some available code from internet to test the requirements..... just a copy past is here, till re-start the project sooner. C# Simple drag and drop example : // Form load event or a similar place private void Form_Load(object sender, EventArgs e) {     // Enable drag and drop for this form // (this can also be applied to any controls) this.AllowDrop = true;     // Add event handlers for the drag & drop functionality this.DragEnter += new DragEventHandler(Form_DragEnter);     this.DragDrop += new DragEventHand...

SQL joins graphically simplified...

Image
SQL[structured query language] is the language to get data from a DB. It let you retrieve data from a simple "select *" to many customized ways. "JOIN" is the keyword to retrieve data from multiple tables with a given relationship "ON". There are few more keywords used with JOIN, and some are optional. ex: INNER, OUTER,LEFT,RIGHT,FULL,CROSS,... those keywords depends on the DB you are using. As given early JOIN give us the opportunity to retrieve rows which are related on two tables. So those could be able to show in a Cartesian Venn diagram. So i have created two sample tables and added sample data to those. lets see how this can be simulated. First lets create sample tables: CREATE TABLE tblleft ( id_customer int(10), customer_name varchar(10) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; insert into tblleft (id_customer, customer_name) values (1, 'amara'); insert into tblleft (id_customer, customer_name) values (2, 'dasun'); insert...

Prevent XSS and request forgery and other common attack patterns | [: GaB :]

It looks like two-third of the attacks are based on three vectors: 1.  SQL injection  (25%) $id="1;DROP TABLE users"; mysql_query("SELECT * FROM bars WHERE id=".$id); It is deeply shocking how many "developers" still don't get the message not to execute SQL commands forged from user input. Or at least, why are they still employed? This attack would be the most simple to prevent. You just always have to *escape* strings which are parameters of the sql query coming in as request parameters. If in doubt, what do I mean by that, simply escape *all* parameters of a query. Or better use queries parameterized as "SELECT ... WHERE id=? AND type=?"-s, your language must have a way to pass the values safely afterwards. But stop, why in the world are these guys still writing any SQL queries in the first place?! Because script kiddies don't know what a persistence framework is. Stop handcrafting  CRUD DAOs. 2.  Cross-site scripting a.k.a. XSS ...

Favorite Text circle on console

Here is a small code snippets for displaying famous charactor circle on the console.... you may enjoy it!!! private String circle() {         if ((System.currentTimeMillis() - startTime) < 100) {             startTime = System.currentTimeMillis();             return "\r" + current + "\t";         }                if (current == '|') {             current = '/';         } else if (current == '/') {             current = '-';         } else if (current == '-') {             current = '\\';         } else {             current = '|';         }  ...

deploying war file on Weblogic server by using ant scripts

Auto deploying war file on Weblogic server by using ant scripts server="t3://${weblogic.adminhost}:${weblogic.adminport}" classpath="${weblogic.classpath}" username="${weblogic.user}" password="${weblogic.password}" component="${app.name}:${app.name}" debug="true"; classname="weblogic.ant.taskdefs.management.WLDeploy" classpath="C:/bea/weblogic81/server/lib/weblogic.jar" name="wldeploy"; debug="true" password="tropicAl" source="${build}/test.war" targets="fwmgb-ms01" user="system" verbose="true"; classpathref="weblogic.classpath" ; user="${weblogic.user}" password="${weblogic.password}" adminurl="t3://${weblogic.adminhost}:${weblogic.adminport}" source="dist/${app.name.war}" action="deploy"; message="Successfully Deployed ...

Lakdasun Trip Reports Archive » Kirigalpoththa Hike on 1st of January 2011

Lakdasun Trip Reports Archive » Kirigalpoththa Hike on 1st of January 2011

install Pulse- Audio Equalizer on Ubuntu 10.10

sudo add-apt-repository ppa:nilarimogard/webupd8 sudo apt-get update; sudo apt-get install pulseaudio-equalizer