This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<manifest> | |
<!-- Request legacy Bluetooth permissions on older devices. --> | |
<uses-permission android:name="android.permission.BLUETOOTH" | |
android:maxSdkVersion="30" /> | |
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" | |
android:maxSdkVersion="30" /> | |
<!-- Needed only if your app looks for Bluetooth devices. | |
You must add an attribute to this permission, or declare the | |
ACCESS_FINE_LOCATION permission, depending on the results when you |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########## Install NGINX ############## | |
# Install software-properties-common package to give us add-apt-repository package | |
sudo apt-get install -y software-properties-common | |
# Install latest nginx version from community maintained ppa | |
sudo add-apt-repository ppa:nginx/stable | |
# Update packages after adding ppa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sample: download json as excel file (BOM + utf-16le encoding) | |
// reference: | |
// https://gist.github.com/maciejjankowski/2db91642fb9eaa771111f2c0538e4560 | |
// | |
<script> | |
function JSON2CSV(objArray) { | |
var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray; | |
var str = ''; | |
var line = ''; | |
// header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const admin = require("admin"); | |
function getFirebaseUser(req, res, next) { | |
console.log("Check if request is authorized with Firebase ID token"); | |
if ( | |
!req.headers.authorization || | |
!req.headers.authorization.startsWith("Bearer ") | |
) { | |
console.error( | |
"No Firebase ID token was passed as a Bearer token in the Authorization header.", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. add a executable dev.sh to run your script (example: web.js) | |
#!/bin/bash | |
node --inspect web.js | |
// 2. install foreman | |
$ npm install -g foreman | |
// 3. prepare your environment variables file | |
$ touch .env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Google Play API Key | |
// ref: http://stackoverflow.com/questions/35127086/android-inapp-purchase-receipt-validation-google-play | |
// ref: https://developers.google.com/android-publisher/authorization | |
// ref: http://google.github.io/google-api-nodejs-client/18.0.0/index.html#toc14__anchor | |
// | |
// install npm package | |
// ref: https://github.com/google/google-api-nodejs-client | |
// $ npm install googleapis --save | |
// | |
const google = require('googleapis'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Coursera course | |
https://www.coursera.org/learn/machine-learning | |
Week 1 Note: | |
Partial derivative in gradient descent for two variables | |
https://math.stackexchange.com/questions/70728/partial-derivative-in-gradient-descent-for-two-variables/189792#189792 | |
Gradient descent | |
https://www.youtube.com/watch?v=WnqQrPNYz5Q&ab_channel=AlexanderIhler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// resend verify email | |
Parse.Cloud.define("ResendVerifyEmail", function(request, response) { | |
var user = Parse.User.current(); | |
if (!user) { | |
response.error("INVALID_USER"); | |
return; | |
} | |
var email = request.params.email; | |
var query = new Parse.Query(Parse.User); | |
Parse.Cloud.useMasterKey(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var queryAllUser = new Parse.Query(Parse.User); | |
Parse.Cloud.useMasterKey(); | |
queryAllUser.each(function(user) { | |
var queryMatch = new Parse.Query(Parse.User); | |
queryMatch.containedIn("offer", user.get("search")); | |
return query.find().then(function(users) { | |
if (users.length >0) { | |
var targetList = []; | |
for (i = 0; i < users.length; i++) { | |
var userPointer = Parse.Object.extend(Parse.User); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parse.Cloud.define("TestUpload", function(request, response) { | |
var attachmentURLs = []; | |
attachmentURLs.push({'name': 'gogole_logo', 'url': 'https://www.google.com.tw/intl/en_ALL/images/srpr/logo11w.png', 'content-type': 'image/png'}); | |
attachmentURLs.push({'name': 'yahoo_logo', 'url': 'https://www.google.com.tw/images/nav_logo225.png', 'content-type': 'image/png'}); | |
var promises = []; | |
attachmentURLs.forEach(function(file){ | |
promises.push(Parse.Cloud.httpRequest({ | |
url: file.url, | |
}).then(function(fetchedFile){ |
NewerOlder