Showing posts with label Web. Show all posts
Showing posts with label Web. Show all posts

March 24, 2010

Poking with ajax

I have played with Ajax before and even used it in a few projects, but never in a way that it was obvious.  With the next round of CADY site updates I have finally had a chance to put ajax to some real use. For the upcoming parent network, which is more or less a very simplified forum I am coding from scratch, I needed a simple and easy to use registration page for parents. Setting up a page is easy, making it point out peoples mistakes in a dynamic non refresh ways is not.

It is good HCI practice to limit any screen refreshes to just when locations are actually changing, it is what people expect. Where as if a user submit a form only to have it return and to say you missed something is not as intuitive, because the user has already moved on in their thought process.  This is where javascript and ajax usually come in.  By allowing the page to call remote content you can check form fields on changes and then update the user to missed fields or issues before they submit. You could extend the process and prevent even the submit if things are not correct, however this falls outside my current beliefs on how applications should handle user control.  If the user wants to submit the page with missing items even after being notified, let them, however have it fail the submit on the server side and then bring them back to the restored page with a notice of what they missed.  This forces the user to learn that finishing a form properly the first time is worth not having to remember what they where filling out.

You can check out the CADY Parent Network Registration Page to see my progress and fancy ajax trimmings, however please do not sign up unless you are actually a parent who is interested.

November 30, 2009

Simple HTML Parser in Objective C

For my current project I needed a way to fetch remote html and then parse it into a more accessible data form. So I took my Java XML Parser work and ported it over to Objective C and extended it to work with HTML, which tends to be far more messy and broken... grr. To combat this, unlike a full html parser, this converts it to a psudo xml form, where all character data between > and < and > or /> is appended to the tag string.  The down side to this is that you need to parse out any needed tag attributes separately, but that is a price I am willing to pay in this case.

Check out the files below for the code...
HTMLNode.h
NTMLNode.m


Using the HTMLNode class should be simple enough, just import the HTMLNode.h file and then use the example below to get started. It is good to note that this parser expects clean and valid HTML/XHTML, however most sites have some issue or mistake. This may cause you a few headaches, it did for me. Still the parser should get most if not all the tags, so in this case use the search function "-(HTMLNode*) search:(HTMLNode*) root: (NSString*) term" to find a containing div tag and then use getChildN for traversing the rest.

// Setup and build html node tree in root...
NSString *url = @"http://www.google.com";
HTMLNode *root = [[HTMLNode alloc] init];
[root buildFromURL: url: root];

// Get the head tag which should be root child 0...
HTMLNode *headnode = [root getChildN:0];

// The tag of the head node should be "head"...
NSLog([headnode getTag]);


As usual the code is free to use, but please give me some credit if it is used in a large project, or at least leave a comment about what it was used in.

November 27, 2009

Remote File Request to NSString in Objective C

A current side project in Obj C that I m working on required a way to fetch a remote HTML file and parse through it to get the url of links and images. The first step required a way to get a remote file and store it as a NSString. The code below is an example of how to so.

NSString *url = @"http://www.google.com";
NSURLRequest *urlrequest = [ [NSURLRequest alloc] initWithURL: [NSURL URLWithString:url] ];
NSData *returnData = [ NSURLConnection sendSynchronousRequest:urlrequest returningResponse: nil error: nil ];
NSString *returnstring = [[NSString alloc] initWithData:returnData encoding:NSASCIIStringEncoding];

Tested on OS X 10.5+ with GCC 4.2

October 5, 2009

Online IE Testing

I had stumbled across IE Netrenderer a few weeks ago, it is a site that lets you put a url into the form on the page and will return a picture of how that site looks rendered in different versions of Internet Explorer. For me as a mac owner this is awesome as it allows quick page testing in IE. I have been using Crossover to run both IE6 and IE7 and for the most part works quite well, however Crossover has some issues with occasional things like transparency in IE7 and can not run IE8. So for final tests IE Netrenderer is perfect for the job. As an added bonus it also allows you to do an overlay of IE6 vs IE7 for ironing out these few small differences in site layouts. Check it out for you self, if you are a Mac or Linux user I guarantee this is something you will want to bookmark.

