Dougy Mak’s Blog

MY BLOG!

Archive for the 'Website Stuff' Category

[PHP] Uppercase & Lowercase

Another few functions for I find useful:

  • ucfirst() – Make a string’s first character uppercase
  • lcfirst() – Make a string’s first character lowercase
  • strtolower() – Make a string lowercase
  • strtoupper() – Make a string uppercase
  • ucwords() – Uppercase the first character of each word in a string

From the looks of things, ucfirst() was coined from it’s function uppercase first letter (unlike some functions!). So goes for lcfirst() and ucwords(): lowercase first letter and uppercase first letter of each word. strtolower() lowercases every letter in every word in a string and strupper() functions in opposite, uppercases each letter in every word in a string.

ucfirst() examples:

<?php
$foo = 'hello world!';
$foo = ucfirst($foo); // Hello world!

$bar = 'HELLO WORLD!';
$bar = ucfirst($bar); // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>

lcfirst() examples:

<?php
$foo = 'HelloWorld';
$foo = lcfirst($foo); // helloWorld


$bar = 'HELLO WORLD!';
$bar = lcfirst($bar); // hELLO WORLD!
$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
?>

strtolower() examples:

<?php
$str = "Mary Had A Little Lamb and She LOVED It So";
$str = strtolower($str);
echo $str; // Prints mary had a little lamb and she loved it so
?>

strtoupper() examples:

<?php
$str = "Mary Had A Little Lamb and She LOVED It So";
$str = strtoupper($str);
echo $str; // Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
?>

ucwords() examples:


<?php
$foo = 'hello world!';
$foo = ucwords($foo); // Hello World!


$bar = 'HELLO WORLD!';
$bar = ucwords($bar); // HELLO WORLD!
$bar = ucwords(strtolower($bar)); // Hello World!
?>

No comments

[PHP] Rounding up and down

I just discovered a few cool functions:

  • ceil() – Round fractions up
  • floor() – Round fractions down
  • round() – Rounds a float

I’m guessing ceil() is short for ceiling. When looking up, you have a ceiling whereas when looking down, you have a floor(). The functions’ names correspond to their actual function which makes it pretty easy to remember. And then we also have round which is just basic rounding.

ceil() examples:

<?php
echo ceil(4.3); // 5
echo ceil(9.999); // 10
echo ceil(-3.14); // -3
?>

floor() examples:

<?php
echo floor(4.3); // 4
echo floor(9.999); // 9
echo floor(-3.14); // -4
?>

round() examples:

<?php
echo round(3.4); // 3
echo round(3.5); // 4
echo round(3.6); // 4
echo round(3.6, 0); // 4
echo round(1.95583, 2); // 1.96
echo round(1241757, -3); // 1242000
echo round(5.045, 2); // 5.05
echo round(5.055, 2); // 5.06
?>
<?php
echo round(9.5, 0, PHP_ROUND_HALF_UP); // 10
echo round(9.5, 0, PHP_ROUND_HALF_DOWN); // 9
echo round(9.5, 0, PHP_ROUND_HALF_EVEN); // 10
echo round(9.5, 0, PHP_ROUND_HALF_ODD); // 9echo round(8.5, 0, PHP_ROUND_HALF_UP); // 9
echo round(8.5, 0, PHP_ROUND_HALF_DOWN); // 8
echo round(8.5, 0, PHP_ROUND_HALF_EVEN); // 8
echo round(8.5, 0, PHP_ROUND_HALF_ODD); // 9
?>

No comments

Fear Will Bring Me Down

Fear keeps us from excelling to great heights and limits are potential rewards. Much of the time, I have these big ideas for websites and before even giving a whack at it, I give up.  The thought of all the work it would take and the lack of resources I have access to, it just scares me and I end up scrapping the idea because it would take too long. What scares me more is the huge competitors or the thought of someone out doing me because he/she has the resource and funding. However, overtime I began caring less about these things. I developed a style and a mindset that works for me. I learned to not give a shit about my competitors; I will not let their success intimidate me. No matter how big my competitor is, they can never monopolize. I will always be able to take a part of their audience, even if it’s a tiny bit. There will be people who prefer something about your website over the other. For example, as a consumer, like many other people, I support the local mom and pop shops over corporate chains. I find myself going to a privately owned pizza joint all the time.

Another way I’ve changed is, instead of looking at the big picture as a whole, I’ve broken down the big picture into little pieces. It’s good to see the big picture, but it can be intimidating when thinking about painting it as a whole. However, it may seem less intimidating if I thought about painting small parts of the picture at a time. Paint a corner here and paint a section there and then you’ll begin noticing how these small steps add up and how effective this strategy is. Instead of going crazy about every little problem in the whole picture, worry about a piece at a time. This would provide psychological comfort by helping me calm my mind. The milestone would help me feel like I’m making progress thus producing more satisfaction and having a milestone would help keep me more motivated. So in the end, I have to tell myself: don’t worry about other people, just worry about yourself. Just keep doing what you like and what you’re passionate about and the success will follow.

No comments

Change Wordpress’ ABSPATH

Recently, I had migrated one of my blogs to another host. Everything was going great until I kept getting errors that showed my old host’s absolute path which was weird because I would think Wordpress wouldn’t store something like this. However, it had to do with one of my plugins (Contact Form 7), and I could of disabled it but I didn’t want to because it was an essential part of my blog. I’m guessing the plugin had some sort of interaction with the wp-upload folder. Anyways, I did a search in my MySQL database using PhpMyAdmin for a part of my old host’s absolute path and I found the entry that needed to be updated. It was under wp_conhnp_options table with the value upload_path for option_name. So just go ahead and update it’s value and everything should run smoothly again.

Here are PhpMyAdmin instructions:

  1. Select the table wp_conhnp_options in your Wordpress database.
  2. Click the Search tab.
  3. Below, look for option_name and in the corresponding text field, type in: upload_path
    and then click Go.
  4. You should  now see one record/row, click the little pencil on the left of the red x to edit.
  5. Now update your old absolute path with your new absolute path and be sure that it points to the uploads folder: /home/public_html/dougymak.com/wp-content/uploads
  6. Be sure to click Go before exiting and then check if everything’s running smoothly.
No comments

QR Barcode

A QR Barcode with DougyMak.com link :)
Generated by http://qrcode.kaywa.com/

qrcode

No comments

Slow and easy

The “Slow and easy” concept can be applied to many things in life. I would say it works very great too. I’ve been taking my website slow and easy: occasionally adding content, and updating content as well. I noticed that my adsense revenue has been slowly inclining. However, it fluctuates, well that is natural due to it’s nature. I haven’t really tried building traffic to it. I just pretty much keep adding content because I want to, and then once in a while I’ll go to forums and ask them what do they think about my content, which helps build up some traffic. Bottom line is, for long term ad revenues with websites, you should take it slow and easy. By not implementing ads in the early life of the website, it helps you build more credibiltiy, and it makes the website more reader friendly.

No comments