Skip to content

Instantly share code, notes, and snippets.

View scintill's full-sized avatar

Joey Hewitt scintill

View GitHub Profile
@scintill
scintill / elements-dictionary.php
Last active December 27, 2015 01:29
PHP to spell words with symbols from the periodic table
<?php
/**
* Similar to elements.php, but with all words in a dictionary.
*/
require_once('elements.php');
$els = getElements();
$mostMatchesLen = 0;
$mostMatches = '';
@scintill
scintill / interleave.php
Created October 31, 2013 07:55
"Interleave" two strings in every possible way.
<?php
/*
* "Interleave" two strings in every possible way.
* interleave('ABC', 'DE') =
* ABCDE ABDCE ABDEC ADBCE ADBEC ADEBC DABCE DABEC DAEBC DEABC
*
* Nothing real special here, just thought it was an interesting
* problem that gets annoying for humans but after some thought is
* quite simple to a programmer and a computer.
@scintill
scintill / ego.md
Last active January 12, 2021 21:34
List of repositories I've contributed to

My forks of these repos were cluttering up my repository list. I liked being able to see where my patches had been accepted, but wanted to get rid of my clones. So here's a list of things I've pruned off my personal repo list, but that exist in the upstream repo.

<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
var BSeed = [109,198,182,214,76,65,92,201,96,30,77,82,22,38,127,144,66,220,135,226,199,188,185,224,68,72,86,200,207,89,236,132,118,240,224,214,210,71,46,165,72,72,241,136,190,48,103,38,243,175,82,65,130,140,34,108,55,87,63,222,169,168,3,44,50,22,113,202,64,182,166,124,123,89,209,193,176,176,107,24,50,80,85,139,75,215,173,132,113,63,23,150,242,240,195,13,143,244,101,214,118,20,220,192,241,156,151,181,88,121,122,44,162,249,239,79,120,28,232,34,57,72,155,52,152,61,196,108,176,218,165,122,184,57,144,172,232,28,8,58,24,155,56,36,215,137,41,196,115,107,181,106,104,22,249,1,110,22,2,124,247,79,110,172,231,210,172,231,170,217,171,145,42,233,100,97,15,74,197,76,192,160,139,151,27,148,235,71,131,142,92,13,236,145,165,251,149,155,149,73,232,145,247,152,141,191,90,170,5,170,126,247,37,45,62,59,76,72,23,150,202,182,80,168,255,123,204,71,151,56,166,197,65,31,46,23,165,250,153,246,242,140,12,32,244,100,117,67,45,187,174,211,80,214,104,97,70,22,94,7,19
<?php
/**
* Extract an interface definition from an existing class.
*
* Found while cleaning up old files -- I am only assuming it works. :)
*/
$class = new ReflectionClass($className);
foreach ($class->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_PUBLIC) as $method) {
@scintill
scintill / README.md
Created June 5, 2017 00:27
redirect syslog to stderr

LD_PRELOAD this as a library to output a binary's output from syslog() on stderr as well as any syslog daemon that's listening (useful for Docker, if you want all log output to be collected by Docker's standard output handling.) Beware though, if the program changes its stderr file descriptor (closes it, points it at /dev/null, pipes it out to a socket), this can have surprising results. For example, when I tried this with cyrus-imapd, I was getting syslog output sent to remote clients because stderr and stdout were remapped that way (not maintaing the original fd that Docker set up.)

Example Docker implementation

COPY syslog2stderr.c /build
RUN gcc -fPIC -shared /build/syslog2stderr.c -o /usr/local/lib/syslog2stderr.so
RUN echo /usr/local/lib/syslog2stderr.so &gt;&gt; /etc/ld.so.preload
@scintill
scintill / Dockerfile
Created August 30, 2017 08:58
docker-uqmi
FROM trinitronx/build-tools:alpine-3.6
RUN apk add --no-cache cmake
RUN git clone https://git.openwrt.org/project/uqmi.git
RUN git clone https://git.openwrt.org/project/libubox.git
RUN git clone https://github.com/json-c/json-c.git
WORKDIR /json-c
RUN ./autogen.sh && ./configure && make install
@scintill
scintill / solve.pl
Last active July 10, 2018 10:08
Puzzle solver in Prolog
% match head and tail, left/right, top/bottom
partsMatch(top(Type), bottom(Type)).
partsMatch(bottom(Type), top(Type)).
cardsMatch(card(_, Right, _, _), right, card(_, _, _, Left)) :- partsMatch(Right, Left).
cardsMatch(card(_, _, Bottom, _), down, card(Top, _, _, _)) :- partsMatch(Bottom, Top).
% define card rotation
rotate(card(A, B, C, D), 0, R) :- R = card(A, B, C, D).
rotate(card(A, B, C, D), 1, R) :- R = card(B, C, D, A).
@scintill
scintill / Dockerfile
Created May 31, 2019 23:07
wine dockerfile
FROM scottyhardy/docker-wine@sha256:ca0481f5c953cbb9c40ce6e91c01f9bf06ea7de73094663f13931778f1060a58
# use win32
ARG WINEARCH=win32
# I don't want HOME as a volume, but baked in to the image
RUN usermod --home /home/wineuser2 wineuser && cp -pr /etc/skel ~wineuser && chown wineuser:wineuser ~wineuser
WORKDIR /home/wineuser2
# install winetricks prereqs

Tested with HP LaserJet 1018.

  1. Set up Raspbian buster as usual. https://raspberrypi.stackexchange.com/a/57023 helped with headless setup of Wifi and SSH.
  2. Change /etc/hostname and /etc/hosts to set hostname.
  3. sudo apt-get install cups hplip
  4. sudo hp-setup -i
  5. sudo cupsctl --share-printers
  6. avahi-browse -art on desktop should show your printer.

You can forward port 631 over ssh to log in to the CUPS web interface. You may have to set a root password to do certain operations over the browser interface.