Thursday, April 26, 2012

SocialFeed Updates

What a terrible article. @Forbes: FBI warns that you need to clean up your computer or you could lose Internet access http://t.co/S1TAVPGh
I hate streets that use all the numbers.
iOS doesn't crash any less than Android. It just doesn't admit it when it happens.


Originally posted by William Barnes (Billy Barnes)

SocialFeed Updates

iOS doesn't crash any less than Android. It just doesn't admit it when it happens.


Originally posted by William Barnes (Billy Barnes)

Monday, April 23, 2012

SocialFeed Updates

RT @eileentv: A new favorite warning http://t.co/UUcyhqQo


Originally posted by William Barnes (Billy Barnes)

Friday, April 13, 2012

SocialFeed Updates

Packed Titanic theater. The only guy. One of perhaps six old enough to have seen it the first time.
Jobs in IP intensive industries. http://t.co/uT23D3xc


Originally posted by William Barnes (Billy Barnes)

SocialFeed Updates

R2D2 cake. Well done. http://t.co/HpPGDPz8


Originally posted by William Barnes (Billy Barnes)

Thursday, April 12, 2012

SocialFeed Updates

RT @ProPublica: A haunting photo essay on U.S. juvenile detention centers: http://t.co/lVL3Wivo #muckreads (via @coracurrier)
A picture was stolen... http://t.co/HcdlYo nl


Originally posted by William Barnes (Billy Barnes)

Wednesday, April 11, 2012

SocialFeed Updates

RT @jeffjarvis: Neat Kickstarter watch with changeable face: http://t.co/7s6qgnyo


Originally posted by William Barnes (Billy Barnes)

Tuesday, April 10, 2012

SocialFeed Updates

RT @BoingBoing: Secret history of the near-construction of a lifesized Starship Enterprise in downtown Las Vegas http://t.co/HWwzW4lP


Originally posted by William Barnes (Billy Barnes)

Monday, April 9, 2012

SocialFeed Updates

By packing a round sandwich in a square tin, one may avoid the arbitrariness otherwise involved in a diagonal cut, achieving maximum taste.


Originally posted by William Barnes (Billy Barnes)

Sunday, April 8, 2012

SocialFeed Updates

Brilliant: Repurpose a Squeeze Bottle for Perfect Pancakes http://t.co/3CqoPQ9t


Originally posted by William Barnes (Billy Barnes)

Friday, April 6, 2012

SocialFeed Updates

RT @Canoe: Toronto cops threw the (Face)book at her http://t.co/Y4nF0sGd


Originally posted by William Barnes (Billy Barnes)

Thursday, April 5, 2012

Exactly what I expected

Why can't I prepare your products in a toaster oven?

Our Product Development personnel do not recommend using a toaster oven due to the toaster oven's small size and proximity of the heating element to the container.
From Stouffer's FAQ I feel kind of bad about tagging this "cooking".


Originally posted by William Barnes (Billy Barnes)

Tuesday, April 3, 2012

Capifony fails on "bin/vendors install --reinstall"

I was attempting to deploy my Symfony app using Capifony, but it just wouldn't work. The first error in the train wreck was: "Warning: Wrong parameter count for parse_ini_file() in .../bin/vendors on line 69". Like all problems that take forever to fix, this one was incredibly simple. My shared host had both php 5.2 and 5.3 installed. I added the following line to deploy.rb: set :php_bin, "/usr/local/bin/php-5.3" Your path may differ.

Originally posted by William Barnes (Billy Barnes)

SocialFeed Updates

I'm still mad at Geocities for deleting my website after I signed up for a second account because 2MB wasn't enough.


Originally posted by William Barnes (Billy Barnes)

HTML5 History API and Scrolling

