Search posterous

Search all posts and users. Type a name, type a favorite song title, whatever! See what comes up.
  

More posterous blogs











More recommended blogs »

Here are posterous posts filed under shell...

Steven says...

The goal here is to set up a local cache to use with TangoGPS or other apps like that. I don't have 3G neither WiMax (and there isn't a great coverage anyway...) so I like to grab my tiles before a trip.

Here is a little bash script which help doing this. You just have to know the coordinates of the first tile you want to get.

Example for the Finistère (France, Brittany)

You get it with a right click on the wanted tile, and "show picture", then you get :

Here this is the path from the URL which we are interested in : 8/124/88.

  • 8 stands for the zoom level.
  • 124 si the x coordinate
  • 88 is the y one.


There is a little algorithm to do a recursive download. I tried to sketch it by a small sample based on Brest Area.

Now you know how to use it, open the dl.sh and modify HOME, MAPHOME and EDITED variables. Execute it with "sh dl.sh args".
To finish, don't abuse on it...  If you need a huge area, or very often the same one,  this will be far better to render by yourself the tiles. For that, have a look to Osmarender ot Mapnik on the OpenStreetMap Wiki.

 

 

Click here to download:
dl.sh (1 KB)

Filed under: shell

Ted says...

For my shell in Terminal, I use Z shell (zsh). After reading Rafe Colburn's blog entry on his zsh adventure, I decided to give it a whirl. (The blog entry on Fried CPU that he links to is also a great read for some additional background.) Z shell shares a similar history with bash, so it has a small learning curve for most users who are comfortable with general command line usage.

Why use Z Shell?

Here are a few of the reasons that I've kept it around:

  • intelligent command completion: zsh was one of the first to implement fully programmable command line completion in the shell. The completion is also handled intelligently for many commands with regard to the context in which the command is being executed — for instance, if the tab key is pressed after typing tar xvf, zsh intelligently only provides a list of tarred gzip files. The completion can also be customized to display the autocompletion results in a multidimensional list that is easily tabbed or arrow keyed through. This goes farther than file and directory names, too, and can include git branches, hostnames, usernames, command arguments, etc. This feature alone is enough reason to switch to zsh, and has lead to a signfinicant increase of productivity (or at least reduced frustration) in my workflow.
  • spelling correction: I make a lot of typos when I'm in the shell for some reason — instead of having to retype (or edit from history) a whole command, a quick prompt, such as zsh: correct 'giy' to 'git' [nyae]? makes life in the shell little bit more convienient.
  • right-hand command prompt: this is one of the more vain reasons to choose a shell, but I like to see the full path of the directory that I'm currently in, without throwing my left-aligned command history out of alignment. For my right-hand command prompt, I have displayed the current git branch (if applicable) as well as the full path to the current directory. If the command in the left-hand prompt starts to bleed over into the right-hand prompt's area, the right-hand prompt disappears to avoid any confusion.

There is a lot more to zsh than just the few features that I've mentioned. I'm fairly confident that I still don't use it as effectively as possible, even after using it exclusively for about 6 months… although I do feel more comfortable than I ever did in bash. (I do still use bash for almost all SSH sessions, though, but that's due mostly to the ubiquity of bash and my laziness.) I've put the .zshrc file (zsh configuration file, in layman's terms) that I use on GitHub, and you can view it here. It's a forked version of Rafe Colburn's, with some additional prompt niceties.

Installing Z Shell on Mac OS X

Installation of zsh on OS X is very easy. To get started, to to Terminal > Preferences and select the Shells open with: setting as "command (complete path)", and type "/bin/zsh" in the text box below. Here's a screenshot of my settings:

Terminal Preferences on OS X for Z Shell

