自製竹筏龍舟

原本是在無名BBS的白爛板看到龍舟的Y拍,點了影片後看到文字就覺得自己會把影片看完:
轉自http://www.wretch.cc/blog/jaymin&article_id=10939492


顯示影片
音樂來源:五月天 倔強。
主演:JAY(我本人)KANE(碩彥)JAYSIN(胡傑)
導演:JAY (自己很想當導演,其實根本沒導演這回事)。
剪接:JAY。
字幕&旁白:JAY。

很多大人其實很會說風涼話,或許有很多人也都會說。
「你們一定浮不起來啦」 「你以為竹筏這麼好做嗎??要是這麼好做每個人都會去做竹筏了」
(但誰會這麼閒整天做竹筏呀? )
「很危險唷,你們最好不要這樣做唷!」

太多不被看好的聲音,使的我們有點灰心。
難道你們有做過竹筏嗎??你們有受過做竹筏的專業訓練嗎??
沒有做過就否定、沒有實驗過就放棄。
這算什麼。( 怎麼感覺我很火 )
現在不是成功了嗎 ? 這只是個態度!! 一個feel, 我們做到了!!

文章分類: 搞笑有什麼前途?

說真的,我(們)即使是在做修的主科的final project,也沒有毅力淋雨砍竹子、沒有休養忍受冷言冷語、沒有意願在大熱天買器材趕工搬運、沒有心思借救生衣和槳....

這篇我轉的有點胖菜或是游智浩或是vic的感覺。
不過我不小心又有點想要譙yya了...
......
... read more

把清大課程總表丟進資料庫

  一直不知道學校到底有沒有把比較好處理的課程「總」表放在網路上,但是又不能去問(去年電商專題的EZCheat讓部分教授們對課務組和計中施壓,不會把那樣的資料給我們),最後只好自己從校務資訊系統的查詢網頁著手了,先跳過表單檢查步驟強制用空字串當關鍵字以一次查到所有課程,然後用PHP去做parsing和塞進資料庫。
  雖然講起來沒什麼,但這東西花了我整個下午,(說起來還頗對不起英翔學長的....答應的BuzzShare的進度已經落後很多了)中途還冒出一些目前還不知道怎麼解決的問題,比方說因為我幾乎不會用正規表示法,只好改用投機的方式去把 <input> 改成 <input/>。(這件事告訴我們修過【正規語言】跟擅長使用正規表示法是兩回事)
  總之,程式碼如下,已經改成只要把網頁給他就可以的function了:function nthuCourseParse( $webpage ) {
$data = file_get_contents( $webpage );
$data = mb_convert_encoding( $data, 'UTF-8', 'BIG-5' );

// Preserve only <table />
$tableStart = strpos( $data, '<table' );
$tableEnd = strpos( $data, '</table>' );
$data = substr( $data, $tableStart, $tableEnd - $tableStart + 8 );

/*
Make it to match XML format
The wierd ');"></td>"' is used for handling the button.
Note that   is not allowed in XML until other DTD declaration.
*/
$replace = array(
'<BR>' => '<BR/>',
'<br>' => '<br/>',
' ' => ' ',
');"></td>' => ');" /></td>',
'&' => '&'
);
foreach( $replace as $from => $to )
$data = str_replace( $from, $to, $data );

$parser = xml_parser_create();
xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 );
xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 1 );
if( !xml_parse_into_struct( $parser, $data, $values, $tags ) )
printf(
'Line %d, Col %d: %s',
xml_get_current_line_number( $parser ),
xml_get_current_column_number( $parser ),
xml_error_string( xml_get_error_code( $parser ) )
);
xml_parser_free( $parser );

/*$colName = array( '科號', '科目', '學分', '時間', '教室/容量',
'教師', '人限', '備註', '人數', '對象', '擋修', '大綱' );*/
/*
Parse into another structure in which each element is a course.
Note that empty string is also parsed.
The initial value 4 of the for-loop is based on the structure of <table />,
as the increasing-step 4 is to skip the other row of <table />.
*/
$tr = $tags['tr'];
for( $c = 0, $i = 4; $i+1 < count( $tr ); $i+=4, $c++ ) {
$tdi = 0; // index of td
for( $j = $tr[$i]+1; $j < $tr[$i+1]; $j++ ) { // Trace each <td /> for data
$re = $values[ $j ];
$arr[$c][$tdi][] .= trim( $re['value'] );
if( $re['tag'] == 'td' )
if( in_array( $re['type'], array( 'close', 'complete' ) ) )
$tdi++;
}
}
return $arr;
}

