OpenLLM-France/wikimedia huggingface dataset:
# PBASIC Programming/Subroutines
## Reusing Code

We have seen in our chapters on loops that there are many times that we want to repeat certain blocks of code multiple times. A loop repeats these blocks one after the other, but what if we want to repeat a block of code at different times?
We can use a special tool called a subroutine to make a block of code repeatable. We can "call" our subroutine at any point in our program, and when the subroutine ends, the control flow will jump back to where it was.
When we move control flow into a subroutine, we say that we "call" the subroutine, or that we "enter" it. Similarly, when the subroutine has completed, we say that we "exit" the subroutine, or that we "return from it".

## GOSUB and RETURN

Subroutines start with a label. Instead of using a GOTO jump, we use the GOSUB instruction to enter the subroutine. The GOSUB does two things:
* it jumps to the subroutine's label, like a regular GOTO
* it stores the old value of the instruction pointer, so that after the subroutine the control flow can return to where it was.
The second point is important, because it allows us to return to our previous position.
The RETURN instruction, at the end of the subroutine, loads the saved value of the instruction pointer.

## Subroutines

A basic subroutine looks like this:

## Readability

One of the big benefits to using subroutines is that they help to make your code much easier to read for other people. Many times the person who writes a program will understand it very well, but it may not be so obvious to other people, such as teammates. For instance, if we have a robot using the BasicStamp, and we want to make that robot walk around in the shape of a square, we can use subroutines to do it easily:
Or, we can combine our subroutines with a loop to make it even easier:
The subroutines for MoveForward or TurnRight may be very complicated, but any person can read the small block of code above and understand what the robot will do.
# PBASIC Programming/Serial Communications
## Parallel and Serial

If we want to send out 16 bits worth of data, as we had been doing in the last chapter, we would need to define 16 output ports, and then write our data out to the pins. Here is an example that will output a 1 on every port:
Unfortunately, this system doesnt leave us any extra pins to play with. We don't have any available pins to use for inputs or other outputs. In cases like these, we want to use serial communications instead.
Parallel communications, what we have been doing so far, uses many wires in parallel with one another. Each data bit is transmitted on its own wire, and so to send x bits we need to use x wires. In a serial system, instead of using 16 wires, we use just 1 wire, and send all the data bits on that one wire, one at a time. The target computer, where the data is being sent to, reads each of the bits, one at a time, and stores them in a variable.
To use serial I/O, we use the SERIN and SEROUT functions

## Serial Settings

Serial I/O is obviously a little more complicated then parallel data is. For instance, we need to know what speed the data is being sent, so that the target computer can read the data at the same speed. We also need to know a few other things:

### Parity

    Parity adds an extra bit to every byte that we transmit. This extra bit can be used to determine if there is an error in the transmission. Parity can be set to "Odd", "Even", or "None".

### Baud

    "Baud" is the number of pulses that are transmitted each second. Both the sender and the receiver need to be using the same baud.

### Data Bits

    Data bits is the number of bits per "chunk" of information. There are commonly 8 data bits, but 7 is also possible on some hardware.
Both the sender and the receiver need to have the same values for the parity, baud, and data bits. If these are not matched, the communication will not work.

### Port

    This is the number of the port to be used to send or receive the data. This can be any of the regular data ports 0 - 15, or it can be the special dedicated serial port 16. Port 16 is the port that you use to program the BasicStamp. If you use port 16 you will have a fancy serial plug to use, but you won't be able to use the debug features of your BasicStamp. The sender and the receiver can use different ports.

### Settings Values
## SERIN and SEROUT

To send serial output, we use the SEROUT command. If we want to read serial data, we use the SERIN command. Because serial can send bits one after the other, we can send long data arrays at once, in addition to sending out single data bytes. We can send entire strings or arrays, if needed.
# PBASIC Programming/Variables and Constants
## Need for Storage

When we write a program, it's always a good thing to be able to store data that we are using, and to manipulate that data. If we want to set aside some storage for a particular use, we need to tell the computer to save that space, and we need to give the space a name. A variable is a storage location, like a box or a shelf in real life, that has a name. Think about the common algebraic equation for a straight line:
    $y=mx+b$
Where y is a variable that can take values dependent on the values for the other parameters.

## Variables

A variable is a storage location where we can hold values. A variable can be the size of one of our datatypes, such as a bit, a nibble, a byte, and a word. Once we define a variable, the size of it is fixed: If we define a byte, our variable cannot contain values over 255.

