Posts tagged ‘trick’
Websites, that aggregate something become more and more popular because we need all information available in one place and accessed fast and easily. From time to time, you come across with tasks, that require retrieving some data from the password-protected area. For example, I use Guru.com for my job search. They post lots of the projects there, but they don’t offer convenient listing and filtering. So I developed my own tool, that grabs everything from there and ranks it all in the way I need. So, we’ll take a look at different types of password-protected areas and see how to deal with any of them
Continue reading ‘Grabbing password-protected content with cURL’ »
Posted by Konstantin Mirin on May 24, 2009 at 9:00 AM under PHP, Programming.
Tags: experiece, PHP, tip, trick, tutorial
10 Comments.
OOP is a great concept, it simplifies the programmer’s life, especially in the field of interface development. Nearly all modern web-interfaces use JS in some way - for field highlighting, validation, help etc. It’s OK when there are such simple things.
And now imagine, that we have a set of dialogue windows (HTML+CSS) for adding a comment, rating, sending to the friend. Each of these boxes has a number of functions - check if user is logged in(if not - show login form), send AJAX request, process response, show error/success messages, position the box on the page etc.
Continue reading ‘OOP in jQuery’ »
Posted by Konstantin Mirin on April 30, 2009 at 10:19 PM under JavaScript, UI, jQuery.
Tags: framework, jQuery, OOP, tip, trick, workaround, yui
1 Comment.
I bet you didn’t know, that switch can be used to answer the question: “Which of the N following statements is true?” Continue reading ‘Trick with php switch()’ »
Posted by Konstantin Mirin on March 6, 2009 at 12:41 PM under PHP.
Tags: PHP, tip, trick
3 Comments.
As you know, PHP can return only one value from the function. However, there is a simple workaround - we return an indexed array from function and immediately split it into variables using list():
-
-
function ret()
-
{
-
//something useful here
-
return array($varA,
$varB);
-
}
-
list($a,
$b) = ret
();
//we’ll have $varA in $a and $varB in $b after this
-
Posted by Konstantin Mirin on March 6, 2009 at 9:38 AM under PHP, Programming.
Tags: Add new tag, PHP, tip, trick
Comment on this post.
Yesterday I’ve read a post on The Developer’s Day blog. Then tested this thing in Yii. There is a jQuery in my application, so I created test controller and test action, that only outputted “Hello, world” and called it from the firebug console Continue reading ‘Speeding up Yii or why should you use DB sessions’ »
Posted by Konstantin Mirin on March 5, 2009 at 6:02 AM under Databases, PHP, Yii.
Tags: DB, production, session, tip, trick, Yii
11 Comments.
Nearly every large application has some configuration parameters - site admin email, cache time for different blocks, number of latest news, number of items per search or catalogue page etc.
Continue reading ‘Handling Application Parameters in Yii - Using the Database’ »
Posted by Konstantin Mirin on March 4, 2009 at 11:48 AM under Databases, Yii.
Tags: DB, extension, framework, tip, trick, Yii
12 Comments.
In Yii you can have all your JS and CSS files together with your PHP. For example, you have some view in /views/user/create.php and you can have your css & js in /views/user/assets/css/ and /views/user/assets/js/. That’s quite convenient when you reuse your views/controllers/components from application to application. But these directories are not accessible from the web, so there is publishing mechanism there. Continue reading ‘Registering group of JS files in Yii’ »
Posted by Konstantin Mirin on March 3, 2009 at 3:27 PM under Yii.
Tags: framework, tip, trick, Yii
3 Comments.
One of the ways to make your blog more search engines friendly is to take cate of your <title> tag. That’s what’s showin in the browser’s window title. By default, wordpress shows Blog name on the homepage and [BolgName] > Blog archive > [PostTitle] on the posts page (the most important to us). Best variant is to show only post title or ctegory title in the <title> tag, without any blog name. Best variant to do this is to install All in one SEO Pack and configure everything there. However, if you can’t/don’t want do this, you can do one simple change.
- Go to Design->Theme Editor if you have version less, than 2.7 or Appearance -> Editor if you have 2.7.
- Choose file header.php
- Find line <title>…..
- Replace this line with these two:
-
-
<?php if (($t = wp_title(" ", false)) == ”){$t = get_bloginfo(’name’);} ?>
-
<title><?php echo $t; ?></title>
-
- You’re done!
Further reading - wordpress reference
Posted by Konstantin Mirin on February 26, 2009 at 6:02 PM under Wordpress.
Tags: seo, tip, title, trick, Wordpress
5 Comments.
Recently I’ve learned one nice trick with for loop. When you use it, you should know he number of itereations. Most people do it like this:
-
-
-
$s =
sizeof($a);
//you may use count(), but sizeof if 5% faster
-
for ($i = 0; $i < $s; $i++)
-
{
-
//do something clever here
-
-
‘;
-
}
-
But this requires counting number of elements before using a loop. Continue reading ‘Nice trick with FOR loop’ »
Posted by Konstantin Mirin on February 20, 2009 at 9:28 AM under JavaScript, PHP, Programming.
Tags: FOR loop, programming technique, tip, trick
7 Comments.