OpenLLM-France/wikimedia huggingface dataset:
# Smalltalk Programming/Syntax

Smalltalk has one of the simpler syntaxes of any computer language. There are 3 different types of method call - unary, binary, and n-way keyword. The rules for precedence scan from left to right for each of those 3 flavors of method calling. Precedence can be overridden with parenthesis, as usual.
1. Unary method. Can be as simple as display redrawEverything. ; the object display looks up its method redrawEverything to do an unqualified redraw, and does it. Unary methods and the object they act on are both alphanumeric words that don't end in a colon. Whenever you see multiple such words in a row, the one on the left is the object, the rest are a gauntlet of method calls.
2. Binary method. In myNumber + 5., the object myNumber is told to look up the method +, and run it with 5 as the argument. Here, the argument is being discarded, the := assignment will come later. Binary method names are 1 or 2 special characters; they only exist for the usual set of suspects in math and logic equations. There is no special precedence for math operators, you must either state them in the order wanted, or use parenthesis.
3. Keyword method. This is where smalltalk diverges from most other programming languages. In display drawFromX:1 fromY:1 toX:50 toY:100., display is being called with one method and 4 arguments. The method's name is drawFromX:fromY:toX:toY:, and the arguments are positionally passed into the method. If you want to call another keyword method without the two blending together, you can use the comma operator, parenthesis, or just carry the result to a new statement.
A statement optionally starts with an assignment, has at least an opening object, and sends at least one method to that object. The statement ends with a period.
A [block] is a bracketed set of statements that are bundled together as a single object, which could be triggered by flow-control style methods. In 4 < 5 ifTrue: [ Transcript print: '4 is less than 5!' ]. , 4<5 evaluates into the boolean object true, who always executes a block passed through the ifTrue: method.
# Smalltalk Programming/Preliminaries

Smalltalk is a fully object oriented language.
The most important and consistent ideas in the language are that:
* there are objects
* send messages to objects
* get back an object as the result.
So 2 + 3 is considered as "sending a message + to object 2, with argument 3 and the result of the message is another object 5"
# Snake II

Snake is one of the more popular games on older Nokia cell phones.

## Introduction

The goal is to make as many points as possible by making the snake eat stuff that shows up. The more you eat, the longer the snake will grow. If the snake collides with itself, the game ends.

### Controls

You control the snake with the number buttons: 2: snake goes up 4: snake goes left 6: snake goes right 8: snake goes down *: snake turns left #: snake turns right To pause, press C or action button.
The snake can not go backwards.

## Speed

You can select the speed of the snake. In the game menu, select "Level" and select a level. The higher the level, the faster the snake goes. There are nine levels. As the levels increase, more points are rewarded for eating things.

## Mazes

There are five mazes you can choose between, plus the "no maze" option. If you select "no maze," there are no walls. When the snake goes out one end, it comes back through the other end. Maze 1 is just a wall around the course. The mazes get harder and more complicated the higher the maze's number is.

## Other

After the snake has eaten five things, a bonus thing will appear for a short time. It gives higher scores the faster you eat them. The snake does not grow when you eat them.
# Smalltalk Programming/Variables

Smalltalk uses variables in the usual Object Oriented way, you move around pointers to data more often than the actual data. A variable is a pointer to an object, through which you could ask that object to report its data, change its data, or perform an action. Care must be taken when altering an object, it may affect other variables pointing to that object elsewhere.
There are different degrees of variable at the system, object, and method levels.
The SystemDictionary Smalltalk holds onto the globally accessible variables. These can be easily called upon anywhere, common singleton objects like transcript are named here.
In their class definition, objects have a given set of variables defined. Any object instance can look at its own variables within a method (subclass methods too). If a variable needs to be altered externally, the object may have methods to get the variable in and out.
Smalltalk variable names are declared in the beginning of a method or block separated by the pipe "|" symbol. Example: | t1 t2 t3 | declares three variables named t1, t2, and t3.
To assign a value to a variable, use this format: variableName := value or this format: variableName _ value.
Arrays also can be variables. Arrays can hold any type of value. An array if defined like this: #('Put array items here'). Example: #('string' $C 6) Makes an array with three values that contain a the string "string", the character 'C', and the number 6.
# Smalltalk the fun way

