All those who wander are not lost.

Tag: code

Share Delicious Library

(with simple HTML)

For anyone interested in sharing the library with friends, here are some tips. For the purpose of this explanation I am going to assume that you have a web server on your machine and that you server root directory is at /Library/WebServer/Documents.

1 – Copy your library file, Library Media Data.xml, from ~/Library/Application Support/Delicious Library/ to the root directory of you web server. I recommend renaming it to something without spaces, such as mylibrary.xml. 2 – Copy the directory ~/Library/Application Support/Delicious Library/Images/Small Covers to the root of your web server. 3 – Edit the file mylibrary.xml (if that is the name you gave it) and add the line:

<?xml-stylesheet type="text/xsl" href="delicious-library.xsl"?>

after then line that reads:

<?xml version="1.0" encoding="utf-8"?>

4 – Create a new file called delicious-library.xsl in the root folder of your web server and add the following text:


  ]>








.oddRow {
background-color: #ffffff;
}

.evenRow {
background-color: #eeeeff;
}








Books

oddRow evenRow
Small Covers/   
Author:
Publisher:
Series:
Volume:

Books

oddRow evenRow

Movies

Small Covers/   
Author:
Publisher:
Series:
Volume:
oddRow evenRow
Small Covers/   
Author:
Publisher:
Series:
Volume:

5 – Now from you web server, if it is running on the same machine:

http://localhost/mylibrary.xml

If your web server is not your local computer, then you will simply have to modify the steps with uploading instead of copying. Always be sure to modify a copy of your files, and not the originals. You don’t want to get burnt if you make a mistake

Run MultiMarkdown in Terminal

I found this script. I think I could substitute the PHP version of MultiMarkdown here.



#!/bin/bash

#******************************************#
# This script runs the multimarkdown       #
# script on specified file, redirects      #
# output to html file, and opens resulting #
# file in web browser.                     #
#******************************************#

# gets complete filename of file 
srcfile="`eval echo $1`"    

# gets the filename without .txt
FILENOEXTENSION="`echo $srcfile | sed -e 's/\..*$//'`"  

# Runs perl script and creates .html file
~/MultiMarkdown/bin/multimarkdown2XHTML.pl $srcfile > $FILENOEXTENSION.html 

# opens it up
firefox $FILENOEXTENSION.html


Convert HTML to text

I forgot from where I copied this script:

#!/bin/bash
# Usage: convert-html-to-md <path-to-html2text.py> <file>[...]
# Convert the specified HTML files into Markdown text-format equivalents
# in the current working directory. The file extension will be .md.txt.
# Requires the html2text.py Python script by Aaron Swartz to convert
# from HTML to Markdown text [www.aaronsw.com/2002/html2text/].
# html2text="${1}"shift

[while [ -n “${1}” ] ; do

Use the contents of the title element for the filename. In case

 # the title element spans multiple lines, the entire file is first
 # converted to a single line before the sed pattern is applied. Any
 # "unsafe" characters are then replaced with hyphens to produce a
 # valid filename.
 title=$(cat "${1}" | \
        tr -d '\n\r' | \
        sed -nre 's/^.*
(.*?).*$/\1\n/ip’ | \ tr “\`~\!@#$%^&*()+={}|[]\\:;\”\’?,/ \t” ‘[-*]’) # If there’s no title, then just use the original filename. if [ -z “${title}” ] ; then title=$(basename “${1}” .html) fi # Convert the HTML to Markdown. cat “${1}” | python “${html2text}” > “${title}.md.txt” shift done]

Subversion Notes

Here’s what a checkout request on the command line looks like:

$ svn checkout http://svn.example.com/repos/calc
A calc/Makefile 
A calc/integer.c 
A calc/button.c 
Checked out revision 56.

SSH Problems

Planet Argon, ssh, authorized_keys, and TextMate happiness

Been trying to get ssh-based password-free login going at Planet Argon (more on the transfer from DreamNightmareHost to Planet Argon in a future post). A couple of back-and-forths with the admins over there. Both they and this thread insist that ~/.ssh/authorized_keys needs to be chmoded to 600. This isn’t right. It only needs 644.

But what the above thread pointed me to is that ~/ needs to be chmoded to 750. Voila! Now I can use Subversion, directly inside the best text editor on the Mac.

Let’s just hope there aren’t any groups that need to write to my home directory.

Problems

Toulouse:~ jjl$ ssh -v
OpenSSH_4.5p1, OpenSSL 0.9.7l 28 Sep 2006
usage: ssh [-1246AaCfgkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]
       [-D [bind_address:]port] [-e escape_char] [-F configfile]
       [-i identity_file] [-L [bind_address:]port:host:hostport]
       [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
       [-R [bind_address:]port:host:hostport] [-S ctl_path]
       [-w local_tun[:remote_tun]] [user@]hostname [command]

Following Allan’s Advice

Your identification has been saved in /Users/jjl/.ssh/id_dsa. Your public key has been saved in /Users/jjl/.ssh/id_dsa.pub. The key fingerprint is:

Shakespeare was the pass-phrase used.

MacFusion

Set up on 2007-04-28. Used SSH (which has the wild woman password by the way). Mounted like a charm. Now, let’s see what’s in there and how well this works.

SVN Checkout

If you are using bash you should put this in your ~/.bash_profile (or a similar file which gets sourced when you open a terminal):

export LC_CTYPE=en_US.UTF-8

© John Laudun