[Solved] Error executing git commit in phpstorm

I thought Git and Phpstorm would work out of the box with minimal configuration. I pointed Git.exe in phpstorm and tried committing a file. To my surprise, I got the following error always.

example is taken from web:

"Error executing git commit --only -F /private/var/folders/bs/zfry67p51_gflf6hqgzplv2xt80189/T/git-commit-msg-5921808149812071312.txt --author=dsedlacek -- web/js/definitions/jquery.d.ts web/js/libs/handlebars-v1.3.0.js web/css/icon...."

And after poking around for a while. I kept git.exe in windows global PATH variable and Phpstorm started working smoothly with Git :).

Solution: Set full path to git.exe to windows environment PATH variable.

Right click on computer > Properties > Advanced system settings > Goto advanced tab then click on “environment variables” > In system variables find the PATH variable edit it and at the end put semicolon and then append the full path to git.exe.

Hope this helps the needy soul :)

Walkthrough on remote access to Ubuntu14.04

I often access my ubuntu machine remotely and today I will be describing how I setup my machine to access it remotely from anywhere through internet. This is not a step by step guide rather it’s a kind of walkthrough and giving overview on how I knitted each bits and pieces to get the job done. To understand this post, you will need to have basic understanding of IP addresses, basic understanding on router, port forwarding, installing/uninstalling applications on Ubuntu, webserver for hosting php files, basic understanding of cron jobs on linux.

Let’s get to the point, at first I installed xrdp on my Ubuntu box and then installed xfce4. I found this http://www.tweaking4all.com/software/linux-software/use-xrdp-remote-access-ubuntu-14-04/ link very helpful. I won’t explain how to install xrdp and xfce4. Follow the link and you will have xrdp and xfce4 installed at the end of that post.

Now the next part is to configure the router. At first enable the remote management port in your router. This instruction differ from router to router so find the instruction that suits to your case. After that forward the port 3389 to your local network IP (for e.g. 192.168.0.10). This local IP will be generally one assigned by your router to your local machine, if DHCP is enabled in your router otherwise you’ll have to manually assign static IP to your local machine. Now the most important part is to get dynamic IP. This dynamic IP is what other users on internet will use to access your computer directly. This dynamic IP varies everytime you make connections to your ISP. Each time your router connects to ISP, each time it gets a new IP assigned by ISP so knowing this IP is crucial part. this IP will be used to access your router remotely and then configure port forwarding to the local machine. I am using a php script to get the dynamic IP. I found a little PHP snippet that does the job of finding the ISP assigned IP address (WAN IP).

<?php
//Filename : ip.php

$externalContent = file_get_contents('http://checkip.dyndns.com/');
preg_match('/Current IP Address: ([\[\]:.[0-9a-fA-F]+)</', $externalContent, $m);
$externalIp = $m[1];
$date = new DateTime();
echo "Last updated :". $date->format("m/d/Y H:i:s a");
echo PHP_EOL;
echo "WAN IP: ".$externalIp;
;?>

The output is

Last updated :10/17/2014 21:30:02 pm
WAN IP: 182.93.64.253

Save the above php snippet in ip.php and put it inside htdocs of your local webserver. In my case, I have kept ip.php file in my webserver’s test folder accessible at http://test/ip.php.

