Categories
Uncategorized

PHP sql returns space in email address while query with json post data using post method

I have faced a scenario where I was getting space error in the email address before @ symbol in email address, as I were making simple post request to verify the login.
Json post object sample:

{
	"email": "test@example.com",
  	"password" : "test123"
}

Was returning error in response of like test @example.com so the email address was not getting verified in the database.

Upon google came to following stack overflow result for solution but not satisfy with the approach of replacing single quote again and forcing self to post the email address with single quote in post request, which is obviously not a good solution. (later I have commented on the result page with my solution 😉 )
Simply I did this at query level and it resolve the space issue in the email address while query in database.

$query = "SELECT * FROM 
            " . $this->table_name . " 
            WHERE email =  '".$this->email."'  LIMIT 0,1";

Finally, wrapped the email address variable with the single quotes, and resolved the issue of space before @ symbol.

Hope this solution and result page will save your day!

Categories
Uncategorized

npm install error due to typescrip dev dependency or following error

If you face any similar kind of log error during npm install for react:

7090 verbose stack FetchError: invalid json response body at https://registry.npmjs.org/@typescript-eslint%2ftypescript-estree reason: Unexpected end of JSON input7090 verbose stack     at C:\Users\HP\AppData\Roaming\npm\node_modules\npm\node_modules\minipass-fetch\lib\body.js:77:317090 verbose stack     at async Promise.all (index 60)7090 verbose stack     at async Arborist.[buildDepStep] (C:\Users\HP\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:854:5)7090 verbose stack     at async Arborist.buildIdealTree (C:\Users\HP\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:209:7)7090 verbose stack     at async Promise.all (index 1)7090 verbose stack     at async Arborist.reify (C:\Users\HP\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:127:5)7090 verbose stack     at async install (C:\Users\HP\AppData\Roaming\npm\node_modules\npm\lib\install.js:38:3)7091 verbose cwd C:\Users\HP\Documents\team-captain\frontend7092 verbose Windows_NT 10.0.190427093 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\HP\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "typescript" "--save-dev"7094 verbose node v12.17.07095 verbose npm  v7.5.27096 error code FETCH_ERROR7097 error errno FETCH_ERROR7098 error invalid json response body at https://registry.npmjs.org/@typescript-eslint%2ftypescript-estree reason: Unexpected end of JSON input7099 verbose exit 1

run following command to clean up npm cache or manually delete the npm-cache folder using path from the above log generation in command line interface.
or update your npm version to the latest version with using following command:
npm install -g npm@latest(or specific to latest version)
like here

Categories
Uncategorized

What is for?

I was wondering about below code, as searched result over google as usually everyone does to know.

<meta name="HandheldFriendly" content="True">

So here is the answer: https://stackoverflow.com/questions/1988499/meta-tags-for-mobile-should-they-be-used

Basically, explained its to identify as mobile content for one of the browser, and it also become general standard to for identifying mobile websites.

Categories
Blog Tech

angular ng serve command throws error: An unhandled exception occurred: Project does not exist

If you facing with such problem, you may refer to following link for the solution. I have posted this question here on StackOverlow Hope it helps someone. Thanks.

Categories
Blog Tech

Fix PUTTY keyboard-interactive authentication password message prompt or access denied error or alternative to connect to SSH with PUTTY

If you are struggling to connect to your server from windows using PUTTY software try this from installation folder path of PUTTY in the command line:

In terminal cd to your putty installation path, for example:

C:\Program Files\PuTTY

in command line type in below with corresponding user information of yours.

putty.exe -l yourserverusername -pw yourserverpwd yourdomain.com

this will let you pass with keyboard-interactive authentication password message and you are good to go!

Categories
Blog Tech

Binding JSON data dynamically from ajax/promise/observable request to pug template

I was struggling to loop over ajax response to pug, with a lot of scratching head on google and Github, got a clue to use ES6 template to create cart list items from response data and append its HTML back to section container of HTML, here is sample code below.

