Getting brief Git repository information
A good bash script that shows brief information about a Git repository. I’ve found the script here: http://goo.gl/QUe5t.
A good bash script that shows brief information about a Git repository. I’ve found the script here: http://goo.gl/QUe5t.
If you have something that you don’t want anyone to know, maybe you shouldn’t be doing it in the first place.
— Google CEO Eric Schmidt
While exploring Tumblr, I saw the following post:
…when switching don’t mind using:
if ($val==0) $val = $1; else $val = 0;instead use:
$val = abs ($val-1);
It’s ok (except the $1 typo); but the following solution is far more efficient:
$val ^= 1;
I saw the post and wanted to leave a comment; but I couldn’t. That’s why I’m posting this. :)
Whenever Ubuntu makes a new release, I realize that I’m getting older…
If you’re familiar with unix-like systems, probably you’ve already worked with shell commands. My favorite shell is Bash and this post is about running Bash commands on a remote machine; but I guess the idea behind it can be used in other Unix shell systems too.
As a web developer, I frequently have to deploy projects to remote servers. When something changes, I need to re-deploy the whole project (especially when I work on projects written in Java). The easiest way for me is to write a deployment script that automatically goes over the boring mandatory steps (e.g. backing up the latest version on the remote server, copying files, preparing the package). This way is even more secure. Once I’m sure that the script does its job correctly, it does not have a choice to make a mistake.
During my first attempt to write such a script, I faced a problem when I wanted some commands of the script to work on the remote machine. Normally, to work on a remote machine you make a connection via ssh, find yourself on its shell and continue writing your commands. Here, the problem is that the script works on your local machine and if you open an ssh connection, it just gets stuck. A workaround for this problem is running commands like this:
ssh -p PORT_NUMBER USERNAME:PASSWORD@REMOTE_MACHINE_IP "cd /var/www; ls;"
The trick here is to append the desired commands after the connection command. But if the job you’re doing is complicated enough, appending such commands may drive you to have problems.
My solution to this problem is to write a second bash script, copying it to the remote server via scp and running that script remotely. Yes, of course it works and is a great idea! Let’s assume that the name of the bash script file is ss-script.sh (ss stands for Server-Side). In our local deployment script, let’s add these lines:
scp -P POST_NUMBER ss-script.sh USERNAME:PASSWORD@REMOTE_MACHINE_IP:/tmp
ssh -p PORT_NUMBER USERNAME:PASSWORD@REMOTE_MACHINE_IP "cd /tmp; chmod 777 ss-script.sh; ./ss-script.sh"
And that’s it! The script would work as expected and after it’s finished, your local script will continue to work from the next line!
I have a server at home. I use the fiber internet connection service of Superonline at 20Mbps. During the initial setup, they provided me Pirelli’s modem (PRG E4202G). Why I’m writing this post is my negative thoughts about the usability of its management console. It’s really hard at first to find out how advanced settings can be configured. It’s likely you’re lost. If you own one, you already understand what I mean.
I wanted my home server to have a static IP in the local network. The solution is simple; you assign an IP to the server’s MAC address. That’s all about it; but it took some time for me to figure out how it works on the management console of PRG E4202G. Here’s how:
That’s it!
I use VIM as the default text editor on my Ubuntu box and generally work on HTML files. It’s a common problem of developers to edit a malformed (e.g. indentations are bad, tabs are used instead of spaces) source code.
When I encounter such a situtation, I enter the following commands in VIM to make the source code more readable (I wrote html as the filetype; but of course you should change it to your needs):
- :set filetype=html
- :filetype indent on
- :e
- gg=G
These 4 commands fixes the indentations of the file; but it’s not enough. I tend to convert tabs to spaces and fix the indention to 4 columns:
- :set tabstop=4
- :set shiftwidth=4
- :set expandtab
- :retab
That’s all!
onur@grizu:~$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
onur@grizu:~$ sudo apt-get update
onur@grizu:~$ sudo apt-get install sun-java6-jdk
By default, Zend Framework dispatches a request to the IndexController if no other controller is defined (modules, controllers and actions are selected via URL). Like me, you may want to change the default controller for some reason. In Zend Framework, you can do that by adding or changing the resources.frontController.defaultControllerName property in the application.ini file. It looks like this:
resources.frontController.defaultControllerName = "auth"
Now Zend Framework sees the AuthController as the default controller.
That’s all. Hope this helps…