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 July 11, 2021 00:56
[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 July 11, 2021 00:57
[scp] secure copy over ssh
#!/usr/bin/env bash
# Copy the file "foobar.txt" from a remote host to the local host
scp [email protected]:foobar.txt /some/local/directory
# Copy the file "foobar.txt" from the local host to a remote host
scp foobar.txt [email protected]:/some/remote/directory
# Copy the directory "foo" from the local host to a remote host's directory "bar"
scp -r foo [email protected]:/some/remote/directory/bar
@selfagency
selfagency / config-x11.sh
Last active August 15, 2021 20:07
[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 July 11, 2021 00:57
[run command before ssh login]
Host selfagency.dev
ProxyCommand sh -c "updatefw; /usr/bin/nc %h %p"
@selfagency
selfagency / parse-data.sh
Last active July 11, 2021 00:58
[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 July 11, 2021 00:58
[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 July 11, 2021 01:31
[new ssh key]
#!/usr/bin/env bash
ssh-keygen -t rsa -b 4096 -C "[email protected]"
@selfagency
selfagency / create-brewfile.sh
Last active July 11, 2021 00:58
[new brewfile]
#!/usr/bin/env bash
brew bundle dump
@selfagency
selfagency / install-starship.sh
Last active July 11, 2021 00:58
[install starship prompt]
#!/usr/bin/env bash
curl -fsSL https://starship.rs/install.sh | bash
@selfagency
selfagency / install-postfix-mailgun.sh
Last active July 11, 2021 00:57
[install postfix with mailgun] 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:[email protected]: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" [email protected]