JavaScript / PHP – Source Documentor for JavaScript

by drew on January 1, 2009

I’ve begun putting together an idea for a PHP program that will document JavaScript.  In the general sense, it will need to have a good lexical analyzer because it need to understand the syntax and the buildup and creation of the functions and classes.   I’m going to outline some goals that are needed for me to use a program like this.

Requirements

  1. Must be autonomous
  2. Must be able to Add/Edit Comments, without having to directly change the source files
  3. Must contain revision controls
  4. Display of the output must be adaptable easily
  5. Must contain an API to access from “afar”

With those five initial setups, I think I will start to build some thought expirements to figure out exactly what I am talking about.  Should I implement SVN into it?  ScriptDoc formats?  JavaScript engine for analyzing?  Lots of different things.

Come back to this post for more info later.  I’m going to search out other programs that implement some of these things to figure out if there are any.

Help appreciated :)

Saving Battery on your Lenovo X61 in Linux

by drew on December 6, 2008

here are some issues with the power manager in ubuntu and tablet.  There was  alarge discussion you can find here.

But basically to save power and time you should run without atime by following these commands

Make sure you have vim-full installed

sudo apt-get install vim-full

This is a powerful editor, the lite edition is confusing to some, ignore this if you would like to use gedit (think graphical editor) just replace `vi` with `gedit` in the commands

Next,

sudo vi /etc/fstab

Find the line that looks like this,

UUID=65d4f3af-6###-4767-b###-4aa28b61b### / ext3 defaults,errors=remount-ro 0 1

Do not copy my line, your likely to have issues if you do so.

Make the line look like this by pressing `insert` and moving the pointer to the place and typing in the text, hit ‘esc’ and then ‘shift + v’  twice

UUID=65d4f3af-6###-4767-b###-4aa28b61b### / ext3 defaults,errors=remount-ro,noatime 0 1

Restart your system or run this command

        sudo mount -o remount /

Updating Ubuntu to Newest Wacom

by drew on December 6, 2008

Most users of linux need not be concerned with updating Wacom.  But there are many out there that should be.  Namely, those that are using tablets or have a tablet PC.  Wacom is probably the number one driver manager for tablet hardware in linux.  Unfortunately, it’s a driver that too often gets fuddled with and not upgraded.

You can check your current version by running this command in a terminal (Applications->Accessories->Terminal)

dpkg -p wacom-tools  | grep Version

You should get an output of something like this

Version 1:08.1.4-0ubuntu3

If that has 08.2 instead of 08.1.##, then you can disregard updating (Understand that this post is from Dec 08, a new version can be found here when they come out).

To solve this, you should always keep your wacom updated to the newest version.  As with this post, the newest version is 0.8.2 (The Linux Wacom Project).  Intrepid Ibex, the current release of Ubuntu, ships with .8.1-4.  .8.2 adds some new features, like better touch support.  Users with an X61T like me would LOVE to have this back after frying Vista.

First thing you should do it download the newest version here – 0.8.2

**This is a pre-built binary.  If this doesn’t work for you, you should read below.

Download the file to your Desktop and unpack it using the archive manager. You can delete these files when your finished.

Run these commands

cd Desktop/linuxwacom-0.8.1-6/prebuilt
sudo ./uninstall
sudo ./install

The last step is to press ‘ctrl + alt + backspace’ to restart your X11.  This will log you out of X11, so make sure to save anything you have open.

For those users that are unable to follow these steps because of errors. You may need to compile the drivers on your own.  You can find out the information on how to do that here.

Enjoy!

Inspiring the Future: a look on Life as we will know it.

by drew on June 27, 2008

After reading up on the latest news with water vapor being found in on mars (NYTIMES), I began to see a future grow literally from the soils of the martian surface.  Interesting enough, if, and when asparagus begins to grow on the red planet, life will grow here on Earth in a much more dramatic way.  Think about the past, as all our secrets tends to point to the past.  Man’s achievement can be signified with simple advances in the time it takes to get from Point A to Point B.  At some point, we crawl. Then we Walk.  Then we Run.  Ride. Float. Drive. Fly. Orbit. Where does it end?  Well, an astute person would say that is impossible to know, but we can judge one thing.  The next step in this chain is sub-solar system traveling from one planet to the next.  All starting from one lonely planet in the deserts of the abyss.  