I have also tried out achieved the same via pug mixin (commented code below, not successful) but not sure how to pass JS object variable to mixin as it’s not accepting response data as an object parameter.

Found similar doing here https://codepen.io/anon/pen/GeQKxp
it has pass individual object literal to the mixin, but if we pass the object variable created in JS and pass to the mixin, it doesn’t work, not sure how to turn around with it!

Hope this example code give you a hint.

I am not a professional writer of content, therefore treat this as general information for help on the similar issue anyone face with pug and json data.

//- cart.pug template

block append headScript
    script(src='./../js/scripts.js')
    script.
        myApp.fetchCartItems().subscribe(
            data => {
                if ('productsInCart' in data){
                    const cartItemsData = data.productsInCart;
                    const cartItemsTemplate = cartItemsData.map(item => {
                        function getColors(colors) {
                            return colors.length ? colors.map( color => `<span>${color.name}</span>`) : 'standard color'
                        }
                        function getSizes(sizes) {
                            return sizes.length ? sizes.map( size => `<span>${size.code}</span>`).join(' ').toUpperCase() : 'standard size'
                        }
                        return `<div class="row cart-item-row">
                                <div class="col-md-6">
                                    <img src="../images/T${item.p_id}.jpg" class="cart-thumb" />
                                    <div class="cart-item-detail">
                                        <h3>${item.p_name}</h3>
                                        <label>Style #: ${item.p_style}</label>
                                        <label>Colour: ${getColors(item.p_available_options.colors)}</label>
                                    </div>
                                    <div class="cart-actions">
                                        <a href="javascript:void(0)" class="jsEdit">Edit</a>
                                        <a href="javascript:void(0)">X Remove</a>
                                        <a href="javascript:void(0)">Save for Later</a>
                                    </div>
                                </div>
                                <div class="col-md-2 text-center">${getSizes(item.p_available_options.sizes)}</div>
                                <div class="col-md-2 text-center">
                                    <input type="text" name="txtQty${item.p_quantity}" id="txtQty${item.p_quantity}" value="${item.p_quantity}" class="form-control qty-input" />
                                </div>
                                <div class="col-md-2 text-right price-text"><sup>$</sup>${item.p_price}</div>
                            </div>
                            `
                    });

                    document.getElementById('cartItemContainer').innerHTML = cartItemsTemplate;
                }
            },
            err => {
                console.error('Subscribe Error', err);
            },
            () => {
                console.info('Subscribe complete');
            }
        );

section(class='cart-content' id='cartItemContainer' data-json= cartItems) cartItemContainer

//- mixin cartItemsMixin(cartItems)
//-     div(id='cartItemContainer' data-json= cartItems) cartItemContainer
//-     //- div= #{JSON.stringify(cartItems)}
//-     div(data-json= cartItems)
//-     section.cart-content
//-         .row.cart-item-row
//-             .col-md-6
//-                 img.cart-thumb(src='../images/T1.jpg')
//-                 .cart-item-detail
//-                     h3 Solid green cotton tshirt
//-                     label Style #: MS13KT1906
//-                     label Colour: Blue
//-                 .cart-actions
//-                     a.jsEdit(href='javascript:void(0)') Edit
//-                     a(href='javascript:void(0)') X Remove
//-                     a(href='javascript:void(0)') Save for later
//-             .col-md-2.text-center S
//-             .col-md-2.text-center
//-                 input.form-control.qty-input(type='text', name='txtQty1', id='txtQty1', value='1')
//-             .col-md-2.text-right.price-text
//-                 sup $ 
//-                 | 11.00
//- +cartItemsMixin(cartItemsData)
Categories
Blog Tech

how to solve basic development issues and steps to getup application working

These are the random solution to the issues, faced while developing the application in front-end and these are just the hand tools to fix issues and refer anytime in need. Hope it helps you in your search for solutions. Will keep updating with more and were need of improvement required to this page.


