earth tech

[software and hardware technology originating from or otherwise pertinent to planet earth]

use these buttons to share this blog on portal sites:

Add to Google

Wednesday, July 29, 2009

 

Emacs mixed-mode PHP sources

Caveat: For these ideas to work, you might [depending on your system] need to download and install either or both of these Elisp modules:

   php-mode
   css-mode

Presumption [for the purposes of this tip]:  IF you are using Emacs to edit PHP and/or CSS, THEN you know about and are using one or the other or both of these modules. If not, then you should probably give up now or seek professional help immediately.

Task:  Editing a PHP source file using Emacs can involve working in several source code language formatting modes, since it is common to mix PHP, CSS, (X)HTML, Javascript, and even MySQL query syntax in one PHP source file.

Rationale:  Although mixing languages in a single source file may on the face of it seem to violate the kind of *nixish organizational precepts that give us e.g. header (.h) and source (.c) files in C, sometimes painful experience has shown that the object oriented (OOD) precepts of "Encapsulation", "Isolation of Commonality", "Maintainability", and even (in some cases) "Human Readability" are all served by facilitating the mixing of languages within a single source file.

All that to say this: When editing a block of CSS code within a PHP file (using Emacs, of course), I have found it helpful to use the Emacs 'css-mode' Meta-Q key binding to format CSS rule blocks. However, when entering a multi-line CSS comment in the traditional 'C' style, it is useful to ask Emacs to use 'php-mode' Meta-Q to format the comments.

<?php 
$str = "example";
>
<style<
body {
  /* 
   * To format this comment block:
   * 1. Move the cursor to this line 
   * 2. Meta-X php-mode
   * 3. Meta-Q 
   *
   */
  margin:0;
  padding:0;
}

Summary:

Labels: , , , , ,

Thursday, February 12, 2009

 

How to Mount a Remote SSH Filesystem using sshfs

http://ubuntu.wordpress.com/2005/10/28/how-to-mount-a-remote-ssh-filesystem-using-sshfs/

Ran across this bit in the Ubuntu Wordpress Blog: How to Mount a Remote SSH Filesystem using sshfs

The sshfs can be used to mount and unmount remote file systems in user space over an SSH tunnel.

The sshfs program was not installed by default.

This program (sshfs) is relate to the FUSE user-space file system architecture.

  1. create /media/<MOUNTPOINTNAME>
  2. chown the newly created directory to belong to the current user
  3. issue 'sshfs user@host:/path /media/<MOUNTPOINTNAME>' to mount the remote filesystem

Labels: , , , ,

 

Adding to the Perl Include Path

[this is from the Perl Module Installer documentation supplied with cPanel and CenOS]

Suppose you need to add a path - say /home/earthsid/perl - to the Perl include path. You will need to modify the Perl code to set the INC path in the BEGIN block of the program.

You can do this by adding the following code to your script:

BEGIN {
    my $homedir = ( getpwuid($>) )[7];
    my @user_include;
    foreach my $path (@INC) {
        if ( -d $homedir . '/perl' . $path ) {
            push @user_include, $homedir . '/perl' . $path;
        }
    }
    unshift @INC, @user_include;
}

Note that - no matter where the BEGIN block resides in a program, it is always excuted first, before ay other part of hte script lib.

Labels: , ,

 

Installing OpenSuSE 11.1 over the Internet

You will need to know these to get the NET install started...

Net Install Parameters:
  Protocol: HTTP
  Host: www.gtlib.gatech.edu
  Path: pub/opensuse/distribution/11.1/repo/oss/

Net Install CD:
  http://www.gtlib.gatech.edu/pub/opensuse/distribution/11.1/iso/openSUSE-11.1-NET-i586.iso

ISO Directory:
  http://www.gtlib.gatech.edu/pub/opensuse/distribution/11.1/iso/

Furthermore, you may need to install these lines into your /etc/hosts file:

## added to solve un-explained "Couldn't resolve host..." error
## while installing OpenSuSE 11.1 (NET) - these lines provide the
## hostname->to->ip address mappings for the OpenSuSE mirrors; 
## NOTE:  These addresses should be checked and updated before use!  
## These is just what the 'host' command returned today...
##     -pdwilso(at)gmail.com
128.8.235.18    mirror.umoss.org
134.174.150.123 mirrors.med.harvard.edu
149.20.20.135   .kernel.org
64.50.236.216   suse.mirrors.tds.net
204.152.186.174 opensuse.ca.unixheads.org
64.50.238.52    ftp.osuosl.org
64.50.236.52    ftp.osuosl.org
146.137.96.15   mirror.anl.gov
146.137.96.7    mirror.anl.gov
198.60.22.13    mirrors.xmission.com
146.6.54.21     ftp.utexas.edu
72.3.128.167    mirror.rackspace.com
155.98.64.86    opensuse.cs.utah.edu
129.21.2.111    mirrors.rit.edu
64.90.181.77    mirror.nyi.net
80.237.136.138  ftp.hosteurope.de
156.56.247.193  ftp.ussg.iu.edu

Hosts file: uploads/opensuse-mirror-hosts-20090212.txt

An odd aspect of the DNS name resolution problem: For some reason, Konqueror could not resolve host names, but 'host' could.

Finally, here is a script that I used to create the hosts listing:

#!/bin/sh
host $1 | perl -e 'while(<>){\
  chomp;m/([a-z.]+) has address ([0-9.]+)/ && print"$2\t$1\n";\
}'

This script is used like:

  getip.sh mirror1.kernel.org

and returns

  <IP-Address>\t<Hostname>

If you've got root, the output of getip.sh can be used thus:

  getip.sh mirror1.kernel.org >> /etc/hosts

Of course there are other ways to do this. Of course you should check the output of getip.sh before appending it to /etc/hosts.

Caveat emptor. YMMV. Don't take any wooden nickels.

Labels: , , , , , ,

Archives

2006/12   2007/01   2007/05   2007/06   2007/07   2007/08   2007/10   2008/01   2008/02   2008/03   2008/05   2008/11   2008/12   2009/01   2009/02   2009/03   2009/04   2009/05   2009/07   2009/09   2009/10   2009/11   2009/12   2010/01  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]