Skip to content

Instantly share code, notes, and snippets.

View midwire's full-sized avatar
🏠
Working from home

Chris Blackburn midwire

🏠
Working from home
View GitHub Profile
@midwire
midwire / vue_commands.sh
Last active June 25, 2021 16:30
[Vue CLI commands] #vue #javascript #command
# Create a new Vue app
vue create APPNAME
@midwire
midwire / change-postgres-user-pw.sh
Last active June 22, 2021 16:27
[Change postgres user password] #postgres #linux
sudo su - postgres
psql -d template1
alter user postgres with password 'new password';
exit # psql
exit # postgres login shell
systemctl restart postgresql
@midwire
midwire / stub_referrer_spec.rb
Created June 21, 2021 19:33
[Stub request.referrer in RSpec Controller Spec] #ruby #rails #rspec
allow_any_instance_of(ActionController::TestRequest).to receive(:referrer) { 'whatever' }
@midwire
midwire / silence_warnings.rb
Created April 15, 2021 21:15
[Silence warnings] Silence warnings in Ruby #ruby
Kernel.silence_warnings do
# do stuff here
end
@midwire
midwire / params.rb
Created April 1, 2021 16:10
[View Rails "Unpermitted" Params] #rails
# Some versions of Rails have a bug where you cannot even examine the `params` object in IRB or Pry
# If you get a message like: "unable to convert unpermitted parameters to hash" when you try to look at it
# You can do this:
params.permit!
@midwire
midwire / synosvc.sh
Created March 20, 2021 04:49
[Synology Service Control] Command line service control for Synology NAS #synology
# List the services
synoservice --list
# Stop a service
synoservicectl --stop pkgctl-EmbyServer
# Start a service
synoservicectl --start pkgctl-EmbyServer
@midwire
midwire / create_tar_gz.sh
Last active March 19, 2021 17:32
[Tar Gzip Files] Create, Decompress *.tar.gz files #tar #linux #devops
# For a couple files..
tar -czf archive.tar.gz file1 file2
# For an entire directory - recursively
tar -cfz archive.tar.gz directory_path
# Create an archive and send to another host over SSH - extract it there
tar cvf - project | ssh user@ip_addr "tar xv -C /var/www"
# Extract a tar.gz file
@midwire
midwire / change_password.sql
Created March 17, 2021 18:45
[Change Posgres User Password] Change password for a postgres user #postgres
-- If necessary:
-- sudo su - postgres
-- psql
ALTER ROLE username WITH PASSWORD 'password';
@midwire
midwire / optional-yubikey-sudo.md
Last active June 15, 2021 05:12
[Optional Yubikey Auth For Sudo] #yubikey #auth #linux
@midwire
midwire / pg_env_vars.sql
Last active February 16, 2021 18:01
[Access Environment Variables With Postgres] Use environment variables with postgresql #postgres
-- Before starting postgres server
-- export ENVNAME='whatever'
-- pg_ctl -D /usr/local/var/postgres [etc...] start
DROP TABLE IF EXISTS env;
DROP TABLE IF EXISTS env_tmp;
CREATE TEMP TABLE env_tmp(e text);
CREATE TEMP TABLE env(k text, v text);
COPY env_tmp ( e ) FROM PROGRAM 'env';