Skip to content

Instantly share code, notes, and snippets.

View benharri's full-sized avatar
💭
why is this a thing

Ben Harris benharri

💭
why is this a thing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am benharri on github.
  • I am bharris (https://keybase.io/bharris) on keybase.
  • I have a public key ASChx0Cm4b0aKHfXbW_UnlWCWiFaDO5NW_ypjnF2E8DChQo

To claim this, I am signing this object:

@benharri
benharri / genthumb.php
Last active January 2, 2018 19:09
generate thumbnails for h5ai
#!/usr/bin/env php
<?php
require_once __DIR__ . '/_h5ai/private/php/class-bootstrap.php';
//Dummy parameters
$_SERVER['REQUEST_METHOD'] = 'get';
$_SERVER['SCRIPT_NAME'] = __DIR__.'/'.__DIR__.'/';
$_SERVER['SERVER_SOFTWARE'] = 'apache';
$_SERVER['HTTP_USER_AGENT'] = 'mozilla';
string h(string s) {
s = string.Concat(s.Where(c => char.IsUpper(c)||char.IsDigit(c)));
var m = s.Length;
var x = new string('-', m);
return $"+{x}+\n|{s}|\n+{x}+\n{new string(' ', m + 1)}v";
}
2018-03-28T17:58:54Z : info : startup : Oragono v0.10.3 starting
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x88 pc=0x6d2ea2]
goroutine 1 [running]:
github.com/oragono/oragono/irc.(*Config).TLSListeners(0xc420152380, 0xc4201651c8)
/home/dan/goenv/src/github.com/oragono/oragono/irc/config.go:333 +0x102
github.com/oragono/oragono/irc.(*Server).setupListeners(0xc420097680, 0xc420152380)
/home/dan/goenv/src/github.com/oragono/oragono/irc/server.go:1466 +0x43
github.com/oragono/oragono/irc.(*Server).applyConfig(0xc420097680, 0xc420152380, 0x1, 0xc420153180, 0x65)
[Unit]
Description=The Lounge IRC client
After=thelounge.service
[Service]
Type=simple
ExecStart=/home/ben/workspace/thelounge/index.js start
User=ben
Group=ben
Restart=always
@import url('https://fonts.googleapis.com/css?family=IBM+Plex+Mono');
* {
font-family: 'IBM Plex Mono', monospace;
font-size: 15px;
}
#chat .from .user::before,
#chat .from .user::after,
#sidebar .chan.query::before,
function scr
set -l filename ~/Pictures/scr_(date +%s).png
maim -s $filename
scp $filename thor:pub/screenies/. >/dev/null
echo -n "https://bhh.sh/pub/screenies/"(basename $filename) | xclip -selection clipboard
xclip -selection clipboard -o
end
#!/bin/bash
ssh tilde.team "awk -F: '($3>=500) && ($3!=65534)' /etc/passwd" > /tmp/passwd.new
ssh tilde.team "awk -F: '($3==100) && ($3!=65534)' /etc/group" > /tmp/group.new
ssh tilde.team "awk -F: '($3>=500) && ($3!=65534)' /etc/passwd | grep -f - /etc/shadow" > /tmp/shadow.new
cat /tmp/passwd.new | awk -F : '{printf("%s:%s:%s:%s::0:0:%s:%s:%s\n", $1,$2,$3,$4,$5,$6,$7); }' > /tmp/masterpasswd.new
cat /tmp/passwd.new >> /etc/passwd && sort -u /etc/passwd > /etc/passwd
cat /tmp/group.new >> /etc/group && sort -u /etc/group > /etc/group
cat /tmp/shadow.new >> /etc/shadow && sort -u /etc/shadow > /etc/shadow
# on tilde.team as root
unshadow /etc/passwd /etc/shadow > linux_passwd
cat linux_passwd | awk -F : '{printf("%s:%s:%s:%s::0:0:%s:%s:%s\n", $1,$2,$3,$4,$5,$6,$7); }' > new_passwd
# edit new_passwd to include only new users
# now on bsd box, switch to root shell
scp tilde.team:/root/new_passwd .
cat new_passwd >> /etc/master.passwd
pwd_mkdb -p /etc/master.passwd
#!/usr/bin/env bash
ssh tilde.team -- unshadow /etc/passwd /etc/shadow \
| awk -F : '{printf("%s:%s:%s:%s::0:0:%s:%s:%s\n", $1,$2,$3,$4,$5,$6,$7); }' > new_passwd
last_user=$(tail -n1 /etc/passwd | cut -f1 -d:)
sed -i "" "1,/^${last_user}/d" new_passwd
if [[ $(wc -l < new_passwd) -lt 1 ]]; then
echo no new users