You'll likely want to set up a custom .zshrc file like the one that I linked to above to improve compatibility with the Mac keyboard layout, but even that's not completely necessary (although it's highly recommended).

Filed under: shell

Meera says...

The lover and I went on a photo trail today. We were supposed to hit town but the rain kinda messed our plans up. We drove to a nearby beach instead and it was a disappointment. Not how I remembered the beach to be from the times when I were younger. The waters and the beach were so terribly dirty and littered. My heart actually ached. Played for a little while with my toy cameras and then the clouds came in. There were yachts out and the view on the horizon was quite pretty.This particular photograph makes my fingers curl a little because I don't really like shells with seaweeds coming out of them and they're slimy and barnacled but it's precisely why I'm putting this up as my picture of the day. The experience at the wrecked beach was not perfectly pleasant and I didn't even feel like taking many photographs but this shell, as the lover reminded me, represents nature's beauty. And I like that.

P.S. We also spotted this freaky, creepy, pre-historic looking worm with a hundred little disgusting tentacles. The picture is too gross to put up, so I'm not going to do that. Ugh, it still makes my skin crawl.

Filed under: Shell

topinforma says...

It's easier to take a decision than to excuse yourself in a mental shell --Ivan C--

Filed under: shell

niels says...

A little while ago I was tasked with migrating about hundred Trac instances from SQLite to MySQL. Unfortunately SQLites schema definitions is not compatible with MySQL. So I had to write some scripts to handle it. After a little bit of experimenting everything worked perfectly.

The Strategy I employed was like this:

  1. Make a dump of a default MySQL Trac db schema.
  2. Make a dump of the Trac SQLite database
  3. Remove db schema definitions from the SQLite dump
  4. Concatenate the MySQL and SQLite dumps
  5. Load data into MySQL
  6. Edit Trac's database settings to use MySQL
  7. Do a trac-admin upgrade

Here is the shell script I made:



MYSQL_USER=username
MYSQL_PSWD=password

SQLITECMD=sqlite3
TRACBASE=/path/to/tracreps


# loop through all trac instances in tracreps
for d in $( ls $TRACBASE )
do
if [ -d "$TRACBASE/$d" ]; then
echo $d
TRACNAME=$d

# create database in mysql
echo "creating database for $TRACNAME..."
mysqladmin --user $MYSQL_USER -p$MYSQL_PSWD create $TRACNAME

# dump sqlite db structure + data
echo "dumping data from sqlite..."
$SQLITECMD $TRACBASE/$TRACNAME/db/trac.db .dump > trac.sqlite.sql

# remove database definitions from dump using a custom python script
echo "cleaning database definition from dump..."
`./cleansql.py < trac.sqlite.sql > trac.sqlite.sql.dataonly`

# concatenate mysql database definitions and sqlite data
cat trac.mysql.sql trac.sqlite.sql.dataonly > trac.sql

echo "loading data into mysql..."
mysql --user $MYSQL_USER -p$MYSQL_PSWD --default_character_set utf8 $TRACNAME < trac.sql

# edit database connection string in trac.ini
sed -i "s?sqlite:db/trac.db?mysql://$MYSQL_USER:$MYSQL_PSWD@localhost:3306/$TRACNAME?" $TRACBASE/$TRACNAME/conf/trac.ini

echo "upgrading mysql database..."
trac-admin $TRACBASE/$TRACNAME upgrade --no-backup


To remove schema definitions from the sqlite dump and fix some incompatibilities I made this python script referenced above as cleansql.py:



#!/usr/bin/env python

import sys
import re

file = sys.stdin.read()
file = re.sub(r'(CREATE (TABLE|INDEX)[^;]*|COMMIT|BEGIN TRANSACTION);', '', file)
file = re.sub(r'INSERT INTO "([^"]+)"', lambda m: 'INSERT INTO `%s`' % m.groups(1), file)
# fix sql for reports
file = re.sub(r'CAST\((.+) AS int\)', lambda m: 'CAST(%s AS signed)' % m.groups(1), file)

sys.stdout.write(file)


And that's it. I hope this will benefit someone tasked with the same job.

Filed under: shell

dchoquec says...

Filed under: Shell

Huberific says...

Filed under: shell

McGivrer says...

One of the next best evolution of gnome 3 has a name:  Gnome Shell
It's a great change in the desktop concept. On the same screen, you are able to launch application, find last document, create, delete, select a virtual desktop in an all-in-on full integrated 3D interface.

Welcome in the next generation of the Linux Desktop.

     
Click here to download:
ubuntu-gnome-shell.zip (845 KB)

Filed under: shell

justin says...

1. Create a .sql file using the below template
-- set the output file in the first SPOOL command
-- add your query in between the SPOOL sections

set echo off
set newpage 0
set pagesize 0
set space 0
 set feedback off
set trimspool on
set heading off
set linesize 555
SPOOL /path/to/your/output/file.txt
select ... 'replace this line with your query'  ;
SPOOL OFF
quit

2. Create a simple shell script

#!/bin/bash
sqlplus oracle_user/password @/path/to/your/sql_file.sql

3. chmod the script

 chmod +x oracle_sql.sh

4. Also to get sql*plus working you mayneed to set a few environmental variables

setenv ORACLE_HOME ..
setenv ORACLE_SID ..
setenv ORACLE_OWNER ..
setenv ORACLE_VERSION ..
setenv ORACLE_CONF ..
setenv ORACLE_BASE ..
setenv TNS_PORT ..
setenv ORACLE_ALERT_LOG ..
setenv TEMPORARY_TS TEMP
 setenv TWO_TASK ..
setenv ORA_LIB ..

5. then just add the oracle_sql.sh to your cron

6. done

Filed under: shell

Jonathan says...

From the Book: California Indians

* Californian Indians used a seashell called dentalium, a string of
them were called kaia.

Filed under: shell