├── .gitignore ├── MIT-LICENSE ├── Makefile ├── Readme ├── announce ├── bin ├── efind_similar_files ├── eindex ├── openurl ├── term.sh └── term_osx.sh ├── doc ├── Makefile ├── about.ehtml ├── bin.ehtml ├── edit.html ├── glossary.ehtml ├── index.ehtml ├── trawl.ehtml └── webserver.ehtml ├── include ├── 354984si.ngl.gz ├── dtd │ ├── catalog.xml │ ├── readdme.html │ ├── xhtml-lat1.ent │ ├── xhtml-special.ent │ ├── xhtml-symbol.ent │ ├── xhtml1-transitional.dtd │ └── xml_check ├── elib1.css ├── images │ ├── dir_icon.jpg │ ├── dir_icon_thumb.jpg │ ├── github.png │ ├── joe.jpg │ ├── joe_thumb.jpg │ ├── pdf_icon.jpg │ ├── pdf_icon_thumb.jpg │ ├── ring.gif │ └── ringtxt.jpg ├── jquery-1.3.2.min.js ├── jquery-slides.js ├── jquery.form.js ├── jquery.simplemodal-1.3.3.js ├── plain.css └── slides.css ├── lib ├── doc │ ├── edoc-info │ ├── elib1_best.html │ ├── elib1_blob_store.html │ ├── elib1_chunks.html │ ├── elib1_content_edit.html │ ├── elib1_diff.html │ ├── elib1_doc.html │ ├── elib1_docmaker.html │ ├── elib1_ensure_copyrighted.html │ ├── elib1_expand.html │ ├── elib1_fast_read.html │ ├── elib1_fast_write.html │ ├── elib1_file_finder.html │ ├── elib1_find.html │ ├── elib1_gamma.html │ ├── elib1_geom.html │ ├── elib1_guid_store.html │ ├── elib1_http_driver.html │ ├── elib1_indexer.html │ ├── elib1_indexer_plugin_erl.html │ ├── elib1_indexer_results.html │ ├── elib1_misc.html │ ├── elib1_ml9.html │ ├── elib1_ml9_2_html.html │ ├── elib1_mysql.html │ ├── elib1_new_webkit.html │ ├── elib1_porter.html │ ├── elib1_rfc4627.html │ ├── elib1_screen.html │ ├── elib1_search.html │ ├── elib1_seq_web_server1.html │ ├── elib1_sha1.html │ ├── elib1_similar.html │ ├── elib1_simple_kv_db.html │ ├── elib1_store.html │ ├── elib1_tagger.html │ ├── elib1_telnet.html │ ├── elib1_webkit.html │ ├── elib1_webquery.html │ ├── elib1_xml.html │ ├── erlang.png │ ├── index.html │ ├── modules-frame.html │ ├── overview-summary.html │ ├── packages-frame.html │ ├── password.html │ ├── stylesheet.css │ └── tryxform.html ├── ebin │ └── README ├── src │ ├── Makefile │ ├── elib1_best.erl │ ├── elib1_blob_store.erl │ ├── elib1_chunks.erl │ ├── elib1_content_edit.erl │ ├── elib1_diff.erl │ ├── elib1_doc.erl │ ├── elib1_docmaker.erl │ ├── elib1_ensure_copyrighted.erl │ ├── elib1_expand.erl │ ├── elib1_fast_read.erl │ ├── elib1_fast_write.erl │ ├── elib1_file_finder.erl │ ├── elib1_find.erl │ ├── elib1_gamma.erl │ ├── elib1_geom.erl │ ├── elib1_guid_store.erl │ ├── elib1_http_driver.erl │ ├── elib1_indexer.erl │ ├── elib1_indexer_plugin_erl.erl │ ├── elib1_indexer_results.erl │ ├── elib1_misc.erl │ ├── elib1_ml9.erl │ ├── elib1_ml9_2_html.erl │ ├── elib1_ml9_parse_header.yrl │ ├── elib1_mysql.erl │ ├── elib1_new_webkit.erl │ ├── elib1_parse_dtd.yrl │ ├── elib1_porter.erl │ ├── elib1_rfc4627.erl │ ├── elib1_screen.erl │ ├── elib1_search.erl │ ├── elib1_seq_web_server1.erl │ ├── elib1_sha1.erl │ ├── elib1_similar.erl │ ├── elib1_simple_kv_db.erl │ ├── elib1_store.erl │ ├── elib1_tagger.erl │ ├── elib1_telnet.erl │ ├── elib1_webkit.erl │ ├── elib1_webquery.erl │ ├── elib1_xml.erl │ ├── mkdoc │ ├── password.erl │ ├── slides.ehtml │ └── tryxform.erl └── tmp │ ├── elib1_ml9_parse_header.erl │ └── elib1_parse_dtd.erl ├── root ├── src ├── .gitignore ├── Makefile ├── best.notes ├── book.book ├── chap2html.xsl ├── chap2pdf.xsl ├── design.chap1 ├── edit.html ├── elib1_best.erl ├── elib1_blob_store.erl ├── elib1_chunks.erl ├── elib1_content_edit.erl ├── elib1_diff.erl ├── elib1_doc.erl ├── elib1_docmaker.erl ├── elib1_ensure_copyrighted.erl ├── elib1_expand.erl ├── elib1_fast_read.erl ├── elib1_fast_write.erl ├── elib1_file_finder.erl ├── elib1_find.erl ├── elib1_find_reent.erl ├── elib1_gamma.erl ├── elib1_geom.erl ├── elib1_guid_store.erl ├── elib1_html_tokenise.erl ├── elib1_http_driver.erl ├── elib1_indexer.erl ├── elib1_indexer_plugin_erl.erl ├── elib1_indexer_results.erl ├── elib1_misc.erl ├── elib1_ml9.erl ├── elib1_ml9_2_html.erl ├── elib1_ml9_parse_header.yrl ├── elib1_mysql.erl ├── elib1_new_webkit.erl ├── elib1_org2latex.erl ├── elib1_parse_dtd.yrl ├── elib1_porter.erl ├── elib1_rfc4627.erl ├── elib1_screen.erl ├── elib1_search.erl ├── elib1_seq_web_server1.erl ├── elib1_sha1.erl ├── elib1_similar.erl ├── elib1_simple_kv_db.erl ├── elib1_spy.erl ├── elib1_spy.erl~ ├── elib1_store.erl ├── elib1_tagger.erl ├── elib1_telnet.erl ├── elib1_txt2xml.erl ├── elib1_webkit.erl ├── elib1_webquery.erl ├── elib1_xml.erl ├── ezxml.chap1 ├── gen_component.erl ├── log ├── log.log ├── lorem.chap ├── mkdoc ├── myapp.app.src ├── myapp_app.erl ├── myapp_sup.erl ├── notes ├── password.erl ├── readme.html ├── slides.ehtml ├── todo ├── tryxform.erl └── wiki.chap1 ├── supported ├── drivers │ ├── README │ ├── c_linked_in_driver │ │ ├── Makefile │ │ ├── complex.erl │ │ └── port_driver.c │ ├── c_port_driver │ │ ├── Makefile │ │ ├── example1.erl │ │ └── port_driver.c │ ├── cpp_linked_in_driver │ │ ├── Makefile │ │ ├── complex.erl │ │ └── port_driver.cpp │ └── doc.ehtml ├── indexer │ ├── Makefile │ ├── README │ ├── doc.ehtml │ ├── medium.in │ ├── slides.ehtml │ └── web_query.ehtml ├── irc │ ├── Makefile │ ├── README │ ├── chat_erl.tcl │ ├── chat_erl_test.tcl │ ├── chat_tcl.tcl │ ├── chat_widget.erl │ ├── doc.ehtml │ ├── elib1_spy.erl │ ├── elib1_wish.erl │ ├── elib1_wish.tcl │ ├── irc.erl │ ├── irc_expt.erl │ ├── irc_server.bad │ ├── irc_server.erl.test │ ├── irc_text_client.erl │ ├── ircd.erl │ ├── redball.gif │ ├── rfc2812.txt │ ├── session.txt │ ├── test1.tcl │ ├── whiteball.gif │ └── widget_lib.erl ├── midi_driver │ ├── Makefile │ ├── doc.ehtml │ ├── endpoint_name.c │ ├── list_devices.c │ ├── midi_driver.erl │ ├── midi_in_driver.c │ ├── midi_in_driver.erl │ ├── midi_out_driver.c │ └── midi_out_driver.erl ├── tagger │ ├── Makefile │ ├── Todo │ ├── doc.ehtml │ ├── html │ │ └── erl.css │ └── make_html.erl ├── template │ ├── Readme │ ├── Todo │ ├── doc.ehtml │ └── doc.html ├── versions │ ├── doc.ehtml │ ├── elib1_lin.erl │ ├── elib1_publish.erl │ ├── elib1_ran.erl │ ├── elib1_rsa.erl │ ├── joe.pri │ ├── joe.pub │ ├── nmap.erl │ ├── nmap.erl.bak │ ├── versions.chap │ └── versions.html └── website │ ├── .#test.html │ ├── .#test1.html │ ├── .#test4.html │ ├── Makefile │ ├── browse.ehtml │ ├── browser.html │ ├── captions.html │ ├── dave.jpg │ ├── doc.ehtml │ ├── editor.html │ ├── file_lister.erl │ ├── ibrowser.html │ ├── index.ehtml │ ├── joe.jpg │ ├── johnny.jpg │ ├── my_simple_server.erl │ ├── nav.html │ ├── new.html │ ├── pdf_icon.jpg │ ├── simple.css │ ├── simple.js │ ├── simple_web_server.erl │ ├── slides.ehtml │ ├── test.html │ ├── test1.html │ ├── test4.html │ ├── test5.html │ ├── test6.html │ ├── todo.ehtml │ ├── web_server_one.erl │ └── web_server_two.erl ├── unsupported ├── epeg │ ├── Makefile │ ├── Readme │ ├── bug.peg │ ├── doc.ehtml │ ├── epeg.erl │ ├── epeg.peg │ ├── epeg2erl │ ├── epeg_bootstrap.erl │ ├── epeg_compiler.erl │ ├── epeg_pc.erl │ ├── epeg_tests.erl │ ├── erlterm.peg │ ├── peglib.peg │ ├── pegtest.peg │ ├── string_metrics.erl │ ├── test.erl │ └── testall.peg ├── folding │ ├── doc.ehtml │ ├── dragger.js │ ├── experiment.html │ ├── f1.html │ ├── f2.html │ ├── f3.html │ ├── folder.js │ ├── folding_editor.html │ ├── instructions.js │ ├── new.html │ ├── render.js │ ├── structure_editor.html │ ├── structure_editor1.html │ └── test_js6.html ├── jpeg │ ├── decode.erl │ ├── doc.ehtml │ ├── itu-t81.pdf │ ├── jfif3.pdf │ └── jpeg_fugi.erl ├── work │ ├── circle.html │ ├── circle.svg │ └── fft.erl └── xml │ ├── chap.dtd │ ├── doc.ehtml │ ├── elib1_xml_validate.erl │ ├── entry.dtd │ ├── log.dtd │ ├── my_catalog.xml │ ├── story.dtd │ ├── story.xml │ ├── test.dtd │ ├── test1.dtd │ ├── validate.ehtml │ ├── xhtml-lat1.ent │ ├── xhtml-special.ent │ ├── xhtml-symbol.ent │ └── xhtml1-transitional.dtd └── wanted ├── doc.ehtml ├── notes └── registry.ehtml └── src └── elib1_bloom.erl /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.tmp 3 | \#* 4 | erl_parse.erl 5 | .eunit/* 6 | deps/* 7 | ebin 8 | priv/* 9 | *.o 10 | *.beam 11 | -------------------------------------------------------------------------------- /MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006-2009 Joe Armstrong 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ## Make 2 | 3 | all: 4 | cd lib/src; make 5 | cd supported/indexer; make 6 | cd supported/tagger; make 7 | cd supported/irc; make beam 8 | cd supported/website; make 9 | (sleep 1 && bin/openurl http://localhost:2246/supported/website/index.ehtml) & \ 10 | erl -pa ./supported/irc -pa ./supported/website -s simple_web_server start 11 | 12 | clean: 13 | cd lib/src; make clean 14 | cd supported/indexer; make clean 15 | cd supported/tagger; make clean 16 | cd supported/irc; make clean 17 | cd supported/website; make clean 18 | 19 | 20 | -------------------------------------------------------------------------------- /Readme: -------------------------------------------------------------------------------- 1 | 2 | Elib1 3 | 4 | An Erlang library and collection of applications 5 | 6 | You will also have to do the following: 7 | 8 | 1) add a path to your ${HOME}/.erlang 9 | code:add_patha(".../elib1-3/lib/ebin"). 10 | 11 | 2) add path to your .bash_profile (on a mac) 12 | export PATH=/Users/joe/code/elib2-1/bin:$PATH 13 | 14 | 3) make eindex and executable 15 | chmod u+x elib1-3/bin/einidex 16 | chnod u+x elib1-3/bin/elib2_find_similar_files 17 | 18 | Then make to compile the library and view 19 | the documentation. 20 | 21 | This should start a web server on port 22 | 23 | If it doesn't point your browser at: 24 | 25 | http://localhost:2246/supported/website/index.ehtml 26 | 27 | Note - I have only tested this with firefox 28 | -------------------------------------------------------------------------------- /announce: -------------------------------------------------------------------------------- 1 | Announcing elib1 2 | 3 | Elib1 was released today. 4 | 5 | Elib1 is a library of Erlang modules and set of applications which use the modules. 6 | 7 | The Elib1 project now moves into phase 2 8 | 9 | The phases of the project are: 10 | 11 | Phase 1: Define and implement a basic structure 12 | and a small number of applications 13 | Phase 2: Make project open source 14 | Phase 3: Write books 15 | 16 | Each phase will take about 2-3 years. 17 | 18 | The first attempt at a library contains modules for the following: 19 | 20 | xml parsing 21 | fast tuple I/O (to disk) 22 | full-text indexing 23 | http parsing 24 | telnet server 25 | json parsing 26 | porter stemming 27 | mysql native interface 28 | sha1 29 | similar file locator 30 | screen manipulation 31 | miscellaneous missing functions (which should be in the standard libraries) 32 | accurate tagging of Erlang so it can be turned into browsable HTML 33 | (and more ...) 34 | 35 | The applications are divided it two areas. Supported and unsupported 36 | 37 | In supported: 38 | 39 | indexer - a full text indexing engine (this is the of near production quality) 40 | irc - and irc kit (includes a TCL wish interface) (somewhat incomplete) 41 | tagger - an application to turn erlang into browsable HTML 42 | drivers - example linked in and port drivers (currently broken) 43 | midi_drivers - mac os X only 44 | website - a webserver (used internally) 45 | versions - a way of munging module names to make them secure 46 | 47 | In unsupported: 48 | 49 | epeg - a peg grammar and parser combinators 50 | folding - Javascript folding editor/organiser (needs some work, not erlang :-) 51 | jpeg - image transformation in Erlang 52 | xml - some xml stuff 53 | 54 | I have attempted to use "best practise" in making the library. Using 55 | the dialyzer, eunit and edoc. 56 | 57 | This code is far from perfect or polished - but the basic way things fit together 58 | is defined. 59 | 60 | Rather than have 500 small libraries each with a few users and a few routines I'd 61 | like to see one library with a much large number of tightly integrated routines. 62 | 63 | The code is available at: 64 | 65 | http://github.com/joearms/elib1 66 | 67 | 68 | -------------------------------------------------------------------------------- /bin/efind_similar_files: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Usage efsim 3 | 4 | erl -noshell -s elib1_similar batch_find_similar $1 5 | 6 | -------------------------------------------------------------------------------- /bin/eindex: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env escript 2 | main(Args) -> 3 | elib1_indexer:do(Args). 4 | -------------------------------------------------------------------------------- /bin/openurl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # an OS independent way to open a URL in a browser 4 | 5 | os=`uname` 6 | 7 | case $os in 8 | Linux) 9 | firefox $1;; 10 | Darwin) 11 | open -a firefox $1;; 12 | *) 13 | echo unknown OS $os;; 14 | esac 15 | -------------------------------------------------------------------------------- /bin/term.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Open a new Mac OS X terminal window or tab in the current or another 4 | # directory and optionally run a command in the new window or tab. 5 | # 6 | # - Without any arguments, the new terminal window opens in 7 | # the current directory, i.e. the executed command is "cd $PWD". 8 | # - If the first argument is a directory, the new terminal will "cd" into 9 | # that directory before executing the remaining arguments as command. 10 | # - The optional "-t" flag executes the command in a new tab 11 | # instead of a new window. 12 | # - The optional "-x" flag closes the new window or tab 13 | # after the executed command finishes. 14 | # - The optional "-p" flag takes an argument of the form x,y (e.g. 40,50) and 15 | # positions the terminal window to the indicated location on the screen 16 | # - The optional "-s" flag takes an argument of the form w,h (e.g. 800,400) and 17 | # resizes the terminal window to the indicated width and height in pixels. 18 | # 19 | # Written by Marc Liyanage 20 | # 21 | # Version 2.1 22 | # 23 | 24 | set -e 25 | 26 | while getopts xtp:s: OPTION; do 27 | [ $OPTION = "x" ] && { EXIT='; exit'; } 28 | [ $OPTION = "t" ] && { TAB=1; } 29 | [ $OPTION = "p" ] && { POSITION="set position of window 1 to {$OPTARG}"; } 30 | [ $OPTION = "s" ] && { SIZE="set size of window 1 to {$OPTARG}"; } 31 | done 32 | 33 | for (( $OPTIND; $OPTIND-1; OPTIND=$OPTIND-1 )); do shift; done 34 | 35 | if [[ -d "$1" ]]; then WD=$(cd "$1"; pwd); shift; else WD=$PWD; fi 36 | 37 | 38 | COMMAND="cd '$WD' && echo -n \$'\\\\ec';" 39 | for i in "$@"; do 40 | COMMAND="$COMMAND '$i'" 41 | done 42 | 43 | if [ $TAB ]; then 44 | 45 | osascript 2>/dev/null < 19 | # 20 | # Version 1.0 21 | # 22 | 23 | if [ "x-x" = x"$1" ]; then 24 | EXIT="; exit"; shift; 25 | fi 26 | 27 | if [[ -d "$1" ]]; then 28 | WD=`cd "$1"; pwd`; shift; 29 | else 30 | WD="'`pwd`'"; 31 | fi 32 | 33 | COMMAND="cd $WD; $@" 34 | echo "$COMMAND $EXIT" 35 | 36 | osascript 2>/dev/null < 2 | 3 |

About

4 | 5 |

Restrictions

6 | 7 |

All documentation must be in a fixed directory 8 | ${ROOT}/doc documentation is written with the extension 9 | .ehtml

10 | 11 |

Elib1 is a library of Erlang modules, together with a number of 12 | complete applications built using the library. The applications have 13 | been co-developed with the library. The test of any library is 14 | are the library functions useful? The only way to answer 15 | this is to write a largish number of applications using the library 16 | functions. If the applications are useful and if they reuse large 17 | amounts of library code then the library is probably OK, otherwise 18 | not.

19 | 20 |

Usually when we write an application we often get to a point 21 | where we think, "Oh dear the libraries are wrong." What we should 22 | really do is stop work on the application, fix up the libraries then 23 | return to the application. Now while this is what we should 24 | do, we rarely do this in practice since we are keen to get the 25 | application finished.

26 | 27 |

In writing the applications I have strictly followed the 28 | principle: If In find anything wrong with the libraries, then go 29 | fix the libraries and return to the application. This of course 30 | breaks all the other application that depend on the libraries, so 31 | I've had a spend end a lot of time fixing up the breakages.

32 | 33 |

Organization

34 | 35 |
    ${ROOT}/lib/src       -- the library
36 |                       /ebin      -- compiled code
37 |            /bin                  -- runnable programs
38 | 	   /examples/XXX         -- application XXX written using the
39 |                                     library
40 |            /doc                  -- documentation
41 |   
42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /doc/glossary.ehtml: -------------------------------------------------------------------------------- 1 | 2 |

Glossary

3 | 4 |

Binary Term Sequence File

5 | 6 |

A BTSF file is a sequence of terms T1, T2, ... 7 | encoded as follows:

8 | 9 | 10 | 11 | 12 | 13 |
encode_term(T1)
encode_term(T2)
...
14 | 15 |

Where:

16 | 17 |
18 |     encode_term(Term) ->
19 |         Bin = term_to_binary(Term),
20 | 	Len = size(Bin),
21 | 	<<Len:32/big,Bin/binary>>.
22 |   
23 | 24 |

An individual term T is represented by a length count Len 25 | (A 32 bit big endian integer) followed by a Len 26 | byte binary. The binary is made by calling term_to_binary(T).

27 | 28 |

29 | Files of encoded binary terms can be read and written extremely 30 | efficiently using the routines in elib1_fast_read 31 | and elib1_fast_write. 32 |

33 | 34 |

Library modules like sort_file make use of buffered I/O to 35 | sort BTSF file very efficiently.

36 | 37 | 38 | -------------------------------------------------------------------------------- /doc/index.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |

Index

10 | 11 | auto generate 12 | the index 13 | 14 |
    15 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /doc/trawl.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Trawl files

5 |

A trawler at 6 | work. The trawler catches fish. Our trawler catches files. A trawl 7 | file is created with top-level 8 | command


> trawl Name Top

This 9 | will tug along for a while collecting a large number of files. These 10 | files are compressed ad appended to the trawl file. Trawl files are 11 | tuple files which contain {FileName, MD5, B} tuples, where B 12 | is

13 | 14 | 15 | -------------------------------------------------------------------------------- /doc/webserver.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Web Server

4 | 5 |

6 | The web server described here is used for all my experiments. It 7 | is not a fully-featured can-do-everything web 8 | server refer to yaws ... here But it is 9 | sufficient for most of my rather modest needs. 10 |

11 | 12 |

Starting the web server

13 | 14 |
    > elib1_webkit:start_web_server(Port, Root)
15 |   
16 | 17 |

Urls and callbacks

18 | 19 |
20 |
Path/to/FileName
21 |
22 |

will try and retreive Path/to/FileName. The path to 23 | the filename can be absolute (starting with "/") or relatiove 24 | (starting with anything else). ".." in a path is permitted, 25 | thjough you cannout use this to climb outside root of the 26 | server.

27 |
28 |
/mod?mod=ModName&func=Func&arg1=...
29 |
30 |

This is where life gets interesting. 31 | /mod?mod=foo?func=bar&x=1&y=2 will try to 32 | evaluate the code in foo.beam (which will be autoloaded) 33 | necessary. It will call foo:bar(...)handle/3

34 |
35 |
36 | 37 |

handle/3

38 | 39 |
40 |
handle(Op, Headers, Uri, Args)
41 |
42 |

This must return:

43 |
    44 |
  • {ok, Type, Content}

  • 45 |
  • {error, Code}

  • 46 |
47 |
48 |
49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /include/354984si.ngl.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/include/354984si.ngl.gz -------------------------------------------------------------------------------- /include/dtd/catalog.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /include/dtd/readdme.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | Readme 7 | 8 | 9 | 10 | 11 | 13 | 14 | 15 |