Imagine if you could, a plant growing some many million miles away.  Soon, it will be two plants. Four, 20, etc.  Soon there will be a forest.  Which will then provide oxygen, and air as we know it.  By now we would have started sending teams of scientists away for years to do their work.  Radio’s and Satellites will begin to appear on the surface.  Children of our Kids will watch the first families begin to leave Earth on SpaceShip101-’The Ark’.  After a few generations, the first child will be born on Mars.  Later, a School.  The children will be instant celebrities, yet human… and martian.  50 years later, there will be thousands living in the soils of our newest Planet.   A government will appear, whose will it be?  Peace on Earth?  Eventually, Martians will have their own governments, maybe they will revolt? But following our steps, in just a handful of generations, chances are we will see our next step in going from Point A to Point B to get much faster, and distance much smaller.  Those partaking in the journey more than once will begin to get a better understanding on distances, and they will adapt to think of the traveling as ‘nothing really’.  Putting platforms into orbit around the two planets will set up ‘OrbitWays’ for less expensive, more convenient, and possibly faster travel.  Eventually Point A to Point B will become fast, in relative terms, one Earth week?  All starting at one lonely robot, planting one lonely asparagus on one desolate place.  We live in exciting times, the future is upon us.

Server Accessible Locally, Not from the Internet

by drew on May 22, 2008

You can learn something everyday it seems.

Yesterday, I had some issues that I hadn’t planned on ever occurring with my local development server. Basically, the issue was discovered when my server suddenly did not have ANY access from the internet. Now, it DID have access to the internet, oddly enough, and I could reach it via hostname through my local network. The first issue I figured it would have been was a router problem. Namely port forwarding was getting messed up. My server is set statically on my network, so the port forwarding should be fine, and Remote Desktop to my XP machine works fine from the outside world. So the router is NOT the issue. Next step was DNS. Maybe my dns is messed up? I checked out my /etc/resolv.conf

> vi /etc/resolv.conf

nameserver 192.168.1.149
nameserver ###.###.###.###

I blocked out the ### because this is uneeded information about my ISP. Normally you want your name servers to be a nameserver, or your access to a name server. The first shows my router, from the inner network, which is what can be here. This explains why my hostname works via my network. But it is not the solution to my issue. So I dugg a bit deeper. What was that I said earlier? Ah yes, my server has a STATIC ip. Which means I should have a static route.

> ip route

192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.129
default via 192.168.1.1 dev eth0 metric 100

OK! There is my issue! My static route is pointing by default to 192.168.1.1 which is NOT my router (192.168.1.149). So a quick update to that and that should fix it!

> vi /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.129
netmask 255.255.255.0
network 192.168.1.0
gateway 192.168.1.149

I edited the line in bold. This was 192.168.1.1 and now it is 192.168.1.149

> /etc/init.d/networking restart

Now the networking is reset!

> ip route
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.129
default via 192.168.1.149 dev eth0 metric 100
default via 192.168.1.1 dev eth0 metric 100

And Wa-Laa! All done. Now I can access my server via the internet from anywhere as it should be always.

Lesson learned I guess. Hope this helps some others stump issues they are having with static networking on linux.

How To Fix: InnoDB has been disabled for this MySQL server.

by drew on May 21, 2008

I was in the middle of installing program that I have been working on and I encountered a very peculiar error, but I was able to eventually get the answer. Not many people have been able to come to the conclusions that I have come to, so this, I am sure, will help a few out there.

I went to add some InnoDB tables and was returned with the error :

“InnoDB has been disabled for this MySQL server.”

I was running Ubuntu Gutsy with my MySQL installed via apt-get install mysql-server-5.0.

