討論串來源: https://www.facebook.com/tomchentw/posts/1537332202978535
原始推文: Jason Miller 🦊⚛ on Twitter: "The web is getting async image decoding!"
| function requestAPI() { //requestDB 實作都類似只是reject的error不同 | |
| return new Promise((resolve, reject) => { | |
| request('https://A.com', (error, data) => { | |
| if (error) reject(new customError("I'am requestAPI",error)) | |
| else resolve(data) | |
| }) | |
| }) | |
| } | |
| // main |
| (function (context, trackingId, options) { | |
| const history = context.history; | |
| const doc = document; | |
| const nav = navigator || {}; | |
| const storage = localStorage; | |
| const encode = encodeURIComponent; | |
| const pushState = history.pushState; | |
| const typeException = 'exception'; | |
| const generateId = () => Math.random().toString(36); | |
| const getId = () => { |
| // 客户端实现 | |
| const net = require('net') | |
| const tls = require('tls') | |
| const localServer = new net.Server() | |
| localServer.on('connection', (socket) => { | |
| socket.pause() | |
| const context = { |
| { | |
| "Smtp": { | |
| "Host": "smtp.gmail.com", | |
| "Port": 587, | |
| "UseSSL": true, | |
| "Username": "bob", | |
| "Password": "password", | |
| } | |
| } |
| { | |
| "emojis": [ | |
| {"emoji": "👩👩👧👧", "name": "family: woman, woman, girl, girl", "shortname": ":woman_woman_girl_girl:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F467", "html": "👩‍👩‍👧‍👧", "category": "People & Body (family)", "order": ""}, | |
| {"emoji": "👩👩👧👦", "name": "family: woman, woman, girl, boy", "shortname": ":woman_woman_girl_boy:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F466", "html": "👩‍👩‍👧‍👦", "category": "People & Body (family)", "order": ""}, | |
| {"emoji": "👩👩👦👦", "name": "family: woman, woman, boy, boy", "shortname": ":woman_woman_boy_boy:", "unicode": "1F469 200D 1F469 200D 1F466 200D 1F466", "html": "👩‍👩‍👦‍👦", "category": "People & Body (family)", "order": ""}, | |
| {"emoji": "👨👩👧👧", "name": "family: man, woman, girl, girl", "shortname": ":man_woman_girl_girl:", "unicode": "1F468 200D 1F469 200D 1F467 200D 1F467", "html": "👨‍👩&z |
| -- VARCHAR TO Base64 | |
| IF OBJECT_ID (N'[dbo].[uFnStringToBase64]', N'FN') IS NOT NULL | |
| DROP FUNCTION uFnStringToBase64; | |
| GO | |
| CREATE FUNCTION [dbo].[uFnStringToBase64] | |
| ( | |
| @InputString VARCHAR(MAX) | |
| ) | |
| RETURNS VARCHAR(MAX) | |
| AS |
| # enable ES6 | |
| parserOptions: | |
| ecmaVersion: 6 | |
| sourceType: "module" | |
| ecmaFeatures: | |
| jsx: true # enable React's JSX | |
| # register plugins | |
| plugins: | |
| - meteor |
| Ionic and ngCordova upload example |
| <!doctype html> | |
| <html> | |
| <head> | |
| <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |
| <script type="text/javascript"> | |
| var spData = null; | |
| function doData(json) { | |
| spData = json.feed.entry; | |
| } | |