How to reverse the ids in a mysql table column without breaking primary key constraint?

Let me explain the problem scenario: Let us assume we have a table with 4 columns in it out of which 1 is PRIMARY column and rest 3 contain some data.

What we want to do is to reverse the primary key IDs for that data keeping the rest of data intact. It is like shifting the first row to end and moving last row to starting.

Initial Data

idnameemailanything
1jacobwhateverhow to reverse
3nathanwhosoeverisnathanids in mysql table column
4jagmohanidontknowjagmohanwithout breaking
8monicaiamsexyprimary key constraint
9batmanidontexistinrealworldi am batman

Data after update

idnameemailanything
9jacobwhatever how to reverse
8nathanwhosoeverisnathan ids in mysql table column
4jagmohanidontknowjagmohan without breaking
3monicaiamsexy primary key constraint
1batman idontexistinrealworld i am batman

Dude, you are just reversing the column, what is so tough in this?

So, this seems simple to reverse an array if isolated by key “id“. But you have to understand that this column is the primary key. So if you run a command to change id for “jacob” to “9“. It will give you error: “Duplicate entry for id 9

So here is my proposed solution, I start with pair of first and last row and then swap them. Then swap second and second last row. and So on…

If total rows are odd, we will be left with 1 row which does not need correction because it will already be the middle row.

If total rows are even, we would swap middle two rows too.

Here is my solution in PHP

$possible_group_id="3";
$ai=12720; //can be any high int which does not exist in column `id` yet
$q="select id,email from table_name where `possible_group_id`=$possible_group_id order by id asc";
$r=mysqli_query($f,$q);
$row_collection=[];
$ct=[];
while($row=mysqli_fetch_row($r))
{
    $row_collection[]=$row;
    $ct[]=$row[0];
}
$pt=array_reverse($ct);
$size=count($row_collection);
for($i=0;$i<$size;$i++)
{
    $row_collection[$i][2]=$pt[$i];
}
echo "start transaction;<br>";
foreach($row_collection as $k=>$v)
{    
    if($k < floor($size/2)){
    echo 'UPDATE `table_name` SET `id`='.$ai.' WHERE `email`="'.$row_collection[$size-$k-1][1].'";<br>';
    echo 'UPDATE `table_name` SET `id`='.$v[2].' WHERE `email`="'.$v[1].'";<br>';
    echo 'UPDATE `table_name` SET `id`='.$row_collection[$k][0].' WHERE `email`="'.$row_collection[$size-$k-1][1].'";<br>';}
    else break;
}
echo "commit;<br>";

It would output this:

start transaction;
UPDATE `table_name` SET `id`=12720 WHERE `email`="idontexistinrealworld ";
UPDATE `table_name` SET `id`=9 WHERE `email`="whatever";
UPDATE `table_name` SET `id`=1 WHERE `email`="idontexistinrealworld ";
UPDATE `table_name` SET `id`=12720 WHERE `email`="iamsexy";
UPDATE `table_name` SET `id`=8 WHERE `email`="whosoeverisnathan";
UPDATE `table_name` SET `id`=3 WHERE `email`="iamsexy";
commit;

How to remove files with “No Content Changes Found” in Git Desktop

There are 2 possible ways git can find a file changed (even if you didnt change it)

  1. Line Endings have changed
  2. File permissions have changed

for first case try these settings in bash shell. One of these will fix it for you

$ git config core.eol
$ git config core.autocrlf
$ git config core.safecrlf

For second case, here is the flag

git config core.filemode false

Mouse and Keyboard sharing across Computers

We use multiple computers in workspace or in home. Often need to share same mouse and keyboard for all because you probably have a wireless/wired keyboard mouse set. here arises the issue that how to share same set of input controllers for both machines.

Below are a few free and paid options for you to choose from. They all work as expected when computers are connected via LAN or WiFi

  1. Mouse without Borders
  2. Barrier
  3. ShareMouse
  4. Synergy

Microsoft Garage Mouse without Borders

This is all time classic program to share clipboard, mouse movements and what not. For windows to windows mouse sharing this is the best.

It is FREE too

Barrier

This is best alternative in FREE category. It supports MAC OS and Windows both. so this is the one you should go with if you dont have just windows machines.

Sharemouse

This is a good one for cross OSs. It supports both windows and apple mac. Free version is okayish. Can get a bit buggy if you are using a HDMI switch for same monitor mirroring. But still gets the job done.

