Skip to content

Instantly share code, notes, and snippets.

View zostay's full-sized avatar

Sterling Hanenkamp zostay

View GitHub Profile
@zostay
zostay / fpshow.go
Created August 31, 2023 19:35
A little program to show the innards of a floating point number.
package main
import (
"fmt"
"math"
"math/big"
"os"
)
func main() {
@zostay
zostay / README.txt
Last active October 18, 2022 05:03
Google Authentication Workflow for Pebble Watchapps
None of the workflow examples given in the Google Authentication OAuth2 documentation
(https://developers.google.com/accounts/docs/OAuth2) handle what's needed for Pebble. I
basically had to mix the needs of a client-side application with an offline web application
to get what's needed and work within the restrictions of the Pebble JS toolkit.
The steps are as follows:
1. Setup a Client ID for Web Application on the Google Developer Console
2. On the configuration web pages, with SSL:
* In the configuration page, use JavaScript to retrieve a authorization code, which
@zostay
zostay / README.md
Created January 24, 2020 22:32
Font files for Julian's hygrometer

Introduction

I built this file with:

./bdfconv -y 0 -th 2 -tv 3 -v -f 2 -m '37,46,67,91-100,176' ../bdf/profont29.bdf -o u8x8_font_profont29_2x3_j.c  -n u8x8_font_profont29_2x3_j
use v6.d;
my Supplier $pinger .= new;
my Supplier $ponger .= new;
react {
say 'Beginning ping/pong...';
whenever $pinger.Supply.throttle: 1, 1 {
.say;
$ponger.emit: 'pong';
@zostay
zostay / python-best-vs-perl6-best.md
Last active June 28, 2018 22:22
Transforming Code into Beautiful, Idiomatic Perl 6

Transforming Code into Beautiful, Idiomatic P̶y̶t̶h̶o̶n̶ Perl 6

I can't help myself... I think Perl 6 is easier to read than Python... so I toook the best practices here and added Perl 6 translations instead.

README FIRST!

Okay, so I'm not really trying to one-up Python (well, maybe just a little). I think Python, especially Python 3, is a very able language and use it for a several projects. I also appreciate the work of Raymond Hettinger and Jeff Paine in putting together these best practices and summarizing them, respectively.

However, I think Perl 6 has a truly ingenious syntax that has taken 15+ years to assemble from lessons learned from 20+ years of language development in Perl preceding it and hundreds of years of experience from other languages. Perl 6 unashamedly steals language features from many others. I sincerely hope that languages will start learning from Perl 6 and stealing back (actually, I'm certain so

@zostay
zostay / all-in-one-live.p6
Created September 4, 2016 12:58
P6WAPI On Demand Mini Server
#!/usr/bin/env perl6
use v6;
my $sideeffect = 0;
sub app(%env) {
start {
note "APP RESPONSE";
200, [ Content-Type => 'text/plain' ], supply {
note "SENDING REQUEST";
@zostay
zostay / all-in-one-live.p6
Created September 4, 2016 12:55
P6WAPI Mini Live Supply Demo
#!/usr/bin/env perl6
use v6;
my $sideeffect = 0;
sub app(%env) {
start {
my Supplier $content .= new;
start {
note "WAITING FOR READY ", %env<p6w.ready>.WHICH;
@zostay
zostay / ulimit.txt
Created January 27, 2016 03:47
My current ulimit -a for my linux box
% ulimit -a
-t: cpu time (seconds) unlimited
-f: file size (blocks) unlimited
-d: data seg size (kbytes) unlimited
-s: stack size (kbytes) 8192
-c: core file size (blocks) 0
-m: resident set size (kbytes) unlimited
-u: processes 15691
-n: file descriptors 1024
-l: locked-in-memory size (kbytes) 64
@zostay
zostay / ulimit.txt
Created January 27, 2016 03:17
ulimit on my machine
% ulimit -a
-t: cpu time (seconds) unlimited
-f: file size (blocks) unlimited
-d: data seg size (kbytes) unlimited
-s: stack size (kbytes) 8192
-c: core file size (blocks) 0
-v: address space (kbytes) unlimited
-l: locked-in-memory size (kbytes) unlimited
-u: processes 709
-n: file descriptors 256
@zostay
zostay / bad.psgi
Created August 15, 2012 13:59
OWASP Top Ten - A2 Cross Site Scripting (XSS) - Good/Bad - In Perl
use v5.16;
use Plack::Request;
my $app = sub {
# Use Plack::Request to help parse the environment
my $req = Plack::Request->new(shift);
# Load our input
my $input = $req->parameters->{input};