Now, most places on the internet keep telling me that I have to uncomment out the line ‘skip-innodb’ from my /etc/mysql/my.cnf file. This file is also known as my.ini file on some other *nix distributions. I am running mysql 5.0 SO this is ALREADY uncommented.

After 3 apt-get -f –purge remove mysql-server-5.0 and and upgrade to Ubuntu Hardy, I recovered the answer. You see, InnoDB is very touchy. If it isn’t told what is going on , it just doesn’t start. It will usually throw NO error upon this issue. I’m not an expert as to why it does this, but that seems to be the case. I found that there are files in the /var/lib/mysql folder that were getting pointed to in some tutorials on MySQL.com. These files were the ibdata1 and the ib_logfile0 files. The program is outputting it’s logs to these files. Now, if InnoDB is supposed to be working, but it’s not, and these files are being pointed at by MyISAM… my understanding is there could be an issue with how the files were created. I did this as root (use sudo in front of each command otherwise)..

>cd /var/lib/mysql

>cp ibdata1 ibdata1.bak

>cp ib_logfile0 ib_logfile.bak

I was just backing them up in case of a misshap. Then I had some fun…

>rm ibdata1 ib_logfile0

After that I ran..

>/etc/init.d/mysql restart

And now my InnoDB options are running. The files have been recreated and it solved and fixed the day :)

First Looks: Yahoo! Search Monkey

by drew on May 12, 2008

So the other day I was invited to try out Yahoo! Search Monkey.  If you haven’t heard yet, the Yahoo! Develepors Team is looking to set Yahoo! at the cutting edge of the current level of Internet Develepment.  They have realeased a preview (think private beta) testing of SearchMonkey which is the first step to making Yahoo! entirely Web 3.0 (buzzword: sharing social information accross websites, using the internet as a development platform itself).

After loggin in you are given three categories to get started with.  Presentation Applications, Custom Data Services, and Data Feeds.  The first is pretty much defining what you want th individual to see when they run a search using your application.  You can pull from up to 10 URL’s after defining what information you are looking to grab.  The second, Custom Data Services, is where you are able to construct your own search engine’ish data path.  You can strip data from pages themselves (think wikipedia) or grab from an API (think facebook).  The last is mainly used for grabbing from RSS feeds and the like.

More to come as I get developing.  I will keep you up to date!

Creating the Ultimate Mobile Developer Computer: Lenovo X61

by drew on January 1, 2008

As a developer, I long for two things that rarely ever come together well. This Christmas, I have been able to do just that, and I love it! I am always on the lookout for something that will give me the power of a desktop, but the mobility and function of a tablet computer. Three years ago I had bought a Toshiba m205, which some may know, was one of the first tablet computers to really make a mark on the market. I really enjoyed it, as it was very nice, but it was quickly outdone by the market. It really couldn’t run Vista, and XP Tablet version has never been developed enough to get the full potential from a tablet computer.

IBM has outdone themselves with the x61. The x61 came out about a half a year ago, and this Christmas they had a one week deal that dropped the price down by nearly 50% of the overall Cost. I jumped at the prospect, even though I had decided to wait another 6 months to replace my aging Toshiba. Let me Introduce you to my new computer.

Lenovo X61

  • Dual Core Centrino Pro 1.8Ghz with 4Mb Cache
  • 3Gb 533Mhz DDRII Ram (Max 4Gb)
  • 100Gb 7200rpm Hard Drive with 1Gb Cache for speed boost
  • Multi-Touch Monitor (Touchscreen and Stylus)
  • Multi-View Monitor (Indoor and Outdoor – full sunlight does not affect viewing enjoyment. ** Max resolution is only 1024 x 768)
  • Tablet Mode (monitor swings around and lays flat)
  • Vista Business
  • Intel 965 Integrated Video with 128Mb dedicated memory
  • 3 usb 2.0, Gigabit Lan, Wifi A/B/G/N, SD reader, PCMCIA slot, 1394 Firewire, VGA out, onboard Mic.
  • 4-Cell Battery (8-Cell available) @ 2.5 hours of power

