Burhan Uddin
Shutdown computer using terminal in Ubuntu
If you want to shutdown your computer what do you do ? Simply go to shutdown button and click shutdown isn’t?
Have you ever wondered how would you shutdown your pc if your gdm (Graphical User Interface) is not working. Or you are only working in command line mood or running a computer user account with ssh(secured shell) ??
No CommentsCreate a lan messenger using socket programming in java
For my networking course lab project I developed an messenger for lan using java. It uses socket protocol for communication.
4 CommentsHow to import large csv file to mysql database in seconds
I had faced a troublesome situation while working with SUST automated mobile based admission registration system. The scene was that, Bangladesh education board give us their database of 1 million students personal info and academic results in old MS Foxpro format. It is single file with more than 1 gb in size. It was really causing so much trouble to convert it into mysql database until i reach the solution below. Before finding it we were trying to parse all that 1gb file into sql query using java. In a P4 computer it took nearly 4/5hrs to parse arrount 20K entries as java heap memory was continiously exceeding limit.
1 CommentCreate tree view in webpages using Google Visulaization Api
Today I am going to tell you about how to create a tree view or binary tree view in webpage using some apis like Google Ajax Api (Visualization Api)
Few days ago I was working with a multi level marketting (MLM) management software where users are being registered under another refereing user. Thus forming a binary tree. I badly needed to create a tree view in web page. I searched the net for a easy solution. But the searched results were getting meshed up with result like creating folder trees. I didnt too much resources on net about it. Finally I found that its Google providing an ajax api called Google Visualization API that are providing some good tools for visualizing an charts. One of them is organizational chart found in Google Visualization API Gallery.
No CommentsGenerate random number within a range in java
If want to generate random numbers within a minimum and maximum limit you can easily do this in java using this function.
public int getRandom(int min, int max)
{
return (int) (Math.random() * (max - min + 1) ) + min;
}
No CommentsFix 500 internal error after uploading drupal site to host
After uploading dscripts.net new site to host it was reallty getting so much boring with 500 internal errors. I developed this site in localhost for last two weeks and when I upload it to my host (http://www.hostgator.com) things started going wrong.
It was arround two nights hard work before I could fix it. I googled and found that having 500 internal error after uploading a drupal site is quite common. It may have lots of reasons.
1 CommentConfigure CKEditor with syntax highlighter in drupal
I ran an website with programming tutorials and related resources with drupal. I need to add lots of reference codes in my posts. So I use javascript SyntaxHighlighter library from http://alexgorbatchev.com/wiki/SyntaxHighlighter.
In my drupal website I have fantastic wysiwyg editor module called ckeditor with lots of reach features. But when I need to add any code in my post. I manually need to switch to source mood and then edit the html to enter the syntaxHighlighter syntax.
1 CommentCustom shopping cart library for codeigniter
I have created this shopping cart library for my super shop management application I created few days ago. I would like to share this with others. This library contains default functionality of creating shopping cart and holding info about products in user session.
<?php
/*********************************************
* Custom Shopping Cart for codeigniter *
* Author: Burhan Uddin *
* Date: 17 March, 2010 *
* Web: http://www.dscripts.net *
**********************************************/
class Shopping_cart {
public $ci; // holds reference pointer to CI object
public $cart = array(); // array to store cart
private $session_var = 'shopping_cart'; // name of the session variable to be used
// constructor
function Shopping_cart() {
$this->ci = &get_instance(); //put reference to codeigniter object for this application
$this->_get_cart(); // get the cart from session to array
}
/* Gets the cart from session
* access: private
*/
function _get_cart() {
$cart = $this->ci->session->userdata($this->session_var);
if(!empty($cart))
$this->cart = unserialize($cart);
}
/* saves the cart to session
* access: private
*/
function _save_cart() {
return $this->ci->session->set_userdata($this->session_var, serialize($this->cart));
}
/* add items to cart
* access: public
* @param: id = String or integer, unique id used to determine the product generally database id
* @param: quantity = Integer, quantity of product added in cart
*/
function add($id, $quantity) {
$this->cart[$id] = $quantity;
$this->_save_cart();
}
/* Updates cart specific item
* access: public
* @param: id = String or integer, unique id used to determine the product generally database id
* @param: quantity = Integer, quantity of product added in cart
*/
function update($id, $quantity) {
$this->cart[$id] = $quantity;
$this->_save_cart();
}
/* Removes items from cart
* access: public
* @param: id = String or integer, unique id used to determine the product generally database id
*/
function remove($id) {
unset($this->cart[$id]);
$this->_save_cart();
}
/* Clear all contents of cart
* access: public
*/
function clear() {
$this->cart = array();
$this->_save_cart();
}
/* Returns the total number of items in cart
* access: public
* return integer
*/
function count() {
return count($this->cart);
}
/* Returns the items array in cart
* access: public
* return array
* sample return data
* $cart = $this->shopping_cart->items();
* when integer id
* $cart = array(
* [1] => 3,
* [2] => 5
* )
* when string id
* $cart = array(
* [mango] => 3,
* [banana] => 5
* )
*/
function items() {
return $this->cart;
}
}
?>
1 CommentDecimal validation using codeigniter form validation class
Codeigniter is a really cool light weight php framework with lots of cool features. One of its cool features in codeigniter form validation. Using codeigniter you can set rules for specific fields and validate them without any hastle of rewritting validation code. Here is the manual of this validation library. If you dont have idea about it go and read.
http://codeigniter.com/user_guide/libraries/form_validation.html
So here we can see we can set validation rules for a input field like this
1 CommentValidating username in drupal
Have you ever noticed that drupal system allows any sort of username with and without spaces. Like “Hello World!”, “N/A”, “#MY SPECIAL && USER % NAME”
.I think you would never like to see these sort of usernames to be allowed in your website. But unfortunately drupal don’t provide any administration to validate username. The only way is to add an access rule from User Management > Access Rule and block each invalid characters. Which is really ineffecient and time consuming.
So what the solution is ?? frown
1 Comment