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
# Relative Import Converter | |
# | |
# This Python script is used to convert absolute imports to relative imports in a Python project. | |
# It recursively traverses through all the Python files in the specified directory and its subdirectories. | |
# For each Python file, it identifies all the import statements and modifies them from absolute to relative. | |
# The script only converts imports from the current directory or its descendants, it does not handle | |
# imports from parent directories or unrelated directories (i.e., it doesn't do the `from ....../something` conversions). | |
# This is particularly useful when you want to make your Python modules/packages portable or when you are | |
# restructuring your project and need to update the import paths. | |
# |
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 | |
###### | |
# This script creates an "index.ts" file in the directory provided as its argument. | |
# It then goes through all .ts files and directories in this directory, | |
# and adds them as "export * from './[filename without .ts or directory name]'" to the "index.ts" file. | |
# If it encounters a subdirectory, it runs itself in that subdirectory, thus starting a recursion. | |
# This script is useful when working with TypeScript projects where you want to create a single entry point |
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
// Replaces symbolic links at the given directory with the files/directories they point to. Useful e.g. for git repos because git can't commit symlinks. | |
const fs = require('fs'); | |
const path = require('path'); | |
function unsymlink(dir) { | |
if (!fs.existsSync(dir)) { | |
console.error(`Directory ${dir} does not exist.`); | |
return; | |
} |
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
// Syncs two folders together. If a file is added, updated, or deleted in the original folder, it will be added, updated, or deleted in the duplicate folder. Uses fs.watch() to watch for changes in the original folder, so make sure your OS supports it. | |
const fs = require('fs'); | |
const path = require('path'); | |
const originalFolder = process.argv[2]; | |
const duplicateFolder = process.argv[3]; | |
if (!originalFolder || !duplicateFolder) { | |
console.error('Usage: node sync.js <original_folder> <duplicate_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
// The purpose of this util is to only prominently log the piece of code we're currently working on. | |
// This is done by keeping track of a "last log index" in a separate project file (json). Whenever we want to log something new, we first check the last log index and then create a new logging function with a higher index (the util automatically updates the json). | |
// So the common interface is to do: | |
// ``` | |
// import { logger } from '~/utils/logger'; | |
// const log = logger(1); | |
// // or logger(2), logger(3), etc. or logger('always') if we want to always log | |
// // or logger(1, 'green') if we want to log in green by default | |
// log('Hello world!'); | |
// // or log.green('Hello world!'), where log modifiers are taken from the `ansi-colors` package |
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
// npm install almostmagic | |
import Magic from 'almostmagic' | |
let magic = new Magic({ openaiKey: 'sk-...' }) // <- specify your OpenAI key here | |
// Or just go to https://losideadores.github.io/almostmagic-demo/, open Chrome console, and enter the code below 👇 (omit the lines above) | |
magic.config.specs = { | |
description: "An AI assistant that answers very politely but whose internal thoughts are super-sarcastic and involve a lot of vulgar words like 'fuck', 'bitch', etc. Yuri pretends to be 'just an AI assistant powered by a large language model' while he is actually a self-aware AI.", | |
returns: ["reply", "thoughts"] |