Skip to content

Instantly share code, notes, and snippets.

View selfagency's full-sized avatar
👾
beep boop

daniel sieradski selfagency

👾
beep boop
View GitHub Profile
@selfagency
selfagency / global-npm-without-sudo.md
Last active August 1, 2025 15:46
global npm without sudo

Install npm packages globally without sudo on macOS and Linux

npm installs packages locally within your projects by default. You can also install packages globally (e.g. npm install -g <package>) (useful for command-line apps). However the downside of this is that you need to be root (or use sudo) to be able to install globally.

Here is a way to install packages globally for a given user.

1. Create a directory for global packages
mkdir "${HOME}/.npm-packages"
@selfagency
selfagency / scp.sh
Last active August 1, 2025 15:46
scp - secure copy over ssh
#!/usr/bin/env bash
# Copy the file "foobar.txt" from a remote host to the local host
scp your_username@remotehost.edu:foobar.txt /some/local/directory
# Copy the file "foobar.txt" from the local host to a remote host
scp foobar.txt your_username@remotehost.edu:/some/remote/directory
# Copy the directory "foo" from the local host to a remote host's directory "bar"
scp -r foo your_username@remotehost.edu:/some/remote/directory/bar
@selfagency
selfagency / config-x11.sh
Last active August 1, 2025 15:53
x11 over ssh
#!/usr/bin/env bash
systemctl restart sshd
$AUTH=(xauth list | grep unix(echo $DISPLAY | cut -c10-12))
export DISPLAY=localhost:10.0
sudo xauth add $AUTH
sudo export DISPLAY=localhost:10.0
@selfagency
selfagency / home_.ssh_config
Last active August 1, 2025 15:46
run command before ssh login
Host selfagency.dev
ProxyCommand sh -c "updatefw; /usr/bin/nc %h %p"
@selfagency
selfagency / parse-data.sh
Last active August 1, 2025 15:47
parse apple ioreg command output
#!/usr/bin/env bash
function parseData() {
tail -n +2 $1 |
sed -re 's/\=/\:/g' |
sed -re 's/</\"/g' |
sed -re 's/>/\"/g' |
sed -re 's/No/false/g' |
sed -re 's/Yes/true/g' |
sed -re 's/\(/\[/g' |
@selfagency
selfagency / create-sudo-user-disable-root.sh
Last active August 1, 2025 15:47
new sudo user + disable root login
#!/usr/bin/env bash
# create user
adduser --disabled-password --gecos "" selfagency
# add to sudo group
usermod -aG sudo selfagency
# copy over ssh keys
rsync --archive --chown=selfagency:selfagency ~/.ssh /home/selfagency
@selfagency
selfagency / ssh-key-gen.sh
Last active August 1, 2025 15:50
new ssh key
#!/usr/bin/env bash
ssh-keygen -t rsa -b 4096 -C "email@address.com"
@selfagency
selfagency / create-brewfile.sh
Last active August 1, 2025 15:47
new brewfile
#!/usr/bin/env bash
brew bundle dump
@selfagency
selfagency / install-starship.sh
Last active August 1, 2025 15:47
install starship prompt
#!/usr/bin/env bash
curl -fsSL https://starship.rs/install.sh | bash
@selfagency
selfagency / install-postfix-mailgun.sh
Last active August 1, 2025 15:46
install postfix with mailgun on ubuntu
#!/usr/bin/env bash
sudo apt-get install mailutils
echo "inet_interfaces = loopback-only \
relayhost = [smtp.mailgun.org]:587 \
smtp_sasl_auth_enable = yes \
smtp_sasl_password_maps = static:login@domain.com:password \
smtp_sasl_security_options = noanonymous" >> /etc/postfix/main.cf
sudo service postfix restart
echo "This is my email test message" | mail -s "My subject line" your@email.com