<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Blog - Alex Peattie, a web developer and designer.</title>
 <link href="http://www.alexpeattie.com/atom.xml" rel="self"/>
 <link href="http://www.alexpeattie.com/"/>
 <updated>2011-07-02T18:50:40+01:00</updated>
 <id>http://www.alexpeattie.com/</id>
 <author>
   <name>Alex Peattie</name>
   <email>alexpeattie@gmail.com</email>
 </author>

 
 <entry>
   <title>New projects - CSS feedback button & animate-textshadow</title>
   <link href="http://www.alexpeattie.com/blog/new-projects-added/"/>
   <updated>2011-06-05T00:00:00+01:00</updated>
   <id>http://www.alexpeattie.com/blog/new-projects-added</id>
   <content type="html">&lt;p&gt;&lt;a href='/projects/'&gt;&lt;img alt='animate-textshadow and Pure CSS floating feedback button' src='/images/posts/new-projects-added/preview.png' /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ts been a while since I blogged last. Since then, lots has happened in the tech world: we had the &lt;a href='http://www.pcmag.com/article2/0,2817,2384254,00.asp'&gt;S3 apocolypse&lt;/a&gt;, the &lt;a href='http://blog.eu.playstation.com/2011/04/23/update-on-playstation-network-qriocity-services/'&gt;PSN debacle&lt;/a&gt;, &lt;a href='http://www.microsoft.com/presspass/press/2011/may11/05-10corpnewspr.mspx'&gt;Microsoft bought Skype&lt;/a&gt;, the world &lt;a href='http://www.bbc.co.uk/news/business-13451057'&gt;bought LinkedIn shares&lt;/a&gt;. I&amp;#8217;ve been keeping myself equally busy, and I&amp;#8217;m going to be rolling out a bunch of new coolness over the next few weeks.&lt;/p&gt;

&lt;p&gt;To kick things off, there are two new additions to the &lt;a href='/projects/'&gt;Projects&lt;/a&gt; section. The first is one of those fancy floating feedback buttons you see everywhere - except &lt;a href='projects/feedback_button/'&gt;this one&lt;/a&gt;&amp;#8217;s done without images (instead using clever CSS trickery). It&amp;#8217;s more of a fun proof-on-concept than something I&amp;#8217;d necessarily recommend for production - it&amp;#8217;s probably most useful as an example of solid, cross-browser vertical text in CSS (with a bit of supplementary Javascript), which took a while to figure out.&lt;/p&gt;

&lt;p&gt;Second, is a redux of Edwin Martin&amp;#8217;s excellent &lt;a href='http://www.bitstorm.org/jquery/shadow-animation/'&gt;Shadow animation plugin&lt;/a&gt; providing a way to animate the &lt;code&gt;text-shadow&lt;/code&gt; property. Head over to &lt;a href='projects/animate-textshadow/'&gt;the plugin&amp;#8217;s page&lt;/a&gt; to see it in action, and browse the source &lt;a href='https://github.com/alexpeattie/animate-textshadow'&gt;on Github&lt;/a&gt;. Although I was able to reuse a lot of the code from Edwin&amp;#8217;s plugin, but there were a couple of gotchas. Most notably, &lt;a href='http://www.w3.org/TR/1998/REC-CSS2-19980512/text.html#text-shadow-props'&gt;the spec&lt;/a&gt; for text-shadow allows the color to be declared at the beginning &lt;em&gt;or&lt;/em&gt; end of the property, while in &lt;code&gt;box-shadow&lt;/code&gt;&amp;#8217;s &lt;a href='http://www.w3.org/TR/css3-background/#the-box-shadow'&gt;spec&lt;/a&gt; only the beginning is allowable. Additionally, I wanted to allow &lt;code&gt;text-shadow&lt;/code&gt; to be given in &lt;code&gt;em&lt;/code&gt;, which meant the text&amp;#8217;s &lt;code&gt;font-size&lt;/code&gt; had to be passed in to the parser. On the plus side, &lt;code&gt;text-shadow&lt;/code&gt; is actually part of the CSS2 spec, so no &lt;a href='http://www.quirksmode.org/blog/archives/2010/03/css_vendor_pref.html'&gt;vendor prefixes&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;As always, feel free to &lt;a href='/contact/'&gt;contact me&lt;/a&gt; about these releases, and I look forward to bringing you more new projects in the coming weeks!&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>JustVector Icons update (v1.5)</title>
   <link href="http://www.alexpeattie.com/blog/justvector-icons-update/"/>
   <updated>2011-04-14T00:00:00+01:00</updated>
   <id>http://www.alexpeattie.com/blog/justvector-icons-update</id>
   <content type="html">&lt;p&gt;&lt;a href='/projects/justvector_icons/'&gt;&lt;img alt='Dropbox, Quora, Pinboard and Ping' src='/images/posts/justvector-icons-update/preview.png' /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Last month I released the &lt;a href='/projects/justvector_icons/'&gt;JustVector Social Icon pack&lt;/a&gt;, 100 monochrome vectors for social sites and services. Really, the pack was a selfish endeavour: although there are plenty of social icon packs out there, what I wanted - no frills, full-scaleable vectors for all common sites - was difficult to find. But the feedback I&amp;#8217;ve gotten suggests others have found the icons useful too, and the pack&amp;#8217;s already clocked up 10K+ downloads.&lt;/p&gt;