The title of this book could be interpreted in two ways:
* It will teach you Smalltalk by programming games, and having fun at it
* We Smalltalk lovers consider this language to be the fun way :-)

## Book Contents

* Smalltalk crash-course
* Phraro crash-course
Basic games:
* Number-guessing Game
TiledMorph-based games:
* Introduction to TiledMorph
* Sliding-puzzle Game
* Memory
* Decrypt the message
* Lynx (lince)
* Tic-Tac-Toe
* Battleship
* Hangman
* Minesweeper
* Who-is-who
* Tetris
* Sokoban
* Maze-game
* Pac-Man
Game aspects:
* Graphics
* Animation
* Sound
* Logic
** Game-Loop
** Game status
** Game Data
* Multiplayer games
* Releasing
Non-TileMorph-based games:
* Spot the difference
* Hidden objects
* Quiz-Game
** Multiple choice
** Audio
** Re-ordering
** Matching
* Adventure game

## Notes
### Required Knowledge

We assume that you:
* have some programming knowledge
* are familiarized with Smalltalk concepts
* know how to download and open a Pharo environment
* can find your way around in a Pharo environment
If you lack this prior knowledge, we advise that you read and learn about these topics here:
http://pharobyexample.org/

### Environment used

The code in this book has been written in Pharo 1.4:
http://www.pharo-project.org/
It should also work in Squeak 4.3 with little or no modifications.
# Snakes of Europe

Snakes Of Europe, based on the book by G.A. Boulenger
The Snakes of Europe, 1913
Data obtained from www.archive.org
and wikipedia.org
Snakes of Europe/Preface
Snakes of Europe/Index
Snakes of Europe/Definition and Classification
Snakes of Europe/Habits
Snakes of Europe/Species
# Snakes of Europe/Index

INTRODUCTION
Definition and Classification
II. External Characters β€” Integument - - 8
III. Coloration - - - - 29
IV. Skeleton - - - - - - 40
V. Dentition - - - - - -53
VI. Poison Apparatus β€” Different Kinds of
Poisons - - - - - 62
VII. Nervous System β€” Sense Organs - - 73
VIII. Viscera - - - - - -77
IX. Organs of Reproduction ; Pairing; Oviposi-
tion ; Development - - - 82
Habits
XI. Parasites - - - - - - 107
XII. Distribution - - - - - 118
XIII. Snakes in Relation to Man - - - 133

## THE SNAKES OF EUROPE
### Family: TYPHLOPIDAE
#### Genus TYPHLOPS, Rafinesque, 1815

1. Typhlops vermicularis, Merrem, 1820, The European Blind-Snake or Worm Snake

### Family: Boidae Gray 1825
#### Genus: Eryx, Daudin 1803

2. Eryx jaculus, Linnaeus 1758, The Javelin Sand-Boa

### Family: COLUBRIDAE
#### Genus Natrix, Laurenti

3. Natrix natrix Linnaeus, The Grass-Snake, or Ring Snake
4. Natrix tesselata, Laurenti β€” The Tessellated Water-Snake - 160
5. Natrix maura, Latreille β€” The Viperine Water-Snake .... 165
Genus ZAMENIS, Wagler - - - - 170
6. Zamenis gemonensis, Laurenti β€” The European Whip-Snake - - - - - 170
7. Zamenis dahlii, Fitzinger β€” Dahl's Whip-Snake - 177
8. Zamenis hippocrepis, Linnaeus β€” The Horseshoe Whip-Snake \- - - - 179
Genus COLUBER, Linn^us - - - - 181
9. Coluber quatuorlineatus, Lacepedeβ€” Aldrovandi's Snake - 182
10. Coluber dione, Pallas β€” The Dione Snake - 185
11. Coluber longissimus, Laurenti β€” The ^Esculapian Snake - - - 187
12. Coluber leopardinus, Bonaparte β€” The Leopard Snake ------ 191
13. Coluber scalaris, Schinz β€” The Ladder Snake - 194
Genus CORONELLA, Laurenti - - - 196
14. Coronella austriaca, Laurenti β€” The Smooth Snake - - - - - - 197
15. Coronella girondica, Daudin β€” The Southern Smooth Snake - 202
Genus CONTIA, Baird and Girard - - - 205
16. Contia modesta, Martinβ€” The Dwarf Snake - 205
Genus CGELOPELTIS, Wagler - - - 207
17. Ccelopeltis monspessulana, Hermann β€” The Montpellier Snake ----- 208
Genus MACROPROTODON, Guichenot - - 212
18. MACROPROTODON CUCULLATUS, I. Geoffroy β€” The False Smooth Snake - - - - 213
Genus TARBOPHIS, Fleischmann - - - 216
19. Tarbophis fallax, Fleischmann β€” The Cat-Snake 217 20. Tarbophis iberus, Eichwald β€” The Caucasian Cat-Snake - - 219

