Skip to main content

Posts

Sample passport Express dùng strategy Github

Link tut:  https://gist.github.com/jokecamp/65604d50227b8ea8e0d3 Đầu tiên càn tạo Github apps: Vô Setting (profile j đó) > Github Apps (tab bên trái dưới) > new app. điền đúng thông tin redirect URL, callback (ai làm Facebook OAuth, Google 0Auth thì rõ). Code demo: package.json: { "name": "securehelloworld", "version": "1.0.0", "description": "", "main": "server.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "express": "^4.13.3", "express-session": "^1.11.3", "passport": "^0.3.0", "passport-github": "^1.0.0" } } 1 var express = require('express'); 2 var app = express(); 3 var passpo...

Note some js date time

// Compute diff datetime // Don't know why fetch from MySQL query become Date JS object without convert.  var last_activity = result_find_usr_by_id[0].updated_at; console.log('last ' + last_activity); var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds var todayDate = new Date(); console.log('today ' + todayDate); var diffDays = 0; if(typeof last_activity !== 'undefined') {     // Split timestamp into [ Y, M, D, h, m, s ]     // var t = last_activity.split(/[- :]/);     // Apply each element to the Date function     // var last_activity = new Date(Date.UTC(t[0], t[1]-1, t[2], t[3], t[4], t[5]));     var diffDays = Math.round(Math.abs((last_activity.getTime() - todayDate.getTime())/(oneDay)));         console.log('diff '+ diffDays);      } /**  * You first need to create a formatting function to pad numbers to two digits…  **/ function twoDigits(d) { ...

FCM, GCM send data, mesasge, notification config, noti type head-up screen on etc.

https://stackoverflow.com/questions/37711082/how-to-handle-notification-when-app-in-background-in-firebase 1. Why is this happening ? There are two types of messages in FCM (Firebase Cloud Messaging): Display Messages : These messages trigger the onMessageReceived() callback only when your app is in foreground Data Messages : Theses messages trigger the onMessageReceived() callback even if your app is in foreground/background/killed Firebase team have not developed a UI to send data-messages to your devices, yet. https://stackoverflow.com/questions/3621599/wake-android-device-up https://stackoverflow.com/questions/37570200/firebase-silent-apns-notification https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#push-message-arrives-with-app-in-background With FCM, you can send two types of messages to clients: Notification messages , sometimes thought of as "display messages." Data messages, which are handled by the client app. As per ...

Windows C: Driver folder size

- Windows about 10-20-30. 10GB after fresh install, 20-30 after install some huge app like visual studio. My PC has some basic app like chrome, Android Studio, XAMPP ... It take 30GB to Windows. I can not found clearly to uninstall Visual Studio because of it has so many item in Control Panel > Program File. I do not use VS but previous PC owner does. - 75 GB C: Drive: + 10GB for hibernate if memory is 10GB. I disabled hibernate so this file rarely exist. + 30GB Windows. + Users\Default (or Admin): about 15-20GB. + Free 10GB Total: about 75GB. Why ? Users\Public about 2GB: Public\Cache ... (or some dir like this) take about 1-2GB. Users\Default ... Users\Admin\AppData: about > 10GB app data n cache: + Skype, slack data, file upload, receive ... about 500MB each + Android: huge sdk, image. I only install default api ver 24 so it take about 5GB whole sdk. + Visual Studio, ... + Geny Motion: about 1.5GB. I only has one image HTC M7. + Temp dir : about 2GB some ca...

Node gcm badge count and notification can not work together

https://github.com/ToothlessGear/node-gcm/blob/master/lib/message-options.js https://github.com/ToothlessGear/node-gcm/blob/master/lib/message.js Use CURL to send push instead of libraries: Write no break curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: key=AIzaSyCyg6f6a8LCTqkN1HUG0xo5G0HlBA57xxx8' -d '{contentAvailable: true, data:{ "room_id":data.room_id, "noti_type":"NEW_MESSAGE", "badge":11, "count": 22, "content-available": "1"},registration_ids: 'dh5DjydSS08:APA91bGAnaldtOxSXX970NWO4SCl3QCzrz4mIp98yCi5St8xDZWT8KNJIwglusSwEVe1wEGZKcSH4RqXYfk6JXiK52sZ1SpS53rXNdg6n1R81lrfCdHYoPMOwC4MAQzVYS5VkkrTExxx', priority: "high", collapse_key:"Updates Available" }' 'https://android.googleapis.com/gcm/send' curl -X POST --header 'Content-Type: application/json' \ --header ...

List modal, present Push Notification

https://loopback.io/doc/en/lb2/Push-notifications.html#create-a-push-model https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/APNSOverview.html#//apple_ref/doc/uid/TP40008194-CH8-SW1

NodeJS WebRef

https://jonathanmh.com/express-passport-json-web-token-jwt-authentication-beginners/ https://medium.freecodecamp.com/requiring-modules-in-node-js-everything-you-need-to-know-e7fbd119be8 https://news.ycombinator.com/item?id=11895440 https://code.tutsplus.com/tutorials/using-passport-with-sequelize-and-mysql--cms-27537 https://www.joshmorony.com/using-json-web-tokens-jwt-for-custom-authentication-in-ionic-2-part-2/ https://auth0.com/blog/building-and-authenticating-nodejs-apps/ https://auth0.com/blog/ionic-2-authentication-how-to-secure-your-mobile-app-with-jwt/ https://medium.com/@pandeysoni/user-authentication-using-jwt-json-web-token-in-node-js-using-express-framework-543151a38ea1 https://github.com/auth0/express-jwt http://martinmicunda.com/2015/04/14/build-ionic-photo-gallery-app-II/ https://float-middle.com/json-web-tokens-jwt-vs-sessions/ https://blog.hyphe.me/token-based-authentication-with-node/ https://devdactic.com/restful-api-user-authentication-1/ https://close...