source: project/demonstrations/awful/fortune/create-database.scm @ 21138

Last change on this file since 21138 was 21138, checked in by Mario Domenech Goulart, 11 years ago

demonstrations/awful/fortune: bug fix and improved `random-fortune' (excellent tips from Peter Bex)

  • Property svn:executable set to *
File size: 6.4 KB
Line 
1#!/usr/bin/csi -s
2
3(use sql-de-lite posix)
4
5(define fortunes
6  '(("Walking on water and developing software from a specification are easy if both are frozen."
7     "Edward V Berard")
8
9    ("Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
10     "Brian Kernighan")
11
12    ("There are only two kinds of languages: the ones people complain about and the ones nobody uses."
13     "Bjarne Stroustrup")
14
15    ("I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone"
16     "Bjarne Stroustrup")
17
18    ("In order to understand recursion, one must first understand recursion.")
19
20    ("If debugging is the process of removing software bugs, then programming must be the process of putting them in."
21     "Edsger Dijkstra")
22
23    ("Computer Science is no more about computers than astronomy is about telescopes."
24     "Edsger Dijkstra")
25
26    ("Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away."
27     "Antoine de Saint Exupéry")
28
29    ("In theory, theory and practice are the same. In practice, they're not.")
30
31    ("Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves."
32     "Alan Kay")
33
34    ("There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult."
35     "C.A.R. Hoare.")
36
37    ("Beware of bugs in the above code; I have only proved it correct, not tried it."
38     "Donald Knuth")
39
40    ("Programs must be written for people to read, and only incidentally for machines to execute."
41     "SICP")
42
43    ("Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
44     "Martin Fowler")
45
46    ("The greatest performance improvement of all is when a system goes from not-working to working."
47     "John Ousterhout")
48
49    ("Unix is very simple, but it takes a genius to understand the simplicity."
50     "Dennis Ritchie")
51
52    ("Controlling complexity is the essence of computer programming."
53     "Brian Kernigan")
54
55    ("The function of good software is to make the complex appear to be simple."
56     "Grady Booch")
57
58    ("That's the thing about people who think they hate computers.  What they really hate is lousy programmers."     "Larry Niven")
59
60    ("First learn computer science and all the theory.  Next develop a programming style.  Then forget all that and just hack."
61    "George Carrette")
62
63  ("To iterate is human, to recurse divine."
64   "L. Peter Deutsch")
65
66  ("The best thing about a boolean is even if you are wrong, you are only off by a bit.")
67
68  ("Optimism is an occupational hazard of programming; feedback is the treatment."
69   "Kent Beck")
70
71  ("You can't have great software without a great team, and most software teams behave like dysfunctional families."
72   "Jim McCarthy")
73
74  ("There are two ways to write error-free programs; only the third one works."
75   "Alan J. Perlis")
76
77  ("No matter how slick the demo is in rehearsal, when you do it in front of a live audience, the probability of a flawless presentation is inversely proportional to the number of people watching, raised to the power of the amount of money involved."
78   "Mark Gibbs")
79
80  ("It used to be the program's purpose to instruct our computers; it became the computer's purpose to execute our programs."
81   "E. W. Dijkstra")
82
83  ("There is no programming language – no matter how structured – that will prevent programmers from making bad programs."
84   "Larry Flon")
85
86  ("The effective exploitation of his powers of abstraction must be regarded as one of the most vital activities of a competent programmer."
87   "Edsger W. Dijkstra")
88
89  ("Premature optimization is the root of all evil."
90   "Donald E. Knuth")
91
92  ("The most important thing in a programming language is the name. A language will not succeed without a good name. I have recently invented a very good name, and now I am looking for a suitable language."
93   "Donald E. Knuth")
94
95  ("Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25")
96
97  ("Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence."
98   "Edsger W. Dijkstra")
99
100  ("If you're willing to restrict the flexibility of your approach, you can almost always do something better."
101   "John Carmack")
102
103  ("Simplicity is prerequisite for reliability."
104   "Edsger W. Dijkstra")
105
106  ("Are you quite sure that all those bells and whistles, all those wonderful facilities of your so called powerful programming languages, belong to the solution set rather than the problem set?"
107   "Edsger W. Dijkstra")
108
109  ("Simplicity is the ultimate sophistication."
110   "Leonardo da Vinci")
111
112  ("Increasingly, people seem to misinterpret complexity as sophistication, which is baffling -- the incomprehensible should cause suspicion rather than admiration. Possibly this trend results from a mistaken belief that using a somewhat mysterious device confers an aura of power on the user."
113   "Niklaus Wirth")
114
115  ("Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.")
116
117  ("The unavoidable price of reliability is simplicity."
118   "C.A.R. Hoare")
119
120  ("The ability to simplify means to eliminate the unnecessary so that the necessary may speak."
121   "Hans Hoffmann")
122
123  ("Simplicity is hard to build, easy to use, and hard to charge for. Complexity is easy to build, hard to use, and easy to charge for."
124   "Chris Sacca")))
125
126(delete-file* "fortunes.db")
127
128(let ((db (open-database "fortunes.db")))
129  (exec (sql db "create table fortunes(sentence text, author text)"))
130  (for-each (lambda (fortune)
131              (let* ((sentence (car fortune))
132                     (author (cdr fortune))
133                     (statement
134                      (string-append
135                       "insert into fortunes (sentence, author) values (?,?)")))
136                (exec (sql db statement)
137                      sentence
138                      (if (null? author) "" (car author)))))
139            fortunes)
140  (close-database db))
Note: See TracBrowser for help on using the repository browser.