September 30, 2009

Tomcat install on OS X 10.4

I had seen Tomcat on job applications before, however this was the first time I had actually played with it. What is it? "Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies. The Java Servlet and JavaServer Pages specifications are developed under the Java Community Process." So it allows you to run Servlets and JSP on a server. Now I needed to find out how to install it on my Lazurus server running OS X 10.4.11 with the latest Java update.

1. First download tomcat from HERE (I used 5.5, so not sure about 6)

2. Then rename the unarchived tomcat folder to "Tomcat"

3. Drop the folder into /Library/

4. Fix the UNIX permissions recursively to 777 (BatchMod is a simple way if you do not know chmod, just check all of the boxes)

5. Edit the /Library/Tomcat/conf/tomcat-users.xml file, see below for example.


<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<role rolename="admin"/>
<user username="tomcat" password="tomcat" roles="tomcat,admin,manager"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>


6. Start tomcat by using the terminal to run "cd /Library/Tomcat/bin" and then "./startup.sh"

7. In a web browser head to http://127.0.0.1:8080/ and you should see the Tomcat start up page.

If you want to read on further I figured out most of my instructions from the Tomcat Wiki, so head there for more info or if you get stuck.

Just in case you where wondering, as I was, put your jsp and servlet files in the /Library/Tomcat/webaps/ folder. The webaps/ROOT folder being the one displayed at the base url address. So for now I am just using that folder for testing.

JSP is quite simple to pickup at a basic level if you already know Java. However there are a few differences do to it being web based, but so far I like not having to compile manually. I had no problem writing a few simple classes with outputs and will later play with post and get. HAHA, tri-fecto of web programing achieved (PHP, ASP, JSP), hm still need to sit down with Perl one of these days.

August 10, 2009

HTML 5 Canvas

I was almost giddy when I discovered the canvas tag to be included in HTML 5. With this javascript joins the ranks of C, JAVA and VB in the fact that I can quickly and easily draw straight to the window with a few basic APIs. So to have a little fun and to keep my javascript knowledge fresh, I sat down over the last few days and read up on the canvas APIs and played around a little.

(NOTE: IE does not work with canvas by default, use another newer browser!)

First off I started with the basic balls bouncing around program that I did in every other language that can draw. You can check it out here and see the code here.

I had to do a little research on classes in javascript, and while not exactly perfect, they do work as expected. After getting the bouncing shape test working I moved on to make a simple platform game. The hard thing with javascript is that it is slower and far more processor hungry then even java, so I had to be somewhat careful of sloppy waste, however I did not put too much effort into it as this was nothing more then a way to try out the canvas with javascript. You can see the result here and the code here.

All in all I am excited to see javascript starting to show signs of maturing into a really powerful and useful scripting language.

If interested, you can also read more on the canvas tag here.

June 22, 2009

Crunchyland bot

Quite a while back I was having fun working on a javascript exploit bot for an online game called crunchyland, the game itself was rather simple you create a character give it weapons and fight silly monsters that you encounter. The entire game engine was based on flash files that where embedded in html and where linked through javascript. The problem was that I quickly got bored with the game, you click, that is it, not very entertaining past a level or two. However before I moved on, I decided to try to write a bot for it so I could at least get on the leader board. Because there was no way I was going to sit for weeks of clicking, like some of the obsessive kids on the site apparently do. (Get a job!)

It was not too hard a task and gave me a good refresher in javascript dom manipulation. The bot uses an open window and url testing to change and click elements in the window triggered by timers. I also went a step further and had it watch the size of the health bar to heal the player after a certain point. After a week of testing I quickly had my character self level up on my testing server while I did other more productive things, and after a few more days I was on the leader board, with little effort, past the coding, on my part.

