Skip to content

Instantly share code, notes, and snippets.

@jeffhuangtw
jeffhuangtw / AndroidManifest.xml
Created February 11, 2022 01:22
android 12 ble
<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
@jeffhuangtw
jeffhuangtw / Instructions.sh
Created August 30, 2018 01:19 — forked from GhazanfarMir/Instructions.sh
Install PHP7.2 NGINX and PHP7.2-FPM on Ubuntu 16.04
########## 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
@jeffhuangtw
jeffhuangtw / JSON2CSV.js
Created January 3, 2018 08:17
Convert json object to csv download link javascript
// 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
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.",
@jeffhuangtw
jeffhuangtw / gist:e64fa7eabf6e16e01842e76ff53ba233
Created September 18, 2017 09:30
[Visual Studio Code] [nodejs] [debugger] [foreman] vsc + foreman + debugger
// 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
@jeffhuangtw
jeffhuangtw / sample.js
Created March 15, 2017 09:52
[nodejs] server side check "androidpublisher.purchases.subscriptions.get" with "service account"
// 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');
@jeffhuangtw
jeffhuangtw / gist:541e7b5ad6701671ce06
Created January 6, 2016 12:26
machine learning note
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
@jeffhuangtw
jeffhuangtw / sample.js
Created October 2, 2015 17:03
Resend Parse User Verification Email Cloud Code
// 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();
@jeffhuangtw
jeffhuangtw / gist:751178dd0c3873449747
Last active September 25, 2015 16:19
dirty sample for Parse Job query.each and push something
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);
@jeffhuangtw
jeffhuangtw / gist:273455305ff8c39d1099
Created August 24, 2015 07:41
Test fetch and upload multiple ParseFile with Promise
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){