Skip to content

Instantly share code, notes, and snippets.

question Yang03

Block or report user

Report or block Yang03

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Yang03
Yang03 / gist:5d3de65a5746646058dd7aa0cc3148b7
Created Jul 23, 2019
Abort Data Fetching in Effect HooK
View gist:5d3de65a5746646058dd7aa0cc3148b7
const useDataApi = (initialUrl, initialData) => {
const [url, setUrl] = useState(initialUrl);
const [state, dispatch] = useReducer(dataFetchReducer, {
isLoading: false,
isError: false,
data: initialData,
});
useEffect(() => {
View gist:69f055308db3190fcbc0b1dab8c54ac4
import { createSoapClient, createSoapHeader } from '../lib/amadeus'
import { writeJson, requestXml, requestJson } from '../util/apiJson'
import OrderService from '../service/order'
import { getPayAmount } from '../service/flights/getPayAmount'
import Str from '../db/redis/str'
exports.PNRAddMultiElements = async function (req, res) {
const data = req.body
const searchInput = buildQuery(data)
const validate = validateAge(data)
View gist:bb54abea2154f1e431799f2a3915ed59
void function(){
var Base64 = {
// private property
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
// public method for encoding
encode : function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
@Yang03
Yang03 / gist:f2ebee7ef5d21a2e88904134a07edf30
Last active Aug 3, 2018
canvas draw multi line text and circle avatar
View gist:f2ebee7ef5d21a2e88904134a07edf30
public async drawActivityPoster() {
const {windowWidth} = wx.getSystemInfoSync()
const width = windowWidth * 80 / 100
const ctx = wx.createCanvasContext('poster')
this.drawText({
text: '我的店铺',
ctx :ctx,
x: 0,
y: 100,
fontSize: 14,
View gist:0a160e229afecaa1f25d60bdf9ac91ec
[{"numberOfPax":{"segmentControlDetails":{"quantity":"1","numberOfUnits":"1"}},"passengersID":[{"travellerDetails":{"measurementValue":"1"}}],"fareInfoGroup":{"emptySegment":null,"pricingIndicators":{"priceTariffType":"I","productDateTimeDetails":{"departureDate":"180818"},"companyDetails":{"otherCompany":"EY"}},"fareAmount":{"monetaryDetails":{"typeQualifier":"B","amount":"3140","currency":"AED"},"otherMonetaryDetails":[{"typeQualifier":"E","amount":"1123.00","currency":"CAD"},{"typeQualifier":"712","amount":"1537.03","currency":"CAD"}]},"textData":[{"freeTextQualification":{"textSubjectQualifier":"4","informationType":"15"},"freeText":"18AUG18AUH EY NYC Q2.50Q40.84 811.38NUC854.72END ROE3.672750"},{"freeTextQualification":{"textSubjectQualifier":"1","informationType":"1P3"},"freeText":"PENALTY APPLIES"},{"freeTextQualification":{"textSubjectQualifier":"1","informationType":"10"},"freeText":"NON ENDO/ REF -BG:EY"},{"freeTextQualification":{"textSubjectQualifier":"1","informationType":"1A49"},"freeText":"- DA
View gist:db012a7d1c56b2205b28d59748c8a597
.content-box {
width:200px;
height: 200px;
box-sizing: content-box;
padding: 10px;
border: 10px solid #f46;
margin: 10px;
}
View Air_SellFromRecommendation
{
"messageActionDetails": {
"messageFunctionDetails": {
"messageFunction": "183",
"additionalMessageFunction": "M1"
}
},
"itineraryDetails": {
"originDestinationDetails": {
"origin": "YVR",
View gist:e8a5e2a31af37c8e8398d0d1bd4cf869
function daysInMonth (year, month) {
return /8|3|5|10/.test(month) ? 30 : month === 1 ? (!(year % 4) && year % 100) || !(year % 400) ? 29 : 28 : 31
}
function formatDate (date, format, translation) {
translation = (!translation) ? en : translation
let year = date.getFullYear()
let month = date.getMonth() + 1
let day = date.getDate()
let str = format
View gist:158de433b6322d81945ccc66267e7310
```
const test = Vue.component('test', {
props: ['msg'],
template:'<div><p>{{msg}}</p><slot name="action">xx</slot></div>'
})
new Vue({
el: '#app',
View gist:a32b3243d02a24c1beeea316246a1c69
var subItems = Array.from(document.querySelectorAll('.sub-item'))
subItems.forEach((item) => {
item.onclick = function() {
var classList = this.classList
if (classList.contains('animation-open')) {
classList.remove('animation-open')
} else {
classList.add('animation-open')
}
You can’t perform that action at this time.