Skip to main content

Posts

Showing posts from July, 2012

JavaScript - Singleton Pattern

The singleton design pattern is probably the simplest and most common pattern in JavaScript. So why should you use the singleton pattern? Encapsulation of members & functions Creates its own Namespace A singleton is a single instance object Encourages code reuse Improves readability because you can logically organise your code The point of a singleton is to only have one instance. A shopping cart is a good example of something that you may want only a single instance of at one time. The simplest form of Singleton is an object literal. This loose form of Singleton cannot be instantiated. All of the members are now accessible through the Singleton variable, accessible through dot notation. var myCart = {     self: this ,     totalCost: 0,     totalQty: 0,     cart: {},     getCart: function (){ },     updateCart: function (){ } }; alert( "Total cost: $" + myCart.totalCost ); By using closures, we can create Private and Publi

HTML5 localStorage

Persistent Client-Side Key-Value Pairs The localStorage object has four primary method: localStorage. clear () localStorage. getItem ( key ) localStorage. removeItem ( key ) localStorage. setItem ( key, value ) When dealing with the localStorage object, it is important to remember that, like cookies, you are dealing with string values. Both the key and the value arguments must be strings. And, while the browser might not throw an error if you pass-in non-string values, you'll quickly find that it is simply calling the toString() method implicitly. Run the following sample code and check the console: <html> <head> <script type="text/javascript"> console.log("tim in localStorage —",("tim" in localStorage)); console.log("localStorage.getItem( tim ) —",localStorage.getItem( "tim" )); localStorage.setItem( "tim", "nice" ); localStorage[ "bad" ] = "awesome"

Download entire website from terminal using wget

This will help you to download entire website along with the links to other pages.i.e, you can almost browse the website offline. First install wget(if not present). Then run this from terminal. wget --mirror -p --convert-links -P ./LOCAL-DIR WEBSITE-URL –mirror : turn on options suitable for mirroring. -p : download all files that are necessary to properly display a given HTML page. –convert-links : after the download, convert the links in document for local viewing. -P ./LOCAL-DIR : save all the files and directories to the specified directory.

How to format USB or external drive in Ubuntu

If you could find the device on the Launcher, just right-click and select "format". Otherwise, see this.... You can use the disk utility(installed by default) to format the drive. There is an option 'format volume' select that option.

Taking Screenshots in Mac OS X

Command-Shift-3: Take a screenshot of the screen, and save it as a file on the desktop Command-Shift-4, then select an area: Take a screenshot of an area and save it as a file on the desktop Command-Shift-4, then space, then click a window: Take a screenshot of a window and save it as a file on the desktop Command-Control-Shift-3: Take a screenshot of the screen, and save it to the clipboard Command-Control-Shift-4, then select an area: Take a screenshot of an area and save it to the clipboard Command-Control-Shift-4, then space, then click a window: Take a screenshot of a window and save it to the clipboard In Leopard and later, the following keys can be held down while selecting an area (via Command-Shift-4 or Command-Control-Shift-4): Space, to lock the size of the selected region and instead move it when the mouse moves Shift, to resize only one edge of the selected region Option, to resize the selected region with its center as the anchor point

Submitting Your App to AppStore

Submitting your app to the App Store is a multistep process involving several tools. First, create a distribution provisioning profile using iOS Provisioning Portal. Then create an archive, validate it, and submit it to the App Store using Xcode. When your app is approved, set the date the app will be available to customers using iTunes Connect. Finally, don’t forget to respond to user issues after you ship your first version. Before You Begin Before starting, you should have a distribution certificate and the status of your iTunes Connect app record should be “Waiting for Upload” or later, as described in  “Creating Your App Record in iTunes Connect.” Now, create a distribution provisioning profile using the iOS Provisioning Portal. Create a Distribution Provisioning Profile When the app is ready for publication, you create a distribution provisioning profile by selecting App Store as the method of distribution. The steps are similar to creating an ad hoc provisioning profil

Creating Your App Record in iTunes Connect

When an app is sold in the App Store, the store displays a lot of information about the app, including its name, a description, an icon, screenshots, and contact information for your company. To provide that information, you log in to iTunes Connect, create a record for the app, and complete some forms. In this chapter you learn how to go through this process. Note:  Normally, you create your iTunes Connect app record late in the development process because there’s a time limit from when you create the record to when you must submit your app. However, some Apple technologies, including Game Center and In-App Purchase, require that an iTunes Connect record to be created earlier. For example, with In-App Purchase, you need to create the app record so that you can add the details of the items you want to sell. This content needs to be created before the development process is complete so that you can use it to test the code you added to implement In-App Purchase. Before You Begin

Creating Distribution certificate

Before an app can be distributed, your team must have a valid distribution certificate linked to a distribution provisioning profile. Only team admins can create or install a distribution certificate. Each team can have only one active distribution certificate. The team admin can either use Xcode to create a distribution certificate or manually request and download one from iOS Provisioning Portal. A team’s distribution certificate allows a developer to build an app for distribution. If your team wants to use another Mac to create a distribution build, you need to transfer a copy of the distribution certificate as described in,  “Safeguarding and Transferring Your Signing and Provisioning Assets”  in  Tools Workflow Guide for iOS . Using Xcode to Create a Distribution Certificate You should use Xcode to create your distribution certificate. Xcode creates, downloads, and installs a development certificate, distribution certificate, and the iOS Team Provisioning Profile for you.