Just went through awesome survey of software developers done by Stackoverflow for year 2015. Pakistan was missing on the webpage but data was available to review in CSV format. From that CSV file I am going to share Pakistan software developers stats here. Wherever it would be possible I will compare Pakistan’s stats with India’s Continue reading
Multiselect List Not Posted In Form
Its funny sometimes being experienced we make such mistakes that we never had imagined. Scenario I had to send to form with multiselect values but these were not getting posted Funny Reason I was moving values to right box but values were not selected as you can see in previous image above and I was Continue reading
Fancybox Title Options & Stylings
Fancybox is a Jquery’s gallery plugin and it comes with four options to display title of image in overlay. Here are these four options are displayed with image examples. Floating Title This is default and if you don’t mention any type for title then title will use Float option. I won’t recommend it because the Continue reading
Freelancing Tips & Tricks – Upwork
Thanks to Almighty God I received email from Odesk(now Upwork) in March 2015, for being a top rated freelancer with 100% job success rate. I am adding here few tips and tricks for upcoming freelancers. I will keep updating this article with time. I had 6 years of experience before entering the freelancing field and Continue reading
Best Recommendable Jquery Gallery Plugin – Galleria
Recently my client asked to implement gallery in a project which has following functionalities 1. Beside gallery slideshow, if clicked on gallery main image it should pop out a bigger images gallery as well. 2. It should also display title and description of the image. 3. Should be responsive as well. 4. Can work in Continue reading
Addthis – Bigger Social Icons
Recently I was asked to make bigger social icons for Addthis widget. Addthis provides maxiumum of 32×32 size of social icons(ref). You can add your bigger images instead, by using following code.
1 2 3 4 5 6 7 |
<div class="addthis_toolbox addthis_default_style addthis_32x32_style addthis_margin"> <a class="addthis_button_facebook"><img src="/assets/img/fb_logo.png" id="fb_share" class="social_buttons" alt="Share On Facebook"/></a> <a class="addthis_button_twitter"><img src="/assets/img/twitter_logo.png" class="social_buttons" alt="Share On Twitter"/></a> <a class="addthis_button_linkedin"><img src="/assets/img/linkedin_logo.png" class="social_buttons" alt="Share On Twitter"/></a> <a class="addthis_button_pinterest_share"><img src="/assets/img/pinterest_logo.png" class="social_buttons" alt="Share On Twitter"/></a> <a class="addthis_button_google_plusone_share"><img src="/assets/img/google_plus_logo.png" class="social_buttons" alt="Share On Twitter"/></a> </div> |
So, basically I have added <img> tags between the anchor <a> tags in above code. Please set the image “src” Continue reading
Zendesk API Implementation In Codeigniter
Recently I had to implement the Zendesk API for exporting users to Zendesk. First here is the controller file created on this path application/controllers/admin/admin_zendesk.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); define("ZDAPIKEY", "your zendesk api key here"); define("ZDUSER", "username or email here"); define("ZDURL", "https://abc.zendesk.com/api/v2"); //replace abc with your domain name. class Admin_zendesk extends CI_Controller{ public function __construct() { parent::__construct(); if(!$this->auth->try_session_login() || get_field('role_id') < '99') redirect('/account/'); } public function index() { die('Nothing here'); } function curlWrap($url, $json, $action) { $ch = curl_init(); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 10 ); curl_setopt($ch, CURLOPT_URL, ZDURL.$url); curl_setopt($ch, CURLOPT_USERPWD, ZDUSER."/token:".ZDAPIKEY); curl_setopt($ch, CURLOPT_CAINFO, "C:/cacert.pem"); //I downloaded the certifcate to this location for CURL. switch($action){ case "POST": curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); break; case "GET": curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); break; case "PUT": curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); break; case "DELETE": curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); break; default: break; } curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json')); curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $output = curl_exec($ch); echo 'Curl output: ' . curl_error($ch); curl_close($ch); $decoded = json_decode($output); return $decoded; } public function export_users(){ //dummy users array for exporting to Zendesk. You can fetch from your database/model here. $users = array( 'users' => array( 0 => array( 'name' => 'Test User', 'email' => 'test@gmail.com', 'external_id' => '', 'details' => 'details', 'notes' => 'any notes', 'phone' => '1234567', 'role' => 'end-user', 'restriction' => 'restriction', 'organization' => 'org', 'tags' => 'tags, etc' ), 1 => array( 'name' => 'Test User 2', 'email' => 'test2@gmail.com', 'details' => 'details', 'notes' => 'any notes', 'phone' => '1234567', 'role' => 'end-user', 'restriction' => 'restriction', 'organization' => 'org', 'user_fields' => array( 'user_id' => '444444444', 'company' => urlencode('abc'), ) ) ) ); $json = json_encode($users); $data = $this->curlWrap("/users/create_many.json", $json, "POST"); //create_many is used for exporting multiple users. print_r($data); // for displaying what is returned. exit; } } /* End of file zendesk.php */ /* Location: ./application/controllers/zendesk.php */ |
Add the following line to application/config/routes.php to access the export_users function
1 2 |
// zendesk admin $route['admin/zendesk/export_users'] = "admin/admin_zendesk/export_users"; |
Now you can access the URL http://testdomain.dev/admin/zendesk/export_users or http://localhost/admin/zendesk/export_users to see above code in action. In controller code on line 66, I Continue reading
Most common tasks in Jquery and Javascript
Confirm Alert Before Deleting or Similar Action
1 2 3 4 5 6 7 8 9 |
function removeProgram(){ if(confirm('are you sure you want to delete program?')){ //do whatever here } } //---OR---// <a href="delete/123" onclick="return confirm('are you sure?')">delete</a> |
Check If Variable is Undefined Or Has No Value
1 2 3 4 |
//To check if variable "data" contains any value or not. if(data !== null && data !== undefined){ //Do whatever here } |
1 2 3 4 5 6 |
//you can write following code in document.ready function $('#id_of_input').keypress(function (e) { if(e.which ==13){ //13 is numeric value of enter key form.submit(); } }); |
Hit Enter Inside Input Field And Submit Form
Pagination URI segments – Codeigniter
After a vast work experience in CakePHP when I had to impliment pagination related task in Codeigniter I ignored one thing and basically it was very important for implementing proper pagination. It is uri_segment configuration of pagination. uri_segment is actualy segments of urls So for example URL for pagination will be like http://example.dev/admin/membership/referels/1/7/10 then set uri_segment to 6
1 |
$config["uri_segment"] = 6; |
GIT error while Compose Install
If you are trying to run any Compose command in Windows CMD and getting following error
1 |
'git' is not recognized as an internal or external command, operable program or batch file. |
Then the quick tip is that, if GIT is installed then use “GIT Bash” instead of CMD to use “compose install” and releated commands.