Compare commits

..

2 commits

Author SHA1 Message Date
b3252e7f1e updated fortunes 2024-03-14 17:20:25 -04:00
8493cab2b4 normalized base-fortune line lengths 2024-03-12 22:30:24 -04:00
8 changed files with 13 additions and 198 deletions

View file

@ -1,7 +1,7 @@
So everything is just a pile of barely working code added\non top of previously written barely working code. It keeps\ngrowing in size and complexity, diminishing any chance for\na change.\n\nTo have a healthy ecosystem you need to go back and revisit.\nYou need to occasionally throw stuff away and replace it with\nbetter stuff.\n\n - Nikita Tonsky, 2018-09-17\n blog post on tonsky.me\n ("Software Disenchantment")
So everything is just a pile of barely working code added on top\nof previously written barely working code. It keeps growing in\nsize and complexity, diminishing any chance for a change.\n\nTo have a healthy ecosystem you need to go back and revisit. You\nneed to occasionally throw stuff away and replace it with better\nstuff.\n\n - Nikita Tonsky, 2018-09-17\n blog post on tonsky.me\n ("Software Disenchantment")
There's nothing more permanent than a temporary solution.
Unix is mature OS, windows is still in diapers and they smell badly\n\n - Rafael Skodlar <raffi@linwin.com>
Hello Jeffrey,\n\nUnfortunately due to company policy, we are unable to offer\npositions to people with the name Jeffrey since it will not work\nwith our database schema\n\n - @yephph, 2020-04-12 on Twitter
Hello Jeffrey,\n\nUnfortunately due to company policy, we are unable to offer\npositions to people with the name Jeffrey since it will not work\nwith our database schema\n\n - @yephph@twitter.com, 2020-04-12
He's making a table\nSorting it twice\nHe's gonna `SELECT NAMES FROM CHILDREN WHERE BEHAVIOR = 'nice';`\nSanta Claus just learned SQL
I don't know why, but first C programs tend to look a lot worse\nthan first programs in any other language (maybe except for fortran,\nbut then I suspect all fortran programs look like 'firsts')\n\n - Olaf Kirch
I'd crawl over an acre of 'Visual This++' and 'Integrated\nDevelopment That' to get to gcc, Emacs, and gdb. Thank you.\n\n - Vance Petree, Virginia Power
@ -10,3 +10,4 @@ With a GUI, that "undo" button is always an option. But in real\nlife, you can't
How do I type "for i in *.dvi do xdvi $i done" in a GUI?\n\n - Discussion in comp.os.linux.misc
"If the code and the comments disagree, then both are probably wrong."\n\n - Norm Schryer
Your karma check for today:\nThere once was a user that whined\nHis existing OS was so blind\nHe'd do better to pirate\nAn OS that ran great\nBut found that his hardware declined.\nPlease don't steal Mac OS\nReally, that's way uncool.\n(C) Apple Computer, Inc.
In 10 years we went from "Rust will never replace C and C++" to\n"New C/C++ should not be written anymore, and you should use\nRust." Good job.\n\n - dpc_pw on lobste.rs

View file