&lt;p&gt;In that spirit, I&amp;#8217;m pleased to roll out the &lt;a href='/projects/justvector_icons/#versions'&gt;first update&lt;/a&gt; to the pack, adding &lt;strong&gt;50 thoroughly lovely new vectors&lt;/strong&gt;. Highlights include icons for Dropbox, Quora, Pinboard and (Apple) Ping, all included by popular demand (&lt;a href='/contact/'&gt;let me know&lt;/a&gt; if there are any icons you&amp;#8217;d like to see included). Compatability has also been improved, the vectors are now CS3+ rather than CS5.&lt;/p&gt;

&lt;h2 id='justvector_web_font'&gt;JustVector web font&lt;/h2&gt;

&lt;p&gt;&lt;a href='/projects/justvector_font/'&gt;&lt;img alt='JustVector web font' src='/images/posts/justvector-icons-update/web_font.png' /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks to some great work by Sergio D&amp;#237;az the set is now available as a web font. With a little @font-face magic, you can have social icons to resize, recolour and &lt;a href='http://mothereffingtextshadow.com/'&gt;generally abuse&lt;/a&gt;. I&amp;#8217;m not hosting or maintaining the web font - go grab it on Sergio&amp;#8217;s site: &lt;a href='http://seich.tumblr.com/post/4344642365/justvector-social-icons-font'&gt;http://seich.tumblr.com/post/4344642365/justvector-social-icons-font&lt;/a&gt; - but you can check out a demo &lt;a href='/projects/justvector_font/'&gt;here&lt;/a&gt;.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Working with dates in Git</title>
   <link href="http://www.alexpeattie.com/blog/working-with-dates-in-git/"/>
   <updated>2011-03-13T00:00:00+00:00</updated>
   <id>http://www.alexpeattie.com/blog/working-with-dates-in-git</id>
   <content type="html">&lt;p&gt;When working in &lt;a href='http://git-scm.com/'&gt;git&lt;/a&gt;, you most commonly trace a repository&amp;#8217;s history using commits&amp;#8217; SHA-1 hashes. To revert to a previous commit, you might write something like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git revert 883c3dc85a49d98da649&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The problem is, we tend not to think in hashes. Rather, we wonder what changes we made &lt;em&gt;yesterday&lt;/em&gt;, or remember that a now-broken piece of code worked perfectly &lt;em&gt;a week ago&lt;/em&gt;. Although we can use &lt;code&gt;git log&lt;/code&gt; to track down the commit we want, there has to be an easier way. Luckily git understands our human quirks, and offers us just that.&lt;/p&gt;

&lt;h2 id='understanding_dates_in_git_author_date_vs_committer_date__approxidate'&gt;Understanding dates in Git: author date vs. committer date &amp;amp; &amp;#8216;approxidate&amp;#8217;&lt;/h2&gt;

&lt;p&gt;There are two kinds of timestamp in git: a &lt;code&gt;GIT_AUTHOR_DATE&lt;/code&gt; and a &lt;code&gt;GIT_COMMITTER_DATE&lt;/code&gt;. Although in most cases they both store the same value, they serve slightly different purposes. As the &lt;a href='http://progit.org/book/ch2-3.html'&gt;Pro Git Book&lt;/a&gt; explains:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The author is the person who originally wrote the work, whereas the committer is the person who last applied the work.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So if, for instance, you send in a patch to a project, the author date will be when you made the original commit but the committer date will be when the patch was applied. Another common scenario is rebasing: rebasing will alter the commit date, but not the author date.&lt;/p&gt;

