Posts

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