Skip to content

Instantly share code, notes, and snippets.

View xiaody's full-sized avatar
🍼
I may be slow to respond.

xiaody xiaody

🍼
I may be slow to respond.
View GitHub Profile
@tomhicks
tomhicks / plink-plonk.js
Last active March 18, 2024 02:23
Listen to your web pages
@laughinghan
laughinghan / Every possible TypeScript type.md
Last active May 8, 2024 11:14
Diagram of every possible TypeScript type

Hasse diagram of every possible TypeScript type

  • any: magic, ill-behaved type that acts like a combination of never (the proper [bottom type]) and unknown (the proper [top type])
    • Anything except never is assignable to any, and any is assignable to anything at all.
    • Identities: any & AnyTypeExpression = any, any | AnyTypeExpression = any
    • Key TypeScript feature that allows for [gradual typing].
  • unknown: proper, well-behaved [top type]
    • Anything at all is assignable to unknown. unknown is only assignable to itself (unknown) and any.
    • Identities: unknown & AnyTypeExpression = AnyTypeExpression, unknown | AnyTypeExpression = unknown
  • Prefer over any whenever possible. Anywhere in well-typed code you're tempted to use any, you probably want unknown.
@Rob--W
Rob--W / manifest.json
Created August 2, 2019 15:20
Dummy extension to prevent elision of "http" / "file" / subdomains from the omnibox in Chrome. Use this instead of the "Suspicious Site Reporter".
// This is a dummy extension that prevents elision of "http" / "file" / subdomains
// from the omnibox by impersonating the "Suspicious Site Reporter" extension.
// Do not use this if you use the "Suspicious Site Reporter" extension.
//
// Usage:
// 1. Create a directory, e.g. "prevent-elision-in-locationbar"
// 2. Put the content of this file as "manifest.json" in that directory.
// 3. Visit chrome://extensions, choose the "Load Unpacked" button and select the directory.
// (OR use the --load-extension=path/to/prevent-elision-in-locationbar flag to load the extension)
// Result:
@devoto13
devoto13 / custom-event-manager.ts
Created January 20, 2018 10:36
EventManager, which allows to subscribe to any event outside of NgZone, so event won't trigger change detection
/**
* Custom event manager, which allows to add event listeners outside of Angular
* zone.
*
* See https://stackoverflow.com/a/45229997/1377864 for original idea
*/
@Injectable()
export class CustomEventManager extends EventManager {
addGlobalEventListener(target: string, eventName: string, handler: Function): Function {
if (eventName.endsWith(NO_ZONE)) {
@stereokai
stereokai / gist:36dc0095b9d24ce93b045e2ddc60d7a0
Last active May 22, 2024 11:42
CSS rounded corners with gradient border
.rounded-corners-gradient-borders {
width: 300px;
height: 80px;
border: double 4px transparent;
border-radius: 80px;
background-image: linear-gradient(white, white), radial-gradient(circle at top left, #f00,#3020ff);
background-origin: border-box;
background-clip: padding-box, border-box;
}
@mauriciosoares
mauriciosoares / doubleclick.js
Created October 19, 2015 20:07
rxjs double click example
let clickStream = Rx.Observable.fromEvent(document.getElementById('link'), 'click');
clickStream
.buffer(clickStream.debounce(250))
.map(list => list.length)
.filter(x => x === 2)
.subscribe(() => {
console.log('doubleclick');
})
@dergachev
dergachev / ubuntu-eol.md
Last active December 7, 2023 22:26
What to do when your ubuntu distro is End-of-Life

Let's say you're using Ubuntu 13.04 (Raring Ringtail, released in April 2013) and it just went End-of-Life on you, because it's supported for only 6 months, and the deprecated packages are taken down after 12 months.

You'll probably figure this out the hard way. When you run sudo apt-get update, it will eventually report these errors:

Ign http://archive.ubuntu.com raring-updates/universe Sources/DiffIndex
Err http://security.ubuntu.com raring-security/main Sources
  404  Not Found [IP: 91.189.91.15 80]
Err http://security.ubuntu.com raring-security/universe Sources
  404  Not Found [IP: 91.189.91.15 80]
@plentz
plentz / nginx.conf
Last active June 11, 2024 06:55
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//