Category Archives: Programming/javascript

如果程式語言是艘船, 那麼 …. 是….

http://compsci.ca/blog/if-a-programming-language-was-a-boat/

…..

If a programming language was a boat…

This one is inspired by a recent forum post, that still leaves me in amazement.

Hi, Im wondering how i can create a boat in turing and if someone can post a example.

This makes no sense, since one doesn’t normally make water vehicles in Turing, the programming language. Though this got me thinking — if a programming language was a boat, what would it be?

Turing

Turing would definitely be a kayak (thank you for comments). It’s small. It’s human powered. It’s often used as a beginner “boat”. And it’s also very Canadian.

Turing programming language as a canoe
Original photo by naokomc

Java

Java is a cargo ship. It’s very bulky. It’s very enterprise~y. Though it can also carry a lot of weight. Will carry a project, but not very fun to drive.

Java programming language as a cargo ship
Original photo by cfarivar

Perl

Perl is a tugboat. Powerful enough to tug Java around, in 80 characters or less.

Perl programming language as a tugboat
Original photo by xeeliz

Ruby

Ruby is difficult to describe. It’s sleek, sexy, and very fun to drive. Here’s a picture. Very trendy.

Ruby programming language as a speed boat
Original photo by Tony Falcon

PHP

PHP is a bamboo raft. A series of hacks held together by string. Still keeps afloat though.

PHP programming language as a raft
Original photo by permanently scatterbrained

C

C is a nuclear submarine. The instructions are probably in a foreign language, but all of the hardware itself is optimized for performance.

C programming language as a nuclear submarine
Original photo by Ryan C. McGinley

HTML

HTML isn’t really a programming language boat.

HTML is not a boat
Original photo by ascendeddaniel

There’s a lot more to this, and it’s all up for discussion. How would your favourite programming language fare in open waters?

範例程式 jQuery /JSON / PHP /json_encode / json_decode sample code

jQuery : 請參考這篇 : http://jsgears.com/thread-63-1-1.html

Microsoft 也提供 video 教學: http://msdn.microsoft.com/zh-tw/asp.net/dd310332.aspx#jQuery

$(document).ready( function(){
  var data = new Object();
  data.hello = "Hello";
  data.world = 'World';
  data.worked = " it worked ";
  data.somebool = true;
  data.array = new Array("he\"ll\"o", '"World"');
  var dataString = $.toJSON(data);
  $.post('phpfile.php', {data: dataString}, function(res){
      var obj = $.evalJSON(res);
      if(obj.somebool === true)
      $("#result").html(obj.hello + ' ' + obj.array[1] + obj.worked + ". Message from PHP: "+obj.php_message);
    });
});

… 未完

颱風天在家練功 – CSS / jQuery

jQuery :

  1. a
  2. #ID : 符何 ID 的元素
  3. .Class : match class items
  4. a#ID.Class : match a tag and ID and Class

 

 

 

這兩天把 blog 的 theme 換了 , 換成黑的 , 也把 javascript 整理了一下

 

筆記一點, CSS 裡面: ID 選擇器用 # 表示 , 類選擇器用 “.” 表示

寫了一個有意思的小程式, 在這! 怎玩呢? 要先在格子內填一下資料, 不清楚的人搞不好真的填了 ID / PW , 然後呢 mouse 不小心就移到底下, 就觸動了 mouseover 的 event , 於是好玩的狀況來了….看程式可以清楚 monster 在搞什麼.

這表示啥呢…就是如果這個頁面若可以外掛別人寫的 javascript 那麼別人就可以取得 user 在這頁面上輸入的資料.

[code language=’html’]
 

帳號 :密碼 :

mouse 經過這邊會 onMouseOver 喔!

 


[/code]

一些處理 javascript 減少 server http connection 數的方法

 

http://joliclic.free.fr/php/javascript-packer/en/
http://yuiblog.com/blog/2008/07/16/combohandler/
This is a fast, low-overhead port of Douglas Crockford’s JSMin JavaScript minifier to PHP. It requires PHP 5 or higher.
JSMin is a filter which removes comments and unnecessary whitespace from JavaScript files.
http://code.google.com/p/jsmin-php/

裝了 SyntaxHighlighter Plus , 程式碼可以看清楚了

SyntaxHighlighter Plus

It supports the following languages (the alias for use in the post is listed next to the name):

* Bash — bash, sh
* C++ — cpp, c, c++
* C# — c#, c-sharp, csharp
* CSS — css
* Delphi — delphi, pascal
* Java — java
* JavaScript — js, jscript, javascript
* PHP — php
* Python — py, python
* Ruby — rb, ruby, rails, ror
* SQL — sql
* VB — vb, vb.net

* XML/HTML — xml, html, xhtml, xslt

修改 … /wp-content/plugins/syntaxhighlighter-plus/shlfiles/SyntaxHighlighter.css
把 .dp-highlighter 的 width 改成想要的寬度

[code language=C]
#include
main() {
printf(“Hello World!”);
}

[/code]