<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>Do Know Evil - A Blog by Tyler Mulligan &#187; The Internet</title> <atom:link href="http://www.doknowevil.net/category/computers/the-internet/feed/" rel="self" type="application/rss+xml" /><link>http://www.doknowevil.net</link> <description>Tips and Tricks About Computers, Web Development, Linux, the Internet and the Like</description> <lastBuildDate>Sat, 16 Jul 2011 01:25:35 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.5</generator> <item><title>jQuery and jQuery UI in your Grease Monkey scripts.</title><link>http://www.doknowevil.net/2011/07/16/jquery-and-jquery-ui-in-your-grease-monkey-scripts/</link> <comments>http://www.doknowevil.net/2011/07/16/jquery-and-jquery-ui-in-your-grease-monkey-scripts/#comments</comments> <pubDate>Sat, 16 Jul 2011 01:25:35 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Chromium]]></category> <category><![CDATA[Computers]]></category> <category><![CDATA[DOM]]></category> <category><![CDATA[Firefox]]></category> <category><![CDATA[Google]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[The Internet]]></category> <category><![CDATA[Web Development]]></category> <category><![CDATA[css]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[client-side hack]]></category> <category><![CDATA[control]]></category> <category><![CDATA[fix websites]]></category> <category><![CDATA[grease monkey]]></category> <category><![CDATA[lifehack]]></category> <category><![CDATA[stylish]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=985</guid> <description><![CDATA[Not all websites are made equal. Unfortunately, some of those websites are ones we&#8217;re required to use. Be it our job, our interests or the undiscovered, web-browsing can be the orgeon trail of the internet. Cultivating the atmosphere to work for us and bringing the right tools along for the journey are essential for survival,]]></description> <content:encoded><![CDATA[<p>Not all websites are made equal.  Unfortunately, some of those websites are ones we&#8217;re required to use.  Be it our job, our interests or the undiscovered, web-browsing can be the <em>orgeon trail</em> of the internet.  Cultivating the atmosphere to work for us and bringing the right tools along for the journey are essential for survival, if you&#8217;re a pioneer.</p><p>I&#8217;m tired of websites that don&#8217;t provide, can&#8217;t provide or will never provide.   I&#8217;ve called in my boys, <a href="https://addons.mozilla.org/en-US/firefox/addon/stylish/" target="_blank" title="create your own css for websites">Stylish</a> and <a href="https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/" target="_blank" title="create your own javascript for websites">Grease Monkey</a> on the front lines.  However, beyond the crazy happenstance that another user might share a solution to your issue on <a href="http://userstyles.org" title="user styles for stylish" target="_blank">userstyles.org</a> or <a href="http://userscripts.org" title="user scripts for grease monkey" target="_blank">userscripts.org</a> you could be left in the cold, without the right tools.  I won&#8217;t go into detail on Stylish in this post but you might not even need it after you see the script.</p><p>Since I&#8217;m already connected with Google every which way in my life, why not pretend like the Internet is a big party and websites are your friends.  Introduce jQuery from Google&#8217;s CDN to other friends (websites) that don&#8217;t already know jQuery and jQuery UI and <em>make it personal</em>.</p><p>That was the driving force behind this <strong>Grease Monkey Script</strong>, which was derived from mashing together <a href="http://strd6.com/2009/02/how-to-load-jquery-ui-css-in-greasemonkey/">strd6&#8242;s script</a> and <a href="http://joanpiedra.com/jquery/greasemonkey/">Joan Piedra&#8217;s script</a> with an update to the latest versions of jQuery and jQuery UI.</p><pre class="brush:javascript">
// ==UserScript==
// @name           jQuery and jQuery UI
// @author         Tyler &quot;-z-&quot; Mulligan
// @version        0.5
// @namespace      http://www.doknowevil.net
// @description    jQuery 1.6.2 and jQuery UI 1.8.4 loaded from google&#039;s CDN with redmond theme.
// @include        http://www.website.com/*
//
// @resource       jQuery               https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
// @resource       jQueryUI             https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js
//
// @resource       jQueryUICSS          http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/jquery-ui.css
//
// @resource       ui-bg_inset-hard_100_fcfdfd_1x100.png  http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-bg_inset-hard_100_fcfdfd_1x100.png
// @resource       ui-bg_gloss-wave_55_5c9ccc_500x100.png http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png
// @resource       ui-bg_glass_85_dfeffc_1x400.png        http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-bg_glass_85_dfeffc_1x400.png
// @resource       ui-bg_glass_75_d0e5f5_1x400.png        http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-bg_glass_75_d0e5f5_1x400.png
// @resource       ui-bg_inset-hard_100_f5f8f9_1x100.png  http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-bg_inset-hard_100_f5f8f9_1x100.png
// @resource       ui-bg_flat_55_fbec88_40x100.png        http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-bg_flat_55_fbec88_40x100.png
// @resource       ui-bg_glass_95_fef1ec_1x400.png        http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-bg_glass_95_fef1ec_1x400.png
// @resource       ui-icons_469bdd_256x240.png            http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-icons_469bdd_256x240.png
// @resource       ui-icons_469bdd_256x240.png            http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-icons_469bdd_256x240.png
// @resource       ui-icons_d8e7f3_256x240.png            http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-icons_d8e7f3_256x240.png
// @resource       ui-icons_6da8d5_256x240.png            http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-icons_6da8d5_256x240.png
// @resource       ui-icons_217bc0_256x240.png            http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-icons_217bc0_256x240.png
// @resource       ui-icons_f9bd01_256x240.png            http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-icons_f9bd01_256x240.png
// @resource       ui-icons_2e83ff_256x240.png            http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-icons_2e83ff_256x240.png
// @resource       ui-icons_cd0a0a_256x240.png            http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-icons_cd0a0a_256x240.png
// @resource       ui-bg_flat_0_aaaaaa_40x100.png         http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-bg_flat_0_aaaaaa_40x100.png
// @resource       ui-bg_flat_0_aaaaaa_40x100.png         http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/redmond/images/ui-bg_flat_0_aaaaaa_40x100.png

// ==/UserScript==

var $;

