Install Squid Proxy on Ubuntu

Install Squid [crayon-59c102ccd2ab8024219157/] When asked to continue press Y Configure Squid The default configuration file for squid is located under /etc/squid3/squid.conf or /etc/squid/squid.conf. [crayon-59c102ccd2ac2844645445/] For http proxy you may need to change below options http_port: Default is 3128 http_access deny all: You may want this to change to http_access allow all for probably testing purpose but real life scenario would be to allow just 1 IP address of your webserver Remember to restart squid after making any changes to the configuration file [crayon-59c102ccd2ac7322885523/]  ...
Read More
Add Google analytics to iOS app

Add Google analytics to iOS app

This shows how to add Google Analytics to your iOS app and not having to use the Firebase Analytics. 1. Login to your Google Analytics Account and create a New Property On the New Property screen select Mobile app, Google Analytics Services SDK. Type your App Name as shown. Rest of the settings can be selected based on your requirement. Then click the button Get Tracking ID Once you get the tracking ID which would be in the format UA-XXXXXXXX-X, click the link for the iOS SDK Getting started guide As mentioned on the Getting Started guide page, create a pod file using terminal by navigating to your project and typing below command [crayon-59c102ccd3266178831044/] Open the newly created pod file and add below code just below the line which says # Pods for My iOS App [crayon-59c102ccd326e542902745/] Run below command [crayon-59c102ccd3272696004558/] Now open your project as workspace Click the button GET A CONFIGURATION FILE on the instructions page which will take you to your firebase console Login and create your Firebase Project if you haven't created by typing your App...
Read More

Empty trash hook in wordpress

In some cases we may want to delete data related to certain post stored in some custom table (i.e. data which is currently not in wordpress). If the data related to a post is not in wordpress then it won't get cleaned once the post is deleted from the wordpress and you may end up garbage and unmanageable data in your custom table. e.g. we have a custom post to register attendees to our events. There is also a need to log if the user had attended previous events too and to maintain their preferences for each year/event. Since it is not possible to store such yearwise/eventwise data in wordpress through custom fields, we may end up creating our own custom table. The requirement is when the user gets deleted from the system, the data stored about the user in the custom table should also get deleted Wordpress provides a hook to clean such data stored in your custom table. [crayon-59c102ccd34e8287158396/]    ...
Read More
How to install Cocoapods

How to install Cocoapods

Start by typing below command in terminal [crayon-59c102ccd8542740942890/] In most cases just the second command would however sometimes you may get below error in case you have an older version of activesupport installed Error installing cocoapods: activesupport requires Ruby version >= 2.2.2 The first command will make sure you don't get the above error Once the above commands run successfully type below command to set up Cocoapods master repo [crayon-59c102ccd854d104598606/] This will download the master repo. The size of the repo is quite big around 380MB so it can take a while depending upon your internet download speed. Once the above is completed, navigate within terminal to your Xcode project and run below command to create the podfile [crayon-59c102ccd8551230758965/] Open the newly created podfile with text editor, and add the required libraries e.g. pod 'Google/Analytics' Then run below command to install the required libraries [crayon-59c102ccd8555718933817/]  ...
Read More
Configure and handle Apple Push Notifications (APN)

Configure and handle Apple Push Notifications (APN)

Configuring Apple Push Notifications (APN) Here are the steps to configure Apple Push Notifications on your IOS app 1. Open project settings, Capabilities Tab 2. Turn On Push Notifications as shown below   3. For security reasons Push Notifications require appropriate SSL Certificates which can be created through your Developer Portal. Here are the steps to create the required certificates. 3 A. Login to your Apple Developer portal 3 B. Click on App IDs under Identifiers 3 C. Click on your IOS App ID entry which shows the services enabled for your app 3 D. Click the Edit button at the bottom of the screen 3 E. Turn on Push Notifications (if not already enabled) 3 F. Click the Create Certificate button under the Development SSL Certificate  3 G. Open Keychain application and Request a Certificate from a Certificate Authority as shown below 3 H. On the Certificate information add your email address, Name (make sure there are no spaces) and Save to Disk 3 I. Double click the certificate to add it to your...
Read More

Customising Navigation Bar or Header in an IOS app

Customising Navigation Bar or Header in an IOS app would involve following things Changing Background Colour Adding a logo Changing Text Colour You would need to add below code mostly to your Initial View Controller [crayon-59c102ccd8d6a209395469/] Just add the lines as per your requirement and change the colour values as per your needs. barTintColor method defines the Tint Color to apply to the navigation bar background The tintColor combines with the translucent part of the bar along with the content behind the bar and results in some different colour. To achieve full control over the colour displayed on the navigation bar you would need to set translucent option to false for the navigation bar appearance method [crayon-59c102ccd8d73444116032/] The other bit of code is self explanatory. It just applied a background colour and shows how to add a logo to your app header...
Read More
How to create wordpress custom filter hook

How to create wordpress custom filter hook

This is just an example explaining how to create a wordpress custom filter hook Let's say you have a page or a plugin displaying posts/custom posts based on a certain criteria Now you wish to provide a hook to the end user to be able to modify how the posts get displayed. Here is a sample code to display posts using a standard wordpress loop [crayon-59c102ccd8fbd720266674/] Note that we have displayed the  posts after getting the contents in a variable named $wpi_snippet_view. This helps us to define a hook to be able to modify this variable. Below code shows how to define our custom filter hook [crayon-59c102ccd8fc6278657816/] The only difference is the above code is line number 19 where we have defined the custom hook as wpi_snippet_view_hook Now that the custom hook is defined, all we need to do is to call the hook in our functions.php and modify the variable $wpi_snippet_view to show the required output. [crayon-59c102ccd8fcb488230758/] Using the above hook we have changed the thumbnail size from thumbnail to...
Read More
Stop bad bots from crawling your website

Stop bad bots from crawling your website

If you are experiencing performance issues with your site one of the reasons could be your Bandwidth is getting unnecessarily utilised by some bad bots. This article explains what are bad bots, how to identify them and how to stop bad bots crawling your website so that your genuine visitors are not affected. What are bad bots upto? There are quite a number of bad bots operating and the number keeps increasing rapidly. Most of them are from hackers trying to find some vulnerability in your code. They may be trying to get credit card numbers from an online store or may be scraping the text off an article and posting it on some random blog. They may also want to steal username and passwords of peole on your database hoping people use same credentials elsewhere which surprisingly they do. Some may just want to post spam comments on your website. How to stop bad bots from crawling your website Bots are supposed to obey the rules within...
Read More
Server load monitoring tools for your wordpress site

Server load monitoring tools for your wordpress site

Here are some basic tools which will allow you to monitor server load to keep your wordpress site optimised. Uptime (shell command) [crayon-59c102ccd98fd971132897/] Above command is an example of the uptime command. It says the server is up since 364 days, 2 users are logged in and the rest of the numbers are showing the server average load. The three numbers show the load averages for the last minute, 5 minutes and 15 minutes. If you have 4 CPUs and the load is 2 then your server is using half the CPU capacity. If you have 2 CPUs and the load is 2 then your server CPU is running at full capacity. A load above the number of CPUs means that the system is overloaded which reduces performance. top (shell command) [crayon-59c102ccd9905284797431/] top command shows information like tasks, memory, cpu and swap. Here is a sample output of the top command. PHP sys_getloadavg function [crayon-59c102ccd9919180718055/] sys_getloadavg function returns an array. In above code, $load[0] would be the server load value. Based on the above code we...
Read More