Carl Topham - React.js & JavaScript developer


Page 4

  • Swift timer

    🕑1 minute read
    March 8, 2015

    This is a simple timer, using Swift.

    var theTimer = NSTimer() //function to start the timer (if needs be)  func startTimer() { //start the timer with a 5 second delay  self.theTimer = NSTimer.scheduledTimerWithTimeInterval(5, target: self, selector: Selector("timerIsDone"), userInfo: nil, repeats: false) } func stopTimer() { //start the timer with a 5 second delay  self.theTimer.invalidate() } //The function called when the timer is done  func timerIsDone() { println("Do something") stopTimer() } //start the...

  • The joy of calc()

    🕑2 minute read
    November 3, 2013

    calc() is a modern css function that allows you to do basic maths in a css file. You can use it to make semi fluid layouts with great ease. This means that you can have layouts with 1 fixed width column (or more) and the rest fluid. It doesn't just stop at columns, but that is the easiest and quickest example to discuss.

    The setup of calc is very simple. If we take a 2 column layout as an example, the side column always has 200px of width, the main will take up the rest, so 100% less 200px!

    /* Fixed columns...

  • Creating a chrome extension - an update

    🕑2 minute read
    June 7, 2013

    Since I wrote my last post on creating a Chrome extension , there have been a few changes to how the extensions are built - mainly that the manifest version has changed to version 2. The original post is still fine, but there are a few tweaks needed. This post is mean mainly as an update to the original, so rather than rehash the old content too much I will skim over the basics quickly.

    • Create a folder for your plugin - name it after your extension so you can find it later!
    • In a text editor create 4 documents...

  • Arabic web fonts

    🕑2 minute read
    November 16, 2012

    I've been looking for a good solution for Arabic web fonts for while now and have been hitting my head against the wall with the lack of options available to me or the cost of buying a font and hosting it myself.

    Just as I was contemplating making my own arabic font (no easy feat) it would seam that some of web services are beginning to add some decent options. Since I use Typekit I would prefer this to be the service with the Arabic fonts, but at the time of writing this isn't the case. This currently means...

  • Changing the version of SASS in LiveReload

    🕑2 minute read
    July 9, 2012

    LiveReload is great a great tool for any web developer. One of the most useful of it's features is the ability to compile SASS on save. Unfortunately the version of SASS that is included in LiveReload isn't the latest one and it just so happened that was the version I needed (3.2 alpha). Long story short, I updated the version of SASS that LiveReload uses on my machine. I'm not sure if it will break anything but backup your LiveReload App just in case. If you ever update LiveReload you will need to redo the...

  • A Responsive Image jQuery Plugin

    🕑2 minute read
    May 15, 2012

    There are a whole variety of ways that responsive images can be accomplished, but as of yet there is no perfect way of doing it without using a combination of .htaccess, javascript and css. My solution is no different and uses JavaScript (in the form of jQuery) as the coordinator of the images.

    responsiveBreakpointJQ works by specifying the images that will show if the screen of the device is big enough. The data-XXX values are how the appropriate image is specified. If a screen is wider than the XXX value ...

  • Creating a chrome extension that uses jQuery to manipulate the DOM of a page

    🕑4 minute read
    December 8, 2011

    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...

  • Flipping a UIImage

    🕑1 minute read
    September 25, 2011

    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...

  • Basics of the NSNotificationCenter

    🕑2 minute read
    September 17, 2011

    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...

  • Preventing unstyled content before jQuery loads

    🕑2 minute read
    February 18, 2011

    jQuery is a very powerful tool but because of it's size it can be quite slow to load, and on some older devices it can also be slow to "boot up" and become ready for action (I'm looking at you iPad/iPhone!)

    Why is this a problem?

    In my case the problem is that jQuery loads after the main page body and then executes. This takes time. One of the actions the jQuery needs to do is to hide() an element, however before the jQuery is ready the element is visible. This means that when jQuery is finally ready there ...