Thursday, March 27, 2008
Thursday, March 20, 2008
Wednesday, March 19, 2008
Server Side Ajax for Classic ASP
There is probably a better name that Server-Side Ajax. its cool to be able to do this.
dim objSrvHTTP
Set objSrvHTTP = Server.CreateObject ("Msxml2.ServerXMLHTTP.3.0")
call objSrvHTTP.open ("GET","http://www.govwaudi.com", false)
call objSrvHTTP.send ()
Response.Write (objSrvHTTP.responseText)
dim objSrvHTTP
Set objSrvHTTP = Server.CreateObject ("Msxml2.ServerXMLHTTP.3.0")
call objSrvHTTP.open ("POST","http://www.example.com/test.asp?algo=1", false)
call objSrvHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
call objSrvHTTP.send ("variablename=value")
dim answer
answer = objSrvHTTP.responseText
Is there an easy way to do this in php?
dim objSrvHTTP
Set objSrvHTTP = Server.CreateObject ("Msxml2.ServerXMLHTTP.3.0")
call objSrvHTTP.open ("GET","http://www.govwaudi.com", false)
call objSrvHTTP.send ()
Response.Write (objSrvHTTP.responseText)
dim objSrvHTTP
Set objSrvHTTP = Server.CreateObject ("Msxml2.ServerXMLHTTP.3.0")
call objSrvHTTP.open ("POST","http://www.example.com/test.asp?algo=1", false)
call objSrvHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
call objSrvHTTP.send ("variablename=value")
dim answer
answer = objSrvHTTP.responseText
Is there an easy way to do this in php?
Tuesday, March 18, 2008
Inline SVG
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg"
xml:lang="en">
<head>
<title>SVG embedded inline in XHTML</title>
<object id="AdobeSVG" classid="clsid:78156a80-c6a1-4bbf-8e6a-3cd390eeb4e2"></object>
<?import namespace="svg" implementation="#AdobeSVG"?>
</head>
<body>
<h1>SVG embedded inline in XHTML</h1>
<svg:svg width="300" height="200">
<svg:circle cx="150" cy="100" r="50" />
</svg:svg>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg"
xml:lang="en">
<head>
<title>SVG embedded inline in XHTML</title>
<object id="AdobeSVG" classid="clsid:78156a80-c6a1-4bbf-8e6a-3cd390eeb4e2"></object>
<?import namespace="svg" implementation="#AdobeSVG"?>
</head>
<body>
<h1>SVG embedded inline in XHTML</h1>
<svg:svg width="300" height="200">
<svg:circle cx="150" cy="100" r="50" />
</svg:svg>
</body>
</html>
xmlns:svg="http://www.w3.org/2000/svg"
xml:lang="en">
<head>
<title>SVG embedded inline in XHTML</title>
<object id="AdobeSVG" classid="clsid:78156a80-c6a1-4bbf-8e6a-3cd390eeb4e2"></object>
<?import namespace="svg" implementation="#AdobeSVG"?>
</head>
<body>
<h1>SVG embedded inline in XHTML</h1>
<svg:svg width="300" height="200">
<svg:circle cx="150" cy="100" r="50" />
</svg:svg>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg"
xml:lang="en">
<head>
<title>SVG embedded inline in XHTML</title>
<object id="AdobeSVG" classid="clsid:78156a80-c6a1-4bbf-8e6a-3cd390eeb4e2"></object>
<?import namespace="svg" implementation="#AdobeSVG"?>
</head>
<body>
<h1>SVG embedded inline in XHTML</h1>
<svg:svg width="300" height="200">
<svg:circle cx="150" cy="100" r="50" />
</svg:svg>
</body>
</html>
http://wiki.svg.org/index.php?title=Inline_SVG
Safari 3.1
This is copied straight from their apples website.
CSS3 web fontsWith CSS3 web fonts, web developers can now choose from a limitless selection offonts to create stunning new websites using standards-based technology. Safariautomatically recognizes websites that use custom fonts and downloads them asthey’re needed.CSS animationSafari is the first browser to support CSS animation. Now anyone can add amazinginteractive animations to their website using open standards. With CSS animations,web developers can scale, rotate, fade, and skew web elements for elegant, highproduction-value pages.HTML 5 media supportThe new HTML 5 media tags make it easy for web developers to deliver rich, interactivevideo and audio as a native part of any website without the need for proprietarytechnologies. The media tags also offer a rich scripting API for controlling mediaplayback.Improved SVG supportSafari 3.1 features improved support for Scalable Vector Graphics (SVG), so nowdevelopers can use SVG images anywhere on a page including HTML and CSSelements. SVG allows developers to create dynamic graphics with the web scriptinglanguages they’re familiar with.HTML 5 offline storage supportWith offline storage support based on the HTML 5 standard, web developers cancreate faster web-based applications that store their information on a user’s localmachine, and then access it instantly rather than having to re-download it overthe Internet.
Saturday, March 15, 2008
iterate through javascript object
function show(value)
{
var count = 0
document.write(showObj(value));
function showObj(o)
{
count++;
var ret = ""
for(var x in o)
{
if (typeof o[x] == "object")
{
for (var i = 0; i < count; i++)
{
ret += "-------";
}
ret += x + ": " + "
" + showObj(o[x]) + "
";
}
else
{
for (var i = 0; i < count; i++)
{
ret += "-------";
}
ret += x + ": " + o[x] + "
";
}
}
count--;
return ret;
}
}
{
var count = 0
document.write(showObj(value));
function showObj(o)
{
count++;
var ret = ""
for(var x in o)
{
if (typeof o[x] == "object")
{
for (var i = 0; i < count; i++)
{
ret += "-------";
}
ret += x + ": " + "
" + showObj(o[x]) + "
";
}
else
{
for (var i = 0; i < count; i++)
{
ret += "-------";
}
ret += x + ": " + o[x] + "
";
}
}
count--;
return ret;
}
}
Tuesday, March 11, 2008
css and tables
Css is great.
What a great concept. Separate content from design.
I started trying to learn css more today with regards to laying out an html document. Yesterday, I thought I had made a good page using css, until I viewed it in Internet Explorer.
Redoing the site was kind-of a nightmare, (first of all i'm not a css expert..yet, and trying to juggle the browser compatibility was hard. (Thanks to a friend who helped explain some css techniquess to me... redoing the site wasn't as hard as it could have been)
People say css replaces tables for layout
csszengarden.com at first convinced me of that.
However, I am not completely convinced any more. It may be too soon for me to blog about this but I don't completely buy the with css you can "separate content from design."
I found myself having to think of the layout of the site and then change the hierarchy of my div elements accordingly.
I also at at least one point had to put a div inside another div.
That doesn't sound like separating content from design but rather complicating your content to meet your design needs.
I imagine, with the complex and complicated use of "position:absolute", you can organize your document in whatever way you want, without regard to the hierarchy of the div elements.
sounds good...
But then if you are still having to think of the hierarchy of your divs in your content, aren't you better off just using a table with each cell as a div element. That table will be your default design, and if you want to change it you can "position:absolute" the divs and change the order.
however...
for simple things like a two column setup you can use a float and not worry about using a table.
I like this example
also...
In IE you cant do "display: table-cell".
(if you want to do things like vertical align or make a div only as wide as it needs)
(I don't know of any other way to do it)
You need an actual table to do that.
What a great concept. Separate content from design.
I started trying to learn css more today with regards to laying out an html document. Yesterday, I thought I had made a good page using css, until I viewed it in Internet Explorer.
Redoing the site was kind-of a nightmare, (first of all i'm not a css expert..yet, and trying to juggle the browser compatibility was hard. (Thanks to a friend who helped explain some css techniquess to me... redoing the site wasn't as hard as it could have been)
People say css replaces tables for layout
csszengarden.com at first convinced me of that.
However, I am not completely convinced any more. It may be too soon for me to blog about this but I don't completely buy the with css you can "separate content from design."
I found myself having to think of the layout of the site and then change the hierarchy of my div elements accordingly.
I also at at least one point had to put a div inside another div.
That doesn't sound like separating content from design but rather complicating your content to meet your design needs.
I imagine, with the complex and complicated use of "position:absolute", you can organize your document in whatever way you want, without regard to the hierarchy of the div elements.
sounds good...
But then if you are still having to think of the hierarchy of your divs in your content, aren't you better off just using a table with each cell as a div element. That table will be your default design, and if you want to change it you can "position:absolute" the divs and change the order.
however...
for simple things like a two column setup you can use a float and not worry about using a table.
I like this example
also...
In IE you cant do "display: table-cell".
(if you want to do things like vertical align or make a div only as wide as it needs)
(I don't know of any other way to do it)
You need an actual table to do that.
Friday, February 29, 2008
Internet Explorer 7 bug
You can not do this in Internet Explorer. For it to work, you must remove the div tags!
<div><script>document.body.appendChild(document.createElement('script'))</script></div>
May you be able to in IE8
<div><script>document.body.appendChild(document.createElement('script'))</script></div>
May you be able to in IE8
Thursday, February 21, 2008
get the text
this code will alert the selected text
if (window.getSelection) {
var str = window.getSelection();
}
else if (document.getSelection) {
var str = document.getSelection();
} else if (document.selection && document.selection.createRange) {
var range = document.selection.createRange();
var str = range.text;
} else {
var str = "Sorry, this is not possible with your browser.";
}
alert(str);
part of this code is from
this site
I added some code to make it work for safari
if (window.getSelection) {
var str = window.getSelection();
}
else if (document.getSelection) {
var str = document.getSelection();
} else if (document.selection && document.selection.createRange) {
var range = document.selection.createRange();
var str = range.text;
} else {
var str = "Sorry, this is not possible with your browser.";
}
alert(str);
part of this code is from
this site
I added some code to make it work for safari
Wednesday, February 20, 2008
Monday, February 18, 2008
Saturday, February 16, 2008
Adding Scripts to others' web pages: a few thoughts
There could be problems doing things like document.body.appendChild when there DOM hasn't loaded yet.
Therefore you need to do things to watchout for that
< body onload = "customfunction()" >
or put script tags right before body
or window.onload =
or window.attachevent("onload",customfunction)
window.addeventlistener("load",customfunction,false) //or true I dont know
What about large images etc. that you dont want to wait for
another thing to research is the defer attribute of the script tag
another thing to research is the DOMContentLoaded
http://developer.mozilla.org/en/docs/Gecko-Specific_DOM_Events
"Fired on a Window object when a document's DOM content is finished loaded, but unlike "load", does not wait till all images are loaded. Used for example by GreaseMonkey to sneak in to alter pages before they are displayed. "
what about document.write
http://www.hedgerwow.com/360/dhtml/ie-dom-ondocumentready.html
unobtrusive javaScript
Therefore you need to do things to watchout for that
< body onload = "customfunction()" >
or put script tags right before body
or window.onload =
or window.attachevent("onload",customfunction)
window.addeventlistener("load",customfunction,false) //or true I dont know
What about large images etc. that you dont want to wait for
another thing to research is the defer attribute of the script tag
another thing to research is the DOMContentLoaded
http://developer.mozilla.org/en/docs/Gecko-Specific_DOM_Events
"Fired on a Window object when a document's DOM content is finished loaded, but unlike "load", does not wait till all images are loaded. Used for example by GreaseMonkey to sneak in to alter pages before they are displayed. "
what about document.write
http://www.hedgerwow.com/360/dhtml/ie-dom-ondocumentready.html
unobtrusive javaScript
Friday, February 15, 2008
Monday, February 11, 2008
Flash Ball example slow in some cases
The ball example that I did is slow in IE7 on my windows vista.
When I open the swf in the browser on IE and on Safari it is also slow.
In Firefox,opera,safari it is fast when embedded in a page.
When I open the swf in the browser on firefox 2, it starts fast and then goes slow.
In opera when It is embedded in a page it is fast, and when I open it in a browser it is also fast!
When I open the swf in the browser on IE and on Safari it is also slow.
In Firefox,opera,safari it is fast when embedded in a page.
When I open the swf in the browser on firefox 2, it starts fast and then goes slow.
In opera when It is embedded in a page it is fast, and when I open it in a browser it is also fast!
Actionscript and flex language reference online
What's the difference between this http://livedocs.adobe.com/flex/201/langref/index.html and this http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/
Sunday, February 10, 2008
Actionscript 3.0 Timer and key events
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class BM2 extends Sprite
{
public var txtbox:TextField;
public var kDown:JS;
public var kUp:JS;
public var xx:int;
public var yy:int;
public var rep:Timer;
public var ymov:int;
public var xmov:int;
public function BM2()
{
kDown = new JS();
kUp = new JS();
txtbox = new TextField();
txtbox.text = "Hello World";
addChild(txtbox);
stage.addEventListener(KeyboardEvent.KEY_DOWN,keydownhandler);
stage.addEventListener(KeyboardEvent.KEY_UP,keyuphandler);
kDown[37] = function():void{xmov = -1;};
kDown[38] = function():void{ymov = -1;};
kDown[39] = function():void{xmov = 1;};
kDown[40] = function():void{ymov = 1;};
kUp[37] = function():void{xmov = 0;};
kUp[38] = function():void{ymov = 0;};
kUp[39] = function():void{xmov = 0;};
kUp[40] = function():void{ymov = 0;};
rep = new Timer(1,0);
rep.addEventListener(TimerEvent.TIMER, draw);
rep.start();
}
public function test(event:TimerEvent):void{txtbox.text = event.toString();}
public function draw(event:TimerEvent):void
{
xx = xx + 1 * xmov;
yy = yy + 1 * ymov;
graphics.clear();
graphics.lineStyle(1);
graphics.beginFill(0xFF8000);
graphics.drawCircle(xx, yy, 10);
}
public function keydownhandler(evento:KeyboardEvent):void
{
txtbox.text = evento.keyCode.toString() + " " + kDown[evento.keyCode];
if (evento.keyCode >= 37 && evento.keyCode <= 40) kDown[evento.keyCode]();
}
public function keyuphandler(evento:KeyboardEvent):void
{
txtbox.text = evento.keyCode.toString() + " " + kUp[evento.keyCode];
if (evento.keyCode >= 37 && evento.keyCode <= 40) kUp[evento.keyCode]();
}
}
} //end package
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Point;
import flash.geom.Rectangle;
//this is how i am rescuing the coolness of javascripts objects!!
dynamic class JS
{
public function JS(){}
}
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class BM2 extends Sprite
{
public var txtbox:TextField;
public var kDown:JS;
public var kUp:JS;
public var xx:int;
public var yy:int;
public var rep:Timer;
public var ymov:int;
public var xmov:int;
public function BM2()
{
kDown = new JS();
kUp = new JS();
txtbox = new TextField();
txtbox.text = "Hello World";
addChild(txtbox);
stage.addEventListener(KeyboardEvent.KEY_DOWN,keydownhandler);
stage.addEventListener(KeyboardEvent.KEY_UP,keyuphandler);
kDown[37] = function():void{xmov = -1;};
kDown[38] = function():void{ymov = -1;};
kDown[39] = function():void{xmov = 1;};
kDown[40] = function():void{ymov = 1;};
kUp[37] = function():void{xmov = 0;};
kUp[38] = function():void{ymov = 0;};
kUp[39] = function():void{xmov = 0;};
kUp[40] = function():void{ymov = 0;};
rep = new Timer(1,0);
rep.addEventListener(TimerEvent.TIMER, draw);
rep.start();
}
public function test(event:TimerEvent):void{txtbox.text = event.toString();}
public function draw(event:TimerEvent):void
{
xx = xx + 1 * xmov;
yy = yy + 1 * ymov;
graphics.clear();
graphics.lineStyle(1);
graphics.beginFill(0xFF8000);
graphics.drawCircle(xx, yy, 10);
}
public function keydownhandler(evento:KeyboardEvent):void
{
txtbox.text = evento.keyCode.toString() + " " + kDown[evento.keyCode];
if (evento.keyCode >= 37 && evento.keyCode <= 40) kDown[evento.keyCode]();
}
public function keyuphandler(evento:KeyboardEvent):void
{
txtbox.text = evento.keyCode.toString() + " " + kUp[evento.keyCode];
if (evento.keyCode >= 37 && evento.keyCode <= 40) kUp[evento.keyCode]();
}
}
} //end package
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Point;
import flash.geom.Rectangle;
//this is how i am rescuing the coolness of javascripts objects!!
dynamic class JS
{
public function JS(){}
}
Thursday, February 7, 2008
Making videos
I have a really cool camera from Canon. It is a camera for pictures but it also records videos. It is a Canon PowerShot SD750 7.1 Megapixels
I love it. I bought a 4 Gig SD card for it and the SD card fits right into my laptop to upload my videos.
Making small movies is great on it because you don't have to mess with the MINI DV tapes, and the quality of video is pretty good!
Apple's iMovie is great for doing video.
It has drawbacks but Windows Movie Maker is allright for simple stuff.
I love it. I bought a 4 Gig SD card for it and the SD card fits right into my laptop to upload my videos.
Making small movies is great on it because you don't have to mess with the MINI DV tapes, and the quality of video is pretty good!
Apple's iMovie is great for doing video.
It has drawbacks but Windows Movie Maker is allright for simple stuff.
Tuesday, February 5, 2008
Publishing Factor
You think your done, until your printer doesn't work and your other computer doesn't have openoffice.
You think your done until you can't find your firewire cord.
You think your done until you can't find your firewire cord.
Tuesday, January 29, 2008
Helpful Acronym Explanations
SDK - Software Development Kit. Has at least a compiler to compile your code
IDE - Integrated Development Environment. Think of Visual Basic. Its a program that lets you write and run (and debug) your programs. There need to be more of these. These are the missing link.
API. Application Programming Interface. I think of this as within the code. The methods and properties that classes have to do things.
IDE - Integrated Development Environment. Think of Visual Basic. Its a program that lets you write and run (and debug) your programs. There need to be more of these. These are the missing link.
API. Application Programming Interface. I think of this as within the code. The methods and properties that classes have to do things.
Monday, January 28, 2008
Sunday, January 27, 2008
TI Calculators
Quick thought. It would be cool to learn how to do assembly language programming on the TI Calculators because so many students have them
Learning how to make my own web server
I finally figured it out. How to turn my computer into a web server. So I could host my own pages.
I need to write a quick tutorial, but basically I had to make it on a port other that port 80.
I had to play with my linksys router (192.168.1.1) and the Qwest Actiontec modem (192.168.0.1)
I made my LAN ip 192.168.1.3
I make the linksys's router ip 192.168.0.4 (with reference to the DSL modem)
I did port forwarding on port 81 from the Modem to 192.168.0.4
I did port forwarding on port 81 from the router to 192.168.1.3
I installed POW (plain old webserver) as an extension to firefox. I ran it using port 80.
you have to test it on a computer not in your lan.
....More details to come!
I need to write a quick tutorial, but basically I had to make it on a port other that port 80.
I had to play with my linksys router (192.168.1.1) and the Qwest Actiontec modem (192.168.0.1)
I made my LAN ip 192.168.1.3
I make the linksys's router ip 192.168.0.4 (with reference to the DSL modem)
I did port forwarding on port 81 from the Modem to 192.168.0.4
I did port forwarding on port 81 from the router to 192.168.1.3
I installed POW (plain old webserver) as an extension to firefox. I ran it using port 80.
you have to test it on a computer not in your lan.
....More details to come!
Wednesday, January 23, 2008
Sunday, January 20, 2008
Bluetooth
I have been using my motorola w490 phone (resembles the famous razr phone) to connect to an iMac via bluetooth...all wirelessly. I have been sending picures, video, audio...all wirelessly.
Remote Desktop
One of the things I have seen done often is a "remote desktop" deal where computer connect to other computers via the internet (and an IP address) can you do that to make your computer be like a server... even if you didn't have a static ip address, you could update the address that it is for others to connect to.... hmmm....
Sockets?
Can I, over the internet, and/or by using ethernet cables directly, connect two computers to play an online game? (or so something that would need the responsiveness like an online game would)
can I do that with flash using sockets... or with java. How would I set up a server that did that?!
can I do that with flash using sockets... or with java. How would I set up a server that did that?!
Saturday, January 19, 2008
php myql quick reference2
$stmt = $mysqli->prepare("SELECT id, thetime, towho, fromwho, message, style FROM chat where towho = ? order by id LIMIT " . intval($_POST[o]) . "," . $rowstoget);// . intval($rowstoget));
$stmt->bind_param('s', $to1);
$stmt->execute();
/* bind variables to prepared statement */
$stmt->bind_result($id, $thetime, $towho, $fromwho, $message, $style);
/* fetch values */
while ($stmt->fetch()) {
$badchar = array("\\","'","\r\n","\r","\n");
$replacebadchar = array("\\\\","\\'","
","
","
");
$fromwho = str_replace($badchar,$replacebadchar,$fromwho);
$towho = str_replace($badchar,$replacebadchar,$towho);
$message = str_replace($badchar,$replacebadchar,$message);
$style = str_replace($badchar,$replacebadchar,$style);//"color: \'rgb(0,128,0)\'"; //str_replace($badchar,$replacebadchar,$style);
...
$stmt->bind_param('s', $to1);
$stmt->execute();
/* bind variables to prepared statement */
$stmt->bind_result($id, $thetime, $towho, $fromwho, $message, $style);
/* fetch values */
while ($stmt->fetch()) {
$badchar = array("\\","'","\r\n","\r","\n");
$replacebadchar = array("\\\\","\\'","
","
","
");
$fromwho = str_replace($badchar,$replacebadchar,$fromwho);
$towho = str_replace($badchar,$replacebadchar,$towho);
$message = str_replace($badchar,$replacebadchar,$message);
$style = str_replace($badchar,$replacebadchar,$style);//"color: \'rgb(0,128,0)\'"; //str_replace($badchar,$replacebadchar,$style);
...
PHP mysql quick reference
$mysqli = new mysqli($host, $login, $pw, $database);
if ($result = $mysqli->query('SELECT name from employee'))
{
while( $row = $result->fetch_assoc() ){
echo "".$row['name']."
";
}
/* Destroy the result set and free the memory used for it */
$result->close();
}
/* Close the connection */
$mysqli->close();
?>
What is the difference?
between this http://livedocs.adobe.com/flex/201/langref/
and this http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/package-summary.html
?
notice that the fl stuff is missing in the first one.
and this http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/package-summary.html
?
notice that the fl stuff is missing in the first one.
Friday, January 18, 2008
Jamba Juice Web Site
Some people don't like flash but this site is really cool
http://www.jambajuice.com
http://www.jambajuice.com
Tuesday, January 15, 2008
Flash can talk to Javascript
this topic is a lot more complicated but here is an exaple of flash talkting to javascript
the actionscript code
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.external.ExternalInterface;
public class HelloWorld extends Sprite {
public function HelloWorld() {
var display_txt:TextField = new TextField();
display_txt.text = "Hello World!";
addChild(display_txt);
var param1:uint = 3;
var param2:uint = 7;
var result:uint = ExternalInterface.call("addNumbers", param1, param2);
display_txt.text = String(result);
}
}
}
the actionscript code
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.external.ExternalInterface;
public class HelloWorld extends Sprite {
public function HelloWorld() {
var display_txt:TextField = new TextField();
display_txt.text = "Hello World!";
addChild(display_txt);
var param1:uint = 3;
var param2:uint = 7;
var result:uint = ExternalInterface.call("addNumbers", param1, param2);
display_txt.text = String(result);
}
}
}
My Canvas Project
For a math class, I used canvas to make a cool little program about gates and inverters etc
Thursday, January 10, 2008
Comet with script tag
not just an iframe, not just the XMLHTTPRequest object... think of the possibilities.
PHP can make images
Here is an example of making images with php.
// create a 100*30 image
$im = imagecreate(100, 30);
$im = imagecreatefromjpeg("http://www.example.com/image.jpg"); /* Attempt to open */
// white background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);
// write the string at the top left
imagestring($im, 4, 375, 0, "Valid from: " . date("n\/j\/y") . " to " . date("n\/j\/y",mktime() + (7*60*60*24)), $textcolor);
// output the image
header("Content-type: image/jpeg");
imagejpeg($im);
?>
// create a 100*30 image
$im = imagecreate(100, 30);
$im = imagecreatefromjpeg("http://www.example.com/image.jpg"); /* Attempt to open */
// white background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);
// write the string at the top left
imagestring($im, 4, 375, 0, "Valid from: " . date("n\/j\/y") . " to " . date("n\/j\/y",mktime() + (7*60*60*24)), $textcolor);
// output the image
header("Content-type: image/jpeg");
imagejpeg($im);
?>
PHP add dates
Here is an easy way to add dates (and format dates) in php
Here is am example that shows "valid from [today] to [a week from today]"
Valid from: " . date("n\/j\/y") . " to " . date("n\/j\/y",mktime() + (7*60*60*24))
Here is am example that shows "valid from [today] to [a week from today]"
Valid from: " . date("n\/j\/y") . " to " . date("n\/j\/y",mktime() + (7*60*60*24))
Tuesday, January 8, 2008
Comet example
http://www.zeitoun.net/index.php?2007/06/22/46-how-to-implement-comet-with-php
I like this guy's examples. Nice and simple about doing comet with php
I like this guy's examples. Nice and simple about doing comet with php
Jetty on Mac OS
I would love to make my own server. Right now I am with two hosting companies: Bluehost and webhost4life.
I just called cox to see how much that would be. This is the number I called 1-866-456-9944.
My brother has a mac and it would be cool to set up a server on his computer.
It would be cool to use php with the built in apache server and also a Jetty server so I could make comet apps.
This might help with that
http://developer.apple.com/internet/java/enterprisejava.html
I just called cox to see how much that would be. This is the number I called 1-866-456-9944.
My brother has a mac and it would be cool to set up a server on his computer.
It would be cool to use php with the built in apache server and also a Jetty server so I could make comet apps.
This might help with that
http://developer.apple.com/internet/java/enterprisejava.html
More on Comet
Comet is fascinating.
I was reading this blog entry on simonwillison.net and it helped me understand a little bit more about implementing Comet in your web apps.
http://cometd.com/
I was reading this blog entry on simonwillison.net and it helped me understand a little bit more about implementing Comet in your web apps.
http://cometd.com/
Monday, January 7, 2008
Javascript helps avoid code duplication
I love javascript because it helps against code duplication
insead of long chain if statements you can call the right function based on properties
eg
Can you do that in any other language
insead of long chain if statements you can call the right function based on properties
eg
//draw the correct shape according to element typesee www.thinknumber.com/dismat
function redraw(elem,x)
{
cir[elem.type](elem.coor.x,elem.coor.y)
//......
}
Can you do that in any other language
My bug using php on a windows server
I was using webhost4life for my online chat (windows server). My scripts are written in php.
I was getting an error for it when I realized that I had extra carriage returns (enters) at the end of my php tag
eg
//code
?>
I was getting an error for it when I realized that I had extra carriage returns (enters) at the end of my php tag
eg
//code
?>
Comet
Comet is cool too.
There may be better more professional words for it. I think comet is the best one because it gives it a name and lets us know that it has to do with Ajax.
The idea behind comet is reverse Ajax. Letting the server communicate with the client.
A sort of way to look at it is in Ajax the client initiates the the communication when it wants something. In Comet, the server initiates the communication.
There may be better more professional words for it. I think comet is the best one because it gives it a name and lets us know that it has to do with Ajax.
The idea behind comet is reverse Ajax. Letting the server communicate with the client.
A sort of way to look at it is in Ajax the client initiates the the communication when it wants something. In Comet, the server initiates the communication.
Ajax
Ajax is so cool.
I have liked it for a while.
I think how I got into it was when I wanted to make a web application where the user sent an email, but the page didn't have to refresh. I searched about how to do that and I discovered Ajax.
The idea is communicate with the server without having to refresh the page
I have liked it for a while.
I think how I got into it was when I wanted to make a web application where the user sent an email, but the page didn't have to refresh. I searched about how to do that and I discovered Ajax.
The idea is communicate with the server without having to refresh the page
Saturday, January 5, 2008
Friday, January 4, 2008
Ajax Online Chat
I am using Bluehost as my web hosting company. I am making an online chat using ajax (XMLHTTPRequest object). I ran into some trouble because I was exceeding the CPU limit. Probably because every half a second or so it checks for new messages. Right now I have many "chat" windows open to test to see if it will do it again. Hopefully not.
For the chat I am using the polling technique, which may not be the best but it works.
It would be cool to learn "Comet." Comet might be a dorky name but I think its good to have something simple to call it.
Exceeded CPU again!
For the chat I am using the polling technique, which may not be the best but it works.
It would be cool to learn "Comet." Comet might be a dorky name but I think its good to have something simple to call it.
Exceeded CPU again!
Thursday, January 3, 2008
Web Design and Programming
Learning how to program and make websites is hard.
There are plenty of tutorials that really don't help.
Hopefully, if there is anything that you don't understand, please comment about it on the blog.
There are plenty of tutorials that really don't help.
Hopefully, if there is anything that you don't understand, please comment about it on the blog.
Flash Flex Actionscript SWF mxmlc compiler
I thought it was cool that you can compile .as files into SWF format without purchasing swf software. Thats cool!
I downloaded the Flex 2 SDK (you can download it here http://www.adobe.com/products/flex/downloads/)
I opened the readme and tried to understand it a little. Unfortunately it wasn't simple enough for me to understand, so I kind of gave up for a while.
However, using Google I found this site Beginners Guide to Getting Started with AS3 (Without Learning Flex).
Wow! that person explained it so well. He gives exapmles of .as files and how to compile them.
The simplest way that he says it is to drag your .as file over the mxmlc.exe file.
If there are errors in your actionscript code, you wont be able to see them
Quoting from his site, here is a simple example of an Actionscript file (.as)
I downloaded the Flex 2 SDK (you can download it here http://www.adobe.com/products/flex/downloads/)
I opened the readme and tried to understand it a little. Unfortunately it wasn't simple enough for me to understand, so I kind of gave up for a while.
However, using Google I found this site Beginners Guide to Getting Started with AS3 (Without Learning Flex).
Wow! that person explained it so well. He gives exapmles of .as files and how to compile them.
The simplest way that he says it is to drag your .as file over the mxmlc.exe file.
If there are errors in your actionscript code, you wont be able to see them
Quoting from his site, here is a simple example of an Actionscript file (.as)
package {
import flash.display.Sprite;
import flash.text.TextField;
public class HelloWorld extends Sprite {
public function HelloWorld() {
var display_txt:TextField = new TextField();
display_txt.text = "Hello World!";
addChild(display_txt);
}
}
}
Subscribe to:
Posts (Atom)
Why Comet? Why not JavaScript Sockets? You know, sockets, like what “real” applications use… True bidirectional communications.
I’m using Sockets all the time for my web applications using Flash. It works great.