Pages

Your Ad Here

This Blog is not to read or go through

because, I have never been such a mess


Search the blog instead

Showing posts with label HowTO. Show all posts
Showing posts with label HowTO. Show all posts

Wednesday, June 5, 2013

git reset to a commit on remote

1. reset to any known good commit
git push -f origin last_known_good_commit:branch_name –

Monday, June 3, 2013

How To Fix “421 Cleartext Sessions Not Accepted” Error In Filezilla?

Server is enforcing TLS encryption for the connections. Hence, need to add prefix ftpes:// before the hostname of the server

if trying to connection to example.com,
simply change the hostname to ftpes://example.com

Refer to this article for more details if required. 

Tuesday, May 14, 2013

curl post (php)

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

Sunday, March 17, 2013

Check ubuntu distribution information

$ cat /etc/lsb-release

Monday, June 18, 2012

OLAP in mysql

SELECT field1, field2, count(field3), count(field4)
group by field1, field2
with rollup

Monday, January 2, 2012

Bookmark: Regex Replace for MySQL

Reference -
 http://techras.wordpress.com/2011/06/02/regex-replace-for-mysql/

DELIMITER $$
CREATE FUNCTION  `regex_replace`(pattern VARCHAR(1000),replacement VARCHAR(1000),original VARCHAR(1000))

RETURNS VARCHAR(1000)
DETERMINISTIC
BEGIN 
 DECLARE temp VARCHAR(1000);
 DECLARE ch VARCHAR(1);
 DECLARE i INT;
 SET i = 1;
 SET temp = '';
 IF original REGEXP pattern THEN 
  loop_label: LOOP 
   IF i>CHAR_LENGTH(original) THEN
    LEAVE loop_label;
   END IF;
   SET ch = SUBSTRING(original,i,1);
   IF NOT ch REGEXP pattern THEN
    SET temp = CONCAT(temp,ch);
   ELSE
    SET temp = CONCAT(temp,replacement);
   END IF;
   SET i=i+1;
  END LOOP;
 ELSE
  SET temp = original;
 END IF;
 RETURN temp;
END$$
DELIMITER ;
Note:
If you are using MySQL version 5.0.1 or higher, make sure you set the NO_BACKSLASH_ESCAPES mode ON, before you use the above function to replace any characters which are escaped with back slash “\”, ie: \A,\B,etc… See how to set the NO_BACKSLASH_ESCAPES mode here
Example on how to use this function
mysql> select regex_replace('[^a-zA-Z0-9\-]','','2my test3_text-to. check \\ my- sql (regular) ,expressions ._,');
Happy Coding!! :)

Tuesday, July 19, 2011

How to set up your private GIT Server

Source: http://tumblr.intranation.com/post/766290565/how-set-up-your-own-private-git-server-linux


How to set up your own private Git server on Linux

Update 2: as pointed out by Tim Huegdon, several comments on a Hacker News thread pointing here, and the excellent Pro Git book, Gitolite seems to be a better solution for multi-user hosted Git than Gitosis. I particularly like the branch–level permissions aspect, and what that means for business teams. I’ve left the original article intact.
Update: the ever–vigilant Mike West has pointed out that my instructions for permissions and git checkout were slightly askew. These errors have been rectified.
One of the things I’m attempting to achieve this year is simplifying my life somewhat. Given how much of my life revolves around technology, a large part of this will be consolidating the various services I consume (and often pay for). The mention of payment is important, as up until now I’ve been paying the awesome GitHub for their basic plan.
I don’t have many private repositories with them, and all of them are strictly private code (this blog; Amanda’s blog templates and styles; and some other bits) which don’t require collaborators. For this reason, paying money to GitHub (awesome though they may be) seemed wasteful.
So I decided to move all my private repositories to my own server. This is how I did it.

Set up the server

These instructions were performed on a Debian 5 “Lenny” box, so assume them to be the same on Ubuntu. Substitute the package installation commands as required if you’re on an alternative distribution.
First, if you haven’t done so already, add your public key to the server:
ssh myuser@server.com mkdir .ssh
scp ~/.ssh/id_rsa.pub myuser@server.com:.ssh/authorized_keys
Now we can SSH into our server and install Git:
ssh myserver.com
sudo apt-get update
sudo apt-get install git-core
…and that’s it.

Adding a user