If you got some bucks to spare, use the paid version which has more features

Synergy

Synergy is the best paid software for this purpose. HANDS DOWN

Supports MAC, Windows and Linux just like the others but provides you support (because you have paid)

How to switch your DNS to Google DNS or Cloudflare DNS on Windows 10?

So, this is the scenario. You are using some local ISP which has its own DNS server fulfilling your DNS requests but to speed things up and not rely upon a DNS server which is updated less frequently. For that purpose,we can switch our computer’s DNS to some other public DNS like Google’s or Cloudflare DNS.

Step 1: Right click the Network Icon in your task bar.

Network Icon in Taskbar
Right Click the network icon in taskbar

Step 2: Choose “Open Network & Sharing Settings

Click Open Network & Sharing Settings
Click Open Network & Sharing Settings

Step 3: Click on “Change Adapter Options

change adapter options
change adapter options

Step 4: Right click on the active hardware and select “properties

adapter properties
adapter properties

Step 5: Select “Internet Protocol Version 4 (TCP/IPv4)” and Click Properties button in the bottom

IPv4 Properties

Step 6: Input the IP addresses after choosing “Use the following DNS Server Addresses

put dns ip here
put dns ip here

Step 7: Select OK to close the pop up window. Restart your browser and have a better browsing experience.


Cloudflare’s Public DNS Servers/addresses for IPv4:

1.1.1.1
1.0.0.1

Cloudflare’s Public DNS Servers/addresses for IPv6:

2606:4700:4700::1111
2606:4700:4700::1001

Google’s DNS Servers for IPv4:

8.8.8.8
8.8.4.4

The Google Public DNS IPv6 addresses are:

2001:4860:4860::8888
2001:4860:4860::8844

Testing Configuration for Paytm Gateway Plugin India

Paytm Payment Gateway Testing Data

Online payment solutions for all your transactions by Paytm Woocommerce Plugin

Download the plugin here: https://github.com/Paytm-Payments/Paytm_Woocommerce_Kit

Enable/Disable
Enable/Disable Enable Paytm Payments.
Title
Title
Paytm
This controls the title which the user sees during checkout.

Description
Description
The best payment gateway provider in India for e-payment through credit card, debit card & netbanking.
This controls the description which the user sees during checkout.

Merchant Identifier
Merchant Identifier
<provided link below>
Merchant Id Provided by Paytm

Secret Key
Secret Key
<provided link below>
Merchant Secret Key Provided by Paytm

Website
Website
WEBSTAGING
Website Name Provided by Paytm

Industry Type
Industry Type
Retail
Industry Type Provided by Paytm

Channel ID
Channel ID
WEB
Channel ID Provided by Paytm

Transaction URL
Transaction URL
https://securegw-stage.paytm.in/theia/processTransaction
Transaction URL Provided by Paytm

Transaction Status Url
Transaction Status Url
https://securegw-stage.paytm.in/merchant-status/getTxnStatus
Transaction Status URL Provided by Paytm

API Keys

You can get your keys here https://dashboard.paytm.com/next/apikeys

API keys are unique credentials issued to every merchant. While MID is used as an identification used for all exchange correspondence, merchant key is used to encrypt every API request to Paytm and decrypt every response from Paytm. Ensure that you keep the merchant key on server side and should not be shared with anyone. In case API keys are compromised, please reach out to our helpdesk to get new API keys.

  • MID (Merchant ID) – Unique identifier issued to every merchant.
  • Merchant Key – This is a unique secret key used for secure encryption of every request. This needs to be kept on server side and should never be shared with anyone.
  • Industry Type ID – This is part of bank and paymode configuration done wrt to an account.
  • Website – This parameter is used to support multiple callback URLs to post the transaction response. Each URL needs to be mapped to a website parameter.

Test API Details are something like this:

  • Test Merchant ID WArHEFXXXXXXXXXXXXXX <–wont work
  • Test Account Secret Key XXXXXXXXOcv1u7P2 <- wont work

Testing Resources / Testing Instruments

Source: https://developer.paytm.com/docs/testing-integration

  • Testing Debit/Credit Card
Card NumberAny Visa or Master Card
Expiration Month & YearAny Future month and Year
CVV123
OTP123123
  • Testing Paytm Wallet Details