// Inject jQuery into page... gross hack... for now...
(function() {
    if (typeof unsafeWindow.jQuery == &#039;undefined&#039;) {
        var head = document.getElementsByTagName(&#039;head&#039;)[0];

        var script = document.createElement(&#039;script&#039;);
        script.type = &#039;text/javascript&#039;;

        var jQuery = GM_getResourceText(&#039;jQuery&#039;);
        var jQueryUI = GM_getResourceText(&#039;jQueryUI&#039;);

        script.innerHTML = jQuery + jQueryUI;
        head.appendChild(script);

    }
    GM_wait();
})();

// Check if jQuery&#039;s loaded
function GM_wait() {
    if (typeof unsafeWindow.jQuery == &#039;undefined&#039;) {
        window.setTimeout(GM_wait, 100);
    } else {
        $ = unsafeWindow.jQuery.noConflict(true);
        addUIStyles();
        letsJQuery();
    }
}

function addUIStyles() {
    var head = document.getElementsByTagName(&#039;head&#039;)[0];
    var resources = {
        &#039;ui-bg_inset-hard_100_fcfdfd_1x100.png&#039;: GM_getResourceURL(&#039;ui-bg_inset-hard_100_fcfdfd_1x100.png&#039;),
        &#039;ui-bg_gloss-wave_55_5c9ccc_500x100.png&#039;: GM_getResourceURL(&#039;ui-bg_gloss-wave_55_5c9ccc_500x100.png&#039;),
        &#039;ui-bg_glass_85_dfeffc_1x400.png&#039;: GM_getResourceURL(&#039;ui-bg_glass_85_dfeffc_1x400.png&#039;),
        &#039;ui-bg_glass_75_d0e5f5_1x400.png&#039;: GM_getResourceURL(&#039;ui-bg_glass_75_d0e5f5_1x400.png&#039;),
        &#039;ui-bg_inset-hard_100_f5f8f9_1x100.png&#039;: GM_getResourceURL(&#039;ui-bg_inset-hard_100_f5f8f9_1x100.png&#039;),
        &#039;ui-bg_flat_55_fbec88_40x100.png&#039;: GM_getResourceURL(&#039;ui-bg_flat_55_fbec88_40x100.png&#039;),
        &#039;ui-bg_glass_95_fef1ec_1x400.png&#039;: GM_getResourceURL(&#039;ui-bg_glass_95_fef1ec_1x400.png&#039;),
        &#039;ui-icons_469bdd_256x240.png&#039;: GM_getResourceURL(&#039;ui-icons_469bdd_256x240.png&#039;),
        &#039;ui-icons_469bdd_256x240.png&#039;: GM_getResourceURL(&#039;ui-icons_469bdd_256x240.png&#039;),
        &#039;ui-icons_d8e7f3_256x240.png&#039;: GM_getResourceURL(&#039;ui-icons_d8e7f3_256x240.png&#039;),
        &#039;ui-icons_6da8d5_256x240.png&#039;: GM_getResourceURL(&#039;ui-icons_6da8d5_256x240.png&#039;),
        &#039;ui-icons_217bc0_256x240.png&#039;: GM_getResourceURL(&#039;ui-icons_217bc0_256x240.png&#039;),
        &#039;ui-icons_f9bd01_256x240.png&#039;: GM_getResourceURL(&#039;ui-icons_f9bd01_256x240.png&#039;),
        &#039;ui-icons_2e83ff_256x240.png&#039;: GM_getResourceURL(&#039;ui-icons_2e83ff_256x240.png&#039;),
        &#039;ui-icons_cd0a0a_256x240.png&#039;: GM_getResourceURL(&#039;ui-icons_cd0a0a_256x240.png&#039;),
        &#039;ui-bg_flat_0_aaaaaa_40x100.png&#039;: GM_getResourceURL(&#039;ui-bg_flat_0_aaaaaa_40x100.png&#039;),
        &#039;ui-bg_flat_0_aaaaaa_40x100.png&#039;: GM_getResourceURL(&#039;ui-bg_flat_0_aaaaaa_40x100.png&#039;)
    };

    var style = document.createElement(&#039;style&#039;);
    style.type = &#039;text/css&#039;;

    var css = GM_getResourceText (&#039;jQueryUICSS&#039;);
    $.each(resources, function(resourceName, resourceUrl) {
        console.log(resourceName + &#039;: &#039; + resourceUrl);
        css = css.replace( &#039;images/&#039; + resourceName, resourceUrl);
    });

    style.innerHTML = css;
    head.appendChild(style);
}

// All your GM code must be inside this function
function letsJQuery() {
    //alert($); // check if the dollar (jquery) function works
    //alert($().jquery); // check jQuery version
    $(&quot;
&lt;div id=&#039;example&#039; class=&#039;flora&#039; title=&#039;This is my title&#039;&gt;I&#039;m in a dialog!&lt;/div&gt;

&quot;).dialog({
        buttons: {
            &quot;Ok&quot;: function() {
                alert(&quot;Ok&quot;);
            },
            &quot;Cancel&quot;: function() {
                $(this).dialog(&quot;close&quot;);
            }
        }
    });
}
</pre><p>I also wanted to use this script with Chromium browser, the open-source version of <a href="http://www.google.com/chrome/" target="_blank">Google Chrome</a>.  I found the <a href="https://chrome.google.com/webstore/detail/dhdgffkkebhmkfjojejmpbldmpobfkfo" target="_blank">TamperMonkey Extension for Chrome</a>. <a href="https://chrome.google.com/webstore/detail/fjnbnpbmkenffdnngjfgmeleoegfcffe" target="_blank">Stylish</a> is also available for Chrome.</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2011/07/16/jquery-and-jquery-ui-in-your-grease-monkey-scripts/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Generating CSS Based on Images, also SEO-Friendly</title><link>http://www.doknowevil.net/2011/02/20/generating-css-based-on-images-also-seo-friendly/</link> <comments>http://www.doknowevil.net/2011/02/20/generating-css-based-on-images-also-seo-friendly/#comments</comments> <pubDate>Sun, 20 Feb 2011 17:19:05 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Bash]]></category> <category><![CDATA[Computers]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[Images]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Web Development]]></category> <category><![CDATA[css]]></category> <category><![CDATA[generation]]></category> <category><![CDATA[tricks]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=977</guid> <description><![CDATA[I&#8217;ve typed out a lot of CSS that&#8217;s focused on using a background image to replace text. I&#8217;ve been using a cross-browser CSS trick that&#8217;s SEO-friendly, I&#8217;m not sure if it&#8217;s documented anywhere. I came upon the solution myself when I was searching for a clever way to do this years ago and it&#8217;s become]]></description> <content:encoded><![CDATA[<p>I&#8217;ve typed out a lot of CSS that&#8217;s focused on using a background image to replace text.  I&#8217;ve been using a cross-browser CSS trick that&#8217;s SEO-friendly, I&#8217;m not sure if it&#8217;s documented anywhere.  I came upon the solution myself when I was searching for a clever way to do this years ago and it&#8217;s become the standard method for me.  However, I dislike the tedious task of typing out the CSS and referencing the image pixels and at work, I don&#8217;t want my developers wasting that time either.</p><p>I figured it&#8217;d be best to come up with a simple solution, so I started coding something out in bash and it worked:</p><pre class="brush:bash">#!/bin/bash
# css.sh - generate common css and html
# Tyler Mulligan (z@interwebninja.com)
# Last Update: 02/16/2011
# MIT License

create_block_image() {
    feh -lr ${1:-.} | awk &#039;{ print $3&quot; &quot;$4&quot; &quot;$8 }&#039; | sed &#039;1d&#039; | while read l; do N=$((N+1));
        cbi_css $l
    done
    feh -lr ${1:-.} | awk &#039;{ print $3&quot; &quot;$4&quot; &quot;$8 }&#039; | sed &#039;1d&#039; | while read l; do N=$((N+1));
        cbi_html_a $l
    done
    feh -lr ${1:-.} | awk &#039;{ print $3&quot; &quot;$4&quot; &quot;$8 }&#039; | sed &#039;1d&#039; | while read l; do N=$((N+1));
        cbi_html_div $l
    done
}
cbi_css() {
    f=${3##*/}
    echo &quot;#${f%.*} {
    display: block;
    background: url(&#039;$3&#039;) no-repeat 0 0;
    width: 0;
    height: $2px;
    padding-left: $1px;
    overflow: hidden;
}&quot;
}
cbi_html_a() {
    f=${3##*/}
    echo &quot;&lt;a href=\&quot;#\&quot; id=\&quot;${f%.*}\&quot; alt=\&quot;$f\&quot; title=\&quot;$f\&quot;&gt;${f%.*}&lt;/a&gt;&quot;
}
cbi_html_div() {
    f=${3##*/}
    echo &quot;
&lt;div id=\&quot;${f%.*}\&quot;&gt;&lt;/div&gt;

&quot;
}

s=$1; shift; case $s in
  --image-block|--cbi|-i) create_block_image $@;;
  *) help help;;
esac</pre><p>Which ouputs something like:</p><pre class="brush:bash">
z@zygon:~/scripts/css$ ./css.sh -i img/
#dumbtubes-fav {
    display: block;
    background: url(&#039;img/dumbtubes-fav.png&#039;) no-repeat 0 0;
    width: 0;
    height: 14px;
    padding-left: 16px;
    overflow: hidden;
}
#submit_new {
    display: block;
    background: url(&#039;img/submit_new.png&#039;) no-repeat 0 0;
    width: 0;
    height: 106px;
    padding-left: 244px;
    overflow: hidden;
}
#dumbtubes-logo {
    display: block;
    background: url(&#039;img/dumbtubes-logo.png&#039;) no-repeat 0 0;
    width: 0;
    height: 70px;
    padding-left: 274px;
    overflow: hidden;
}
&lt;a href=&quot;#&quot; id=&quot;dumbtubes-fav&quot; alt=&quot;dumbtubes-fav.png&quot; title=&quot;dumbtubes-fav.png&quot;&gt;dumbtubes-fav&lt;/a&gt;
&lt;a href=&quot;#&quot; id=&quot;submit_new&quot; alt=&quot;submit_new.png&quot; title=&quot;submit_new.png&quot;&gt;submit_new&lt;/a&gt;
&lt;a href=&quot;#&quot; id=&quot;dumbtubes-logo&quot; alt=&quot;dumbtubes-logo.png&quot; title=&quot;dumbtubes-logo.png&quot;&gt;dumbtubes-logo&lt;/a&gt;
&lt;div id=&quot;dumbtubes-fav&quot;&gt;&lt;/div&gt;
&lt;div id=&quot;submit_new&quot;&gt;&lt;/div&gt;
&lt;div id=&quot;dumbtubes-logo&quot;&gt;&lt;/div&gt;
</pre><p>To explain the way this CSS works, it uses the padding-left as the actual width, setting the width 0 and then pushes whatever content you have out of view using overflow:hidden to hit it from view.  This makes it easy for search engines, keeping your HTML clean and CSS simple.</p><p>The bash script relies of &#8220;feh&#8221; a lightweight image viewer for linux that outputs a list of images and their dimensions.  It also generates some sample HTML to quickly drop in and modify.</p><p>This is not an elegant solution and I&#8217;m not happy with the fact that it relies on feh.  I&#8217;ve been slowly getting into python and I was amazed at how fast I was able to recreate this script in Python.</p><pre class="brush:python">#!/usr/bin/python
# css.py - generate common css and html
# Tyler Mulligan (z@interwebninja.com)
# Last Update: 02/17/2011
# MIT License
from PIL import Image
import sys
import os.path

CSS_FORMAT = &quot;&quot;&quot;#%s {\n\
    display: block;\n\
    background: url(&#039;%s&#039;) no-repeat 0 0;\n\
    height: %spx;\n\
    width: 0;\n\
    padding: %spx;\n\
    overflow: hidden;\n\
}\n&quot;&quot;&quot;

HTML_A_FORMAT = &quot;&quot;&quot;&lt;a href=&quot;#&quot; id=&quot;%s&quot; alt=&quot;%s&quot; title=&quot;%s&quot;&gt;%s&lt;/a&gt;\n&quot;&quot;&quot;
HTML_DIV_FORMAT = &quot;&quot;&quot;
&lt;div id=&quot;%s&quot;&gt;%s&lt;/div&gt;

\n&quot;&quot;&quot;

css=&quot;&quot;
html_a=&quot;&quot;
html_div=&quot;&quot;
for tf in os.listdir(sys.argv[1]):
    f = os.path.join(sys.argv[1],tf)
    if os.path.isfile(f) == True :
        img = Image.open(f)
        fid = os.path.splitext(tf)[0]
        (width, height) = img.size[0:2]
        css += CSS_FORMAT % (fid,f,height,width)
        html_a += HTML_A_FORMAT % (fid,f,fid,fid)
        html_div += HTML_DIV_FORMAT % (fid,fid)

print css
print html_a
print html_div </pre><p>This is just the basic idea, I didn&#8217;t spend more than 15 minutes on this rewrite, it does what I need it to do so far.  It was suggested by friends if I make it any bigger, to look into a templating engine, such as mako.  I hope this script can be useful to someone :). PS, HTML_DIV_FORMAT should be on one line, not sure why my syntax highlighter is trying to put it on 3.</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2011/02/20/generating-css-based-on-images-also-seo-friendly/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>The Best Way to Tweet to Twitter, Post on Facebook from WordPress</title><link>http://www.doknowevil.net/2010/07/26/the-best-way-to-tweet-to-twitter-post-on-facebook-from-wordpress/</link> <comments>http://www.doknowevil.net/2010/07/26/the-best-way-to-tweet-to-twitter-post-on-facebook-from-wordpress/#comments</comments> <pubDate>Tue, 27 Jul 2010 02:47:47 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Application Management]]></category> <category><![CDATA[Computers]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Web Applications]]></category> <category><![CDATA[Web Development]]></category> <category><![CDATA[Wordpress]]></category> <category><![CDATA[internet marketing]]></category> <category><![CDATA[ping.fm]]></category> <category><![CDATA[publishing]]></category> <category><![CDATA[social networks]]></category> <category><![CDATA[web]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=762</guid> <description><![CDATA[I&#8217;ve been focusing some time recently to the foundation levels of Internet marketing. I&#8217;m aiming to increase visibility as strongly as possible at the core of a website giving it the power to leverage evolving trends as simply as possible. This of course means utilizing APIs from other web applications, such as social networks. The]]></description> <content:encoded><![CDATA[<p>I&#8217;ve been focusing some time recently to the foundation levels of Internet marketing.  I&#8217;m aiming to increase visibility as strongly as possible at the core of a website giving it the power to leverage evolving trends as simply as possible.  This of course means utilizing APIs from other web applications, such as social networks.  The title of this post is true but deceptive.  I consider the following method the best way to tweet from WordPress but it&#8217;s actually a whole lot more than that. It&#8217;s a gateway to a large number of social media applications; one account to rule them all. <a href="http://www.ping.fm">ping.fm</a> is a service that allows you to link multiple social network websites, such as <a href="http://www.facebook.com" target="_blank">facebook</a>, <a href="http://www.twitter.com" target="_blank">twitter</a>, <a href="http://www.linkedin.com" target="_blank">linkedin</a> and more.</p><p><a href="http://www.doknowevil.net/wp-content/uploads/2010/07/screenshot241.png"><img class="alignnone size-full wp-image-763" title="ping fm services (minus twitter)" src="http://www.doknowevil.net/wp-content/uploads/2010/07/screenshot241.png" alt="" width="757" height="854" /></a><br /> + twitter</p><p>So the idea then, is to leverage then is to utilize the ping.fm application from your website.  If you&#8217;re using WordPress then you&#8217;re set, <a href="http://wordpress.org/extend/plugins/publish-2-pingfm">the simple no frills publish 2 ping.fm plugin</a> will allow you to interact with ping.fm from your blog/website.</p><p><a href="http://www.doknowevil.net/wp-content/uploads/2010/07/wordpress_ping_fm.png"><img class="alignnone size-full wp-image-764" title="wordpress_ping_fm" src="http://www.doknowevil.net/wp-content/uploads/2010/07/wordpress_ping_fm.png" alt="" width="815" height="818" /></a></p><p>I&#8217;ve tested this out with the free open-source GPL First Person Shooter, <a href="http://www.xonotic.org" target="_blank">Xonotic</a> and a new site I just started <a href="http://www.dumbtubes.com">dumbtubes.com</a>.  Both have twitter accounts that you can see publishing <a href="http://twitter.com/dumbtubes" target="_blank">twitter.com/dumbtubes</a>, <a href="http://twitter.com/xonotic" target="_blank">twitter.com/xonotic</a>.  Xonotic also publishes to many other social accounts, see the <a href="http://www.xonotic.org">Xonotic homepage</a> to find other accounts.</p><p>Stay tuned for more wordpress tips.</p><p><strong>WARNING</strong>, this plugin may cause other plugins options panels not to work.  I&#8217;m not sure the cause yet but be aware that it can cause the sub settings of dedicated plugin setting groups to throw access errors.</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2010/07/26/the-best-way-to-tweet-to-twitter-post-on-facebook-from-wordpress/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>scp-notifications for GNOME and Ubuntu &#8211; Expanding on My Original Python Script</title><link>http://www.doknowevil.net/2010/06/26/scp-notifications-for-gnome-and-ubuntu-expanding-on-my-original-python-script/</link> <comments>http://www.doknowevil.net/2010/06/26/scp-notifications-for-gnome-and-ubuntu-expanding-on-my-original-python-script/#comments</comments> <pubDate>Sun, 27 Jun 2010 00:11:15 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Compiz]]></category> <category><![CDATA[Computers]]></category> <category><![CDATA[Desktop Mods]]></category> <category><![CDATA[GNOME]]></category> <category><![CDATA[KDE]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Operating Systems]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[The Internet]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[Web Applications]]></category> <category><![CDATA[open source]]></category> <category><![CDATA[libnotify]]></category> <category><![CDATA[notification-daemon]]></category> <category><![CDATA[pynotify]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=698</guid> <description><![CDATA[I&#8217;ve only been coding Python for ~12 hours total, so don&#8217;t expect this to be perfect. Knowing what I know about creating/testing other software and doing my best to scour through very light pynotify documentation, I&#8217;ve begun to build out this script to be more useful / portable / configurable. As the Version 0.6 indicates,]]></description> <content:encoded><![CDATA[<p>I&#8217;ve only been coding Python for ~12 hours total, so don&#8217;t expect this to be perfect.  Knowing what I know about creating/testing other software and doing my best to scour through very light pynotify documentation, I&#8217;ve begun to build out this script to be more useful / portable / configurable.  As the Version 0.6 indicates, I&#8217;m not quite at my goal yet and there is still more to learn to bring it up to that point.</p><p>I&#8217;m releasing this early on my blog just in case I caught any people yesterday who&#8217;ve been experimenting with my research / code so far.  I&#8217;ll share it on github when I evolve it just a bit more.</p><p><a href="http://interwebninja.com/videos/compiz-screenshot-piped-to-notification-daemon-for-upload.ogv">Video of it in Action</a></p><pre class="brush:python">
#!/usr/bin/env python
#
# Title: scp-notifications
# Author: Tyler Mulligan (tyler@detrition.net)
# Date: 06/26/2010
# Version: 0.6
# Description:
# Used in combination with an event, such as an action or cronjob, this script
# will scp the latest file from a folder to your server.
#
# Optionally, it can copy the url to your clipboard and/or show a popup with a
# link to the file after succesfully uploading
#
# Orginally developed to be piped to from compiz screenshot tool
# http://interwebninja.com/videos/compiz-screenshot-piped-to-notification-daemon-for-upload.ogv
#
# The MIT License
#
# Copyright (c) 2010 Tyler Mulligan
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the &quot;Software&quot;), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE
#

import pygtk
pygtk.require(&#039;2.0&#039;)
import pynotify
import gtk
import sys
import os
import subprocess

# Set Variables
#####################################
user = &quot;user&quot;
host = &quot;server.com&quot;
# All should have trailing slashes
lfolder = &quot;/home/user/screenshots/&quot;
hfolder = &quot;/home/remote_user/screenshots/&quot;
httplink = &quot;http://&quot;+host+&quot;/screenshots/&quot;

# Display
#####################################
t1 = 5000 # timeout for screenshot upload dialog
t2 = 3000 # timeout for screenshot preview
t3 = 7000 # timeout for link dialog

screenshot_preview = 1 # If using with the compiz screenshot plugin, you may want this
popup_link = 1 # another popup
copy_to_clipboard = 0 # automatically copy text to keyboard

# Position
#####################################

# Get screensize &lt; &lt; used for relative positioning
display = gtk.gdk.display_get_default()
screen = display.get_default_screen()
x = screen.get_width() - 1
y = screen.get_height() - 1

# 0 for Automatic Placement
&quot;&quot;&quot;
x1 = 0
y1 = 0
x2 = 0
y2 = 0
x3 = 0
y3 = 0
&quot;&quot;&quot;
# Define Relative Position (assuming top-right)
x1 = x-1
y1 = 12
x2 = x1
y2 = y1 + 100
x3 = x-1
y3 = 12
# Define Static (1920 puts it on my second monitor)
&quot;&quot;&quot;
x1 = 1919
y1 = 12
x2 = x1
y2 = y1 + 100
x3 = 1920
y3 = 12
&quot;&quot;&quot;
#####################################

def upload_cb(n, action):
    assert action == &quot;upload&quot;

    subprocess.call([&quot;scp&quot;, os.path.join(lfolder, f), &#039;%s@%s:%s&#039; % (user, host, hfolder)])

    # setup URL in
    if copy_to_clipboard:
        clipboard = gtk.clipboard_get()
        clipboard.set_text(httplink + f)
        # make our data available to other applications
        clipboard.store()

    # Notification: Link for the clicking
    if popup_link:
        n3 = pynotify.Notification(&quot;Here is your link&quot;,&quot;&lt;a href=&#039;&quot; + httplink + f + &quot;&#039;&gt;&quot; + httplink + f + &quot;&quot;)

        helper = gtk.Button()
        icon = helper.render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_DIALOG)
        n3.set_icon_from_pixbuf(icon)

        n3.set_urgency(pynotify.URGENCY_NORMAL)
        if x3:
            n3.set_hint(&quot;x&quot;, x3)
        if y3:
            n3.set_hint(&quot;y&quot;, y3)
        n3.set_timeout(t3)
        n3.connect(&quot;closed&quot;,closen3_cb)

        if not n3.show():
            print &quot;Failed to send notification&quot;
            sys.exit(1)

        closen1_cb(n1)
        closen2_cb(n2)

    gtk.main_quit()
    sys.exit(1)

# Notification 1 was closed
def closen1_cb(n):
    n1.close()
    if screenshot_preview:
        n2.close()
    gtk.main_quit()

# Notification 2 was closed
def closen2_cb(n):
    n2.close()
    gtk.main_quit()

# Notification 2 was closed
def closen3_cb(n):
    n3.close()
    gtk.main_quit()

# The Ignore button was clicked
def ignore_cb(n, action):
    assert action == &quot;ignore&quot;

    closen1_cb(n1)
    closen2_cb(n2)
    gtk.main_quit()

# Main
def main():
    gtk.main()

# Init
if __name__ == &#039;__main__&#039;:
    if not pynotify.init(&quot;Notifier &#039;scp&#039; Option&quot;):
        sys.exit(1)

    # Get latest file and build uri
    start = os.path.abspath(lfolder)
    f = max([(os.path.getmtime(os.path.join(start,p)),p)
         for p in os.listdir(start)])[1]
    uri = lfolder + f

    # Notification: Upload to Server
    n1 = pynotify.Notification(&quot;Upload to Server?&quot;,&quot;Copy the file &#039;&quot; + f + &quot;&#039; to the server?&quot;)

    helper = gtk.Button()
    icon = helper.render_icon(gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG)
    n1.set_icon_from_pixbuf(icon)

    n1.set_urgency(pynotify.URGENCY_NORMAL)
    if x1:
        n1.set_hint(&quot;x&quot;, x1)
    if y1:
        n1.set_hint(&quot;y&quot;, y1)
    n1.set_timeout(t1)
    n1.add_action(&quot;upload&quot;, &quot;Yes, Upload&quot;, upload_cb)
    n1.add_action(&quot;ignore&quot;, &quot;Ignore&quot;, ignore_cb)
    n1.connect(&quot;closed&quot;,closen1_cb)

    if not n1.show():
        print &quot;Failed to send notification&quot;
        sys.exit(1)

    # Notification: Screenshot Preview
    if screenshot_preview:
        n2 = pynotify.Notification(&quot;Screenshot Preview&quot;, &quot;&quot;, uri)
        n2.set_urgency(pynotify.URGENCY_LOW)
        if x2:
            n2.set_hint(&quot;x&quot;, x2)
        if y2:
            n2.set_hint(&quot;y&quot;, y2)
        n2.set_timeout(t2)
        n2.connect(&quot;closed&quot;,closen2_cb)

        if not n2.show():
            print &quot;Failed to send notification&quot;
            sys.exit(1)

    main()
</pre><p>.</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2010/06/26/scp-notifications-for-gnome-and-ubuntu-expanding-on-my-original-python-script/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <enclosure url="http://interwebninja.com/videos/compiz-screenshot-piped-to-notification-daemon-for-upload.ogv" length="2797703" type="video/ogg" /> </item> <item><title>Patching NextGEN Voting Plugin to Allow Showing of the Vote Form on Single Images</title><link>http://www.doknowevil.net/2010/05/30/patching-nextgen-voting-plugin-to-allow-showing-of-the-vote-form-on-single-images/</link> <comments>http://www.doknowevil.net/2010/05/30/patching-nextgen-voting-plugin-to-allow-showing-of-the-vote-form-on-single-images/#comments</comments> <pubDate>Sun, 30 May 2010 21:17:19 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[The Internet]]></category> <category><![CDATA[Web Applications]]></category> <category><![CDATA[Web Development]]></category> <category><![CDATA[Wordpress]]></category> <category><![CDATA[NextGEN]]></category> <category><![CDATA[Wordpress Plugins]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=669</guid> <description><![CDATA[Intro NextGEN Voting is a plugin for the wordpress plugin NextGEN Gallery plugin. Keeping this in mind made the task of extending easier. NextGEN Gallery hooks into wordpress functions, NextGEN Voting hooks into NextGEN Gallery. By default, NextGEN Voting hooks into the gallery view, giving access to a function that uses the image id for]]></description> <content:encoded><![CDATA[<h2>Intro</h2><p><a href="http://wordpress.org/extend/plugins/nextgen-gallery-voting/" target="_blank">NextGEN Voting</a> is a plugin for the wordpress plugin <a href="http://wordpress.org/extend/plugins/nextgen-gallery/" target="_blank">NextGEN Gallery</a> plugin.  Keeping this in mind made the task of extending easier.  NextGEN Gallery hooks into wordpress functions, NextGEN Voting hooks into NextGEN Gallery.</p><p>By default, NextGEN Voting hooks into the gallery view, giving access to a function that uses the image id for lookup.  The only reason we see nothing if we try to paste the same template code into a page other than the recommended <em>&#8220;nextgen-gallery/view/gallery.php&#8221;</em> is because that function is not given access in any other view.</p><h2>How-to Add Access to Use the Function in the Image Browser Template</h2><p>Open <em>&#8220;wp-content/plugins/nextgen-gallery-voting/ngg-voting.php&#8221;</em>,</p><p>Look for:</p><pre class="brush:php">add_filter(&quot;ngg_show_gallery_content&quot;, &quot;nggv_show_gallery&quot;, 10, 2);</pre><p>Add After:</p><pre class="brush:php">add_filter(&quot;ngg_show_imagebrowser_content&quot;, &quot;nggv_show_imagebrowser&quot;, 10, 2);</pre><p>Look for:</p><pre class="brush:php">
function nggv_show_gallery($out, $gid) {
	return $out.nggc_voteForm($gid, $buffer);
}
</pre><p>Add After:</p><pre class="brush:php">
function nggv_show_imagebrowser($out, $gid) {
	return $out.nggc_voteForm($gid, $buffer);
}
</pre><p>Now we have given access to the function and can paste the following code into <em>&#8220;wp-content/plugins/nextgen-gallery/imagebrowser.php&#8221;</em>:</p><pre class="brush:php">&lt;?php echo nggv_imageVoteForm($image-&gt;pid); ?&gt;</pre><h2>Conclusion</h2><p>I&#8217;ve tried to explain this in method in a way you can repeat an extend to suit your needs.  By following the same logic and tracing the hooks, you can apply this however you might need.</p><p>You&#8217;ll want to keep <em>&#8220;wp-content/plugins/nextgen-gallery/nggfunctions.php&#8221;</em> open as a reference for what hooks are available.  You can find hooks by searching for &#8220;apply_filters(&#8216;&#8221;, it will be the first parameter.</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2010/05/30/patching-nextgen-voting-plugin-to-allow-showing-of-the-vote-form-on-single-images/feed/</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>Mac Browsers + PNGs = Mismatching Image Colors with Same HTML Hex</title><link>http://www.doknowevil.net/2010/05/28/mac-browsers-pngs-mismatching-image-colors-with-same-html-hex/</link> <comments>http://www.doknowevil.net/2010/05/28/mac-browsers-pngs-mismatching-image-colors-with-same-html-hex/#comments</comments> <pubDate>Fri, 28 May 2010 11:30:36 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Computers]]></category> <category><![CDATA[Graphics]]></category> <category><![CDATA[OSX]]></category> <category><![CDATA[Operating Systems]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[The Internet]]></category> <category><![CDATA[Web Applications]]></category> <category><![CDATA[Web Development]]></category> <category><![CDATA[apple]]></category> <category><![CDATA[mac]]></category> <category><![CDATA[png]]></category> <category><![CDATA[steve jobs]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=635</guid> <description><![CDATA[Most people with a Mac don&#8217;t know this but their gamma is set to 1.8 by default where the rest of the world is set to 2.2 for web/tv. The only reason I know this is because I had to figure out what was causing certain images to display darker on macs than Windows/Linux computers.]]></description> <content:encoded><![CDATA[<p>Most people with a Mac don&#8217;t know this but their gamma is set to 1.8 by default where the rest of the world is set to 2.2 for web/tv.  The only reason I know this is because I had to figure out what was causing certain images to display darker on macs than Windows/Linux computers.  Thankfully <a href="http://don.blogs.smugmug.com/author/onethumb/" target="_blank">Don MacAskill</a>, explained the basics of this &#8220;phenomenon&#8221; of <a href="http://don.blogs.smugmug.com/2007/02/14/this-is-your-mac-on-drugs/" target="_blank">Mac Browsers + PNGs = Mismatching Image Colors with Same HTML Hex&#8221;</a> in great detail and with <a href="http://www.smugmug.com/help/safari/safari.html" target="_blank">good examples</a></p><blockquote><p>Internet standards, including HTML, CSS, and Flash, are based on a gamma of 2.2, making colors partway between black &#038; white appear darker and higher contrast than 1.8 gamma makes them appear.</p></blockquote><p>Clearly this is a problem, as referenced by Ron, even <a href="http://support.apple.com/kb/HT2026?viewlocale=en_US" target="_blank">Apple recommends you change your default gamma from 1.8 to 2.2</a>, where they also link to some <a href="http://www.gballard.net/psd/srgbforwww.html" target="_blank">further reading</a>.</p><p>If images are delivered with the lower gamma information embedded, web browsers on macs tend to* (not all see note below) display them incorrectly if it&#8217;s not reading the color profile properly.</p><p>As a webdesigner / web developer / photographer, this might worry you.  You&#8217;ll want it too look the same to everyone or at least the majority (95%+ of the world uses windows). The easiest way I found to fix this in my work flow, using Ubuntu Linux was with <a href="http://en.wikipedia.org/wiki/Pngcrush" target="_blank">pngcrush</a>, a cross-platform application that allows you to not only reduce image filesize loseless, but allows you to remove information that can cause confusion with the way images appear in mac web browsers.</p><p>All I had to do to install it on Ubuntu was:</p><pre class="brush:bash">sudo apt-get install pngcrush</pre><p>Then I wrote the following command to strip all gAMA, cHTM, iCCP and sRGB information from all png files within a directory and move them to a folder called &#8220;crushed&#8221;</p><pre class="brush:bash">pngcrush -d crushed -rem gAMA -rem cHRM -rem iCCP -rem sRGB *.png</pre><p>*It&#8217;s important to point out that <a href="http://support.apple.com/kb/ht3712">this does not effect OSX 10.6+ (snow leopard and beyond)</a>.  Further reading on <a href="http://www.earthboundlight.com/phototips/gamma-18-or-22.html" target="_blank">why apple chose 1.8 gamma as the default can be found here</a>.</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2010/05/28/mac-browsers-pngs-mismatching-image-colors-with-same-html-hex/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Blocking Ads Cross-browser and Save Bandwith Using Your Hosts file</title><link>http://www.doknowevil.net/2010/05/26/blocking-ads-cross-browser-and-save-bandwith-using-your-hosts-file/</link> <comments>http://www.doknowevil.net/2010/05/26/blocking-ads-cross-browser-and-save-bandwith-using-your-hosts-file/#comments</comments> <pubDate>Thu, 27 May 2010 01:49:06 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Application Management]]></category> <category><![CDATA[Computers]]></category> <category><![CDATA[Firefox]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[The Internet]]></category> <category><![CDATA[hosts]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=638</guid> <description><![CDATA[Ethics of blocking ads vs. data mining aside, one of the smartest ways I found to block ads is at http://someonewhocares.org/hosts/zero/ where the author, Dan Pollock has compiled a list of urls, with the help of contributors that all redirect to 0.0.0.0 or 127.0.0.1 (localhost, your machine). By appending this list to your current hosts]]></description> <content:encoded><![CDATA[<p>Ethics of blocking ads vs. data mining aside, one of the smartest ways I found to block ads is at http://someonewhocares.org/hosts/zero/ where the author, Dan Pollock has compiled a list of urls, with the help of contributors that all redirect to 0.0.0.0 or 127.0.0.1 (localhost, your machine).  By appending this list to your current hosts file (or selectively adding parts), whenever your machine attempts to look up a domain name in this list, it will resolved to 0.0.0.0 or your machine.  It will never make a request on the internet to the intended server.  It will never even download the advertisement.</p><p>To take this a step further, you could develop a similar list for your router or DNS server (if you operate it).</p><p>I still use adblock plus on top for missed entries.</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2010/05/26/blocking-ads-cross-browser-and-save-bandwith-using-your-hosts-file/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Resources for Learning About jQuery Functions and a Note About Callbacks</title><link>http://www.doknowevil.net/2009/09/07/resources-for-learning-about-jquery-functions-and-a-note-about-callbacks/</link> <comments>http://www.doknowevil.net/2009/09/07/resources-for-learning-about-jquery-functions-and-a-note-about-callbacks/#comments</comments> <pubDate>Mon, 07 Sep 2009 22:31:51 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Javascript]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[The Internet]]></category> <category><![CDATA[Web Development]]></category> <category><![CDATA[jQuery]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=502</guid> <description><![CDATA[Though it&#8217;s still using 1.2.6 (with current jQuery at 1.3.2), visualjquery.com has always been a favorite of mine for it&#8217;s simple and elegant layout. Some of the functions leave some documentation to be desired but after working with jQuery for a while, you begin to develop a taste for what is needed. Unfortunately, next to]]></description> <content:encoded><![CDATA[<p>Though it&#8217;s still using 1.2.6 (with <a href="http://www.jquery.com" target="_blank">current jQuery</a> at 1.3.2), <a href="http://visualjquery.com/" target="_blank">visualjquery.com</a> has always been a favorite of mine for it&#8217;s simple and elegant layout.  Some of the functions leave some documentation to be desired but after working with jQuery for a while, you begin to develop a taste for what is needed.  Unfortunately, next to this issue and despite it&#8217;s strong layout, there is one other thing this application that takes this application down from strongest candidate.  It cannot look into the future and as such, some functions are outright missing.</p><p><a href="http://api.jquery.com/" target="_blank">The jquery API is a somewhat familiar interface</a>, featuring the latest version, the freshest functions and some decent documentation.  Another in-depth (but outdated) resource is the <a href="http://view.jquery.com/trunk/tools/api-browser" target="_blank">old api-browser</a>.  Of course, there exists the <a href="http://docs.jquery.com/Main_Page">Main Wiki Documentation</a>, which also provides <a href="http://docs.jquery.com/Alternative_Resources">Alternative Resources</a>.  I think I&#8217;ll find myself using http://api.jquery.com/ most often despite it lacking the multi-panel style selection.  It integrates it&#8217;s documentation with <a href="http://jsbin.com" target"_blank">jsbin.com</a> for testing / playing with code which is a nice touch.</p><p>Now a note about callbacks while we&#8217;re on the subject of jQuery.  I find myself using them quite often, with ajax specifically.  Understanding how to nest functions in jQuery allows you to do more things in terms of user or application response.  When using ajax, you&#8217;ll often want to fade out content, do some processing, report the data back and have it fade back in nicely rather than a quick blink that can cause discomfort for a user.  If you aren&#8217;t familiar with a callback, it&#8217;s a function that&#8217;s executed when the current function finishes.</p><p>Below I will break down this common scenario.</p><p>You have your HTML</p><pre class="brush:xhtml">
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;
    &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;my_ajax.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;style&gt;
#ajax_loader {
  display:block;
  height:90px;
  width:90px;
  background:url(&#039;http://imgur.com/KW8ZD.gif&#039;) no-repeat 0 0;
}
&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;ajax_loader&quot;&gt;&lt;/div&gt;
&lt;div id=&quot;ajax_content&quot;&gt;&lt;/div&gt;

  &lt;a href=&quot;#&quot; id=&quot;my_link&quot;&gt;click me&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre><p>your php (or whatever language returning the data file) (my_page.php)</p><pre class="brush:php">
&lt;? echo &quot;hi, I was loaded with ajax!&quot;; ?&gt;
</pre><p>and your javascript (my_ajax.js) that glues them together</p><pre class="brush:javascript">
// $(function() is shorthand for $(document).ready(function () {
$(function() {
    $(&quot;#ajax_loader&quot;).hide();
    $(&quot;#my_link&quot;).click(function() {
        $(&quot;#ajax_loader&quot;).fadeIn();
        $(&quot;#ajax_content&quot;).fadeOut();
        $(&quot;#content&quot;).load(&quot;my_page.php&quot;,function() {
          $(&quot;#ajax_loader&quot;).fadeOut();
          $(&quot;#ajax_content&quot;).fadeIn();
        });
    });
});
</pre><p>Here we can clearly see how all functions are nested into one root, the document ready function.  We go two more deep here, using the click event and then the load callback.  Many functions allow for callbacks, search the documentation for the best way you think you should be nesting them.  I hope this helps to clarify some of the basics in AJAX using jQuery, good luck.</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2009/09/07/resources-for-learning-about-jquery-functions-and-a-note-about-callbacks/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Reducing pageweight by compressing production css and js files</title><link>http://www.doknowevil.net/2009/09/04/reducing-pageweight-by-compressing-production-css-and-js-files/</link> <comments>http://www.doknowevil.net/2009/09/04/reducing-pageweight-by-compressing-production-css-and-js-files/#comments</comments> <pubDate>Fri, 04 Sep 2009 22:20:30 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Computers]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[Organization]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Web Applications]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=497</guid> <description><![CDATA[I&#8217;ve been a little obsessed with improving the speed of web pages via minified javascript and css files. YUI&#8217;s team not only agrees with this, they recommend gzipping your minified js and css files. For a while I&#8217;ve been calling YUI Compressor inside my push to production scripts to do the deed. However, with this]]></description> <content:encoded><![CDATA[<p>I&#8217;ve been a little obsessed with improving the speed of web pages via <a href="http://www.crockford.com/javascript/jsmin.html" title="Compress your css and js files" target="_blank">minified javascript and css files</a>.  YUI&#8217;s team not only agrees with this, <a href="http://yuiblog.com/blog/2006/10/16/pageweight-yui0114/" title="Compress your css and js files" target="_blank">they recommend gzipping your minified js and css files</a>.  For a while I&#8217;ve been calling <a href="http://yuilibrary.com/downloads/#yuicompressor" title="YUI Compressor -- minify your js and css files" target="_blank">YUI Compressor</a> inside my push to production scripts to do the deed.  However, with this new mention of gzipping, I think might be exploring other options such as the method mentioned on the page which originally linked me to that awesome YUI writeup; <a href="http://agachi.name/weblog/archives/2006/11/25/pack-your-javascript.htm">minifying and gzipping javascript and css on the fly using php</a>.</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2009/09/04/reducing-pageweight-by-compressing-production-css-and-js-files/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Optimizing CSS selectors for load time; #home is faster than #menu li a#home</title><link>http://www.doknowevil.net/2009/06/27/optimizing-css-selectors-for-load-time-home-is-faster-than-menu-li-ahome/</link> <comments>http://www.doknowevil.net/2009/06/27/optimizing-css-selectors-for-load-time-home-is-faster-than-menu-li-ahome/#comments</comments> <pubDate>Sat, 27 Jun 2009 17:45:13 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[DOM]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[css]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=445</guid> <description><![CDATA[I was trying to figure out how to cut rendering time with smarter CSS. In my quest, I came across a plugin by google for Firebug called Page Speed which not only answered my question in the &#8216;Use efficient CSS selectors&#8217; section (* #header #menu a:hover &#8212; Tag key with 2 descendant selectors and hover]]></description> <content:encoded><![CDATA[<p>I was trying to figure out how to cut rendering time with smarter CSS.  In my quest, I came across a plugin by google for <a href="http://getfirebug.com" title="firebug" title="Firebug">Firebug</a> called <a href="http://www.teknobites.com/2009/06/06/google-page-speed-for-firebug-firefox-addon/">Page Speed</a> which not only answered my question in the &#8216;Use efficient CSS selectors&#8217; section (* #header #menu a:hover &#8212; Tag key with 2 descendant selectors and hover pseudo selector) but provided more details on the subject on the <a href="http://code.google.com/speed/page-speed/docs/rendering.html#UseEfficientCSSSelectors">Page Speed Documentation</a>.</p><p>&#8220;Descendant selectors are inefficient because, for each element that matches the key, the browser must also traverse up the DOM tree, evaluating every ancestor element until it finds a match or reaches the root element. The less specific the key, the greater the number of nodes that need to be evaluated.&#8221;</p><p>So, #home is faster than #menu li a#home; at least in Mozilla&#8217;s case.  More on this <a href="https://developer.mozilla.org/en/Writing_Efficient_CSS" title="Writing efficient CSS" target="_blank">here</a></p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2009/06/27/optimizing-css-selectors-for-load-time-home-is-faster-than-menu-li-ahome/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Object Caching 884/1014 objects using disk

Served from: www.doknowevil.net @ 2012-02-07 09:06:13 -->
