Posts

Showing posts from 2017

ZTE MF 667 Remove Card Lock

Image
DC Unlock is the Most populer application .But its not free. Sonic provide good chance .You can User following URL. http://ineedohelp.blogspot.com/2012/04/internet-dongle-unlock.html Fallow the interaction as it indicates .There is a major difference only on identify device .You need to select ZTE and enable DC Unlock to detect Dongle by clieck on Search. I used  this with Windows 10.

Firebase database.ServerValue.TIMESTAMP get current time

Firebase Server Time STAMP can only retive the value when it comminted to firebase database var currentTimeStamp=firebase.database.ServerValue.TIMESTAMP; value for this will be set when datbase operation like set ,push or update occures . In order to get the value you need to write code like below.   ref.child(test).child(time-stamp').set(firebaseAdmin.database.ServerValue.TIMESTAMP).then(function() {                           ref.child(test).once('value').then(function(Snapshot) {                                                          var currentTimeStamp= Snapshot.val()['time-stamp']; }); });

Firsby for Unit test Firebase REST API

Firebase required to iniciate in order to run test cases. Firsby is a api testing fromwork ,which can work with jasmine.  npm install jasmine-node -g Install frisby.js http://frisbyjs.com/ Create spec file witih spec folder Import depeldancy var request = require("request"); var server = require("./../src/test.js");   // server file var frisby = require('frisby'); Header value for every request frisby.globalSetup({ request: { headers: {'AccessToken':process.env.test_token}. // taken from the .env } }); Dependent Request frisby.create(' Login')   .post(process.env.npm_config_host+'/api/login',{.  //take the host when running test command         "profile-type": "test",         "mess-token":"" }) .after(function(err, res, body) {   frisby.create('Dome')     .post(process.env.npm_config_host+'/api/user',{           "profile-type": ...

Uplaod to Firebase Storage from Node Express REST

Image
I need to upload user profile picture from mobile device trogh rest API to Firebase storage .Finally I go the follwing articale wich really guide me .  https://mzmuse.com/blog/how-to-upload-to-firebase-storage-in-node In order to upload the file from Express REST I used connect-busboy and fs node modules . Route file   router.post('/api/user-pic/profile-type/:type', ProfilePicController.setProfile); Controller File    exports.setProfile = function(req, res, next) {                     var fstream;                     req.pipe(req.busboy);                     req.busboy.on('file', function (fieldname, file, filename) {                                           console.log("Uploadin...

Node Express REST API Document while coding

I have used apidoc in my  Node Express REST Project . It works like charm and cpable to handle document versioning. APIDOC Inline Documentation for RESTful web APIs http://apidocjs.com/#param-api-description 1.npm install apidoc - g 2. /** * @api {get} /tasks/:id Find a task * @apiGroup Tasks * @apiDescription User login + register user if user login for the frist time. * @apiParam {id} id Task id * @apiSuccess {Number} id Task id * @apiSuccess {String} title Task title * @apiSuccess {Boolean} done Task is done? * @apiSuccess {Date} updated_at Update's date * @apiSuccess {Date} created_at Register's date * @apiSuccessExample {json} Success * HTTP/1.1 200 OK * { * "id": 1, * "title": "Study", * "done": false * "updated_at": "2016-02-10T15:46:51.778Z", * "created_at": "2016-02-10T15:46:51.778Z" * } * @apiErrorExample {json} Task not f...

ENOENT: no such file or directory, rename : node_modules/async

Image
I have gone trough follwing error ,when I was updating npm. npm ERR! path /Users/interlectivethree/firebase/fetchme/server/node_modules/winston/node_modules/async npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall rename npm ERR! enoent ENOENT: no such file or directory, rename '/Users/interlectivethree/firebase/fetchme/server/node_modules/winston/node_modules/async' -> '/Users/interlectivethree/firebase/fetchme/server/node_modules/winston/node_modules/.async.DELETE' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent npm ERR! A complete log of this run can be found in: npm ERR!     /Users/interlectivethree/.npm/_logs/2017-07-07T14_17_29_016Z-debug.log I have done sevarel things like package wise unstall and install ,package relocating .But no success .But I think compleate unstall and reinstall is the best option and follwing commands used. npm uninstall ` ls - 1 node_modules | tr '/\n' ' ...

Docker Dev Environment with Nodemon and Mongo DB

Image
1 Install Docker  Community ediction and Composer https://blog.codeship.com/using-docker-compose-for-nodejs-development/ 2 . Sampe application resides in server folder which have the package.json file ensure package.json  has script.  "start": "nodemon -L index.js" ensure nodemon.json exhist 3. touch Dockerfile. FROM node:8.1.0-alpine RUN mkdir /server RUN npm install nodemon -g ADD ./server /server WORKDIR /server RUN npm install #ADD server/nodemon.json /server/nodemon.json EXPOSE 3000 CMD npm start 5. docker-compose build 6.touch docker-compose.yml version: '2' services:   web:     build: .     volumes:     - "./server:/server"     ports:       - "3000:3000"     links:       - mongo   mongo:     image: mongo:3.4.4     container_name: mongo     ports:       - "27017:27017" 7.docker-co...

Firebase Promises

Image
 Firebase Nodejs requests are Asyncronus .Which means, in the follwing code block I need to check order users exhist before set user. But the user order insert fucntion written second will fire before validation finished .Developer need to careful on this when firebase adopted.     for(var user in users) {                                              f irebase.database().ref("users"); users.once("value", function(snapshot) {                                      var temp= snapshot.exists();                                                             if (temp) {             ...

Firebase REST API auth - access token

I have to use Firebase Database and server a REST API .I need to allow the REST API call only for authenticated users from the same freebase. According to Documentation on REST API Save data > Auth Section I able to successfully access the Database using database secret . https://firebase.google.com/docs/database/rest/save-data But I could not successfully retrieve the data using access token of authenticated user . https://<<removed-my-project-id>>.firebaseio.com/users.json?access_token=ya29.GlxuBLxJ6R2uNYJ7SXnMhe7Inqw94ShGeZ7MTBmyxYUI2cLDCXJcPAfbo1_uKLjUhfPX3uQw_ElBjIVwu73caeKJfBAh87GGRWZx2JiSwuIZybAmtVXyFyqaeYbAJQ Reffering confusing document again I pass the URL as fallows using the idtoken.(currentUser.getIdToken taken from cleint side) https:// <<my-project-id>> .firebaseio.com/users.json?auth=eyJhbGciOiJSUzI1NiIsImtpZCI6IjBkNWNlYjA1ODA2ODk3OTM3ZTAxNGFjMDNkYWZkODQyMzM4ZjBlNmQifQ.eyJpc3MiOiJodHRwczovL3NlY3VyZXRva2VuLmdvb2dsZS5jb20vZmV0Y2htZS1...

Custom Email template for Laravel Password Reset

Image
Today I got new task with laravel , since I  have forget passwrod reset scenario. It works but not using the UIs of our theme.Scpecailly mail. However reset pasword section of the follwing helps me . http://miftyisbored.com/a-complete-laravel-5-3-tutorial-for-user-authentication-with-activation-email/ Mailtrap will help you. php artisan vendor:publish --tag=laravel-notifications     // email template php artisan make:notification ResetPassword.          .//edit temaplte parameters chage user class to call notification   public function sendPasswordResetNotification($token)     {         $this->notify(new ResetPassword($token));     } change ResetPassword in notification folder  eg : namespace App\Notifications; use Illuminate\Notifications\Notification; use Illuminate\Notifications\Messages\MailMessage; class PasswordResetNotification ...

Laravel Session Time Out - Trying to get property of non-object Error

Image
I have faced the follwing  error in laravel in user logged pages . Laravel Session Time Out  - Trying to get property of non-object Error The reason for error is session time out of the logged user but it not properly handled in the views . In larvel if the logged in user from auth , can be logged out using same auth middleware. Route::post('controllerName','folderName\fileName@fnNmae')- >middleware('auth'); https://stackoverflow.com/questions/34443632/make-session-expiration-redirect-back-to-login

Dynamic Responsive Pinterest Style Columns Layout with Pure CSS

Image
When Im searching for casarole  layout I found the following which is really helped me. I further improved and shared herewith. http://www.cssscript.com/dynamic-responsive-pinterest-style-columns-layout-with-pure-css/ HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jquery实现瀑布流效果</title> <link rel="stylesheet" type="text/css" href="../css/style.css" /> <script src="../js/jquery.js"></script> <script src="../js/waterfalls.js"></script> </head> <body> <section id="title"> <h2>jquery瀑布流效果特效代码</h2> </section> <div id="warp"> <div class="box"> <div class="pic"> <img src="../images/img_1.jpg" /> </div> </div> <div class="box"> <div cla...

jQuery Validator with Loding GIF

Image
I had to add Loding GIF   form submmit but it was not trigger at the exact event due to form validations. However as fallows it can be achieved easy .I use jQuery form validator (not HTML 5) . CSS div#spinner {     display: none;     width:160px;     height: 160px;     position: fixed;     top: 50%;     left: 50%;     background:url(../images/page-loader.gif) no-repeat center ;     text-align:center;     padding:10px;     font:normal 16px Tahoma, Geneva, sans-serif;     margin-left: -50px;     margin-top: -50px;     z-index:2;     overflow: auto; } HTML  <div id="spinner"></div> JS $(document).ready(function() {    $("form[name='registerRefer']").validate({     rules: {        name: {            required: true, ...

Laravel using Cookies to Save URL Question Mark Parameter

Image
In Laravel most of the time cookies are set by the response .Further most of the posts does not directly tell how to retire URL Get  parameters. Eg: https://www.blogger.com/? blogID=1441573773987640178 To retrieve the value we can take the value in routes >>web.php Route::get('/', function(){      $term = Input::get(' blogID ');       if(isset($term)){         Cookie::queue(Cookie::make(' blogID ',$term, 60*24*365));       }     return view('home'); }); In here cookies are save using (Cookie::make) . In the next response the cookie value get saved in client browser.               e.g.  $cookie = Cookie :: make ( $name , $value , 60 ); http://laravel-recipes.com/recipes/48/creating-a-new-cookie To retrieve the Cookies value is simple       $request->cookie(' blogID ');

Laravel Customize Auth RegisterController Step By Step

Image
In Laravel Default RegisterController located in Auth/RegisterController can be customized to to meet another requirement. It use the user table of Laravel and not use any e.g. : send the account activation mail with other detail namespace App\Http\Controllers\Auth; use App\User; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Validator; use Illuminate\Foundation\Auth\RegistersUsers; class RegisterController extends Controller {     /*     |--------------------------------------------------------------------------     | Register Controller     |--------------------------------------------------------------------------     |     | This controller handles the registration of new users as well as their     | validation and creation. By default this controller uses a trait to     | provide this functionality without requiring any additional code.     | ...

Comple Guilde on Setup Laravel Bitbucket clone

Image
Guide  https://laravel.com/docs/5.3/installation 1. sudo git clone https://kanchanainterlec@bitbucket.org/interlectivesg/bme_app.git 2. composer install 3.config debug true 4 .create .env mv .env.sample .env 5. php artisan key : generate   6.see error 7. Set permission :chmod -R 777 8.Set the database detail on .env file 9.  php artisan migrate : refresh run the application by moving to public

Remove MySql Strick Mode

Image
I have installed MySql in my Mac OSx using home brew. However when I was going to execute query like below it iilll gives a error Query : `comment_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', Error :  #1067 - Invalid default value for 'comment_date' The reason is My Sql has been installed in Strict mode Where User could not do some database actions ,which are prmiited in old version. This  article helps to remove strict mode permemtly as well as tempory  : http://nickbartlett.com/how- to-turn-off-mysql-strict-mode/ Simply run the query with following in the begin SET @@global.sql_mode= ”;

Google Adsense alternative for Sri Lankans

Hi, I found difficult to get Adsense to local content .However WP beginner post assist me a lot . http://www.wpbeginner.com/beginners-guide/make-money-online/?utm_source=retargeting&utm_medium=fbads#make-money-with-affiliate-marketing But there are others like amazon. One of good guide : https://www.wpsitecare.com/amazon-affiliate-wordpress/

Url encode decode anchor links with AngularJS PHP

Image
I had following link  in one of rest call which lead to SQL unexpected result due to & symbol. http://localhost/test/getDsv?$top=32&$skip=0&var=HR & Admin&com= Query has only considered  var=HR   only  which leads to unexpected results. My front end is anguler and I can encode the perticulter paramenter with  window . encodeURIComponent() Ref : http://stackoverflow.com/questions/11294107/how-can-i-send-the-ampersand-character-via-ajax To Decode it at PHP side there in nothing to do ,although there are lot of posts ,which indicate decoding. $this->_request['var']; http://stackoverflow.com/questions/11294107/how-can-i-send-the-ampersand-character-via-ajax

ICT AL - Dynamic and Static Web Pages

Image
Copyrights Goes to :https://web.facebook.com/alits.lk/?_rdc=1&_rdr

jQery Serialize Form Explicitly

Image
                                                In order to pass the HTML controls without using submit button. HTML  <div class="col-md-12"><button type="button" id="reject" class="form-control  btn-info " onclick="reject()" >Reject</button></div>                       js                                function reject() {                                                var fromdata=$('#detailform');                             ...

Apache enable MOD_REWRITE for PHP Rest API

Image
Hi Im woarking with follwing expample which illustrate how to create REST Api form genic PHP http://www.tutorialsface.com/2016/02/simple-php-mysql-rest-api-sample-example-tutorial/ However I  need to set MOD_REWRITE for the API folder in Wamp and Follwing steps need to follow to achive it . 1.Go to apache  http.conf in WAMP apache folder ,and open it 2. Make a backup of http.conf   3.  Find the line #LoadModule rewrite_module modules/mod_rewrite.so and uncomment it by removing hash. 4.ADD the rule as below for the APi folder . in my case its MI_API (there will be block like below mapped to WAP ,www folder ,you can edit it as nesosary) <directory C:/wamp/www> Options All   AllowOverride All </directory> Thanks  for : https://webdevdoor.com/php/mod_rewrite-windows-apache-url-rewriting

Oracle Varchar2 DateTime Experassions - yyyy-mm-dd HH24:MI:SS

There is a verchar2 Date Time Filed  in the table which now need to get Results with the given rnage eg : up to 3 days of the past from today. Eg Field DONE_TIME SELECT  * substr(DONE_TIME,0,19) FROM EG_TABLE Convert to date : SELECT  *  TO_DATE(substr(DONE_TIME,0,19),'yyyy-mm-dd HH24:MI:SS') FROM EG_TABLE Reduce From the System Time : SELECT  *  (systimestamp-TO_DATE(substr(substr(DONE_TIME,0,19),0,19), 'yyyy-mm-dd HH24:MI:SS')) FROM EG_TABLE RANGE Comparison  : WHERE trunc(to_number(substr((systimestamp-TO_DATE(substr(substr(DONE_TIME,0,19),0,19), 'yyyy-mm-dd HH24:MI:SS')),1,instr(systimestamp-TO_DATE(substr(substr(DONE_TIME,0,19),0,19), 'yyyy-mm-dd HH24:MI:SS'),' '))))>3

jQuery Ajaz to check if returned data object is empty

Image
In one of my jQuery Ajax Request ,I need to check wehter quary  return  empty results. $ . post ( "php/socialbookmark-post.php" , { bookmarkID : $ ( this ). val ()}, function ( data ) { if ( data != "" ) alert ( data ); });   data !== 'undefined' && data !== '' not worked Properly and Stack OverFlow also not given good answer. I observed, If empty data set  returned , the full block will not executed. http://stackoverflow.com/questions/2589558/jquery-to-check-if-returned-data-object-is-empty But refffering to jQuery I able to come up with solid answer. http://api.jquery.com/jQuery.ajax/ By defult we inherit the sucess method (done ) and if empty data set returned it will go (fail).     $.post("./testURL" function (o) {                                 ...