Remove annoying WINE file associations
Author: pengrath
This has always annoyed me and I finally found the right solution. Here is the problem, when you install WINE linux starts opening text files and images using windows applications. This is usually not the desired behavior and can be avoided by removing file associations that have been placed in your home configuration files.
edit
~/.local/share/applications/mimeinfo.cache
comment out the file associations with a preceding #.
TinyMCE Popup with text selection
Author: pengrath
If you are writing your own plugin that uses tinyMCEPopup and you want to get the text that the user highlighted, make sure you use the restoreSelection() method.
tinyMCEPopup.restoreSelection();
This will get whatever was selected before pushing the button for your plugin. This fixed an Internet Explorer bug and may help fix compatibility with other browsers.
Vi and Vim non-Greedy RegEx
Author: pengrath
Took me a long time to find the solution to this but finally found it and it is a little strange. when doing a search or find and replace in Vi or Vim you can use regular expressions. Many times when writing regular expressions you want to use a * that is non-Greedy meaning it gets the smallest number of preceding characters that it can to fulfill the rule.
Some engines can use a ? after an * to symbolize non-greed
input: foobarbar
RegEx: m/fo.*?b/
matches: foob
but Vi cannot:
To do the same thing in Vi or Vim all you have to do is mach a range of instances but don't worry about giving it any numbers instead give it a dash, \{-}.
input: foobarbar
RegEx: m/fo.\{-}b/
matches: foob
If you don't use the non-greedy symbol in either engine then the result would be "foobarb". Hope this helps, it helped me on multiple occasions.
Note on range of instances:
\{3\} will match 3 preceding symbols
\{1,3\} will match anywhere from 1-3 preceding symbols
\{,3\} will match 0-3 preceding symbols
Avoid Costly Mistakes and Confusion – Colored Prompt Tip
Author: Maq
I thought I'd share a little trick for my fellow Linux users. Some of you may already know this but it's very helpful for me when SSH'ing from development to live servers, so I don't make any mistakes. This trick will allow you to change the color of your prompts for each individual server.
For this trick to work, you simply edit your bashrc file on whatever server you want to change the color of your prompt. Some general steps if you're not familiar:
1) Use your favorite editor to edit your bashrc file:
vim ~/.bashrc
2) Comment out the default setting for PS1:
#PS1='[\u@\h \W]\$ '
3) Add (this is my setting for a user, it's pink
):
export PS1="\[\e[0;35m\]${PS1}\[\e[m\]"
for Root settings:
PS1='\[\e[0;31m\]\u \[\e[1;34m\]\w \[\e[0;31m\]\$ \[\e[0;32m\] '
Here's a list of different colors:
Black-0;30 Dark Gray-1;30 Blue-0;34 Light Blue-1;34 Green-0;32 Light Green-1;32 Cyan-0;36 Light Cyan-1;36 Red-0;31 Light Red-1;31 Purple-0;35 Light Purple-1;35 Brown-0;33 Yellow-1;33 Light Gray0;37 White-1;37
4) Keep repeating these steps on your desired servers with your preference of color.
5) For the colors to take effect you have to either restart your console or source your bashrc file:
source ~/.bashrc
or if your last command was to edit the bashrc file you can use bang-dollar (which saves me a lot of time if I'm dealing with the same file a lot):
source !$
I know this helps me out a lot, so I hope this helps others to avoid mistakes and improves the efficiency of your work!
SSH Auto-mount Network Share
Author: Maq
(Beware - This blog/tutorial is directed towards linux based users)
When doing any type of work, especially web work, one of the royal pains is FTPing to your server, or any type of file transfer. Well now you can make it quick and painless. Let me introduce SSHFS. There are 3 major components when creating the SSHFS, and I will guide you through creating and installing all of the necessary steps. Now you can mount and use your file system to automatically upload files and folders to your server with ease.
The 3 Major components:
- SSH Automatic Login
- Install SSHFS
- Mount your folder(s)
SSH Automatic Login
Run this command (with the obvious variable substitutions). It should create a public ssh key on your server.
ssh-copy-id [-i [identity_file]] [user@]machineCheck to make sure it's there, the file should be called, "authorized_keys".
- ssh-keygen -t dsa
- ssh-copy-id user@machiner.
ls -al ~/.ssh/If you're having trouble with this part, you can reference this tutorial which breaks this component into smaller steps: SSH Automatic Login.
Install SSHFS
sudo apt-get install sshfs Or use whatever package manager your distribution provides.Mount
Create a shell script, we'll call it "mount.sh", and add the contents:sshfs [user]@[your_server].com:/dir/on/server /dir/to/mountRun the script:
./mount.shGo to the mounted directory and run the 'ls' command to make sure all of your files/folders from your server show up in your local directory.
After you have this successfully working you should at it to your startup scripts.
System >> Preferences >> Sessions >> [add_a_new_entry]You should be all set. You should have an automatic SSH login (no prompt for a password) from your computer to your server and a mounted folder to your server that acts as an automatic FTP client. The files in your mounted directory should be synced with that of your server. Now all you have to do is move or copy your desired files/folders into the mounted directory, and voila, they're on your server.
Multiple domains with SSL on same IP
Author: stim
At some point in your Unix Admin days you may be tasked with setting up multiple signed SSL certificates on a single IP. There is a fundamental problem with this, and it's worth understanding before tackling the issue at hand.
The problem is when you add SSL. The server sets up the encryption before your browser sends the HTTPS request. Therefore the server does not know what page you are trying to access, until after authentication/encryption is completed. Since the server doesn't know what site you are visitng until after the encyption "handshake" is complete, the server can not send the correct SSL certificate for that site and you get a nasty warning.
With the venerable Apache web server, you can overcome this* using SNI and a set of name-based VirtualHosts.
SNI or server name indication (RFC 4366) allows the browser to send an additional field, the name of the site being requested, in its initial SSL "handshake" or connection setup. Apache can then use SNI to deliver the correct certificate.
Now that we know why this is needed let's explore the solution.
Step 1.
Compile OpenSSL with the necessary TLS extensions included to support SNI. For this example we will put the new OpenSSL installation in /usr/local2 to avoid conflicts with any existing OpenSSL installations.
./config --prefix=/usr/local2 --openssldir=/usr/local2/openssl enable-tlsext shared
Step 2.
Compile Apache to use the new OpenSSL library. Your set of includes and enabled modules may differ from the example below.
LDFLAGS=-L/usr/local2/lib CPPFLAGS=-I/usr/local2/include/ ./configure --prefix=/opt/apache-ssl-sni --enable-so --enable-ssl --enable-rewrite --enable-unique-id --with-ssl=/usr/local2/ --with-included-apr --enable-headers
Step 3.
Add this to the top of the apachectl script in the /bin directory of your apache installation. This tells Apache to use the OpenSSL library that we just installed in /usr/local2 .
export LD_LIBRARY_PATH=/usr/local2/lib:$LD_LIBRARY_PATH
When you restart Apache (bin/apachectl -k restart) you should see the following warning in the logs. This means Apache has successfully loaded the new OpenSSL library.
[warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support
Sample Apache Vhost configuration:
Listen 443 NameVirtualHost *:443 <VirtualHost *:443> DocumentRoot /www/website1 ServerName www.website1.com </VirtualHost> <VirtualHost *:443> DocumentRoot /www/website2 ServerName www.website2.org </VirtualHost>
*SNI is not supported in any version of IE on Windows XP. SNI does work in other browsers on XP, and in IE on Vista and above.
URL Redirects on Personal Web Pages
Author: pengrath
Many people with personal web pages may not know the power they have over the server. The company providing the server space may be giving you more power then you think. By using files called .htaccess files you can directly influence the server's configuration in the directory that you place the .htaccess file. Dream Host and Host Gator both provide this functionality (to learn more whether your host provides this functionality, please see their documentation).
The first thing you should know about .htaccess files is that on many Operating Systems (Linux, Mac OS X, or other Unix based OS) a '.' in front of the file name means its hidden. In order to view this file on an FTP client, or file browser you may have to make sure you can view hidden files. It is simple to create redirects with .htaccess files once you see some example.
Redirect /index.html /myblog/index.php
This will redirect your default home page to a different subdirectory. If listing out more then one redirect put them on sepreate lines.
Redirect /index.html /myblog/index.php
Redirect /oldhtml.html /newhtml.html
This will redirect the user if they go to index.html or oldhtml.html
if you change your domain name and want to redirect all traffic to your new webiste then you can do this too
In your old website directory you can write something like this in the .htaccess file
Redirect /index.html http://www.example.com/index.html
One thing to note about .htaccess files is that they apply themselves to all subdirectories, so without the '/' before index.html server will redirect all index.html files to the blogs index.php (given that the .htaccess file is in the root directory). This said you may have more then one .htaccess file on your site as long as they are in different sub directories and they will only apply themselves to their directory and subdirectories.
This is just a starting point for redirects if you want to get into more complex rewrites then you should be using mod_rewrite adding functionality like conditionals (RewriteCond) and rules (RewriteRule), maybe I will post about the usefulness of mod_rewrite later.
If you are more technical and would like to learn how to create script directories or other advanced server configurations please refer to Apache's documentation on .htaccess files
Welcome
Author: admin
Welcome to Pod 2. We are a self proclaimed elite group of software developers, who would like to provide other tech users with up to date information about the ever changing world of computers.