My new web app uses the HTML5 History API (as abstracted by History.js) to smooth out navigation. This proved to be a bit of a challenge because, despite all the Javascript, my app is supposed to act just like a normal web page. The main content of my app is dynamically loaded in an ordinary static-positioned DIV. Thus, the user scrolls the window like normal. Other elements are fixed to the viewport. One major problem I encountered was that browsers have serious issues with remembering the window scroll position across pages Normally, when a user clicks the back button, they are taken to the previous page at the same place that they left it. Most browsers don't actually reload the page, but store it in memory, so this happens almost instantaneously. When using the History API, this does not always work. In this post, I detail the problems and my solution.

In Webkit, when the user navigates (using links or the back/forward buttons) the scroll does not change from page to page unless the page is too short to support the scroll value. If the user scrolls on page 1 and clicks to page 2, window.scrollY on page2 is the same as it was on page 1. If they scroll on page 2 and navigate back to page 1, scrollY is now the new value. If page 3 is not long enough to scroll, then scrollY is zeroed. Going back to page 1, it remains 0. I like this behaviour because it is predictable. If I am overriding the browser's navigation, I'd like to have complete control. Firefox, however, is somewhat erratic in this area. Generally speaking, it behaves like a browser on a normal website. If scrollY on page 1 is 50 and the user clicks to page 2, scrollY is 0. If they scroll a bit so scrollY on page 2 is now 200, then navigate back to page 1, scrollY will be 50. However, if they navigate to page 3 (which doesn't scroll) and then back to page 1, scrollY will be 0. I worked around this by storing the scroll value myself, and scrolling to that on each History statechange. Originally, I only stored the current scroll value while handling the statechange event, but Firefox applies its remembered value before firing the event. This placed me in the awkward position of needing to know the value before the user did anything. I use the window.onscroll event to detect when the window has been scrolled by the user so that it does not store a value in the awkward time where new content is loading. Following John Resig's example, I store the value every half second using setInterval. [codesyntax lang="javascript" tab_width="4"]
var loc = { 	currentState: 0, 	states: [ 		{scroll: 0} 	], 	hasScrolled: true,  	initHistory: function() { 		var History = baseWin.global.History; 		if (History.enabled) { 			// Before binding events, replace the state with the proper ID. 			// Otherwise, strange things happen. 			History.replaceState({state:0}); 			// Bind the state change event (Dojo won't do this for some reason) 			History.Adapter.bind(baseWin.global, "statechange", loc.handleStateChange); 			// Bind the anchor click 			on(baseWin.body(), "a[href]:click", loc.anchorClick); 			// Bind the scroll event 			on(baseWin.global, 'scroll', function() { loc.hasScrolled = true; }) 			// Store the scroll position every 500ms 			setInterval(function() { 				if (loc.hasScrolled) { 					loc.states[loc.currentState].scroll = baseWin.global.scrollY; 					loc.hasScrolled = false; 				} 			}, 500) 		} 	},  	anchorClick: function(e) { 		var History = baseWin.global.History, 			rootUrl = History.getRootUrl(), 			node    = e.target;  		// Remove orphaned states 		loc.states = loc.states.slice(0, loc.currentState + 1); 		// Initialize the new state 		loc.states[loc.currentState + 1] = {scroll: 0};  		// If there is a span, b, i, etc inside the link, that will be the target node. 		// This loop finds the actual anchor. 		while (node.nodeName.toLowerCase() != 'a') { 			node = node.parentNode; 		}  		var url 			= domAttr.get(node,"href"), 			isInternalLink 	= url.substring(0,rootUrl.length) === rootUrl || url.indexOf(":") === -1; 		if (isInternalLink) { 			event.stop(e); 			url = url.replace(rootUrl,"") 			History.pushState({state:loc.currentState + 1},"",url); 		} 	},  	handleStateChange: function(e) { 		var History = baseWin.global.History 			state = History.getState();  		// Load the state id 		loc.currentState = state.data.state;  		// IMPLEMENTATION SPECIFIC XHR STUFF 		// onSuccess: function() { 			baseWin.global.scrollTo(0, loc.states[loc.currentState].scroll); 		// } 	} }
[/codesyntax] Naturally, the above code would have to be modified for another application, but I hope that the method is clear and is of use to someone.

Originally posted by William Barnes (Billy Barnes)

Sunday, April 1, 2012

SocialFeed Updates

Star Trek, drug searches, police dogs, bad cops. The canine section is particularly interesting. http://t.co/FivFIFg9


Originally posted by William Barnes (Billy Barnes)

Mobile Safari bugs so far

I just bought my first iOS device (the new iPad) and I've been busy squashing bugs in my latest project. And by bugs in my project I mean, of course, bugs in Safari. Here are some of the more annoying ones and how I fixed them.

Changing CSS visibility breaks things

Several of the problems I had seem to have been caused by various problems with Safari's handling of visibility. For example, a number of elements in the app use the following CSS transition to fade in and out: [codesyntax lang="css" title="Transitioning Opacity"]
.hideable { 	opacity: 0; 	visibility: hidden; 	transition: visibility 0.5s linear 0.5s, opacity 0.5s ease; 	-moz-transition: visibility 0.5s linear 0.5s, opacity 0.5s ease; 	-webkit-transition: visibility 0.5s linear 0.5s, opacity 0.5s ease; 	-o-transition: visibility 0.5s linear 0.5s, opacity 0.5s ease; }  .visible { 	opacity: 1; 	visibility: visible; 	transition-delay:0s; 	-moz-transition-delay:0s; 	-webkit-transition-delay:0s; 	-o-transition-delay:0s; }
[/codesyntax] I use visibility for two reasons: (1) elements can be sized according to their contents before being shown, (2) visibility can be transitioned. The second reason is important, because otherwise it would require additional Javascript to delay the hiding of the element until after the opacity transition runs. This works in Desktop Safari, Chrome, Firefox, the Android Browser, and Mobile Chrome. In Mobile Safari, however, the element does not get shown until you click on another link. I originally solved this by disabling the visibility transition in iOS, but I ran into another problem. Merely toggling visibility breaks Mobile Safari's new native "overflow: auto/scroll" functionality. I'll talk about this problem in more detail later. For now, the solution is to disable the transition and use display instead of visibility in Mobile Safari: [codesyntax lang="css" title="Mobile Safari Fix"]
body.iOS .hideable { 	display: none; 	opacity: 1; 	-webkit-transition: none; 	visibility: visible; }  body.iOS .visible { 	display: block; }
[/codesyntax]

Overflow scroll breaks on visibility toggle

iOS5 finally introduced scrolling within an element. Previously, this had to be achieved with Javascript (e.g. iScroll). Frankly, I was pretty happy with my Javascript solution, but some variation of the position fixed bug mentioned below was breaking it. The touchable portion of the inner DIV scrolled with the document, rather than remaining fixed.; if the document was scrolled partway down, the fixed element no longer scrolled. iOS's solution is fairly simple, just add the following to your CSS: "-webkit-overflow-scrolling: touch;" I imagine it's done this way because they're afraid of breaking apps that relied on overflow-scroll just not working. It works pretty well, though it does not use the custom scrollbars. It also does not work if the scrolling DIV is contained in an element that was previously visibility-hidden. This time, it has nothing to do with transitions. The only fix I can find is to use display instead of visibility.

 Javascript scrolling breaks touch events on position-fixed objects

This was a weird one. I put buttons on the right edge of the screen to allow a user to page up and down the document. They were position-fixed (supported in iOS 5!) and they worked. Once. You couldn't click them a second time. If you clicked one, all the other position-fixed buttons stopped working. If you then scrolled normally, everything started working again. Interestingly, if I just scrolled down 100px, the button would stop working, but if I then touched a spot 100px above the button, it would register. It's as if Safari has a map of elements for the purpose of registering touch events that stays fixed to the page (ie: position absolute), while the visible representation of the elements stays fixed to the screen. Thus, when the page scrolls, the map goes with it. For whatever reason, Javascript doesn't trigger a recalculation of where the elements are. I disabled the buttons in iOS. Apple is aware of this, so a fix may be coming.

Originally posted by William Barnes (Billy Barnes)