I have been waiting a while before releasing it, one to not get kicked of while I was still on the leader board, and to to prevent hoards of script kiddies from also quickly leveling up with no work. Now it looks like the game it not being worked on, and my script does not work completely anymore, so here it is CL Bot (For Safari 3 maybe 4 only). Anyone with some javascript experience could take it further and fix the parts that do not work with the game updates, however I have better things to be doing. Enjoy...

May 9, 2009

Finally bought AwardSpace hosting

With my time at college dwindling fast, I though it was about time that I broke down and bought a domain and hosting. I have been using the schools hosting for almost 4 years and have gotten very use to being able to easily have web project or files online, so with that ability ending I needed to get my own.

I had been using the free hosting on awardspace for a while, which is fantastic for a free service. No adds and access to php and MySQL! But there is limitations on bandwidth and you only get a subdomain, so after I graduate, I will require a bit more then that. Yet, the basic hosting is more then enough for me and only costs 47$ for a year with a free domain. The bandwidth is 1000GiB a month which is around 32GiB a day, way more then I will need right now.

So I am now the proud owner of www.efeion.com!

February 10, 2009

KavaTunes

Matt clued me into an interesting piece of software called KavaTunes last night. He found it on the Mac Heist website as one of their free software titles when you solve puzzles in one of their yearly heists. I was not interested at first, however after watching him for a bit, I quickly wanted a copy as well. What KavaTunes is, is a piece of software that builds a php page of your iTunes library, but to take it a step further, it even looks like your iTunes library! This may be the simplest way to get access to your music on a local network, and on the campus network it is a perfect solution.

Oh course my g4 server is my test bed for playing with things and has a custom apache and php setups, so unlike Matt I had quite a bit of extra trouble with the setup. (With Matt laughing at the issues I was having the whole time ^_^) First off was that KavaTunes always builds in ~/Library/Webserver/Documents/ however I have a custom webserv folder instead, so it took a while to figure out why it was not building in the right place, but a symbolic link fixed that. Then do not call your iTunes music folder iTunes as KavaTunes adds a another separate folder under this name with its required php files. And lastly do not mess up your symbolic links, as it just causes a general mess. After about 30 minutes of bug fixing, which would have been nice if it gave you some warning about these things, I was up and running. It even streams my movies and tv shows I have on iTunes.

If you are interested grab a copy from Mac Heist

October 13, 2008

Fantastic Contraption



Well this is a dangerous find when I have a project I am researching and home to do! Check out Fantastic Contraption for an amazing way to kill time, or loose time that you should be doing other things with. I have been obsessed all weekend with this game. Basically you get an infinite number of motors, rollers and two types of sticks to connect it all together with, all with a mission to get a red piece into a predefined goal area. However getting to the goal is not so easy, especially when it is below you or up a wall, and to make maters worse you only have so much space to build in, although after you run it it can go anywhere! You can only experience it by playing, and after finishing a level check out the thousands of other ways people have found to solve the same problem. If you liked building small gizmos as a child you will love this!

Oh and you can save and share creations! Check out some of mine...
http://FantasticContraption.com/?designId=2972825
http://FantasticContraption.com/?designId=2973894
http://FantasticContraption.com/?designId=2974040
http://FantasticContraption.com/?designId=2975559
http://FantasticContraption.com/?designId=2977810
http://FantasticContraption.com/?designId=2993872
http://FantasticContraption.com/?designId=2994200

October 8, 2008

You have to burn the rope!



A very cute example of how even a very short flash game can be awesome. It is little flash games like this, that are going to take game creation from simple entrainment to form of art. It is not about how hard the game is, or how complex it is, it is how the game effects the users and after playing this you have to tell friends about it. Check it out You have to burn the rope.

A amazing in-depth look at the art of the game is here at 1UP.

UPDATE: Found the ending song! Can be download here.

August 22, 2008

The Internet Archive

I am sure, just like me, others have found a site with the information they needed, however only to have it disappear at a later date. Lack of funds or just lack of interest, it does not mater, it still is one of the most aggravating things about the web, sites can close with out a moments notice, why else would I constantly end up with a list of bookmarks that go nowhere. However just like anything on the net, once it is there it stays there, in some shape or form.

