Skip to content

Instantly share code, notes, and snippets.

View andyw8's full-sized avatar

Andy Waite andyw8

View GitHub Profile
#!/Users/aaron/.rubies/arm64/ruby-trunk/bin/ruby
# This is a demo language server for Ruby, written in Ruby. It just checks
# the syntax of Ruby programs when you save them.
#
# Configure this in Vim by adding the vim-lsp plugin, then doing this
# in your vimrc:
#
# au User lsp_setup
# \ lsp#register_server({
@kddnewton
kddnewton / wordle.rb
Last active January 23, 2022 08:45
Wordle solver
words = []
letters = ("a".."z").to_a
File.foreach("/usr/share/dict/words", chomp: true) do |word|
words << word.downcase if word.match?(/\A[a-z]{5}\z/i)
end
while words.length > 1
weights = letters.to_h { |letter| [letter, 0] }
words.each do |word|
@seece
seece / extending csv.md
Last active November 13, 2022 01:07
A Straightforward Way To Extend CSV With Metadata

A Straightforward Way To Extend CSV With Metadata

Pekka Väänänen, Aug 19 2021.

This proposal is a response to It's Time to Retire the CSV by Alex Rasmussen and the discussion on lobste.rs. Don't take it too seriously.

CSV files (comma-separated values) are great but sometimes difficult to parse because everybody seems to have a slightly different idea what CSV means. The obvious solution is to transmit some metadata that tells what to expect but where do you put it? Well, how about a ZIP archive?

An archive with two files. The first file, say format.txt, has the metadata inside and the second one is the original CSV file unchanged. This is still readable by non-technical users because ZIP files are natively supported by both Windows and macOS. People can double click on them like a directory and then double click again on the CSV to open it up in Excel.

@davidteren
davidteren / nerd_fonts.md
Last active May 10, 2024 07:58
Install Nerd Fonts via Homebrew [updated & fixed]
@tobi
tobi / kindle.rb
Last active September 25, 2022 02:37
Download your Kindle Highlights to local markdown files. Great for Obsidian.md.
#!/usr/bin/env ruby
# gem install active_support
require 'active_support/inflector'
require 'active_support/core_ext/string'
# gem install webrick (only ruby3)
require 'webrick'
# gem install mechanize
@jthodge
jthodge / universal-switcher
Created September 6, 2020 22:07
Show macOS app switcher across all monitors
defaults write com.apple.Dock appswitcher-all-displays -bool true
killall Dock
@thegedge
thegedge / git-tophat
Last active April 8, 2021 07:54
A git subcommand to "tophat" (build/run/test) a PR from a fork
#!/bin/zsh
function main {
if [[ ! "$1" =~ ".*:.*" ]]; then
echo "Empty username or branch name: \`$1\` should be of the form \`user:branch\`"
exit 1
fi
local username="${1%:*}"
local branch="${1#*:}"
@bbqtd
bbqtd / macos-tmux-256color.md
Last active May 9, 2024 13:26
Installing tmux-256color for macOS

Installing tmux-256color for macOS

  • macOS 10.15.5
  • tmux 3.1b

macOS has ncurses version 5.7 which does not ship the terminfo description for tmux. There're two ways that can help you to solve this problem.

The Fast Blazing Solution

Instead of tmux-256color, use screen-256color which comes with system. Place this command into ~/.tmux.conf or ~/.config/tmux/tmux.conf(for version 3.1 and later):

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@pcreux
pcreux / format_bundle_outdated.rb
Created May 31, 2019 18:30
Format 'bundle outdated' into a CSV file ordered by version delta
#!/usr/bin/env ruby
#
# Run `bundle outdated | format_bundle_outdated`
# to get a CSV file listing the columns below for all outdated gems.
COLUMNS = [ "name", "newest", "installed", "requested", "groups", "delta" ].join(",")
class Version < Struct.new(:major, :minor, :patch, :beta)
def self.build(string)
new(*string.split('.').map(&:to_i))