Posted 4 months ago
A note on email versus e-mail
Newly coined nonce words of English are often spelled with a hyphen, but the hyphen disappears when the words become widely used. For example, people used to write “non-zero” and “soft-ware” instead of “nonzero” and “software”; the same trend has occurred for hundreds of other words. Thus it’s high time for everybody to stop using the archaic spelling “e-mail”. Think of how many keystrokes you will save in your lifetime if you stop now! The form “email” has been well established in England for several years, so I am amazed to see Americans being overly conservative in this regard. (Of course, “email” has been a familiar word in France, Germany, and the Netherlands much longer than in England —- but for an entirely different reason.)
Posted 6 months ago

Current date and time in Java

To get the current date and time in Java is pretty easy:

DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
Date date = new Date();
String strDate = dateFormat.format(date);
System.out.println(strDate);
Posted 6 months ago

Temporarily disabling foreign-key constraints check on MySQL

If you use foreign keys in your database tables, you’ll probably have problems on migrating data from one database to another.

To solve this problem you need temporarily disable the foreign key constraints check  before import. To do so, simply add this line to the beginning of the import file.

 
SET foreign_key_checks = 0

And add this line to the end of the file. 

 
SET foreign_key_checks = 1
Posted 8 months ago

Unix Commands For Connecting To The Serial Console

Most embedded Linux / BSD systems such as routers, servers and nas devices comes with console interface (serial port with RS-232). BIOS can uses this, and after boot BIOS screen I/O is redirected so that you can use the device. RS-232 is also used for communicating to headless server, where no monitor or keyboard is installed, during boot when operating system is not running yet and therefore no network connection is possible. You need to use a serial cable between your computer and embedded system or server. In this post I will cover five conman utilities used for serial communication under Linux / Unix / *BSD and Mac OS X.

Posted 9 months ago

Debian / Ubuntu Linux: Install SquidGuard Web Filter Plugin For Squid 3.x To Block Unwanted Sites

How do I install and configure SquidGuard - a web filter plugin for Squid to restrict access to domains/URLs based upon access control lists? How do I block porn, gambling, and other web-sites using squid proxy server version 3.x under Debian or Ubuntu Linux server for my school?

Posted 1 year ago

Crop images using mask on PHP

Sometimes the rectangle images are not enough from the design point view. You can crop images using the masks on Photoshop, GIMP or other graphical manipulation software.

Another way to do it is using PHP’s GD library. Conceptual steps for croping image are as follows:

  1. Create image from source image.
  2. Resize it for you needs.
  3. Create the mask. (in our case it’s ellipsis)
  4. Merge the mask and image.

Code:

 
<?php
$filename = "sapmle.jpg";
$image_s = imagecreatefromjpeg($filename);
 
$width = imagesx($image_s);
$height = imagesy($image_s);
 
// New dimensions
$newwidth = 285;
$newheight = 232;
 
// Create new image
$image = imagecreatetruecolor($newwidth, $newheight);
imagealphablending($image,true);
imagecopyresampled($image,$image_s,0,0,0,0,$newwidth,$newheight,$width,$height);
imagedestroy($image_s);
 
// Create mask
$mask = imagecreatetruecolor($width, $height);
$mask = imagecreatetruecolor($newwidth, $newheight);
 
$transparent = imagecolorallocate($mask, 255, 0, 0);
imagecolortransparent($mask, $transparent);
imagefilledellipse($mask, $newwidth/2, $newheight/2, $newwidth, $newheight, $transparent);
 
 
 
$red = imagecolorallocate($image, 0, 0, 0);
imagecopymerge($image, $mask, 0, 0, 0, 0, $newwidth, $newheight,100);
imagecolortransparent($image, $red);
imagefill($image,0,0, $red);
 
// output and free memory
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
imagedestroy($mask);

The code above produces an image like this:


Posted 1 year ago
Software is the invisible thread, and hardware is the loom on which we weave the fabric of computing.
Grady Booch

(Source: twitter.com)

Posted 1 year ago

Installing Redmine on cPanel

