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 / 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';
@midwire
midwire / sed.sh
Created February 8, 2021 23:27
[SED one-liners] Handy sed one-liners #sed #utils
Handy one-liners for SED
HANDY ONE-LINERS FOR SED (Unix stream editor) Mar. 23, 2001
compiled by Eric Pement <[email protected]> version 5.1
Latest version of this file is usually at:
http://www.student.northpark.edu/pemente/sed/sed1line.txt
http://www.cornerstonemag.com/sed/sed1line.txt
This file is also available in Portuguese at:
http://www.lrv.ufsc.br/wmaker/sed_ptBR.html
@midwire
midwire / screen.sh
Last active February 4, 2021 03:32
[Using Screen] #linux #ssh
# Launch screen with a title
screen -t <title>
# start long running command
<ctrl>-a d # detach screen
# Launch named screen session
screen -S <title>
# live a happy life.
@midwire
midwire / yubikey-for-linux-sudo.md
Last active January 31, 2021 21:09
[Passwordless Login With Yubikey on Linux] #linux #yubikey #security #authentication