Coredump

Work, play, and everything in-between.

Archive for the ‘howto’ tag

Run X apps on Windows

without comments

At work, I connect to remote servers through SSH. Sometimes, I use Hummingbird Exceed to forward X and xterm sessions to colleagues. Hummingbird is not only proprietary, but also prohibitively expensive, so I use the open source alternative at home: XMing.

In PuTTy, I enable X11 forwarding in the config (Connection > SSH > X11). In /etc/ssh/sshd_config on the remote host, I set up the following:

X11Forwarding yes
X11DisplayOffset 0

and do a service sshd restart. Once Xming is fired up and I’m connected to the remote box, I can issue something like xclock &, and the app gets displayed in my Windows machine:

Written by Ian Dexter

November 3rd, 2008 at 8:56 am

Posted in Play

Tagged with , , , ,

Quick directory switching

with 3 comments

At work, I do a lot of directory traversal: going from one location to another within the whole (global) filesystem structure. So, to conveniently go back to a previous directory, I use pushd and popd, aside from the usual cd:

$ pwd
/home/iandexter
$ pushd /etc/sysconfig
$ pwd
/etc/sysconfig
$ popd
$ pwd
/home/iandexter

You can even echo $DIRSTACK to list the current directories in the stack, and push multiple directories.

Written by Ian Dexter

August 17th, 2007 at 2:07 am

Posted in Play, Work

Tagged with , , , , , ,

Remote desktop through SSH

without comments

I sometimes telecommute. And when I badly need some files on my office desktop, I can connect remotely through the company’s SSH gateway and tunnel RDP to my desktop. Here’s how:

  1. Using PuTTY, create a new session for the SSH gateway.
    PuTTY session
  2. In Connection > SSH > Tunnels, add a new forwarded port: the source can be an arbitrary port number (e.g. 4444) and the destination should be the address of the remote desktop with the port set to tcp/3389 (the RDP port). Make sure the “Local” is selected because we will be forwarding the local port (4444) to the remote desktop’s port (remote.desktop:3389).

    Set tunnel

  3. Connect and log in in the SSH session. (We use one-time RSA SecurID passkeys, so I always keep that nob handy.)
  4. In Windows XP (yes, my notebook is still not free), open up Remote Desktop Connection, add connect to localhost:4444. This should then be forwarded through the SSH session to the remote desktop port 3389.

    Remote desktop connection

  5. You would have to authenticate again, and if all goes well, you’ll be presented with your remote desktop.
    Remote desktop

Steps 1 and 2 above can also be achieved from the command line, using Plink:

C:\> plink -N -L 4444:remote.desktop:3389 user@ssh.server.org

Take note that the SSH gateway must be able to forward tcp/3389. (Setting that up is beyond the scope of this post. ;)) It would have been great if the VNC port (tcp/5900) was set up as well, but unfortunately, only RDP is allowed. So to connect to my Linux box at work, I either use SSH or, in the remote desktop, open up TightVNC. It looks a bit surreal: having a remote desktop within a remote desktop.

Written by Ian Dexter

April 11th, 2007 at 2:34 pm

Posted in Work

Tagged with , ,

Writing a custom init script

with one comment

It’s been a long time since I did a source tar-ball install. But the production servers at work require that applications that are not part of the standard install base (from Kickstart/Jumpstart and VMWare images) should be compiled from source. It was a very refreshing experience. :)

So after going through the usual configure; make; make install invocation, it was time to make sure that the app is persistent at boot. I would have copied an init script from my *nix desktop, but good thing SLES had a baseline script in /etc/init.d/skeleton.

In a nutshell, the steps are:

  1. Define the INIT INFO section, as per the LSB specs.
  2. Fill in the variables.
  3. Use /etc/rc.status and rc_* functions for sanity checks.
  4. Create the basic start, stop and status functions.
  5. Use YAST (System > System Services (Runlevel)) — or, if available, innserv — to enable the startup script.

Below is a script I wrote for Apache:

#!/bin/sh
#
# Author: Ian Dexter R. Marquez
#
# /etc/init.d/httpd
#
### BEGIN INIT INFO
# Provides: httpd
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start the Apache httpd daemon
### END INIT INFO
 
HTTPD=/path/to/apache/2.2.4/bin/httpd
APACHECTL=/path/to/apache/2.2.4/bin/apachectl
PROG=httpd
 
test -x $HTTPD || exit 5
test -s /etc/rc.status && . /etc/rc.status && rc_reset
 
start() {
   echo -n "Starting $PROG: "
   $HTTPD -k start
   rc_status -v
}
 
stop() {
   echo -n "Stopping $PROG: "
   /sbin/killproc $HTTPD
   rc_status -v
}
 
status() {
   echo -n "Checking $PROG: pid "
   /sbin/pidofproc $HTTPD
   rc_status -v
}
 
case "$1" in
   start)
      start
      ;;
   stop)
      stop
      ;;
   restart)
      stop
      start
      rc_status
      ;;
   status)
      status
      ;;
   try-restart|condrestart)
      if test "$1" = "condrestart"; then
         echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
      fi
      $0 status
      if test $? = 0; then
         $0 restart
      else
         rc_reset   # Not running is not a failure.
      fi
      # Remember status and be quiet
      rc_status
      ;;
   graceful|help|configtest|fullstatus)
      $APACHECTL $@
      rc_status
      ;;
   *)
      echo "Usage: $PROG {start|stop|restart|status|graceful|help|configtest|fullstatus}"
      exit 1
esac
rc_exit

References:

Written by Ian Dexter

January 24th, 2007 at 3:27 pm

Posted in Work

Tagged with , , ,

From my ‘digital’ baul: Notes on news writing

without comments

