Skip to content

Instantly share code, notes, and snippets.

(defun ps:auto-file-mode ()
(when (save-excursion
(save-restriction
(widen)
(goto-char (point-min))
(save-match-data
(looking-at "^#!"))))
(let* ((cmode (file-modes buffer-file-name))
(nmode (logior cmode (lsh (logand cmode #o444) -2))))
(when (not (= cmode nmode))
@pstray
pstray / my_auto-file-mode.el
Created January 27, 2020 12:58
A small elisp snippet for automatic +x on scripts
(defun my:auto-file-mode ()
(when (save-excursion
(save-restriction
(widen)
(goto-char (point-min))
(save-match-data
(looking-at "^#!"))))
(let* ((cmode (file-modes buffer-file-name))
(nmode (logior cmode (lsh (logand cmode #o444) -2))))
(when (not (= cmode nmode))
@pstray
pstray / keybase.md
Last active July 21, 2019 15:56
keybase.io proof

Keybase proof

I hereby claim:

  • I am pstray on github.
  • I am pstray (https://keybase.io/pstray) on keybase.
  • I have a public key whose fingerprint is 1AFB EC29 9C6F BD24 0127 B844 A659 284C D70F 3912

To claim this, I am signing this object:

@pstray
pstray / mkcrypt.pl
Created December 7, 2018 12:29
Generate various crypt for a password
#! /usr/bin/perl
use strict;
use Term::ReadKey;
my $pass = shift;
unless ($pass) {
$| = 1;
@pstray
pstray / ether-match
Last active August 17, 2018 13:21
A small script for use in ssh-config Match statements.
#! /bin/bash
#
# Usage in ~/.ssh_config, usefull RPi defaults:
#
# Match exec "ether-match %h 'b8:27:eb:*'"
# User pi
# ForwardX11 no
# CheckHostIP no
# StrictHostKeyChecking no
@pstray
pstray / gtaftw.md
Last active November 12, 2016 18:50 — forked from pkhamre/gtaftw.md
#gtaftw PSN handles

PSN username handles

Nick PSN handle
denis denizb
eric aatland
espen fooobaar
Flums Flumsen
jonas Zergnomen
norvald norvald
@pstray
pstray / ghclone.pl
Last active October 21, 2016 19:25
#! /usr/bin/perl
use JSON;
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
my $what = shift;
my($user,$repo);
@pstray
pstray / ssh-multi.sh
Last active September 28, 2023 18:07
Start tmux and ssh to multiple hosts with synchronized input
#! /bin/bash
if [ -z "$1" ]; then
echo "please supply at least one server to connect to" >&2
exit 1
fi
target=multi-ssh-$$
if [ -z "$TMUX" ]; then
@pstray
pstray / encode_header.pl
Last active October 22, 2016 13:26
Function to encode mail headers that aren't just plain ascii, like subject. use as encode_header('UTF-8', 'q', $subject);
sub encode_header {
my $charset = lc $_[0];
my $encoding = lc $_[1];
my $text = $_[2];
my @ret;
my $pre = "=?$charset?$encoding?";
my $suf = "?=";
my $max = 75 - length($pre) - length($suf);
#! /bin/sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
gw=$(route -A inet -n|awk '/UG/{ print $2 }')
ok=
if [ -n "$gw" ]; then
ping -c 1 $gw >& /dev/null && ok=1
fi