Skip to content

Instantly share code, notes, and snippets.

View chnbohwr's full-sized avatar
🐳
Enjoy development fun 享受開發樂趣

HsuChing(Hyman) chnbohwr

🐳
Enjoy development fun 享受開發樂趣
View GitHub Profile
const afterLogin = async() => {
const datas = await Promise.all([
axios.get('/profileData'),
axios.get('/menuData'),
axios.get('/api/dashboard/xxxx')
]);
return {
userProfile: datas[0],
menuData: datas[1],
dashboardData: datas[2]
const afterLogin = async() => {
const userProfile = await axios.get('/profileData');
const menuData = await axios.get('/menuData');
const dashboardData = await axios.get('/api/dashboard/xxxx');
return { userProfile, menuData, dashboardData };
}
@chnbohwr
chnbohwr / getmyprofile.js
Created October 31, 2017 06:04
get user profile by axios
const getMyProfile = async() => {
try {
const response = await axios.get('/api/myProfile');
return response.data;
} catch(e) {
throw e;
}
}
import React, { Component } from 'react';
export default class Home extends Component {
componentDidMount(){
// execute api here
}
render() {
return (
@chnbohwr
chnbohwr / component.js
Created September 17, 2017 01:08
react simple component example
import React, { Component } from 'react';
export default class Home extends Component {
render() {
return (
<div id="pageHome">
hi this is home page
</div>
);
}
@chnbohwr
chnbohwr / command.sh
Created May 12, 2017 06:37
git delete all local branches that are already merged into the currently checked out branch:
git branch --merged | egrep -v "(^\*|master|develop|)" | xargs git branch -d
@chnbohwr
chnbohwr / .gitignore
Created February 21, 2017 14:22 — forked from rjmunro/.gitignore
gitignore for cordova cli projects
# Android
platforms/android/assets/www
platforms/android/bin/
platforms/android/gen/
platforms/android/res/xml/config.xml
# iOS
platforms/ios/build/
platforms/ios/CordovaLib/build/
platforms/ios/www
@chnbohwr
chnbohwr / line_notify_example.js
Created January 4, 2017 15:21
line_notify_example
var request = require('request');
var API_URL = 'https://notify-api.line.me/api/notify';
var token = 'TOKEN'
var message = '今天吃好料的'
var data = {
url: API_URL,
method: 'POST',
json: true,
headers: {
'User-Agent': 'Request-Promise',
@chnbohwr
chnbohwr / scroll.js
Created July 11, 2016 07:40
javascript is scroll bottom function
function isBottom(){
var windowHeight = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;
var scrollTop = $(window).scrollTop();
var totalHeight = $(document).height();
var percent = (windowHeight + scrollTop)/totalHeight;
if(percent === 1){
return true;
}else{
@chnbohwr
chnbohwr / gist:6d9dae6650d297620372eda01ea502b4
Created May 27, 2016 02:10 — forked from chad3814/gist:2924672
deleting array items in javascript with forEach() and splice()
// This is from my comment here: http://wolfram.kriesing.de/blog/index.php/2008/javascript-remove-element-from-array/comment-page-2#comment-466561
/*
* How to delete items from an Array in JavaScript, an exhaustive guide
*/
// DON'T use the delete operator, it leaves a hole in the array:
var arr = [4, 5, 6];
delete arr[1]; // arr now: [4, undefined, 6]