Skip to content

Instantly share code, notes, and snippets.

View gunjanpatel's full-sized avatar

Gunjan Patel gunjanpatel

View GitHub Profile
@gunjanpatel
gunjanpatel / postal-codes.json
Created July 6, 2017 08:00 — forked from matthewbednarski/postal-codes.json
Global postal codes regex formats
[{ "Note": "The first two digits (ranging from 10–43) correspond to the province, while the last two digits correspond either to the city/delivery zone (range 01–50) or to the district/delivery zone (range 51–99). Afghanistan Postal code lookup", "Country": "Afghanistan", "ISO": "AF", "Format": "NNNN", "Regex": "^\\d{4}$"}, { "Note": "With Finland, first two numbers are 22.", "Country": "Åland Islands", "ISO": "AX", "Format": "NNNNN", "Regex": "^\\d{5}$"}, { "Note": "Introduced in 2006, gradually implemented throughout 2007.", "Country": "Albania", "ISO": "AL", "Format": "NNNN", "Regex": "^\\d{4}$"}, { "Note": "First two as in ISO 3166-2:DZ", "Country": "Algeria", "ISO": "DZ", "Format": "NNNNN", "Regex": "^\\d{5}$"}, { "Note": "U.S. ZIP codes (range 96799)", "Country": "American Samoa", "ISO": "AS", "Format": "NNNNN (optionally NNNNN-NNNN or NNNNN-NNNNNN)", "Regex": "^\\d{5}(-{1}\\d{4,6})$"}, { "Note":
@gunjanpatel
gunjanpatel / economic.php
Created September 23, 2016 14:09
redSHOP CLI script to add e-conomic orders using CRON
<?php
/**
* @package Joomla.Cli
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// Make sure we're being called from the command line, not a web interface
if (PHP_SAPI !== 'cli')
@gunjanpatel
gunjanpatel / company_rules_in_ahmedabad.php
Last active August 23, 2017 07:27
How programmer explain when he feels disappointed?
<?php
/**
* This script is intented to give real life example and written based on expereience of company.
*
* @package Company.Rules
*
* Copyright (c) 2009-2016 Gunjan Patel<http://www.gunjanpatel.info>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
@gunjanpatel
gunjanpatel / get-menu-item-backend.php
Created July 11, 2016 05:10
Get article or content menu item from backend
<?php
// Get site menu - specially pass `site` argument as you are going to get site menu from backend.
$menu = JFactory::getApplication()->getMenu('site');
// Get menu item based on query
$menuItems = $menu->getItems('link', 'index.php?option=com_content&view=article&id=' . (int) $this->item->id);
@gunjanpatel
gunjanpatel / multiple_ssh_setting.md
Created June 24, 2016 15:37 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@gunjanpatel
gunjanpatel / revert-a-commit.md
Last active September 20, 2025 22:27
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@gunjanpatel
gunjanpatel / bitbucket_multi.md
Created May 10, 2016 06:13
How to maintain multiple bitbucket accounts with multiple ssh keys in the same system
@gunjanpatel
gunjanpatel / shift redshop script.md
Created April 21, 2016 07:33
shift redshop script on first
$document = JFactory::getDocument();

// Store document script in variable
$scripts = $document->_scripts;

// Clean document script head temporary
unset($document->_scripts);

// Find the redshop js to shift it up
@gunjanpatel
gunjanpatel / git-beautify.md
Last active May 8, 2018 07:23
Setup Git short codes and terminal them to show branch and path

Git short commands

You can enable short commands by updating your home .gitconfig file. Goto /home/{user}/.gitconfig file and add contents from https://gist.github.com/gunjanpatel/10019184 file.

Beautify terminal for git commands

1. Create the files which you will need to copy later from git repository

touch ~/.git-completion.bash
touch ~/.git-prompt.sh
@gunjanpatel
gunjanpatel / filter.md
Last active September 25, 2015 04:55
joomla method to filter username string
<?php
$string = 'Hello $ World/';
$username = JFilterInput::getInstance()->clean($string, 'USERNAME');