Skip to content

Instantly share code, notes, and snippets.

View codeprimate's full-sized avatar

Patrick Morgan codeprimate

  • Bellingham, WA
  • 10:59 (UTC -07:00)
View GitHub Profile
#!/bin/bash
# Usage:
# ~/bin/ai <<< "Why is the sky blue?"
# ls -l | ~/bin/ai "Which files listed above have symlinks?"
context_size=4000
n_predict=2000
temperature=0.5
prompt_prefix="\\nUSER: "
@codeprimate
codeprimate / gist:bb244d3d05da5eec4e726fc75a685546
Last active January 29, 2024 20:27
Tmux AI llama.cpp integration
#!/bin/bash
# Script: ~/bin/tmai
#
# Helper script for tmux llama.cpp integration
#
# Usage:
# - Optionally set the PROMPT_FILE envvar, containing the full path to a text file containing the system prompt
# - While in an active tmux session, press: CTRL-B x
# - Enter your prompt and press Enter
@codeprimate
codeprimate / script.sh
Created April 11, 2019 19:11
Generate Missing SSH Public Key
ssh-keygen -y -f $PRIVATEKEY > $PRIVATEKEY.pub
@codeprimate
codeprimate / installing-ffi.md
Created November 13, 2018 15:19
Error Installing ffi gem

ld: library not found for -lgcc_s.10.4

brew reinstall libffi
export LDFLAGS="-L/usr/local/opt/libffi/lib"
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
bundle install
@codeprimate
codeprimate / gist:c73411300684c228f4249873d244210e
Created November 28, 2017 16:04
Create favicon with ImageMagick
convert favicon.png -define icon:auto-resize=64,48,32,16 favicon.ico
@codeprimate
codeprimate / example.txt
Created August 21, 2017 03:28
Easy File Transfer from Heroku
# Remote
cat <file_name> | gpg -ac -o- | curl -X PUT -T "-" https://transfer.sh/<file_name>.gpg
# Local
curl https://transfer.sh/<hash>/<file_name>.gpg | gpg -o- > <file_name>
@codeprimate
codeprimate / convert.sh
Created February 8, 2017 16:05
Convert Apple iOS Certificate to PEM
openssl x509 -inform der -in certificate.cer -out certificate.pem
@codeprimate
codeprimate / annodate_images.sh
Created November 15, 2016 16:02
Annotate Images with Date
#!/bin/bash
[ ! -d out ] && mkdir out
for img in "$@"; do \
img_width="$(identify -format %w $img)"; \
img_height="$(identify -format %h $img)"; \
label_height=$(bc -l <<< "$img_height/50"); \
img_date=$(stat -l -t "%F" $img | awk '{print $6}'); \
convert -background '#0008' -fill white -gravity center -size ${img_width}x$label_height \
@codeprimate
codeprimate / update-blocklist.sh
Created November 10, 2016 18:00
Update Transmission Blocklist
#!/bin/bash
echo "* Updating transmission blocklist"
BLOCKLIST_DIR=/var/lib/transmission-daemon/info/blocklists
#wget -q -O- http://www.bluetack.co.uk/config/level{1,2,3}.gz | \
# gunzip -c > ${BLOCKLIST_DIR}/level123 && \
cd $BLOCKLIST_DIR
wget -qO level1.gz http://list.iblocklist.com/?list=bt_level1&fileformat=p2p&archiveformat=gz&username=XXXX&pin=XXXX
wget -qO level2.gz http://list.iblocklist.com/?list=bt_level2&fileformat=p2p&archiveformat=gz&username=XXXX&pin=XXXX
wget -qO level3.gz http://list.iblocklist.com/?list=bt_level3&fileformat=p2p&archiveformat=gz&username=XXXX&pin=XXXX
@codeprimate
codeprimate / gen-ssl.sh
Created July 22, 2016 20:23
Script to Generate self-signed SSL certificate
#!/usr/bin/env bash
[ -z "$SSL_DIR" ] && export SSL_DIR="."
[ -z "$DOMAIN" ] && export DOMAIN="*.lvh.me"
[ -z "$FILENAME" ] && export FILENAME="wild_lvh_me"
echo " => Generating Self-Signed SSL certificate for $DOMAIN (Using ENV[DOMAIN])"
echo " Filename: $SSL_DIR/$FILENAME (Using ENV[SSL_DIR] and ENV[FILENAME])"
if [ -e "$SSL_DIR/$FILENAME.key" ]; then