### = Fourth Family: VIPERIDAE

Genus VIPERA, Laurenti - - - - 221
21. Vipera ursinii, Bonaparteβ€” Orsini's Viper - 221
22. Vipera renardi, Christoph β€” Renard's Viper - 227
23. Vipera berus, Linnaeus β€” The Northern Viper, or Adder - 230
24. Vipera aspis, Linnaeusβ€” The Asp Viper - - 239
25. Vipera latastii, Bosca β€” Lataste's Viper - - 247
26. Vipera ammodytes, Linnaeus β€” The Sand-Viper, or Long-Nosed Viper ... - 249
27. Vipera lebetina, Linnaeus β€” The Blunt-Nosed Viper, or Kufi - - - - - 257
Macrovipera schweizeri, Werner, Milos viper
Genus ANCISTRODON, Palisot de Beauvois - 261
28. Ancistrodon halys, Pallasβ€” Pallas's Pit-Viper - 262
All other spp
# XRX/File Locking
## Motivation

You want to put systems in place to avoid the problem of concurrent users writing over each other changes.
Consider the following scenario. Bob loads the data to a configuration file into his client XForms application, makes half of his changes and then goes out to lunch before he does a save back to the server. During lunch Alice opens the same data in her XForms client, makes some changes, and does a save. When Bob gets back from lunch he does a save on the same data and wipes out all of Alice's updates.
This is known as the "Lost Update Problem" and is common when you have many users that may be concurrently editing the same data.

## Two Strategies for Managing Client Locks

There are many strategies to solve this problem, and each of them have some design limitations.
In general you will find two separate locking strategies which can be used together or independently:
The first strategy is to do checksums on the data when you move the data to the client. When you save, you recalculate the checksum on the data and make sure it has not changed. You can also put the last modified timestamp in the client and warn the user if the file has changed since they started editing it. The etag element within the HTML header is frequently used to hold an md5 checksum of the data.
The second strategy is to set some state on the server when a resource is edited and provide reasonable timeouts if the user does not do a save. This method is always more complex because you must deal with unlocking resources and this often involves tools and reports to view locked files.
The strategy presented here is to place a lock on the file when an Edit form is used and unlock the file when a save is performed.
eXist provides some simple functions to lock a file. This lock can be used to prevent the second user from opening up an edit session. The drawback to this approach is that if a file is locked and the user does not do a save, then a tool must be created to permit records to be manually unlocked.

## eXist Locking Functions

Here are some of the locking functions you can use on eXist:

## References

* Locking Grain Design Article from XML.com
* W3C Article on Concurrent Editing
* Java Class for Locking used in eXist
Back: Login and Session Management • Next: Selection List Generator
# XRX/Glossary Term Editor
## Motivation

You want a tool to manage your organization-specific business terms including definitions, acronyms, synonyms, broader/narrower terms, see-also terms, definition sources, approval history, versions, and traceability and mappings to ISO/IEC 11179 data elements.

## Method

Create a tool that manages individual business terms using a vocabulary similar to the W3C Simple Knowledge Organization SKOS draft standard. Use one XML file in an eXist collection for each term and have the server assign an ID number as each term is created. Allow each term to belong to one synonym set. We will associate each term with broader terms and use XQuery reports to infer narrower terms.

## Design Steps

To build the glossary we can create an XML Schema for each term and generate an XForms application to manage the Term data. We can then hand-edit the generated form to add specific functionality.

## XForms Application

This is an XQuery that when run with a parameters of new=true or an id=123 will generate an XForms application. It will need to be in the same folder as a new-instance.xml and it will need a save.xq and an update.xq to do the work of saving new instances (with the ids assigned) and updating existing instances, respectively. The update.xq will be responsible for versioning and archiving old values. The update script can also be responsible for creating log files of who changed what files and when.
Note: I have not fixed this yet to use the new pathnames for the Approval and DataElement containers.

