Hello, In the past we have used setcookie() function and $_COOKIE global array to create and access cookies for our domain that expires in N number of days. If you are using Yii framework, it comes with couple of handy classes that you can manage your cookies utilizing Yii poweress. These two classes are called CCookieCollection Doc URL: http://www.yiiframework.com/doc/api/1.1/CCookieCollection CHttpCookie Doc URL: http://www.yiiframework.com/doc/api/1.1/CHttpCookie CHttpCookie is responsible for creating a cookie. An instance stores a single cookie that includes cookie name cookie value domain it is valid for path expiry date indication if cookie is on secure channel CCookieCollection is a collection of cookies Generally you will get all the cookies set by you as where Yii::app()->request is an instance of CHttpRequest Ok so lets create a cookie A simple cookie can be created as as per the documentation the default constructor for CHttpCookie is shown below Where options can be domain, expire, path, httpOnly, secure In our example above we are setting our cookie to expire after 365 days and to send this newly created cookie to our cookie collection we will do the following Send cookie to cookie collection How do we read cookie value You can use the code below to read your cookie value. Now $value will have value 'my_cookie_value' How to remove a cookie Its really as simple as this. The code below will remove the cookie altogether. There are a few handy methods in CCookieCollection such as add(), remove() etc that you can use to add or remove cookies if you prefer to use class functions. Idea of this post was to show how we can set cookies with Yii framework. Yii Framework classes are just a wrapper to already existing functions in code PHP with a little bit of flexibility and event handling added that gives you more control. I hope that … [Read more...]
Using font awesome as icons to beautify Input boxes
Hello, Well first of all thanks to creator of font awesome who has developed such a wonderful font that we can use and get rid of those images that we used for past many many years to beautify our buttons, informational messages etc. Its HTML5 and CSS3 days now and all is starting to make sense now. Purpose of this post is to show you how we can use font awesome to beautify a HTML text field or a HTML number box or similar. Its not exactly a background image but our Font awesome icon will be placed on top of our input box so that it act as one. Ok so if you have no Idea what I am talking about you should check this out and comeback to finish reading this post OR just finish this post and then visit the link below :) http://fortawesome.github.com/Font-Awesome/ Alright so lets get started here First download fontawesome from the URL above. Font awesome is a font library with CSS wrapper that was first created for Twitter bootstrap (http://twitter.github.com/bootstrap/) and offers many advantages. Some of the advantages are highlighted below With one single font you get 220+ vector icons, that means it does not matter how big you want to make your font size the quality will not deteriorate. Its absolutely FREE for commercial use. I would suggest you though to make generous donations because this type of stuff takes a while to build and what more satisfactory than supporting a good souls those are making their work freely available. CSS wrapper. i.e. you don't do anything with the font directly and use CSS to manipulate your icons. It comes with IE7 support (A stroke of a genius) and much more Alright lets jump into some depth now with some examples that I assume that you are not using twitter bootstrap at all. Here are the installation instructions Download and extract fontawesome somewhere on your harddrive Now Copy the Font directory into your project. Copy font-awesome.css into your project Open font-awesome.css and … [Read more...]
HTML5 force download using different file name
Hello, Now that lots of people are wondering about what HTML5 is I am thinking why not add another category called HTML5 and share whatever I have learnt and will learn in future. Todays post is about HTML5 attribute called download We have been using PHP and other scripting languages to read a file, setup proper headers and force download a file with a changed file name. All of that worked but its not essential anymore at least in Google Chrome that at the time of writing supports download attribute Lets check the Markup first The HTML5 Markup Now as you can see that the hyper link is pointing to a file called star_yellow.png but our download attribute value is set to star.png This attribute will force browsers (at the moment only chrome) to download file with name star.png Now this is great because we have been generating some sort of files especially Pdfs , Images etc on the fly reacting to a user action and then our script at server handles the rest. This actually gives flexibility for a programmer to program for hyper link without worrying about the server side code or configs Another good point about download attribute is that it force a file to be downloaded rather than open in the same browser window if browser support a file format such as pdfs or images etc. I am looking forward for this attribute to be supported by all major browsers but only time will tell when we will see those days will come. I am pretty sure that all browsers devs are working really hard to make HTML5 work as a standard. Advertisement Demo http://jaspreetchahal.org/examples/html5-download-attribute.html Try it in chrome I hope that you found this reading useful. I will bring some other cool HTML5 features that are easy to add and use Till then goodbye Cheers … [Read more...]
How to check if jQuery is loaded and include it programatically if not
Hello, There are many a times when you want to do this but if you are a plugin or jQuery widget developer then this becomes much more important. It becomes important because your widget or plugin may not work if jQuery is not present. right? Ok so lets check it out To check if jQuery is present or not then you can choose any one of these methods First method Second Method This is a bit more comprehensive and check if jQuery is not present to jQuery has preoperly loaded yet Alrigth so now we know how to check if jQuery is loaded or not now we want to include it if its not there at all this is how I do it normally. Including jQuery programatically I will just copy the first method here and put the jQuery inclusion code in the first if Ok so this is how I would approach this problem. If you think of something that can be done to improve this please share it using site comments. I hope that this helps you in one way or another. Cheers Advertisement … [Read more...]
jQuery List Iteration Tricks
Hello, Reason for this post is to show you how to iterate through Unordered or Ordered lists with jQuery. There are many times that you want to do this because of N number of reasons. You will also know after reading this about how to get number of list elements. Lets jump into it and see how we can do it Lets consider the mark up below to work with. The Markup Ok so the above code is clearly very simple, nothing there that need explanation but I will explain it anyway We have one list with ID names Then we have a DIV container where we will push our iteration results Third we have an anchor that we will use as a clickable object and once user clicks on it, our code will iterate through the list The jQuery Code Considering that you already have included jQuery on your page this code can be placed somewhere on your page Alright so this code is what you need to iterate through our list. Lets check it with a demo Demo http://jaspreetchahal.org/examples/jquery-examples/jquery-list-iteration.html Now what I've shown you is a good enough technique, But lets take that to another level now that will give us more flexibility. We will need to stylize our list first The CSS Please keep in mind that this is just a basic example and you can extend to whatever you would like to Ok So now lets take a look at our jQuery code (can be improved) The jQuery code Usage Demo http://jaspreetchahal.org/examples/jquery-examples/jquery-list-iteration-plugin.html So we end up making use of few jQuery functions and links to those are below The .find() function http://api.jquery.com/find/ The .eq() function http://api.jquery.com/eq/ And we end up using recursive approach to iterate through our list I hope this helps in one form or another. Cheers Advertisement … [Read more...]
Chrome on iPhone iPad Find on page
Hello, Yes! I understand that you installed cool browser app called chrome on your iPhone or iPad and now you want to know how to find something on a page that you are viewing. Right?? You are reading the right article on feel good blog :) Find in page is really easy in Chrome Ok rather than wasting time to make this article very long lets get straight to the point. First tap on the chrome icon and fire it up. Type your favourite website address and hit Go. I am using one of the pages on my blog as the initial view is shown below Ok so now press that (3 lines) button next to address bar as shown below As you can see that when you hit that button a drop down menu will show up. That where you will find that Find in Page function. Hit that menu item and you will get an input box where you start typing what you want to search on that page as shown below As you can see that I am typing text "windows box" and Chrome is highlighting it with orange background that is cool and now to go find next and previous entries for that text just press Up (^) and Down (V) buttons and thats pretty much it. Oh and yes it does show you how many matches it has found on the page for what you are trying to look for. Chrome is a wonderful browser and I think its better than other browsers available as an app in iOS platform. I wrote this post just because I was looking at it and unlike Safari where finding a text on page is not that friendly, Chrome is just opposite. It makes things easier for you. I hope that this is what you were looking for. Please leave your comments just in case if I missed a point. Cheers Advertisement … [Read more...]
setting up httpie and curl on Windows environment
Hello, Thanks Jason for sharing a link to HTTPIE. HTTPIE is basically a command line util to make interaction with your webservices. You can use it so effectively that you will wonder why you were using old styled scripts to perform tasks that can be done easily with this tool. This post is about setting up httpie. httpie can be used for debugging, automating tests, and for general interaction with your web services. Ok so lets get started. Step 1 HTTPIE is python based so you will need python on your windows box. You can get a 32 bit or 64 bit installer from here http://www.python.org/download/ Run the installer and I think by default it will try to install it to this path Now that you've got Python Installed, Open Advanced system settings under Control Panel\All Control Panel Items\System And add c:\Python32 and C:\Python32\Scripts to the Path variable as shown below. Scripts folder is where our HTTP command lives that I will show you in a while. Now that our Python is setup we will install curl library now Step 2 Goto http://curl.haxx.se/download.html and Under Win32 -Generic, you should find curl package for win 2000/XP version 7.27.0. Direct link to download the library is below http://curl.haxx.se/gknw.net/7.27.0/dist-w32/curl-7.27.0-rtmp-ssh2-ssl-sspi-zlib-idn-static-bin-w32.zip Download the library and extract it to c:\tools Add c:\tools to your environment path just so that curl command is available from anywhere. Step 3 Fire up your command prompt as administrator now that both curl.exe and python.exe available, execute this command to install setuptools Step 4 Install Python package installer util called pip More details can be found here https://github.com/pypa/pip to install pip run this command If everything went on smoothly you will get this message Step 5 Now lets install httpie as all the requirements has been met, run this command from your … [Read more...]
YiiFramework set page title
Hello, Yii is awesome, easy to learn PHP framework and is brisk fast and offer so much that you can't turn your back on it. Combined with Zend framework its a killer combination. This post is about me showing you how to set a page title in YiiFramework. Let check it out Now when you install Yii and create a web project Controllers and Views directories are created by default. Under views directory you've got a folder called layout Under that folder there should be a php file with name main.php, You don't really have to use the default template of course. You can create your own and use that making required changes to your Yii config. Anyway under main.php look for this line The variable pageTitle is what we need to set. You have got 2 choices. Either set it in Controller action or In the view file it self. For me View is somewhere I would put my pageTitle in. Example Controller action Say your controller file is called DefaultController.php and it has an action method Index, Below is how you set a pageTitle property. Where $this is current instance of Controller. Please note: If you don't set pageTitle then this property default to Controller' Action name Setting up in View File I will always set a pageTitle under a view file. I personally think that View is the right place to put your pageTitle in. So if your View file is index.php Then somewhere in that file do this Couple of points. If you are not using default Layout file then make sure that the title tag should look like this You can place $this->pageTitle = "My Page Title"; anywhere in your View file or Controller action. It is not required to be the first line or last line. But for consistency sake you may wish to place it somewhere where other devs working on the same project can find it easily rather than to override your code. I hope this helps you Cheers Advertisement … [Read more...]
Photoshop CS5 Keyboard different color key
Hello, To start with I am not a Photoshop Pro as my primary job is of a Programmer but I am an enthusiast that like to play with Photoshop as a hobby. I like editing my son's and my wife's pictures. But sometimes to understand Photoshop better I will do something that could be useful to understand. The technique in this post is to transform a keyboard key to a different color. I thus have created a Video to highlight what I did. I am not claiming that this is the best technique or the only technique but for me it worked. So if you are a photoshop expert then please let me know how I can improve on my technique. Ok so an example keyboard image before I edited it looks like this and after edit it will look like this You can follow step by step instructions from the video that I created. I think its better to explain it that way rather than to write a long post where sometimes I end up missing a step or two. Video Tutorial httpvh://www.youtube.com/watch?v=sI9Zs4GQvTE Please let me know how did I do with the Vid? I know I kinda mess up sometimes because of the nervousness while recording. I am working on wordpress plugin which I will be releasing either tomorow to the day after. I hope that you enjoyed this information share, thats what I call it rather than tutorial because for me I label my post as tutorial when I think I know 100% about the topic. Photoshop is not my forte so I won't claim expertise. But this Keyboard key highlighting effect with different color was awesome thing to learn and do it all by myself. I will see you tomorow with another post Cheers Advertisement … [Read more...]





JC WordPress Coupon Revealer Plugin Pro License
Australian Street Names with City, State and Display Names only, Single Server License
Recent Comments