@ -1,9 +1,9 @@
......... Escape the 'Gates' of Hell\n `:::' ....... ......\n ::: * `::. ::'\n ::: .:: .:.::. .:: .:: `::. :'\n ::: :: :: :: :: :: :::.\n ::: .::. .:: ::. `::::. .:' ::.\n...:::.....................::' .::::..\n -- William E. Roadcap
Win95 is not a virus; a virus does something.
In most countries selling harmful things like drugs is punishable.\nThen how come people can sell Microsoft software and go unpunished?\n\n - Hasse Skrifvars <hasku@rost.abo.fi>
In most countries selling harmful things like drugs is\npunishable. Then how come people can sell Microsoft software\nand go unpunished?\n\n - Hasse Skrifvars <hasku@rost.abo.fi>
Once upon a time there was a DOS user who saw Unix, and saw that\nit was good. After typing cp on his DOS machine at home, he\ndownloaded GNU's unix tools ported to DOS and installed them.\nHe rm'd, cp'd, and mv'd happily for many days, and upon finding\nelvis, he vi'd and was happy. After a long day at work (on a Unix\nbox) he came home, started editing a file, and couldn't figure\nout why he couldn't suspend vi (w/ ctrl-z) to do a compile.\n\n - Erik Troan <ewt@tipper.oit.unc.edu>
When you say "I wrote a program that crashed Windows," people\njust stare at you blankly and say "Hey, I got those with the\nsystem, *for free*."\n\n - Linus Torvalds
By golly, I'm beginning to think Linux really *is* the best thing\nsince sliced bread.\n\n - Vance Petree, Virginia Power
By golly, I'm beginning to think Linux really *is* the best\nthing since sliced bread.\n\n - Vance Petree, Virginia Power
/*\n * [...] Note that 120 sec is defined in the protocol as the\n * maximum possible RTT. I guess we'll have to use something\n * other than TCP to talk to the University of Mars.\n * PAWS allows us longer timeouts and large windows, so once\n * implemented ftp to mars will work nicely\n */\n\n - /usr/src/linux/net/inet/tcp.c\n concerning round trip times
MSDOS didn't get as bad as it is overnight--it took over ten\nyears of careful development\n\n - <dmeggins@aix1.uottawa.ca>
"No manual is ever necessary."\nMay I politely interject here: BULLSHIT. That's the biggest\nApple lie of all!\n\n - Discussion in comp.os.linux.misc

View file

@ -1,4 +1,4 @@
PLYADES I'll take care of you.\nORESTES It's rotten work.\nPLYADES Not to me. Not if it's you.\n\n - Anne Carson, Euripides
me: good night darling. I'm so happy to be able to fall asleep\nnext to you\n\nmy gf: *already rotating like a kebab to ensure maximum duvet\ntheft*\n\n - @davideastUK, Twitter.
me: good night darling. I'm so happy to be able to fall asleep\nnext to you\n\nmy gf: *already rotating like a kebab to ensure maximum duvet\ntheft*\n\n - @davideastUK@twitter.com
<sawasawako>\nidc anymore i think we should be a burden to each other\n\nand yes this includes a certain degree of tolerance for emotional\nburden, all else being equal. my love for you, and loyalty to\nyou, is not dependent on how easy you make it for me to love you.\ni don't value you for how little trouble you cause me. i want to\nlearn how to take you for who you are, instead of who i want you\nto be or who i think you should be\n\n<starrbear>\nThe measure of any relationship should not be whether loving\nsomeone is work, but whether it is work that you are glad to do.\n\n - tumblr exchange
I want to eat the sunbeam flaring in your lovely body,\nthe sovereign nose of your arrogant face,\nI want to eat the fleeting shade of your lashes,\n - Pablo Neruda

View file

@ -1,3 +1,3 @@
When I kill God I will find the spigot from which he meters out\ngrace and smash it permanently open\n\n - @Iinux@twitter.com, 2022-06-12
> TikTok is out of the question because, "I have a reprehensible\n> visage that does not allow me to use any video-based apps," he\n> said.\n\n - Dril, 2022-11-23\n interview with the Washington Post
An ant crosses your carpet. A spider weaves a pattern older than mammals beneath your stairs. Just nod, breathe, and think, "Good. It's all still here. The forest, the mountains, the desert. At home in my home." The sterile white box is the stranger. Not the ant. Not the spider.\n\n - @CryptoNature@twitter.com, 2018-27-08
An ant crosses your carpet. A spider weaves a pattern older than\nmammals beneath your stairs. Just nod, breathe, and think,\n"Good. It's all still here. The forest, the mountains, the\ndesert. At home in my home." The sterile white box is the\nstranger. Not the ant. Not the spider.\n\n - @CryptoNature@twitter.com, 2018-27-08

View file

@ -1,42 +0,0 @@
.Dd $Mdocdate$
.Dt FORTUNE-CS 6
.Os
.Sh NAME
.Nm fortune-cs
.Nd a no-nonsense fortune cookie program
.Sh SYNOPSIS
.Nm fortune-cs
.Op Ar source
.Nm fortune-cs
.Op Fl hlv
.Nm fortune-cs
.Fl m Ar file1 Ar file2
.Sh DESCRIPTION
.Nm fortune-cs
is a sensible, straightforward replacement for
.Xr fortune 6 . Its options are as follows:
.Bl -tag -width Ds
.It Fl h , Fl -help
Shows a brief help text.
.It Fl l , Fl -list
Lists files in the fortune directory
.Po Ev FORTUNE_CS_DIR
.It Fl m , Fl -merge Ar files...
Prints all distinct lines from the provided files to standard output.
.It Fl v , Fl -version
Shows version information.
.Sh ENVIRONMENT
.Bl -tag -width Ds
.It Ev FORTUNE_CS_DIR
Any existing directory. This sets the base directory to pull fortunes from. Default:
.Pa /usr/share/fortune-cs
.Sh FILES
.Bl -tag -width Ds
.It Pa /usr/share/fortune-cs/
The default fortune directory, containing text files with one line per fortune.
.El
.Sh SEE ALSO
.Xr fortune 6
.Sh AUTHORS
.An -nosplit
.An Valerie Wolfe Aq Mt sleeplessval@gmail.com

View file

@ -1,40 +0,0 @@
using System;
using System.IO;
public static class Globals {
public const string VERSION = "0.1.0";
public const string DEFAULT_PATH = "/usr/share/fortune-cs/";
}
public static class Usage {
public static void HelpText() {
VersionText();
Console.WriteLine(@"Valerie Wolfe <sleeplessval@gmail.com>
Shows quotes from a set of files.
usage: fortune-cs [flags] [source]
args:
[source] Show a quote from a specific file
flags:
-h, --help Shows this help text
-v, --version Shows version information
-l, --list List files in the fortune directory
-m, --merge [files...] Output all distinct lines from a set of files");
}
public static void ListText(string[] files) {
foreach(var file in files) {
var fileName = Path.GetFileNameWithoutExtension(file);
Console.WriteLine(fileName);
}
}
public static void VersionText() {
Console.WriteLine("fortune-cs v" + Globals.VERSION);
}
}

View file

@ -2,75 +2,25 @@ using System;
using System.IO;
using System.Security.Cryptography;
// handle help flag
if(Utilities.HasFlags(args, "-h", "--help")) {
Usage.HelpText();
return 0;
}
// handle version flag
if(Utilities.HasFlags(args, "-v", "--version")) {
Usage.VersionText();
return 0;
}
// collect nonflag args for merge or file selection
var arguments = Utilities.CollectArgs(args);
// handle merge flag
if(Utilities.HasFlags(args, "-m", "--merge")) {
Utilities.Merge(arguments);
return 0;
}
// get resource path from var or default
string resourcePath = Environment.GetEnvironmentVariable("FORTUNE_CS_DIR");
if(resourcePath == "" || !Directory.Exists(resourcePath))
resourcePath = Globals.DEFAULT_PATH;
// pull file arg if provided
string file = null;
if(arguments.Count == 1) {
file = arguments[0];
// if the file doens't exist, see if it's in `resourcePath`
if(!File.Exists(file)) {
if(!file.EndsWith(".txt"))
file = file + ".txt";
file = resourcePath + file;
if(!File.Exists(file)) {
// don't try to read a file that doesn't exist
Console.WriteLine($"fortune-cs: no file '{file}' found.");
return 2;
}
}
}
// make sure fortune directory exists
var resourcePath = "/usr/share/fortune-cs/";
if(!Directory.Exists(resourcePath)) {
Console.WriteLine($"fortune-cs: directory '${resourcePath}' does not exist");
Console.WriteLine("fortune-cs: directory '/usr/share/fortune-cs/' does not exist");
return 1;
}
// pull file list
var files = Directory.GetFiles(resourcePath, "*.txt");
// handle list flag
if(Utilities.HasFlags(args, "-l", "--list")) {
Usage.ListText(files);
return 0;
}
// choose file if not provided
if(file == null)
file = files[RandomNumberGenerator.GetInt32(files.Length)];
// read the file and choose a line
// choose a file and line
var file = files[RandomNumberGenerator.GetInt32(files.Length)];
var lines = File.ReadAllLines(file);
var line = lines[RandomNumberGenerator.GetInt32(lines.Length)];
// process line breaks
// process escape codes
line = line.Replace("\\n", "\n");
// write the fortune
// write
Console.WriteLine(line);
return 0;

View file

@ -1,54 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
public static class Utilities {
/// <summary>
/// returns a `List` of all non-flag arguments
/// </summary>
public static List<string> CollectArgs(string[] args) {
var output = new List<string>();
foreach(string arg in args)
if(!arg.StartsWith("-"))
output.Add(arg);
return output;
}
/// <summary>
/// checks if a given flag is set in `args`
/// </summary>
public static bool HasFlags(string[] args, params string[] flags) {
foreach(string flag in flags)
// using `Array.IndexOf` since including Linq for `array.Contains` increases binary size
if(Array.IndexOf(args, flag) != -1)
return true;
return false;
}
/// <summary>
/// outputs all unique lines from all files in `files` to stdout
/// </summary>
public static void Merge(List<string> files) {
// hashset to prevent duplicates
var members = new HashSet<string>();
// iterate over all paths given
foreach(var file in files) {
// skip nonexistent files gracefully
if(!File.Exists(file))
continue;
// iterate over lines
var lines = File.ReadAllLines(file);
foreach(var line in lines) {
// prevent duplicates
if(members.Contains(line))
continue;
members.Add(line);
// emit to stdout
Console.WriteLine(line);
}
}
}
}