## Search Application

Back: Selection List Generator • Next: FAQ Manager
# XRX/Map Navigation
## Motivation

You would like to add map navigation to your XRX application.
Although map controls were not defined within the original XForms specification, they can be added by using a bit of JavaScript.

## Method

We will use three frameworks.
* XSLTForms - that enables the model, controls and bindings
* JQuery - JQuery UI, JQuery layout - for the user interface. This includes the controls to do pans north, south, east, west
* OpenLayers - for the map navigation, pan and zoom functions
The XForms model will contain the following:
* A default instance that contains a search query with the min and max longitude and latitude (default).
* A place to store the response to the query (response).
* A locate instance (locate)
* A few binding statements
* A submission to get the new map data from the openmap database

## Sample User Interface

This example has a simple map user interface control that allows for panning to the North/South/East/West and zoom and zoom out.
This user interface uses a JQuery object that is associated with XForms input user interface controls.

## Sample Model Source

The following is stored in the XForms model:
Note that the following namespaces are used in this example:

## JavaScript Imports

The Javascript libraries will come from the openstreemap.org site. We will also use some JQuery user interface controls.
Here are the static JavaScript files you will need to add.

### Importing Static JavaScript Libraries
## Inline JavaScript Data

In addition to the above, the following JavaScript data must be used.

## XQuery

The following is a sample of the server-side XQuery code.
will be evaluated at server side for instance:

### Geo XQuery Module
## Credits

All the work was done by Evgeny Gazdovsky. The writeup was done by Dan McCreary.
# XRX/FAQ Manager
## Motivation

You want a simple tool to manage frequently asked questions for your web site. You want a user-friendly form to allow each user to enter the questions and answers, and to categorize each FAQ into one or more categories.

## Source Code

Link to FAQ Application
Back: Glossary Term Editor • Next: Detecting Duplicates
# XRX/Login and Session Management
## Motivation

You want to use an XForms application to get login information and set server session variables.

## Method

The XForms standard has a "secret" attribute for collecting a password. After the user fills out the login form, it is POSTed to the server.
Note that you should not use HTTP GET for passwords since the passwords will appear in the web log files as a URL parameter.
The eXist system has several functions for setting session variables. After a user logs in these session variables should be set and all subsequent XQueries can use these session variables when accessing secure resources.
Note that setting session variables is out-of-scope of the W3C XQuery 1.0 standard and each server may use slight variations of these functions. But the concepts should be very similar.
Most commonly, a session variable is used to associate the user to one or more roles. This is known as role-based access control (RBAC). This allows your XQueries to set conditional behavior based on the user's role, and avoids having to hard-code XQueries based on usernames that may change frequently. A typical role is the "admin" role or the "document-approver" role. eXist uses a UNIX style group that can be associated with a collection or a file. You can use these groups for security if you note that a collection or file can be associated with one-and-only-one group at any time. Users are frequently associated with multiple roles during a session, just as in UNIX a user can be in many groups.

## Sample XForms Login Screen

A sample login XForms application is provided here:
XForms Login Screen
This form may be customized to put in any legal disclaimers about the use of unauthorized systems. It can then be wrapped in an XQuery function such as local:display-login and invoked if the user is accessing a page that they do not have authorization to access.

## XQuery Function to display session information

Once the user is logged in, the following function can be used to display session information in the upper-right corder of the screen.
Back: Save File Dialog • Next: File Locking
# XRX/Introduction
## Background

This cookbook was created by Dan McCreary in the Spring of 2008. The XRX label was created by Dan soon after the December 2007 XTech meeting in Boston. Dan found many people there that all came to the same conclusion: using XForms and a native XML database offered some huge advantages. He also found that his related cookbook (the XForms cookbook) started to have many examples that used not just XForms but also XQuery as a back end. In order to keep the XForms cookbook general and still appeal XForms developers, many of the XForms/XQuery examples were migrated to this Wikibook.
Many XRX fans feel XRX to be a superior web application architecture, a natural consequence of XML being used both in the client, as a data transmission standard, and in the server.
We hope you find this book useful and we hope you contribute to the examples.
Next: Benefits of XRX
# XRX/Dictionary Editor
## Motivation