ANGULAR – To use on CLI


//to run server with proxy file optionally can be set under angular.json > server > options >
ng serve –proxy-config proxy.config.json

//if need to add port optionally
ng serve –proxy-config proxy.config.json –port 9999


EXPRESS – To use on CLI


express –view=pug spar-api

create : spar-api\
create : spar-api\public\
create : spar-api\public\javascripts\
.
.

change directory:
> cd spar-api

install dependencies:
> npm install

run the app:
> SET DEBUG=spar-api:* & npm start

On Windows use this command
set DEBUG=myapp:* & npm start

On Mac or linux
DEBUG=myapp:* npm start


TO CREATE SECRECT KEY


Window terminal side of code:

node -e “console.log(require(‘crypto’).randomBytes(256).toString(‘base64’)); #not working with jwt token signing trying other way below:

Source: https://gist.github.com/Holger-Will/3edeea6855f1d69a5368871bce5ea926

(tried on windows 7, working find with angular-jwt app)

generate private key

openssl genrsa -out private.pem 2048

extatract public key from it

openssl rsa -in private.pem -pubout > public.pem


Express side of code:

//Normalizing the path for windows environment
var normalPKPath = path.normalize( __dirname + ‘/private.key’);

const RSA_PRIVATE_KEY = fs.readFileSync(normalPKPath, ‘utf8’);



FIREBASE SETUP FOR ANGULAR CLI PROJECT


Create project in firebase console web page; https://console.firebase.google.com/

install firebase tool

npm install -g firebase-tool

firebase login

Google will try to login with your google account

(prior to init everytime, you have to make angular prod build ready and do firebase init each time for new deployment to firebase server)

firebase init

couple of questions will be asked after init command, type of deployment for web choose Hosting by presseing space bar key after selecting the option in list.
next publish folder path to be, in angular cli its dist folder for production build, type dist and hit enter
next it will ask you is your app is singple page app or not? type yes and hit enter
next it will ask do you want to replace existing index.html with firebase choose now? because our prod build as created file under dist folder.
next will create necessary files in your app directoy related to firebase/

make sure you update enviorments.prod.ts with firebase configuration detail, which you will get object from firebase console Create app for web page by clicking on it,

under project overview page.

next finially execute

firebase deploy

optionally you may use firebase deploy –proiect

if everything fine you will see app running under firebase server


ZEIT NOW – ISSUE SOLUTION


Build failing for typescript file: giving error Error: Cannot find module ‘typescript’

Fix to use @now/node@0.4.28-canary.6: in now.json file to make a build :
solution source: Github Issue https://github.com/zeit/now-builders/issues/181

Example: { “src”: “./src/app/server/*.ts”, “use”: “@now/node@0.4.28-canary.6”}

Categories
Blog Tech

Random Solution to development issues and steps to getup application working

These are the random solution to the issues I have faced while developing the application in front-end and these are my hand tools to fix issues and refer anytime in need. Hope it helps you in your search for solutions. Will keep updating with more and were need of improvement required to this page.

https://gist.github.com/jsbimra/aa63475592b9909a0c7b877ffb7d9667

Categories
Life & Nature

Nature importance to humans and life on this planet!

We do need nature’s work to do our own work in life. So, don’t take nature as not as important as you take much of yourself.

As a human, we don’t produce much excepts our babies, as nature gives us a lot of things for ourself’s and to babies.

As trees are so important, as we work daily for our needs & trees to work for us unconditionally by giving and maintaining oxygen for our life’s, which is very much essential of each individual to live on this planet.

Care for nature, nature will care for you.

Categories
Uncategorized

Amazon Great Indian Festive Season Sale 2018

Amazon Great Indian festive season sale 2018 coming up from 10th of October, buy your loving products at good discounted rates right away from Amazon.

Click on the banner to Shop Now!