This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Zellij - Launch zellij if not launched yet and not in vscode integrated shell | |
if not set -q VSCODE_SHELL_INTEGRATION | |
if set -q ZELLIJ | |
else | |
zellij | |
end | |
end | |
# Python - Activate python virtual env | |
function __auto_source_venv --on-variable PWD --description "Activate/Deactivate virtualenv on directory change" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/questions/76123232/can-javascript-detect-the-arc-browser | |
console.log( | |
getComputedStyle(document.documentElement) | |
.getPropertyValue('--arc-palette-title') ? 'Is Arc' : 'Is Not Arc' | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
from collections import Counter | |
import string | |
# Example collection of documents | |
documents = [ | |
'the quick brown fox jumps over the lazy dog', | |
'never jump over the lazy dog quickly', | |
'bright sun and the quick lazy dog', | |
'good dogs jump high' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TrieNode { | |
children: Map<string, TrieNode> = new Map(); | |
isValidDomain = false; | |
hasWildcard = false; | |
} | |
class Trie { | |
static build(allowedDomains: string | string[] | Trie, allowedSubDomains: string[]): Trie { | |
if (allowedDomains instanceof Trie) return allowedDomains; | |
if (!Array.isArray(allowedDomains)) allowedDomains = [allowedDomains]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* BloomFilter is a probabilistic data structure used to test whether an element | |
* is a member of a set, allowing for false positives. | |
*/ | |
export class BloomFilter { | |
static readonly DEFAULT_BIT_LEN = 8; | |
#size: number; | |
#bitArray: Uint8Array; // Uint8Array might be slower than BigInt64Array but easier to debug | |
#hashPassCount: number; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strings" | |
"bufio" | |
"bytes" | |
"strconv" | |
"io" | |
"os" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
test: /\.css$/, | |
loader: "style-loader!css-loader?modules&importLoaders=1&camelCase!postcss-loader", | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 悪い例:render関数内で新しい関数を定義 | |
class MyComponent extends React.Component { | |
render() { | |
const { value, handleChange } = this.props; | |
return <input value={value} onChange={handleChange.bind(this)} /> | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const urls = ['/task1', '/task2', ]; | |
let promise = Promise.resolve(); | |
tasks.forEach((task) => { | |
promise = promise.then(() => request.get(task)); | |
}); |
NewerOlder