Blog posts
There are plenty of tutorials and guides on how to make a chome extension and there are hundeds for jQuery manipulation of the DOM. There are also a few about using jQuery in a chome extension, but only for the popup window. There seems to be a lack of using jQuery to actually do something on a page.This is something that too me a while to get my head around and a bit of googling to figure out, so now it's time to share.
Create a folder for the extension files. It's probably best to name it after your extension so you can find it later on.
In a plain text editor such as Notepad, Textmate or TextEdit create 3 blank documents. You can save the files as manifest.json, background.js and background.html. Using your favorite image editing software create a png icon with a transparent background (20px x 20px should be ok for now). Chome should scale the icon for the different areas it shows. Later we can create different resolution icons and tell chome to use them.
Get a copy of jQuery. and add it to the folder.
In your folder you should now have the following files:
manifest.json
background.html
background.js
icon.png
jquery.min.js
Let's go over what each of the files will contain, and then what that does.
manifest.json
{
"name": "jQuery DOM",
"version": "1",
"description": "Manipulate the DOM when the page is done loading",
"background_page": "background.html",
"browser_action": {
"name": "Manipulate DOM",
"icons": ["icon.png"],
"default_icon": "icon.png"
},
"content_scripts": [ {
"js": [ "jquery.min.js", "background.js" ],
"matches": [ "http://*/*", "https://*/*"]
}]
}
The important part of the manifest.json is:
"content_scripts": [ {
"js": [ "jquery.min.js", "background.js" ],
"matches": [ "http://*/*", "https://*/*"]
}]
The js tells the extension to load jquery and then ...
Continue reading (permalink)
Posted in 'Web development'.
Recently I have been working on quite a few projects that require different versions of packages to run. Each setup has been running in a virtual environment (that is a post for another day) and setting them up with the required package rather than the latest that easy_install can find is really simple.
easy_install "django == 1.3"
That will find and install Django version 1.3... simple as that!
Continue reading (permalink)
Posted in 'Programming'.
Flipping an image using objective-c is so easy once you know how...
//Create a normal image
UIImage* img = [UIImage imageNamed:@"myImage.png"];
//Flip it
UIImage* flippedImage = [UIImage imageWithCGImage:img.CGImage scale:1.0 orientation: UIImageOrientationDownMirrored];
That's it! Now to have it as an method we can use more conveniently, try this:
-(UIImage *)flipImage:(UIImage *)img {
UIImage* flippedImage = [UIImage imageWithCGImage:img.CGImage scale:1.0 orientation: UIImageOrientationDownMirrored];
return flippedImage;
}
Then we can send any image to it and it will return a flipped version.
Continue reading (permalink)
Posted in 'Programming'.
The uses of NSNotificationCenter can be many; It is handy for using to notify the app that a background download of data, a post of some kind is done, or some calculation is finished. It can also be useful for letting sub views know when some root level functions happen in the app such as shutdown/sending to background because the user tapped the home button. In this example I will be doing just that.
In the AppDelegate you should find a method named:
- (void)applicationDidEnterBackground:(UIApplication *)application
This is called when the app starts the process to pause into the background state. Since this method can only be called by the app delegate and not a sub view notifications are ideal for subviews so that they can do what they need such as save data or stop heavy processing of data.
//.m
- (void)applicationDidEnterBackground:(UIApplication *)application{
[[NSNotificationCenter defaultCenter] postNotificationName:@"UIApplicationDidEnterBackgroundNotification" object:self];
}
'UIApplicationDidEnterBackgroundNotification' is the name of the notification we send out. If we name notifications in a smart way it makes sense when you have lost of them to listen for.
In a sub view class we need tell it to listen (observe) for the 'UIApplicationDidEnterBackgroundNotification'. Add the notification observer to somewhere like the init so that it is listening as soon as the object is created. Lets go over the details before we see the code.
addObserver:self assigns the listener to the current object. We can also assign the listener to other objects, such as views, i.e: addObserver:myCustomViewControllerObject.
selector:@selector(theActionToCarryOut:) is which method to call when we get the notification.
name:@"UIApplicationDidEnterBackgroundNotification" is what notification we are listening to.
object:nil is which object sent it. By setting 'nil' we say that we don't care where the message came from. If we ...
Continue reading (permalink)
Posted in 'Programming'.
I have added a new section to the site to share some the photographs that I have been taking. If your interested then hop on over to http://carl-topham.com/portfolio/photography/ and have a look.
Continue reading (permalink)
Posted in 'News'.
The site redesign has been launched. As with any redesign, things change. Some you may like, and other you may not, but I assure you that I have put a lot of thought behind each change I have made. Let me know what you think of the changes. Since the site was also rebuilt from the ground up some of the things you may see may be things that are buggy or broken so please let me know asap.
Continue reading (permalink)
Posted in 'News'.
When setting up a new mac or fresh install of Mac OS X there is a issue that many developers may come across. The issue is with getting MySQL-python to work properly. This guide was written with 10.6.8 in mind, but it will probably work for earlier versions of the OS as well as (hopefully) 10.7 a.k.a.Lion.
EDIT: This will get you up and working, but for some reason it needs you to type the following into terminal before you start each time:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
After you have typed this it will work until you next quit/restart. I will update this when I have figured out the best way of adding this into your paths so that you don't have to do it each time. If you know then feel free to comment below. Thanks.
The way to get this to work is a good clean install. You can google for how to remove older versions of MySQL , and I wouldn't remove Python since some OS utilities apparently use it. We will also need to get Xcode so that some of the files can be compiled.
Download Xcode (It's about 4Gb so find sonething else to do for a bit): http://developer.apple.com/tools/Xcode/
Download MySQL(Latest 64bit): http://dev.mysql.com/downloads/mysql/
Download Python (2.7.2 64bit): http://www.python.org/getit/
Install both. Install the MySQL pref pane too and start the MySQL service/server.
Open up terminal and type:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
Keep terminal open after doing this until we are done. Use the same window for the following. /usr/local/mysql/lib/ is where MySQL is where the MySQL installer puts MySQL. The command is ...
Continue reading (permalink)
Posted in 'Web development'.
Another day, and another social network spring up for us all to join. This time it's from google (again). They have had a few attempts in the past, which have eventually been shut down. It's been up and running by invite only for a week or so now and it seems, so far at least, that this one could be their one.
It's design has been well though out and the privacy has so far been really well handled. There are a few quirks, and things to get used to, but the google+ team are on the ball and changes and updates are being handled in a really up front and timely manor. These guys have really set out to make this work just right.
At the moment the vast majority of people are Programmers, developers and designers with the general creatives falling in 4th. It seems to be somewhere in the middle of being facebook & twitter, with the better bits of both, so hopefully it can drag people off both of them and on to it.
Hopefully I will find some time to do a more in depth article on the in's and out's of it, and some of the beautiful features that Google has given us to play with.
P.S. You may also notice I now have +1 buttons on the blog posts, so share away!
Continue reading (permalink)
Posted in 'News'.
Another day, another cloud is here. This time it is the iCloud. Since Apple is the company that most people are watching I thought it was time to take a quick minute and think about what we are about to get.
Any 'cloud' is essentially a buzz word for a big pile of servers that holds your data. It's not just one computer your data sits on. It's a whole bunch. You can call it what you like, 'cloud' doesn't matter. How you see a cloud workng is entirely up to you. What I see is devices that just add and take data from your cloud, your friends clouds etc and the cloud just holds them and pushes and pulls data between devices. Essentially you can just pick up one device and carry on where you put down the other. Perhaps this is a service that is cloud based? It seems cloudy ehough for me!
So far this sounds excellent, so long as the network that keeps the data up to date quickly enough so I can put down my phone and pick up the iPad and carry on exactly where I left off. Here's hoping it is as good as I think it can be.
Continue reading (permalink)
Posted in 'Other'.
Due to a few things I have been working on and a range of different projects I have been focusing on there are now many more things I can add to the site and many more streams of information that I can feed into it. The site wants to grow so I am going to make it grow as well as it can.
Currently the redesign is just starting in the UI/UX design and look and feel stages and it has raised a few questions about what people actually want to see in any site?
Personally I love to look at peoples projects and illustrations, designs and photographs. I like to read there blog and see what makes them tick, and I like to learn a few things as I go along. I like a site that has what I will call 'multi-focus'. Where you go for one thing, perhaps your were looking for a snippet of code, and you end up staying for something else. Something else that isn't just one thing but also another core part of the site. When I find what I like I want to share it with everyone else easily.
That's what I like in a site, but I am just one person. So more importantly what you want to see in my site?
I am designing the site with visitors in mind, so what are you looking at? what are you struggling to find and what would you like to see? Do you want to tweet and like articles and photos, any pages as all or just blog posts? Let me know by leaving a comment or sending me a tweet @Designer023
Continue reading (permalink)
Posted in 'News'.