Gypsy Vials

//Verse
I’m a little destructive
my walls are closing in;
I’m beginning to lose perspective,
Is it worth the pain again?

//Verse
How many times must we argue
circular contradictions-
trying to harmonize the dichotomy
of your logic and emotions.

//Chorus 1
This searing pain evokes the rain
that fills the gypsy vials;
This heart of mine – beats in time –
reflecting on these trials.

//Verse
The centerpiece for this ‘game’
comes at a steep price.
Is it worth the pain again
to come in second twice?

//Chorus 1
This searing pain evokes the rain
that fills the gypsy vials;
This heart of mine – beats in time –
reflecting on these trials.

//Chorus 2
This searing pain evokes the rain
that flows from my sorrow
This heart of mine – beats in time –
pumping blood in those gypsy vials.

//Bridge
I just wish you could see
that you don’t have to settle
for anything less than perfect.
But your eyes are blinded
by the veil of illusion
telling you, “You can’t do better.”

//Chorus 1
This searing pain evokes the rain
that fills the gypsy vials;
This heart of mine – beats in time –
reflecting on these trials.

//Chorus 2
This searing pain evokes the rain
that flows from my sorrow
This heart of mine – beats in time –
pumping blood in those gypsy vials.

Copyright(c) 2011. digitalVectorz.

Wiki Tables

So I found the need / desire to place tables side by side in https://wiki.ubuntu.com/BeginnersTeam/FocusGroups/Development/Joining.

I successfully got the tables working how I wanted them, however I noticed a few issues.  The first issue is that the tables aren’t maintained when you break them across lines by the ‘||’ tag.  i.e.

||<tablestyle...>||Something||SomethingElse||

does not parse the same as

||<tablestyle...>
||Something
||SomethingElse

But that’s understandable, given how parsing engines work.. And the only time this becomes a hassle is when you want two or three or even four tables side by side, you have to write them as one large table which tends to take up several lines for one row of tabular data.

But one idea I propose is to create a shortcut for <style=”border:none”>.  Similar to how:  <#000000> is a shortcut for <style=”background:#000000;”>  and how <50%>  is a shortcut for <width:”50%”>  which is a shortcut for <style=”width:50%;”>.

That would make it a little easier and a little clutter than seeing a line such as:

||<style="border:none">||<style="border:none">||<style="border:none">|| dataHere || DataHere ||

And make it something more like:

||<nb>||<nb>||<nb>|| dataHere || DataHere ||

where <nb> = no border.

Another idea would be for the tables to actually be floated next to each other…but in the few attempts I had with the floating, it didn’t seem to work.  So if that does work, then I just may have overlooked something.  Hrm.

Food for thought. Tis all.

Bash/Shell Programming – Binary Operator Expected

So if you ever decide to get into shell scripting, it’s a wonderful world.  Until you run into snags that you once thought you had the hang of.  Let’s take shell conditionals, for example.

So i’m trying to test the output of grep and do something if it returns a result.  After setting it up the usual way:

if [ -n `ls | grep something' ]; then
echo "Something Exists";
fi

But by doing it that way, I kept getting the error:
./scnotify.sh: line 3: [: 2841.c: binary operator expected
which for the life of me I couldn’t figure out. Eventually I figured it out though…and all that the error was, was instead of a single ‘[‘ and ‘]’ wrapping the comparison, it requires a double…i.e.

if [[ -n `ls | grep something` ]]; then
echo "Success";
fi

Hope this saves someone some headache in the future.

Determining WHICH *nix distro is currently used…

–Edit.
Originally, I had run into the issue of trying to determine the *nix distribution – a command that would tell me the distribution and the build and everythign else I wanted to know. After reviewing some of the awesome comments left behind, here’s the updated perl script to determine the distribution (in Perl).

#!/usr/bin/env perl
use strict;
use warnings;

my ( $distro );
$distro = `lsb_release -i -s`;
chomp $distro;

my %installCmd = (
"Fedora" => \&fedora,
"Ubuntu" => \&ubuntu,
);

&test();

sub test {
if ( exists $installCmd{$distro} ) {
$installCmd{$distro}->();
} else {
print "Supported Distributions are: ". join(', ' , keys %installCmd) . ".\n";
exit;
}
}

sub fedora { print "Hello from the Fedora Family!"; }
sub ubuntu { print "Hello from UBUNTU!!!"; }

sqlite, sqlite3, and CPAN equivalents in Ubuntu and Fedora

So I ran into an issue today, while working trying to port a program from Ubuntu to Fedora, involving Sqlite and Sqlite3 and CPAN.

sqlite (2.8)

Ubuntu:    sudo apt-get install sqlite
Fedora:    su -c 'yum install sqlite2'

sqlite3 (3.0+)

Ubuntu:    sudo apt-get install sqlite3
Fedora:    su -c 'yum install sqlite'

CPAN

Ubuntu:    Installed by default
Fedora:    su -c 'yum install perl-CPAN'

Resize / reposition divs and and background based on window size

One problem that I’ve run into is positioning/sizing divs on a background, with the following caveat:  when the window is resized, the background is resized…however, the divs don’t adjust accordingly.  Well here’s how to accomplish that.

First let’s create our HTML file.

<html>
  <head>
    <link rel="stylesheet" href="ourStyle.css" type="text/css" media="screen"/>
  </head>
  <body>
    <div id="page-background">
      <img src="ourBackground.png" id="bgimg" alt="Our Background"/>
    </div>

    <div id="contentBlock1">
      Some content goes here
    </div>
  </body>
</html>

ourStyle.css

html, body {height:100%; margin:0; padding:0;}
#page-background { /* sets background to full width and height of browser window */
 position:fixed;
 top:0;
 left:0;
 width:100%;
 height:100%;
 }
#contentBlock1 {
 position:relative;
 top: 51.42%;   /* use percentages for the top,left to maintain the top-left corner at the same */
 left: 48.66%;  /* relative position on the background */
 width: 26.69%;    /* use % for width,height to scale the div block according to the window */
 height: 23.57%;   /* width and height */
 background: #999999;
 z-index:1;
 padding:10px;
 }

What’s Happening?

Say you have an image that’s 1120 x 700 at 100% view.  Now let’s say you find that you have a part of the background that you want to place a div over, say for a nav bar.  First, open the image in some editing program that will show you the pixels/points that your mouse is hovering over, and find the top-left corner of the space you want to place your nav bar.  That should give you two points:  x1 , y1.

Next, hover your mouse over the bottom-right corner of where your nav bar will be.  This should give you points:  x2 , y2.

So let’s say in my image, my top-left corner is at:  ( 545 , 360 )  and my bottom-left corner: ( 844 , 525 ).

x1 = 545 ,  x2 = 844

y1 = 360 ,  y2 = 525

Now to find the values:

top   = y1  / 700
      = 360 / 700 = 0.5143

left  = x1  / 1120
      = 545 / 1120 = 0.4866

width =  (x2 - x1)  / 1120
      = (844 - 545) / 1120 = 0.2669

height=  (y2 - y1)  / 700
      = (525 - 360) / 700 = 0.2357 

Now, since we’re working in PERCENTAGES, we need to multiply those values by 100.  Thus, our result is:

top: 51.42%;
left: 48.66%;
width: 26.69%;
height: 23.57%;

Which, if we look at ourStyle.css, are the values that were used there.

Hope this finds use for someone.

Until next time,
dVz-