Skip to content

Instantly share code, notes, and snippets.

View sandheepg's full-sized avatar

Sandeep Guduru sandheepg

View GitHub Profile
@sandheepg
sandheepg / apache-config-location.md
Created March 8, 2017 07:18
Locate apache config file

There is no default location for apache configuration file (httpd.conf) as this can be configured. To know the location run the below commands.

ps -ef | grep apache

root      4053     1  0 06:26 ?        00:00:04 /usr/sbin/apache2 -k start
www       5189  4053  0 11:00 ?        00:00:00 /usr/sbin/apache2 -k start
www       5199  4053  0 11:00 ?        00:00:00 /usr/sbin/apache2 -k start
@sandheepg
sandheepg / server-ip.md
Created March 8, 2017 07:17
Find server ip address

To find a server IP address

ifconfig eth0 | grep inet | awk '{ print $2 }'
@sandheepg
sandheepg / window-manager-ubuntu.md
Created March 8, 2017 07:16
Know which window manager is running

In ubuntu, you have a variety of window managers to choose from. Though Ubuntu 12.04 comes with Unity as the default you can switch back to Gnome, or choose other managers like Cinnamon.

If you want to know, which window manager you are running currently

echo $XDG_CURRENT_DESKTOP # tells you what window manager you are running
echo $GDMSESSION  # tells you what option you've selected from login screen
@sandheepg
sandheepg / sublime-contextual-menu.md
Created March 8, 2017 07:15
Add sublime text option to contextual menu

After installing sublime text, we must be able to open text files with it. Right click on a text file and you must see the option "open with sublime text". In case you don't, click Open with other applications and you should see Sublime text option there. No luck yet, here are the troubleshooting steps.

# open the .desktop file for sublime
sudo sublime /usr/share/applications/sublime.desktop

# add the below lines to the file
@sandheepg
sandheepg / cisco-vpn-ubuntu.md
Created March 8, 2017 07:14
Install cisco vpn client on ubuntu

Ubuntu ships by default with the plugin for the Point-to-Point Tunneling Protocol (PPTP), but we need the plugin for the Cisco Compatible VPN (vpnc), that provides easy access to Cisco Connector based VPNs. To install the vpnc plugin, follow the below instructions

Open Ubuntu Software Center and install Openconnect
sudo apt-get install vpnc
sudo apt-get install network-manager-vpnc
@sandheepg
sandheepg / unicode-conversion-url.md
Created March 8, 2017 07:12
Escape non unicode text in url

when the file names were actually in japaneese (or any non unicode language), IE by default will not convert the links from Japanese text to unicode URL format i.e %20. Here is the fix that is required to do that.

<a href="<%= product.product_image.url) %> ">SOME FILE NAME</a>
CHANGE TO :
<a href="<%= URI.escape(product.product_image.url) %>" >SOME FILE NAME</a>
@sandheepg
sandheepg / ruby-string-encoding.md
Created March 8, 2017 07:07
Change string encoding in ruby
# Ruby 1.9
string_in_utf8_encoding = string_in_latin1_encoding.encode('UTF-8')

#Ruby 1.8
gem install iconv

require 'iconv'
string_in_utf8_encoding = Iconv.conv("UTF8", "LATIN1", string_in_latin1_encoding)
@sandheepg
sandheepg / old-sessions-db.md
Created March 8, 2017 07:06
Clear old rails sessions from db

To delete sessions based on a hard coded cut-off date:

DELETE FROM sessions WHERE updated_at < STR_TO_DATE('23.05.2013',GET_FORMAT(DATE,'EUR'));

Replacing cut-off date with period of inactivity

DELETE FROM sessions WHERE updated_at &lt; DATE_SUB(CURDATE(), INTERVAL 30 DAY);
@sandheepg
sandheepg / wordpress-blog-rails.md
Last active March 8, 2017 07:04
Deploying wordpress blog in Rails
  1. First of all make sure that your server can parse both php and rails application.

  2. Make a blog directory in side the public folder of rails application.

  3. Deploy all WordPress content inside blog directory.

  4. Configure your database connection at wp-config.php file .

  5. Then just paste the following code in the apache config file

@sandheepg
sandheepg / current-parent-directory.md
Created March 8, 2017 06:56
What is ./ and ../ in Linux

In linux, we often see the use of ./ or ../ before a file name. Here is the explanation for the same

.  Current Directory
.. Parent Directory

./filename  # referring to file name in current directory
../filename # referring to file name in parent directory