Readme

16 | 17 | 18 |

Validation

19 | 20 |

XML and HTML are validated with the command:

21 |
22 |       > xml_check <File>
23 |     
24 | 25 |

xml_check is as follows:

26 | 27 |
28 | #!/bin/sh
29 | export XML_CATALOG_FILES=$HOME/code/elib2-1/dtd/catalog.xml
30 | unset SGML_CATALOG_FILES
31 | xmllint  --nonet --valid --noout  $1
32 |     
33 | 34 |

The environemnt variable must point to this directory.

35 | 36 |

catalog.xml also contains some absolut paths 37 | which must be edited to reflect the absolute location of the 38 | DTD files.

39 | 40 |

The nXML mode is used for all XML/HTML editing. It is setup as 41 | follows:

42 | 43 |

How do I setup xmllint to validate xhtml?

44 | 45 |

Well actually it does :-)

46 | 47 |
48 |       xmllint --valid --noout html1.html
49 |     
50 | 51 |
52 |       xmllint --valid --noout --nonet html1.html
53 |       Validation failed: no DTD found !
54 |     
55 | 56 |

Which means we can validate but not offline

57 | 58 | 59 |
60 |       wget http:
61 |     
62 | 63 |
64 |       wget http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
65 |     
66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /include/dtd/xml_check: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export XML_CATALOG_FILES=$HOME/code/elib2-1/dtd/catalog.xml 3 | unset SGML_CATALOG_FILES 4 | unset XML_DEBUG_CATALOG 5 | xmllint --nonet --valid --noout $1 6 | 7 | -------------------------------------------------------------------------------- /include/elib1.css: -------------------------------------------------------------------------------- 1 | body {margin-left:2in; width:60%; font-size:1.2em} 2 | 3 | @font-face{ 4 | font-family: 'handwriting'; 5 | src: url('dkg.ttf'); 6 | font-style:normal; 7 | font-weight:normal} 8 | 9 | .hand { font-family: handwriting} 10 | 11 | b {font-weight:bold; font-family: courier} 12 | 13 | h1, h2, h3, p, td { font-family: serif;} 14 | 15 | h1{font-size:2.5em; 16 | text-align:right; 17 | margin-top:1.5in; 18 | margin-bottom:0.8in} 19 | 20 | h2{ font-size:1em; display:block; clear:both; } 21 | 22 | h3{ font-size:0.75em; color:#777; margin-bottom:0;} 23 | 24 | dd > p:first-child { margin-top:0} 25 | 26 | 27 | h3 + p{ margin-top:0;} 28 | 29 | tt { font-weight:bold } 30 | 31 | // td { border: 1px solid black } 32 | // table {border-collapse:collapse} 33 | 34 | p { text-align:justify } 35 | 36 | p:hover, li:hover 37 | { text-shadow: #ccc 2px 2px 5px; 38 | color:#E20074; 39 | } 40 | 41 | div.note { background-color: silver; 42 | border: solid thin #666666; 43 | margin: 35px; 44 | padding: 12px} 45 | 46 | div.author {color: blue} 47 | 48 | div.ed {color: red} 49 | 50 | pre {margin: 30px; 51 | font-family:courier; 52 | font-size:0.8em; 53 | font-weight: bold} 54 | 55 | -------------------------------------------------------------------------------- /include/images/dir_icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/include/images/dir_icon.jpg -------------------------------------------------------------------------------- /include/images/dir_icon_thumb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/include/images/dir_icon_thumb.jpg -------------------------------------------------------------------------------- /include/images/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/include/images/github.png -------------------------------------------------------------------------------- /include/images/joe.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/include/images/joe.jpg -------------------------------------------------------------------------------- /include/images/joe_thumb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/include/images/joe_thumb.jpg -------------------------------------------------------------------------------- /include/images/pdf_icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/include/images/pdf_icon.jpg -------------------------------------------------------------------------------- /include/images/pdf_icon_thumb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/include/images/pdf_icon_thumb.jpg -------------------------------------------------------------------------------- /include/images/ring.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/include/images/ring.gif -------------------------------------------------------------------------------- /include/images/ringtxt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/include/images/ringtxt.jpg -------------------------------------------------------------------------------- /include/jquery-slides.js: -------------------------------------------------------------------------------- 1 | 2 | $(document).ready(function(){ 3 | var n = 0; 4 | var next=n; 5 | 6 | $(window).keydown(function(e){ 7 | switch(e.keyCode){ 8 | case 37: next = 0; break; 9 | case 38: if(n > 0)next = n-1; break; 10 | case 39: next = size -1; break; 11 | case 40: if(n < size-1) next = n+1; break; 12 | default: break; 13 | }; 14 | if(n != next){ 15 | slides.eq(n).hide(); 16 | slides.eq(next).show(); 17 | }; 18 | n = next; 19 | }); 20 | 21 | var slides=$('.slide'); 22 | var size = slides.size(); 23 | $('.slide').hide(); 24 | 25 | // show the first slide 26 | slides.eq(n).show(); 27 | 28 | }); 29 | -------------------------------------------------------------------------------- /include/plain.css: -------------------------------------------------------------------------------- 1 | 2 | h1, h2, h3, p, td { 3 | font-family: serif; 4 | } 5 | 6 | 7 | h1{ font-size:1.2em } 8 | 9 | h3{ font-size:0.75em; color:#777; margin-bottom:0;} 10 | 11 | h3 + p{ margin-top:0;} 12 | 13 | h2{ font-size:1em; display:block; clear:both; } 14 | 15 | td + td + td, 16 | th + th + th{ text-align:left; } 17 | 18 | tt { font-weight:bold } 19 | 20 | 21 | td { border: 1px solid black } 22 | table {border-collapse:collapse} 23 | 24 | 25 | *.myhover 26 | { text-shadow: #ccc 2px 2px 5px; 27 | color:#E20074; 28 | } 29 | 30 | p { text-align:justify } 31 | /* structured text styles */ 32 | 33 | body {margin-left:2in; width:60%} 34 | 35 | h1{ font-size:1.2em } 36 | 37 | h3{ font-size:0.75em; color:#777; margin-bottom:0;} 38 | 39 | h3 + p{ margin-top:0;} 40 | 41 | h2{ font-size:1em; display:block; clear:both; } 42 | 43 | td + td + td, 44 | th + th + th{ text-align:left; } 45 | 46 | tt { font-weight:bold } 47 | 48 | 49 | td { border: 1px solid black } 50 | table {border-collapse:collapse} 51 | 52 | pre { 53 | margin: 1em; 54 | font-weight: bold; 55 | background-color: #FED; 56 | border-style: solid; 57 | border-width: 1px; 58 | -webkit-border-radius: .5em; 59 | -moz-border-radius: .5em; 60 | border-color: #48C; 61 | padding: 0.5em; 62 | font-size: 120%; 63 | overflow: auto; 64 | } 65 | 66 | 67 | body { font-size:1.2em; } 68 | 69 | p { text-align:justify } 70 | 71 | 72 | *.hover 73 | { text-shadow: #ccc 2px 2px 5px; 74 | color:#E20074; 75 | } 76 | -------------------------------------------------------------------------------- /include/slides.css: -------------------------------------------------------------------------------- 1 | h1 { text-align: center; font-size:1.5em } 2 | 3 | .slide { 4 | padding: 0.5em 2em 0em 2em; 5 | display: block; 6 | border: 1px solid black; 7 | background: #ffddee; 8 | width: 90%; 9 | height: 90%; 10 | font-size: x-large; 11 | } 12 | 13 | p {text-align:justify} 14 | 15 | ul { margin-left:1em} 16 | 17 | pre { 18 | margin: 1em; 19 | font-weight: bold; 20 | background-color: #FED; 21 | border-style: solid; 22 | border-width: 1px; 23 | -webkit-border-radius: .5em; 24 | -moz-border-radius: .5em; 25 | border-color: #48C; 26 | padding: 0.5em; 27 | font-size: 100%; 28 | } 29 | 30 | .right {position: absolute; left:50%; top:100px;} 31 | .middle {position: absolute; left:33%; top:100px;} 32 | .farright {position: absolute; left:70%; top:100px;} 33 | 34 | td { border: 2px solid black; padding:5px; } 35 | table {border-collapse:collapse} 36 | -------------------------------------------------------------------------------- /lib/doc/edoc-info: -------------------------------------------------------------------------------- 1 | {packages,[]}. 2 | {modules,[tryxform]}. 3 | -------------------------------------------------------------------------------- /lib/doc/elib1_best.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_best 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_best

12 | 13 | 14 | 15 |

Function Index

16 | 17 |
fac/1fac(N) computes factorial(N) using a fast iterative algorithm.
18 | 19 |

Function Details

20 | 21 |

fac/1

22 |
23 |

fac(N) -> any()

24 |

fac(N) computes factorial(N) using a fast iterative algorithm. [7]

25 |
26 | 27 | 28 |

Generated by EDoc, Dec 9 2009, 19:02:40.

29 | 30 | 31 | -------------------------------------------------------------------------------- /lib/doc/elib1_blob_store.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_blob_store 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_blob_store

12 | 13 | 14 | 15 |

Function Index

16 | 17 | 18 | 19 | 20 | 21 |
close/0
fetch/1
keys/0
open/1
store/2
22 | 23 |

Function Details

24 | 25 |

close/0

26 |
27 |

close() -> any()

28 |
29 | 30 |

fetch/1

31 |
32 |

fetch(Key) -> any()

33 |
34 | 35 |

keys/0

36 |
37 |

keys() -> any()

38 |
39 | 40 |

open/1

41 |
42 |

open(File) -> any()

43 |
44 | 45 |

store/2

46 |
47 |

store(Key, Blob) -> any()

48 |
49 |
50 | 51 | 52 |

Generated by EDoc, Dec 9 2009, 19:02:41.

53 | 54 | 55 | -------------------------------------------------------------------------------- /lib/doc/elib1_chunks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_chunks 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_chunks

12 | 13 | 14 |
15 | 16 | 17 |

Generated by EDoc, Dec 9 2009, 19:02:41.

18 | 19 | 20 | -------------------------------------------------------------------------------- /lib/doc/elib1_content_edit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_content_edit 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_content_edit

12 | 13 | 14 |
15 | 16 | 17 |

Generated by EDoc, Dec 9 2009, 19:02:41.

18 | 19 | 20 | -------------------------------------------------------------------------------- /lib/doc/elib1_diff.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_diff 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_diff

12 | 13 | 14 | 15 |

Function Index

16 | 17 | 18 | 19 | 20 | 21 |
diff/2
diff_files/2
patch/2
patchL/2
test/0
22 | 23 |

Function Details

24 | 25 |

diff/2

26 |
27 |

diff(Old, New) -> any()

28 |
29 | 30 |

diff_files/2

31 |
32 |

diff_files(A, B) -> any()

33 |
34 | 35 |

patch/2

36 |
37 |

patch(New, Patch) -> any()

38 |
39 | 40 |

patchL/2

41 |
42 |

patchL(New, Patches) -> any()

43 |
44 | 45 |

test/0

46 |
47 |

test() -> any()

48 |
49 |
50 | 51 | 52 |

Generated by EDoc, Dec 9 2009, 19:02:41.

53 | 54 | 55 | -------------------------------------------------------------------------------- /lib/doc/elib1_doc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_doc 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_doc

12 | 13 | 14 | 15 |

Function Index

16 | 17 | 18 | 19 | 20 |
batch/1
file/1
file/2
setup/1
21 | 22 |

Function Details

23 | 24 |

batch/1

25 |
26 |

batch(X1) -> any()

27 |
28 | 29 |

file/1

30 |
31 |

file(F) -> any()

32 |
33 | 34 |

file/2

35 |
36 |

file(InFile, OutFile) -> any()

37 |
38 | 39 |

setup/1

40 |
41 |

setup(File) -> any()

42 |
43 |
44 | 45 | 46 |

Generated by EDoc, Dec 9 2009, 19:02:41.

47 | 48 | 49 | -------------------------------------------------------------------------------- /lib/doc/elib1_ensure_copyrighted.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_ensure_copyrighted 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_ensure_copyrighted

12 | 13 | 14 |
15 | 16 | 17 |

Generated by EDoc, Dec 9 2009, 19:02:42.

18 | 19 | 20 | -------------------------------------------------------------------------------- /lib/doc/elib1_fast_write.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_fast_write 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_fast_write

12 | 13 | 14 | 15 |

Function Index

16 | 17 | 18 | 19 | 20 |
close/1Close stream.
new/1Create a new stream.
new/2
write/2write(Stream, Term) -> newStream.
21 | 22 |

Function Details

23 | 24 |

close/1

25 |
26 |

close(X1) -> any()

27 |

Close stream

28 | 29 |

new/1

30 |
31 |

new(File) -> any()

32 |

Create a new stream

33 | 34 |

new/2

35 |
36 |

new(File, N) -> any()

37 |
38 | 39 |

write/2

40 |
41 |

write(X1, Term) -> any()

42 |

write(Stream, Term) -> newStream.

43 |
44 | 45 | 46 |

Generated by EDoc, Dec 9 2009, 19:02:42.

47 | 48 | 49 | -------------------------------------------------------------------------------- /lib/doc/elib1_file_finder.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_file_finder 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_file_finder

12 | 13 | 14 | 15 |

Function Index

16 | 17 | 18 |
foldl/4
test/1
19 | 20 |

Function Details

21 | 22 |

foldl/4

23 |
24 |

foldl(Top, F, A, Follow) -> any()

25 |
26 | 27 |

test/1

28 |
29 |

test(X1) -> any()

30 |
31 |
32 | 33 | 34 |

Generated by EDoc, Dec 9 2009, 19:02:43.

35 | 36 | 37 | -------------------------------------------------------------------------------- /lib/doc/elib1_geom.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_geom 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_geom

12 | 13 | 14 |
15 | 16 | 17 |

Generated by EDoc, Dec 9 2009, 19:02:43.

18 | 19 | 20 | -------------------------------------------------------------------------------- /lib/doc/elib1_guid_store.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_guid_store 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_guid_store

12 | 13 | 14 | 15 |

Function Index

16 | 17 | 18 | 19 | 20 |
fetch/1
fetch/2
store/1
test/0
21 | 22 |

Function Details

23 | 24 |

fetch/1

25 |
26 |

fetch(Guid) -> any()

27 |
28 | 29 |

fetch/2

30 |
31 |

fetch(Guid, N) -> any()

32 |
33 | 34 |

store/1

35 |
36 |

store(Assoc) -> any()

37 |
38 | 39 |

test/0

40 |
41 |

test() -> any()

42 |
43 |
44 | 45 | 46 |

Generated by EDoc, Dec 9 2009, 19:02:43.

47 | 48 | 49 | -------------------------------------------------------------------------------- /lib/doc/elib1_indexer.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/lib/doc/elib1_indexer.html -------------------------------------------------------------------------------- /lib/doc/elib1_indexer_plugin_erl.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_indexer_plugin_erl 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_indexer_plugin_erl

12 | 13 | 14 | 15 |

Function Index

16 | 17 | 18 | 19 | 20 |
file/1
frequencies/1
strings/1
tokenise_string/1
21 | 22 |

Function Details

23 | 24 |

file/1

25 |
26 |

file(F) -> any()

27 |
28 | 29 |

frequencies/1

30 |
31 |

frequencies(Str) -> any()

32 |
33 | 34 |

strings/1

35 |
36 |

strings(Str) -> any()

37 |
38 | 39 |

tokenise_string/1

40 |
41 |

tokenise_string(Str) -> any()

42 |
43 |
44 | 45 | 46 |

Generated by EDoc, Dec 9 2009, 19:02:44.

47 | 48 | 49 | -------------------------------------------------------------------------------- /lib/doc/elib1_indexer_results.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_indexer_results 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_indexer_results

12 | 13 | 14 |
15 | 16 | 17 |

Generated by EDoc, Dec 9 2009, 19:02:44.

18 | 19 | 20 | -------------------------------------------------------------------------------- /lib/doc/elib1_ml9_2_html.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_ml9_2_html 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_ml9_2_html

12 | 13 | 14 | 15 |

Function Index

16 | 17 | 18 |
exec/2
get_data/2
19 | 20 |

Function Details

21 | 22 |

exec/2

23 |
24 |

exec(File, Parse) -> any()

25 |
26 | 27 |

get_data/2

28 |
29 |

get_data(X, Default) -> any()

30 |
31 |
32 | 33 | 34 |

Generated by EDoc, Dec 9 2009, 19:02:45.

35 | 36 | 37 | -------------------------------------------------------------------------------- /lib/doc/elib1_porter.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_porter 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_porter

12 | 13 | 14 | 15 |

Function Index

16 | 17 | 18 | 19 |
stem/1
test/0
tst/3
20 | 21 |

Function Details

22 | 23 |

stem/1

24 |
25 |

stem(In::string()) -> Out::string()

26 |
27 | 28 |

test/0

29 |
30 |

test() -> any()

31 |
32 | 33 |

tst/3

34 |
35 |

tst(Ins, Outs, N) -> any()

36 |
37 |
38 | 39 | 40 |

Generated by EDoc, Dec 9 2009, 19:02:46.

41 | 42 | 43 | -------------------------------------------------------------------------------- /lib/doc/elib1_screen.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_screen 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_screen

12 | 13 | 14 |
15 | 16 | 17 |

Generated by EDoc, Dec 9 2009, 19:02:46.

18 | 19 | 20 | -------------------------------------------------------------------------------- /lib/doc/elib1_search.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_search 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_search

12 | 13 | 14 |
15 | 16 | 17 |

Generated by EDoc, Dec 9 2009, 19:02:46.

18 | 19 | 20 | -------------------------------------------------------------------------------- /lib/doc/elib1_seq_web_server1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_seq_web_server1 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_seq_web_server1

12 | 13 | 14 | 15 |

Function Index

16 | 17 | 18 | 19 |
default_response/2
pre/1
start/3
20 | 21 |

Function Details

22 | 23 |

default_response/2

24 |
25 |

default_response(F, Args) -> any()

26 |
27 | 28 |

pre/1

29 |
30 |

pre(X) -> any()

31 |
32 | 33 |

start/3

34 |
35 |

start(Mod, DB, Args) -> any()

36 |
37 |
38 | 39 | 40 |

Generated by EDoc, Dec 9 2009, 19:02:46.

41 | 42 | 43 | -------------------------------------------------------------------------------- /lib/doc/elib1_sha1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_sha1 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_sha1

12 | 13 | 14 | 15 |

Function Index

16 | 17 | 18 |
binstring/1
hexstring/1
19 | 20 |

Function Details

21 | 22 |

binstring/1

23 |
24 |

binstring(S) -> any()

25 |
26 | 27 |

hexstring/1

28 |
29 |

hexstring(S) -> any()

30 |
31 |
32 | 33 | 34 |

Generated by EDoc, Dec 9 2009, 19:02:47.

35 | 36 | 37 | -------------------------------------------------------------------------------- /lib/doc/elib1_similar.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_similar 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_similar

12 | 13 | 14 | 15 |

Function Index

16 | 17 | 18 |
batch_find_similar/1
find_similar_files/1
19 | 20 |

Function Details

21 | 22 |

batch_find_similar/1

23 |
24 |

batch_find_similar(X1) -> any()

25 |
26 | 27 |

find_similar_files/1

28 |
29 |

find_similar_files(Base) -> any()

30 |
31 |
32 | 33 | 34 |

Generated by EDoc, Dec 9 2009, 19:02:47.

35 | 36 | 37 | -------------------------------------------------------------------------------- /lib/doc/elib1_simple_kv_db.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_simple_kv_db 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_simple_kv_db

12 | 13 | 14 | 15 |

Function Index

16 | 17 |
start_link/1
18 | 19 |

Function Details

20 | 21 |

start_link/1

22 |
23 |

start_link(X1) -> any()

24 |
25 |
26 | 27 | 28 |

Generated by EDoc, Dec 9 2009, 19:02:47.

29 | 30 | 31 | -------------------------------------------------------------------------------- /lib/doc/elib1_telnet.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_telnet 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_telnet

12 | 13 | 14 |
15 | 16 | 17 |

Generated by EDoc, Dec 9 2009, 19:02:48.

18 | 19 | 20 | -------------------------------------------------------------------------------- /lib/doc/elib1_webquery.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module elib1_webquery 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module elib1_webquery

12 | 13 | 14 |
15 | 16 | 17 |

Generated by EDoc, Dec 9 2009, 19:02:48.

18 | 19 | 20 | -------------------------------------------------------------------------------- /lib/doc/erlang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/lib/doc/erlang.png -------------------------------------------------------------------------------- /lib/doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Overview 5 | 6 | 7 | 8 | 9 | 10 | 11 | <h2>This page uses frames</h2> 12 | <p>Your browser does not accept frames. 13 | <br>You should go to the <a href="overview-summary.html">non-frame version</a> instead. 14 | </p> 15 | 16 | 17 | -------------------------------------------------------------------------------- /lib/doc/modules-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Overview 5 | 6 | 7 | 8 |

Modules

9 | 10 |
tryxform
11 | 12 | -------------------------------------------------------------------------------- /lib/doc/overview-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Overview 5 | 6 | 7 | 8 | 9 |

Overview

10 | 11 |
12 | 13 |

Generated by EDoc, Dec 9 2009, 19:02:49.

14 | 15 | 16 | -------------------------------------------------------------------------------- /lib/doc/packages-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Overview 5 | 6 | 7 | 8 |

Packages

9 |
10 | 11 | -------------------------------------------------------------------------------- /lib/doc/password.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module password 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module password

12 | 13 | 14 | 15 |

Function Index

16 | 17 | 18 |
password/1
username/1
19 | 20 |

Function Details

21 | 22 |

password/1

23 |
24 |

password(X1) -> any()

25 |
26 | 27 |

username/1

28 |
29 |

username(X1) -> any()

30 |
31 |
32 | 33 | 34 |

Generated by EDoc, Dec 9 2009, 19:02:49.

35 | 36 | 37 | -------------------------------------------------------------------------------- /lib/doc/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* standard EDoc style sheet */ 2 | body { 3 | font-family: Verdana, Arial, Helvetica, sans-serif; 4 | margin-left: .25in; 5 | margin-right: .2in; 6 | margin-top: 0.2in; 7 | margin-bottom: 0.2in; 8 | color: #000000; 9 | background-color: #ffffff; 10 | } 11 | h1,h2 { 12 | margin-left: -0.2in; 13 | } 14 | div.navbar { 15 | background-color: #add8e6; 16 | padding: 0.2em; 17 | } 18 | h2.indextitle { 19 | padding: 0.4em; 20 | background-color: #add8e6; 21 | } 22 | h3.function,h3.typedecl { 23 | background-color: #add8e6; 24 | padding-left: 1em; 25 | } 26 | div.spec { 27 | margin-left: 2em; 28 | background-color: #eeeeee; 29 | } 30 | a.module,a.package { 31 | text-decoration:none 32 | } 33 | a.module:hover,a.package:hover { 34 | background-color: #eeeeee; 35 | } 36 | ul.definitions { 37 | list-style-type: none; 38 | } 39 | ul.index { 40 | list-style-type: none; 41 | background-color: #eeeeee; 42 | } 43 | 44 | /* 45 | * Minor style tweaks 46 | */ 47 | ul { 48 | list-style-type: square; 49 | } 50 | table { 51 | border-collapse: collapse; 52 | } 53 | td { 54 | padding: 3 55 | } 56 | -------------------------------------------------------------------------------- /lib/doc/tryxform.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Module tryxform 5 | 6 | 7 | 8 | 9 |
10 | 11 |

Module tryxform

12 | 13 | 14 |
15 | 16 | 17 |

Generated by EDoc, Dec 9 2009, 19:02:49.

18 | 19 | 20 | -------------------------------------------------------------------------------- /lib/ebin/README: -------------------------------------------------------------------------------- 1 | This directory has beam code 2 | -------------------------------------------------------------------------------- /lib/src/Makefile: -------------------------------------------------------------------------------- 1 | .SUFFIXES: .erl .beam .yrl 2 | 3 | MODS := $(wildcard *.erl) 4 | YRL := $(wildcard *.yrl) 5 | CHAPS := $(wildcard *.chap) 6 | BOOKS := $(wildcard *.book) 7 | LOGS := $(wildcard *.log) 8 | 9 | CWD := $(shell pwd) 10 | 11 | ../ebin/%.beam: %.erl 12 | ## erlc +warn_missing_spec -o ../ebin -W $< 13 | ## grep --silent --invert-match "_test" 14 | erlc -o ../ebin -W $< 15 | 16 | ../ebin/%.beam: ../tmp/%.erl 17 | erlc -o ../ebin -W $< 18 | 19 | ../doc/%.html: %.chap 20 | @erl -noshell -pa ../ebin -s elib1_docmaker batch $< -s init stop 21 | 22 | ../doc/%.html: %.log 23 | @erl -noshell -pa ../ebin -s elib1_chunks batch $< -s init stop 24 | 25 | ../doc/%.html: %.erl 26 | ./mkdoc $< 27 | 28 | ../tmp/%.erl: %.yrl 29 | erlc -o ../tmp -W $< 30 | 31 | ../../pdf/%.pdf: %.chap 32 | erl -s elib1_doc batch $< 33 | fop -xml ../tmp/$*.xml -xsl chap2pdf.xsl -pdf ../../pdf/$*.pdf 34 | 35 | # ../../html/%.html: %.chap 36 | # erl -s elib1_doc batch $< 37 | # fop -xml ../tmp/$*.xml -xsl chap2html.xsl -txt ../../html/$*.html 38 | 39 | all: yecc beam html #chapHTML 40 | 41 | test: 42 | dialyzer -Wno_return --src -c "." 43 | 44 | utest: beam 45 | erl -noshell -eval "eunit:test(elib1_misc, [verbose])" -s init stop 46 | 47 | edoc: 48 | erl -noshell -eval "edoc:application(lib, \".\", [{dir,\"../doc\"}])" \ 49 | -s init stop 50 | 51 | html: ${MODS:%.erl=../doc/%.html} 52 | 53 | beam: ${MODS:%.erl=../ebin/%.beam} 54 | 55 | yecc: ${YRL:%.yrl=../tmp/%.erl} ${YRL:%.yrl=../ebin/%.beam} 56 | 57 | chapPDF: ${CHAPS:%.chap=../../pdf/%.pdf} 58 | 59 | # chapHTML: ${CHAPS:%.chap=../../html/%.html} 60 | 61 | books: ${BOOKS:%.book=../doc/%.html} 62 | 63 | logs: ${LOGS:%.log=../doc/%.html} 64 | 65 | clean: 66 | rm -rf ../ebin/*.beam 67 | rm -rf ../doc/*.beam 68 | rm -rf *.aux *.beam 69 | rm -rf *.log *.tmp erl_crash.dump 70 | 71 | veryclean: 72 | rm ../bin/* ../doc/* ../tmp/* 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /lib/src/elib1_best.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | %% ^ [4] 5 | 6 | -module(elib1_best). %% [1] 7 | 8 | %% elib1_best: Best practice template for library modules [2] 9 | %% Time-stamp: <2009-12-02 12:28:04 ejoearm> [3] 10 | 11 | -include_lib("eunit/include/eunit.hrl"). %% [5] 12 | 13 | -export([fac/1]). %% [6] 14 | 15 | 16 | %% @doc fac(N) computes factorial(N) using a fast iterative algorithm. [7] 17 | 18 | -spec fac(non_neg_integer()) -> non_neg_integer(). %% [8] 19 | 20 | fac(N) when is_integer(N), N >= 0 -> fac1(N, 1). 21 | 22 | fac1(0, K) -> K; 23 | fac1(N, K) -> fac1(N-1, K*N). 24 | 25 | fac_test() -> %% [9] 26 | 6 = fac(3), 27 | 24 = fac(4). 28 | 29 | %% Notes: 30 | %% [1] - module on line 1 31 | %% [2] - module comment 32 | %% [3] - Time stamp auto genertaed by emacs. Must be near start of file 33 | %% [4] - Copyright (I always forget this, but adding a ciopyright reduces 34 | %% the pain later 35 | %% [5] - Needed for eunit 36 | %% [6] - use export and NOT compile(export_all) 37 | %% [7] - @doc comes first 38 | %% [8] - -spec comes immediately *before* the function 39 | %% [9] - test cases come immediatly after the function 40 | 41 | %% end of module 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /lib/src/elib1_blob_store.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_blob_store). 5 | 6 | %% The guid store is a two level store 7 | %% 8 | %% M:init(File) 9 | %% M:store(Key, Blob) 10 | %% M:fetch(Key) -> Blob raises eNoKey 11 | %% M:keys() -> [Key] 12 | 13 | -export([open/1, close/0, fetch/1, store/2, keys/0]). 14 | 15 | open(File) -> 16 | %% io:format("dets opened:~p~n", [File]), 17 | case dets:open_file(?MODULE, [{file, File}]) of 18 | {ok, ?MODULE} -> 19 | true; 20 | {error,_Reason} -> 21 | io:format("cannot open dets table~n"), 22 | exit(eDetsOpen) 23 | end. 24 | 25 | close() -> dets:close(?MODULE). 26 | 27 | store(Key, Blob) when is_binary(Blob) -> 28 | %% io:format("storing blob key=~p size=~p~n",[Key,size(Blob)]), 29 | ok = dets:insert(?MODULE, [{Key,Blob}]). 30 | 31 | fetch(Key) -> 32 | case dets:lookup(?MODULE, Key) of 33 | [] -> error; 34 | [{_,Blob}] -> {ok, Blob} 35 | end. 36 | 37 | keys() -> 38 | %% I guess there is a better way of doing this ... 39 | dets:foldl(fun({K,_},A) -> [K|A] end,[],?MODULE). 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /lib/src/elib1_doc.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_doc). 5 | 6 | %% -compile(export_all). 7 | -export([batch/1, file/1, file/2, setup/1]). 8 | 9 | %% takes a file like this ... 10 | %% strips the header and replaces with a valid xhml header 11 | %% expands ... 12 | 13 | -import(lists, [map/2, reverse/1, reverse/2]). 14 | 15 | batch([X]) -> 16 | File = filename:rootname(atom_to_list(X)), 17 | file(File). 18 | 19 | %% file converts F.ehtml to F.html in the same directory 20 | 21 | file(F) -> 22 | io:format("elib1_doc::~s~n",[F]), 23 | file(F ++ ".ehtml", F ++ ".html"). 24 | 25 | file(InFile, OutFile) -> 26 | case file:read_file(InFile) of 27 | {ok, Bin} -> 28 | Str1 = binary_to_list(Bin), 29 | Str2 = remove_top_level_markup(Str1), 30 | Str3 = elib1_expand:expand_string(Str2), 31 | Str4 = add_xhtml_markup(InFile, Str3), 32 | file:write_file(OutFile, Str4); 33 | _ -> 34 | cannot_read_file 35 | end. 36 | 37 | remove_top_level_markup("" ++ T) -> remove_top_level_markup(T, []). 38 | 39 | remove_top_level_markup("" ++ _, L) -> reverse(L); 40 | remove_top_level_markup([H|T], L) -> remove_top_level_markup(T, [H|L]). 41 | 42 | add_xhtml_markup(File, L) -> 43 | Root = filename:rootname(filename:basename(File)), 44 | [<<" 46 | \n">>, 47 | setup(Root), 48 | L, 49 | <<"\n">>]. 50 | 51 | setup(File) -> 52 | [" 53 | ", File, " 54 | 55 | 56 | 57 | edit 59 | 60 | "]. 61 | -------------------------------------------------------------------------------- /lib/src/elib1_ensure_copyrighted.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_ensure_copyrighted). 5 | -compile(export_all). 6 | 7 | start() -> 8 | L = elib1_find:files(elib1_misc:root_dir(), "*.erl", true), 9 | [ensure_copyrighted(I, copyright()) || I <- L]. 10 | 11 | ensure_copyrighted(F, C) -> 12 | L = elib1_misc:file2lines(F), 13 | %% io:format("L=~p~n",[L]), 14 | fix(L, C, F). 15 | 16 | fix([C1,C2|_], [C1, C2], File) -> 17 | io:format("~p ok~n", [File]); 18 | fix(["%% Copyright " ++ _, C2|T], [C1,C2], File) -> 19 | %% change an old copyright 20 | create(File, [C1,C2,"\n"|T]); 21 | fix(T, [C1,C2], File) -> 22 | create(File, [C1,C2,"\n"|T]). 23 | 24 | create(File, L) -> 25 | io:format("Updating:~p~n",[File]), 26 | file:write_file(File, L). 27 | 28 | 29 | copyright() -> 30 | ["%% Copyright (c) 2006-2009 Joe Armstrong\n", 31 | "%% See MIT-LICENSE for licensing information.\n"]. 32 | -------------------------------------------------------------------------------- /lib/src/elib1_fast_write.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_fast_write). 5 | -export([new/1, new/2, write/2, close/1]). 6 | 7 | %% default is to buffer 32 KB 8 | 9 | %% new(File, [#Buffers]) -> Buffer 10 | %% write(Buffer, Term) -> Buffer' 11 | %% close(Buff) -> {#TermsWritten,#bytesWritten} 12 | 13 | -type stream() :: {iow, 14 | file:io_device(), 15 | integer(), 16 | integer(), 17 | integer(), 18 | integer(), 19 | [byte()]}. 20 | 21 | %%---------------------------------------------------------------------- 22 | %% @doc Create a new stream 23 | 24 | -spec new(FileName::string()) -> stream(). 25 | 26 | new(File) -> 27 | new(File, 8). 28 | 29 | new(File, N) -> 30 | %% N is in units of 4096 bytes 31 | {ok, Stream} = file:open(File, 32 | [write,binary,raw,delayed_write]), 33 | {iow,Stream,0,0,0,N*4096,[]}. 34 | 35 | %% Data structure = {iow,Stream,N,W,Max,L} 36 | %% N = number of bytes in the buffer 37 | %% W = total bytes written 38 | %% T = number of terms written 39 | %% Max = Max size of buffer 40 | %% L = Buffer 41 | 42 | %%---------------------------------------------------------------------- 43 | %% @doc write(Stream, Term) -> newStream. 44 | 45 | -spec write(stream(), any()) -> stream(). 46 | 47 | write({iow,Stream,N,W,T,Max,L}, Term) -> 48 | B = term_to_binary(Term), 49 | Size = size(B), 50 | L1 = [L,<>,B], 51 | N1 = N + Size + 4, 52 | W1 = W + Size + 4, 53 | T1 = T + 1, 54 | if 55 | N1 > Max -> 56 | ok = file:write(Stream, L1), 57 | {iow, Stream,0,W1,T1,Max,[]}; 58 | true -> 59 | {iow, Stream,N1,W1,T1,Max,L1} 60 | end. 61 | 62 | %%---------------------------------------------------------------------- 63 | %% @doc Close stream 64 | 65 | -spec close(stream()) -> 66 | {NumberOfTermsWritten::integer(), NumberOfBytesWritten::integer()}. 67 | 68 | 69 | close({iow,Stream,0,W,T,_,_}) -> 70 | file:close(Stream), 71 | {T,W}; 72 | close({iow,Stream,_,W,T,_,L}) -> 73 | file:write(Stream, L), 74 | file:close(Stream), 75 | {T,W}. 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /lib/src/elib1_geom.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_geom). 5 | 6 | -compile(export_all). 7 | 8 | %% intersect(L1, L2) -> Bool. 9 | 10 | intersect({line,{X1,Y1},{X2,Y2}},{line,{X3,Y3},{X4,Y4}}) -> 11 | Denom = (Y4-Y3)*(X2-X1) - (X4-X3)*(Y2-Y1), 12 | if 13 | Denom == 0 -> 14 | false; 15 | true -> 16 | Ua = (X4-X3)*(Y1-Y3) - (Y4-Y3)*(X1-X3), 17 | if 18 | Ua >= 0, Ua =< 1 -> 19 | Ub = (X2-X1)*(Y1-Y3) - (Y2-Y1)*(X1-X3), 20 | if 21 | Ub >= 0, Ub =< 1 -> 22 | true; 23 | true -> 24 | false 25 | end; 26 | true -> 27 | false 28 | end 29 | end. 30 | %% http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ 31 | -------------------------------------------------------------------------------- /lib/src/elib1_indexer_results.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_indexer_results). 5 | -compile(export_all). 6 | -import(elib1_misc, [time_fun/2]). 7 | 8 | test() -> 9 | q(medium, "hypot lists"). 10 | 11 | q(Name, Str) -> 12 | time_fun("query", 13 | fun() -> 14 | Dets = atom_to_list(Name) ++ ".index", 15 | {ok, result} = dets:open_file(result, {file,Dets}), 16 | Words = string:tokens(Str, " "), 17 | L1 = [q1(I) || I <- Words], 18 | L2 = intersection(L1), 19 | FileNames = [filename(I) || I <- L2], 20 | dets:close(result), 21 | io:format("~p~n",[FileNames]) 22 | end). 23 | 24 | intersection(L) -> 25 | sets:to_list(sets:intersection([sets:from_list(I) || I <- L])). 26 | 27 | filename(I) -> 28 | case dets:lookup(result, I) of 29 | [] -> error; 30 | [{I,X}] -> X 31 | end. 32 | 33 | q1(Str) -> 34 | %% io:format("lookup:~p~n",[Str]), 35 | Bin1 = list_to_binary(elib1_porter:stem(Str)), 36 | L = case dets:lookup(result, Bin1) of 37 | [] -> []; 38 | [{_,Bin2}] -> 39 | elib1_gamma:gamma_to_alist(Bin2) 40 | end, 41 | io:format("~s : ~p hits~n",[Str, length(L)]), 42 | L. 43 | -------------------------------------------------------------------------------- /lib/src/elib1_ml9_parse_header.yrl: -------------------------------------------------------------------------------- 1 | Nonterminals 2 | form kv args term record tuple_args list_args. 3 | 4 | Terminals 5 | int atom string 6 | ',' '{' '}' '[' ']' '='. 7 | 8 | Rootsymbol form. 9 | 10 | form -> record : '$1'. 11 | 12 | record -> '{' args '}' : '$2'. 13 | record -> '{' '}': []. 14 | 15 | args -> kv : ['$1']. 16 | args -> kv ',' args : ['$1'|'$3']. 17 | 18 | kv -> term '=' term : {'$1', '$3'}. 19 | 20 | term -> atom: unwrap('$1'). 21 | term -> int : unwrap('$1'). 22 | term -> string : unwrap('$1'). 23 | term -> '{' tuple_args '}': list_to_tuple('$2'). 24 | term -> '{' '}' : {}. 25 | term -> '[' ']' : []. 26 | term -> '[' list_args ']' : '$2'. 27 | 28 | 29 | tuple_args -> term: ['$1']. 30 | tuple_args -> term ',' tuple_args: ['$1'|'$3']. 31 | 32 | list_args -> term: ['$1']. 33 | list_args -> term ',' list_args: ['$1'|'$3']. 34 | 35 | Erlang code. 36 | 37 | unwrap({X,_}) -> X; 38 | unwrap({_,_,V}) -> V. 39 | -------------------------------------------------------------------------------- /lib/src/elib1_search.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_search). 5 | -compile(export_all). 6 | -import(elib1_mysql, [start/4, cmd/2, stop/1]). 7 | 8 | make_data_base() -> 9 | {ok, Pid} = start("localhost", 3306, 10 | password:username(mysql), password:password(mysql)), 11 | cmd(Pid, "use test"), 12 | cmd(Pid, "drop table if exists mods"), 13 | cmd(Pid, "create table if not exists mods (" 14 | "themod CHAR(32) not null primary key," %% don't call this mod 15 | "val mediumtext not null, fulltext(val))"), 16 | _V1 = cmd(Pid, "show tables"), 17 | V2 = cmd(Pid, "describe mods"), 18 | stop(Pid), 19 | V2. 20 | 21 | insert_erl() -> 22 | _Files = find:files(".", "*.erl", true), 23 | a. 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /lib/src/elib1_similar.erl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/lib/src/elib1_similar.erl -------------------------------------------------------------------------------- /lib/src/elib1_simple_kv_db.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_simple_kv_db). 5 | 6 | -export([start_link/1]). 7 | 8 | %% simplest of all KV database using uses dets 9 | 10 | %% Interface: 11 | %% start(Args) -> Pid 12 | %% Protocol 13 | %% Pid ! {From, {read, key}} => From ! {self(), Ret} 14 | %% Ret = {ok, V} | error 15 | %% Pid ! {From, {write, Key, Val}} => From ! {self(), ack} 16 | %% Pid ! {From, close} => From ! {self(), ack} 17 | 18 | start_link([{name,Name},{file,File}]) -> 19 | spawn_link(fun() -> run(Name, File) end). 20 | 21 | run(Name, File) -> 22 | Val = dets:open_file(Name, [{auto_save,2000}, 23 | {file,File}]), 24 | {ok, Name} = Val, 25 | io:format("Opening:~p name=~p~n",[File, Name]), 26 | loop(Name). 27 | 28 | loop(Name) -> 29 | receive 30 | {From, {read, Key}} -> 31 | From ! {self(), lookup_i(Name, Key)}, 32 | loop(Name); 33 | {From, {write, Key, Val}} -> 34 | store_i(Name, Key, Val), 35 | From ! {self(), ack}, 36 | loop(Name); 37 | {From, info} -> 38 | From ! {self(), dets:info(Name)}, 39 | loop(Name); 40 | {From, keys} -> 41 | %% all keys in the db 42 | Vals = dets:foldl(fun({Key,_}, L) -> [Key|L] end, [], Name), 43 | From ! {self(), Vals}, 44 | loop(Name); 45 | {From, close} -> 46 | dets:close(Name), 47 | From ! {self(), ack}, 48 | void; 49 | Other -> 50 | io:format("~p:unexpected message:~p~n",[?MODULE, Other]), 51 | loop(Name) 52 | end. 53 | 54 | lookup_i(Name, Key) -> 55 | Ret = case dets:lookup(Name, Key) of 56 | [{_,Val}] -> {ok, Val}; 57 | _Other -> error 58 | end, 59 | %% io:format("**real lookup ~p => ~p~n",[Key,Ret]), 60 | Ret. 61 | 62 | store_i(Name, Key, Val) -> 63 | %% io:format("**real insert:~p ~p~n",[Key,Val]), 64 | dets:insert(Name, {Key, Val}). 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /lib/src/elib1_webquery.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_webquery). 5 | -compile(export_all). 6 | 7 | qu([{"name",Collection},{"query",Str}], Root) -> 8 | Name = Collection, 9 | Dir = Root, 10 | {Hits,Pages} = elib1_indexer:q(Dir,Name,Str), 11 | L1 = [[Str," ",integer_to_list(N)," hits
"] || {Str,N} <- Hits], 12 | L2 = [["
  • ",Loc,"
  • "] || {Pos,Loc} <- Pages], 15 | {response, html, 16 | ["

    Root:",Root,"

    Query collection:",Collection," str:",Str, 17 | "

    ",L1,"

    ",L2]}. 18 | 19 | show_file([{"name",Collection},{"pos",Pos}], Root) -> 20 | Dir = Root, 21 | Name = Collection, 22 | Index = list_to_integer(Pos), 23 | {File, Val} = elib1_indexer:extract(Dir, Name, Index), 24 | {response, html, ["

    ",Val,"
    "]}. 25 | 26 | -------------------------------------------------------------------------------- /lib/src/mkdoc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env escript 2 | main([File]) -> 3 | io:format("mkdoc ~s~n",[File]), 4 | edoc:files([File], [{dir,"../doc"}]). 5 | 6 | -------------------------------------------------------------------------------- /lib/src/password.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(password). 5 | 6 | -export([username/1, password/1]). 7 | 8 | username(mysql) -> "joejoe". 9 | password(mysql) -> "joepass". 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /lib/src/slides.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
    7 |

    Highlights of the library

    8 |
      9 |
    1. Streams
    2. 10 |
    3. Fast IO
    4. 11 |
    5. Gamma encoding
    6. 12 |
    7. XML parser
    8. 13 |
    14 |
    15 | 16 |
    17 | 18 |

    Streams

    19 | 20 |

    Stream parsing is very powerful technique.

    21 | 22 |

    If F is a stream then: 23 |

      24 |
    1. {string(), F1} | eos = F()
    2. 25 |
    26 | 27 |

    Where F1 is a new stream

    28 |

    Used in elib1_xml.erl

    29 | 30 |
    31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /lib/src/tryxform.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(tryxform). 5 | -compile(export_all). 6 | 7 | test() -> 8 | L = elib1_xml:parse_file("lorem.chap"), 9 | elib1_misc:dump("tryx", L), 10 | Chapter = get_node(L, "chap"), 11 | HTML = toHTML([Chapter], [], Chapter), 12 | file:write_file("out.html",[HTML]). 13 | 14 | 15 | toHTML([{node,"chap",_,_,L}|_], Path, C) -> 16 | [<<" 17 | 19 | 20 | ">>, 21 | toHTML(L, [chap|Path], C), 22 | <<"">>]; 23 | toHTML([{node,"title",_,_,L}|T], [chap], C) -> 24 | ["", text(L), "", 25 | <<" 26 | 28 | 29 | ">>,toHTML(T, [chap], C),<<"">>]; 30 | toHTML([{node,Tag,_,_,L}|T], Path, C) -> 31 | ["<",Tag,">", 32 | toHTML(L, [Tag|Path], C), 33 | ""|toHTML(T, Path, C)]; 34 | toHTML([{raw,_,_,Str}|T], Path, C) -> 35 | [quote(Str)|toHTML(T, Path, C)]; 36 | toHTML([], _, _) -> 37 | []. 38 | 39 | text([{raw,_,_,Str}]) -> 40 | quote(Str); 41 | text(X) -> 42 | io:format("text:~p~n",[X]), 43 | "aa". 44 | 45 | quote(X) -> 46 | elib1_misc:string2html(X). 47 | 48 | get_node([{node,N,_,_,_}=X|_], N) -> X; 49 | get_node([_|T], N) -> get_node(T, N). 50 | 51 | -------------------------------------------------------------------------------- /root: -------------------------------------------------------------------------------- 1 | / -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.tmp 3 | \#* 4 | erl_parse.erl 5 | .eunit/* 6 | deps/* 7 | ebin 8 | priv/* 9 | *.o 10 | *.beam 11 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | .SUFFIXES: .erl .beam .yrl 2 | 3 | MODS := $(wildcard *.erl) 4 | YRL := $(wildcard *.yrl) 5 | CHAPS := $(wildcard *.chap) 6 | BOOKS := $(wildcard *.book) 7 | LOGS := $(wildcard *.log) 8 | 9 | CWD := $(shell pwd) 10 | 11 | ../ebin/%.beam: %.erl 12 | ## erlc +warn_missing_spec -o ../ebin -W $< 13 | ## grep --silent --invert-match "_test" 14 | erlc -o ../ebin -W $< 15 | 16 | ../ebin/%.beam: ../tmp/%.erl 17 | erlc -o ../ebin -W $< 18 | 19 | ../doc/%.html: %.chap 20 | @erl -noshell -pa ../ebin -s elib1_docmaker batch $< -s init stop 21 | 22 | ../doc/%.html: %.log 23 | @erl -noshell -pa ../ebin -s elib1_chunks batch $< -s init stop 24 | 25 | ../doc/%.html: %.erl 26 | ./mkdoc $< 27 | 28 | ../tmp/%.erl: %.yrl 29 | erlc -o ../tmp -W $< 30 | 31 | ../../pdf/%.pdf: %.chap 32 | erl -s elib1_doc batch $< 33 | fop -xml ../tmp/$*.xml -xsl chap2pdf.xsl -pdf ../../pdf/$*.pdf 34 | 35 | # ../../html/%.html: %.chap 36 | # erl -s elib1_doc batch $< 37 | # fop -xml ../tmp/$*.xml -xsl chap2html.xsl -txt ../../html/$*.html 38 | 39 | all: yecc beam html #chapHTML 40 | 41 | test: 42 | dialyzer -Wno_return --src -c "." 43 | 44 | utest: beam 45 | erl -noshell -eval "eunit:test(elib1_misc, [verbose])" -s init stop 46 | 47 | edoc: 48 | erl -noshell -eval "edoc:application(lib, \".\", [{dir,\"../doc\"}])" \ 49 | -s init stop 50 | 51 | html: ${MODS:%.erl=../doc/%.html} 52 | 53 | beam: ${MODS:%.erl=../ebin/%.beam} 54 | 55 | yecc: ${YRL:%.yrl=../tmp/%.erl} ${YRL:%.yrl=../ebin/%.beam} 56 | 57 | chapPDF: ${CHAPS:%.chap=../../pdf/%.pdf} 58 | 59 | # chapHTML: ${CHAPS:%.chap=../../html/%.html} 60 | 61 | books: ${BOOKS:%.book=../doc/%.html} 62 | 63 | logs: ${LOGS:%.log=../doc/%.html} 64 | 65 | clean: 66 | rm ../ebin/*.beam 67 | rm -rf *.aux *.beam 68 | rm -rf *.log *.tmp erl_crash.dump 69 | 70 | veryclean: 71 | rm ../bin/* ../doc/* ../tmp/* 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/book.book: -------------------------------------------------------------------------------- 1 | = An Erlang Library 2 | 3 | This book describes an Erlang library called ''elib1''. 4 | 5 | == Todo (formatting program) 6 | 7 |
      8 | + Add a diagram language (inline svg) 9 | + ~~Make the Book version~~ 10 | + ~~Make compact lists, so I can leave out the blank line in paragraphs like 11 | this~~ 12 | + ~~add processing of ''footnotes''~~ 13 | + Make commands for /bin 14 | + check that all list entries do not end with a dot. 15 | + Check that all list entries start with a big letter. 16 | + punctuation check. 17 | + ~~add "typographic quotes."~~ 18 | + Nice to make paragraphs "clickable-editable" in the browser. 19 | + Add some nive paragraph hover effect that colors paras as we move over them. Makes text easier to read. 20 |
    21 | 22 | == To do (programs) 23 | 24 |
      25 | + mysql full text searching and metadata 26 | + go through all old library adding good stuff (example topological sort) 27 | + javascript slide show from wiki markup 28 | + move over to GIT 29 | + xref 30 |
    31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/chap2html.xsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/src/chap2html.xsl -------------------------------------------------------------------------------- /src/edit.html: -------------------------------------------------------------------------------- 1 | edit 2 | 3 | 4 |
    5 | 6 | 7 |
    9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 30 | 31 |
    23 | 24 |
    28 | 29 |
    32 |
    33 |
    34 | -------------------------------------------------------------------------------- /src/elib1_best.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | %% ^ [4] 5 | 6 | -module(elib1_best). %% [1] 7 | 8 | %% elib1_best: Best practice template for library modules [2] 9 | %% Time-stamp: <2009-12-02 12:28:04 ejoearm> [3] 10 | 11 | -include_lib("eunit/include/eunit.hrl"). %% [5] 12 | 13 | -export([fac/1]). %% [6] 14 | 15 | 16 | %% @doc fac(N) computes factorial(N) using a fast iterative algorithm. [7] 17 | 18 | -spec fac(non_neg_integer()) -> non_neg_integer(). %% [8] 19 | 20 | fac(N) when is_integer(N), N >= 0 -> fac1(N, 1). 21 | 22 | fac1(0, K) -> K; 23 | fac1(N, K) -> fac1(N-1, K*N). 24 | 25 | fac_test() -> %% [9] 26 | 6 = fac(3), 27 | 24 = fac(4). 28 | 29 | %% Notes: 30 | %% [1] - module on line 1 31 | %% [2] - module comment 32 | %% [3] - Time stamp auto genertaed by emacs. Must be near start of file 33 | %% [4] - Copyright (I always forget this, but adding a ciopyright reduces 34 | %% the pain later 35 | %% [5] - Needed for eunit 36 | %% [6] - use export and NOT compile(export_all) 37 | %% [7] - @doc comes first 38 | %% [8] - -spec comes immediately *before* the function 39 | %% [9] - test cases come immediatly after the function 40 | 41 | %% end of module 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/elib1_blob_store.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_blob_store). 5 | 6 | %% The guid store is a two level store 7 | %% 8 | %% M:init(File) 9 | %% M:store(Key, Blob) 10 | %% M:fetch(Key) -> Blob raises eNoKey 11 | %% M:keys() -> [Key] 12 | 13 | -export([open/1, close/0, fetch/1, store/2, keys/0]). 14 | 15 | open(File) -> 16 | %% io:format("dets opened:~p~n", [File]), 17 | case dets:open_file(?MODULE, [{file, File}]) of 18 | {ok, ?MODULE} -> 19 | true; 20 | {error,_Reason} -> 21 | io:format("cannot open dets table~n"), 22 | exit(eDetsOpen) 23 | end. 24 | 25 | close() -> dets:close(?MODULE). 26 | 27 | store(Key, Blob) when is_binary(Blob) -> 28 | %% io:format("storing blob key=~p size=~p~n",[Key,size(Blob)]), 29 | ok = dets:insert(?MODULE, [{Key,Blob}]). 30 | 31 | fetch(Key) -> 32 | case dets:lookup(?MODULE, Key) of 33 | [] -> error; 34 | [{_,Blob}] -> {ok, Blob} 35 | end. 36 | 37 | keys() -> 38 | %% I guess there is a better way of doing this ... 39 | dets:foldl(fun({K,_},A) -> [K|A] end,[],?MODULE). 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/elib1_doc.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_doc). 5 | 6 | %% -compile(export_all). 7 | -export([batch/1, file/1, file/2, setup/1]). 8 | 9 | %% takes a file like this ... 10 | %% strips the header and replaces with a valid xhml header 11 | %% expands ... 12 | 13 | -import(lists, [map/2, reverse/1, reverse/2]). 14 | 15 | batch([X]) -> 16 | File = filename:rootname(atom_to_list(X)), 17 | file(File). 18 | 19 | %% file converts F.ehtml to F.html in the same directory 20 | 21 | file(F) -> 22 | io:format("elib1_doc::~s~n",[F]), 23 | file(F ++ ".ehtml", F ++ ".html"). 24 | 25 | file(InFile, OutFile) -> 26 | case file:read_file(InFile) of 27 | {ok, Bin} -> 28 | Str1 = binary_to_list(Bin), 29 | Str2 = remove_top_level_markup(Str1), 30 | Str3 = elib1_expand:expand_string(Str2), 31 | Str4 = add_xhtml_markup(InFile, Str3), 32 | file:write_file(OutFile, Str4); 33 | _ -> 34 | cannot_read_file 35 | end. 36 | 37 | remove_top_level_markup("" ++ T) -> remove_top_level_markup(T, []). 38 | 39 | remove_top_level_markup("" ++ _, L) -> reverse(L); 40 | remove_top_level_markup([H|T], L) -> remove_top_level_markup(T, [H|L]). 41 | 42 | add_xhtml_markup(File, L) -> 43 | Root = filename:rootname(filename:basename(File)), 44 | [<<" 46 | \n">>, 47 | setup(Root), 48 | L, 49 | <<"\n">>]. 50 | 51 | setup(File) -> 52 | [" 53 | ", File, " 54 | 55 | 56 | 57 | edit 59 | 60 | "]. 61 | -------------------------------------------------------------------------------- /src/elib1_ensure_copyrighted.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_ensure_copyrighted). 5 | -compile(export_all). 6 | 7 | start() -> 8 | L = elib1_find:files(elib1_misc:root_dir(), "*.erl", true), 9 | [ensure_copyrighted(I, copyright()) || I <- L]. 10 | 11 | ensure_copyrighted(F, C) -> 12 | L = elib1_misc:file2lines(F), 13 | %% io:format("L=~p~n",[L]), 14 | fix(L, C, F). 15 | 16 | fix([C1,C2|_], [C1, C2], File) -> 17 | io:format("~p ok~n", [File]); 18 | fix(["%% Copyright " ++ _, C2|T], [C1,C2], File) -> 19 | %% change an old copyright 20 | create(File, [C1,C2,"\n"|T]); 21 | fix(T, [C1,C2], File) -> 22 | create(File, [C1,C2,"\n"|T]). 23 | 24 | create(File, L) -> 25 | io:format("Updating:~p~n",[File]), 26 | file:write_file(File, L). 27 | 28 | 29 | copyright() -> 30 | ["%% Copyright (c) 2006-2009 Joe Armstrong\n", 31 | "%% See MIT-LICENSE for licensing information.\n"]. 32 | -------------------------------------------------------------------------------- /src/elib1_fast_write.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_fast_write). 5 | -export([new/1, new/2, write/2, close/1, stream_pos/1]). 6 | 7 | %% default is to buffer 32 KB 8 | 9 | %% new(File) -> Buffer 10 | %% new(File,NumberOfBuffers) -> Buffer 11 | %% write(Buffer, Term) -> Buffer' 12 | %% close(Buff) -> {#TermsWritten,#bytesWritten} 13 | 14 | -type stream() :: {iow, 15 | file:io_device(), 16 | integer(), 17 | integer(), 18 | integer(), 19 | integer(), 20 | [byte()]}. 21 | 22 | %%---------------------------------------------------------------------- 23 | %% @doc Create a new stream 24 | 25 | -spec new(FileName::string()) -> stream(). 26 | 27 | new(File) -> 28 | new(File, 8). 29 | 30 | new(File, N) -> 31 | %% N is in units of 4096 bytes 32 | {ok, Stream} = file:open(File, 33 | [write,binary,raw,delayed_write]), 34 | {iow,Stream,0,0,0,N*4096,[]}. 35 | 36 | %% Data structure = {iow,Stream,N,W,T,Max,L} 37 | %% Stream = io:stream 38 | %% N = number of bytes in the buffer 39 | %% W = total bytes written 40 | %% T = total number of terms written 41 | %% Max = Max size of buffer 42 | %% L = Buffer 43 | 44 | stream_pos({iow,_,_,W,_,_,_}) -> 45 | W+1. 46 | 47 | 48 | %%---------------------------------------------------------------------- 49 | %% @doc write(Stream, Term) -> newStream. 50 | 51 | -spec write(stream(), any()) -> stream(). 52 | 53 | write({iow,Stream,N,W,T,Max,L}, Term) -> 54 | B = term_to_binary(Term), 55 | Size = size(B), 56 | L1 = [L,<>,B], 57 | N1 = N + Size + 4, %% number of bytes in current buffer 58 | W1 = W + Size + 4, 59 | T1 = T + 1, 60 | if 61 | N1 > Max -> 62 | ok = file:write(Stream, L1), 63 | {iow, Stream,0,W1,T1,Max,[]}; 64 | true -> 65 | {iow, Stream,N1,W1,T1,Max,L1} 66 | end. 67 | 68 | %%---------------------------------------------------------------------- 69 | %% @doc Close stream 70 | 71 | -spec close(stream()) -> 72 | {NumberOfTermsWritten::integer(), NumberOfBytesWritten::integer()}. 73 | 74 | close({iow,Stream,0,W,T,_,_}) -> 75 | file:close(Stream), 76 | {T,W}; 77 | close({iow,Stream,_,W,T,_,L}) -> 78 | file:write(Stream, L), 79 | file:close(Stream), 80 | {T,W}. 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/elib1_geom.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_geom). 5 | 6 | -compile(export_all). 7 | 8 | %% intersect(L1, L2) -> Bool. 9 | 10 | intersect({line,{X1,Y1},{X2,Y2}},{line,{X3,Y3},{X4,Y4}}) -> 11 | Denom = (Y4-Y3)*(X2-X1) - (X4-X3)*(Y2-Y1), 12 | if 13 | Denom == 0 -> 14 | false; 15 | true -> 16 | Ua = (X4-X3)*(Y1-Y3) - (Y4-Y3)*(X1-X3), 17 | if 18 | Ua >= 0, Ua =< 1 -> 19 | Ub = (X2-X1)*(Y1-Y3) - (Y2-Y1)*(X1-X3), 20 | if 21 | Ub >= 0, Ub =< 1 -> 22 | true; 23 | true -> 24 | false 25 | end; 26 | true -> 27 | false 28 | end 29 | end. 30 | %% http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ 31 | -------------------------------------------------------------------------------- /src/elib1_indexer_results.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_indexer_results). 5 | -compile(export_all). 6 | -import(elib1_misc, [time_fun/2]). 7 | 8 | test() -> 9 | q(medium, "hypot lists"). 10 | 11 | q(Name, Str) -> 12 | time_fun("query", 13 | fun() -> 14 | Dets = atom_to_list(Name) ++ ".index", 15 | {ok, result} = dets:open_file(result, {file,Dets}), 16 | Words = string:tokens(Str, " "), 17 | L1 = [q1(I) || I <- Words], 18 | L2 = intersection(L1), 19 | FileNames = [filename(I) || I <- L2], 20 | dets:close(result), 21 | io:format("~p~n",[FileNames]) 22 | end). 23 | 24 | intersection(L) -> 25 | sets:to_list(sets:intersection([sets:from_list(I) || I <- L])). 26 | 27 | filename(I) -> 28 | case dets:lookup(result, I) of 29 | [] -> error; 30 | [{I,X}] -> X 31 | end. 32 | 33 | q1(Str) -> 34 | %% io:format("lookup:~p~n",[Str]), 35 | Bin1 = list_to_binary(elib1_porter:stem(Str)), 36 | L = case dets:lookup(result, Bin1) of 37 | [] -> []; 38 | [{_,Bin2}] -> 39 | elib1_gamma:gamma_to_alist(Bin2) 40 | end, 41 | io:format("~s : ~p hits~n",[Str, length(L)]), 42 | L. 43 | -------------------------------------------------------------------------------- /src/elib1_ml9_parse_header.yrl: -------------------------------------------------------------------------------- 1 | Nonterminals 2 | form kv args term record tuple_args list_args. 3 | 4 | Terminals 5 | int atom string 6 | ',' '{' '}' '[' ']' '='. 7 | 8 | Rootsymbol form. 9 | 10 | form -> record : '$1'. 11 | 12 | record -> '{' args '}' : '$2'. 13 | record -> '{' '}': []. 14 | 15 | args -> kv : ['$1']. 16 | args -> kv ',' args : ['$1'|'$3']. 17 | 18 | kv -> term '=' term : {'$1', '$3'}. 19 | 20 | term -> atom: unwrap('$1'). 21 | term -> int : unwrap('$1'). 22 | term -> string : unwrap('$1'). 23 | term -> '{' tuple_args '}': list_to_tuple('$2'). 24 | term -> '{' '}' : {}. 25 | term -> '[' ']' : []. 26 | term -> '[' list_args ']' : '$2'. 27 | 28 | 29 | tuple_args -> term: ['$1']. 30 | tuple_args -> term ',' tuple_args: ['$1'|'$3']. 31 | 32 | list_args -> term: ['$1']. 33 | list_args -> term ',' list_args: ['$1'|'$3']. 34 | 35 | Erlang code. 36 | 37 | unwrap({X,_}) -> X; 38 | unwrap({_,_,V}) -> V. 39 | -------------------------------------------------------------------------------- /src/elib1_search.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_search). 5 | -compile(export_all). 6 | -import(elib1_mysql, [start/4, cmd/2, stop/1]). 7 | 8 | make_data_base() -> 9 | {ok, Pid} = start("localhost", 3306, 10 | password:username(mysql), password:password(mysql)), 11 | cmd(Pid, "use test"), 12 | cmd(Pid, "drop table if exists mods"), 13 | cmd(Pid, "create table if not exists mods (" 14 | "themod CHAR(32) not null primary key," %% don't call this mod 15 | "val mediumtext not null, fulltext(val))"), 16 | _V1 = cmd(Pid, "show tables"), 17 | V2 = cmd(Pid, "describe mods"), 18 | stop(Pid), 19 | V2. 20 | 21 | insert_erl() -> 22 | _Files = find:files(".", "*.erl", true), 23 | a. 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/elib1_similar.erl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/src/elib1_similar.erl -------------------------------------------------------------------------------- /src/elib1_simple_kv_db.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_simple_kv_db). 5 | 6 | -export([start_link/1]). 7 | 8 | %% simplest of all KV database using uses dets 9 | 10 | %% Interface: 11 | %% start(Args) -> Pid 12 | %% Protocol 13 | %% Pid ! {From, {read, key}} => From ! {self(), Ret} 14 | %% Ret = {ok, V} | error 15 | %% Pid ! {From, {write, Key, Val}} => From ! {self(), ack} 16 | %% Pid ! {From, close} => From ! {self(), ack} 17 | 18 | start_link([{name,Name},{file,File}]) -> 19 | spawn_link(fun() -> run(Name, File) end). 20 | 21 | run(Name, File) -> 22 | Val = dets:open_file(Name, [{auto_save,2000}, 23 | {file,File}]), 24 | {ok, Name} = Val, 25 | io:format("Opening:~p name=~p~n",[File, Name]), 26 | loop(Name). 27 | 28 | loop(Name) -> 29 | receive 30 | {From, {read, Key}} -> 31 | From ! {self(), lookup_i(Name, Key)}, 32 | loop(Name); 33 | {From, {write, Key, Val}} -> 34 | store_i(Name, Key, Val), 35 | From ! {self(), ack}, 36 | loop(Name); 37 | {From, info} -> 38 | From ! {self(), dets:info(Name)}, 39 | loop(Name); 40 | {From, keys} -> 41 | %% all keys in the db 42 | Vals = dets:foldl(fun({Key,_}, L) -> [Key|L] end, [], Name), 43 | From ! {self(), Vals}, 44 | loop(Name); 45 | {From, close} -> 46 | dets:close(Name), 47 | From ! {self(), ack}, 48 | void; 49 | Other -> 50 | io:format("~p:unexpected message:~p~n",[?MODULE, Other]), 51 | loop(Name) 52 | end. 53 | 54 | lookup_i(Name, Key) -> 55 | Ret = case dets:lookup(Name, Key) of 56 | [{_,Val}] -> {ok, Val}; 57 | _Other -> error 58 | end, 59 | %% io:format("**real lookup ~p => ~p~n",[Key,Ret]), 60 | Ret. 61 | 62 | store_i(Name, Key, Val) -> 63 | %% io:format("**real insert:~p ~p~n",[Key,Val]), 64 | dets:insert(Name, {Key, Val}). 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/elib1_txt2xml.erl: -------------------------------------------------------------------------------- 1 | -module(elib1_txt2xml). 2 | -compile(export_all). 3 | -import(lists, [reverse/1, reverse/2]). 4 | 5 | %% first step of document massage. Break a text file into parahraphs 6 | %% and output as XML 7 | 8 | test() -> 9 | Files = elib1_find:files(".", "*.txt", false), 10 | [cvt(I) || I <- Files]. 11 | 12 | cvt(F) -> 13 | L = elib1_misc:file2paras(F), 14 | H = ["\n", 15 | "\n", 16 | "\n",[fix(P) || {I, P} <- L],"\n"], 17 | io:format("created:~p~n",[F++".xml"]), 18 | file:write_file(F ++ ".xml", [H]). 19 | 20 | fix(L) -> 21 | L1 = normalise_ws(L, []), 22 | L2 = quotify(L1, 0, []), 23 | L3 = linebreak(L2, [], []), 24 | L4 = to_para(L3). 25 | 26 | to_para(L) -> 27 | ["

    \n", 28 | [[" ",string2html(Str),"\n"] || Str <- L], 29 | "

    \n"]. 30 | 31 | 32 | string2html("" ++ T) -> "" ++ string2html(T); 33 | string2html("" ++ T) -> "" ++ string2html(T); 34 | string2html("<" ++ T) -> "<" ++ string2html(T); 35 | string2html([H|T]) -> [H|string2html(T)]; 36 | string2html([]) -> []. 37 | 38 | 39 | linebreak([], [], L) -> 40 | reverse(L); 41 | linebreak([], This, L) -> 42 | reverse([reverse(This)|L]); 43 | linebreak(Str, This, L) -> 44 | {Word, Str1} = get_next_word(Str, []), 45 | case 1 + length(Word) + length(This) of 46 | K when K > 75 -> 47 | %% start a new line 48 | This1 = reverse(Word), 49 | linebreak(Str1, This1, [reverse(This)|L]); 50 | _ -> 51 | This1 = reverse(Word, This), 52 | linebreak(Str1, This1, L) 53 | end. 54 | 55 | get_next_word([$\s|T], L) -> 56 | {reverse([$\s|L]), T}; 57 | get_next_word([H|T], L) -> 58 | get_next_word(T, [H|L]); 59 | get_next_word([], L) -> 60 | {reverse(L), []}. 61 | 62 | quotify([$"|T], 0, L) -> 63 | quotify(T, 1, reverse("&o;", L)); 64 | quotify([$"|T], 1, L) -> 65 | quotify(T, 0, reverse("&c;", L)); 66 | quotify([$'|T], N, L) -> 67 | quotify(T, N, reverse("&s;", L)); 68 | quotify([H|T], N, L) -> 69 | quotify(T, N, [H|L]); 70 | quotify([], 0, L) -> 71 | reverse(L); 72 | quotify([], 1, L) -> 73 | L1 = reverse("Quotes?", L), 74 | reverse(L1). 75 | 76 | normalise_ws([], [$\s|L]) -> 77 | normalise_ws([], L); 78 | normalise_ws([], L) -> 79 | reverse(L); 80 | normalise_ws([H|T], L) when H =:= $\n; H =:= $\r; H =:= $\t -> 81 | normalise_ws([$\s|T], L); 82 | normalise_ws([$\s|T], [$\s|_]=L) -> 83 | normalise_ws(T, L); 84 | normalise_ws([H|T], L) -> 85 | normalise_ws(T, [H|L]). 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /src/elib1_webquery.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_webquery). 5 | -compile(export_all). 6 | 7 | qu([{"name",Collection},{"query",Str}], Root) -> 8 | Name = Collection, 9 | Dir = Root, 10 | {Hits,Pages} = elib1_indexer:q(Dir,Name,Str), 11 | L1 = [[Str," ",integer_to_list(N)," hits
    "] || {Str,N} <- Hits], 12 | L2 = [["
  • ",Loc,"
  • "] || {Pos,Loc} <- Pages], 15 | {response, html, 16 | ["

    Root:",Root,"

    Query collection:",Collection," str:",Str, 17 | "

    ",L1,"

    ",L2]}. 18 | 19 | show_file([{"name",Collection},{"pos",Pos}], Root) -> 20 | Dir = Root, 21 | Name = Collection, 22 | Index = list_to_integer(Pos), 23 | {File, Val} = elib1_indexer:extract(Dir, Name, Index), 24 | {response, html, ["

    ",Val,"
    "]}. 25 | 26 | -------------------------------------------------------------------------------- /src/log: -------------------------------------------------------------------------------- 1 | = chunks 2 | 3 | I am going to give a talk at Spotify and am a bit nervous about how it 4 | will be received. 5 | 6 | The talk is ready so not I have to kill an hour or so. 7 | 8 | I'm going to go back to my theme of ''information chunks''. The basic 9 | fault with all that I have done before is that all the data I generate 10 | is in text files, which I create with an editor and ''not'' in a 11 | database. 12 | 13 | I'm going to develop the program in order: 14 | 15 | First I think I need a pretty web display. I'll mock this up ... 16 | in new.html 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/lorem.chap: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Lorum Ipsum 5 | 6 |

    This file tests the documentation system:

    7 | 8 |

    This file is regular xml with the exception of a single tag 9 | <erl func="...">. The program elib1_doc expands 10 | this tag replacing the tag with well formed xml. Therafter XSLT and 11 | xmllint and Apache FOP are used to transform the XML into HTML and 12 | PDF.

    13 | 14 |

    15 | 16 |
      17 |
    1. Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    2. 18 |
    3. Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    4. 19 |
    5. Lorem ipsum dolor sit amet, consectetur 20 | adipisicing elit.

    6. 21 |
    7. Lorem ipsum dolor sit amet, consectetur 22 | adipisicing elit.

    8. 23 | 24 |
    25 | 26 |

    27 | 28 |

    This tests the constructs in the validator

    29 | 30 | 31 | aaa 32 |

    aa

    33 | bbb 34 |
    35 | 36 |
    Ipsum Dolor
    37 | 38 |
    39 |
    [Lorem Ipsum]
    40 |

    dolor sit amet, consectetur X> adipisicing elit, sed do 41 | eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut 42 | enim ad.

    43 |
    44 | 45 |
    [consectetur]
    46 |

    adipisicing elit, sed do eiusmod tempor incididunt ut labore 47 | et dolore magna aliqua. Ut enim ad minim veniam, "quis nostrud 48 | exercitation," ullamco laboris nisi ut aliquip ex ea commodo 49 | consequat.

    50 |
    51 | 52 |
    
    53 |   
    54 | 55 |
    56 | {dl, [{tag,"aaa",[{p,p1},{p,P2}]}, {tag, "bbb",[{p,p1}]}}
    57 |   
    58 |
    59 | 60 | -------------------------------------------------------------------------------- /src/mkdoc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env escript 2 | main([File]) -> 3 | io:format("mkdoc ~s~n",[File]), 4 | edoc:files([File], [{dir,"../doc"}]). 5 | 6 | -------------------------------------------------------------------------------- /src/myapp.app.src: -------------------------------------------------------------------------------- 1 | {application, myapp, 2 | [ 3 | {description, ""}, 4 | {vsn, "1"}, 5 | {registered, []}, 6 | {applications, [ 7 | kernel, 8 | stdlib 9 | ]}, 10 | {mod, { myapp_app, []}}, 11 | {env, []} 12 | ]}. 13 | -------------------------------------------------------------------------------- /src/myapp_app.erl: -------------------------------------------------------------------------------- 1 | -module(myapp_app). 2 | 3 | -behaviour(application). 4 | 5 | %% Application callbacks 6 | -export([start/2, stop/1]). 7 | 8 | %% =================================================================== 9 | %% Application callbacks 10 | %% =================================================================== 11 | 12 | start(_StartType, _StartArgs) -> 13 | myapp_sup:start_link(). 14 | 15 | stop(_State) -> 16 | ok. 17 | -------------------------------------------------------------------------------- /src/myapp_sup.erl: -------------------------------------------------------------------------------- 1 | 2 | -module(myapp_sup). 3 | 4 | -behaviour(supervisor). 5 | 6 | %% API 7 | -export([start_link/0]). 8 | 9 | %% Supervisor callbacks 10 | -export([init/1]). 11 | 12 | %% Helper macro for declaring children of supervisor 13 | -define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}). 14 | 15 | %% =================================================================== 16 | %% API functions 17 | %% =================================================================== 18 | 19 | start_link() -> 20 | supervisor:start_link({local, ?MODULE}, ?MODULE, []). 21 | 22 | %% =================================================================== 23 | %% Supervisor callbacks 24 | %% =================================================================== 25 | 26 | init([]) -> 27 | {ok, { {one_for_one, 5, 10}, []} }. 28 | 29 | -------------------------------------------------------------------------------- /src/notes: -------------------------------------------------------------------------------- 1 | http://stackoverflow.com/questions/2626859/chrome-extension-how-to-capture-selected-text-and-send-to-a-web-service 2 | http://stackoverflow.com/questions/2139616/window-getselection-gives-me-the-selected-text-but-i-want-the-html 3 | -------------------------------------------------------------------------------- /src/password.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(password). 5 | 6 | -export([username/1, password/1]). 7 | 8 | username(mysql) -> "joejoe". 9 | password(mysql) -> "joepass". 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/slides.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
    7 |

    Highlights of the library

    8 |
      9 |
    1. Streams
    2. 10 |
    3. Fast IO
    4. 11 |
    5. Gamma encoding
    6. 12 |
    7. XML parser
    8. 13 |
    14 |
    15 | 16 |
    17 | 18 |

    Streams

    19 | 20 |

    Stream parsing is very powerful technique.

    21 | 22 |

    If F is a stream then: 23 |

      24 |
    1. {string(), F1} | eos = F()
    2. 25 |
    26 | 27 |

    Where F1 is a new stream

    28 |

    Used in elib1_xml.erl

    29 | 30 |
    31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/todo: -------------------------------------------------------------------------------- 1 | docmaker 2 | gloabal xref 3 | index in mysql 4 | -------------------------------------------------------------------------------- /src/tryxform.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(tryxform). 5 | -compile(export_all). 6 | 7 | test() -> 8 | L = elib1_xml:parse_file("lorem.chap"), 9 | elib1_misc:dump("tryx", L), 10 | Chapter = get_node(L, "chap"), 11 | HTML = toHTML([Chapter], [], Chapter), 12 | file:write_file("out.html",[HTML]). 13 | 14 | 15 | toHTML([{node,"chap",_,_,L}|_], Path, C) -> 16 | [<<" 17 | 19 | 20 | ">>, 21 | toHTML(L, [chap|Path], C), 22 | <<"">>]; 23 | toHTML([{node,"title",_,_,L}|T], [chap], C) -> 24 | ["", text(L), "", 25 | <<" 26 | 28 | 29 | ">>,toHTML(T, [chap], C),<<"">>]; 30 | toHTML([{node,Tag,_,_,L}|T], Path, C) -> 31 | ["<",Tag,">", 32 | toHTML(L, [Tag|Path], C), 33 | ""|toHTML(T, Path, C)]; 34 | toHTML([{raw,_,_,Str}|T], Path, C) -> 35 | [quote(Str)|toHTML(T, Path, C)]; 36 | toHTML([], _, _) -> 37 | []. 38 | 39 | text([{raw,_,_,Str}]) -> 40 | quote(Str); 41 | text(X) -> 42 | io:format("text:~p~n",[X]), 43 | "aa". 44 | 45 | quote(X) -> 46 | elib1_misc:string2html(X). 47 | 48 | get_node([{node,N,_,_,_}=X|_], N) -> X; 49 | get_node([_|T], N) -> get_node(T, N). 50 | 51 | -------------------------------------------------------------------------------- /src/wiki.chap1: -------------------------------------------------------------------------------- 1 | = Wiki text 2 | 3 | The problem with lists is that we dont know where they end. 4 | This problem is really easy t solve. Just add a tag: 5 | 6 |
     7 |    
     8 |       ....
     9 |    
    10 | 
    11 | 
    12 | Then within the list it is easy to group elements:
    13 | 
    14 | 
    15 | 
    16 |    * aaaa
    17 | 
    18 |    bbb
    19 | 
    20 |    *ccccc
    21 | 
    22 |    dddd
    23 | 
    24 | eeee
    25 | 
    26 | 27 | Without the final <<>> tag we don't know if <> is the second 28 | paragrah attatched to the <> or if it outside the scope of the 29 | list. 30 | 31 | 32 | * List item 1 33 | 34 | another para. 35 | 36 | and another para. 37 | 38 | * List item2 39 | 40 | A sup para of two. 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /supported/drivers/README: -------------------------------------------------------------------------------- 1 | These programs are *very* fragile -- do not edit 2 | make a copy of entire directory and edit 3 | 4 | NOTES: cpp must be compiled with g++ not gcc 5 | ldd -r example_drv.so 6 | 7 | Is useful for debugging -------------------------------------------------------------------------------- /supported/drivers/c_linked_in_driver/Makefile: -------------------------------------------------------------------------------- 1 | driver: example_drv.so erl 2 | 3 | example_drv.so: port_driver.c 4 | gcc -o example_drv.so -fpic -shared port_driver.c 5 | 6 | erl: complex.beam 7 | @erl -noshell -s complex test 8 | 9 | complex.beam: complex.erl 10 | erlc complex.erl 11 | 12 | clean: 13 | rm -f example_drv.so complex.beam erl_crash.dump -------------------------------------------------------------------------------- /supported/drivers/c_linked_in_driver/complex.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(complex). 5 | -export([bug/0, test/0, start/0, start/1, stop/0, init/2]). 6 | -export([plus_one/1, times_two/1]). 7 | 8 | test() -> 9 | start(), 10 | 3 = plus_one(2), 11 | 6 = times_two(3), 12 | io:format("Horray C interface with linked-in driver works~n"), 13 | stop(), 14 | init:stop(). 15 | 16 | bug() -> 17 | case erl_ddll:load_driver(".", "example_drv") of 18 | ok -> ok; 19 | {error, X} -> erl_ddll:format_error(X) 20 | end. 21 | 22 | start() -> 23 | start("example_drv"). 24 | 25 | %% erl_ddll:load_driver(".","example_drv"). 26 | 27 | start(SharedLib) -> 28 | case erl_ddll:load_driver(".", SharedLib) of 29 | ok -> ok; 30 | {error, already_loaded} -> ok; 31 | {error, X} -> 32 | io:format("Error:~p", [erl_ddll:format_error(X)]), 33 | exit(eBadStuff) 34 | end, 35 | S = self(), 36 | spawn(?MODULE, init, [S, SharedLib]), 37 | receive 38 | {S, ack} -> 39 | true 40 | end. 41 | 42 | 43 | init(P, SharedLib) -> 44 | register(complex, self()), 45 | P ! {P, ack}, 46 | Port = open_port({spawn, SharedLib}, []), 47 | loop(Port). 48 | 49 | stop() -> 50 | complex ! stop. 51 | 52 | plus_one(X) -> 53 | call_port({plus, X}). 54 | 55 | times_two(Y) -> 56 | call_port({times, Y}). 57 | 58 | call_port(Msg) -> 59 | complex ! {call, self(), Msg}, 60 | receive 61 | {complex, Result} -> 62 | Result 63 | end. 64 | 65 | loop(Port) -> 66 | receive 67 | {call, Caller, Msg} -> 68 | Port ! {self(), {command, encode(Msg)}}, 69 | receive 70 | {Port, {data, Data}} -> 71 | Caller ! {complex, decode(Data)} 72 | end, 73 | loop(Port); 74 | stop -> 75 | Port ! {self(), close}, 76 | receive 77 | {Port, closed} -> 78 | exit(normal) 79 | end; 80 | {'EXIT', Port, Reason} -> 81 | io:format("~p ~n", [Reason]), 82 | exit(port_terminated) 83 | end. 84 | 85 | encode({plus, X}) -> [1, X]; 86 | encode({times, Y}) -> [2, Y]. 87 | 88 | decode([Int]) -> Int. 89 | -------------------------------------------------------------------------------- /supported/drivers/c_linked_in_driver/port_driver.c: -------------------------------------------------------------------------------- 1 | /* port_driver.c */ 2 | // gcc -o exampledrv -fpic -shared complex.c port_driver.c 3 | 4 | #include 5 | #include "/usr/local/lib/erlang/usr/include/erl_driver.h" 6 | 7 | typedef struct { 8 | ErlDrvPort port; 9 | } example_data; 10 | 11 | static ErlDrvData example_drv_start(ErlDrvPort port, char *buff) 12 | { 13 | example_data* d = (example_data*)driver_alloc(sizeof(example_data)); 14 | d->port = port; 15 | return (ErlDrvData)d; 16 | } 17 | 18 | static void example_drv_stop(ErlDrvData handle) 19 | { 20 | driver_free((char*)handle); 21 | } 22 | 23 | 24 | int plus_one(int x) { 25 | return x+1; 26 | } 27 | 28 | int times_two(int y) { 29 | return y*2; 30 | } 31 | 32 | 33 | static void example_drv_output(ErlDrvData handle, char *buff, int bufflen) 34 | { 35 | example_data* d = (example_data*)handle; 36 | char fn = buff[0], arg = buff[1], res; 37 | if (fn == 1) { 38 | res = plus_one(arg); 39 | } else if (fn == 2) { 40 | res = times_two(arg); 41 | } 42 | driver_output(d->port, &res, 1); 43 | } 44 | 45 | 46 | ErlDrvEntry example_driver_entry = { 47 | NULL, /* F_PTR init, N/A */ 48 | example_drv_start, /* L_PTR start, called when port is opened */ 49 | example_drv_stop, /* F_PTR stop, called when port is closed */ 50 | example_drv_output, /* F_PTR output, called when erlang has sent 51 | data to the port */ 52 | NULL, /* F_PTR ready_input, 53 | called when input descriptor ready to read*/ 54 | NULL, /* F_PTR ready_output, 55 | called when output descriptor ready to write */ 56 | "example_drv", /* char *driver_name, the argument to open_port */ 57 | NULL, /* F_PTR finish, called when unloaded */ 58 | NULL, /* F_PTR control, port_command callback */ 59 | NULL, /* F_PTR timeout, reserved */ 60 | NULL /* F_PTR outputv, reserved */ 61 | }; 62 | 63 | DRIVER_INIT(example_drv) /* must match name in driver_entry */ 64 | { 65 | return &example_driver_entry; 66 | } 67 | 68 | 69 | -------------------------------------------------------------------------------- /supported/drivers/c_port_driver/Makefile: -------------------------------------------------------------------------------- 1 | .SUFFIXES: .erl .beam .yrl 2 | 3 | .erl.beam: 4 | erlc -W $< 5 | 6 | MODS = example1 7 | 8 | all: ${MODS:%=%.beam} port_driver 9 | erl -s example1 test 10 | 11 | port_driver: port_driver.c 12 | gcc -o port_driver port_driver.c 13 | 14 | clean: 15 | rm -rf port_driver erl_crash.dump *.beam *~ 16 | 17 | -------------------------------------------------------------------------------- /supported/drivers/c_port_driver/example1.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | %% --- 5 | %% Excerpted from "Programming Erlang", 6 | %% published by The Pragmatic Bookshelf. 7 | %% Copyrights apply to this code. It may not be used to create training material, 8 | %% courses, books, articles, and the like. Contact us if you are in doubt. 9 | %% We make no guarantees that this code is fit for any purpose. 10 | %% Visit http://www.pragmaticprogrammer.com/titles/jaerlang for more book information. 11 | %%--- 12 | -module(example1). 13 | -export([test/0, start/0, stop/0]). 14 | -export([twice/1, sum/2]). 15 | 16 | test() -> 17 | io:format("Port process starting~n"), 18 | start(), 19 | case (catch begin 20 | 4 = twice(2), 21 | 5 = sum(3,2), 22 | ok 23 | end) of 24 | {'EXIT', Why} -> 25 | io:format("Something wrong:~p~n",[Why]); 26 | ok -> 27 | io:format("test worked~n") 28 | end, 29 | stop(), 30 | io:format("Port process stopped~n"), 31 | init:stop(). 32 | 33 | start() -> 34 | S = self(), 35 | Pid = spawn(fun() -> run(S) end), 36 | receive 37 | {Pid, ack} -> 38 | true 39 | end. 40 | 41 | run(Parent) -> 42 | register(example1, self()), 43 | process_flag(trap_exit, true), 44 | Port = open_port({spawn, "./port_driver"}, [{packet, 2}]), 45 | Parent ! {self(), ack}, 46 | loop(Port). 47 | 48 | stop() -> 49 | example1 ! stop. 50 | 51 | twice(X) -> call_port({twice, X}). 52 | sum(X,Y) -> call_port({sum, X, Y}). 53 | 54 | call_port(Msg) -> 55 | example1 ! {call, self(), Msg}, 56 | receive 57 | {example1, Result} -> 58 | Result 59 | end. 60 | 61 | loop(Port) -> 62 | receive 63 | {call, Caller, Msg} -> 64 | Port ! {self(), {command, encode(Msg)}}, 65 | receive 66 | {Port, {data, Data}} -> 67 | Caller ! {example1, decode(Data)} 68 | end, 69 | loop(Port); 70 | stop -> 71 | Port ! {self(), close}, 72 | receive 73 | {Port, closed} -> 74 | exit(normal) 75 | end; 76 | {'EXIT', Port, Reason} -> 77 | exit({port_terminated,Reason}) 78 | end. 79 | 80 | encode({twice, X}) -> [1, X]; 81 | encode({sum, X, Y}) -> [2, X, Y]. 82 | 83 | decode([Int]) -> Int. 84 | -------------------------------------------------------------------------------- /supported/drivers/c_port_driver/port_driver.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | typedef unsigned char byte; 5 | 6 | int read_cmd(byte *buf); 7 | int write_cmd(byte *buf, int len); 8 | int read_exact(byte *buf, int len); 9 | int write_exact(byte *buf, int len); 10 | 11 | byte out[128]; 12 | 13 | int read_cmd(byte *buf) 14 | { 15 | int len; 16 | 17 | if (read_exact(buf, 2) != 2) 18 | return(-1); 19 | len = (buf[0] << 8) | buf[1]; 20 | return read_exact(buf, len); 21 | } 22 | 23 | int write_cmd(byte *buf, int len) 24 | { 25 | byte li; 26 | 27 | li = (len >> 8) & 0xff; 28 | write_exact(&li, 1); 29 | 30 | li = len & 0xff; 31 | write_exact(&li, 1); 32 | 33 | return write_exact(buf, len); 34 | } 35 | 36 | int read_exact(byte *buf, int len) 37 | { 38 | int i, got=0; 39 | 40 | do { 41 | if ((i = read(0, buf+got, len-got)) <= 0) 42 | return(i); 43 | got += i; 44 | } while (got 0) { 67 | handle(n, buff); 68 | } 69 | } 70 | 71 | // This is were we do all the work 72 | 73 | handle(int n, byte* in){ 74 | if (in[0] == 1) { 75 | // double 76 | out[0] = 2 * in[1]; 77 | write_cmd(out, 1); 78 | } else if (in[0] == 2) { 79 | // sum 80 | out[0] = in[1] + in[2]; 81 | write_cmd(out, 1); 82 | }; 83 | } 84 | -------------------------------------------------------------------------------- /supported/drivers/cpp_linked_in_driver/Makefile: -------------------------------------------------------------------------------- 1 | driver: example_drv.so erl 2 | 3 | example_drv.so: port_driver.cpp 4 | g++ -o example_drv.so -fpic -shared port_driver.cpp 5 | 6 | erl: complex.beam 7 | @erl -noshell -s complex test 8 | 9 | 10 | complex.beam: complex.erl 11 | erlc complex.erl 12 | 13 | clean: 14 | rm -f example_drv.so complex.beam -------------------------------------------------------------------------------- /supported/drivers/cpp_linked_in_driver/complex.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(complex). 5 | -export([bug/0, test/0, start/0, start/1, stop/0, init/2]). 6 | -export([plus_one/1, times_two/1]). 7 | 8 | test() -> 9 | start(), 10 | 3 = plus_one(2), 11 | 6 = times_two(3), 12 | io:format("Horray CPP interface with linked-in driver works~n"), 13 | stop(), 14 | init:stop(). 15 | 16 | bug() -> 17 | case erl_ddll:load_driver(".", "example_drv") of 18 | ok -> ok; 19 | {error, X} -> erl_ddll:format_error(X) 20 | end. 21 | 22 | start() -> 23 | start("example_drv"). 24 | 25 | %% erl_ddll:load_driver(".","example_drv"). 26 | 27 | start(SharedLib) -> 28 | case erl_ddll:load_driver(".", SharedLib) of 29 | ok -> ok; 30 | {error, already_loaded} -> ok; 31 | {error, X} -> 32 | io:format("Error:~p", [erl_ddll:format_error(X)]), 33 | exit(eBadStuff) 34 | end, 35 | S = self(), 36 | spawn(?MODULE, init, [S, SharedLib]), 37 | receive 38 | {S, ack} -> 39 | true 40 | end. 41 | 42 | 43 | init(P, SharedLib) -> 44 | register(complex, self()), 45 | P ! {P, ack}, 46 | Port = open_port({spawn, SharedLib}, []), 47 | loop(Port). 48 | 49 | stop() -> 50 | complex ! stop. 51 | 52 | plus_one(X) -> 53 | call_port({plus, X}). 54 | 55 | times_two(Y) -> 56 | call_port({times, Y}). 57 | 58 | call_port(Msg) -> 59 | complex ! {call, self(), Msg}, 60 | receive 61 | {complex, Result} -> 62 | Result 63 | end. 64 | 65 | loop(Port) -> 66 | receive 67 | {call, Caller, Msg} -> 68 | Port ! {self(), {command, encode(Msg)}}, 69 | receive 70 | {Port, {data, Data}} -> 71 | Caller ! {complex, decode(Data)} 72 | end, 73 | loop(Port); 74 | stop -> 75 | Port ! {self(), close}, 76 | receive 77 | {Port, closed} -> 78 | exit(normal) 79 | end; 80 | {'EXIT', Port, Reason} -> 81 | io:format("~p ~n", [Reason]), 82 | exit(port_terminated) 83 | end. 84 | 85 | encode({plus, X}) -> [1, X]; 86 | encode({times, Y}) -> [2, Y]. 87 | 88 | decode([Int]) -> Int. 89 | -------------------------------------------------------------------------------- /supported/drivers/cpp_linked_in_driver/port_driver.cpp: -------------------------------------------------------------------------------- 1 | /* port_driver.c */ 2 | // gcc -o exampledrv -fpic -shared complex.c port_driver.c 3 | 4 | using namespace std; 5 | 6 | #include 7 | 8 | #include "/usr/local/lib/erlang/usr/include/erl_driver.h" 9 | 10 | typedef struct { 11 | ErlDrvPort port; 12 | } example_data; 13 | 14 | static ErlDrvData example_drv_start(ErlDrvPort port, char *buff) 15 | { 16 | example_data* d = (example_data*)driver_alloc(sizeof(example_data)); 17 | d->port = port; 18 | return reinterpret_cast (d); 19 | } 20 | 21 | static void example_drv_stop(ErlDrvData handle) 22 | { 23 | driver_free((char*)handle); 24 | } 25 | 26 | /* complex.c */ 27 | 28 | int plus_one(int x) { 29 | return x+1; 30 | } 31 | 32 | int times_two(int y) { 33 | return y*2; 34 | } 35 | 36 | 37 | static void example_drv_output(ErlDrvData handle, char *buff, int bufflen) 38 | { 39 | example_data* d = (example_data*)handle; 40 | char fn = buff[0], arg = buff[1], res; 41 | if (fn == 1) { 42 | res = plus_one(arg); 43 | } else if (fn == 2) { 44 | res = times_two(arg); 45 | } 46 | driver_output(d->port, &res, 1); 47 | } 48 | 49 | 50 | ErlDrvEntry example_driver_entry = { 51 | NULL, /* F_PTR init, N/A */ 52 | example_drv_start, /* L_PTR start, called when port is opened */ 53 | example_drv_stop, /* F_PTR stop, called when port is closed */ 54 | example_drv_output, /* F_PTR output, called when erlang has sent 55 | data to the port */ 56 | NULL, /* F_PTR ready_input, 57 | called when input descriptor ready to read*/ 58 | NULL, /* F_PTR ready_output, 59 | called when output descriptor ready to write */ 60 | "example_drv", /* char *driver_name, the argument to open_port */ 61 | NULL, /* F_PTR finish, called when unloaded */ 62 | NULL, /* F_PTR control, port_command callback */ 63 | NULL, /* F_PTR timeout, reserved */ 64 | NULL /* F_PTR outputv, reserved */ 65 | }; 66 | 67 | 68 | /* INITIALIZATION AFTER LOADING */ 69 | 70 | extern "C" { 71 | DRIVER_INIT(example_drv) 72 | { 73 | return &example_driver_entry; 74 | } 75 | } 76 | 77 | -------------------------------------------------------------------------------- /supported/drivers/doc.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

    Drivers

    5 | 6 |

    Example code for linked-in drivers

    7 | 8 |

    Currently broken

    9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /supported/indexer/Makefile: -------------------------------------------------------------------------------- 1 | all: medium.index medium.fsim 2 | 3 | medium.fsim: medium.crawl 4 | efind_similar_files medium 5 | 6 | medium.index: medium.in 7 | eindex -crawl medium 8 | eindex -index medium 9 | 10 | clean: 11 | rm -rf medium.crawl medium.files medium.index medium.fsim medium.hashes 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /supported/indexer/README: -------------------------------------------------------------------------------- 1 | The Index consists of 4 programs 2 | 3 | egather 4 | .in -> .flist .trawl 5 | eindex 6 | .trawl -> .idx 7 | esearch "Query" 8 | .idx "Query" -> Output 9 | efsim 10 | .trawl -> .fsim 11 | 12 | .in 13 | {"Dir", "*.erl", Bool}. 14 | ... 15 | 16 | Talk: 17 | 18 | elib2 - an Erlang library 19 | Joe Armstrong 20 | 21 | Elib2 is an Erlang library and a number of complete programs that 22 | make use of the library. 23 | 24 | The talk discusses: 25 | 26 | - the philosophy behind the library 27 | - what's in the library 28 | - my plans for the library 29 | 30 | I'll also show some of the programs that I have built using the 31 | library, with special attention to the following programs: 32 | 33 | - elib2_gather 34 | A program to scavenge your hard disk and find all Erlang 35 | programs on your disk and pack them in a single 36 | compressed file (called a trawl). 37 | 38 | - elib2_make_index 39 | A program that creates a full text index from a trawl. 40 | This implements some of the algorithms in "managing gigabytes." 41 | In particular I'll show how gamma compression is implemented 42 | using the bit syntax. 43 | 44 | - elib2_query 45 | A program that queries the full text index. 46 | 47 | - elib2_find_similar_files 48 | A program that computes a "similarity index" between pairs 49 | of Erlang modules. Using this we can find "the most similar" 50 | module to a given module in linear time. I compute the similarity 51 | digraph of all Erlang module programs on my disk. 52 | 53 | Programs which are very similar are candidates for refactoring into 54 | a library part and a specific part. 55 | 56 | I'll also discuss my plans for releasing the library. 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /supported/indexer/medium.in: -------------------------------------------------------------------------------- 1 | %% these paths get added to $HOME 2 | {"code/elib2-1/lib", ".erl"}. 3 | {"code/elib2-1/supported", ".erl"}. 4 | {"code/elib2-1/unsupported", ".erl"}. 5 | -------------------------------------------------------------------------------- /supported/indexer/web_query.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 13 | 14 |

    Web Query

    15 | 16 |

    Enter a query here (note you must be running live for this to work)

    17 | 18 |
    19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
    Collection:
    Search for:
    29 | 30 |
    31 | 32 |

    Output

    33 |
    Response
    34 | 35 | 36 | -------------------------------------------------------------------------------- /supported/irc/Makefile: -------------------------------------------------------------------------------- 1 | .SUFFIXES: .erl .beam .yrl 2 | 3 | MODS := $(wildcard *.erl) 4 | 5 | %.beam: %.erl 6 | erlc -W $< 7 | 8 | all: server 9 | 10 | server: beam 11 | erl -s ircd start_server 12 | 13 | client: beam 14 | erl -noshell -s irc_text_client local 15 | 16 | irc: beam 17 | erl -noshell -s irc start 18 | 19 | test: beam 20 | erl -noshell -s irc test12 21 | 22 | chat: beam 23 | erl -s chat_widget test1 24 | 25 | widgets: beam 26 | erl -s widget_lib test 27 | 28 | beam: ${MODS:%.erl=%.beam} 29 | 30 | clean: 31 | rm -rf *.beam 32 | rm -rf *.log *.tmp erl_crash.dump 33 | 34 | veryclean: 35 | make clean 36 | rm -rf *~ 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /supported/irc/README: -------------------------------------------------------------------------------- 1 | The code in this directory 2 | is in a complete mess. 3 | 4 | This is being fixed. 5 | 6 | Don't tell me - I know 7 | -------------------------------------------------------------------------------- /supported/irc/chat_erl_test.tcl: -------------------------------------------------------------------------------- 1 | proc sendToErlang { x } { 2 | puts "$x" 3 | } 4 | 5 | source "chat_erl.tcl" 6 | 7 | image create photo rball -file "./redball.gif" 8 | image create photo wball -file "./whiteball.gif" 9 | 10 | wm withdraw . 11 | 12 | proc windowDestroyed { w } { 13 | puts "$w is destoyed" 14 | } 15 | 16 | toplevel .w1 17 | bind .w1 "windowDestroyed %W" 18 | 19 | chat::make_chat .w1 20 | chat::add_tab .w1 f1 "One" 21 | chat::add_content .w1 f1 {This is some content} 22 | 23 | chat::add_tab .w1 f2 "Two" 24 | chat::add_content .w1 f2 {This is some other content} 25 | 26 | chat::add_tab .w1 f3 "Three" 27 | chat::add_content .w1 f2 {This is tab 3 28 | and some other content} 29 | 30 | chat::add_listbox .w1 {joe} 31 | chat::add_listbox .w1 {james the first} 32 | 33 | chat::set_title .w1 {This is my window} 34 | 35 | ## make a test widget 36 | toplevel .w2 37 | button .w2.b1 -text "toggle one" -command "chat::toggle .w1 f1" 38 | button .w2.b2 -text "add text to one" -command "chat::add_content .w1 f1 {\nhello}" 39 | button .w2.b3 -text "set entry" -command "chat::set_entry .w1 {some stuff}" 40 | button .w2.b4 -text "set one red" -command "chat::set_color .w1 f1 red" 41 | button .w2.b5 -text "set one white" -command "chat::set_color .w1 f1 white" 42 | button .w2.b6 -text "delete tab 3" -command "chat::delete_tab .w1 f3" 43 | button .w2.b7 -text "add tab 3" -command "chat::add_tab .w1 f3 New" 44 | 45 | pack .w2.b1 .w2.b2 .w2.b3 .w2.b4 .w2.b5 .w2.b6 .w2.b7 -fill both -expand 1 46 | 47 | 48 | -------------------------------------------------------------------------------- /supported/irc/doc.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

    IRC

    5 | 6 |

    This is an IRC client and server.

    7 | 8 |

    Show me

    9 | 10 |

    The intention is to control all Erlang components with 11 | IRC

    12 | 13 |

    Erlang components (web-servers, indexing engines, databases etc.) 14 | should appear to be "chat-rooms" in an IRC interface. To interact 15 | with mnesia for example, one might say:

    16 | 17 |
    18 |     /join #mnesia
    19 |   
    20 | 21 |

    This would enter the chat room mnesia, then you could chat with 22 | the #mnesia bot:

    23 | 24 |
    25 |     joe: show tables
    26 |     #mnesia: one two three
    27 |     joe: describe one
    28 |     #mnesia: {name:string(), ag::integer()}
    29 |     ...
    30 |   
    31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /supported/irc/irc_text_client.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(irc_text_client). 5 | 6 | -compile(export_all). 7 | 8 | local() -> 9 | User = "j" ++ elib1_misc:random_string(5), 10 | Nick = "j" ++ elib1_misc:random_string(5), 11 | start("localhost", User, Nick). 12 | 13 | %% start() -> start("irc.freenode.net"). 14 | %% irc_text_client:start("localhost", "joe", "armstrong"). 15 | %% irc_text_client:start("localhost", "mike", "williams"). 16 | 17 | start(Host, Nick, User) -> 18 | S = self(), 19 | Pid = spawn_link(fun() -> start(S, Host) end), 20 | receive 21 | {Pid, ok} -> 22 | %% Pid ! {send, "USER " ++ User ++ " myhost localhost :snark\r\n"}, 23 | Pid ! {send, "USER " ++ User ++ "\r\n"}, 24 | Pid ! {send, "NICK " ++ Nick ++ "\r\n"}, 25 | cmd_loop(Pid); 26 | {Pid, Error} -> 27 | Error 28 | end. 29 | 30 | cmd_loop(Pid) -> 31 | case io:get_line(' > ') of 32 | "quit\n" -> 33 | exit(Pid); 34 | Str -> 35 | Str1 = remove_nl(Str), 36 | io:format("sending ~s~n",[Str1]), 37 | Pid ! {send, Str1 ++ "\r\n"}, 38 | cmd_loop(Pid) 39 | end. 40 | 41 | remove_nl("\n") -> []; 42 | remove_nl([H|T]) -> [H|remove_nl(T)]. 43 | 44 | 45 | start(Parent, Host) -> 46 | io:format("trying to connect to:~p port 6669~n",[Host]), 47 | case gen_tcp:connect(Host, 6669, [{packet,0}], 60000) of 48 | {ok, Socket} -> 49 | io:format("connected~n"), 50 | Parent ! {self(), ok}, 51 | loop(Socket); 52 | Error -> 53 | Parent ! {self(), Error} 54 | end. 55 | 56 | loop(Socket) -> 57 | receive 58 | {send, Str} -> 59 | io:format(" >> ~p~n", [Str]), 60 | gen_tcp:send(Socket, Str), 61 | loop(Socket); 62 | {tcp, Socket, Str} -> 63 | io:format(" << ~s", [Str]), 64 | case Str of 65 | "PING " ++ T -> 66 | self() ! {send, "PONG " ++ T}; 67 | _Other -> 68 | void 69 | end, 70 | loop(Socket); 71 | {tcp_closed, Socket} -> 72 | io:format("socket closed~n"), 73 | exit(bye); 74 | Other -> 75 | io:format("unexpected:~p~n",[Other]), 76 | loop(Socket) 77 | end. 78 | 79 | -------------------------------------------------------------------------------- /supported/irc/redball.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/supported/irc/redball.gif -------------------------------------------------------------------------------- /supported/irc/test1.tcl: -------------------------------------------------------------------------------- 1 | proc mkListScroll { w } { 2 | frame $w 3 | listbox $w.list -yscrollcommand "$w.scr set" 4 | puts "creating listbox $w.list" 5 | scrollbar $w.scr -orient vertical -command "$w.list yview" 6 | pack $w.scr -side right -fill y 7 | pack $w.list -fill both -expand 1 8 | bind $w.list {listBoxClicked %W [selection get]} 9 | return $w 10 | } 11 | 12 | proc listBoxClicked { w } { 13 | ## sendToErlang "event $w listbox [selection get]" 14 | puts "event $w listbox [selection get]" 15 | } 16 | 17 | mkListScroll .lb 18 | pack .lb 19 | 20 | 21 | .lb.list insert end {one} 22 | .lb.list insert end {two} 23 | .lb.list insert end {three} 24 | .lb.list insert end {four} 25 | -------------------------------------------------------------------------------- /supported/irc/whiteball.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/supported/irc/whiteball.gif -------------------------------------------------------------------------------- /supported/midi_driver/Makefile: -------------------------------------------------------------------------------- 1 | MODS := $(wildcard *.erl) 2 | 3 | %.beam: %.erl 4 | erlc -W $< 5 | 6 | run: all beam 7 | erl -s midi_driver test1 8 | 9 | beam: ${MODS:%.erl=%.beam} 10 | 11 | all: list_devices midi_in_driver midi_out_driver 12 | 13 | list_devices: list_devices.c endpoint_name.c 14 | gcc -o list_devices -framework CoreMIDI\ 15 | -framework CoreServices\ 16 | list_devices.c endpoint_name.c 17 | 18 | midi_in_driver: midi_in_driver.c 19 | gcc -o midi_in_driver -framework CoreMIDI\ 20 | -framework CoreServices midi_in_driver.c 21 | 22 | midi_out_driver: midi_out_driver.c 23 | gcc -o midi_out_driver -framework CoreMIDI\ 24 | -framework CoreServices midi_out_driver.c 25 | 26 | clean: 27 | rm -rf list_devices midi_in_driver midi_out_driver 28 | rm -rf *.beam 29 | -------------------------------------------------------------------------------- /supported/midi_driver/doc.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

    Midi drivers

    5 | 6 |

    Programs to read and write midi streams. Mac OS-X only

    7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /supported/midi_driver/list_devices.c: -------------------------------------------------------------------------------- 1 | #include /* interface to MIDI in Macintosh OS X */ 2 | #include /* for sleep() function */ 3 | #define MESSAGESIZE 3 /* byte count for MIDI note messages */ 4 | 5 | // try to list all midi devices 6 | 7 | char *cm_get_full_endpoint_name(MIDIEndpointRef); 8 | 9 | void print_devices(){ 10 | int i, n; 11 | char *str; 12 | MIDIEndpointRef endpoint; 13 | 14 | n=MIDIGetNumberOfDestinations(); 15 | // printf("number of destinations = %d \n", n); 16 | printf("["); 17 | for(i=0; i 11 | io:format("Port process starting~n"), 12 | start(6). 13 | 14 | start(Idev) -> 15 | S = self(), 16 | Pid = spawn(fun() -> run(S, Idev) end), 17 | receive 18 | {Pid, ack} -> 19 | Pid 20 | end. 21 | 22 | 23 | run(Parent, Idev) -> 24 | process_flag(trap_exit, true), 25 | Prog = elib1_misc:root_dir() ++ "/examples/midi_driver/midi_in_driver", 26 | Port = open_port({spawn, Prog}, [{packet, 2}]), 27 | Port ! {self(), {command, [Idev]}}, 28 | wait_ready(Port), 29 | Parent ! {self(), ack}, 30 | loop(Port, Parent). 31 | 32 | wait_ready(Port) -> 33 | receive 34 | {Port, {data, "ready"}} -> 35 | true; 36 | Any -> 37 | io:format("mid_in_driver unexpected:=~p~n",[Any]), 38 | wait_ready(Port) 39 | end. 40 | 41 | 42 | stop(Pid) -> 43 | Pid ! stop. 44 | 45 | loop(Port, Pid) -> 46 | receive 47 | stop -> 48 | Port ! {self(), close}; 49 | {send, Msg} -> 50 | Port ! {self(), {command, Msg}}, 51 | loop(Port, Pid); 52 | {Port, {data, D}} -> 53 | Pid ! {midi, D}, 54 | loop(Port, Pid); 55 | Any -> 56 | io:format("dropping:~p~n",[Any]), 57 | loop(Port, Pid) 58 | end. 59 | 60 | -------------------------------------------------------------------------------- /supported/midi_driver/midi_out_driver.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(midi_out_driver). 5 | 6 | %% Midi_out_driver 7 | 8 | -compile(export_all). 9 | 10 | test() -> 11 | io:format("Port process starting~n"), 12 | start(1). 13 | 14 | %% K = number of the midi device to open 15 | 16 | start(K) -> 17 | S = self(), 18 | Pid = spawn(fun() -> run(S) end), 19 | receive 20 | {Pid, ack} -> 21 | Pid ! {play,[K]}, 22 | wait_ready(Pid), 23 | Pid 24 | end. 25 | 26 | wait_ready(Pid) -> 27 | receive 28 | {synt, "ready"} -> 29 | true; 30 | Any -> 31 | io:format("sync Any=~p~n",[Any]), 32 | wait_ready(Pid) 33 | end. 34 | 35 | run(Parent) -> 36 | process_flag(trap_exit, true), 37 | Prog = elib1_misc:root_dir() ++ "/examples/midi_driver/midi_out_driver", 38 | Port = open_port({spawn, Prog}, [{packet, 2}]), 39 | Parent ! {self(), ack}, 40 | loop(Port, Parent). 41 | 42 | stop(Pid) -> 43 | Pid ! stop. 44 | 45 | loop(Port, Pid) -> 46 | receive 47 | stop -> 48 | Port ! {self(), close}, 49 | receive 50 | {'EXIT', Port, normal} -> 51 | void; 52 | Any -> 53 | io:format("unexpect port message:~p~n",[Any]) 54 | end; 55 | {play, Data} -> 56 | Port ! {self(), {command, Data}}, 57 | loop(Port, Pid); 58 | {Port, {data, D}} -> 59 | Pid ! {synt, D}, 60 | loop(Port, Pid); 61 | Any -> 62 | io:format("dropping:~p~n",[Any]), 63 | loop(Port, Pid) 64 | end. 65 | 66 | parse_midi(D) -> 67 | {parse_midi, D}. 68 | 69 | -------------------------------------------------------------------------------- /supported/tagger/Makefile: -------------------------------------------------------------------------------- 1 | .SUFFIXES: .erl .beam .yrl 2 | 3 | MODS := $(wildcard *.erl) 4 | 5 | %.beam: %.erl 6 | erlc -W $< 7 | 8 | all: beam 9 | erl -noshell -s make_html start -s init stop 10 | 11 | beam: ${MODS:%.erl=%.beam} 12 | 13 | clean: 14 | rm -rf *.beam 15 | rm -rf html/*.html 16 | rm -rf *.log *.tmp erl_crash.dump 17 | 18 | veryclean: 19 | make clean 20 | rm -rf *~ 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /supported/tagger/Todo: -------------------------------------------------------------------------------- 1 | The todo file has a list of things that need to be done 2 | As entires are added they should be marked as done/by/date 3 | 4 | ToDo 5 | 6 | Open Items (one liners) 7 | 8 | Number Status Assigned Date What 9 | 1 closed joe 2009-12-05 Make an initial release 10 | 2 open joe 2009-12-05 Investigate the bug ... 11 | 12 | Notes: Free text 13 | 14 | [1] started by joe on 2009-12-15 15 | closed by joe on 2009-12-15 16 | 17 | [2] nothing yet 18 | -------------------------------------------------------------------------------- /supported/tagger/doc.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

    Tagger

    5 | 6 |

    Tagger converts Erlang to fully tagged HTML ...

    7 | 8 |

    Setup

    9 | 10 |

    Type make in this directory.

    11 | 12 |

    Then start clicking on elib1_tagger 13 | or elib1_misc

    14 | 15 |

    Bugs

    16 |

    Seems like there is a bug in syntax tools ... or mayby not ...

    17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /supported/tagger/html/erl.css: -------------------------------------------------------------------------------- 1 | .comment {color:green} 2 | .keyword {font-weight:bold} 3 | .string {color: grey} 4 | .var {color:orange} 5 | .bif {color:red; font-weight:bold} 6 | .int {color:#cceeaa} 7 | .atom { } 8 | a:link {text-decoration:none; color:blue} 9 | a:visited {text-decoration:none; color:blue} 10 | 11 | -------------------------------------------------------------------------------- /supported/tagger/make_html.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(make_html). 5 | 6 | -compile(export_all). 7 | 8 | start() -> 9 | process_dir(elib1_misc:root_dir()), 10 | process_dir(code:lib_dir(stdlib)), 11 | process_dir(code:lib_dir(kernel)), 12 | process_dir(code:lib_dir(compiler)). 13 | 14 | process_dir(Dir) -> 15 | L = elib1_find:files(Dir, "*.erl", true), 16 | lists:foreach(fun mk_html/1, L). 17 | 18 | mk_html(In) -> 19 | F = filename:rootname(filename:basename(In)), 20 | Out = "./html/" ++ F ++ ".html", 21 | case elib1_misc:out_of_date(In, Out) of 22 | true -> elib1_tagger:erl2html(In, Out); 23 | false -> void 24 | end. 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /supported/template/Readme: -------------------------------------------------------------------------------- 1 | The template directory has a generic template for all projects 2 | -------------------------------------------------------------------------------- /supported/template/Todo: -------------------------------------------------------------------------------- 1 | The todo file has a list of things that need to be done 2 | As entires are added they should be marked as done/by/date 3 | 4 | ToDo 5 | 6 | Open Items (one liners) 7 | 8 | Number Status Assigned Date What 9 | 1 closed joe 2009-12-05 Make an initial release 10 | 2 open joe 2009-12-05 Improve it 11 | 12 | Notes: Free text 13 | 14 | [1] started by joe on 2009-12-15 15 | closed by joe on 2009-12-15 16 | 17 | [2] nothing yet 18 | -------------------------------------------------------------------------------- /supported/template/doc.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

    Template

    5 | 6 |

    This is an empty template. This entire directory is a 7 | a template that the other applications in the system can be based on. 8 | 9 | 10 | -------------------------------------------------------------------------------- /supported/template/doc.html: -------------------------------------------------------------------------------- 1 |

    Template

    2 | -------------------------------------------------------------------------------- /supported/versions/elib1_lin.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_lin). 5 | 6 | %% (c) Joe Armstrong 2009 7 | 8 | -export([pow/3, inv/2, solve/2, str2int/1, int2str/1, gcd/2]). 9 | 10 | %% pow(A, B, M) => (A^B) mod M 11 | %% examples pow(9726,3533,11413) = 5761 12 | %% pow(5971,6597,11413) = 9726 13 | 14 | 15 | pow(A, 1, M) -> 16 | A rem M; 17 | pow(A, 2, M) -> 18 | A*A rem M; 19 | pow(A, B, M) -> 20 | B1 = B div 2, 21 | B2 = B - B1, 22 | %% B2 = B1 or B1+1 23 | P = pow(A, B1, M), 24 | case B2 of 25 | B1 -> (P*P) rem M; 26 | _ -> (P*P*A) rem M 27 | end. 28 | 29 | %% inv(A, B) = C | no_inverse 30 | %% computes C such that 31 | %% A*C mod B = 1 32 | %% computes A^-1 mod B 33 | %% examples inv(28, 75) = 67. 34 | %% inv(3533, 11200) = 6597 35 | %% inv(6597, 11200) = 3533 36 | 37 | inv(A, B) -> 38 | case solve(A, B) of 39 | {X, _} -> 40 | if X < 0 -> X + B; 41 | true -> X 42 | end; 43 | _ -> 44 | no_inverse 45 | end. 46 | 47 | 48 | %% solve(A, B) => {X, Y} | insoluble 49 | %% solve the linear congruence 50 | %% A * X - B * Y = 1 51 | 52 | solve(A, B) -> 53 | case catch s(A,B) of 54 | insoluble -> insoluble; 55 | {X, Y} -> 56 | case A * X - B * Y of 57 | 1 -> {X, Y}; 58 | _Other -> error 59 | end 60 | end. 61 | 62 | s(_, 0) -> throw(insoluble); 63 | s(_, 1) -> {0, -1}; 64 | s(_, -1) -> {0, 1}; 65 | s(A, B) -> 66 | K1 = A div B, 67 | K2 = A - K1*B, 68 | {Tmp, X} = s(B, -K2), 69 | {X, K1 * X - Tmp}. 70 | 71 | %% converts a string to a base 256 integer 72 | %% converts a base 256 integer to a string 73 | 74 | str2int(Str) -> str2int(Str, 0). 75 | 76 | str2int([H|T], N) -> str2int(T, N*256+H); 77 | str2int([], N) -> N. 78 | 79 | int2str(N) -> int2str(N, []). 80 | 81 | int2str(N, L) when N =< 0 -> L; 82 | int2str(N, L) -> 83 | N1 = N div 256, 84 | H = N - N1 * 256, 85 | int2str(N1, [H|L]). 86 | 87 | %% greatest common devisor 88 | 89 | gcd(A, B) when A < B -> gcd(B, A); 90 | gcd(A, 0) -> A; 91 | gcd(A, B) -> gcd(B, A rem B). 92 | -------------------------------------------------------------------------------- /supported/versions/elib1_ran.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_ran). 5 | %% Author: Joe Armstrong 6 | 7 | -compile(export_all). 8 | 9 | -export([make/1, make_prime/1, is_prime/1]). 10 | 11 | %% make a prime of N decimal digits 12 | make_prime(N) -> 13 | ensure_seeded(), 14 | io:format("Generating a ~p digit prime ",[N]), 15 | D = make(N), 16 | D1 = make_prime(1, D, N), 17 | io:format("~n",[]), 18 | D1. 19 | 20 | make_prime(1000,_,_) -> 21 | no; 22 | make_prime(K, D, N) -> 23 | io:format(".",[]), 24 | case is_prime(100, D, N) of 25 | yes -> D; 26 | {no,X,Y} -> 27 | %% io:format(" ~p ~p~n",[X,Y]), 28 | make_prime(K+1,D+1,N) 29 | end. 30 | 31 | 32 | %% make(N) -> a random integer with N digits. 33 | 34 | make(N) -> ensure_seeded(), make(N, 0). 35 | 36 | make(0, D) -> D; 37 | make(N, D) -> 38 | make(N-1, D*10 + (random:uniform(10)-1)). 39 | 40 | is_prime(D) -> 41 | ensure_seeded(), 42 | %% figure out the number of digits in D 43 | N = length(integer_to_list(D)) -1, 44 | is_prime(100, D, N). 45 | 46 | is_prime(0, _, _) -> yes; 47 | is_prime(Ntest, D, N) -> 48 | %% generate a random number A less than D 49 | K = random:uniform(N), 50 | A = make(K), 51 | if 52 | A < D -> 53 | %% fermat's theormem says that if D is a prime and if A is 54 | %% less than A then 55 | %% A^D mod N = A 56 | case lin:pow(A,D,D) of 57 | A -> is_prime(Ntest-1,D,N); 58 | _ -> {no,A,D} 59 | end; 60 | true -> 61 | is_prime(Ntest, D, N) 62 | end. 63 | 64 | ensure_seeded() -> 65 | case get(random_seed) of 66 | undefined -> 67 | random:seed(); 68 | _ -> 69 | true 70 | end. 71 | -------------------------------------------------------------------------------- /supported/versions/joe.pri: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/supported/versions/joe.pri -------------------------------------------------------------------------------- /supported/versions/joe.pub: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/supported/versions/joe.pub -------------------------------------------------------------------------------- /supported/versions/nmap.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(nmap). 5 | %% autogenerated do not edit by hand. 6 | -export([map/0]). 7 | map()-> 8 | [{elib1_lin,"elib1_lin.erl","joe",mBA4EEB84C7300F1E41DBA739A5B6B5CD, 9 | 500650928944951191769493696474405575381911082979684600684574028039678782452961895406542941703210292296331314543448060202207676628940769232420730584467429973074600328366743002777512870083199695490746}, 10 | {elib1_publish,"elib1_publish.erl","joe",m82025D6B593F591DCA2C22A7B43DB6EC, 11 | 636464549955466392748974332900831709952231824256523563527872010506547342297956920549825210129669000403782500840470220344690637594916922013372431664431956098995366566405451821172889112942363684400402}, 12 | {elib1_ran,"elib1_ran.erl","joe",m79D5C6A6F882B11991744F7B2606CA64, 13 | 2329594173361474324190232482853695316884874897576445382967980843059831465330522412218097243257716364189014793272536186551063744985204144707438220996632378720744597737146912523535510310393381194093597}, 14 | {elib1_rsa,"elib1_rsa.erl","joe",m446C085CB7758C195CF3CF95B16C9DB0, 15 | 2910974264086651494910900305549096653743145448450721038090724889131664658349388178448985611695982877340923237069136719211879080077258623630385819406053147661006782300328845282020650946834233959217038}, 16 | {nmap,"nmap.erl","joe",m544F5B9BA815FE56CEA43EB71D06A39A, 17 | 3405460608445339512672699809127854971584960697012448954746997075547278418926581010074122792050447885153654945475477929458312790736238143004048492874742805075338688720045689981658740063991939196842229}]. 18 | -------------------------------------------------------------------------------- /supported/versions/nmap.erl.bak: -------------------------------------------------------------------------------- 1 | -module(nmap). 2 | %% autogenerated do not edit by hand. 3 | -export([map/0]). 4 | map()-> 5 | [{elib1_lin,"elib1_lin.erl","joe",mBA4EEB84C7300F1E41DBA739A5B6B5CD, 6 | 500650928944951191769493696474405575381911082979684600684574028039678782452961895406542941703210292296331314543448060202207676628940769232420730584467429973074600328366743002777512870083199695490746}, 7 | {elib1_publish,"elib1_publish.erl","joe",m82025D6B593F591DCA2C22A7B43DB6EC, 8 | 636464549955466392748974332900831709952231824256523563527872010506547342297956920549825210129669000403782500840470220344690637594916922013372431664431956098995366566405451821172889112942363684400402}, 9 | {elib1_ran,"elib1_ran.erl","joe",m79D5C6A6F882B11991744F7B2606CA64, 10 | 2329594173361474324190232482853695316884874897576445382967980843059831465330522412218097243257716364189014793272536186551063744985204144707438220996632378720744597737146912523535510310393381194093597}, 11 | {elib1_rsa,"elib1_rsa.erl","joe",m446C085CB7758C195CF3CF95B16C9DB0, 12 | 2910974264086651494910900305549096653743145448450721038090724889131664658349388178448985611695982877340923237069136719211879080077258623630385819406053147661006782300328845282020650946834233959217038}, 13 | {nmap,"nmap.erl","joe",m7CBE67D26BDBC47380640E1DF8B7AA2A, 14 | 3666727335502514916133760025316272493389658267514640302562685959837712754067935401261573681252332278333719327544697312991046139115520450556025427077794159212546493530631229328380103986645559185036756}]. 15 | -------------------------------------------------------------------------------- /supported/website/.#test.html: -------------------------------------------------------------------------------- 1 | joe@localhost.431 -------------------------------------------------------------------------------- /supported/website/.#test1.html: -------------------------------------------------------------------------------- 1 | joe@localhost.431 -------------------------------------------------------------------------------- /supported/website/.#test4.html: -------------------------------------------------------------------------------- 1 | joe@localhost.431 -------------------------------------------------------------------------------- /supported/website/Makefile: -------------------------------------------------------------------------------- 1 | .SUFFIXES: .erl .beam .yrl 2 | 3 | MODS := $(wildcard *.erl) 4 | 5 | %.beam: %.erl 6 | erlc -W $< 7 | 8 | server: beam 9 | 10 | beam: ${MODS:%.erl=%.beam} 11 | 12 | clean: 13 | rm -rf *.beam 14 | rm -rf *.log *.tmp erl_crash.dump 15 | 16 | veryclean: 17 | make clean 18 | rm -rf *~ 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /supported/website/browse.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /supported/website/captions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

    The title is this

    6 | 7 | Dave Letterman 10 |

    11 | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do 12 | eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad 13 | minim veniam, quis nostrud exercitation ullamco laboris nisi ut 14 | aliquip ex ea commodo consequat. Duis aute irure dolor in 15 | reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla 16 | pariatur. Excepteur sint occaecat cupidatat non proident, sunt in 17 | culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum 18 | dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor 19 | incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 20 | quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea 21 | commodo consequat. Duis aute irure dolor in reprehenderit in voluptate 22 | velit esse cillum dolore eu fugiat nulla pariatur. 24 | http://www.askthecssguy.com/2006/12/image_captions_generated_with.html 25 | Excepteur sint occaecat cupidatat non proident, sunt in culpa qui 26 | officia deserunt mollit anim id est laborum. 27 |

    28 | 29 | Jonny Carlson 33 | 34 |

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do 35 | eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad 36 | minim veniam, quis nostrud exercitation ullamco laboris nisi ut 37 | aliquip ex ea commodo consequat. Duis aute irure dolor in 38 | reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla 39 | pariatur. Excepteur sint occaecat cupidatat non proident, sunt in 40 | culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum 41 | dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor 42 | incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 43 | quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea 44 | commodo consequat. Duis aute irure dolor in reprehenderit in voluptate 45 | velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint 46 | occaecat cupidatat non proident, sunt in culpa qui officia deserunt 47 | mollit anim id est laborum. 48 |

    49 | 50 | -------------------------------------------------------------------------------- /supported/website/dave.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/supported/website/dave.jpg -------------------------------------------------------------------------------- /supported/website/doc.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

    Website

    5 | 6 |

    This website is built using an extremely simple 7 | web server and mark-up language.

    8 | 9 |

    The server is stateless and merely returns the requested file. 10 | If the filename extension is .ehtml then the file is expanded.

    11 | 12 |

    .ehtml files

    13 | 14 |

    Files with the extension .ehtml can contain embedded Erlang code. 15 | such code is contained in <? ... ?> brackets.

    16 | 17 |

    Expansion module elib1_expand 18 | expands the expressions within the brackets and replaces the 19 | entire bracked expression by the value of the last expression in the 20 | brackets, which must be a string. So for example, the code seqeunce:

    21 | 22 |
    23 |     <? Who = "Joe", "Hello" ?>
    24 |     my name is <? Who ?>
    25 |   
    26 | 27 |

    Evaluates to:

    28 | 29 |

    30 | 31 | my name is 32 |

    33 | 34 |

    The first line in a .ehtml file is usually:

    35 | 36 |
    37 |     <? M=simple_web_server, M:header() ?>
    38 |   
    39 | 40 |

    Code inclusion

    41 | 42 | 43 | 44 |
    45 |     
    46 |   
    47 | 48 |

    Then start clicking on elib1_tagger 49 | or elib1_misc

    50 | 51 |

    Bugs

    52 |

    Seems like there is a bug in syntax tools ... or mayby not ...

    53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /supported/website/editor.html: -------------------------------------------------------------------------------- 1 | 54 | 55 | 56 | 78 | 79 | 80 | 83 | 84 | 89 | 90 |
    91 |
    92 | 93 |
    94 |

    Content

    95 |
    96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /supported/website/joe.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/supported/website/joe.jpg -------------------------------------------------------------------------------- /supported/website/johnny.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/supported/website/johnny.jpg -------------------------------------------------------------------------------- /supported/website/nav.html: -------------------------------------------------------------------------------- 1 |

    I am nav

    2 | -------------------------------------------------------------------------------- /supported/website/pdf_icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/supported/website/pdf_icon.jpg -------------------------------------------------------------------------------- /supported/website/simple.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin-left:2in; 3 | margin-top:0.5cm; 4 | width:60%; 5 | font-size:1.2em} 6 | 7 | h1 { font-size:1.4em } 8 | 9 | p { text-align:justify } 10 | 11 | p:hover, li:hover 12 | { text-shadow: #ccc 2px 2px 5px; 13 | color:#E20074; 14 | } 15 | 16 | .left { 17 | position:relative; 18 | float:left; 19 | margin: 0 1.2em 4px 0; /* top right bottom left */ 20 | } 21 | 22 | 23 | .right { 24 | position:relative; 25 | float:right; 26 | margin: 0 0 4px 1.2em; 27 | } 28 | 29 | .caption { 30 | font: normal 0.8em; 31 | background:#fff; 32 | color:#000; 33 | position:absolute; 34 | bottom:0; 35 | left:0; 36 | text-align:center; 37 | width:100%; 38 | opacity:.75; 39 | filter:alpha(opacity=85); 40 | } 41 | -------------------------------------------------------------------------------- /supported/website/simple.js: -------------------------------------------------------------------------------- 1 | function setup() 2 | { 3 | $(".xright").each(function(i) { 4 | var text = $(this).attr('alt'); 5 | // alert(text); 6 | $(this).wrap("
    "); 7 | $(this).parent().append("
    " + 8 | text + "
    "); 9 | }); 10 | $(".xleft").each(function(i) { 11 | var text = $(this).attr('alt'); 12 | // alert(text); 13 | $(this).wrap("
    "); 14 | $(this).parent().append("
    " + 15 | text + "
    "); 16 | }); 17 | } 18 | 19 | $(document).ready(function(){setup()}); 20 | -------------------------------------------------------------------------------- /supported/website/test.html: -------------------------------------------------------------------------------- 1 | 44 | 45 | 46 | 47 |

    Test

    48 | 49 |

    50 | This is a simple test with an image in the same directory. 51 | This is a simple test with an image in the same directory. 52 | This is a simple test with an image in the same directory. 53 | This is a simple test with an image in the same directory. 54 | This is a simple test with an image in the same directory. 55 | This is a simple test with an image in the same directory. 56 |

    57 | 58 |

    59 |

    60 | 61 |

    Joe

    62 |
    63 | This is a simple test with an 64 | image in the same directory. This is a simple test with an image in 65 | the same directory. This is a simple test with an image in the same 66 | directory. This is a simple test with an image in the same directory. 67 | This is a simple test with an image in the same 68 | directory. This is a simple test with an image in the same directory. 69 | This is a simple test with an image in the same 70 | directory. This is a simple test with an image in the same directory. 71 | This is a simple test with an image in the same 72 | directory. This is a simple test with an image in the same directory. 73 | This is a simple test with an image in the same 74 | directory. This is a simple test with an image in the same directory. 75 |

    76 | 77 | 78 | -------------------------------------------------------------------------------- /supported/website/test6.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

    The title is this

    6 | 7 | Dave Letterman 10 |

    11 | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do 12 | eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad 13 | minim veniam, quis nostrud exercitation ullamco laboris nisi ut 14 | aliquip ex ea commodo consequat. Duis aute irure dolor in 15 | reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla 16 | pariatur. Excepteur sint occaecat cupidatat non proident, sunt in 17 | culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum 18 | dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor 19 | incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 20 | quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea 21 | commodo consequat. Duis aute irure dolor in reprehenderit in voluptate 22 | velit esse cillum dolore eu fugiat nulla pariatur. 24 | http://www.askthecssguy.com/2006/12/image_captions_generated_with.html 25 | Excepteur sint occaecat cupidatat non proident, sunt in culpa qui 26 | officia deserunt mollit anim id est laborum. 27 |

    28 | 29 | Jonny Carlson 33 | 34 |

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do 35 | eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad 36 | minim veniam, quis nostrud exercitation ullamco laboris nisi ut 37 | aliquip ex ea commodo consequat. Duis aute irure dolor in 38 | reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla 39 | pariatur. Excepteur sint occaecat cupidatat non proident, sunt in 40 | culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum 41 | dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor 42 | incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 43 | quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea 44 | commodo consequat. Duis aute irure dolor in reprehenderit in voluptate 45 | velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint 46 | occaecat cupidatat non proident, sunt in culpa qui officia deserunt 47 | mollit anim id est laborum. 48 |

    49 | 50 | -------------------------------------------------------------------------------- /supported/website/todo.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 |

    Todo

    4 | 5 |
    6 |
    [1] describe streams
    7 | 8 |
    9 | Put into slides in the library 10 |
    11 | 12 |
    13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /supported/website/web_server_one.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(web_server_one). 5 | 6 | %% callback module for a web server 7 | -compile(export_all). 8 | 9 | start() -> 10 | Root = elib1_misc:root_dir(), 11 | File = Root ++ "/data.dets", 12 | elib1_seq_web_server1:start(?MODULE, 13 | elib1_simple_kv_db, 14 | [{name,?MODULE},{file,File}] 15 | ). 16 | 17 | server_port() -> 2246. 18 | max_connections() -> 200. 19 | root() -> elib1_misc:root_dir(). 20 | 21 | %% handle(Request, Db) -> Response 22 | %% Request = {get|put, Vsn, Url, Args, Env} 23 | %% DB = db handler function 24 | %% DB({read,K}) | DB({write,key,val}) 25 | %% Response = {ok, Headers, Body} | {error, What} | close 26 | %% Headers = Atom (html,jpg,...) or [{Key,Val}] 27 | 28 | handle({_,_,"/cgi",[{"mod",M},{"func",Str}|Args],_}, F) -> 29 | Mod = list_to_atom(M), 30 | Func = list_to_atom(Str), 31 | Mod:Func(Args, F); 32 | handle({_, Vsn, F0, Args, _Env}, F) -> 33 | %% DB is a function that can be used to 34 | %% read of write the DB 35 | %% DB({read, Key}) 36 | %% DB({write,Key,Val}) 37 | %% Pid 38 | %% Module_name:read(Pid, Key) 39 | File = F(root) ++ F0, 40 | %% io:format("Get:~p~n",[File]), 41 | elib1_seq_web_server1:default_response(File, Args). 42 | 43 | -------------------------------------------------------------------------------- /supported/website/web_server_two.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(web_server_two). 5 | 6 | %% callback module for a web server 7 | -compile(export_all). 8 | 9 | start() -> 10 | Root = elib1_misc:root_dir(), 11 | File = Root ++ "/data.dets", 12 | elib1_seq_web_server1:start(?MODULE, 13 | elib1_simple_kv_db, 14 | [{name,?MODULE},{file,File}] 15 | ). 16 | 17 | server_port() -> 2246. 18 | max_connections() -> 200. 19 | root() -> elib1_misc:root_dir(). 20 | 21 | %% handle(Request, Db) -> Response 22 | %% Request = {get|put, Vsn, Url, Args, Env} 23 | %% DB = db handler function 24 | %% DB({read,K}) | DB({write,key,val}) 25 | %% Response = {ok, Headers, Body} | {error, What} | close 26 | %% Headers = Atom (html,jpg,...) or [{Key,Val}] 27 | 28 | handle({_,_,"/cgi",[{"mod",M},{"func",Str}|Args],_}, F) -> 29 | Mod = list_to_atom(M), 30 | Func = list_to_atom(Str), 31 | Mod:Func(Args, F); 32 | handle({_, Vsn, F0, Args, _Env}, F) -> 33 | %% DB is a function that can be used to 34 | %% read of write the DB 35 | %% DB({read, Key}) 36 | %% DB({write,Key,Val}) 37 | %% Pid 38 | %% Module_name:read(Pid, Key) 39 | File = F(root) ++ F0, 40 | %% io:format("Get:~p~n",[File]), 41 | elib1_seq_web_server1:default_response(File, Args). 42 | 43 | -------------------------------------------------------------------------------- /unsupported/epeg/Makefile: -------------------------------------------------------------------------------- 1 | .SUFFIXES: .erl .beam .yrl 2 | 3 | .erl.beam: 4 | erlc -W $< 5 | 6 | MODS = epeg_pc epeg_bootstrap epeg_compiler 7 | 8 | ERL = erl -noshell -boot start_clean 9 | 10 | test1: compile 11 | ${ERL} -s epeg_bootstrap batch epeg.peg 12 | ${ERL} -s epeg_bootstrap batch peglib.peg 13 | ${ERL} -s epeg_bootstrap batch pegtest.peg 14 | ${ERL} -s epeg_bootstrap batch erlterm.peg 15 | erlc -W pegtest.erl peglib.erl epeg.erl erlterm.erl 16 | @${ERL} -s pegtest test 17 | @${ERL} -s epeg test 18 | @${ERL} -s erlterm test 19 | 20 | compile: ${MODS:%=%.beam} 21 | 22 | clean: 23 | rm -rf *.beam *~ pegtest.erl peglib.erl erlterm.erl erl_crash.dump 24 | rm -rf *.COVER.out 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /unsupported/epeg/Readme: -------------------------------------------------------------------------------- 1 | epeg.erl -- the output of running epeg:file("epeg.peg"). 2 | epeg.peg -- a peg grammar for epeg 3 | epeg_pc.erl -- parser combinators used by epeg 4 | epeg_compiler.erl -- epeg compiler 5 | samples.peg -- simple peg samples 6 | erlparse.peg -- parsing Erlang forms 7 | epg_boot.erl -- the bootstrap that created epeg.erl from epeg.peg 8 | Makefile -- makefile 9 | 10 | Make targets are: 11 | 12 | make -- compiles epeg.peg using the bootstrap compiler 13 | runs test cases 14 | 15 | 16 | -------------------------------------------------------------------------------- /unsupported/epeg/bug.peg: -------------------------------------------------------------------------------- 1 | # test a few peg expressions 2 | 3 | s = " "*; # spaces 4 | 5 | a = b; 6 | 7 | %{ 8 | 9 | line([_,X,_]) -> X. 10 | 11 | %} 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /unsupported/epeg/doc.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

    Epeg

    5 | 6 |

    Erlang PEG grammar

    7 |
     8 | epeg.erl          -- the output of running epeg:file("epeg.peg").
     9 | epeg.peg          -- a peg grammar for epeg
    10 | epeg_pc.erl       -- parser combinators used by epeg
    11 | epeg_compiler.erl -- epeg compiler
    12 | samples.peg       -- simple peg samples
    13 | erlparse.peg      -- parsing Erlang forms
    14 | epg_boot.erl      -- the bootstrap that created epeg.erl from epeg.peg
    15 | Makefile         -- makefile
    16 | 
    17 | Make targets are:
    18 | 
    19 | make    -- compiles epeg.peg using the bootstrap compiler
    20 |                  runs test cases
    21 | 
    22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /unsupported/epeg/epeg2erl: -------------------------------------------------------------------------------- 1 | #/bin/sh 2 | erl -noshell -pa '.' -s epeg_bootstrap peg2erl $1 3 | -------------------------------------------------------------------------------- /unsupported/epeg/peglib.peg: -------------------------------------------------------------------------------- 1 | int = [0-9]+; 2 | 3 | float = [0-9]+ "." [0-9]+ ("e" ("+"|"-")? [0-9]+)? ; 4 | 5 | # semantic function (which deals with the parse tree) is: 6 | 7 | %{ 8 | 9 | final(int, L) -> 10 | list_to_integer(L); 11 | 12 | final(float, [A,_,C,D]) -> 13 | D1 = toexp(D), 14 | Str = lists:flatten([A,".",C,D1]), 15 | {float, list_to_float(Str)}. 16 | 17 | toexp([]) -> []; 18 | toexp([[e,['-'],S]]) -> ["e-",S]; 19 | toexp([[e,['+'],S]]) -> ["e+",S]; 20 | toexp([[e,[], S]]) -> ["e",S]. 21 | 22 | %} 23 | -------------------------------------------------------------------------------- /unsupported/epeg/pegtest.peg: -------------------------------------------------------------------------------- 1 | # test a few peg expressions 2 | 3 | s = " "* ; # spaces 4 | 5 | line = s (token s)*; 6 | 7 | token = peglib:float | peglib:int | atom; 8 | 9 | atom = [a-z]+; 10 | 11 | %{ 12 | 13 | test() -> 14 | {Toks, []} = ?MODULE:parse_line(" 1234 abc 12.23 34"), 15 | [{token,1234}, 16 | {token,{atom,"abc"}}, 17 | {token,{float,_}}, 18 | {token,34}] = Toks, 19 | io:format("test:test worked~n"), 20 | init:stop(). 21 | 22 | final(line, [_,L]) -> 23 | [I || [I,_] <- L]; 24 | final(Tag, Val) -> 25 | {Tag, Val}. 26 | 27 | 28 | %} 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /unsupported/epeg/string_metrics.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | %%%============================================================================= 5 | %%% @author Adam Lindberg 6 | %%% Fredrik Svensson 7 | %%% @doc This module contains string metric operations. 8 | %%% 9 | %%% Currently only the function {@link levenshtein/2}. 10 | %%% @end 11 | %%%============================================================================= 12 | -module(string_metrics). 13 | 14 | %% from www.trapexit.org 15 | 16 | -export([levenshtein/2]). 17 | 18 | %%------------------------------------------------------------------------------ 19 | %% @spec levenshtein(StringA, StringB) -> integer() 20 | %% StringA = StringB = string() 21 | %% @doc Calculates the Levenshtein distance between two strings 22 | %% @end 23 | %%------------------------------------------------------------------------------ 24 | 25 | levenshtein(Samestring, Samestring) -> 0; 26 | levenshtein(String, []) -> length(String); 27 | levenshtein([], String) -> length(String); 28 | levenshtein(Source, Target) -> 29 | levenshtein_rec(Source, Target, lists:seq(0, length(Target)), 1). 30 | 31 | %% Recurses over every character in the source string and calculates a list of distances 32 | levenshtein_rec([SrcHead|SrcTail], Target, DistList, Step) -> 33 | levenshtein_rec(SrcTail, Target, 34 | levenshtein_distlist(Target, DistList, SrcHead, 35 | [Step], Step), Step + 1); 36 | levenshtein_rec([], _, DistList, _) -> 37 | lists:last(DistList). 38 | 39 | %% Generates a distance list with distance values for every character in the target string 40 | levenshtein_distlist([TargetHead|TargetTail], [DLH|DLT], 41 | SourceChar, NewDistList, LastDist) when length(DLT) > 0 -> 42 | Min = lists:min([LastDist + 1, hd(DLT) + 1, 43 | DLH + dif(TargetHead, SourceChar)]), 44 | levenshtein_distlist(TargetTail, DLT, SourceChar, NewDistList ++ [Min], Min); 45 | levenshtein_distlist([], _, _, NewDistList, _) -> 46 | NewDistList. 47 | 48 | % Calculates the difference between two characters or other values 49 | dif(C, C) -> 0; 50 | dif(_, _) -> 1. 51 | -------------------------------------------------------------------------------- /unsupported/epeg/test.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(test). 5 | -compile(export_all). 6 | -import(lists, [map/2, reverse/1]). 7 | 8 | %% -------------- begin ---------------- 9 | %% DEFN s = " "* ; 10 | 11 | %% Abstract syntax: 12 | %% {star,{lit," "}} 13 | %% 14 | 15 | parse_s(S)-> 16 | {Val, S1} = 17 | (epeg_pc:star(fun(" " ++ V1) -> {' ', V1} end ))(S), 18 | {epeg_pc:done(?MODULE,s,Val), S1}. 19 | 20 | %% =============== end ================= 21 | 22 | %% -------------- begin ---------------- 23 | %% DEFN line = s (token s)* ; 24 | 25 | %% Abstract syntax: 26 | %% {seq,[{nt,"s"},{star,{seq,[{nt,"token"},{nt,"s"}]}}]} 27 | %% 28 | 29 | parse_line(S)-> 30 | {Val, S1} = 31 | (epeg_pc:seq([ 32 | fun parse_s/1, 33 | epeg_pc:star(epeg_pc:seq([ 34 | fun parse_token/1, 35 | fun parse_s/1]))]))(S), 36 | {epeg_pc:done(?MODULE,line,Val), S1}. 37 | 38 | %% =============== end ================= 39 | 40 | %% -------------- begin ---------------- 41 | %% DEFN token = peglib:float | peglib:int | atom ; 42 | 43 | %% Abstract syntax: 44 | %% {alt,[{nt,"peglib","float"}, 45 | %% {nt,"peglib","int"}, 46 | %% {nt,"atom"}]} 47 | %% 48 | 49 | parse_token(S)-> 50 | {Val, S1} = 51 | (epeg_pc:alt([ 52 | fun peglib:parse_float/1, 53 | fun peglib:parse_int/1, 54 | fun parse_atom/1]))(S), 55 | {epeg_pc:done(?MODULE,token,Val), S1}. 56 | 57 | %% =============== end ================= 58 | 59 | %% -------------- begin ---------------- 60 | %% DEFN atom = [a-z]+ ; 61 | 62 | %% Abstract syntax: 63 | %% {plus,{class,[{97,122}]}} 64 | %% 65 | 66 | parse_atom(S)-> 67 | {Val, S1} = 68 | (epeg_pc:plus(epeg_pc:cc([{97,122}])))(S), 69 | {epeg_pc:done(?MODULE,atom,Val), S1}. 70 | 71 | %% =============== end ================= 72 | 73 | 74 | 75 | test() -> 76 | {Toks, []} = test:parse_line(" 1234 abc 12.23 34"), 77 | [{token,1234}, 78 | {token,{atom,"abc"}}, 79 | {token,{float,_}}, 80 | {token,34}] = Toks, 81 | io:format("test:test worked~n"), 82 | init:stop(). 83 | 84 | final(line, [_,L]) -> 85 | [I || [I,_] <- L]; 86 | final(Tag, Val) -> 87 | {Tag, Val}. 88 | 89 | 90 | -------------------------------------------------------------------------------- /unsupported/folding/doc.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

    A folding editor

    5 | 6 |

    Nothing to do with Erlang.

    7 | 8 |

    9 | This is some JavaScript that I tried to make a folding editor 10 | with. 11 |

    12 | 13 |

    If anybody who is skilled in the art can fix the problems below then 14 | I will be able to integrate this with an Erlang content management system

    15 | 16 |
      17 |
    • Run the latest version f3
    • 18 |
    19 | 20 |

    Problems with this:

    21 |
      22 |
    • Focus - when I hit down arrow a few times the focus moves off screen 23 | I need to scroll the display to keep the focus on screen
    • 24 |
    • Keyboard mappings. This works fine on firefox/ubuntu, but not on my 25 | mac (I think). Need a portable way of doing this that works on all 26 | browsers.
    • 27 |
    28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /unsupported/folding/folding_editor.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 45 | 46 | 47 | 48 | 49 |

    Arrow keys up + down moves the focus 50 | u + d moves the object. Enter opens or closes a fold.

    51 | 52 | 56 | 57 |
    53 | 54 |
    55 |
    58 | 59 |
    60 |
    61 | 62 |

    63 |

    64 |
    65 |

    66 | 67 | -------------------------------------------------------------------------------- /unsupported/folding/instructions.js: -------------------------------------------------------------------------------- 1 | 2 | var data = [ 3 | {header:"Getting started", 4 | expanded: true, 5 | content: "You are now interacting with an on-line //folding// editor - all commands are entered from the keyboard.^Please remember not to use your mouse. Just hit enter twice to see what happens.Then read the section on //navigation//.\n!!Navigation\nYou can navigate round the document using the keyboard.\n*Enter opens or closes a fold\n*The //up// and //down// arrows change the selections\nNow try to close this fold, move to the fold marked //editing//, and open the fold"}, 6 | {header:"Editing", 7 | content:"To edit a fold just hit the **e** key. You will be thrown into an editor - you'll see the text and the rendered text in two different windows. As You edit the text the //rendered text will change//.\n\nWhen you have finished editing hit escape"}, 8 | {header:"How to make a header", 9 | content:"> !A header\n>!!Sub-header\nproduces\n!header1\n!!Sub-header\n\nHit //e// to see the code"}, 10 | {header:"Inlines", 11 | content:"Text can be --struck through-- or **bold** or //emphasised// or <>\nHit //e// to see how this is represented"}, 12 | {header:"Preformatted text", 13 | content:"To make preformatted text\n> just preceed every\n> line with a >\nHit //e// to see the code"}, 14 | {header:"Organising your text", 15 | content:"To move a block up or down just hit the **u** or **d** keys"}, 16 | {header:"Modes", 17 | content:"The editor can run two modes //folding mode// or //non-folding mode//.\n\nTo change modes hit the **m** key."}, 18 | {header:"To do", 19 | content:"* fix bug with quoting to so I can write (star)(star) in text\n*Only know to work with **firefox**\n*--Add mode to render all data in non-folding mode--\n*--Add wrap around for select--\n*Edit the header\n*Add new header\n*images"}]; 20 | 21 | -------------------------------------------------------------------------------- /unsupported/jpeg/decode.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(decode). 5 | 6 | -compile(export_all). 7 | 8 | -import(lists, [reverse/1, seq/2, sum/1]). 9 | 10 | zigzag([X1, X2, X3, X4, X5, X6, X7, X8, 11 | X9, X10,X11,X12,X13,X14,X15,X16, 12 | X17,X18,X19,X20,X21,X22,X23,X24, 13 | X25,X26,X27,X28,X29,X30,X31,X32, 14 | X33,X34,X35,X36,X37,X38,X39,X40, 15 | X41,X42,X43,X44,X45,X46,X47,X48, 16 | X49,X50,X51,X52,X53,X54,X55,X56, 17 | X57,X58,X59,X60,X61,X62,X63,X64]) -> 18 | [X1,X2,X9,X17,X10,X3,X4,X11,X18, 19 | X25,X33,X26,X19,X12,X5,X6,X13, 20 | X20,X27,X34,X41,X49,X42, 21 | X35,X28,X21,X14,X7,X8,X15,X22,X29, 22 | X36,X43,X50,X57,X58,X51,X44,X37,X30,X23,X16,X24,X31,X38, 23 | X45,X52,X59,X60,X53,X46,X39,X32,X40,X47, 24 | X54,X61,X62,X55,X48,X56,X63,X64]. 25 | 26 | data1() -> 27 | {139,144,149,153,155,155,155,155, 28 | 144,151,153,156,159,156,156,156, 29 | 150,155,160,163,158,156,156,156, 30 | 159,161,162,160,160,159,159,159, 31 | 159,160,161,162,162,155,155,155, 32 | 161,161,161,161,160,157,157,157, 33 | 162,162,161,163,162,157,157,157, 34 | 162,162,161,161,163,158,158,158}. 35 | 36 | quant() -> 37 | [16,11,10,16,24,40,51,61, 38 | 12,12,14,19,26,58,60,55, 39 | 14,13,16,24,40,57,69,56, 40 | 14,17,22,29,51,87,80,62, 41 | 18,22,37,56,68,109,103,77, 42 | 24,35,55,64,81,104,113,92, 43 | 49,64,78,87,103,121,120,101, 44 | 72,92,95,98,112,100,103,99]. 45 | 46 | test1() -> 47 | D1 = data1(), 48 | D2 = list_to_tuple([I-128 || I <- tuple_to_list(D1)]), 49 | DCT = dct(D2), 50 | Q = quant(DCT,quant()), 51 | f8(Q). 52 | 53 | quant([H1|T1],[QH|QT]) -> 54 | [iround(H1/QH)|quant(T1, QT)]; 55 | quant([], []) -> 56 | []. 57 | 58 | iround(X) when X > 0 -> trunc(X+0.5); 59 | iround(X) -> trunc(X-0.5). 60 | 61 | dct(T) -> 62 | [bigF(U,V,T) || U <- seq(0,7), V <- seq(0,7)]. 63 | 64 | -define(Pi1, 0.19634954084936207). %% Pi/16 65 | 66 | bigF(U,V,T) -> 67 | 0.25 * c(U) * c(V) * 68 | sum([f(X,Y,T) * 69 | math:cos((2*X+1)*U*?Pi1) * 70 | math:cos((2*Y+1)*V*?Pi1) || X <- seq(0,7), Y <- seq(0,7)]). 71 | 72 | f(X,Y,T) -> 73 | element(8*X+Y+1, T). 74 | 75 | c(0) -> 0.7071067811865475; 76 | c(_) -> 1.0. 77 | 78 | f8([]) -> 79 | []; 80 | f8(L) -> 81 | {H,T} = take(8, L, []), 82 | [H|f8(T)]. 83 | 84 | take(0, L, L1) -> 85 | {reverse(L1), L}; 86 | take(N, [H|T], L) -> 87 | take(N-1, T, [H|L]). 88 | -------------------------------------------------------------------------------- /unsupported/jpeg/doc.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

    Image manipulation in Erlang

    5 | 6 |

    Yes it is possible

    7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /unsupported/jpeg/itu-t81.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/unsupported/jpeg/itu-t81.pdf -------------------------------------------------------------------------------- /unsupported/jpeg/jfif3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joearms/elib1/d617d0ec70a058ef102749eadf51c024444c28d9/unsupported/jpeg/jfif3.pdf -------------------------------------------------------------------------------- /unsupported/jpeg/jpeg_fugi.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(jpeg). 5 | 6 | -export([time/1]). 7 | 8 | -import(lists, [filter/2, reverse/1, foreach/2]). 9 | 10 | time(File) -> 11 | L = parse(File), 12 | %% io:format("L=~p~n",[L]), 13 | time1(L). 14 | 15 | time1({ok, BB}) -> 16 | case (catch get_time(binary_to_list(BB))) of 17 | error -> 18 | error; 19 | X -> 20 | {ok, X} 21 | end; 22 | time1(error) -> error. 23 | 24 | get_time("Digital Camera FinePix4700 ZOOM Ver1.00\000" ++ T) -> 25 | extract_time(T); 26 | get_time([_|T]) -> 27 | get_time(T); 28 | get_time([]) -> 29 | error. 30 | 31 | extract_time([0|_]) -> 32 | []; 33 | extract_time([H|T]) -> 34 | [H|extract_time(T)]; 35 | extract_time([]) -> 36 | throw(error). 37 | 38 | 39 | parse(File) -> 40 | {ok, Bin} = file:read_file(File), 41 | p(Bin). 42 | 43 | p(Bin) -> 44 | case binary_head(Bin, 2) of 45 | {[16#ff,16#d8], B1} -> 46 | p_seq(B1); 47 | fail -> 48 | exit(not_jpg) 49 | end. 50 | 51 | binary_head(Bin, Len) -> 52 | case split_binary(Bin, Len) of 53 | {'EXIT', _} -> fail; 54 | {B1, B2} -> {binary_to_list(B1), B2} 55 | end. 56 | 57 | p_seq(Bin) -> 58 | case binary_head(Bin, 2) of 59 | {[16#ff,16#da], B} -> error; 60 | _ -> 61 | case binary_head(Bin, 4) of 62 | {[16#ff,Type,Msb,Lsb],T} -> 63 | Len = (Msb bsl 8) bor Lsb, 64 | {B1, B2} = split_binary(T, Len-2), 65 | io:format("~p ~n",[Type]), 66 | case Type of 67 | 225 -> 68 | {ok, B1}; 69 | _ -> 70 | p_seq(B2) 71 | end; 72 | fail -> 73 | exit(fail) 74 | end 75 | end. 76 | 77 | 78 | -------------------------------------------------------------------------------- /unsupported/work/circle.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
    4 | 5 | 21 | 22 | The Origional code was 23 |
    24 | <embed src="circle.svg" width="50" height="50" type="image/svg+xml" />
    25 | 
    26 | <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
    27 | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
    28 |     "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
    29 |     <!ATTLIST svg
    30 |               xmlns:a3 CDATA #IMPLIED
    31 |               a3:scriptImplementation CDATA #IMPLIED>
    32 |     <!ATTLIST script
    33 |               a3:scriptImplementation CDATA #IMPLIED>
    34 | ]>
    35 | <svg onload="makeShape(evt)"
    36 |      xmlns="http://www.w3.org/2000/svg"
    37 |      xmlns:xlink="http://www.w3.org/1999/xlink"
    38 |      xmlns:a3="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
    39 |      a3:scriptImplementation="Adobe">
    40 |     <script type="text/ecmascript" a3:scriptImplementation="Adobe"><![CDATA[
    41 |         var svgns = "http://www.w3.org/2000/svg";
    42 | 
    43 |         function makeShape(evt) {
    44 |             if ( window.svgDocument == null )
    45 |                 svgDocument = evt.target.ownerDocument;
    46 | 
    47 |             var shape = svgDocument.createElementNS(svgns, "circle");
    48 |             shape.setAttributeNS(null, "cx", 25);
    49 |             shape.setAttributeNS(null, "cy", 25);
    50 |             shape.setAttributeNS(null, "r",  20);
    51 |             shape.setAttributeNS(null, "fill", "green");
    52 |             
    53 |             svgDocument.documentElement.appendChild(shape);
    54 |         }
    55 |     ]]></script>
    56 | </svg>
    57 | 
    58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /unsupported/work/circle.svg: -------------------------------------------------------------------------------- 1 | 2 | 7 | 9 | ]> 10 | 15 | 31 | 32 | -------------------------------------------------------------------------------- /unsupported/xml/chap.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | 27 | 28 | 29 | 30 | 35 | -------------------------------------------------------------------------------- /unsupported/xml/doc.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

    XML validation

    5 | 6 |

    Not in erlang but useful anyway

    7 | 8 |

    Validating XML 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /unsupported/xml/entry.dtd: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /unsupported/xml/log.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /unsupported/xml/my_catalog.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 10 | 12 | 13 | -------------------------------------------------------------------------------- /unsupported/xml/story.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /unsupported/xml/story.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The Happy Dragon 5 |

    Wet Matches
    6 |

    Once upon a time there was a dragon whoes matches were wet ...

    7 |

    ...

    8 |

    .. and I shall starve to death

    9 |
    Happy at Last
    10 |

    ...

    11 |

    And they all lived happily ever after.

    12 | 13 | -------------------------------------------------------------------------------- /unsupported/xml/test.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 35 | -------------------------------------------------------------------------------- /wanted/doc.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

    Wanted

    6 | 7 |

    This section is for wanted programs. These are programs that are 8 | wanted but not yet written.

    9 | 10 |

    The life cycle of a program

    11 | 12 |
      13 |
    1. You check the library - what you want is missing.
    2. 14 |
    3. You choose a sensible name for your module, we'll call it 15 | MYNAME here.
    4. 16 |
    5. You fork the library and add a module stub in 17 | /wanted/src/elib1_MYNAME.erl You write some 18 | edoc annotations to say what you want and why
    6. 19 |
    7. For longer requests you write a request and put it in 20 | /wanted/notes/MYNAME.ehtml
    8. 21 |
    9. You request that the form be pulled into the main branch
    10. 22 |
    11. The moderator accepts or rejects the request
    12. 23 |
    13. If accepted, sooner of later somebody starts work on your code
    14. 24 |
    15. The code matures (in a forked version)
    16. 25 |
    17. A request is made to move the code to the supported, unsupported or 26 | lib branch of the library.
    18. 27 |
    28 | 29 |

    Notes

    30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /wanted/notes/registry.ehtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

    A name register

    6 | 7 |

    You have written your program and you want the world to use it. 8 | We need something like a dynamic DNS to register your program with.

    9 | 10 |

    You want a single liner

    11 | 12 |

    elib1_dynamic_register(self(), "Name")

    13 | 14 | 15 | -------------------------------------------------------------------------------- /wanted/src/elib1_bloom.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) 2006-2009 Joe Armstrong 2 | %% See MIT-LICENSE for licensing information. 3 | 4 | -module(elib1_bloom). 5 | -export([filter/1]). 6 | %% @doc I want a bloom filter 7 | --------------------------------------------------------------------------------