π΅βπ«
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
from collections import defaultdict | |
try: | |
book: defaultdict[str, str] = defaultdict(str) | |
with open("test.txt", "r", encoding="utf-8") as file: | |
for line in file: | |
if line.strip(): | |
parts = line.split() | |
if len(parts) >= 2: | |
book[parts[0]] = parts[1] |
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
#!/bin/bash | |
# Function to extract package versions from flutter pub outdated | |
get_latest_versions() { | |
flutter pub outdated | grep -v "Package Name" | grep -v "dependencies:" | grep -v "^$" | while read -r line | |
do | |
# Skip the header line with dashes | |
if [[ $line == *"Current"* ]]; then | |
continue | |
fi |
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
#!/bin/bash | |
# Store your new Git credentials | |
NEW_NAME="<$1>" | |
NEW_EMAIL="<$2>" | |
# Color codes for output | |
GREEN='\033[0;32m' | |
BLUE='\033[0;34m' | |
NC='\033[0m' # No Color |
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
type Success<T> = { | |
readonly success: true; | |
readonly value: T; | |
}; | |
type Failure<E> = { | |
readonly success: false; | |
readonly error: E; | |
}; |
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 * as fs from 'node:fs'; | |
import { $ } from 'bun'; | |
const hslToRgb = (h: number, s: number, l: number): [number, number, number] => { | |
h /= 360; | |
s /= 100; | |
l /= 100; | |
if (s === 0) { | |
return [l, l, l].map((v) => Math.round(v * 255)) as [number, number, 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
'use client'; | |
import type { JSXElementConstructor, ReactNode } from 'react'; | |
type InferProps<T> = T extends JSXElementConstructor<infer P> ? P : never; | |
type ProviderWithProps<T extends JSXElementConstructor<unknown>> = [ | |
T, | |
Omit<InferProps<T>, 'children'> | |
]; |
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 fs from 'fs'; | |
import path from 'path'; | |
import depcheck from 'depcheck'; | |
import { $ } from 'bun'; | |
import type { PackageJson } from 'type-fest'; | |
// If you're coming from GitHub Gist, you can remove or change this | |
const rootDir = path.join(__dirname, '..'); // Go up one level to project root | |
const packageJsonPath = path.join(rootDir, 'package.json'); | |
console.log('Checking:', packageJsonPath); |
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 { execSync } from 'child_process'; | |
import fs from 'fs'; | |
import path from 'path'; | |
import type { PackageJson } from 'type-fest'; | |
const packageJsonPath = path.join(process.cwd(), 'package.json'); | |
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')) as PackageJson; | |
const dependencies = Object.keys(packageJson.dependencies || {}); | |
const devDependencies = Object.keys(packageJson.devDependencies || {}); | |
const allDependencies = [...dependencies, ...devDependencies]; |
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
'use client'; | |
import { type StoreState, createGlobalStore } from '@/core/store'; | |
import type React from 'react'; | |
import { createContext, useContext, useRef } from 'react'; | |
import { useStore } from 'zustand'; | |
/** | |
* React context to provide the global store throughout the application. The context | |
* holds a reference to the store created by createGlobalStore or null if not yet initialized. |
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 { Provider } from 'jotai/react'; | |
import type { ReactNode } from 'react'; | |
/** | |
* Type definition for a React component that can accept children | |
* @template P - The props type for the component | |
*/ | |
type ComponentWithChildren<P = {}> = React.ComponentType<P & { children?: ReactNode }>; | |
/** |