07 2023 档案
摘要:Mistake 1: Not using the same function reference // Wrong button.addEventListener('click', () => {console.log('click')}) button.removeEventListener('c
阅读全文
摘要:So it's much easier to do what we did with Docker. Run this command: docker run --interactive --tty alpine:3.10 # or, to be shorter: docker run -it al
阅读全文
摘要:Okay, so now we've hidden the processes from Eve so Bob and Alice can engage in commerce in privacy and peace. So we're all good, right? They can no l
阅读全文
摘要:namespace While chroot is a pretty straightforward, namespaces and cgroups are a bit more nebulous to understand but no less important. Both of these
阅读全文
摘要:When Virtual keyboard popup, we can relayout the UI element accordingly: navigator.virtualKeyboard.overlaysContent = true; navigator.virtualKeyboard.s
阅读全文
摘要:It's a Linux command that allows you to set the root directory of a new process. In our container use case, we just set the root directory to be where
阅读全文
摘要:// Base case // 1. Off the map // 2. Hit a wall // 3. Already visited // 4. It's the end const dirs = [ [1, 0], //top [0, 1], //right [-1, 0], //botto
阅读全文
摘要:Run the following code, found that for get & push & pop, it is O(1) time; But for shift/unshfit, it is O(n) time. In this cases, Javascript's [], is a
阅读全文
摘要:z-index property arranges how an element is stacked onto other positioned elements. At times you may set a z-index property on a child element to be l
阅读全文
摘要:You only require a few lines of CSS to enable a dark/light mode on your website. You just need to let browsers know that your website can display corr
阅读全文
摘要:This trick is inclined towards improving copy and paste experience for website users. Using user-select: all, you can enable easy text selection with
阅读全文
摘要:You don't have to get stuck on how the browser renders a numbered list. You can implement your own design utilizing counters(). Here's how: ul { margi
阅读全文
摘要:Try throttling to a slow internet in the browser Dev tools and visit a website made up of HD images like unsplash. That's how to experience the pain o
阅读全文
摘要:When working with positioned elements, you often write code like this: .some-element { position: absolute; top: 0; left: 0; right: 0; bottom: 0; } Thi
阅读全文
摘要:p.intro { width: 300px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; /* Truncate when no. of lines exceed 3 */ overflow:
阅读全文
摘要:Using Linked list to implement a Queue. In javascript, if you want to push a item in front of an Array, it need to shift the rest of items, not good f
阅读全文
摘要:const $ = () => document.querySelector.call(this, arguments); const $$ = () => document.querySelectorAll.call(this, arguments); HTMLElement.prototype.
阅读全文
摘要:Implement the util type OptionalUndefined<T, Props> that turns all the properties of T that can be undefined, into optional properties. In addition, a
阅读全文
摘要:Given a number N, find the Nth triangular number, i.e. 1 + 2 + 3 + ... + N /* _____________ Your Code Here _____________ */ export type NumberToArray<
阅读全文
摘要:Given 2 sets (unions), return its Cartesian product in a set of tuples, e.g. CartesianProduct<1 | 2, 'a' | 'b'> // [1, 'a'] | [2, 'a'] | [1, 'b'] | [2
阅读全文
摘要:Solution 1: consider change font-size to 16px or above Soution 2: using javascript if(navigator.userAgent.indexOf('iPhone') > -1 ) { document .querySe
阅读全文
摘要:Merge variadic number of types into a new type. If the keys overlap, its values should be merged into an union. For example: type Foo = { a: 1; b: 2 }
阅读全文
摘要:Implement type CheckRepeatedChars<T> which will return whether type T contains duplicated member For example: type CheckRepeatedTuple<[1, 2, 3]> // fa
阅读全文
摘要:Remove the key starting with _ from given type T. /* _____________ Your Code Here _____________ */ type PublicType<T extends object> = { [Key in keyof
阅读全文
摘要:Empty commits might seem unusual, but they offer significant advantages in managing version control. By documenting milestones, triggering automation
阅读全文
摘要:You're given two identical crystal balls and a 100-story building. The balls are incredibly tough, but there exists some floor in the building, above
阅读全文
摘要:type OverloadedReturnType<T> = T extends { (...args: any[]) : infer R; (...args: any[]) : infer R; (...args: any[]) : infer R ; (...args: any[]) : inf
阅读全文
摘要:https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_container_queries .container { container: article / inline-size; } h2 { font-size: 7cqw; } @conta
阅读全文
摘要:The margin-trim property allows the container to trim the margins of its children where they adjoin the container's edges. https://developer.mozilla.o
阅读全文
摘要:html: <div class="post"> <h2>Post</h2> <a href="#"> a link</a> </div> <div class="post"> <h2>Post</h2> </div> <div class="post"> <a href="#"> a link</
阅读全文