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 { Client } from 'pg'; | |
import env from 'dotenv'; | |
// Load .env file. | |
env.config(); | |
const connectionURL = process.env.DATABASE_URL; | |
if (!connectionURL) throw new Error('Missing DATABASE_URL environment variable.'); | |
const defaultSchemaUrl = connectionURL.replace(/\/[^/]*$/, '/postgres'); |
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 { exec } from 'node:child_process'; | |
import os from 'node:os'; | |
export function getProcessUsage() { | |
let command = ''; | |
switch (os.platform()) { | |
case 'darwin': command = `ps -p ${process.pid} -o %cpu,rss`; break; | |
case 'linux': command = `ps -p ${process.pid} -o %cpu,rss`; break; | |
default: return Promise.reject(new Error('Unsupported platform!')); |
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
#!/bin/bash | |
confirm_and_apply() { | |
echo "The following credentials will be applied:" | |
echo "Name: $1" | |
echo "Email: $2" | |
echo | |
read -p "Do you want to apply these settings? (Y/n): " confirmation | |
echo |
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
#!/bin/bash | |
# How to get auth token: | |
# 1. Go to https://www.npmjs.com/settings/YOUR_USERNAME/tokens | |
# 2. Click on "Create New Token" | |
# 3. Enter the token name and click on "Create Token" -> "Classic Token" | |
# 4. Select "Publish" and click on "Generate Token" | |
# 5. Copy the generated token and paste it in the tokens array below | |
declare -A tokens |
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 numpy as np | |
import cv2 | |
import os | |
from tqdm import tqdm | |
def blur_faces(input_folder, output_folder, aggressivity): | |
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_alt2.xml') | |
if not os.path.exists(output_folder): | |
os.makedirs(output_folder) |
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 { isValidElement, Children } from 'react'; | |
import pkg from 'katex'; | |
export function Math({ expression }: { expression: string }) { | |
const equation = pkg.renderToString(expression, { throwOnError: false }); | |
return <span dangerouslySetInnerHTML={{ __html: equation }} />; | |
} | |
export function MathText({ children }: { children: React.ReactNode; }) { | |
const parseMathExpressions = (text: string) => { |
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
FOR /D /r %%F in ("*") DO ( | |
pushd %CD% | |
cd %%F | |
FOR %%X in (*.rar *.zip) DO ( | |
"C:\Program Files\7-zip\7z.exe" x %%X | |
DEL /Q "%%X" | |
) | |
popd | |
) |
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
export type RecursiveStringArray = (RecursiveStringArray | string)[]; | |
export type DeconstructedFunction = { args: (string | string[])[], body: string, wrapScope: boolean, wrapArgs: boolean; isAsync: boolean; }; | |
export function guildEvalParser<R, A extends never[]>(func: string | ((...args: A) => R)): string { | |
if (typeof func === 'function') func = func.toString(); | |
const type: 'function' | 'arrow' = (func.startsWith('function') || func.startsWith('async function')) ? 'function' : 'arrow'; | |
if (type === 'function') func = func.replace(/function\s+\w+\s*/, 'function '); | |
const data = getStuff({ func, type }); |
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
export type PusherEvents = { | |
// 'channel.id'; | |
channel: { | |
FollowersUpdated: { | |
followersCount: string | number | |
channel_id: number | |
username: unknown | |
created_at: number | |
followed: boolean | |
} |
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 https = require(`node:https`); | |
const fs = require(`node:fs`); | |
const config = { | |
token: ``, | |
fetchAll: true, // Fetch all files or just specific number | |
downloadFromDomain: null, // null or cdn.something.com | |
sortByMonth: true // would you like sort files by month | |
}; | |
main(); |
NewerOlder