Hunspell with PHP on Windows – Part 1

Ok so I hear you saying, how the hell can I use Hunspell and PHP with Windows, Now the way I am going to show you isn't the only way but is a much simpler way without compiling and using binaries. What is Hunspell? Well I can re-write what's already written, however if you wish to find out, please check the link below Long story cut short, Hunspell is a tool that you can use to validate your text against a given dictionary, get options for correct spellings for a wrongly spelt words. What to do next on Windows 8/10? First thing first you have to get the executables, I've got, download and extract it to say c:\Hunspell so path to bin folder will look like c:\Hunspell\bin  This is where you will find hunspell.exe Great so far so good, now let's add our bin folder to our Environment PATH, Setting Environment variable PATH Step 1 Goto Control Panel --> System --> Advanced system settings --> "Advanced" tab --> "Environment Variables" Step 2 Under "System variables" window select "Path" and click "Edit" button Step 3 A window "Edit System Variable" will pop up showing the current value of "Path". At the end of that string add ;c:\Hunspell\bin Step 4 Click Ok buttons to exit current open pop up windows We are pretty much set, now open your command prompt and type [crayon-58db0d272d626145484651/] You will see something like this [crayon-58db0d272d636156856968/] Now try typing baddd and press enter You will see something like this [crayon-58db0d272d63c436998749/] Above line is just options of matching words to correct the misspelled word. This step validates that our installation works ok. However you may see error something like this [crayon-58db0d272d642449706060/] This means that dictionary definitions are missing, how to recover from this situation First thing to do is to use hunspell command with -D … [Read more...]

PHP Start of the day and End of the day for a timezone Util functions

This is a quick post where I am sharing a couple of functions to calculate start of a given day and end of the day for a given timezone Start of the day [crayon-58db0d272e57c108307048/] End of the day [crayon-58db0d272e58e710940459/] [crayon-58db0d272e599010879305/] You can play with these function and can adjust as per your requirement. Let me know if you see any issues with these. I hope that this post will help you out in one way or another, Cheers … [Read more...]

Project Data Sources: re-sync required – Upgrading to PhpStorm 10.0.2

Hey Guys, While I upgraded to PHPStorm 10.0.2 and restarted it, I got this message at the top right corner of this IDE Project Data Sources: re-sync required Unsupported format version 2.2 - (2.4 expected) While that got me puzzled for a while, I thought, because its something to do with data sources, thus possibly there must be some issue there, It turned out to be true, All you have to do is to GoTo View > Tools Window > Database and then hit that refresh (Sync button) Here is how it looks That fixed it for me If you fixed it using some other way, please do share Cheers   … [Read more...]

How to get Pinterest Numeric Board ID

Hi Guys, It used to be easy to get Pinterest board ID before, but for some reason they have buried that sort of information within source, A while back I wrote something that wouldn't use the Pinterest official/unofficial API but parse the HTML source code to extract the board ID. I was using that for myself but today I thought maybe others will find it handy on occasions. This led me port the code and beautify it using a StartBootstrap theme, thus was born. Little tool just to parse that source code and give your the board ID you are looking for. Using this tool is simple. Just enter a valid board URL and a numeric board ID will be displayed somewhere in big text just above word Simple. Let me know if you want to add something to this tool or its giving you an error when you least expected it. This tool is written using PHP, HTML, CSS, JAVASCRIPT and use curl to query board URL's Good luck. … [Read more...]

Android Emulator Windows Hosts file editing