Mobile Number77777 77777
PasswordPaytm12345
OTPDoesn’t require 2nd factor authentication489871
  • Testing Netbanking Details
Bank NameAndhra Bank
User IDtest
PasswordTest

Note:
In case you are testing on production environment, use live paymode details to complete the transaction. Once the transaction is successful, you can initiate refund from the dashboard.

What are Customer Relationship Management (CRM) Software?

What Is CRM?

CRM, also known as Customer Relationship Management can be understand as the software which was developed to improve the customer services and to make the customer services much more efficient.

CRM Software act as the single tools which has the ability to bring your sales, marketing, customer support services at one place and helps you to manage them at one single platform.

Who uses a CRM system?

CRM System can be easily customized and changed by the different Organisations and companies according to their needs and requirements. The CRM software can be used by the any business types and size for increasing their sales, marketing, and customer support services i.e, Small Scale Startups, Large Organizations, Real-estate, Healthcare, Insurance and the list goes on and on….

Customer relationship management systems can be easily customized to meet the specific needs of any business type and size. Start-ups, large enterprises, and verticals like real-estate, healthcare, insurance, legal, media, restaurants, travel, banking, tax, freelancers, and non-profits all use a customer relationship management software for increasing their sales, marketing, and customer support efforts.

With CRM you get,

300%

Improvement in
lead conversion rates.

41%

Revenue increase
per sales person.

27%

Improvement in
customer retention.

24%

Decreased
sales cycles

23%

Decreased sales and
marketing costs.

Here is a list of some famous CRM Software

Salesforce helps you to connect to your customer in a whole new way to build more meaningful and lasting relationship. With a single view of every customer interaction you can sell, service and market. With the help of salesforce you will get more lead, close more deals much faster, Increase customer loyalty, retention and satisfaction. You can also manage your business anytime and anywhere.

Full feature package: Salesforce Lightning Professional

Cost when billed annually: $75 per user, per month

Cost when billed monthly: n/a

Pipedrive focuses your mind on the pipeline and shuffles deals with due activities to the top in the list. In pipedrive your emails, calls, progress are tracked automatically. Pipedrive is rated the easiest sales tool to implement by leading software site. Pipedrive supports visual indicators which shows you where to focus and what actions are needed to close more sales.

Full feature package: Pipedrive Platinum

Cost when billed annually: $62.50 per user, per month

Cost when billed monthly: $75 per user, per month

In Microsoft dynamics you can engage with customers on any channel or device. You can personalise your services and deliver them fast. You can innovate with an application that is easy to tailor, extend and connect to other applications also which are already in use.

Full feature package: Dynamics 365 Plan

Cost: Starting at $210 per user, per month

Hubspot is a developer and marketer of the software products, it was founded 2006. Hubspot provide tools for social media marketing, content management, web analytics, landing page and search engine optimization. CRM has Integration Features of salesforce.com, sugarCRM, Netsuite, Microsoft Dynamics CRM and more.

Full feature package: HubSpot CRM is not a “full feature” CRM, and lacks reporting and certain sales process capabilities out of the box.

Cost: Free. Reporting can be added for $200/month

Zoho uses a open application programming interface for its writer, sheet, show, creator, meeting and product planner.it also has plugins into Microsoft excel and word, and plugins for Firefox. Zoho CRM has the some features like procurement, inventory, and some accounting functions from the realm of ERP. The free version is limited to 10 users only.

Full feature package: Zoho Enterprise

Cost when billed annually: $35 per user, per month

Cost when billed monthly: $45 per user, per month

amoCRM is very easy to use and also very powerful CRM Solution for the Organisations.it was founded in 2004 .The amoCRM is first CRM company to introduced integration with messaging application.It has easy to use pipeline management of data and information.it also gives a feature of sale automation to its users.

Full feature package: amoCRM Enterprise

Cost: $45 per user, per month, with a six-month minimum commitment

Nutshell is powerful and flexible enough to fit every to fit every sales model. Nutshell software helps in sales automation, We can manage our contacts and emails. We get the feature of reporting and performance tracking. It also offer pipeline management and friendly customer care.

Full feature package: Nutshell Pro

Cost when billed annually: $35 per user, per month

Cost when billed monthly: $39 per user, per month

Insightly CRM is for lifelong customer relationship, It can help you to grow your revenues more than 20% annually. Close more deal faster with work automation. In insightly, We can automatically convert closed deals to projects. It also provide apps integration to stay connected to apps you already use.

