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
@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 / 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 / .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 / 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 / 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>
);
}
import React, { Component } from 'react';
export default class Home extends Component {
componentDidMount(){
// execute api here
}
render() {
return (
@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;
}
}
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 };
}
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 selectSize = (size) => {
const selector = document.querySelector('#exp-pdp-buying-tools-container > form > div.exp-pdp-size-and-quantity-container > div > div.exp-pdp-size-dropdown-container.nsg-form--drop-down--option-container.selectBox-options.nsg-form--drop-down.exp-pdp-size-dropdown.exp-pdp-dropdown.two-column-dropdown.selectBox-dropdown-menu > ul');
const children = Array.from(selector.children);
children.forEach(ele => {
const rel = ele.getAttribute('rel');
if (rel.substring(rel.indexOf(':'), rel.length) === `:${size}`) {
console.log('find ele', ele);
$('select[name="skuAndSize"]').val(rel);
$('#buyingtools-add-to-cart-button').click();
}