Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 readline = require("node:readline"); | |
const { Writable } = require("node:stream"); | |
const getPassword = (user) => | |
new Promise((resolve) => { | |
const mutableStdout = new Writable({ | |
write: function (chunk, encoding, callback) { | |
if (!this.muted) process.stdout.write(chunk, encoding); | |
callback(); | |
}, |
This file contains 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 crypto = require("node:crypto"); | |
const { Buffer } = require("node:buffer"); | |
const ALGO = "aes-256-cbc"; | |
// random SECRET stored in memory | |
const SECRET = crypto.randomBytes(64); | |
function getKey(salt) { | |
// In 2023, OWASP recommended to use 600,000 iterations for PBKDF2-HMAC-SHA256 and 210,000 for PBKDF2-HMAC-SHA512.[6] | |
return crypto.pbkdf2Sync(SECRET, salt, 210_000, 32, "sha512"); |
This file contains 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
// to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2. | |
use std::fs; | |
use std::io::Error; | |
fn main() -> Result<(), Error> { | |
let contents = fs::read_to_string("./src/input.txt"); | |
let data = match contents { | |
Ok(c) => c, |
This file contains 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 { useRef, useEffect } from 'react'; | |
type IProps = Record<string, unknown>; | |
const useWhyDidYouUpdate = (componentName: any, props: any) => { | |
const oldPropsRef = useRef<IProps>({}); | |
useEffect(() => { | |
if (oldPropsRef.current) { | |
// iterate through all the key of the old and new props |
This file contains 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 | |
type dessert int | |
const ( | |
ICE_CREAM dessert = iota | |
CUP_CAKES | |
GUMMY_WORMS | |
) |
This file contains 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
git ls-remote --heads origin | while read sha ref; do | |
behind=`git rev-list $sha..master --count` | |
if [ $behind -ge 1000 ]; then | |
echo "$ref $behind"; | |
fi | |
done |
This file contains 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
[alias] | |
rebase-since = !sh -c 'git rebase -i $(git merge-base --fork-point \"${1:-master}\" HEAD)' - | |
graph = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue) <%an>%Creset' --abbrev-commit --date=relative |
This file contains 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
function getElemByText(text) { | |
return document.evaluate( | |
`//*[contains(translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '${text}')]`, | |
document, | |
null, | |
XPathResult.FIRST_ORDERED_NODE_TYPE, | |
null | |
).singleNodeValue; | |
} |
This file contains 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 React from 'react'; | |
const withTheme = <P extends {}>(Comp: React.ComponentType<P>) => { | |
return Comp as any as React.ForwardRefExoticComponent< | |
React.PropsWithoutRef<P> & | |
React.RefAttributes<any> | |
> & { | |
defaultProps: typeof Comp['defaultProps']; | |
}; | |
} |
NewerOlder