&lt;p&gt;This distinction is worth mentioning because of an inconsistency in git that &lt;a href='http://cworth.org/hgbook-git/tour/'&gt;Carl Worth points out&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By default, &amp;#8220;git log&amp;#8221; displays author dates as &amp;#8220;Date&amp;#8221; but then uses commit dates when given a &amp;#8211;since option. That seems like broken defaults to me.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In other words, all the methods listed below rely on the committer date, even though you&amp;#8217;re used to seeing the author date. As mentioned, most of the time they&amp;#8217;ll be the same, but to see committer dates in the log just use:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; git log --format=fuller&lt;/code&gt;&lt;/pre&gt;

&lt;h4 id='date_parsing_with_approxidate'&gt;Date parsing with &amp;#8216;approxidate&amp;#8217;&lt;/h4&gt;

&lt;p&gt;Git employs a kind of date parsing which will be familiar to any rubyists who&amp;#8217;ve used &lt;a href='http://chronic.rubyforge.org/'&gt;Chronic&lt;/a&gt;. The parser, called &amp;#8216;approxidate&amp;#8217; is very flexible, and allows both fixed dates in any format you can dream up (&amp;#8220;10-11-1998&amp;#8221;, &amp;#8220;Fri Jun 4 15:46:55 2010 +0200&amp;#8221;, &amp;#8220;9/9/83&amp;#8221;) and relative dates (&amp;#8220;today&amp;#8221;, &amp;#8220;1 month 2 days ago&amp;#8221;, &amp;#8220;six minutes ago&amp;#8221;). You can include days of the week (&amp;#8220;last Tuesday&amp;#8221;), timezones (&amp;#8220;3PM GMT&amp;#8221;) and &amp;#8216;named&amp;#8217; times (&amp;#8220;noon&amp;#8221;, &amp;#8220;tea time&amp;#8221;).&lt;/p&gt;

&lt;p&gt;Approxidate isn&amp;#8217;t really documented anywhere, but the &lt;a href='https://github.com/git/git/blob/master/date.c'&gt;code for the parser&lt;/a&gt; is very readable, so check it out to get an idea of the kind of formats git will accept.&lt;/p&gt;

&lt;h2 id='log_whatchanged_since_and_until'&gt;log, whatchanged, &amp;#8211;since and &amp;#8211;until&lt;/h2&gt;

&lt;p&gt;OK, so how about if we want to look at all the commits made since yesterday? All we need is the &lt;code&gt;--since&lt;/code&gt; option:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; git log --since=&amp;quot;yesterday&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We can also use &lt;code&gt;--until&lt;/code&gt; to fetch all commits up to a certain date; or of course we can use both options in tandem:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; git log --since=&amp;quot;1 week ago&amp;quot; --until=&amp;quot;yesterday&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;code&gt;--since&lt;/code&gt; and &lt;code&gt;--until&lt;/code&gt; can also be used with &lt;code&gt;whatchanged&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; git whatchanged --since=&amp;quot;1/1/2010&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Worth noting: instead of &lt;code&gt;--until&lt;/code&gt; and &lt;code&gt;--since&lt;/code&gt; you can use &lt;code&gt;--before&lt;/code&gt; and &lt;code&gt;--after&lt;/code&gt;, if that&amp;#8217;s more your style.&lt;/p&gt;

&lt;h2 id='revert_diff_and_the__construct'&gt;revert, diff and the @ construct&lt;/h2&gt;