### Defining a Variable

To define a variable, we use the VAR keyword. First we need to give a name to our variable, and the name for the variable cannot be the same as any of the reserved words. Variable names must start with a letter, may contain letters or numbers, and are not case sensitive. Here are some examples:

### Aliases

We can give names to the individual parts of our variables. For instance, we know that a byte is made up of 8 bits, and if we want we can give each of these bits a name, if we want. Notice that bit numbers start at 0, not 1. Here are some examples:
Notice that the variable FirstBit is the same exact thing as FirstNibFirstBit.

### Arrays

If we have multiple data values that are related, and we don't want to give them all individual names, we can create an array. An array is a large variable that contains many "boxes", each with an address. The array has a name, and to access an individual box in the array, you need the name of the array and the address. Here are some examples:
This creates an array with 10 bytes. Each byte can still only contain numbers up to 255, and we cannot combine multiple bytes in our array to make larger numbers.
We can use aliases with array elements too:
We can also make more complicated aliases, but we need to keep the box address at the end:

## Constants

Sometimes when we are doing calculations, we can define a thing called a constant to make things easier. Constants are just numbers, not variables, and once you set the value it cannot be changed. A common example of a constant that people use is π = 3.1415.... Instead of having to write out π to several decimal points each time we want to use it, we can simply define a constant value with the name "pi". To define a constant, we use the CON keyword. Here are a few examples:
Constants are useful for a number of reasons:
* Makes mathematical equations easier to read.
* If we need to change a value, we only change the CON definition, and we dont need to change it everywhere in the code
# PHP Programming
## Introduction

* Introduction

## Setup and Installation

* Setup and Installation
** Installation on Windows
*** Easy Windows Setup Instructions
** Installation on Linux
** Installation on Mac OS X
* Uses of PHP
Note: Before contributing, check out the discussion page. How to write your examples.

## Learning the Language
### The Basics

    This section is about things that are important for any type of PHP development. Useful for a PHP programmer of any level.
* Beginning with "Hello World!" (10 Feb 2006)
* Nuts and Bolts (14 Jan 2006)
* Commenting and Style (14 Jan 2006)
* Comparison operators (2016-04-06)
* Arrays (10 Feb 2006)
* Control structures
** The if Structure (19 Mar 2009)
** The switch Structure (14 Jan 2006)
** The while Loop (14 Jan 2006)
** The do while Loop (14 Jan 2006)
** The for Loop (14 Jan 2006)
** The foreach Loop (14 Jan 2006)
* Functions (10 Feb 2006)
* PHP Include Files
* Files (12 Feb 2008)
** Images
* Mailing (14 Jan 2006)
* Cookies (14 Jan 2006)
* Sessions (2008-05-07)
* Databases
** MySQL (14 Jan 2006)
*** PHP and MySQL
** PostgreSQL (18 Apr 2009)
** PHP Data Objects (18 Dec 2006)
** Neo4j
** DBAL
* Integration Methods (HTML Forms, etc.) (14 Jan 2006)
* Regular expressions

### Advanced PHP

    Advanced PHP includes high level programming and PHP techniques designed to make PHP even more useful and powerful.

#### Data Structures

* Data Structures

#### Object Oriented Programming (OOP)

* Classes
* Special Methods
* Overriding and Overloading
* Inheritance
* SSH Class

#### Caching

* Caching

#### Templating

* Why Templating
* Templates
* Smarty templating system
** Smarty templating system/Functions
** Smarty templating system/Simple tutorial
* Flat Frog
* XML
* XSL
** XSL/registerPHPFunctions

#### Libraries

* PHP PEAR
* PHP Manual Function Reference
* PHP 5 Functions

#### Frameworks

| CakePHP | CodeIgniter | Drupal | Kohana |
| Laravel | Nette | Qcodo | Silverstripe |
| Solar | Symfony | Yii | Zend |

#### Security

* Configuration: Register Globals
* SQL Injection Attacks
* Building a secure user login system
* Cross Site Scripting Attacks (XSS)
* Secure HTTP headers
* Encryption
See also:
* section on avoiding session fixation in the Sessions chapter.
* Cross-site request forgery (CSRF)

#### Command-Line Interface (CLI)

* PHP CLI
* PHP-GTK
* Daemonization