Installing Redmine on cPanel will be bit harder, because it needs some modifications on server configuration. And custom modifications will be lost on regeneration of configuration files by cPanel. According instruction at http://www.redmine.org/projects/redmine/wiki/HowTo_install_Redmine_on_CentOS_5 you will need change Apache configuration manually. It’s not okay on cPanel. Also it will be conflicts with the Ruby, Rack, RoR versions which comes with cPanel.

Let’s deal with it.
First of all be sure that you have root access to your server, and Ruby on Rails is uninstalled.
Get the rubygems (1.4.2 version):

wget http://production.cf.rubygems.org/rubygems/rubygems-1.4.2.tgz
tar zxvf rubygems-1.4.2.tgz
cd rubygems-1.4.2
ruby setup.rb

Then install passenger:

gem install passenger

Download and extract redmine:

wget http://rubyforge.org/frs/download.php/75518/redmine-1.2.2.tar.gz  
# GET LATEST VERSION ON RUBYFORGE
tar zxvf redmine-1.2.2.tar.gz

Install bundler:

gem install bundler

Go to redmine directory and create Gemfile and install bundle:

vi Gemfile
source "http://rubygems.org"
gem "rake", "0.8.3"
gem "rack", "1.1.0" 
gem "i18n", "0.4.2" 
gem "rubytree", "0.5.2", :require => "tree" 
gem "RedCloth", "~>4.2.3", :require => "redcloth" 
# for CodeRay
gem "mysql" 
gem "coderay", "~>0.9.7" 
bundle install

Create database and user for it, go to redmine directory:

cd config
mv database.yml.example database.yml

Edit database.yml file and write database credentials in production section.
Now edit the config/environment.rb file.

ENV['RAILS_ENV'] ||= 'production'

Type in the shell:

RAILS_ENV=production bundle exec rake generate_session_store
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake redmine:load_default_data

Make sure there were no any error messages.
Go to public/ directory:

cd public/
mv dispatch.cgi.example dispatch.cgi
mv dispatch.fcgi.example dispatch.fcgi
mv dispatch.rb.example dispatch.rb
mv htaccess.fcgi.example .htaccess

Half of the work is done.
Now we must make it available to cPanel. So cPanel uses different version of rack and RoR there will be conflicts.
Install rubyonrails for cPanel.

/scripts/installruby

It will install RoR, RubyGems, Rack etc. which not compatible with redmine. Otherwise you’ll not be able to start ruby application from cPanel. So, create application named redmine and show the path(e.x. /home/redmine/ruby_apps/redmine - but it’s not real redmine directory with you just configured, it’s better show the non-existing directory). Once application is created. You can start it.
Start by clicking Run button on cPanel.

Test it http://yoursite.com:12001. If everything is okay, so we can continue for tricks.
Now stop it.
Go to directory which you created with RoR application on cPanel. Remove all files, copy everything from configured redmine directory. Then go to rubygems directory where you downloaded 1.4.2 version.

ruby setup.rb

Go to redmine directory

gem install passenger
bundle install

Change permissions for redmine directory.

cd ..
chown -R apache:apache redmine_dir
chmod -R 755 redmine_dir

Now go to cPanel, Ruby on Rails section. Run the application. Now it’s ready on http://yoursite.com:12001. You can make it available on port 80 with htaccess.
Enjoy!

Posted 1 year ago

Ten Common Database Design Mistakes

No list of mistakes is ever going to be exhaustive. People (myself included) do a lot of really stupid things, at times, in the name of “getting it done.” This list simply reflects the database design mistakes that are currently on my mind, or in some cases, constantly on my mind. I have done this topic two times before. If you’re interested in hearing the podcast version, visit Greg Low’s super-excellent SQL Down Under. I also presented a boiled down, ten-minute version at PASS for the Simple-Talk booth. Originally there were ten, then six, and today back to ten. And these aren’t exactly the same ten that I started with; these are ten that stand out to me as of today.

Posted 1 year ago

Adobe Stops Development of Mobile Browser Flash [REPORT]

Adobe Stops Development of Mobile Browser Flash [REPORT]
Adobe has ceased the development of Flash Player for browsers on mobile devices, ZDNet reports citing an upcoming announcement from Adobe. “Our future work with Flash on mobile devices will be focused on enabling Flash developers to package native apps with Adobe AIR for all the major app sto…