If you intend to share these repositories with any collaborators, at this point you’ll either:
We’ll be following the latter option. So, add a Git user:
sudo adduser git
Now you’ll need to add your public key to the Git user’s authorized_keys:
sudo mkdir /home/git/.ssh
sudo cp ~/.ssh/authorized_keys /home/git/.ssh/
sudo chown -R git:git /home/git/.ssh
sudo chmod 700 !$
sudo chmod 600 /home/git/.ssh/*
Now you’ll be able to authenticate as the Git user via SSH. Test it out:
ssh git@myserver.com

Add your repositories

If you were to not share the repositories, and just wanted to access them for yourself (like I did, since I have no collaborators), you’d do the following as yourself. Otherwise, do it as the Git user we added above.
If using the Git user, log in as them:
login git
Now we can create our repositories:
mkdir myrepo.git
cd !$
git --bare init
The last steps creates an empty repository. We’re assuming you already have a local repository that you just want to push to a remote server.
Repeat that last step for each remote Git repository you want.
Log out of the server as the remaining operations will be completed on your local machine.

Configure your development machine

First, we add the remotes to your local machine. If you’ve already defined a remote named origin(for example, if you followed GitHub’s instructions), you’ll want to delete the remote first:
git remote rm origin
Now we can add our new remote:
git remote add origin git@server.com:myrepo.git
git push origin master
And that’s it. You’ll probably also want to make sure you add a default merge and remote:
git config branch.master.remote origin && git config branch.master.merge refs/heads/master
And that’s all. Now you can push/pull from origin as much as you like, and it’ll be stored remotely on your own myserver.com remote repository.

Bonus points: Make SSH more secure

This has been extensively covered by the excellent Slicehost tutorial, but just to recap:
Edit the SSH config:
sudo vi /etc/ssh/sshd_config
And change the following values:
Port 2207
...
PermitRootLogin no
...
AllowUsers myuser git
...
PasswordAuthentication no
Where 2207 is a port of your choosing. Make sure to add this so your Git remote:
git remote add origin ssh://git@myserver.com:2207/~/myrepo.git


--------------------


Sunday, July 3, 2011

Google +1 Button in your site

Implement +1 button to your website

The implementation button is simple. You just need to insert two line of codes to your HTML or theme file.
1. Insert the following javascript code to your  tag
<script type="text/javascript" src="http://apis.google.com/js/plusone.js">script>
2. Insert the following tag to the place where you want the button to appear.
That ‘s it.
For WordPress
As of this post, there are no plugins for adding the +1 button yet (but I am sure it will be available very soon). To add the +1 button, in your themes folder, open the header.php file. Insert the javascript code to the  tag
Open your single.php or index.php, and place the  to the place where you want it to appear.
plus1-button-code

Parameter

There are several parameters that you can use.
Size of the button: The default is “standard“, which is 24px tall. You can choose “small” (15px), “medium” (20px) or “tall” (60px).
Include count: The default is set to “true”. You can turn it off if you don’t want the +1′d count to appear.
URL (href): By default, the button will grab the URL of the existing page, but you can specify your own URL with the parameter href="your-url-here".

http://maketecheasier.com/add-google-1-to-website/2011/06/02
Source: 

Thursday, June 23, 2011

Disabling / Enabling Keyboard and Mouse in Linux (Xinput)

http://wpkg.org/Disable_/_enable_keyboard_and_mouse_in_Linux


Here is how to do it:
  • First, list the devices your X sees:
$ xinput --list
"Virtual core pointer"  id=0    [XPointer]
"Virtual core keyboard" id=1    [XKeyboard]
"Keyboard2"     id=2    [XExtensionKeyboard]
"Mouse2"        id=3    [XExtensionKeyboard]

  • Now, list details for the mouse (id=3):
$ xinput --list-props 3
Device 'Mouse2':
        Device Enabled (119):   1
        Evdev Reopen Attempts (254):    10
        Evdev Axis Inversion (257):     0, 0
        Evdev Axis Calibration (258):   
        Evdev Axes Swap (259):  0
        Evdev Middle Button Emulation (260):    2
        Evdev Middle Button Timeout (261):      50
        Evdev Wheel Emulation (262):    0
        Evdev Wheel Emulation Axes (263):       0, 0, 4, 5
        Evdev Wheel Emulation Inertia (264):    10
        Evdev Wheel Emulation Timeout (265):    200
        Evdev Wheel Emulation Button (266):     4
        Evdev Drag Lock Buttons (267):  0

  • Disable the mouse:
$ export DISPLAY=:0
$ xinput set-int-prop 3 "Device Enabled" 8 0

  • Enable the mouse again:
$ xinput set-int-prop 3 "Device Enabled" 8 1

  • Disable the keyboard:
$ xinput set-int-prop 2 "Device Enabled" 8 0

  • Enable the keyboard again:
$ xinput set-int-prop 2 "Device Enabled" 8 1

  • You may find more details in "man xinput".

Tuesday, May 17, 2011

base_url() function for php



function base_url(){
    $pathinfo = pathinfo($_SERVER["SCRIPT_NAME"]);
    $dirname = $pathinfo["dirname"];
    if($_SERVER["HTTPS"] == "on"){
    $protocol = "https";
    }else{
        $protocol = "http";
    }
    $base_url = $protocol."://".$_SERVER["HTTP_HOST"].$dirname."/";
    return $base_url;
}

Thursday, January 6, 2011

Adding network printer in linux

$ lpadmin -p some-printer-name -E -v ipp://network-ip-address/printers/printer-name

forexample
$ lpadmin -p LBP3050_on_server -E -v ipp://192.168.144.1/printers/LBP3050

Local printer alias - LBP3050_on_server
Server 192.168.144.1
Server Printer - LBP3050

Friday, July 30, 2010

Google Chrome - Your Profile could not be opened correctly ...

You might have encountered this issue.  Well I did too. Here is a solution I found and posted to the Google Discussion Thread on this same issue.
http://www.google.com/support/forum/p/Chrome/thread?tid=08e9aa36ad5159cb&start=40

So, here is what happened in my case.


I have been using Ubuntu Hardy 8.04 and Google Chrome 5.0.375.70
...

After facing similar problem, I tried as said above in the discussions and also at the Ubuntu Forums page mentioned here.

However, I could not make it solved, and the message saying 'Your profile could not be opened correctly' popped every time I restarted my browser.
....

So, I checked each single file, in the following order inside the directory ~/.config/google-chrome/Default
1) databases (dir)
2) Local Storage (file)
3) Web Data(file)

and on my third trial, I just found it working without the pop up.

Hence, according to my findings, its the 'Web Data' file which when removed I got the problem solved.
......................

Further,
I could not find my saved passwords restored still.

Any suggestions will be highly appreciated.

Friday, July 16, 2010

VIM Editor - Search and Replace

  • /searchkey - search something
  • :[range]s/search/replace/ - replace something within range
  • :8,10 s/search/replace/g  - replace something within range
  • :%s/search/replace/g - replace something full document
  • :%s/search/replace/gc.  - prompt

Tuesday, July 6, 2010

Recovering Grub

Uhu, Grub thing again.,

Now i must find the easiest solution, as simple as 1, 2 3.


  1. Boot from Live CD. Install grub with the following command
    $ apt-get install grub
    sudo grub
  2. Find the partition in which Grub is to be installed. May be the '/' partition of your hard drive, or the '/boot' partition of your hard drive. Then execute the following. Make sure you are in the grub shell with grub> prompt
    grub> root (hd0, 0) - Assuming 1st paritition of your first hard drive is the boot partition
  3. Setup the grub and reboot.
    grub> setup
    grub> quit
    $ reboot

Wednesday, June 23, 2010

Kannel restart script | Attempting to Kill a process in linux until it gets killed

Restarting kannel wasn't simpler, as the bearerbox was not exiting on single stop command for Kannel. So needed to do some tricks on killing the bearerbox first. See the code

#!/bin/bash
while [ true ]
do
 echo "quering bearerbox"
 sleep 1
 count=$(ps -C "bearerbox" | wc -l)
 echo $count
 if [ $count -eq 2 ]
 then
  echo "attempting to kill bearerbox"
  killall bearerbox
 else
  sleep 1
  echo "======= bearerbox killed ========"
  break
 fi
done
sleep 1
bearerbox /etc/kannel/kannel.conf
smsfox /etc/kannel/kannel.conf

Altering system default timezone in linux

Reference:
http://www.cyberciti.biz/faq/howto-linux-unix-change-setup-timezone-tz-variable/


Change Linux timezone

Select the method as per your Linux distribution:

If you are using Fedora / RHEL / Cent OS Linux

Type the redhat-config-date command at the command line to start the time and date properties tool.
# redhat-config-date
OR type setup and select time zone configuration (good for remote ssh text based Linux server sessiob)
# setup
Select timezone configuration
Fig.01: Redhat / CentOS Server Setting Up Timezone
Fig.01: Redhat / CentOS Server Setting Up Timezone
Now, just follow on screen instructions to change timezone.

Set timezone using /etc/localtime configuration file [any Linux distro]

Often /etc/localtime is a symlink to the file localtime or to the correct time zone file in the system time zone directory.

Generic procedure to change timezone

Change directory to /etc
# cd /etc
Create a symlink to file localtime:
# ln -sf /usr/share/zoneinfo/EST localtime
OR some distro use /usr/share/zoneinfo/dirname/zonefile format (Red hat and friends)
# ln -sf /usr/share/zoneinfo/EST localtime
OR if you want to set up it to IST (Asia/Calcutta):
# ln -sf /usr/share/zoneinfo/Asia/Calcutta localtime
Please mote that in above example you need to use directory structure i.e. if you want to set the timezone to Calcutta (India) which is located in the Asia directory you will then have to setup using as above.
Use date command to verify that your timezone is changed:
$ date
Output:
Tue Aug 27 14:46:08 EST 2006

Use of environment variable

You can use TZ environment variable to display date and time according to your timezone:
$ export TZ=America/Los_Angeles
$ date

Sample Output:
Thu Aug 27 11:10:08 PST 2006

Monday, June 21, 2010

Forgot your Google Apps Admin Password

If you forget Google apps admin password, sometimes it might be quite boring not to find the exact link to reset the password, since Google apps says contact administrator to support your login.

If you are yourself admin then ?


hmm, no need to think more.

Just Visit this link

Eg.
https://www.google.com/a/cpanel/appsdomain.com/ForgotAdminAccountInfo
Replace appsdomain.com with your own apps domain
Your Ad Here