這樣就會回傳一個比較容易懂的結構了,至少比較方便直接呼叫到想要的東西,可以有如是的用法:foreach( $arr as $r => $course ) {
$db[$r]['sn'] = $course[0][1];
$db[$r]['chinese'] = $course[1][0];
$db[$r]['english'] = $course[1][2];
$db[$r]['credit'] = $course[2][1];
$db[$r]['period'] = $course[3][1];
list( $db[$r]['location'] ) = explode( '/', $course[4][1] );
$db[$r]['teacher']['chinese'] = $course[5][1];
$db[$r]['teacher']['english'] = $course[5][3];
}

其實也可以用數字當index直接呼叫所需的資料啦,不過先做過這件事的話就比較可以知道自己再寫什麼:foreach( $db as $i => $course ) {
$teacher = $db->getOne( sprintf( "SELECT sn FROM teacher WHERE name = '%s'", $course['teacher']['chinese'] ) );
$db->exec( "INSERT INTO course ( sn, name, teacher ) VALUES ( '%s', '%s', %d )", $course['sn'], $course['chinese'], $teacher ) );
}
......
... read more

Csound - Final Project

MP3下載

這次的比較能聽了....
/*
Csound - Final Project
Author: Kong Kao
Advisor: Prof. James Ma

This project uses pre-entered chords to implement auto-composition.
Chords are stored by their roots in tables.
Instr 1 decides how the chord goes, and store the way the music would go
into a function table (giftMelody).
Instr 2 does 3 part of music:
1. The root of the chord.
2. A melody generated by an algorithm with random.
3. Accompaniment
*/
<CsoundSynthesizer>
<CsOptions>
</CsOptions>

<CsInstruments>
; Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

; Global a-rate variabe used for reverberation
gaSig init 0

; Some constant for convenience
giSemiTone init 2^(1/12)
giLoopLength init 8 ; Seconds a period would use.

; Function tables
giftScale init 2
giftMelody ftgen 0, 0, 8192, -2, 0, 8192, 0 ; Overall roots of chords

; Function tables that stores the chords.
; The name of them is only meaningful for me, so don't mind it...XD
giftBallad init 1
giftHappy init 4
giftToDearYou init 5


instr 1
/*
No signal output, but need to have the same length with i2.
Used to assign the overall roots to the function table giftMelody
Note that only the value is neither semitones nor intervals, but the
index of the tone in giftScale.
*/
aPhasor phasor 1/giLoopLength
INIT0:
iSwitch = floor(rnd(3))
if( iSwitch == 0 ) then
iFt = giftBallad
elseif( iSwitch == 1 ) then
iFt = giftHappy
else
iFt = giftToDearYou
endif
aMelody table aPhasor, iFt, 1
timout 0, giLoopLength, CONT0
reinit INIT0
CONT0:
rireturn
aPhasor phasor 1/p3
tablew aMelody, aPhasor, giftMelody, 1
endin


instr 2
iUnit = 0.25 ; The shortest length of a note, measured in seconds
iAmp = ampdb( p4 )
iBaseFreq = p5

kPhasor phasor 1/p3
kMelody table kPhasor, giftMelody, 1
kPitch table kMelody, giftScale
kFreq = iBaseFreq * giSemiTone ^ kPitch / 2
aSig1 oscil iAmp, kFreq, 11

; ----------------------------------------------------------
iPrevPitch = 3
iPrevInterval = 0
iPosition = 0
/*
Use a variable to store the position of the current note in the period.
This is used to decide which chord it is for the note.
*/
INIT2:
/*
Decide the interval of this note with the root of the chord.
If the previous interval tends to be balanced (such as 4th tends to
3rd, and 7th tends to octave), set the interval to the tension. (Note
that this may go wrong as the chord changes)
Note that the "interval" is stored one less than what we call it.
*/
if( iPrevInterval == 3 ) then
iInterval = 2
elseif( iPrevInterval == 6 ) then
iInterval = 7
else
INTERV2:
iInterval table rnd(ftlen(3)), 3
cigoto ( iInterval < 0 ), INTERV2
endif

/*
Fetch what the chord here it is and calculate the tone to be played.
If the interval with the previous note is bigger than octave,
then choose the interval again randomly.
*/
iRootIndex table iPosition/p3, giftMelody, 1, 0, 1
iPitch table iRootIndex + iInterval, giftScale
cigoto ( abs( iPitch - iPrevPitch ) > 12 ), INTERV2