I was rummaging through my backup CDs — yes, I keep those, despite the fact that there’s always FTP. (Torvalds)

A bit of a backgrounder: I used to be an editor for the school publication back in college. In fact, I was with the national secretariat of the College Editors Guild of the Philippines from 1996 to 1998. During my stint with the CEGP, we give journalism training to other student writers. This was a part of my notes on editorial writing. I’ve had notes on other topics: editorial analysis, publication design and features writing. Only, those aren’t in my known backups. But they’re in there somewhere.

I borrowed copiously from Vergel Santos, my dad’s former editor in the now-defunct Today, who gave a particularly refreshing and unconventional talk on writing way back in 1997.

Some notes on news writing

Definition.

  • “History in a hurry.” (Nick Joaquin)
  • Derived, presumably, from the cardinal directions, hence, coming from all sides, everywhere.
  • “Fresh info of something recent; new or strange.” (Webster)

Types.

  • Verbal. Grows out of speeches, interviews, press releases, documents. “Stories you listen to.”
  • Visual. Elements that are concrete, explicit. Involves human struggle, action. Typically sports and police stories. “Stories you can see.”

Structure.

  • Conventional. Inverted pyramid.

    News structure - pyramid

    Most of the time, this still works but is considered passe. It came from when reporters used to call in their stories. (Aside: my dad spent some of his time filing his stories this way.) Sometimes, the transmission gets cut off so it was necessary to put everything important in the first few paragraphs. (Another aside: also, back in the days of literal cut-and-paste, it’s often okay to just cut off the end parts of the columns to fit the copy in the page, hence the publication term, “copyfitting”.) With the advent of fax machines and emails, complete stories can reach the desk on the fly and intact. Another reason why this is considered almost obsolete is that it is too mechanical to order the importance of paragraphs in a story — it goes against the natural flow of thought.

  • New. “Hour glass” configuration.

    News structure - hour glass

    This is more flexible and solves the problem of natural flow. As always, the lead is at the core of every news story. A reporter cannot cram all the salient facts in the lead to drive the point in, so a lead support is used to back it up. The lead support can consist of as many as two to three paragraphs. Details can then follow, going through the natural motion of the story. Background material can be inserted to prop everything up and add spice to the rest of the article.

    The point is to take care of the important points first: what happened? (lead); why? how? (lead support); what does it mean? what makes it unique? (detail). Write a story as if you’re telling it to a friend, a neighbor or a colleague.

Elements. What makes news news?

  • Immediacy. Something that just happened, is happening, or is about to happen.
  • Proximity. Anything that directly or indirectly affects the audience, their families and friends, neighborhood or community. Not just physical but psychological. Mental as well as linear. How close is it?
  • Consequence. Significance of the story for the readers. What will this bring about? What’s it to me? Closely related to immediacy and proximity.
  • Prominence. Well-known people, events, places (remember Loren Legarda’s PEP Talk?) by virtue of achievements or notoriety.
  • Conflict. The struggle between good and evil is always a central element in every human conflict: the criminal versus the victim; the landlord versus peasants; Lucio Tan and the Estrada regime versus striking PAL workers [NB: The age of this article shows.]; repressive school administration policies versus students.
  • Suspense. Piling up of action to an unpredictable climax.
  • Oddity. Anything strange, rare, unfamiliar, novel.

Lead. The “core” of a news story.

In a lead, facts must be at the maximum, words kept at a minimum. (Fifteen to 20 words standard; one sentence, one paragraph.) More sentences mean more words; more words, more relationships; more relationships, more effort to the reader; a greater chance of misunderstanding by the reader; the sooner he will just quit reading. KISS: keep it short and sweet.

  • Conventional. Summary or capsule lead (5Ws, 1H).
  • Grammatical.
    • Subject - emphasis on individuals, events, places, objects.
    • Phrase - prepositional (to).
    • Clause - conditional (if), causal (because), substantive (what), concessive (although), temporal (after, before).
  • Teasers.
    • Quotation - direct or indirect, often forceful.
    • Allusion - coining a literary phrase, for example.
    • Staccato - build-up of action.
    • Question - posing something to be answered in the succeeding paragraphs, or not at all.

Tips.

  • Use natural language. Be comfortable with the reader: try to establish rapport, but don’t get too chummy — be reserved, not aloof. Use simple words: avoid heavy phraseology — you are writing for the reader, not for your editor nor yourself. Take pains in explaining terms, if jargon is unavoidable. Know the nuances of the language — remember, words are weapons. Mind your grammar, use appropriate tensing.
  • Edit your own work. Cut ruthlessly. Read your story. Then cut some more. (Aside: In the editorial office of the Assumption College’s publication, I read this sign: “Macro-edit, then micro-edit.”) Less verbal fat, more contextual muscle.
  • Establish meaning, context and perspective in your story. These can be inferred from the detail and background aspects. But don’t keep your readers guessing. Get to the point, and quickly.
  • Remember your ABCs: accuracy, brevity and coherence.
  • Attribute. If possible, reveal your source at the onset of the story to establish credibility and authority. Or, for effect, delay the introduction of the source until the later paragraphs. Protects against libel, too.
  • Assume your reader knows nothing of the story. Convince him that it will affect him and everyone around him. Make your story significant. Make it interesting, but don’t dumb it down. Do not put on a condescending tone, “preach to the choir”, nor proselytize.
  • Cover everything. Gather facts conscientiously and present them clearly. Avoid generalizations and speculations — reserve that for opinion writers, pundits and your readers.
  • Take sides. Objectivity comes from the careful presentation of facts — nothing more. Take all sides of the story, but always emphatize with the aggrieved party.

Written by Ian Dexter

September 13th, 2006 at 9:39 pm

Posted in Play, Work

Tagged with , , , ,