## Appendices

* Alternative Hungarian Notation
* Code Snippets
* Coding Standards
* formatting notes
* Get Apache and PHP
* headers and footers
* html output
* OOP5/Advanced Input validation
* OOP5/Input validation
* phpDocumentor
* Reserved words
* Contributors

## External links

* Editors
* Resources
# Physics with Calculus/Electromagnetism/Capacitance, Inductance, LRC Circuits

2/27/06 Capacitance (c)
Capacitance is a measure of the amount of electric charge stored (or separated) for a given electric potential. The capacitance is usually defined as the total electric charge placed on the object divided by the potential of the object:
or, according to Gauss's law, the capacitance can be expressed as the electric flux per volt
where
Conductors have equal and opposite charge
The charge (aka current) is split up Each capacitor will have part of the total charge that is available for the group (there is a certain amount of charge in each branch there will be charge and when you add the charge of the branches that will be the total charge.) Voltage is split up Each capacitor in series gets a part of the total available charge They all acquire the same voltage Each parallelel branch gets the same voltage as all other Total equivalent Capacitance
# Physics Using Geometric Algebra/Relativistic Classical Mechanics/The electromagnetic field

The electromagnetic field is defined in terms of the electric and magnetic fields as
    $F=\mathbf {E} +ic\mathbf {B} .$
Alternatively, the fields can be derived from a paravector potential $A$ as
    $F=c\left\langle \partial {\bar {A}}\right\rangle _{V+BV},$
where:
    $\partial ={\frac {\partial }{\partial x^{0}}}-\nabla$
and
    $A=\phi /c+\mathbf {A} .$

## Lorenz gauge

The Lorenz gauge (without t) is expressed as
    $\langle \partial {\bar {A}}\rangle _{S}=0$
The electromagnetic field $F$ is still invariant under a gauge transformation
    $A\rightarrow A^{\prime }=A+\partial \chi ,$
where $\chi$ is a scalar function subject to the following condition
    ${\bar {\partial }}\partial \chi =0$
where
    ${\bar {\partial }}={\frac {\partial }{\partial x^{0}}}+\nabla$

## Maxwell Equations

The Maxwell equations can be expressed in a single equation
    ${\bar {\partial }}F={\frac {1}{c\epsilon }}{\bar {j}},$
where the current $j$ is
    $j=\rho c+\mathbf {j}$
Decomposing in parts we have
* Real scalar: Gauss's Law
* Real vector: Ampere's Law
* Imaginary scalar: No magnetic monopoles
* Imaginary vector: Faraday's law of induction

### Electromagnetic Lagrangian

The electromagnetic Lagrangian that gives the Maxwell equations is
    $L={\frac {1}{2}}\langle FF\rangle _{S}-\langle A{\bar {j}}\rangle _{S}$

### Energy density and Poynting vector

The energy density and Poynting vector can be extracted from
    ${\frac {\epsilon _{0}}{2}}FF^{\dagger }=\varepsilon +{\frac {1}{c}}S,$
where energy density is
    $\varepsilon ={\frac {\epsilon _{0}}{2}}(E^{2}+c^{2}B^{2})$
and the Poynting vector is
    $S={\frac {1}{\mu _{0}}}E\times B$

## Lorentz Force

The electromagnetic field plays the role of a spacetime rotation with
    $\Omega ={\frac {e}{mc}}F$
The Lorentz force equation becomes
    ${\frac {dp}{d\tau }}=\langle Fu\rangle _{V}$
or equivalently
    ${\frac {dp}{dt}}=\langle F(1+v)\rangle _{V}$
and the Lorentz force in spinor form is
    ${\frac {d\Lambda }{d\tau }}={\frac {e}{2mc}}F\Lambda$

### Lorentz Force Lagrangian

The Lagrangian that gives the Lorentz Force is
    ${\frac {1}{2}}mu{\bar {u}}+e\langle {\bar {A}}u\rangle _{S}$

## Plane electromagnetic waves

The propagation paravector is defined as
    $k={\frac {\omega }{c}}+\mathbf {k} ,$
which is a null paravector that can be written in terms of the unit vector $\mathbf {k}$ as
    $k={\frac {\omega }{c}}(1+\mathbf {\hat {k}} ),$
A vector potential that gives origin to a polarization|circularly polarized plane wave of left helicity is
    $A=e^{is\mathbf {\hat {k}} }\mathbf {a} ,$
