Mounting drives in Linux

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Linux, OS, Uncategorized, Utilities | No comments yet.

Sometimes you have a drive that your want to mount under Linux. The mount command can make the drive available to you. But you need to also create a directory to hold the mount point.

mkdir /mnt/drivepoint

Then you can mount the drive to that mount point by using the mount command and giving the device identifier, in this case it is /dev/sda1, and the mount point which we created as /mnt/drivepoint. One thing to note, is that the mount will use whatever directory you specify, so if there are files located in the directory you use as a mount point, they will no longer be visible.

mount /dev/sda1 /mnt/drivepoint

This must be run as root or with the sudo command.

Tags: , ,

WordPress blank pages after updating

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Wordpress | No comments yet.

Recently I upgraded to WordPress 3.2.1 and in the midst of this I was fixing a problem in my functions.php file. It turned out that using the editor happened to leave an extra line at the end of my functions.php file and this caused all of the admin pages to no longer load. I removed the extra space at the end of the file and now I am able to admin my site.

So check any recently updated files and make sure there are no erroneous spaces at the end of the files.

Tags:

WordPress fix for 28px margin issue

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Wordpress | No comments yet.

I was tearing my hair out the other night trying to figure out why there was a 28px margin at the top of the page that I don’t remember setting up. I searched the for the issue and found that there is an issue with the version I am stuck on and the work around is to put the following code just before the </body> tag in footer.php.

 <?php wp_footer(); ?>;

Tags:

Perl: CPAN installing modules

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Perl, Programming, Scripting | No comments yet.

Sometimes it is necessary to install other modules into the Perl environment. Luckily there is a great repository of modules known as CPAN (The Comprehensive Perl Archive Network). This lets you install modules to help with encryption, XML,YAML, and many other things. There are a few ways to install a package and here are the ones that I use the most.

Using the CPAN shell:

perl -MCPAN -e shell

This will open a command prompt that will let you search for CPAN modules with:

i /PACKAGENAME/

or install a new module:

install /DateTime/

The nice thing about installing with CPAN is that it will look for the dependencies and suggest installing them before the module you requested.

NOTE:This can take some time and your dependencies could have dependencies.

The other method I use is to skip the CPAN prompt and just directly execute the install of the module:

perl -MCPAN -e 'install DateTime'

This is just the most basic of usage, and there is probably a lot more you can do, but I have not had to use much more than this.

Tags: , ,

Gallery of Hello World!

digg del.icio.us TRACK TOP
By Eric Downing | Filed in C/C++, C#, Java, Perl, PHP, Programming, Python, Ruby, Rust, Shell | No comments yet.

Here is a list of the Hello World Programs for different languages:

C

#include <stdio.h>
int main()
{
printf("Hello World!");
}

C++

#include <iostream.h>
int main()
{
cout << "Hello World!" << endl;
}

C#

public class HelloWorld
  public static void Main()
  {
    System.Console.WriteLine("Hello World!");
  }

Java

class HelloWorld {
static void main(String[] args)
{
System.out.println("Hello World!");
}

SHELL

echo "Hello World"

Python 2

print "Hello World!\n"

Python 3

print ("Hello World!")

Ruby

puts "Hello World!"

Perl

print "Hello World!n";

PHP

  <?php      
    print "Hello World!";
  ?>

Rust

fn main() {
    println("Hello World!");
}

This is the simplest form of Hello World for most of these languages.

Tags: , , , , , , ,

Using tar over ssh

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Scripting, Uncategorized, Utilities | No comments yet.

Every once in awhile, I need to backup a large directory from another computer. This can be done by creating a zip or tar of the files you are looking to save and then copying those zips to the other computer. But what it you have a very large directory and not enough room to store the extra file. Here is a way to use tar over ssh:

ssh tar zcvf – /wwwdata | ssh root@backupserver.mydomain.com “cat > /backup/wwwdata.tar.gz”

Setting timestamp with Touch

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Linux, Scripting, Uncategorized, Utilities | No comments yet.

Did you know? You can Set file timestamp using touch command. One way to do this is:
touch -c -t YYMMDDhhmm filename.txt

Best Learning sites(in progress)

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Uncategorized | No comments yet.

Learnable
www.learnable.com
Brought to you by Sitepoint. They have created a site to host their on-line classes and a place for people to create their own as
well.

Udemy
www.udemy.com
Just checking this one out, I found some interesting courses, but many seem to be placeholders for classes to come later.

LiveMind
www.livemind.com
Just read about this one and have not looked thorugh it very much yet.

Vi: Remove Ctrl-M characters from a document

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Uncategorized | No comments yet.

I regularly have to move scripts between Windows and Linux systems. The line endings from
Windows can make running my scripts on Linux fail. I have been on a few systems where the
dos2unix command was not available, so how do I get rid of the Ctrl-M at the end of the lines?

Command: vi -b <filename>

The -b sets vi into binary mode. This displays the extra control characters. In vi, I remove the
ctrl-Ms.

In vi, I use the following key sequence in command mode:

 :%s/<ctrl-v><enter>//g 

The ctrl-v tells vi to take the next character and display it as a ctrl char sequence. And hitting the
enter key displays the ctrl-M. The :%s///g is a command to replace the characters in the first // and replace
it with the chars in the second // and the g says to do it to every line.

Retrieve drive letter on Windows

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Scripting, Windows | No comments yet.

The other day I had to write a script to change to a working directory and back to the original directory. The problem was they were on different drives on Windows. So I had to find a way to capture the drive letter
and switch back to that drive. When using the following command,

cd F:somedir

you are not moved to the “F:” drive without an explicit “F:” command.

The cd Command on windows will show the current directory location. Using some string manipulation on that and capturing it to a variable allows us to go back to that drive.

REM Capture the current drive letter
set ORIGDRIVE=%cd:~0,2%

F:
REM some other scripting things here

REM Return to the original drive letter
ORIGDRIVE

The first line captures the current drive letter by specifying the first character with 0 and the ,2 states to pick up the next 2 characters which would hold the “C:” or whatever drive you started on.

Tags: , , ,