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 / hide-accessibly.css
Last active August 1, 2025 15:45
hide content accessibly
.visuallyhidden {
border: 0;
clip: rect(0 0 0 0);
height: auto; /* new - was 1px */
margin: 0; /* new - was -1px */
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
white-space: nowrap; /* 1 */
@selfagency
selfagency / grid-aspect-ratio.css
Last active August 1, 2025 15:46
grid aspect ratio
#grid {
width: 240px;
background: grey;
}
.aspectRatioSizer {
display: grid;
}
.aspectRatioSizer > * {
@selfagency
selfagency / dark-mode.css
Last active August 1, 2025 15:46
easy css dark mode
/* Text and background color for light mode */
body {
color: #333;
}
/* Text and background color for dark mode */
@media (prefers-color-scheme: dark) {
body {
color: #ddd;
background-color: #222;
@selfagency
selfagency / unquarantine-app.sh
Last active August 1, 2025 15:46
unquarantine mac os app
#!/usr/bin/env bash
xattr /path/to/MyApp.app
sudo xattr -r -d com.apple.quarantine /path/to/MyApp.app
@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