You want a simple application that saves one XML file per form. You want multiple users to each be editing individual records without conflict.

## Design

We will put each term in a separate XML file, and the files will be numbered sequentially - 1.xml, 2.xml, and so on. Each file defines a single term, its acronym, and its definition.

## Method

* Create a new eXist collection (aka Folder if you are using a WebDAV tool) called "dictionary"
* Create three collections called "data", "edit", and "views" within the "dictionary" collection.

### data/2.xml

Your XForms application loads the data into an instance:
You pass the ID number to an XQuery "edit.xq" as a parameter in the URI, "id". "edit.xq" uses the ID parameter as a variable, "$id", to build the form.

### Contents of edit/edit.xq

calling format: edit.xq?id=1

### Contents of edit/next-id.xml
## Contents of views/list-terms.xq

As you save more and more terms, you will want to create a list of them. You can create an XQuery that list all terms. For each term you can include a link to view and edit each term.

## edit.xq Header

The edit.xq takes parameters from the URI (i.e. in the form "edit.xq?id=2") and either puts a new element in the instance or it puts an existing element in the instance.

## xforms.css

The following file can be linked into the form for formatting. [And which file might that be?]
Back: Configuration File Editor • Next: Regular Expression Builder
# XRX/Large XForms Generator
## Motivation

You want to be able to generate large XForms using a REST service for doing performance tests for large forms. The primary item being tested is how long does the form take to become "ready" after the form is loaded.

## Method

We will use an XQuery to create XForms files. This XQuery will take a single URL parameter that has a count of the number of elements it will generate. The XForms will have one input field and two select1 fields for each count. Each input control will have its own instance in the model.

## Autogeneration of Select1 Fields

The code tables are stored in a static XML file called "code-tables.xml". The format is as follows:

## Sample Code Tables

Many large forms use large code tables. This example uses two large code tables. One is a list of all the countries in the world and another is a list of all US State Codes.
# XRX/Data Encapsulation
## Motivation

There are several motivations for data encapsulation.
* You want to make it clear to others what data an application manages.
* You want to use the same encapsulation patterns of object-oriented systems.
* You want to be able to prevent other applications from changing your data.
* You want to use consistent role-based access control for your applications data.
* You want to make it easy for all applications to share data management code for tasks such as ID assignment, versioning and linking.

## Method

Each XRX application stores all its user-managed data in a sub-collection of the application called data. For example if your application manages business terms the collection path to the terms might be:
Each XRX application stores its own data. When this application's main collection is removed, all the data that it manages is also automatically removed by the simple nature of the collection structure.
# XRX/Detecting Duplicates
## Motivation

You want to detect duplicate terms as the user types within a field of a form.

## Method

We will create a form that sends a request to the server each time a letter is typed into a field. The form will call a ReST web service and pass the current term as a parameter.

## Sample XQuery

The following query can be used on the server to detect duplicates.
This query takes a single parameter and returns a true or false element.
$BASENAME/xqueries/term-exists.xq?term-name=Product
If the term exists in the database it will return the following:

## XForms Application

Now we have a simple XForms that calls a web service and returns a true/false record. Our next step is to make this test occur in the background as the user types and display a warning message as a duplicate has been detected.

## Adding Character-by-Character Testing

Now we have two tasks. We need to fire off the event to the server as the user types and we need to bring the information back without interrupting the user.
First we want to add an event to the input field that sends a message each time a character is typed into the input field:
Back: FAQ Manager • Next: Data Element Editor
# Sustainable Business/Buy one give one

ABOUT THIS BOOK | THE BUSINESS PLAN | BOOKLETS | PRINT THIS BOOK
the idea of setting environmental and social dividends into the transactions of the business
http://www.buy1-give1free.com for example
or
Simply adding statements on the bottom on invoices that tell people what your business is giving through the transaction

## Tell the world

There is no commercial sense in linking your business to local charities or another good cause it you don't tell people about it. Consider doing the following:
* having a banner on the bottom of your website what charities you support.
* having a footer on your invoices
* having a notice at your place of business
This will add to your credibility with not just your customers but also your community.
can you link your customers more directly to your causes?