Skip to content

Instantly share code, notes, and snippets.

View scsibug's full-sized avatar

Greg Heartsfield scsibug

View GitHub Profile
@scsibug
scsibug / style.css
Created November 17, 2022 17:27
Org Mode CSS
a[href*="//"]:not([href*="notes.wellorder.net"]):after {
content: "";
width: 11px;
height: 11px;
margin-left: 4px;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5z'/%3E%3Cpath fill-rule='evenodd' d='M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0v-5z'/%3E%3C/svg%3E");
background-position: center;
background-repeat: no-repeat;
background-size: contain;
display: inline-block;
@scsibug
scsibug / book-giveaway-2020.md
Last active December 1, 2020 17:38
2020 Book Giveaway

Fiction

  • Doctor Zhivago, by Pasternak.
  • East of Eden, by Steinbeck. (Jordan)
  • All the Light We Cannot See, by Doerr.
  • Peace, by Wolfe. (Jordan)
  • Submergence, by Ledgard.
  • The Soul of a New Machine, by Kidder.
  • A Year with Rumi: Daily Readings, by Barks.
@scsibug
scsibug / svc_account_creation.txt
Last active June 8, 2020 02:35
Linux Service Account Creation
useradd username \
--system \
--shell /bin/nologin \
--comment "Description of account" \
--expiredate 1 # block all authentication \
--create-home # or --no-create-home \
--home /home/dir
# Or, short version (w/ home directory)
useradd username -r -s /bin/nologin -c "description" -e 1 -m -d /home/dir
@scsibug
scsibug / bare_repo_setup.txt
Created March 12, 2017 20:26
Setting up a bare repo and connecting a remote
# On shared server
git init --bare <directory>
# On client
# For a new repository
git clone ssh://user@host/path/to/dir
# For an existing repository
public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException {
RrdGraphDef graphDef = new RrdGraphDef();
configureImageParameters(graphDef, req);
configureContents(graphDef, req);
try {
RrdGraph graph = new RrdGraph(graphDef);
BufferedImage bi = new BufferedImage(graph.getRrdGraphInfo().getWidth(), graph.getRrdGraphInfo().getHeight(), BufferedImage.TYPE_INT_RGB);
# Create a bare repository
mkdir /Users/me/repos/shared.bare.git
cd /Users/me/repos/shared.bare.git
git init --bare
# Start the git daemon
git daemon --reuseaddr --enable=receive-pack --enable=upload-archive --verbose --export-all --base-path=/Users/me/repos
# On the remote machine, push master over
git push git://192.168.1.100/shared.bare.git master
@scsibug
scsibug / stones.hs
Created February 24, 2012 03:53
40lb stone problem
import Data.List
-- Return all combinations of 4 weights that can be used to weigh objects from 1 to 40 pounds.
weights = [(a,b,c,d) | a <- r, b <- r, c <- r, d <- r, -- generate 4 weights
(a+b+c+d) == 40, a <= b, b <= c, c <= d, -- sum exactly 40, weights in order
(canMeasure [a,b,c,d]) == [1..40]] -- can measure from 1 to 40 lbs
where r = [1..37] -- each stone must be at least 1 pound, so the max weight of each is 37.
-- Determine what a list of stones with given weights can themselves be used to weigh.
canMeasure s = sort . nub . filter (>0) $ foldl' (\a b -> concatMap (\c -> [c-b,c,c+b]) a) [0] s
@scsibug
scsibug / core-tests.clj
Created February 16, 2012 00:53
Clojure 7-lang
(ns seven-lang-clojure.test.core
(:require [seven-lang-clojure.core])
(:use [seven-lang-clojure.core])
(:use [clojure.test])
(:import [seven_lang_clojure.core SimpleBOM Account]))
(deftest big-test
(is (not (big "blah" 4)))
(is (big "blah" 3))
(is (not (big "" 0)))
@scsibug
scsibug / error_printer.erl
Created February 9, 2012 01:28
Error Printer
-module(error_printer).
-export([error_check/1]).
% Write a function that uses matching to selectively print "success"
% or "error: message" given input of the form {error, Message} or
% success.
error_check({error, M}) ->
io:format("~p~n",[M]);
error_check(success) ->
@scsibug
scsibug / count_ten.erl
Created February 9, 2012 01:22
Count to ten
-module(count_ten).
-export([count_ten/0]).
% Write a unction that uses recursion to count to ten.
count_ten() -> cnt(0).
cnt(X) ->
io:format("~p~n",[X]),
if (X < 10) -> cnt(X+1);