Skip to content

Instantly share code, notes, and snippets.

View apotheon's full-sized avatar
🐙
What are you doing, Dave?

apotheon apotheon

🐙
What are you doing, Dave?
  • the 25th century
View GitHub Profile
@apotheon
apotheon / fiction_no_no.txt
Created February 4, 2018 17:15
Fiction Writer No-Nos
# Fiction Writer No-Nos
What are things you shouldn't do in your stories if you want to be a big-time
fiction writer that makes a living at it? I mean things that won't make your
story bad, but might hurt your readership and scare off publishers. For
instance:
* Don't be too technically accurate. "Hacking" should be exciting, not
realistic. Protecting your horse from weather is boring.
@apotheon
apotheon / LICENSE.txt
Created March 1, 2017 21:30
Which license is this?
Copyright (c) <year(s)> <Copyright Holder>
All rights reserved.
The following terms apply to all files associated with this software and its
documentation, with the exception of individual files that explicitly state
their own licensing terms.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@apotheon
apotheon / gist:38c431e9d6e9eec8655291a214592b03
Created February 18, 2017 08:44
final form of a comment with commit message "prohibit accessing lore beyond mortal kenning"
/*
* Unlike the horizontal histogram version, I stuck with what the book has
* already covered this time, and used arrays as K&R seemed to intend. I chose
* to explicitly limit the number of words measured and the maximum length of
* words for display within a reasonably small console, which might result in
* truncated results on both the number of words axis and the word length axis
* for moderately sized files and for extremely long words (e.g. lengthier
* German compound words or gratuitously long words such as those longer than
* "antihyperpolysyllabicsesquipedalianistic", because this program should not
* print out the answer to the question of life, the universe, and everything,
#include <stdio.h>
int main() {
int i = 0;
int intarray[10] = {1, 2, 7, 4, 3, 7, 3, 9, 5, 0};
char chararray[10] = {'h', 'e', 'l', 'l', 'o', ' ', 'y', 'o', 'u', '\0'};
while (i < 10) {
printf("%d\n", intarray[i]);
@apotheon
apotheon / quicksort_erlang.erl
Created September 26, 2014 17:23
Erlang Quicksort
quicksort( [] ) -> [].
quicksort( [FirstElement | RestOfList] ) ->
SmallerThan = fun(X) -> X < FirstElement end,
{ Smaller, LargerOrEq } = lists:partition(SmallerThan, RestOfList),
quicksort(Smaller) ++ [FirstElement] ++ quicksort(Larger).
@apotheon
apotheon / quicksort_elixr.exs
Created September 26, 2014 17:22
Elixr Quicksort
defmodule Quicksort do
def qsort([]) do
[]
end
def qsort([pivot | tail]) do
qsort( lc x inlist tail, x < pivot, do: x ) ++ [pivot] ++ qsort( lc x inlist tail,x >= pivot, do: x )
end
end
@apotheon
apotheon / FUGPL.txt
Last active August 29, 2015 14:03 — forked from schacon/FUGPL.txt
punctuation- and grammar-corrected, slightly clarified FUGPL ("anti-gpl license")
The FUGPL License
===================
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software with the restriction that no part of
it may be included in software projects that are solely distributed under
strong copyleft restricted licenses. This license is *NOT* GPL compatible.
There otherwise exist no restrictions on using this software, including
@apotheon
apotheon / 0 - UNIX Fifth Edition
Created June 1, 2014 19:58
UNIX V5, OpenBSD, Plan 9, FreeBSD, and GNU coreutils implementations of echo.c
main(argc, argv)
int argc;
char *argv[];
{
int i;
argc--;
for(i=1; i<=argc; i++)
printf("%s%c", argv[i], i==argc? '\n': ' ');
}
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
void listdir(const char *name, int level)
{
DIR *dir;
struct dirent *entry;
@apotheon
apotheon / gist:719618
Created November 29, 2010 05:38
irb vs. rbx
~> irb
irb(main):001:0> foo = {:one => [0,1], :two => 2}
=> {:one=>[0, 1], :two=>2}
irb(main):002:0> File.open('tempfile.txt', 'w') {|f| f.write foo.inspect }
=> 23
irb(main):003:0> bar = Hash.new
=> {}
irb(main):004:0> File.open('tempfile.txt', 'r') {|f| bar = eval(f.read) }
=> {:one=>[0, 1], :two=>2}
irb(main):005:0> p bar