To help with this, there is the Internet Archive "The Internet Archive is building a digital library of Internet sites and other cultural artifacts in digital form. Like a paper library, we provide free access to researchers, historians, scholars, and the general public."(Taken from the front page of the Internet Archive). This is a very handy tool to know of, as it can help you get to any page at almost any time that the site was available, even if it does not exist anymore.

I think it was TUAW that first brought this site to my attention about a year ago, they where showing what the Apple site used to look like over the years. I have recently needed to use the site, so I figure it is worth mentioning.

July 28, 2008

Somnium Nexus Site Up



Now that University Physics is over I have to start working again on my SN Project. However, I wanted to make a decient site for it first, other then the one that I had made at school. Googlepages is not perfect, but it will do the job. Probally the cleanest CSS that I have writen yet. Check it out here SN Project. There is a link for the latest build, though that was about a year ago, however it still works. Just remember it is a Mac only pre alpha, so no guarantee on stability and safety. ^_^

Expect more updates on the SN Project in the future, as it is going to be my Senior Project this year.

UPDATE: Brian gave me some constructive critisim on the art, so I added a more worn feel. Also played with the styling a bit, works in FF3 now, see previous post for the fix.

July 27, 2008

100% Height Divs

It is rare that I need to have a div fill the whole height of the window, but in my SN Project Website I thought that this would look rather nice, the problem is that if you just put "height: 100%; " in the css it does not work. This is because all parent divs must also have 100% height set, which makes sense after you finally are told this fact. So in order for you to have a 100% height div, you must first set the html and body to 100% then all other parent divs as well. See example below...


html, body
{
height: 100%;
}

div.content...
{
height: 100%;
min-height: 600px; /* I like 600 you can use any number */

}


UPDATE: You should also set a min height for your content divs, this will allow the page to stop only being 100% height and get smaller and scroll when the page size is reduced below that number.

Also, it makes the process a lot simpler to only use cascading inclosing divs, avoid any buggy fancy positioning, because this may break things. I am happy with the results, and to my supprise it worked with no issues in Saffari, Camino/FFox and IE 7.

July 18, 2008

Dad's Flash Series

I love finding awesome things online just by random coincidence. Today I stumbled upon Dad's Home and Dad's at work, both featuring a grinning guy in business casual attire that goes on a "friendly" rampage at home and then at work. The home one was goofy, especial the bizarre end, however the at work one had me laughing so hard that tears where coming out! I still crack up when he leaps and spins in the air then lands in a rolling chair that speeds away after exploding. This has to be the funniest animation I have seen is a great while. I have added the youtube versions below, however the original flash version are better in quality.



July 17, 2008

Map of visiting IPs

Ever interested in new cool webbased tools, I stumbled across Webmaps from ipligence. It is a free service that maps visitor's country/region based on IP. So you can get a view of where people are from that are looking at your site. I added it just below my ads on the left, so you can see what it does. The setup was painless, you enter a website and email address and it spits out the code to use. I will be interested in seeing roughly where people are from who read my blog, I am getting over 100 hits per week, so I know it is not just my friends.

July 10, 2008

ASP Email

I have never had such a hard time finding the correct way to create an online form that email the contents. Apparently there are several way to do email, but at least on the server that I have access to non of them work. Apparently there was/is a old way of doing email objects with CDONTS, however Microsoft has replaced that with CDOSYS, sadly most of the guides online to doing email forms with asp use the older CDONTS way, which on the server I have access to does absolutely nothing...

SO after looking through many guides I finally found a correct (in the fact that it works) way of doing ASP based email.


Set oCdoMail = Server.CreateObject("CDO.Message")
Set oCdoConf = Server.CreateObject("CDO.Configuration")

sConfURL = "http://schemas.microsoft.com/cdo/configuration/"

with oCdoConf
.Fields.Item(sConfURL & "sendusing") = 2
.Fields.Item(sConfURL & "smtpserver") = "localhost"
.Fields.Item(sConfURL & "smtpserverport") = 25
.Fields.Update
end with

