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
#!/usr/bin/env bash | |
# GIT_USERNAME="" | |
GIT_PUBLIC_KEYS_AUTHORIZED_KEYS_FILE="${GIT_PUBLIC_KEYS_AUTHORIZED_KEYS_FILE:-${HOME}/.ssh/authorized_keys}" | |
GIT_PUBLIC_KEYS_START="## Start of git public keys" | |
GIT_PUBLIC_KEYS_STOP="## End of git public keys" | |
tmp_file=$(mktemp) | |
clean() { | |
rm -f "$tmp_file" "${GIT_PUBLIC_KEYS_AUTHORIZED_KEYS_FILE}.gitkeys" |
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
#!/usr/bin/env bash | |
if ! command -p sudo -n -v > /dev/null 2>&1; then | |
echo "Execute this script as admin by using sudo writing:" | |
echo " sudo !!" | |
echo | |
fi | |
# Update | |
apt update -y |
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
# You need to change last param of the resource url for your stop number | |
# You need to change "A" for whatever your line it is | |
# You can view all default params information stop here: | |
#. https://www.tua.es/es/lineas-y-horarios/paradas/uria-centro-1218.html?idLinea=6#paradasIda | |
# homeassistant: | |
# packages: | |
# rest: !include tua.yaml | |
input_text: |
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
if(typeof Object.groupBy === typeof undefined) { | |
Object.groupBy = (arr, callback) => { | |
return arr.reduce((acc = {}, ...args) => { | |
const key = callback(...args); | |
acc[key] ??= [] | |
acc[key].push(args[0]); | |
return acc; | |
}, {}) | |
} | |
} |
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
/* Source: https://twitter.com/midudev/status/1652957687015940097 */ | |
background-color: Canvas; | |
color: CanvasText; | |
color-scheme: light dark; |
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
{ | |
"zschema": { | |
"prefix": "zschema", | |
"body": [ | |
"export const $1Schema = z.$2($3);", | |
"export type ${1/(.*)/${1:/pascalcase}/} = z.infer<typeof $1Schema>;", | |
"", | |
"$0" | |
], | |
"description": "Creates a function wrapper for a model's attribute." |
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 isBun() { | |
return Boolean(globalThis.Bun); | |
} | |
function isDeno() { | |
return Boolean(globalThis.Deno); | |
} | |
function isNode() { | |
return Boolean(globalThis.process?.versions?.node); |
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
77 | |
export type RemoveUnderscoreFirstLetter<S extends string> = | |
S extends `${infer FirstLetter}${infer U}` | |
? `${FirstLetter extends '_' ? U : `${FirstLetter}${U}`}` | |
: S; | |
export type CamelToSnakeCase<S extends string> = | |
S extends `${infer T}${infer U}` | |
? `${T extends Capitalize<T> ? '_' : ''}${RemoveUnderscoreFirstLetter< | |
Lowercase<T> |
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 { genericMapToType } from './generic-map-to-type.ts'; | |
export type ScraperSetter = (property: string, value?: any) => void; | |
type Key = Exclude<any, Function>; | |
type Value = Exclude<any, Function>; | |
export type ScrapeHandler = { | |
selector: string; | |
handler: HTMLRewriterTypes.HTMLRewriterElementContentHandlers; |
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
// bun --hot sse.ts | |
import { randomUUID } from "node:crypto"; | |
import { EventEmitter } from "node:events"; | |
const sseEvents = new EventEmitter(); | |
export const sse = (data) => { | |
sseEvents.emit( | |
"sse", | |
`id: ${randomUUID()}\ndata: ${JSON.stringify(data)}\n\n` |
NewerOlder