Peter Stuifzand Notes on software, small tools, and the open web.

Tagged code

22:37 code

.obsidian/monospace.css


.markdown-source-view, .cm-s-obsidian { font-family: "Jetbrains Mono", monospace; }


.cm-fat-cursor .CodeMirror-cursor, .cm-animate-fat-cursor
{
  background: limegreen;
  opacity: 60% !important;
  width: 1em;
}

.cm-header-1, .cm-header-2, .cm-header-3, .cm-header-4,.cm-header-5, .cm-header-6 {
  font-size: 14px;
}

.CodeMirror {
  font-size: 14px;
  line-height: 1.4em;
}
19:58 code

.phpstorm.meta.php

<?php

namespace PHPSTORM_META {
    override(\ObjectManagerInterface::get(''), map([
        "" == "@",
    ]));

    override(\ObjectManagerInterface::create(''), map([
        "" == "@",
    ]));
}
11:24 code

endpoint.php

<?php
if ($_GET['action'] == 'channels') {
    $channels = array(
        array('uid' => 'notifications', 'name' => 'Notifications'),
        array('uid' => 'home', 'name' => 'Home'),
    );
    header('Content-Type: application/json');
    echo json_encode(array('channels' => $channels));
}
elseif ($_GET['action'] == 'timeline') {
    $uid = $_GET['channel'];
    $items = array();
    if ($uid == 'notifications') {
        $items[] = array(
            'type' => 'entry',
            'name' => 'Notification',
            'content' => array(
                'text' => 'simple text version',
                'html' => 'simple <b>HTML</b> version',
            ),
            'url' => 'https://example.com/1',
            'published' => '2018-07-22T13:11:00+02:00',
            '_id' => '1',
            '_read'=> false,
        );
    } elseif ($uid == 'home') {
        // add items to $items array ...
    }
    header('Content-Type: application/json');
    echo json_encode(array('items' => $items, 'paging'=>array()));
}
21:27 code

microsub-protocol.go

type Microsub interface {
	ChannelsGetList() []Channel
	ChannelsCreate(name string) Channel
	ChannelsUpdate(uid, name string) Channel
	ChannelsDelete(uid string)

	TimelineGet(before, after, channel string) Timeline

	MarkRead(channel string, entry []string)

	FollowGetList(uid string) []Feed
	FollowURL(uid string, url string) Feed

	UnfollowURL(uid string, url string)

	Search(query string) []Feed
	PreviewURL(url string) Timeline
}

Read on

15:15 code

.htaccess


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule>

# END WordPress
18:57 code

config.json

{
  "syndicate-to": [
    {
      "uid": "https://pinboard.in/pstuifzand",
      "name": "pstuifzand on Pinboard"
    },
    {
      "uid": "https://twitter.com/pstuifzand",
      "name": "pstuifzand on Twitter"
    }
  ],
  "destination": [
    {
      "uid": "https://p83.nl/",
      "name": "P83"
    },
    {
      "uid": "https://example.com/",
      "name": "Other blog"
    }
  ],
  "media-endpoint": "https://publog.stuifzandapp.com/media"
}
22:17 code

SXG.pm

# Simplest conversion from PHP to Perl.
# Based on PHP code from http://tantek.pbworks.com/w/page/19402946/NewBase60
# PHP code by Tantek Çelik http://tantek.com

sub num_to_sxg {
    my ($n) = @_;
    my $s = "";
    my @m = split//,"0123456789ABCDEFGHJKLMNPQRSTUVWXYZ_abcdefghijkmnopqrstuvwxyz";
    if (!$n) { return 0; }
    while ($n>0) {
        my $d = $n % 60;
        $s = $m[$d].$s;
        $n = ($n-$d)/60;
    }
    return $s;
}

sub num_to_sxgf {
    my ($n, $f) = @_;
    my $s = num_to_sxg($n);
    if (!$f) { 
        $f=1; 
    }
    $f -= length($s);
    while ($f > 0) { 
        $s = "0".$s; 
        --$f; 
    }
    return $s;
}

sub sxg_to_num {
    my ($s) = @_;
    my $n = 0;
    my @s = split//,$s;
    my $j = length($s);
    for (my $i=0;$i<$j;$i++) {
        my $c = ord($s[$i]);
        if ($c>=48 && $c<=57) { $c=$c-48; }
        elsif ($c>=65 && $c<=72) { $c-=55; }
        elsif ($c==73 || $c==108) { $c=1; }
        elsif ($c>=74 && $c<=78) { $c-=56; }
        elsif ($c==79) { $c=0; }
        elsif ($c>=80 && $c<=90) { $c-=57; }
        elsif ($c==95) { $c=34; }
        elsif ($c>=97 && $c<=107) { $c-=62; }
        elsif ($c>=109 && $c<=122) { $c-=63; }
        else { $c = 0; }
        $n = 60*$n + $c;
    }
    return $n;
}

Read on

10:51 code

screenshot.sh

#!/bin/bash
bkdest=$HOME/Desktop/Screenshots/
target=${bkdest}/$(date +%Y_%m_%d_%H_%M_%S).png
mkdir -p $bkdest
/usr/bin/gnome-screenshot -f $target -a
/usr/bin/pinta "$target"
MEDIA=`shpub -d -s $SHPUB_SERVER upload $target | tail -n 1`
shpub -d -s $SHPUB_SERVER note -c screenshots -f $MEDIA --json Screenshot