Archive for the ‘Programming’ Category

Remove Automatic Line Breaks
from Wordpress

authored on Friday, August 21st 2009

This is for me to remember only. Thank God someone had the consideration to post their findings on the internet.

When I code, I like ample spacings between the codes so their are more easily read, but Wordpress reads those spaces as line breaks.

Find this line in your b2functions.php (inside your b2-include folder):
function wpautop($pee, $br=1) {

Replace it with:
function wpautop($pee, $br=0) {

And no more extra line breaks!

This person took 5 hours to find the solution I needed, 5 years ago.

Here’s a link to you!

Remove extra line breaks in WordPress

She Is Such a Delicate Creature

authored on Friday, December 5th 2008

In conjunction with the previous post I was clearing up my database, one of them, the table was 68 MB strong! No matter how I download, I could never make a full backup of it.

However this afternoon I managed to shrink that I didn’t database from 68 MB to only 2.6 MB :-)

you should first understand that in creation of that database, I was very lazy to set the field type appropriately to what I need instead I made most of the fields “text” (which can hold up to 2 million characters) which would bloat up this lady.

The moment I know what I want, and change those text view to “varchar” of only 255 characters, she shrank by 300%! doing the math here that would be 20 MB.

Next , I deleted old archives and that shave off another 10 MB.

Lastly, instead of storing the content I need on the SQL database, I made it to read dynamically. In that sense, I dropped a field from the database.

2.6MB. TADA!

Oh yeah, if I zip the contents, I got it compressed as low as 600 kB

A full day’s work. Now I am a happy man, and she is a gorgeous creature ;)

My Latest Girlfriend ((vibe))

authored on Wednesday, September 24th 2008

Computers these days are so affordable. For just a little over RM3K, I got one that can last me for the next five years!

Nicknamed ((vibe)), she’s got an tough yet elegant body.

My previous PC was a Pentium 4. at least 5 years old. Wondered why I’ve waited so long to buy this one. At last I’m glad I did!

Money wasn’t spared for topping it’s perfromance. This big fan sits on top of the processor. If only it admits a kewl light and a whistle….

One other thing that fasinated me was the size of the mother board.

Or at least it’s box.

Bottom left of the box is a DVD just to show you the size of the box in prespective.

In comparison to the CDROM box, you can imagine how many things I’ve to toll around Low Yat. Bleh

Before it all ends, our stomach comes first before gaming…. yet gaming can make one forget about food and baths, day and night…. even work.

Let the Crysis begin!

Migration was a success!

authored on Monday, February 25th 2008

NO! NO! NO!

I’m not migrating to another country. Hah, most would think so when election’s near. But heyz, I ain’t rich enuf to move.

So what was the success?

YES! YES! YES!

Happy is he who managed to migrate his first MySQL database over to another server without a glitch (I hope).

You see, i was helping someone to setup a website, and I was using a subdomain under one of my sites.

A domain looks like this:

http://tomagogame.com

A subdomain looks like this :

http://subdomain.tomagogame.com

So you blogspot bloggers, you are just a subdomain. It’s free to setup.

So back to my story, they wanna move out on their own de, so I’ve to migrate them outta my server into their own. But what happens to the work already done before migration?

It ain’t as easy as copy and paste.  Almost, but not quite.

Anyways…

Yea, I “copied” and “pasted” and it’s working smoothly.

Thanks to the MySQL guys who made it alllllll so easy to import and export!

I Know What You Clicked Last Summer

authored on Saturday, January 26th 2008

programming is so fun!

Simply by creating a new table, I can now track which link of the Sith or clicks on my website, how long it took him to click that link would tell me if he or she read my article.

This tracking software was created the by me and I am a little proud of it. That is because Google Analytics exists. no matter, as long as he does goes into my database, I can make it customized to what I want to see.

Imagine the placement of your links are so important if you get the right information on which most of your users click on, then you can track what is working and what is not. Should you color your links a different color? should you put your links a little higher?so on and so forth.

It is a little tedious, however like Robert Kyosaki said do more work to do less work. Oxymoron yet true :-)

The Beginning of a Search Algorithm

authored on Friday, January 25th 2008

Building a website is easy!

When you have a database full of articles, posts, and reviews… you will want your users and visitors to search your site instead of finding more information by clicking around.  adding a search box is easy, however producing results from your database is a little tougher.

How to build a mini Google search engine

Here is a simple database structure: ID, title, article

let’s say our precious visitors search for “attracting beautiful women”.

we will have to run multiple queries.

The first query is to search all three words in this same order on the title,

then from the article,

then break up the search to and find in title that contains all keywords in any order,

then break up the search term again find in the article that contains all the keywords in any order.

If the above a few queries does not produce a result, then break up the keywords such to begin and as long as the title contains any one of those keywords or the article that contains any one of those keywords… those should produce results.

What if the user types “sdljklodsfeowirdfkljkldfs dsfkl;dfsldsfpioewfjkfdskfjlsdfkljdsfjkl “?

I can’t even begin to pronounce the word!  But if my algorithm doesn’t produce a result, throw in some advertisements!

be kind to your visitors, baby gift and the gift and send them on their way home :-)

A New Breed of Programmers

authored on Monday, October 29th 2007

Today I had a loooong meeting.

And they are talking about accounting while I’m only in charged of the website.

So I whipped out my laptop and started coding for a site I’m working on.