with oCdoMail
.From = "your server"
.To = "email to send to"
.Subject = "Subject line"
.HTMLBody = "Body of email"
.Configuration = oCdoConf
.Send
end with

Set oCdoConf = Nothing
Set oCdoMail = Nothing


I do warn you that this works for me, and should... (and I take should lightly) work for you, however I feel that it is worth warning on that fact that depending on how your server is set up, who knows how ASP will function.

July 2, 2008

Blog > 1000 hits!

Well I have now hit over 1000 views of my blog since I put the google ad-sense banner on my blog!
It is funny, I am not really making money with the ads, but I love the fact that it tracks hit counts.

June 21, 2008

ASP Stock Ticker

Another little ASP script that I had to whip up was a stock ticker. I had searched around for a free javascript version, however they where either way to complicated and ad ridden to use, or they just did not work. So like most situation call for I just gave up on that idea and whipped up my own version.

It is very simple, it just pulls the CVS data on the stock from yahoo finance and prints out a table row, that way I can use single calls in a table row, and just make a new row and call for each different stock. Also I have an up and down arrow image, but you can make your own. This should be a good starter for people looking for a simple stock ticker. I am using an asp include to call the whole page for code simplification, but you can just drop the code in a page and it will work.


<%
function getQuote(name,location)
strURL = location
Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
objXMLHTTP.open "GET",strUrl, false
objXMLHTTP.send
ProcessUrl = objXMLHTTP.ResponseText
Set objXMLHTTP = Nothing
Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")

dim quote
quote = Array()

' Split the string at the comma characters and add each field to a ListBox
quote = Split(ProcessUrl, ",")

if quote(4) >= 0 then
Response.Write "<td>" & name & "</td><td><img src='images/up.gif'></td><td><font color='green'>" & quote(1) & "</font></td><td><font color='green'>" & quote(4) & "</font></td>"
else
Response.Write "<td>" & name & "</td><td><img src='images/down.gif'></td><td><font color='red'>" & quote(1) & "</font></td><td><font color='red'>" & quote(4) & "</font></td>"
end if
end function
%>

<center>
<h3>Stock Ticker</h3>
<table width="190" border="0" cellspacing="1" cellpadding="1">
<tr>
<% getQuote "Dow", "http://download.finance.yahoo.com/d/quotes.csv?s=%5EDJI&f=sl1d1t1c1ohgv&e=.csv" %>
</tr>
<tr>
<% getQuote "Nasdaq", "http://download.finance.yahoo.com/d/quotes.csv?s=%5EIXIC&f=sl1d1t1c1ohgv&e=.csv" %>
</tr>
<tr>
<% getQuote "S&P 500", "http://download.finance.yahoo.com/d/quotes.csv?s=%5EGSPC&f=sl1d1t1c1ohgv&e=.csv" %>
</tr>
<tr>
<% getQuote "10Yr Bond(%)", "http://download.finance.yahoo.com/d/quotes.csv?s=%5ETNX&f=sl1d1t1c1ohgv&e=.csv" %>
</tr>
</table>
</center>

June 10, 2008

50 Posts & ASP

Wow it has been over a half year since I started this blog!

For my internship I have been working an an updated site for Prescott Brokerages Services, and after getting the layout pretty much finished I I needed a very simple login page for agents, easy for me except for the fact that I can not use PHP, their web hosting company Webfodder uses Microsoft Server and only supports ASP. So just like last summer with learning PHP this time I am learning ASP. Luckily like most programing languages, it is close enough to PHP that I am having no problems picking it up. It may be just me but ASP reminds me of Fortran mixed with PHP.

It only took a few minutes to whip up a simple login script


<%
'// Check login if used, otherwise ignore
if request.form("pass")="password" then
'// Redirect to another page if correct
Response.Redirect "other_page.html"
end if
%>


This i pulling from a form on the home page, luckily it only need to be deterrent for legal reasons and not a full secure page, otherwise I would never hard code it.