Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
| // create context with no upfront defaultValue | |
| // without having to do undefined check all the time | |
| function createCtx<A>() { | |
| const ctx = React.createContext<A | undefined>(undefined) | |
| function useCtx() { | |
| const c = React.useContext(ctx) | |
| if (!c) throw new Error("useCtx must be inside a Provider with a value") | |
| return c | |
| } | |
| return [useCtx, ctx.Provider] as const |
| <html> | |
| <body> | |
| <script> | |
| // @author: ideawu | |
| // @link: http://www.ideawu.net/blog/archives/1021.html | |
| var swap_count = 0; | |
| var cmp_count = 0; | |
| // https://gist.github.com/wintercn/c30464ed3732ee839c3eeed316d73253 | |
| function wintercn_qsort(arr, start, end){ |
| // UPDATE: In 2023, you should probably stop using this! The narrow version of Safari that | |
| // does not support `nomodule` is probably not being used anywhere. The code below is left | |
| // for posterity. | |
| /** | |
| * Safari 10.1 supports modules, but does not support the `nomodule` attribute - it will | |
| * load <script nomodule> anyway. This snippet solve this problem, but only for script | |
| * tags that load external code, e.g.: <script nomodule src="nomodule.js"></script> | |
| * | |
| * Again: this will **not** prevent inline script, e.g.: |
| function get(uri) { | |
| return http(uri,'GET'); | |
| } | |
| function post(uri,data) { | |
| if(typeof data === 'object' && !(data instanceof String || (FormData && data instanceof FormData))) { | |
| var params = []; | |
| for(var p in data) { | |
| if(data[p] instanceof Array) { | |
| for(var i = 0; i < data[p].length; i++) { | |
| params.push( encodeURIComponenet(p) + '[]=' + encodeURIComponenet(data[p][i]); |
| _oo0oo_ | |
| o8888888o | |
| 88" . "88 | |
| (| -_- |) | |
| 0\ = /0 | |
| ___/`---'\___ | |
| .' \\| |-- '. | |
| / \\||| : |||-- \ | |
| / _||||| -:- |||||- \ | |
| | | \\\ - --/ | | |
| //Chrome上能用的 | |
| ["Image", "Audio", "MediaController", "TrackEvent", "Option", "PopStateEvent", "HashChangeEvent", "PageTransitionEvent", "Event", "CustomEvent", "MutationObserver", "Document", "FormData", "XMLHttpRequest", "FormData", "IDBVersionChangeEvent", "StorageEvent", "RTCSessionDescription", "RTCIceCandidate", "MediaStreamEvent", "Notification", "Blob", "FileReader", "ErrorEvent", "Worker", "SharedWorker", "TransitionEvent"] | |
| //标准里有但是还不能用的 | |
| ["RelatedEvent", "DragEvent", "AnonXMLHttpRequest", "RTCPeerConnection", "RTCPeerConnectionIceEvent", "DataChannelEvent", "ClipboardEvent", "FileReaderSync", "BlobBuilder", "FileSaver", "ParGroup", "SeqGroup", "Animation", "PseudoElementReference", "KeyframeAnimationEffect", "PathAnimationEffect", "TimingEvent", "AnimationEvent"] |
Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
| // @license http://opensource.org/licenses/MIT | |
| // copyright Paul Irish 2015 | |
| // Date.now() is supported everywhere except IE8. For IE8 we use the Date.now polyfill | |
| // github.com/Financial-Times/polyfill-service/blob/master/polyfills/Date.now/polyfill.js | |
| // as Safari 6 doesn't have support for NavigationTiming, we use a Date.now() timestamp for relative values | |
| // if you want values similar to what you'd get with real perf.now, place this towards the head of the page | |
| // but in reality, you're just getting the delta between now() calls, so it's not terribly important where it's placed |
| function getCommonParent(el1,el2){ | |
| var parents1 = []; | |
| var el = el1; | |
| while(el) { | |
| parents1.unshift(el); | |
| el = el.parentNode; | |
| } | |
| var parents2 = []; |