Skip to content

Instantly share code, notes, and snippets.

View frodwith's full-sized avatar

Paul Driver frodwith

View GitHub Profile
# vim:syntax=perl
# A PSGI app that listens for POSTs, runs an editor on the posted text,
# and returns the modified text as the response body. Intended for use with
# Chrome extensions like TextAid and Edit With Emacs.
#
# This app blocks, so you'll want to run it in a forking Plack server (like
# Starman).
#
# Requires: Plack
use warnings;
use strict;
use Getopt::Long;
my ($search, $sfilename);
GetOptions(
'search=s' => \$search,
'servers=s' => \$sfilename,

Encoding and utf8 in perl

A perl string is a logical sequence of characters.

encoding a perl string produces a sequence of octets. decoding a sequence of octets produces a perl string.

utf8::is_utf8 tells you whether the string is a sequence of logical characters (true) or a sequence of octets (false). You should not

import script pseudocode:
find all sites on this server
for each site:
look in config file (see below for example)
for each entry for this site:
fetch package from 300dev/config.url
import package under config.parent with the overwriteLatest flag
set according to config.overwrite (default yes)
We have the opportunity now to rethink the way packages are done. The old
methods need to continue working, so we're going to maintain backwards
compatibility -- that is, we are going to support the old package format, etc.
New package system
---
- packages aren't going to be tied to WebGUI::Storage.
- operates on directories, not tarballs (transport detail)
- possibly support other transports, like gzipped tarballs
#!/usr/bin/perl
use warnings;
use strict;
my %keys = ( esc => 53, tab => 48, space => 49);
my %mt = (m => 'command', 'o' => 'option', c => 'control', s => 'shift');
my @mods = @ARGV;
my $key = pop @mods;
@frodwith
frodwith / wbaduk.pl
Last active December 18, 2015 03:58
use warnings;
use strict;
use DBI;
my $dbname = $ARGV[0] || die 'No database file name';
my $dbh = DBI->connect("dbi:SQLite:dbname=$dbname");
my $games = $dbh->selectall_arrayref('SELECT * FROM t_gibo', { Slice => {} });
?- val
{$thing *} ...
{$gizmo *} ...
==
@frodwith
frodwith / newmug.hoon
Created July 3, 2020 20:43
mung, a replacement for mug?
:- %say
|= [* ~ *]
:- %noun
=< ^- (list @uv)
%- turn
:_ mung
^- (list *)
:~ 0
42
[0 0]