My name is Harry Bailey. I am a web developer who lives in Didsbury Manchester. This site is what I use as my extended memory because sometimes mine doesn't do it's job too well.

Animating Fade Of Twitter Bootstrap Buttons

I came across a curious issue today. You can’t select a period of time over which to fade out and fade in Twitter Bootstrap buttons.

If you apply jQuery fadeTo() or animate() they fade out and they fade in, but they do it in their own time.

This may be related to a css transition which is applied in the bootstrap css, I haven’t had a chance to look, but the workaround for me is to put the button in a span and fade the span in and out instead.

   <span><a href="#" class="btn small">Button Text</a></span>

Add Random Hashes With Mysql

Adding a new column to a table which needs to contain a different random hash for each row?

Mysql can easily generate md5 strings and update all rows in the table for you

UPDATE thetable
SET thecolumn = MD5(RAND())
WHERE thecolumn IS NULL

CSS3 Element Wiggle With Keyframes

fetchit-21

This technique produces something similar to the wiggle you get on an iPhone when deleting items.

Be aware that keyframe animation is still very poor in Chrome and cases freezing and jumping if multiple items are animated at once.

The animation css below results in a hovered element rotating back and forth around it’s centre point. You can update the number of degrees and length of animation to change the appearance.

Just add this css and give your element the class ‘wiggler’ to implement

 
/* safari and chrome */
@-webkit-keyframes wiggle {
	0% {-webkit-transform:rotate(4deg);}
	50% {-webkit-transform:rotate(-4deg);}
	100% {-webkit-transform:rotate(4deg);}
}
 
/* firefox */
@-moz-keyframes wiggle {
	0% {-moz-transform:rotate(4deg);}
	50% {-moz-transform:rotate(-4deg);}
	100% {-moz-transform:rotate(4deg);}
}
 
/* anyone brave enough to implement the ideal method */
@keyframes wiggle {
	0% {transform:rotate(4deg);}
	50% {transform:rotate(-4deg);}
	100% {transform:rotate(4deg);}
}
 
.wiggler:hover {
	-webkit-animation: wiggle 0.5s infinite;
	-moz-animation: wiggle 0.5s infinite;
	animation: wiggle 0.5s infinite;
}

Reordering Yii Results Without Another Select

fetchit-21

In case you weren’t aware, you can reorder the results you already have from a previous Yii call. For example…

 
$users = User::model()->findByPk(2);
$posts = $user->posts(array('order'=>' created Desc '));

There were just ordered our users posts by created date descending.

We can also do filtering…

 
$users = User::model()->findByPk(2);
$posts = $user->posts(array('condition'=>' status=1 '));

So now we only have active posts. We could also combine a condition and a status.

You can find out more here: http://www.yiiframework.com/doc/guide/1.1/en/database.arr#dynamic-relational-query-options

A Friend Request Form Inside A Facebook Iframe Application

fetchit-21

The example given on the Facebook developer documentation page ( http://developers.facebook.com/docs/reference/fbml/serverFbml/ ) doesn’t work. This one does.

Note how some html is escaped and the multi-friend-selector is inside the form.

The code below allows you to add the large version of a friend select in the form of an invite tool to your iframe facebook applications:

<fb:serverFbml style="width: 755px;">  
     <script type="text/fbml">
        <fb:fbml>
            <fb:request-form
                action=""
                method="post"
                invite="true"
                type="XFBML"
                content="This is a test invitation from XFBML test app
                &lt;fb:req-choice url=&quot;see fb:req-choice docs for details.&quot;
                    label=&quot;Ignore the Facebook test app!&quot; /&gt;
             ">
				<fb:multi-friend-selector
                    showborder="false"
                    actiontext="Invite your friends to use Socially." />
             </fb:request-form>
         </fb:fbml>
    </script>
</fb:serverFbml>