how to Latest Entries
Nov 13, 2011
Web Design
Update: There is an undocumented ID of your channel playlist which is available in the current beta version of YouTube UI as described by Federico in the comments.
For some reason YouTube doesn’t offer a simple way to embed your YouTube channel. The only official method is to manually create a playlist with all your videos and embed that. However, it requires additional work after every upload which is not cool, especially if you’re on a mobile. Here is a simple script that creates an HTML5 (iframe) player using the YouTube API:
(function() {
function createPlayer(jqe, video, options) {
var ifr = $('iframe', jqe);
if (ifr.length === 0) {
ifr = $('<iframe scrolling="no" frameborder="no">');
ifr.addClass('player');
if (options.playeropts)
ifr.attr(options.playeropts);
}
var src = 'http://www.youtube.com/embed/' + video;
if (options.playopts) {
src += '?';
for (var k in options.playopts) {
src+= k + '=' + options.playopts[k] + '&';
}
}
ifr.attr('src', src);
jqe.append(ifr);
}
var defoptions = {
autoplay: false,
user: null,
player: createPlayer,
playeropts: {},
loaded: function() {},
playopts: {
fs: 1,
showinfo: 1,
modestbranding: 1
}
};
$.fn.extend({
youTubeChannel: function(options) {
var md = $(this);
var allopts = $.extend(true, {}, defoptions, options);
$.getJSON('http://gdata.youtube.com/feeds/api/users/' + allopts.user + '/uploads?alt=jsonc&v=2', null, function(data) {
var videos = [];
var playlist = '';
$.each(data.data.items, function(i, item) {
videos.push(item.id);
if (i > 0)
playlist += item.id + ',';
});
allopts.playopts.playlist = playlist;
allopts.player(md, videos[0], allopts);
});
}
});
})();
$(function() {
$('#player').youTubeChannel({user:'kasparsdambis', playeropts: { width: 400, height: 280 }});
});
#
Nov 9, 2011
WordPress

One putukrejums.lv blog we use the ‘sticky’posts to add introductory information to all category pages (see here, for example). This approach is better than using the category description field because it allows for all the usual formatting options. Read more »
#
Oct 24, 2011
Meta, Web
Knowing who is talking about your blog or website on Twitter is easy — simply subscribe to the following RSS feed:
http://search.twitter.com/search.rss?q=konstruktors.com
Replace konstruktors.com with your own domain.
#
Oct 16, 2011
WordPress

Photo credit added automatically to every photo with a caption (via putukrejums.lv)
Crediting and linking the source of any republished photo or illustration on the web is one of the most important best practices of web publishing. Unfortunately, there isn’t a standard way of doing it in WordPress and authors are left with their own decision on how and where to credit the original author or website. Read more »
#
Oct 2, 2011
Web Design
This is a known Webkit bug — any text with @font-face applied will be rendered without anti-aliasing if there is a text element without anti-aliasing applied preceding it. Usually those are fonts smaller than 5px or monospaced fonts at small sizes which are rendered without anti-aliasing.

I noticed this bug on this page — the heading “Kāzu ABC” was rendered aliased despite having the main menu in between that heading and the logo which had font-size:1px; applied. The only way to fix this is by avoiding aliased text directly before elements that use @font-face.
Here is a live demo of the bug.
#
Sep 8, 2011
WordPress
add_filter('get_previous_post_where', 'remove_stickies_adjacent');
add_filter('get_next_post_where', 'remove_stickies_adjacent');
function remove_stickies_adjacent($where) {
return $where . ' AND p.ID NOT IN (' . implode(',', get_option('sticky_posts')) . ')';
}
#
Mar 20, 2011
WordPress
Inline CSS and line breaks <br style="clear" /> that are automatically added to the image galleries in WordPress is an example of how the needs of Automattic and WordPress.com influence the way new features are added to the WordPress core. So instead of editing every single theme on WordPress.com and adding the necessary CSS for galleries to look good in all of them, they decided to put it WordPress core.
Here is how to replace those double line breaks with a single <br /> and remove the inline CSS:
add_filter('the_content', 'remove_br_gallery', 11);
function remove_br_gallery($output) {
return preg_replace('/(<br[^>]*>\s*){2,}/', '<br />', $output);
}
add_filter('use_default_gallery_style', '__return_false');
#
Mar 16, 2011
Web
I wrote this little (quick & dirty) PHP command line utility to migrate around 10 email accounts from my IMAP server to Google Apps.
#
Feb 28, 2011
Web Design
There are several plugins out there that allow you to replace the WordPress logo on the login screen. Here is a simple way to replace that logo with your site’s name — place this in your theme’s functions.php:
add_filter('login_headerurl', 'my_login_url_local');
function my_login_url_local() {
return get_bloginfo('url');
}
add_filter('login_headertitle', 'my_login_title_attr');
function my_login_title_attr() {
return esc_attr(get_bloginfo('name'));
}
add_action('login_head', 'my_style_site_name');
function my_style_site_name() {
?>
<style type="text/css">
h1 a { width:auto; height:auto; text-indent:0; overflow:visible; text-decoration:none; color:#666; display:block; margin:0; padding:0 10px; background:none; }
h1 a:hover { color:#000; background:none; }
h1 { font-family:'helvetica neue', arial, sans-serif; font-weight:bold; text-align:center; font-size:2em; width:310px; position:relative; right:-8px; margin:0 0 1em 0; }
</style>
<?php
}
Here is how it will look:

#
Feb 17, 2011
Web Design, WordPress
Built-in search engines of WordPress, Drupal and other content management systems are good, but not as good as Google. Here is a simple way to create a Google search form that will return results only from your site:
<form name="google-search" method="get" action="http://www.google.com/search">
<input type="hidden" name="sitesearch" value="http://yourdomain.com/" />
<input name="q" type="text" />
<input type="submit" name="sa" value="Google" />
</form>
which will look like this:
This form does redirect your visitors to Google, but the results returned are only from your site, so there is nothing to worry about. And with Googling indexing blogs almost instantly, there are actually very little drawbacks from using this approach for site search.
#