Skip to content

Instantly share code, notes, and snippets.

View cawa-93's full-sized avatar
🇺🇦
Volunteer in Ukraine

Alex Kozack cawa-93

🇺🇦
Volunteer in Ukraine
View GitHub Profile
@cawa-93
cawa-93 / clearURL.js
Created January 29, 2019 13:42
Clear URL
/**
* @example
* const url = 'https://example.com/?query=val'
* const clearURL = new URL(url).clear('query').toString()
*/
URL.prototype.clear = function (...params) {
params.forEach(param => {
this.searchParams.delete(param)
})
return this
@cawa-93
cawa-93 / createObject.js
Last active February 4, 2020 11:55
Тестирование работы V8 — https://habr.com/ru/post/486162/
module.exports = function(keys) {
for (let key of keys) this[key] = 42;
}
@cawa-93
cawa-93 / dist_index-407b6fe0.js
Created November 30, 2020 10:39
reexport-test
export { B as ButtonComponent } from './main.js';
function IconComponent() {
console.log('This is IconComponent');
}
function HeavyComponent() {
console.log('This is HeavyComponent');
}
@cawa-93
cawa-93 / MapWithLimit.ts
Created June 16, 2021 09:08
Implementation of JavaScript `Map` with `size` limit
export class MapWithLimit<K = any, V = any> extends Map<K, V> {
readonly #limit: number
constructor(limit = 10, entries?: readonly (readonly [K, V])[] | null) {
super(entries);
this.#limit = limit;
}
set(key: K, value: V): this {
if (this.size + 1 > this.#limit) {
@cawa-93
cawa-93 / index.html
Created June 23, 2021 08:23
Reproducion for Electron issue #29319
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Electron Issue #29319</title>
</head>
<body>
@cawa-93
cawa-93 / index.html
Created September 13, 2021 20:18
Electron Media Session Api test case
<!-- Empty -->
@cawa-93
cawa-93 / index.html
Last active September 20, 2021 14:15
Electron Window Controls Overlay Issue
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<style>
body {
background: white;
-webkit-app-region: drag;
}
@cawa-93
cawa-93 / index.html
Created February 1, 2022 12:29
Electron repro: Devtools TypeError
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
@cawa-93
cawa-93 / sideloader.function.php
Last active June 3, 2022 20:04 — forked from kellenmace/class-download-remote-image.php
Download and Insert a Remote Image File into the WordPress Media Library
<?php
namespace Plugin\Sideloader;
/**
* Function handles downloading a remote file and inserting it
* into the WP Media Library.
* @param string $url HTTP URL address of a remote file
* @param int $post_id The post ID the media is associated with
* @param string $desc Description of the side-loaded file
* @param string $post_data Post data to override
@cawa-93
cawa-93 / index.html
Created January 28, 2022 16:28
Reproduction for: USB package crash electron webview
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<title>Hello World!</title>
</head>
<body>