Twitter Updates

Sunday, 31 January 2010

SASS with Sinatra

Have started looking onto how to use use stylesheets with Sinatra. The easiest way way is to have a top level folder called Public with your main.css file.

This can be referenced from all pages as
< h t m l>
< h e a d>
< t i t l e> example < / t i t l e>
< l i n k href="/main.css" rel="stylesheet" type="text/css" />
< / h e a d>

Standard stylesheets have no have variables, they say they do but I could not get them to work. So I have started to look at compass which is a framwork for CSS! it based on haml which is another templating language like erb.

The Main Compass page. Integrating it with Sinatra.

Also see github for a basic example of using Sinatra and Compass.

Example of some SASS:
!cdark =    rgb(145, 129, 107)
!cdarker = rgb(125, 91, 95)
!clight = rgb(141, 189, 168)
!clighter = rgb(23 , 206, 143)

background-color: #{!cdark}

color: #{!clight}

Compass uses SASS and is built on the blueprint layout system.
Blueprint Tutorials.

Saturday, 23 January 2010

Java and Ant setup on Windows XP

Setting up a Windows XP machine for creating/testing java builds. These programs are required:

Java JDK
ant, for more automated builds (like make and rake)
JSmooth, creates .exe from jar files.
Zip Genius, for unpacking the .tar.gz source files.

Download and install the Java SDK.

Download ant, put contnets of .zip in C:/Program Files/ant/
Now go to Control Panel -> System -> Advanced tab and press the set Environment Variables

Create these two new variables

JAVA_HOMEC:\Program Files\Java\jdk1.6.0_18
ANT_HOMEC:\Program Files\ant\apache-ant-1.8.0RC1

Edit Path to include ant bin and java JDK bin,
C:\Program Files\ant\apache-ant-1.8.0RC1\bin;C:\Program Files\Java\jdk1.6.0_18\bin;

JSmooth and zip Genius should download and install like standard windows programs

NB: I Kept getting this error when trying to run ant
> ant
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\li

JAVA_HOME does not point to the bin folder but the folder above 'C:\Program Files\Java\jdk1.6.0_18' quotes not to be included.

VMware Fusion Disk Usage

The disk images for the operating systems are sparse, i.e. they expand as necessary. They unfortunately do not shrink automatically when you delete data.

For a windows image you have to install the VMware tools to shrink the disk.
VMware guide

The VMware Tools are installed by: Start your virtual Operating system -> Move mouse to the top of the screen and select 'Virtual Machine' -> 'Install VMware Tools'

VMware Tools location
C:\Program Files\VMware\VMware Tools\VMwareControlPanel

Thursday, 21 January 2010

Java String Search and Replace

Java by default by default only searches for regular expressions and replaces with strings. The method below allows String search and string replace.

Why is regular expression search an issue ? if search for [ex] it will match 'e' and 'x' but not '[ex]' if you have control over thestring you could excape the special characters with '\[ex\]' but if you are loading from a config file and you know it is plain text then it would be nice if there was a simple search and replace function example supplied below:
public String replaceString(String input, String find, String replace, boolean casesensitive){
String input_case_adjusted = input;
if (casesensitive == false) {
//For Case Insensitive searchs
//Lowercase everything (but replace in the original string)
input_case_adjusted = input.toLowerCase() ;
find = find.toLowerCase() ;

int startPosition = input_case_adjusted.indexOf(find);
String start = "";
String end = "";

if (startPosition >= 0) {
if (startPosition > 0) {
start = input.substring(0, startPosition);
end = input.substring(startPosition + find.length());

return start + replace + end;
} else {
return input;

Sunday, 17 January 2010

Java case insensitive regular search and replace

Java's Search and replace function on strings is:
new_string = old_string.replaceFirst(regularExpresionFind, textReplace);

To make this non-case sensitive / case insenitive:
new_string = old_string.replaceFirst("(?i)" + regularExpresionFind, textReplace);

Saturday, 9 January 2010

Audio File Tag Editor

The best MP3 tag editor I can find is Mp3tag (supports most audio files). The feature that I find most useful is its ability to parse the file name and writing it into the tags and vice versa. Unfortunately it is windows only.

Saturday, 2 January 2010

Happy New Year, Have some Tabs

File Explorer (my souceforge project) now has tabbed browsing and right click open folders in new window or new tab.