Skip to content

Instantly share code, notes, and snippets.

@pdvcs
pdvcs / setup-neofetch.sh
Created March 28, 2024 21:56
Download and set up neofetch
#!/usr/bin/env bash
set -e
echo "Determining the latest version..."
LATEST_TAG=$(curl -sf 'https://api.github.com/repos/dylanaraps/neofetch/tags' | jq -r '.[0].name')
echo "Downloading neofetch..."
curl -sfL -o neofetch.tar.gz "https://github.com/dylanaraps/neofetch/archive/refs/tags/${LATEST_TAG}.tar.gz"
mkdir ./tmp
tar -C ./tmp -xf neofetch.tar.gz --strip-components=1
@pdvcs
pdvcs / .bashrc
Last active March 25, 2024 00:00
arch .bashrc
# ~/.bashrc for arch
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
alias ls='ls --color=auto'
alias ll='ls -l'
alias lh='ls -lrth'
alias me=micro
alias ppath="echo $PATH | tr ':' '\n'"
@pdvcs
pdvcs / employee.csv
Last active September 4, 2023 21:47
Write CSV to Postgres using COPY FROM
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 6 columns, instead of 7. in line 1.
1,^Alice Adams^,32,^3200 Sierra Drive, Bayport NY 10976^,125000
2,^Bob Bayliss^,23,^1900 Madison Ave, Apt 20, Bridgeport NY 10980^,83000
3,^Cayla Cass^,28,^1900 Brooke St, Apt 23, Bridgeport NY 10880^,120000
4,^Dan Drummond^,42,^102 Ellis St, Lynnford NY 10320^,205000
5,^Elaine Emms^,34,^112 Spring St, Hamford NY 10200^,130000
6,^Fifi Fenriss^,21,^^,90000
7,^Gaile Gantrieg^,29,^1900 Brooke St, Apt 23, Fremont CA 94537^,124000
8,^Harry Hall^,35,^^,85000
9,^Ian Isher^,26,^304 Malibu^^West Cross St, Dublin CA 94568^,89000
@pdvcs
pdvcs / ppath.c
Last active March 19, 2023 15:36
Pretty-print the system PATH
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define PATH_ENV_VAR "PATH"
#ifdef _WIN32
#define PATH_SEPARATOR ";"
#else
#define PATH_SEPARATOR ":"
@pdvcs
pdvcs / .tmux.conf
Created February 21, 2023 23:15
.tmux.conf for tmux 1.8 on RHEL7
# ~/.tmux.conf for tmux 1.8 (RHEL7)
set -sg escape-time 20
set -g default-terminal 'screen-256color'
set -g mouse-select-window on
set -g mouse-resize-pane off
# Start numbering at 1
set -g base-index 1
setw -g pane-base-index 1
@pdvcs
pdvcs / asdf-check-latest.py
Created January 22, 2023 20:26
Check ~/.tool-versions to see if contents are up-to-date
#!/usr/bin/env python3
import subprocess
targets = {
"nodejs": "18",
"ruby": "3",
"delta": "latest",
"exa": "latest",
"jq": "latest",
@pdvcs
pdvcs / ruby-asdf-ubuntu.md
Created January 1, 2023 19:46
Install Ruby with `asdf` on Ubuntu

Install Ruby with asdf on Ubuntu

Ruby needs the following dependencies:

sudo apt install git curl autoconf bison build-essential \
    libssl-dev libyaml-dev libreadline6-dev zlib1g-dev \
    libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libdb-dev
@pdvcs
pdvcs / setup-ssh-agent.sh
Last active January 8, 2024 03:31
Set up ssh-agent
#!/bin/bash
[[ "${BASH_SOURCE[0]}" == "${0}" ]] && echo "Please source this script" && exit 1
ssh-add -l > /dev/null 2>&1
export RET=$?
export ADDKEY=1
if [[ $RET == 2 ]]; then
# unable to connect to ssh-agent, so start it
eval $(ssh-agent -s)
@pdvcs
pdvcs / asdf-cheatsheet.md
Last active January 12, 2023 02:14
Frequently used asdf commands (asdf-vm.com)

asdf Cheatsheet

Install

The quickest way is to use git. You can find the latest branch on Github.

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.0

Source the following in .bashrc:

@pdvcs
pdvcs / setup-git-ssh.sh
Created August 28, 2022 01:09
Set up ssh-agent for Git
#!/bin/bash
[[ "${BASH_SOURCE[0]}" == "${0}" ]] && echo "Please source this script (source ~/setup-git-ssh)" && exit 1
ssh-add -l > /dev/null 2>&1
export RET=$?
if [[ $RET == 2 ]]; then
# unable to connect to ssh-agent, so start it
eval $(ssh-agent -s)
else