How to autostart service in linux ubuntu

I was creating a program using python for my linux box and I need this program runs every time when the server booting. I was googling how to get this done, some are suggesting to edit the rc.d file then add our line in there. That’s work though, but I found something better, we can manage what service will be started on booting using rcconf.

You will need to install rcconf from repository to get this work,

apt-get install rcconf

Once installed you can use it by entering this command

rcconf

The rcconf will display what service/program that located in /etc/init.d/, mark the service you want to start manually then save it.

That’s it, so simple and easy 🙂

Powershell enable execution of script

By default powershell prevent the user to run a script file (.ps1), in order to enable the execution of script we have to manually enable it.

First check your powershell execution policy

Get-ExecutionPolicy
Restricted

If it shows “Restricted” then you will have to enable it

We can use "Unrestricted" phrase to enable it

Set-ExecutionPolicy Unrestricted

It will prompt confirmation, if you want it to force put "-f" in the command. The command will look like this

Set-ExecutionPolicy Unrestricted -f

Now you can run your scripts on your Powershell.

Hostgator coupon code 2011

Hi guys, special info for you who looking for Hostgator coupon. I have the hostgator coupons list, these coupons works for this year (2011).

 

$9.94 Coupon

luvgator994

supercode994

25% Off Coupon

luvgator25

24.94 Off reseller hosting Coupon

gatorresell2494

supercode2494

 

How to use this coupon? When you stepped on Choose a domain page, take a look at this picture. By default there will be a “spring coupon” this coupon only gives you 20% off. Replace it with luvgator then you will get 25% off.

 

How to Flush DNS Cache in Windows XP

If you have a domain and set a new nameserver for your domain, your computer will not access the server behind your new nameserver. It’s happened because your computer cached the DNS so when you trying to access your server using the domain, it will always redirected to previous server. The DNS cache  will be updated automatically after period of time, max time for this update is 2 x 24 hours.

To manually flush your DNS cache on Windows XP, you can use this command in command prompt. Open your command prompt by pressing Windows Button + R, then type cmd.

Use this command.

ipconfig /flushdns

How to mount .iso image in Mac OSX

It’s really easy to mount .iso image in Mac OSX, we don’t need to install any third party too. We can use terminal command to mount the .iso image

hdiutil mount yourimage.iso

Change the “yourimage.iso” into the .iso path file. You can also mount .dmg using this method.

Access CPanel behind company proxy firewall

I was having problem accessing my web server from my company, my company network only open port 80 for internet access. So it would be impossible if someone trying to do to access CPanel behind this firewall.

But there’s a way for us to access CPanel via port 80 on our server, there’s no change at all both side our network or server. To access CPanel behind company firewall we can go to http://cpanel.domain.com, replace the domain.com with your own domain. For example http://cpanel.leoganda.net

By using this technique we are bypassing the port on our server, and accessing the port 80 over CPanel. So we gain access.

The System Cannot Execute The Specified Program C++

Today I made a simple console application using Visual C++ 2008 and it was runs well on my development machine. But the problem occurred when I run the application on another machine, the error says “The system cannot execute the specified program“. I was guessing the problem occurred because of missing library or something, after short analysis both machine have the correct and the same library. So what’s going on??

I googled for this error and found this article, it explains how this problem occurred on compiled C++ application. There’s two type of build on VC++ ( Debug and Release), my application was built in debug mode and we can’t re-distribute the application on debug mode. The built program in debug mode only runs on development machine, so in order to distribute my app I should build my application in ‘Release’ mode. Time to switch from ‘Debug’ to ‘Release’ mode,

Open your Visual Studio->(Open Project)->Project->(project name) properties

select the Build Tab, in configuration option choose “Release”.

Rebuild your project, you will find “Release” folder, your released application is in there.

Simple Powershell FTP

With Powershell we can do FTP transaction really easy. The best feature from Powershell is we can use any dll library in our script, we can import .Net libraries and etc into our script. The script below is simple FTP to upload file to FTP server. In this script I’m using System.Net.WebClient to handle the file transfer.

$ftpuser = "user"
$ftppass = "12345"
$ftpserver = "localhost"
$file = "C:\test.txt"
$filenewname = "test.txt"

$webclient = New-Object System.Net.WebClient
$ftp = "ftp://"+$ftpuser+":"+$ftppass+"@"+$ftpserver+"/"+$filenewname
$uri = New-Object System.Uri($ftp)

$webclient.UploadFile($uri,$file)

Powershell script sort list file

It’s pretty easy to sort an output from ls or Get-ChildItem using powershell, you can sort the output by name, length, and date.

Sort By Name

Get-ChildItem C:\ | sort -property Name

Sort By Size

Get-ChildItem C:\ | sort -property Length

Sort By Date Modified

Get-ChildItem C:\ | sort -property LastWriteTime

You also can reorder the sort output with “-descending”
example :

Get-ChildItem C:\ | sort -property LastWriteTime -descending

Python for Windows Mobile

Hello, right now I’m doing development some project using Python for my new company I’m working on. I thought Python will be boring, but Python changes my mind! As programming language Python is really simple and powerful. It can be run cross platform without compile anywhere. It runs well on my Windows and Linux, so I was thinking could I install Python on my Windows Mobile device? The answer is YES! I’m using Windows mobile 6.1 and runs Python perfectly on it. If you want to install Python CE on your windows mobile device, you can get the CAB file in here. It’s free.