&lt;p&gt;Not all git commands have options like &lt;code&gt;--since&lt;/code&gt; and &lt;code&gt;--until&lt;/code&gt;. So what if we wanted to revert back to our repo as it was a month ago? Luckily git provides us with a more generic way to reference commits using dates, with the @ construct:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; git revert master@{&amp;quot;1 month ago&amp;quot;}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(where master is the name of the branch you&amp;#8217;re working on).&lt;/p&gt;

&lt;p&gt;This lets us do clever things, like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; git diff master@{&amp;quot;yesterday&amp;quot;} master@{&amp;quot;1 year 6 months ago&amp;quot;}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;which will compare the repo as it was yesterday, and as it was 1 year, 6 months ago.&lt;/p&gt;

&lt;h2 id='change_history_amending_and_editing_dates'&gt;Change history: amending and editing dates&lt;/h2&gt;

&lt;p&gt;There might be certain situations where you want to alter the timestamps git assigns to commits. There are a couple of ways that you can do this.&lt;/p&gt;

&lt;h4 id='use_'&gt;Use &lt;code&gt;--date&lt;/code&gt;&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;--date&lt;/code&gt; option allows you to specify the author date that git attaches to the commit. Here we can&amp;#8217;t use approxidate unfortunately, only fixed dates will work (YYYY.MM.DD, MM/DD/YYYY, DD.MM.YYYY, &lt;a href='http://www.apps.ietf.org/rfc/rfc2822.html#sec-3.3'&gt;RFC 2822&lt;/a&gt; and &lt;a href='http://en.wikipedia.org/wiki/ISO_8601'&gt;ISO 8601&lt;/a&gt; are all valid).&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; git commit --date=&amp;quot;Wed Feb 16 14:00 2037 +0100&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We can also use &lt;code&gt;amend&lt;/code&gt; to change the timestamp of a previous commit:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; git commit --amend --date=&amp;quot;Wed Feb 16 14:00 2037 +0100&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Unfortunately &lt;code&gt;--date&lt;/code&gt; will only change the &lt;code&gt;GIT_AUTHOR_DATE&lt;/code&gt;, not &lt;code&gt;GIT_COMMITTER_DATE&lt;/code&gt;. If this is a problem, you may need to&amp;#8230;&lt;/p&gt;

&lt;h4 id='manually_set__and_'&gt;Manually set &lt;code&gt;GIT_AUTHOR_DATE&lt;/code&gt; and &lt;code&gt;GIT_COMMITTER_DATE&lt;/code&gt;&lt;/h4&gt;

&lt;p&gt;A word of warning - overriding &lt;code&gt;GIT_COMMITER_DATE&lt;/code&gt; is somewhat &lt;a href='http://www.kernel.org/pub/software/scm/cogito/docs/cg-commit.1.html'&gt;frowned upon&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It should be never overridden, unless you know you absolutely need to override it (to ensure the commit gets the same ID as another or when migrating history around)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; export GIT_AUTHOR_DATE=&amp;quot;Wed Feb 16 14:00 2037 +0100&amp;quot;
&amp;gt; export GIT_COMMITTER_DATE=&amp;quot;Wed Feb 16 14:00 2037 +0100&amp;quot;
&amp;gt; git commit&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The code above will alter both timestamps. Amending a commit in the past is more tricky, but the &lt;a href='https://git.wiki.kernel.org/index.php/GitFaq#How_can_I_tweak_the_date_of_a_commit_in_the_repo.3F
'&gt;GitFAQ&lt;/a&gt; provides us with a handy bash script:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/bin/sh
#
# Rewrite all branches to modify the date of one specific commit in a repo.
#
# Sample date format: Fri Jan 2 21:38:53 2009 -0800
# ISO8601 and RFC822 dates will also work.
#
# Note: filter-branch is picky about the commit argument. As of 1.7.0.4,
# a hex ID will work, the symbolic revision HEAD will fail silently,
# and the usability of more exotic rev specs was not tested by the author.
#
# Copyright (c) Eric S. Raymond, 2010-08-01. BSD terms apply (if anybody really thinks that this
# script is long and non-obvious enough to fall under copyright law).
#
commit=&amp;quot;$1&amp;quot;
date=&amp;quot;$2&amp;quot;
git filter-branch --env-filter \
    &amp;quot;if test \$GIT_COMMIT = &amp;#39;$commit&amp;#39;
     then
         export GIT_AUTHOR_DATE
         export GIT_COMMITTER_DATE
         GIT_AUTHOR_DATE=&amp;#39;$date&amp;#39;
         GIT_COMMITTER_DATE=&amp;#39;$date&amp;#39;
     fi&amp;quot; &amp;amp;&amp;amp;
rm -fr &amp;quot;$(git rev-parse --git-dir)/refs/original/&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Instead of setting the date explicitly, we can also use &lt;code&gt;GIT_COMMITTER_DATE=&amp;quot;$GIT_AUTHOR_DATE&amp;quot;&lt;/code&gt; ( source: &lt;a href='https://gist.github.com/568898'&gt;this gist&lt;/a&gt; ) to match up the committer date to the author date.&lt;/p&gt;</content>
 </entry>
 
 
</feed>