I fell asleep!

Funny thing was, I was still coding. Yup, sleep programming. Less harzadous than sleep walking and wayyyyy cool.

When I woke up after my short snooze (everyone noticed ofcoz), and what I saw on the computer screen was amist my codes, I actually typed a sentence I ‘heard’ while I was snoozing!

I mean, it looks like this…

$q = mysql_query(”SELECT * FROM admin WHERE approval = ‘1′;”) or die(mysql_error());

while ($r = mysql_fetch call suppliers to start collecting their data

yup yup, part of that second line of code was my ’sleep programming’ programming.

Once again, this time, a million sleeping monkeys, pounding on a million bedsized keyboard, a universe of something will appear!

Hah, yea, right. if the keyboard is plugged in.

The Function That Broke The Programmer’s Back

authored on Thursday, October 25th 2007

Have you ever tried to do something you so passionate about that you forgot about breakfast, lunch, dinner and sleep! Yea, worth the sacrifice right?

Put yourself in the shoes of a programmer, whose passion is to, program, and eats instant noodles for nutrition, coke for hydration. After a few months writing your heart out, you look out the window, you see a lovely couple walking by. In their hand they hold a travel magazine, see them get into a Limo… you wonder why did you start programming in the first place.

One saying says that if a million monkeys pound on a million keyboard, the universe would have a chance to be created.

Ok, back to topic.

Why did you program?

Passion? yea, right, like the monkeys.

Money? It doesn’t seem to be working yet.

Addicted to information? It ain’t getting you no where esspecially if you are not in the ‘in’ group.

So why did that coupling scenario you saw, the comparison between you and them, why the vast difference? Why can he/she make it and you still haven’t?

You can’t just give up what you started.

You ain’t where you wanna be but you aren’t where you used to be either.

So back to your chair you go and you try to write a program. A program that will change the world! A program with many many functions that will make the program a success.

After writing ‘endless’ functions, the fruits ain’t big. Why?!

Dang programming. Dang the functions. Dang 0101011101010101010101!!!

“There’s gotta be more to life” comes to your head.

You got out of your chair, grab your coat, ditched your laptop, went for a movie, played basketball, have a handful of life out there…

2 months later….

Cutting the story short, you are back on your chair programming. Feeling like a monkey (again). Bleh.

What went wrong?

Lack of persistence?

Lack of tools?

Did you stop “3 feet before you struck gold”? YES!

Not many can deny, it is when upon almost giving up is where success is. Ironically, that equates to asking you to fail (dig) faster. Though not blindly, but NEVER GIVE UP!

As long as one monkey is left pounding, something is bound to happen…

THE END.

P.S. You may be wondering what does all these monkey stuff have to do with the title “The Function That Broke the Programmer’s Back”.

Simply put, my back’s *broken* and out comes this ranting. X_X

OKOK, back to work.

Going Back In Time

authored on Sunday, October 21st 2007

Wendy tagged Time Machine on me. The whole objective is that if given a chance, what one time you would want to change if given the chance to go back in time?

I would say that I wished I had studied more and ‘activated’ my passions in programming WHILE still in college.

Lost a few years there.

Nevertheless, things are as they are, and by GOD’s grace, I still got the fire and drive to do something worthwhile.

And here’s something worth mentioning, wish that I could have taken that BIG positive hint from the girl that I liked.

Hah, I let her go. Cheh.

But yesterday is buried with tomorrow. Today, today, today, is the time machine for me! (sounds pathetically fake).

Thanks Wendy for bringing this one out :)

Now to tag… Itchyichitaka, Angeline, Aaron Woo Lala, Daniel

CSS XSS RSS ASS?

authored on Saturday, September 1st 2007

How did you spend your merdeka? Holidaying? Pak Tor-ing? I was ss-sing! In just 3 days I learnt every single of the 4 items listed on the title.

 CSS - Cascading style sheet. Cool stuff. Imagine you want to change all your links color to green, just add in your external style sheet

a:link{
color:green;
}

piece of cake.

XSS - Last known was called Cross Site Scripting, but many people started to get confused between Cascading  Style Sheet and Cross Site Scripting, so they named the latter as XSS. So what’s XSS? basically it’s preventing you from using javascript or any language for that matter to manipulate a page that doesn’t belong to you. For example, you can’t click a button and autofill my search box because… well, that’s XSS for you.

RSS -  Really Simple Syndication. What’s so simple about it? I’ve been on the web for over two years now and I couldn’t really figure out how and what RSS is for until I had my own personal Merdeka these last 3 days. Creating your own RSS feeds means to compile all your information into a file say “rss.xml” with xml standard coding. It’s really simple because everything in the rss.xml has a head and a body.

<title>This is my first rss</title>
<description>Tomagogame? Never heard of him. </description>
<url>http://www.tomagogame.com</url>

so on and so forth. Go google “create my first rss feeds”.

ASS - Ahhhhhhhhhhhhhhhhhhhhh……. I’m sure you and I know what this means. Nope, nothing related to a donkey. It’s a biological chemistry that happens when one consumes a lot. ASS is nothing more than an abbr of ASSimiliation. Digestion. Ingestion.

OKay, the last one was crap but hey, 3 of the 4 were useful stuff and learning how to implement them into my work gives me more added value and thus increase pay.

Comment quickly and you might get a free lunch from me ;)