Archive for the 'Techy 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!
?>
[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
?>
Counter-Strike starts up in black screen
When you start your Counter-Strike and if it’s always a black screen, then you’re most likely stuck in Direct 3D mode. To fix this, you would have to set it back to OpenGL for renderer. However, you’re most likely unable to due to the black screen.
To fix this:
- Go to your Steam (not the game, just Steam) and go to the My Games tab.
- Right click on Counter-Strike and go click Properties.
- A new box should pop up. Now click Set launch options…
- In the following box that pops up, type -dxlevel 9.0 and click Ok when you’re done.
- Launch Counter-Strike normally, and enjoy!
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:
- Select the table wp_conhnp_options in your Wordpress database.
- Click the Search tab.
- Below, look for option_name and in the corresponding text field, type in: upload_path
and then click Go. - You should now see one record/row, click the little pencil on the left of the red x to edit.
- 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
- Be sure to click Go before exiting and then check if everything’s running smoothly.
Facebook Advertising is Inconsistent
There’s a big potential in the Facebook advertising platform, but there’s still a long way to go. I’ve been playing around with Facebook ads lately and I have concluded that Facebook advertising is very inconsistent. However, it may be the season that’s causing such fluctuations and differences within the results. Regardless, I’ll either continue through the Christmas season or stop until the Christmas season is over. What I did notice though was that Facebook advertising isn’t strong or any good at all for direct sales of products. However, it works better with free services, but not as well for paid services.
Thinking from a consumer’s point of view. If I wanted to buy something, I wouldn’t go to Facebook to find ads for my purchase. I would use a search engine instead. There’s absolutely no reason for me to even touch those ads. However, on rare occasions, an ad would catch my eye and I would click on the ad to see what is it about, but I would never buy something through Facebook ads just because that’s me. On the other hand, I normally would ignore most ads whether it is on Facebook or not, but I do enjoy analyzing some them and figuring out it’s target audience.
No commentsChange Firefox’s Address Bar’s Default Search
Today, I was trying to declutter my Firefox. Since you can search using your address bar (the bar where you type the web address), then I decided to take away the dedicated search bar on the right of the address bar. However, when I typed in a keyword and hit enter, it would use Yahoo has the default search engine, but I wanted Google instead. With no further delays, here’s how to change your Firefox’s address bar’s default search.
1. Type about:config in Firefox location bar and press Enter
2. Type keyword.URL in Filter textbox to find keyword.URL.
3. Double-click on keyword.URL and change the value to: http://www.google.com/search?q=
Also, you can change it to Google’s I’m Feeling Lucky search- just use: http://www.google.com/search?btnI=I%27m+Feeling+Lucky&q=
That’s it! Now give it a test drive!
No commentsInstall Digsby without crapware!
Recently, Digsby decided to add a bunch of crapware into their installation. It’s very understandable considering they need to make a living too, but don’t let the crapware turn you off. Digsby is still an excellent program and it’s the best IM (instant messaging) client out there. It’s so robust, fast, and easy to use. Having Digsby handle all your social internet communications in one place is an absolute ease! It just simplifies life and even speeds up your computer since you wouldn’t have to load 5 different instant message programs. Digsby can handle instant messaging (AIM, MSN, Yahoo, ICQ, Google Talk, Jabber, and Facebook Chat), e-mail (Hotmail, Gmail, Yahoo Mail, AOL/AIM Mail, IMAP, and POP ), and even social networks (Facebook, Twitter, MySpace and LinkedIn accounts)! Anyways, without further ado! I shall show you the way of the crapless install of Digsby. Read more
No comments