Oh! so you want to update a hosts file just like I wanted and spoiled many minutes playing with what works. Let's go through this process to make it work for you as well (hopefully!) Google Android emulator is an amazing tool to test out your apps, Hybrid or Native. There are many cases when we want to use hosts file to point a domain to a machine located in local network. A good place to start reading about what is or is not possible with emulator when it comes down to networking is to read this help page on Android emulator networking. Edit the hosts file in Android emulator Start your Android Virtual Device (AVD): [crayon-58db0d272edc2615389594/] Emulator is located under "C:\Program Files (x86)\Android\android-sdk\tools" folder, we are adding the partition size so we give enough buffer to write to our hosts file without any error. The error you may get is  failed to copy ‘c:\temp\hosts’ to ‘/system/etc/hosts’: Out of memory Second step is to remount the device image by using the command below [crayon-58db0d272ede3607402204/] adb stands for Android Debug Bridge, to read more on this command please go visit this page, this program can be found in "C:\Program Files (x86)\Android\android-sdk\platform-tools" location of your windows install. Next step is to get the default hosts file and save it on your local hard drive using the command below, I am using the destination location as c:\copied, yours can be anything [crayon-58db0d272edf2871529073/] Make the new entries to you hosts file. Important: Now in the example below I am using a white space instead of a TAB delimiter between IP address and hostname. For me, TAB didn't work. But you can try both to see what works for you. Also not that I am appending my entry to the existing file rather than editing it with notepad. [crayon-58db0d272edff639350138/] Let's save the edited file and send it back to the emulator. [crayon-58db0d272ee09394143777/] Now you are able to browse your … [Read more...]

PHPStorm Painfully Slow….

Oh Yeah, That went and drove me nuts. I would like to share what worked for me. I am a Windows user so the instructions you see in this post apply to windows user, but stuff shall be quite similar for Mac/Linux users too. First thing first start using Java 64 bit to get some instant performance gain. Set your default environment path for java to point to your 64 bit install. Variables such as JAVA_HOME etc I mean. Second thing is to then start using PHPStorm 64 bit. Where do you find it? Depends where you installed it basically. On my system it is located as shown in the screenshot below   Third thing, make sure you are on latest version of PHP storm, WebStorm, IntelliJ whatever, all pretty much based on same core code I would assume.   Wait wait... one more thing before you double click that file to launch your IDE is to edit that PHPStorm64.exe.vmoptions this file is found in the same location as your phpstorm exe, What is this stuff? Read more about vmoptions tuning on PHPStorm site, basically all properties in this file are meant to tune your Java Virtual Machine so it handles PHPStorm stuff better. I won't go into much detail on each property and what it means. You can read all that stuff from oracle website. Here is the link But I want to highlight one thing, the settings that made my PHPstorm good enough to work with it again. Here is my snapshot of vmoptions file [crayon-58db0d272f5ca505112015/] My problem was made worse by font rendering issue that Java has, thus settings -Dawt.useSystemAAFontSettings=lcd -Dawt.java2d.opengl=true ;<-- we are just enabling Java2D OpenGL Hardware Acceleration here so to speed up You can also enable xrender setting to see if that helps, here is my updated vmoptions file. [crayon-58db0d272f5d6998693658/] You should tune Java heaps and cache settings depending on your project. Higher … [Read more...]