/*
Decide the length of this note.
For disonant tones (those not in the triad chord of the given root),
set the length of it short.
*/
if( iInterval != 0 \
&& iInterval != 2 \
&& iInterval != 4 \
&& iInterval != 7 \
) then
iDur = iUnit
else
iDur = (int(rnd(3))+1)*iUnit
endif

kAmp expseg 0.01, 0.1, 1, iDur-0.2, 0.25, 0.1, 0.01

iFreq = iBaseFreq * giSemiTone ^ iPitch
kVibEnv linseg 0, 0.3, 0, iDur-0.3, 0.5
kVibAmp lfo kVibEnv, 10
kFreq = iFreq * ( 1 + kVibAmp )

kForm line 600, iDur, 800
kBand line 60, iDur, 80
aSig2 fof iAmp * kAmp, kFreq, kForm, 0, kBand, \
0.005, 0.02, 0.07, 64, 14, 15, iDur


if( iDur > 0.3 ) then
gaSig = gaSig + aSig2 / 2
endif
iPosition = iPosition + iDur
iPrevPitch = iPitch
iPrevInterval = iInterval
timout 0, iDur, CONT2
reinit INIT2
CONT2:
rireturn

; ---------------------------------------------------------------------
iPosition3 = 0
iPrevPitch31 = 0
iPrevPitch32 = 0
INIT3:
/*
Decide 2 tones to play.
floor(rnd(3))*2 is used to decide the semitones with the root would be,
that is, they're deciding whether the the interval is 1st, 3rd, or 5th.
*/
iRootIndex3 table iPosition3/p3, giftMelody, 1, 0, 1
iPitch31 table iRootIndex3 + floor(rnd(3))*2, giftScale
iPitch32 table iRootIndex3 + floor(rnd(3))*2, giftScale
iFreq31 = iBaseFreq * giSemiTone ^ iPitch31 * 2 ^ floor(birnd(1))
iFreq32 = iBaseFreq * giSemiTone ^ iPitch32 * 2 ^ floor(rnd(2))

kAmp3 linseg 0, 0.2, 1, iUnit-0.2, 0
aSig31 oscil iAmp*kAmp3, iFreq31/2, 13
aSig32 oscil iAmp*kAmp3, iFreq32/2, 12

if( iFreq31 < 220 ) then
gaSig = gaSig + aSig31 * abs( 220 - iFreq31 ) / 220
endif

iPrevPitch31 = iPitch31
iPrevPitch32 = iPitch32
iPosition3 = iPosition3 + iUnit
timout 0, iUnit, CONT3
reinit INIT3
CONT3:
rireturn
aSig3 = ( aSig31 + aSig32 ) / 2


aSig sum aSig1/2, aSig2, aSig3
kAmp linseg 1, p3-4, 1, 4, 0.01
aSig = aSig * kAmp
out aSig
endin

instr 101
aSig reverb gaSig, 0.5
out aSig
gaSig = 0
endin


</CsInstruments>

<CsScore>
/*
Function table 1 and 4:
Stores the roots of the chords by the index of the note in f2.
By using GEN7 and big enough table, we can then set the chord to change
in a nonregular way, that is, chord may change not only at the 1st beat
of a bar.
*/
f 1 0 64 -7\
3 8 3 0 \
7 8 7 0 \
8 8 8 0 \
7 8 7 0 \
6 8 6 0 \
5 8 5 0 \
6 8 6 0 \
7 4 7 0 \
0 4 0

f 4 0 16 -7\
3 4 3 0 \
1 4 1 0 \
6 4 6 0 \
7 2 7 0 \
0 2 0

f 5 0 32 -7\
6 4 6 0 \
7 4 7 0 \
3 2 3 0 \
2 2 2 0 \
1 4 1 0 \
6 4 6 0 \
7 4 7 0 \
3 8 3

/*
Function table 2
Stores major scale in numbers of semitones
between the tonic and each one.
*/
f 2 0 16 -2 \
-5 -3 -1 0 2 4 5 7 \
9 11 12 14 16 17 19 21

/*
Function table 3
Stores the probability of an interval to be used.
More a number appears, more the inteval would be used.
*/
f 3 0 64 -7 \
0 5 0 0 \
1 5 1 0 \
2 10 2 0 \
3 3 3 0 \
4 7 4 0 \
5 12 5 0 \
6 2 6 0 \
7 8 7 0 \
-1 64 -1

