Skip to content

Instantly share code, notes, and snippets.

View HarishChaudhari's full-sized avatar

Harish Chaudhari HarishChaudhari

  • Bitwise Global
  • Pune
View GitHub Profile
@HarishChaudhari
HarishChaudhari / country-code-to-currency-code-mapping.csv
Last active September 9, 2024 10:00
Country, Country Code, Currency code mapping in CSV format Taken from https://gist.github.com/304261 Contains 249 countries.
Country CountryCode Currency Code
New Zealand NZ New Zealand Dollars NZD
Cook Islands CK New Zealand Dollars NZD
Niue NU New Zealand Dollars NZD
Pitcairn PN New Zealand Dollars NZD
Tokelau TK New Zealand Dollars NZD
Australian AU Australian Dollars AUD
Christmas Island CX Australian Dollars AUD
Cocos (Keeling) Islands CC Australian Dollars AUD
Heard and Mc Donald Islands HM Australian Dollars AUD
@HarishChaudhari
HarishChaudhari / Authorize.net important error codes.csv
Created February 1, 2013 06:17
Authorize.net important error codes in csv format
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 3 in line 1.
List of error codes to process:
response_reason_code,reason_text,reason_note
2,This transaction has been declined,
3,This transaction has been declined,
4,This transaction has been declined,The code returned from the processor indicating that the card used needs to be picked up
6,The credit card number is invalid,
7,The credit card expiration date is invalid,The format of the date submitted was incorrect
8,The credit card has expired,
13,The merchant API Login ID is invalid or the account is inactive,
19,An error occurred during processing,
@HarishChaudhari
HarishChaudhari / us-states-json-array.json
Last active November 2, 2023 09:38
US State names with ISO 3166-2 Codes in JSON array, can be useful while working with Google Maps
[
{"name":"Alabama","iso_code":"US-AL"},
{"name":"Alaska","iso_code":"US-AK"},
{"name":"Arizona","iso_code":"US-AZ"},
{"name":"Arkansas","iso_code":"US-AR"},
{"name":"California","iso_code":"US-CA"},
{"name":"Colorado","iso_code":"US-CO"},
{"name":"Connecticut","iso_code":"US-CT"},
{"name":"Delaware","iso_code":"US-DE"},
{"name":"District of Columbia","iso_code":"US-DC"},
@HarishChaudhari
HarishChaudhari / cpt-to-cpt.php
Last active August 17, 2021 12:13
Copy posts from one Custom Post Type to another. (It doesn't handle post attachments for now)
<?php
add_action('admin_init', 'foo_duplicate_posts', 99999);
function foo_duplicate_posts(){
// Only allow admins to run the script
if(!current_user_can('manage_options'))
return;
// Check if keyword is set
if(!isset($_GET['duplicate-posts']))
@HarishChaudhari
HarishChaudhari / cpt-to-cpt.php
Last active March 20, 2017 14:46
code to transfer from CPT to CPT
<?php
function foo_duplicate_posts(){
# Only allow admins to run the script
if(!current_user_can('manage_options'))
return;
# Check if keyword is set
if(!isset($_GET['duplicate-posts']))
/**
* Form Validation
*
* @since 11/04/2014
* @author Harish
*/
function enformValidation() {
var i = 0;
// Validate
@HarishChaudhari
HarishChaudhari / cf7-custom-validation.php
Created November 5, 2014 08:08
Contact Form 7 custom validation
<?php
// Add custom validation for CF7 form fields
function custom_text_validation_filter($result,$tag){
$type = $tag['type'];
$name = $tag['name'];
$the_value = $_POST[$name];
if($name == 'firstname'){
if( empty($the_value) ) {
$result['valid'] = false;
@HarishChaudhari
HarishChaudhari / ctrl-key-detection.js
Created February 6, 2015 11:23
CTRL + key detection in JavaScript
/* This may not work with default browser shortcuts. Need to give it a try though. */
/* Create function */
$.ctrl = function(key, callback, args) {
$(document).keydown(function(e) {
if(!args) args=[]; // IE barks when args is null
if(e.keyCode == key.charCodeAt(0) && e.ctrlKey) {
callback.apply(this, args);
return false;
}
<?php
class polishcalculator {
/**
* Variables
*/
private $expected;
private $polishexprestion;
private $token;
@HarishChaudhari
HarishChaudhari / polishcalculator_test.php
Created June 24, 2015 14:15
Polish Calculator Unit tests
<?php
/**
* First, download phpunit.phar from www.phpunit.de
* Navigate to PHP bin folder and enter following command to execute tests:
*
* php.exe phpunit.phar --bootstrap c:\wamp\www\unit\src\polishcal\polishcalculator.php c:\wamp\www\unit\tests\polishcal_test\polishcalculator_test.php
*
*/
class polishcalculatorTest extends PHPunit_Framework_Testcase {