Category Archives: apple

Webkit custom scroll bars

Webkit browsers such as Safari and Chrome support some superb CSS3 styling.
They are ( even thought I use firefox as my primary browser ) the most advanced browsers.

For a while now I have created custom scroll bars using a Javascript library called Mootools, other libraries such as jQuery and Prototype can do this too, but here is one easy way to do it with CSS alone;

here is the simple code, if you know CSS it will be self explanatory, else I have added some commenting

/* were a webkit browser, lets style our scroll bar */
@media screen and (-webkit-min-device-pixel-ratio:0) {

	html{
		/* hide overall scrolling */
		overflow: auto;
	}
	body {
		/* absolute position our 'body' and allow for the width of the scroll bar */
		position: absolute;
		left: 0;
		top: 0;
		right: 10px;
		bottom: 0;
		padding-right: 10px;
		overflow-x: auto;
		overflow-y:scroll;
	}


	::-webkit-scrollbar {
		/* set the width of the scroll bar */
		width: 10px;
	}

	::-webkit-scrollbar-button:start:decrement, 
	::-webkit-scrollbar-button:end:increment {
		/* hide the arrows */
		display: block;
		height: 10px;
	}

	::-webkit-scrollbar-track-piece {
		/* set the style/colour of the scroll bar background */
		background: 
		-webkit-gradient(
			linear, 
			0 0, 
			100% 0, 
			from(rgba(0,0,0,0.2)), 
			to(rgba(0,0,0,0.12))
		);
		-webkit-box-shadow: 0 1px 0 0 rgba(255,255,255,0.35);
		-webkit-border-radius: 5px;
	}

	::-webkit-scrollbar-thumb:vertical{
		/* this is the acutal scrooll bar, set the colours here to match your site */
		/* I have used grey's (#464646 & #383838 & #cccccc) */
		background: 
		-webkit-gradient(
			linear, 
			0 0, 
			100% 0, 
			from(#464646),
			to(#383838)
			);
			-webkit-border-radius: 6px;
			border: 3px solid #cccccc;
			-webkit-background-clip: padding-box;
		}
		::-webkit-scrollbar-track-piece:horizontal{
			background: none;
			-webkit-box-shadow:none;
		}
		::-webkit-scrollbar:horizontal{
			height: 16px;
		}
		::-webkit-scrollbar-thumb:horizontal{
			height: 12px;
			-webkit-border-radius:12px;
			background: 
			-webkit-gradient(
				linear, 
				0 0, 
				0 100%, 
				from(rgba(0,0,0,0.1)), 
				to(rgba(0,0,0,0.25))
			);
			border: 6px solid transparent;
			-webkit-background-clip: padding-box;
			
		}
	}
}

Use PHP to find your mobile browser

I needed a quick way to include different files based on the if the visitor to a site is on a mobile device or a regular browser/computer.

Every browser has a user agent depending on the operating system, browser and system.

below are some common use agents, they can be found by echoing the server variable HTTP_USER_AGENT

< ?php echo $_SERVER['HTTP_USER_AGENT']; ?>

FireFox

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7

Safari Mac

Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-en) AppleWebKit/523.10.3 (KHTML, like Gecko) Version/3.0.4 Safari/523.10 

Safari Windows

Mozilla/5.0 (Windows; U; Windows NT 6.0; en) AppleWebKit/522.13.1 (KHTML, like Gecko) Version/3.0.2 Safari/522.13.1 

Nexus One

Mozilla/5.0 (Linux; U; Android 2.1; en-us; Nexus One Build/ERD56C) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17

Apple iPhone

Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3

Apple iPod Touch

Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A100a Safari/419.3 

Internet Explorer

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.2; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)

PHP mobileAgent() Function

Here is my function, is it simple PHP function, is expects one paramerter, and array or expected user agents, but by leaving it blank, the function will use the default user agents.

Update: I have added more mobile user agents for older Android models, Blackberrry’s and the iPhone simulator. .

< ?php
	function mobileAgent($custom_agents = array()) {

		$agents = array_merge($custom_agents, array(
			'iphone',           // Apple iPhone
			'ipod',             // Apple iPod touch
			'aspen',            // iPhone simulator
			'nexus',            // Nexus One Android
			'dream',            // Pre 1.5 Android
			'android',          // 1.5+ Android
			'cupcake',          // 1.5+ Android
			'blackberry9500',   // Storm
			'blackberry9530',   // Storm
			'opera mini',       // Opera mobile
			'webos',            //  Nokia Browser
			'incognito',        // Other iPhone browser
			'webmate'           // Other iPhone browser
		));
		$user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
		foreach($agents as $agent) if(strpos($user_agent, $agent)) return TRUE;
		return FALSE;

	}
?>

Usage

	< ?php if(mobileAgent()): ?>
	
	
	< ?php else: ?>
	
	< ?php endif; ?>

Cleaning my Apple Mighty Mouse Ball's

I have a couple of Apple Mac’s and with each of them, I have a Mighty Mouse.
I have one I carry with my with my Mac Book Pro, this is getting quite old now, It was the first release of the Wireless model, I pre-ordered it as soon as they were announced and have used it on almost a daily basis since.

