|
|
| [solution][ubuntu] How to get the buttons at the right place? |
Author
ramon fincken
:: Posted: Thu Sep 09, 2010 7:27 pm
:: Category: Lounge
Tagged: button, buttons, close, left, maximize, menu, minimize, move, right, side, tool, ubuntu
This is one of the things I am not so fond of ..
so here is the cure!
Open a command box and enter this:
| Code: | gconftool-2 --set /apps/metacity/general/button_layout --type string menu:minimize,maximize,close
|
|
| [solution][snipplet] function update_twitter_status() using the API |
Author
ramon fincken
:: Posted: Mon May 24, 2010 11:59 am
:: Category: PHP coding
A simple function to update your twitter status using the API:
Thanks to http://woork.blogspot.com/2007/10/twitt...-page.html
| Code: |
/**
* A simple function using Curl to post (GET) to Twitter
* Kosso : March 14 2007 http://woork.blogspot.com/2007/10/twitter-send-message-from-php-page.html
* Ramon Fincken http://www.ramonfincken.com/permalink/topic215.html
* Warning: make sure your message is not more then 140 chars!
*/
function update_twitter_status($username,$password,$message,$mailto = NULL){
$message = substr($message, 0, 140);
$host = "http://twitter.com/statuses/update.xml?status=".urlencode(stripslashes(urldecode($message)));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);
// Look at the returned header
$resultArray = curl_getinfo($ch);
curl_close($ch);
if($resultArray['http_code'] == "200"){
$twitter_status='Your message has been sended! <a>See your profile</a> http://twitter.com/' . $username;
} else {
$twitter_status="Error posting to Twitter. Retry";
}
if(isset($mailto))
{
mail($mailto, 'twitter sent', $twitter_status);
}
return $twitter_status;
}
|
|
| [solution][snipplet] function has_gravatar() |
Author
ramon fincken
:: Posted: Sun May 23, 2010 4:32 pm
:: Category: PHP coding
Looking for an elegant method to see if a user has a gravatar or not ..
I stumbled upon this url: http://codex.wordpress.org/Using_Gravat...a_Gravatar
> | Quote: | | The trick to do this is to specify "404" as the default. In this case, the gravatar service will return a 404 error if no gravatar exists, instead of returning some default image. A real image will get a 200 code. It is best to check for 200, as some other errors might be returned as well, for other cases. |
| Code: |
function validate_gravatar($email) {
// Craft a potential url and test its headers
$hash = md5($email);
$uri = 'http://www.gravatar.com/avatar/' . $hash . '?d=404';
$headers = @get_headers($uri);
if (!preg_match("|200|", $headers[0])) {
$has_valid_avatar = FALSE;
} else {
$has_valid_avatar = TRUE;
}
return $has_valid_avatar;
} |
Works great, alltough I would have named the function has_gravatar($email); or user_has_gravatar($email);
So this is the code I use at http://www.ikzoekeensportpartner.nl :
Warning: you cannot simply copy paste this code below, but if you are a PHP coder, you'll know what to do
| Code: |
/**
* Checks if user has a gravatar or not
* @return boolean
*/
function has_valid_gravatar($email) {
// Craft a potential url and test its headers
$hash = md5($email);
$uri = 'http://www.gravatar.com/avatar/' . $hash . '?d=404';
$headers = @ get_headers($uri);
if (!preg_match("|200|", $headers[0])) {
$has_valid_avatar = FALSE;
} else {
$has_valid_avatar = TRUE;
}
return $has_valid_avatar;
}
/**
* Returns gravatar OR default avatar url (if no gravatar found)
*/
function create_gravatar_url($email, $size) {
$rating = 'R';
global $default_gravatar;
if (validate :: email($email)) {
if (overall :: has_valid_gravatar($email)) {
return $url = "http://www.gravatar.com/avatar/" . md5($email) . "?r=" . $rating . "&default=" . $default_gravatar . "&size=" . $size;
}
}
return $default_gravatar;
} |
|
| Forum |
Topics |
Posts |
Last Post |
| General forums |
|
 |
About this blog
Moderator ramon fincken |
4 |
4 |
Mon Jan 05, 2009 5:47 pm ramon fincken  |
 |
Lounge
Chit - chat
Moderator ramon fincken |
51 |
68 |
Thu Sep 09, 2010 7:27 pm ramon fincken  |
 |
Reviews
Movie reviews - Goodie reviews and much more !
Moderator ramon fincken |
5 |
5 |
Sun Oct 11, 2009 8:00 pm ramon fincken  |
 |
Rants
Rants about things in daily life ...
|
5 |
11 |
Sun Mar 21, 2010 10:12 pm ramon fincken  |
| The world of freelance |
|
 |
Freelancing
Moderator ramon fincken |
2 |
2 |
Wed Jan 21, 2009 9:52 am ramon fincken  |
 |
Coping with clients
Moderator ramon fincken |
1 |
1 |
Thu Jan 08, 2009 12:00 pm ramon fincken  |
 |
Services
I offer many webdevelopment services such as custom coding, photoshop webdesign and W3 valid slicing and basing !
Feel free to ask for a quote !
Moderator ramon fincken |
1 |
2 |
Sun Mar 21, 2010 2:00 pm ramon fincken  |
| Programming |
|
 |
PHP coding
Moderator ramon fincken |
59 |
70 |
Sun Sep 05, 2010 2:45 pm ramon fincken  |
 |
Mysql databases
Moderator ramon fincken |
6 |
6 |
Sat Feb 20, 2010 3:04 pm ramon fincken  |
 |
HTML and other markup&programming languages
Moderator ramon fincken |
15 |
15 |
Sun Jan 24, 2010 8:02 pm ramon fincken  |
 |
Control panels (plesk, cpanel, direct admin)
Moderator ramon fincken |
4 |
6 |
Thu Oct 30, 2008 11:53 pm ramon fincken  |
 |
CMS-ses (Joomla, WordPress, etc..)
Moderator ramon fincken |
28 |
41 |
Mon Aug 16, 2010 8:59 pm ramon fincken  |
| Other projects |
|
 |
Antispam
Moderator ramon fincken |
5 |
5 |
Tue Aug 18, 2009 1:12 pm ramon fincken  |
 |
Other projects
Moderator ramon fincken |
11 |
19 |
Sat Aug 28, 2010 1:59 pm ramon fincken  |
| Who is Online |
 |
Our users have posted a total of 259 articles We have 12 registered users The newest registered user is accentmedia
|
In total there are 7 users online :: 0 Registered, 0 Hidden and 7 Guests [ Administrator ] [ Moderator ] Most users ever online was 40 on Tue Jan 05, 2010 11:59 pm Registered Users: None |
| This data is based on users active over the past five minutes |
 |
New posts |
|
 |
No new posts |
|
 |
Forum is locked |
|
|
|