I have set cron job in my machine that runs ip.php file and saves the out on wan.txt file. I have another shell script (ftp.sh) which uploads this wan.txt file to my personal web-space. Now, this uploaded wan.txt is accessible from internet at (http://www.samundra.com.np/wan/wan.txt). I am now able to get the dynamic address assigned to my machine everytime. Below is the cronjob settings and ftp.sh contents.

ftp.sh

#!/bin/bash
echo "Uploading ip.txt via ftp"
HOST=ftp.yourdomain.com
USER=user@yourdomain.com
PASS="XXXXX"
ftp -inv $HOST << EOF
user $USER $PASS
put "wan.txt" "wan.txt"
bye

Put the appropriate settings on HOST, USER, PASS and then save the ftp.sh and put in the same location where you have kept ip.php.

Cronjob settings

*/5 * * * * /usr/bin/wget -q -O wan.txt http://test/ip.php
*/5 * * * * /var/www/test/ftp.sh

Those were all, what I did for getting my machine to internet. I have configured various services on my machine and use them on regular basis using remote access. When you are exposing your machines to the wild you need to take precautions and use tight security measures which I haven't mentioned here. Hope this sharing helps someone out there.

Let me know your comments and feedbacks. I will try to answer your queries as soon as possible.

[Windows] Reset group policy to default through command line

These are the three magic lines that will reset the windows group policy from your windows machine. This does not delete any user data but there are chances that some windows settings may be reset to default (That’s what we are trying to do right?) for e.g. windows update.

This may help you for cases like

  • Missing Network adapters from Network connection
  • When you screw up your group policies while experimenting windows settings on it.
  • Some installations of windows 8 won’t let you change windows update settings and report that “Some settings are managed by your system administrator”

Below are the magical lines:

1. Start cmd and run it as administrator
2. And then execute below lines one by one

RD /S /Q "%WinDir%\System32\GroupPolicyUsers"
RD /S /Q "%WinDir%\System32\GroupPolicy"
gpupdate /force

3. After executing above commands, in some instances you might have to restart your computer. It’s better to restart your machine.

Hope this helps.

[Solved] How to deploy php app to heroku from windows

I am fulltime linux user and parttime windows user. Lately I have started working with windows for some project stuffs. I found windows quite frustating and limited to what linux provided me. Well it’s all personal feelings. I always hated unnecessary installations of extra applications for the same tools which most of the linux distributions provides us out of the box. For e.g. ssh-keygen. To emulate the most of the linux command we need to install cygwin.

I was working on a facebook application and had to deploy it to heroku. I could do this with few commands in ubuntu which already come with those commands preinstalled. I had to do nothing, just push and push as I had already added my SSH keys in heroku settings.

Basic walkthrough on how one can deploy the heroku app using git Bash shell.

To carry out this process you must have git bash shell installed. Download git for windows and install it.
Git Download Link

Download Heroku toolbelt for windows, Download Link for Heorku

Once downloaded install the heroku toolbelt. After installation is complete, you can set heroku path to the environment variable.

c:\set path=%path%;C:\Program Files (x86)\Heroku\bin;

Now start the Git bash shell.
Git bash shell

Note:We installed git bash shell because it already comes with ssh-keygen which is required to generate pair of our keys.

1. Generate SSH Keys for windows

$ ssh-keygen -t rsa

When asked for

Enter file to which to save the key(/c/Users/user/.ssh/id_rsa):
just hit enter then enter your password, re-enter your password.

See the screenshot below:
Generate SSH Keys for windows

You have successfully generated ssh keys and has been saved in location supplied above.

Now, you have to use those SSH keys with heroku. To do this first copy the contents of id_rsa.pub file exactly as it is. You will find this file in C:\Users\user\.ssh\, if you haven’t changed the default folder location while creating ssh keys shown above.

Now, Go to your heroku dashboard, scroll down under section SSH Keys, Click in Add new SSH Key, paste contents of id_rsa.pub here. Then click in Add key. You have successfully added your public key to heroku. Now is the time to test our key.

Also see the screenshot below:
Heroku SSH keys

Upload ssh keys to heroku

$ heroku keys:add

Try to login to heroku use the command shown below, Since we have already added heroku to path. This should work.

$ heroku login

See the screenshot below:
heroku login

If we are using heroku login for the first time, it looks for ssh keys and since we have already created SSH keys and have also added it to heroku, this should work as expected and give us authentication successfull message. That’s it.

2. Add heroku remote repository to the project

$ heroku git:remote -a survey2email-sam

See screenshot below:
Add git repository to heroku

3. After adding heroku remote confirm it. To confirm it use the following command.

$ git remote -v

git remote -v

4. Now push code commits

$ git push heroku master

Enter password that you used to create SSH Key pairs. Wait for a while, heroku is working on your requesting.
After few seconds/minutes depending on your sources you will be shown feedback what is going on. Now you can feel relaxed and have cup of tea.

Push git repository to heroku

Congratulations. You have successfully deployed your PHP app to heroku.

I have skipped some steps assuming that you have basic familiarity with git. The above command assumes that you have already added, commited your codes to repository and want to deploy them to heroku.

If you find any difficulty in following the walkthrough drop your questions in comment box below.