where the phase is
$s=\left\langle k{\bar {x}}\right\rangle _{S}=\omega t-\mathbf {k} \cdot \mathbf {x}$
and $\mathbf {a}$ is defined to be perpendicular to the propagation vector $\mathbf {k}$. This paravector potential obeys the Lorenz gauge condition. The right helicity is obtained with the opposite sign of the phase
The electromagnetic field of this paravector potential is calculated as
    $F=ickA_{_},$
which is nilpotent
    $FF_{_}=0$
# Physics with Calculus/Electromagnetism/Current and Circuits
## Current

Imagine a wire with charge flowing through it. The current is the rate at which charge flows through the wire. Say that there are n movable electrons per unit volume, that the electrons have a charge e, and move at a velocity in the direction of the wire with velocity v. Also assume that the wire has cross-sectional area A. Then the charge per second passing through the surface is envA. You can easily see this if you imagine a cylinder of the wire of length v dt. It has a volume of Av dt, and by the definition of n, nAv dt electrons, and by definition of e, enAv dt charge. All of that (and only all of that) will go through the wire in the time dt. Therefore, the current, i = envA.
Notice that in our formula, even though electrons have negative charge, we regard the current as positive. This is called conventional current. It is equivalent to an equal and opposite flow of positive charge (mathematically, that means multiplying both sides of i = envA by -1).

## Circuits

A circuit component is a device that sets up a relationship between voltage and current. A circuit component may have any number of terminals, and have any relationship. However, in practice, there are only a few basic circuit components. In analyzing circuits, it is highly advantageous to use only circuit components that, given the voltage at a single instant, or infinitesimal neighborhood, you can determine the current, and vice versa. Two very simple circuit elements are voltage sources and current sources. A voltage source keeps the voltage fixed and lets the current be whatever it wants. A current source keeps the current constant and lets the voltage be whatever it wants. A third simple circuit element is the resistor, which keeps the voltage proportional to the current, with the constant of proportionality called the resistance. We can write these relationships as:
V = V_0; I = I_0; V = IR
for a voltage source, current source, and resistor respectively.
A special case of the voltage source is when it keeps the voltage zero; this is called a short circuit or wire. When a current source keeps the current zero, it is called an open circuit. We may regard an open circuit as not being part of the circuit at all, and a short circuit as just combining the two circuit elements it joins.
A circuit or network is a collection of circuit components hooked together. Naturally, there will be loops and nodes, which are when two or more circuit components join together. At every node, we assume that charge does not build up, and that charge is conserved. That is, the current going in is the current going out. In any loop, we assume that an electron going around cannot speed up faster and faster ad infinitum, in other words, the voltage in a closed loop must be zero; that is, energy is conserved. These two rules, along with the voltage-current (v-i) relationships, completely describes a circuit. With these, we can find every voltage and every current.
# Physics Using Geometric Algebra/Relativistic Classical Mechanics/Spacetime position

The spacetime position $x$ can be encoded in a paravector
    $x=x^{0}+\mathbf {x} ,$
with the scalar part of the spacetime position in terms of the time
    $x^{0}=ct_{_}.$
The proper velocity $u$ is defined as the derivative of the spacetime position with respect to the proper time $\tau _{_}$
    $c\,u={\frac {dx}{d\tau }}$
The proper velocity can be written in terms of the velocity
    $c\,u={\frac {dx^{0}}{d\tau }}+{\frac {d\mathbf {x} }{d\tau }}=\gamma \left(1+{\frac {d\mathbf {x} }{dx^{0}}}\right)=\gamma \left(1+{\frac {\mathbf {v} }{c}}\right),$
where
    $\gamma ={\frac {dx^{0}}{d\tau }}={\frac {1}{\sqrt {1-{\frac {\mathbf {v} ^{2}}{c^{2}}}}}}$
and of course
    $\mathbf {v} ={\frac {d\mathbf {x} }{dt}}.$
The proper velocity is unimodular
    $u{\bar {u}}=1$

## Spacetime momentum

The spacetime momentum is a paravector defined in terms of the proper velocity
    $p_{_}=mcu$
The spacetime momentum contains the energy as the scalar part
    $p=mc(\gamma +\gamma {\frac {\mathbf {v} }{c}})={\frac {E}{c}}+\mathbf {p} ,$