I also have one on my iMac which gets a daily use also.

These mice are Great ! there are 5 buttons, the 5th is the 360 degree scroll ball. The wired model is very light and agile, while the wireless model is slightly heavier due to the batteries, but if you only use one AA rather than two, it is only ever so slightly heavier than the wired, and still not as heavy as most.

The only Issue I with these mice are the Ball’s get dirty from your finger being rolled over them on a continuous basis. Apple have an article and QT Movie on how to clean them, and plenty of discussions on the Apple forums, but the simple method is rolling it on paper.

Roll to Clean your Balls !

A way to clean the mighty mouse ball that I have always used, is turn it off ( or un-plug ), and get a clean sheet of paper, and upside down, and firmly roll the mouse around on the ball.

Cleaning the Mighty's Balls

Cleaning the Mighty's Balls

Changing the RSS refresh rate in Apple Mail

I use Apple’s Mail App as my primary mail client on both my personal and work mac’s, and for both machines I have various RSS Feeds subscribed.
I use apple mail as an RSS Client for a couple of reasons,

1) I just like how it works
2) its not just one more application I have to have open.

Recently though, I have found that none of the 30 or so feeds I am subscribed to were pulling any new posts.
I found this Odd, espically I know that multiple of them update daily. I did a bit of digging around, and have found a simple terminal command to alter the refresh rate that Mail will check for feed updates.

The default time is 30 minutes, admin the preferences you can set it to manually, 30 minutes, hourly or daily.

Apple Mail RSS Refresh Rate

Apple Mail RSS Refresh Rate

I changed these around then back to 30 minutes, and waiting an hour, but still NO feeds were updating.

After a little more digging, I found a terminal command that you can specify and refresh rate.

Specify the Refresh rate in Terminal !

  1. Quit Mail
  2. Open Terminal – /Applications/Utilities/Terminal.app
  3. Type:
    defaults write com.apple.mail RSSPollTime xx

    ** Replace the ‘nn’ with minutes, EG:

    defaults write com.apple.mail RSSPollTime 20
  4. Open Mail

This worked for me, and within the next 20 mintues, I had all the posts that I was missing for the last week that I didn’t get any.

Pretty lucky, as I was missing out some some pretty good stuff!

BounceBox Update, Version 1.1

I was using an implementation of my BounceBox mootools javascript class on a site I am working on at the moment, and made a couple of additions to the Class that I hope other will enjoy.

The new version1.1 demo can be viewed at http://bouncebox.lendrum.co.nz/ and the change log with a new version 1.1 demo link at the bottom of that page to show full screen positioning that is now supported.

The Demo page has full links to download this free Mootools Javascript effects class.

Hack Safari to open links in new tabs, not new windows

Safari (by default) will open certain links (e.g. target=”_blank”) in a new browser window instead of a new tab even if you have your preferences set no too. Fortunately, there is a hidden preference you can set to force Safari to behave.

If you run this command in Terminal /Applications/Utilities/Terminal.app

defaults write com.apple.Safari TargetedClicksCreateTabs -bool true

to disable this afterwards, change the true on the end to false.

I have tested this on Safari Mac 2, 3 and 4 Beta.

removing .SVN directories recursively

I have been working a lot lately using SubVersion ‘s to maintain all the projects that I and some times others are all working on.

A firm that I contract to has recently set up a SVN Server on a dedicated machine with ActiveCollab and Versions to manage our projects. This means that we have versions and versions of manageable projects.

Today, I pulled down a part of a project to use inside another project, but the directories still contained the .svn data from the original project.

So here is a quick command to strip out all the .svn data from a project.

rm -rf `find . -name .svn`

Force Eject a CD/DVD in Apple Leopard

Today I had to help a friend force eject a stuck DVD in his iBook, there are a couple of methods we tried and I thought that hey may be helpful for others.

I would recommend trying to eject your stuck CD/DVD in this order;

1) Hold the ‘Eject’ Key for up to 30 seconds.

2) Stop the CD/DVD spinning

Stop the CD/DVD from spinning by gentle pushing in a thin piece of cardboard ( not to soft, nor hard ), thin packaging cardboard from like a battery or toy packet.
This will stop the CD as it is always spinning slightly, then hold the EJECT key for 8-10 seconds.

3) Restart holding the Mouse Button

Restart your mac, and once the machine chimes, hold the mouse button down ( external mouse or trackpad button ). This should eject the DV/DVD in up to 8 seconds.
If not, restart your mac again.

4) Restart in to Single User Mode

Restart your machine, and hold down the ‘Command ( apple )‘ + ‘O ( o for orange )‘ + ‘F ( f for fred )‘ keys.
This will boot you in to single user mode.

Type the following Command:

eject cd

Then press the ‘enter’ key

This should eject the CD/DVD.

Once the CD is ejected, type;

mac-boot

Then press the ‘enter’ key to boot back in to your Mac OS.

Force Eject a CD/DVD in Apple Leopard

Force Eject a CD/DVD in Apple Leopard