Rackspace Cloud FIles Bulk Delete objects prefixed/* wildcard php sdk

Hi Guys   Rackspace cloud files is an awesome file storage system, We upload a file and can make it publicly available through their CDN. While I use Cloud files in pretty much all my projects at work or personal stuff, one thing that I did today was to delete objects with specific prefix e.g. Lets say I have these objects under container "jcorg" hello hello1 hello2 anothervaluableobject and I want to delete all objects whose name starts with hello Here is a code snippet that will be handy for you Language: PHP API link: and of course you can use equivalent code in other language SDKs too     Code Snippet [crayon-58db0d2730ac1523279172/] Let me give you a brief overview to you First we are creating a connection to Rackspace server, depending on which region you are in you will use either RACKSPACE_US or RACKSPACE_UK to authenticate your request. [crayon-58db0d2730ace442123015/] Then we are connection to our object store [crayon-58db0d2730ad4424133544/] Then we are getting hold of object list where name or an object starts with "hello" [crayon-58db0d2730ada008992114/] Finally we are iterating on objects found and deleting them. You can check object name here to just to filter them out before you process them for deletion [crayon-58db0d2730ae0161194120/] I hope this makes sense, but just in case if you have a question, do leave your comment.     … [Read more...]

Yii Framework Apply Custom layout to a controller or action

If you are using Yii PHP framework you are using one of the fastest PHP frameworks around. Sometimes there are minor things that we want to do and couldn't find a document that is to the point and precise in what you are looking after. This Quick Tip article will show you how to use custom layout for your controllers and actions Controllers When you want to use custom layout other than //layouts/main then you can do it in several different ways Option 1 Include $layout property in your class definition as shown below [crayon-58db0d2731278457648875/]  Option 2 Use init() method of Controller [crayon-58db0d273128a505626479/] Option 3 Use beforeAction() to overwrite default value of layout property [crayon-58db0d2731296099935557/] Please note that when you do any of the above layout is applied to all action views. If you however want to only apply a custom layout to one of the controller action then you do it this way Apply custom layout to a Controller Action [crayon-58db0d27312a2372473273/] As we see that in above snippet we are overwriting default value of layout property for just our action Test. Other action views will still be rendered in default or controller layout. I hope that this helps   … [Read more...]

Installing Apache thrift, Cassandra 2.x and YACassandra-PDO on CentOS 6.5+

Hello, Well after a long time this is my in length article, the reason I am writing is because of all the stuff I have been gone through building thrift and cassandra-pdo on centOS 6.5 Versions I will be writing about installing latest version of thrift that at time of writing and RnD was 0.9.1, CentOS is version 6.5 64 bit, php 5.3.3,  Apache/2.2.15, Cassandra is at version 2.06 which is most stable version for production at the time of writing.   Prerequisite Most of the commands will need elevated privileges. You should prefix sudo with every command, I am doing it on test VM so doing it as privileged user root Packages wget, nano are available if not then yum install them as shown below. Of course if you use vi or other util other than wget to download files then skip this [crayon-58db0d2731ecb765264179/] Ok so lets get started. When I started building thrift, or cassandra pdo I was getting all sort of errors such as [crayon-58db0d2731eda179598555/]   Install Cassandra Installing cassandra is the simplest one, We will be installing it from rpm provided by datastax Open datastax.repo for editing with following command [crayon-58db0d2731ee3252859462/] paste following content in editor [crayon-58db0d2731eed425593766/]  Install cassandra [crayon-58db0d2731ef8017254158/] Above command will also install openJDK but cassandra guys recommend that we should use latest java from Oracle so lets do that now Get into opt directory You can actually choose to be any other directory of your liking [crayon-58db0d2731f03850645091/] Get RPM path for latest jre  from I am using jre 8 from   [crayon-58db0d2731f0e753972592/] output of java --version would be  something like [crayon-58db0d2731f1a014722395/] Lets now install Development … [Read more...]

Installing YAF php framework and getting /usr/include/php/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory on Centos 6+

Hi Guys, Yaf framework appears to be the fastest framework around, logically so because its built with C and compiled in a PHP extension. While installing Yaf, I ran into a problem where it seems like make was complaining about pcre.h missing and progress get halted at make: *** [yaf_router.lo] Error 1 ERROR: `make' failed To solve this first I would like to point out to run a yum update [crayon-58db0d2733034882790423/] Secondly make sure you have all of the stuff below [crayon-58db0d273303f245753959/] and now you should install yaf normally through pecl now as shown below [crayon-58db0d2733045491703784/] This should work now, and finally you should add the compiled so extension to php.ini file [crayon-58db0d273304b465807876/] add line below [crayon-58db0d2733050294368739/] Once this is done restart your apache service and yaf as module will now be available with all its APIs and stuff I hope this helps. If I missed a point or 2 please leave your comment for others to benefit from. Cheers,   … [Read more...]