save arrays into database

i’ve known this for a while but forgot to share it. there is a very easy way you can store array into database as a string. then you can grab the string from the database and convert it back into an array.

code example:

<?php 
$myarray[] = "meow"; 
$myarray[] = "woof"; 
$myarray[meow] = "cool"; 
$myarray[woof] = "cool"; 
$myarray[thisrules][0] = "Mmmm"; 
$text_myarray = serialize($myarray); 
// store it into my database (depend on the length of your array, declare the column as text or varchar) 
// pull it out of my database, suppose $out_of_my_database stores the text from your database column 
// then $get_myarray = unserialize($out_of_my_database); echo "<pre>"; print_r($get_myarray); 
?>

you should get

Array
(
    [0] => meow
    [1] => woof
    [meow] => cool
    [woof] => cool
    [thisrules] => Array
        (
            [0] => Mmmm
        )

)

record streaming audio and more

ever wondered how you can grab streaming audio and convert it to mp3? or how to convert .rm to .mp3? well here’s my way of doing it. you need the wonderful softwere Total Recorder. it allows you to record anything that is played by your sound card. ^_^

download: the version i have is 4.1b standard edition (1.03mb includes tutorial. the actual exe is only 0.98mb)

here’s a short tutorial for how to get started once you have it installed.

Once installed, the first thing you need to do is set your playback to use total recorder
Continue reading

return to top link without bookmark

i saw this on leslie’s site. i never thought of it before. the conventional way to do a “return to top” link is create a bookmark with:

<a name="top"></a>

at the top of the page and then use:

<a href="#top">Return to Top</a>

to link it.

well there’s an easier way. this only works if you want to return to the very top of the page. it obviously does not replace the functionality of bookmarks.

<a href="#" onclick="window.scrollTo(0,0);return false;">Return to Top</a>

Since the latter one uses javascript therefore it will not work on browsers with javascript disabled.

congratulations andy!

today’s andy’s last day at his old job – auto technician for iowa city toyota shop. monday he’s gonna start a new desk job as a customer service for toyota financial (headquarter) with a pay raise and lots more benefits. i’m so proud of him ^_^

welcome to cubicle life XP. you get wonderful deals if you wish to lease or purchase a brand new toyota working there. lease also includes insurance and registration. well i’m sure i will find out more about it once he starts his job.

separate template from code

when you do serious coding, it’s always a good idea to separate your layout design (template) from your logic code. i’m at the beginning stage rebuilding dmb. one thing i want to do very badly is to get rid of all templates in the database. every time i load a template right now it causes me a query. i want to store my templates in files because file_get_contents is less expensive than a query. and i just figured out a very easy way to do that.

store your template in a file. it can be html, text or php, whatever suits your need.

put this in your html file, name it “test.html”

this is so $test

and then use the code below:

<?php 
$test = "cool"; 
$meep = file_get_contents("test.html"); 
eval("\$meep = \"$meep\";"); 
echo $meep; 
?>

and it will print out “this is so cool” ^_^

new plan for dmb

thanks shi for being so sweet and supporting. maybe i’m being too pessimistic on dmb’s coding. yes it is inefficient but it’s still curable. if i re-plan the whole thing from database design to layout design (javascript, css) with all my knowledge i can probably improve its performance by 200%. and shi told me another domain name more appropriate for dmb is available and she’s gonna give me a testing space :)

since regretless.org is going to expire in august, i will set that day to be my goal to have dmb moved to the new system ^_^

i will have to remove some of the unnecessary hacks such as buddyland, theme background music etc. basically anything that did not perform very well in the past will be taken out. i will leave the most essential parts and we will start from there. i will probably need some beta testers before it’s launched. so if you are interested, leave a comment :)

critical mass

when a codebase gets so large and unmanageable, that it’s impossible to work with. Of a software product, describes a condition of the software such that fixing one bug introduces one plus epsilon bugs. When software achieves critical mass, it can never be fixed; it can only be discarded and rewritten.

yes that’s how i feel about dmb right now. a bit sad but more reflecting. it doesn’t surprise me if the total solid coding time i spent on that site is over 10,000 hours.

the foundation of dmb, the now extincted software devbb, was very poorly written. back then i didn’t know better so when i first started hacking i wasn’t concerned with its efficiency. time goes on, i was more focused on getting “cool” features implemented than making the code more efficient. i guess for the most part, you can’t blame me. i was a naive and new coder and no one really gave me a heads up. the recent server move for dmb really got me thinking. no this is not the first time i thought about how inefficently is dmb coded but it just hit me, if it keeps growing like this, eventually it will break or it will be too big for me to handle.

i’ve considered rebuilding the board with another bb software like phpbb. but how much time will that take to make it to today’s standard? i also question my ability. how much more efficient can i make it if i were to rebuild it? what happens when technology gets even more advanced in the future? am i gonna have to rebuild it again?

my feeling toward dmb is so mixed. sometimes i imagine myself running dmb until i’m retired. other times i feel eventually i will let it go. maybe one day my amibition will die down tho i know i will always love programming.

multi-page form submission trick

someone asked on my board how to use an email script for a long form that expands into multiple pages. leslie gave me an idea which i played and got it working. it’s very cool :) You basically just make *fake* pages with javascript and div layers. the script is from alexking and i put everything together. want to see an example?

take a look at my demo for dodosmail 2