/*
Function tables for timbre
*/
f 11 0 8193 10 1 0.5 0.25
f 12 0 8193 10 1 0.1 0.2 0.3 0.4 0.3 0.2 0.1
f 13 0 8193 10 1 0.4 0.3 0.2 0.1
f 14 0 8193 10 1
f 15 0 8192 19 0.5 0.5 260 0.5


i 1 0 16
i 2 0 16 75 220
i 101 0 17
e

</CsScore>
</CsoundSynthesizer>
......
... read more

超級馬利

發信人: emch.bbs@bbs.mis.cycu.edu.tw (頑酷籽弟) 看板: Joke
標 題: 我心中的超級馬利
發信站: 中原資管森林站 (05/24/07 16:44:04 Thu)

一日, 兩個滿臉鬍渣, 骯髒拉塌的男人來到了號稱和平的庫巴帝國.

"老哥, 你看這裡好極了. 金幣, 到處都是金幣..."

"媽媽米啊, 我們發了, 路易."

"不過你看那邊有一些長得不怎麼樣的小東西, 要怎麼下手?"

"老弟, 不用擔心, 就殺了他們吧."

叫做馬利的紅衣矮胖男人貪婪的眼神令人作嘔.

"但是老哥, 要是出了意外..."

"不用怕." 咪著眼睛的馬利舔了手中的金幣, 不懷好意的說...

"路易, 這一百個金幣買一條命. 有錢, 老子最大."

話未說完, 便將手中握著的香菇吞了下去.

此乃庫巴王國盛產的千年靈芝, 吃下去後可以變成巨人, 力大無窮.

只見瑪利滿口妖氣吐出, 身體驚人的膨脹, 一瞬間從五短身材變成身高兩米三的巨人.

這一旁的路易大驚, 連忙摸了一邊的白花.

這下不同凡響, 此乃萬年魔花, 接觸者妖魔化後, 能手擲十億度的火球.

兩兄弟大喝一聲, 便向前衝.

"唉呀, 客人您好, 想必是外地來的..."

這小蘑菇不知人心險惡, 一瞬間便化作攤血泥.

一旁綠龜還來不及出聲, 一記結實的火球向自己身邊襲來, 瞬間被燒成了灰.

兩兄弟知道得逞, 對目而笑, 便加速向前殺去.

這當中更服用恐怖的毒品無敵星星減低敵人抵抗帶來的痛苦, 大肆破壞磚瓦.

"住手! 不要傷我同胞!"

此人乃庫巴, 威風凜凜, 王國之最強者.

狼腰虎背, 擅擲小槌, 並能噴火, 平日愛民如子.

"賊龜, 今日要你看看我兄弟的利害!"

三強者兩方交手, 電光火石, 打得驚天地泣鬼神, 一時間城堡內風雲變色, 好不緊張.

"路易, 俺抱住他, 快向他頭部丟火球."

馬利從後面拉住了庫巴的尾巴, 要路易趁機給致命的一擊.

"哼!"

路易翻身一跳, 盡不是跟著攻擊, 而選擇取斧斷橋.

庫巴見馬利一起落下, 連忙將他捉起, 寧以自己的肉身承受火海之苦,

也不希望馬利就此喪命.


"路易, 幹什麼!"

"老哥, 你不過是個矮子, 卻處處搶我東西, 我不滿你很久了. 現在你就犧牲吧."

眼淚掉下來了. 但是哭泣的, 是一代霸王庫巴.

"兄弟如此無情無義, 此乃椎心之痛, 我心不忍啊."

於是在大梟雄馬利的救命聲中, 兩人一同沉入熔炎深處.

路易笑了兩聲, 發現城內有一妙齡女子哭泣.

"小姐, 給虧嗎?"

女子抬頭, 唇眸皓齒, 氣質高雅, 姍姍說道:

"我夫君庫巴出戰, 如今音訊全無..."

這廝路易淫笑兩聲, 向前踏一步, 動手撕開少女的洋裝, 色欲橫流.

"你是誰, 為什麼這麼作?"

"我是誰?" 路易冷笑了三聲.

"我是世界上最強的路易. 為什麼這麼作?"

"因為, 我是水電工啊."

少女的氣息漸漸從城堡當中消失.

留下的, 是被扭曲的英雄傳說...

--
※ 來源:‧中原資管森林站 bbs.mis.cycu.edu.tw‧[FROM: 220-138-32-164.dynam]
......
... read more