Full feature package: Insightly Professional

Cost when billed annually: $49 per user, per month

Cost when billed monthly: $59 per user, per month

Oracle is a complete, Integrated, Extensible application suite for modern customer experience. Oracle helps in analyze marketing performance, attribute revenue, and gain better insight into the customer experiences. We can deploy and use the CRM system easily, optimize sales performance and simplify everything in one place.

Full feature package: Oracle Sales Cloud Standard Edition

Cost: Starting at $100 per user, per month

SAP customer data cloud helps to create seamless customer experience and it also provide the data privacy, customer transparency and control. It provide personalise customer experience across the business. It helps in saving time and guesswork to accelerate sales and manage the sales territories and incentives.

Full feature package: SAP Business By Design CRM Sales

Cost when billed annually: $89 per user, per month

Cost when billed monthly: n/a

Copper is the Best CRM for G Suite users. Copper integrates with G Suite, gets rid of manual data entry, and It is super easy to use. If you can use Gmail, you’ll know how to use Copper. They have over 12,000 customers love using Copper and selling more with the CRM teams.

Full feature package: Copper Professional

Cost when billed annually: $49 per user, per month

Cost when billed monthly: $69 per user, per month

How to push into master or any other branch after removing last n commits in git?

  1. git log to find out the commit you want to revert
  2. git push origin +daee17:master while daee17 is the commit before the wrongly pushed commit.+ was for force push
  3. Finally use git push origin master to sync your local with your git repo

And that’s it.

Below is my log aka example. One of the teammates had committed to the repo (he was not supposed to) after which I committed on server and when I tried to push it on github.com, I received REJECTED error because the remote contained 2 commits which the server did not have.

[[email protected] www]$ git push origin master
To github.com:Organization/ttc.git
 ! [rejected]          master -> master (fetch first)
error: failed to push some refs to '[email protected]:Organization/ttc.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
[[email protected] www]$ git history
git: 'history' is not a git command. See 'git --help'.
[[email protected] www]$ git log
commit 8168d26efcd2cc9aa7ddaa47ce3c11d61a134813 (HEAD -> master)
Author: Your Name <[email protected]>
Date:   Mon Jan 21 18:57:55 2019 +0000

    filters css

commit daee17568269bb517870bba5aa75031dbd4f4554 (origin/master)
Author: Your Name <[email protected]>
Date:   Mon Jan 21 06:02:18 2019 +0000

    ravi shopyby resynced api and classes

commit 423c77c82bfb88d0febd5735bae3795740aa5b72
Author: Your Name <[email protected]>
Date:   Mon Jan 21 05:56:24 2019 +0000

    plugin defaulted and collapsible removed

commit bbd39f5a124261af64d015a55d5bd8ba9fdec94a
Author: Your Name <[email protected]>
Date:   Sun Jan 20 13:57:24 2019 +0000

    hirens new design layouts

commit 988524d8d3e90265977355ea738c262c7249a8e0
Author: Your Name <[email protected]>
Date:   Fri Jan 18 15:52:32 2019 +0000

    shubham landing page code improved

https://stackoverflow.com/a/35291514/2229148

5 ways to redirect your Web page?

Hi Everyone!

In this post we will be learning about redirects. And see how you can redirect your web-page.

We will see two ways to redirect web-pages:

  • Through your registrars’ Cpanel.
  • Right into your code.

Through cPanel redirect feature

You can easily redirect your visitors from one page to another with the help of the Redirects feature. 

To setup a redirection, access your website’s Control Panel and locate the Redirects menu.

In the Create a Redirect section. You can set up a redirection from one page of your website to another. This also works for subdomains or completely different websites.

If you choose to use HTTPS, make sure the redirected page has a certificate first, because redirecting to a website without an SSL certificate but using the HTTPS protocol for it, will most likely land your visitor to an error page

Now let’s see how you can set redirection by including few lines in your code.

HTML redirects:

The simplest way to redirect to another URL is with the Meta Refresh tag. We can place this meta tag inside the <head> at the top of any HTML page like this:

<meta http-equiv="refresh" content="0; URL='http://new-website.com'" />

JavaScript redirects

Redirecting to another URL with JavaScript is pretty easy, simply change the locationproperty on the window object:

// Use any of the following lines below.

window.location = "http://new-website.com";
window.location.href = "http://new-website.com";
window.location.assign("http://new-website.com");
window.location.replace("http://new-website.com");

