Skip to content

Instantly share code, notes, and snippets.

View drsjb80's full-sized avatar

Steve Beaty drsjb80

View GitHub Profile
@drsjb80
drsjb80 / gist:314aed91eb945faa6ec5e07c9658dd31
Created August 4, 2022 13:36
Adding subscripting to Rails Activerecord
class Phone < ApplicationRecord
belongs_to :person
def self.[](index)
find(index)
end
end
The resource http://localhost:3000/assets/es-module-shims.min-4ca....js was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally.
config.action_view.preload_links_header = false
This :#<NameError: uninitialized constant Gem::Source led me to this which worked for me:
https://github.com/rubygems/rubygems/issues/5351#issuecomment-1216741599
Not enough Rubies in rbenv:
mkdir -p "$(rbenv root)"/plugins
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
@drsjb80
drsjb80 / ffmpegall.sh
Last active December 15, 2020 03:01
Convert all arguments from wav to mp3
#!/usr/bin/env bash
IFS=''
for i in $@
do
ffmpeg -i "${i}" -b:a 320k "${i%%.*}".mp3
done
@drsjb80
drsjb80 / faker.sh
Created July 16, 2018 14:02
An example of how to use faker for database seeds in Ruby on Rails.
#! /bin/bash
rm -rf advisorandstudent
rails new advisorandstudent --skip-spring
cd advisorandstudent
echo "gem 'faker'" >> Gemfile
bundle install
rails generate scaffold Student name:string advisor:references
rails generate scaffold Advisor name:string
rails db:migrate
@drsjb80
drsjb80 / eye2eh.c
Last active September 25, 2017 17:09
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <unistd.h>
/* Write a string */
#define WRITES(a) { assert (write (STDOUT_FILENO, a, strlen (a)) >= 0); }
/* Write an integer i no longer than l */
#define WRITEI(i,l) { char buf[l]; assert (eye2eh (i, buf, l, 10) != -1); WRITES (buf); }
/* Write a newline */
#! /bin/bash
# my subaru plays tracks based on creation or modification date (i'm not
# sure which and i'm not going to spend the time to find out), not
# alphabetically nor by paying attention to the track numbers. so i wrote
# this to align the dates with the alphabetic order.
today=`date "+%C%y%m%d"`
hour=0
minute=0
#! /bin/bash
dryrun=false
if [[ $1 == '-n' ]]
then
dryrun=true
shift
fi
# 's/^([0-9])-/0\1-/' -- add one leading zero
@drsjb80
drsjb80 / rmkernels
Last active December 27, 2016 19:21
Remove debian kernels, except the last three
#! /bin/bash
# remove kernel and kernel headers, leaving the three most recent versions.
# the user is prompted before actions performed.
# parameters: what to remove and how many to leave
function doit {
LIST=`dpkg -l "$1" | \
grep ii | \
grep generic | \
@drsjb80
drsjb80 / mp3tagBrewWineStartwine.diffs
Last active December 19, 2016 21:29
diffs to get mp3tag working in macos using brew wine
diff --git a/startwine b/startwine
index 8b52866..596545a 100755
--- a/startwine
+++ b/startwine
@@ -1,13 +1,12 @@
#!/bin/bash
-
-
BUNDLERESOURCEPATH="$(dirname "$0")/../Resources"
#! /bin/bash
# based partially on:
# https://github.com/docker/toolbox/blob/master/osx/uninstall.sh
# just an initial guess, you might want to add more.
keepdirs=('/usr' '/usr/local' '/usr/local/bin' '/usr/sbin' '/etc' \
'/usr/local/etc' '/usr/local/share' )
for pkg in "$*"