Skip to content

Instantly share code, notes, and snippets.

View aculich's full-sized avatar
😀
Having fun exploring repos for Computational Text Analysis with D-Lab CTAWG

Aaron Culich aculich

😀
Having fun exploring repos for Computational Text Analysis with D-Lab CTAWG
View GitHub Profile

Mermaid on Github Examples

All of these diagrams are dynamically rendered during html display by Github, the images generated from text inside the Github-Flavored Markdown. None are static images. Mermaid support was released for Github on 2022-02-14

Pros & Cons:

  • Pro: You don't need to care about the layout.
  • Con: You cannot control the layout.

Notes:

  • Not all the features of Mermaid (in particular symbols B-->C[fa:fa-ban forbidden], hyperlink and tooltips) are supported by Github.
@aculich
aculich / bookmarkletify.sh
Last active January 16, 2025 10:42
converts a given JavaScript file into a bookmarklet using terser
#!/usr/bin/env bash
# Overview:
# This script ensures that npm and the terser package are installed,
# and it converts a given JavaScript file into a bookmarklet. The
# output is saved as bmlet_<original_file_name>.js. The script does the following:
# 1. Checks if npm is installed.
# 2. Installs terser globally if not already installed.
# 3. Minifies the provided JavaScript file and converts it into a bookmarklet format.
# 4. Outputs the result into a new file named bmlet_<input_file_name>.js.
#!/usr/bin/env python
import os
import sqlite3
from tqdm import tqdm
def get_table_schema(cursor, table_name):
cursor.execute(f"PRAGMA table_info({table_name})")
return {col[1]: col[2] for col in cursor.fetchall()}

Quick Start Tutorial: Setting Up SSH for a Mac Laptop to Access Remote Linux Environments

This tutorial will guide you through setting up SSH on a Mac laptop to securely connect to a remote Linux machine with two different user accounts. We'll cover SSH key generation, integrating keys with the Mac keychain, updating authorized keys on the remote machine, and configuring VS Code for seamless access.

Step 1: Generate SSH Keys on the Mac

  1. Open Terminal on your Mac.
  2. Generate a new SSH key pair:
    ssh-keygen -t rsa -b 4096 -C "[email protected]"
@aculich
aculich / add_to_zshrc.sh
Created August 26, 2024 05:48 — forked from karpathy/add_to_zshrc.sh
Git Commit Message AI
# -----------------------------------------------------------------------------
# AI-powered Git Commit Function
# Copy paste this gist into your ~/.bashrc or ~/.zshrc to gain the `gcm` command. It:
# 1) gets the current staged changed diff
# 2) sends them to an LLM to write the git commit message
# 3) allows you to easily accept, edit, regenerate, cancel
# But - just read and edit the code however you like
# the `llm` CLI util is awesome, can get it here: https://llm.datasette.io/en/stable/
gcm() {
@aculich
aculich / gcom.plugin.zsh
Last active August 26, 2024 06:42 — forked from karpathy/add_to_zshrc.sh
Git Commit Message AI
# -----------------------------------------------------------------------------
# AI-powered Git Commit Function
# Copy paste this gist into your ~/.bashrc or ~/.zshrc to gain the `gcom` command.
# or add it to ~/.oh-my-zsh/custom/plugins
#
# 1) gets the current staged changed diff
# 2) sends them to an LLM to write the git commit message
# 3) allows you to easily accept, edit, regenerate, cancel
# But - just read and edit the code however you like
# the `llm` CLI util is awesome, can get it here: https://llm.datasette.io/en/stable/
#!/bin/bash
# turn GCP (Google Cloud Platform) metadata key/values into shell environment variables
# Function to fetch metadata and set as environment variable
fetch_and_export() {
local path=$1
local value=$(curl "http://metadata.google.internal/computeMetadata/v1/${path}" -H "Metadata-Flavor: Google" --silent)
if [ $? -eq 0 ] && [ ! -z "$value" ]; then
# Convert metadata keys to uppercase and replace invalid characters for shell variable names
# To automatically start tmux on a remote system
# add this to the ~/.ssh/config Host stanzas
# Host remote-with-tmux
# RequestTTY yes
# RemoteCommand tmux new -A
# see also: https://github.com/tmux/tmux/wiki/Clipboard
# and also: https://blog.jbowen.dev/tips/ssh-tmux/
# and also: https://www.freecodecamp.org/news/tmux-in-practice-integration-with-system-clipboard-bcd72c62ff7b/
@aculich
aculich / using-details-summary-github.md
Created December 7, 2022 20:36 — forked from scmx/using-details-summary-github.md
Using <details> <summary> expandable content on GitHub with Markdown #details #summary #markdown #gfm #html

How to use <details> <summary> expandable content on GitHub with Markdown

Firstly, what is <details> <summary>?

The HTML Details Element (<details>) creates a disclosure widget in which information is visible only when the widget is toggled into an "open" state. A summary or label can be provided using the <summary> element. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details.

Example

@aculich
aculich / homebrew-gnubin.md
Created November 28, 2022 19:42 — forked from skyzyx/homebrew-gnubin.md
Using GNU command line tools in macOS instead of FreeBSD tools

macOS is a Unix, and not built on Linux.

I think most of us realize that macOS isn't a Linux OS, but what that also means is that instead of shipping with the GNU flavor of command line tools, it ships with the FreeBSD flavor. As such, writing shell scripts which can work across both platforms can sometimes be challenging.

Homebrew

Homebrew can be used to install the GNU versions of tools onto your Mac, but they are all prefixed with "g" by default.

All commands have been installed with the prefix "g". If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH from your bashrc.