where the energy $E$ is defined as
    $E_{_}=\gamma mc^{2}$
The shell condition of the spacetime momentum is
    $p{\bar {p}}=(mc)^{2}$
# Physics Using Geometric Algebra/Relativistic Classical Mechanics/The classical spinor

The proper velocity can be expressed in terms of the associated Lorentz transformation spinor called eigenspinor.
The proper time derivative of the eigenspinor can be expressed in terms of the spacetime rotation biparavector $\Omega$ as
    ${\frac {d\Lambda }{d\tau }}={\frac {1}{2}}\Omega \Lambda$
The spacetime rotation biparavector contains the information of the interaction that the particle is subject to.
The dynamics of a classical particle can be expressed in terms of a differential equation involving the eigenspinor.
    ${\frac {dp}{d\tau }}=mc{\frac {d}{d\tau }}(\Lambda \Lambda ^{\dagger })=mc({\frac {d\Lambda }{d\tau }}\Lambda ^{\dagger }+\Lambda {\frac {d\Lambda ^{\dagger }}{d\tau }}),$
using the definition of the spacetime rotation biparavector
    $mc{\frac {1}{2}}(\Omega \Lambda \Lambda ^{\dagger }+\Lambda \Lambda ^{\dagger }\Omega ^{\dagger })=mc\langle \Lambda \Omega \rangle _{\Re},$
that finally gives the dynamic equation
    ${\frac {dp}{d\tau }}=mc\langle \Omega \Lambda \rangle _{\Re},$
where the role of the force is now played by the spacetime rotation biparavector.
Once the spacetime rotation is identified with the electromagnetic force, the result is the spinorial form of the Lorentz force.
    ${\frac {d\Lambda }{d\tau }}={\frac {e}{2mc}}F\Lambda$

## Constant Electric Field

The eigenspinor form of the Lorentz force can be solved analytically in many interesting cases. One of the simplest is the case of the constant electric field. If the electric field is directed along the z direction, the equation to solve is
    ${\frac {d\Lambda }{d\tau }}={\frac {e}{2mc}}E\mathbf {e} _{3}\Lambda$
and the solution is
    $\Lambda =e^{{\frac {e}{2mc}}E\mathbf {e} _{3}\tau }\Lambda _{0}.$
The proper velocity is calculated as
    $u=e^{{\frac {e}{2mc}}E\mathbf {e} _{3}\tau }u_{0}e^{{\frac {e}{2mc}}E\mathbf {e} _{3}\tau }.$
If the particle starts at rest, the proper velocity is simply
    $u=e^{{\frac {e}{mc}}E\mathbf {e} _{3}\tau }.$
An additional integration gives the spacetime position
    $x=x_{0}+{\frac {mc^{2}}{eE}}\mathbf {e} _{3}(e^{{\frac {e}{mc}}E\mathbf {e} _{3}\tau }-1)$
# Physics with Calculus/Appendix 1/Derivatives

We define a derivative as the limit of a function as the ratio of the changes in the function and the changes in the variable as the change in the variable goes to zero.
i.e.
    ${\begin{matrix}{df \over dx}=\lim _{\Delta x\to 0}{{f(x+\Delta x)-f(x)} \over {\Delta x}}\end{matrix}}$

### An example

Quantity B is found to depend on quantity A such that B is always the square of A.
A ..... B In this case, x=A and f(x) is [the function of x] = B. Look at what happens at the point A=2 (for example).
0 ..... 0 At x=2 f(x)=4. Changing x very slightly, by only 0.01, we have delta x=0.01, so that x+delta x is 2.01.
1 ..... 1 Then the function of (x+delta x) = the function of 2.01 = the square of 2.01 = 4.0401. The difference between f(x+delta x) and f(x)
2 ..... 4 is 4.0401 and 4. It is 0.0401. Dividing it by delta x we have 0.0401/0.01 which is 4.01, meaning that
3 ..... 9 the CHANGE of the function divided by the CHANGE in x is nearly 4 when x=2. If we would have made delta x much smaller
etc. ..... we would have got exactly 4, which happens to be 2 times x at x=2
* In general, if we have a polynomial of x, such as $x^{3},x^{4},$ etc then the derivative is as follows:$f(x)=x^{n};{\frac {df(x)}{dx}}=nx^{n-1}$Where ${\frac {df(x)}{dx}}$ is the symbol for the derivative of f with respect to x.