So as you can see, this thing flies! It’s a tablet computer that weighs a mere 3.77 lbs with the battery in.

Now to the good stuff, what this is intended to do.

First thing I did was install VMware Workstation 6. This is a virtualization software that will allow me to do what’s next in the list.

Next I downloaded Ubuntu Gutsy 7.10 in live cd Iso format. Then mounted the ISO as a virtual CD drive. Fired up VMware and created a new virtual computer, which was subsequently loaded with Ubuntu.

While in Ubuntu, I then installed Quanta+, Apache, PHP5.2, MySql5, RapidSVN.

Quanta has quickly become my chosen editor when it comes to developing. It’s fast, sublime, pretty and full of features, including auto finishing words you are typing based on a history of the words you have typed. The rest of the LAMP install is too long and also reproduced many times over (check out the forums on http://forums.ubuntu.com for more details if you are interested in this) to repeat here for the 10 Millionth time.

While VMWare is running the Ubuntu machine, that I dedicated 512Mb Ram to, I started network installing Microsoft Office. I really really enjoy using OneNote, which is one of the greatest Tablet Tools that is out there.

After that was all said an done, I know have a mobile computer that packs a serious punch. I am running Vista using OneNote to take notes, Internet Explorer 7, Firefox, Safari and Opera to test web pages, virtualized Ubuntu Gutsy running my editor and Webserver, so no matter where I happen to be, I can easily program and test via a single powerful machine.

Such an amazing combination, I am sure many of you also would consider the same.

How To: Converting PDF to Word and HTML

by drew on December 23, 2007

Sites need to be able to interact in one single, universal space.

-Tim Berners-Lee

I started this little project because I have a client whom needs to get his 24 page PDF online. The problem is that a 24 page PDF with all the bells and whistles

ends up being over 5mb in size. This causes issues for people running sub-cable internet connections, as the loading time becomes horrendous. So to solve the problem, I am going to run the PDF as a download by choice and have all the links point to the HTML(Hyper-Text Markup Language: what webpages are written in) converted page when they click on what page they want to see. This does however cause problems if something is updated on the PDF, the HTML is not dynamic or binded to the PDF so and update will p align=”left”> have to occur in both places. The only way around that is to have the HTML being the origionating source and have the ‘download as pdf’ link be a call to a server side script that packages the HTML as a PDF. That however is too much for what this client needs and the issues with the updating will have to be taken in stride.

Tools Needed:
RTF or DOC reader (I prefer OpenOffice2.2) that can convert to HTML
A Program designed to convert PDF to DOC format (I used Able2dDoc, licensed)

Unfortunately, In my case, the PDF contained a large amount of tables that were made up by images after conversion. Because of this, I had to handle things a little bit different, in which I will explain later.


First things first, lets convert to HTML

Using the software I used, Able2Doc, if you load up the PDF you can simply convert the file to a DOC format. Notice, not many converters will go straight from PDF to DOC or RTF formats. Once you are able to convert the PDF to DOC or RTF, you can then open up that file into Microsoft Office or Open Office. Both have the ability to Open up these files and then Export them as HTML.

Microsoft Offices’ way of doing things

Office is really simple. Take the document you are in and go to File->Save As->Other

PDF to HTML Save as

Then after that you can go click and change the type to an HTML Document… put in the name and your done!

PDF to HTML Save as HTML

Open Offices’ way of doing things
In Open Office, it is actually easier! Just have your document open and then go to File ->Save As and you can then select the HTML from the drop down list. No extra step as there is in Word.

 

 

PDF to HTML OO


When things get messy…
You have to start to get creative. I know, it stinks, when things just don’t go your way. I mentioned earlier that I my specific issue just could not be settled by this process only because the images in the PDF were making up the tables and the text did not stick inside the image/tables when changed to HTML. I ended having to go with a slightly altered reality, but the end result to the user is near the same.

The idea that I had was to split the PDF into images. This was actually really easy to do. I swapped over to linux for this part (Ubuntu Gutsy). The PDF Reader program has the ability to output to JPG for your PDF’s. This came in very handy, I simply outputted the PDF I was using, 28 pages of it, as JPG’s and then used to Javascript to make a nice little setup for Checking out the picutres.

Javascript Code In the <body> tags :
<script> function PageQuery(q) {if(q.length > 1) this.q = q.substring(1, q.length);else this.q = null;
this.keyValuePairs = new Array();
if(q) {
for(var i=0; i < this.q.split(“&”).length; i++) {
this.keyValuePairs[i] = this.q.split(“&”)[i];
}
}
this.getKeyValuePairs = function() { return this.keyValuePairs; }
this.getValue = function(s) {
for(var j=0; j < this.keyValuePairs.length; j++) {
if(this.keyValuePairs[j].split(“=”)[0] == s)
return this.keyValuePairs[j].split(“=”)[1];
}
return false;
}
this.getParameters = function() {
var a = new Array(this.getLength());
for(var j=0; j < this.keyValuePairs.length; j++) {
a[j] = this.keyValuePairs[j].split(“=”)[0];
}
return a;
}
this.getLength = function() { return this.keyValuePairs.length; }
}
function queryString(key){
var page = new PageQuery(window.location.search);
return unescape(page.getValue(key));
}
function displayItem(key){
if(queryString(key)==’false’)
{
return ’1′;
}else{
return queryString(key);
}
}
</script>

What else?

Once this code is in place, you can see what it is trying to do. You are basically parsing a query address URL and looking for the specific information showing on whatever variable you pass in. This is giving your JavaScript the ability to know what a variable is from a JavaScript /PHP equivalent to the Get variables.

Now you need the code that will change values of a select box, so the complete picture will come into view.

The idea that I had was to split the PDF into images. This was actually really easy to do. I swapped over to Linux for this part (Ubuntu Gutsy). The PDF Reader program has the ability to output to JPG for your PDF’s. This came in very handy, I simply outputted the PDF I was using, 28 pages of it, as JPG’s and then used to JavaScript to make a nice little setup for Checking out the pictures.

<SCRIPT LANGUAGE=”JavaScript”>
 function loadPage(value) {
if(value == “”) {
 document.getElementById(‘mainimage’).src=”img/ProductCatalog/Page1.jpg”;
 } else {
 document.getElementById(‘mainimage’).src=”img/ProductCatalog/Page” + displayItem(‘p’) +”.jpg”;
 }
 }
 function changeImage()
{
 document.getElementById(‘mainimage’).src = document.getElementById(‘list’).options[document.getElementById('list').selectedIndex].value;
 }
function prevImage()
 {
 if(document.getElementById(‘list’).selectedIndex == 0)
 {
 document.getElementById(‘list’).selectedIndex = document.getElementById(‘list’).options.length-1;
 }
 else
 {
 document.getElementById(‘list’).selectedIndex–;
 }
 changeImage();
 }
function nextImage()
 {
 if(document.getElementById(‘list’).selectedIndex == document.getElementById(‘list’).options.length-1)
 {
 document.getElementById(‘list’).selectedIndex = 0;
 }
 else
 {
 document.getElementById(‘list’).selectedIndex++;
 }
 changeImage();
}
</script>

That was pretty much what the JavaScript needed, and then I could handle everything else from HTML which made things much easier. All that is said and done, any Q’s just ask.

Introduction: From Me

by drew on December 11, 2007

I do not fear computers. I fear the lack of them

- Isaac Asimov

I’m a computer guy.  I grew up thinking they were cool, and now I have come to appreciate them more, because they are a source of income now.  I do web design, development, server stuff, troubleshooting things, etc.  Because of this, I run into a lot of problems that have to be solved.  But, more often then not, I find that I have to solve them on my own, without GOOG’s help.  So I have decided to turn to the internet, to pass on my information as I get it.  Hopefully it will help out more out there… and they can in turn help me with issues I may have.

Enjoy

Drew