Apache redirects

The most common method of redirecting a web page is through adding specific rules to a .htaccess file on an Apache web server.

Redirect 301 / http://www.new-website.com

PHP redirects

With PHP we can use the header function, which is quite straightforward:

<?php
  header('Location: http://www.new-website.com/', true, 301); // Permanent redirection.
// OR
  #header('Location: http://www.new-website.com/', true, 307); // Temporary redirection.
  exit();
?>

This is it for this post. Now the comment section is all yours.

Thank You.

How to learn Git in 15 minutes? List of most basic git commands

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git is easy to learn and has a tiny footprint with lightning fast performance. Every dev has a working copy of the code and full change history on their local machine

Here are some most important and useful GIT commands that will surely help you.

Git Commands:

  • This command sets the author name and email address respectively to be used with your commits.
$ git config –global user.name "[name]" 
$ git config –global user.email "[email address]"
  • This command is used to start new repository.
$ git init [repository name]
  • This command is used to obtain a repository from an existing URL.
$ git clone [url]  
  • This command records or snapshots the file permanently in the version history.
$ git commit -m "[Type in the commit message]"
  • This command lists all the files that have to be committed.
$ git status  
  • This command shows the metadata and content changes of the specified commit.
$ git show [commit]  
  • These commands lists, creates and delete branch respectively.
$ git branch  
$ git branch [branch name]  
$ git branch -d [branch name]  
  • This command is used to connect your local repository to the remote server.
$ git remote add [variable name] [Remote Repo Link]  
 
  • This command sends the committed changes of master branch to your remote repository.
$ git push [variable name] master  
  • This command sends the branch commits to your remote repository.
$ git push [variable name] [branch]
  • This command pushes all branches to your remote repository.
$ git push –all [variable name]
  • This command deletes a branch on your remote repository.
$ git push [variable name] :[branch name]
  • This command fetches and merges changes on the remote server to your working directory
$ git pull [Repository Link]

If you want more commands with examples, please let us know in the comments below.

More Useful commands:

  • Checks if sha is in production.
$ git tag --contains [sha]
  • Number of commits by author.
$ git shortlog -s --author 'Author Name'
  • List of authors and commits to repository sorted alphabetically.
$ git shortlog -s -n
  • Undo local changes to a file.
$ git checkout -- filename
  • Shows number of lines added or removed from repository by an author since some time in the past.
$ git log --author="Author name" --pretty=tformat: --numstat --since=month | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }'

reference:

https://gist.github.com/davfre/8313299#undoing-previous-actions

https://github.com/bpassos/git-commands#committing-files

Programming Paradigm.

Hi Everyone!

Today we are going to talk about programming paradigm. And in pronounces, the ‘g‘ is silent in ‘paradigm’.

So, in layman’s language programming paradigm is just the style of programming. Their are various styles of programming.

Every developer is different, hence is the style. Here we are about to talk about the most commonly used styles or pattern of programming.

Different Paradigms:

1. Imperative/procedural programming.

Imperative programming consists of sequence of statements and values are stored in memory after the implementation of statements.

Memory utilization is low. And mostly contains Variables & Iterations. Quite simple to implement.

Yet this style of programming has some demerits.

  • Complex problems can not be implemented.
  • Parallel programming is not possible.
  • Less productive.

2. object oriented programming.

Here the data $ functions are bound in one entity called class. In this pattern of programming everything is modeled as object. It follows the modular programming approach.

Mostly known for Data abstraction, encapsulation, inheritance, polymorphism. It is also quite easy to debug and modify.

Just one demerit to name is:

Methods (fx) of class are hidden.

3. functional programming.

To be honest this is what I prefer.

Here all the computations are expressed in functions. Complex functions can be developed from a single function.

Due to a re-usable functional approach, this style becomes quite comprehensible. Large number of functions can be mentained.

  • Consumes large amount of time and memory.
  • Not recommended for commercial applications.

4. Logical Programming.

Here the computations are expressed in mathematical logic. It follows the declarative programming approach.

Development is quite fast as it uses true or false (boolean) statements.

Known demerit are:

  • Slow execution
  • True and false can not solve most of the problems.

So, this is it from my side for this article. Please let us know what’s your way of programming.

  • Functional,
  • Logical, or
  • Object oriented.

See you soon in the next article.

Thank You.