nosql-tutorial 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/README.markdown +20 -0
  2. data/Rakefile +34 -0
  3. data/VERSION.yml +5 -0
  4. data/lib/config.ru +12 -0
  5. data/lib/nosql.rb +64 -0
  6. data/lib/public/doc/mail/body.txt +1 -0
  7. data/lib/public/doc/mail/mail-00.rb +31 -0
  8. data/lib/public/doc/mail/mail-01.rb +29 -0
  9. data/lib/public/doc/mail/mail-10.rb +24 -0
  10. data/lib/public/doc/mail/motylek.jpeg +0 -0
  11. data/lib/public/doc/plain-text-files/contacts.yaml +11 -0
  12. data/lib/public/doc/plain-text-files/contacts_g.rb +105 -0
  13. data/lib/public/doc/plain-text-files/contacts_g_test.rb +51 -0
  14. data/lib/public/doc/plain-text-files/contacts_y.rb +57 -0
  15. data/lib/public/doc/plain-text-files/contacts_y_test.rb +39 -0
  16. data/lib/public/doc/plain-text-files/gdbm-example.rb +22 -0
  17. data/lib/public/doc/using-plain-text-files-for-data-persistence.pdf +0 -0
  18. data/lib/public/favicon.ico +0 -0
  19. data/lib/public/images/conan_doyle.jpg +0 -0
  20. data/lib/public/images/datamapper.png +0 -0
  21. data/lib/public/images/datamapper.svg +95 -0
  22. data/lib/public/stylesheets/fonts/Cyklop-Italic.otf +0 -0
  23. data/lib/public/stylesheets/icons/cross.png +0 -0
  24. data/lib/public/stylesheets/icons/doc.png +0 -0
  25. data/lib/public/stylesheets/icons/email.png +0 -0
  26. data/lib/public/stylesheets/icons/external.png +0 -0
  27. data/lib/public/stylesheets/icons/feed.png +0 -0
  28. data/lib/public/stylesheets/icons/im.png +0 -0
  29. data/lib/public/stylesheets/icons/key.png +0 -0
  30. data/lib/public/stylesheets/icons/pdf.png +0 -0
  31. data/lib/public/stylesheets/icons/tick.png +0 -0
  32. data/lib/public/stylesheets/icons/visited.png +0 -0
  33. data/lib/public/stylesheets/icons/xls.png +0 -0
  34. data/lib/public/stylesheets/ie.css +27 -0
  35. data/lib/public/stylesheets/nosql.css +166 -0
  36. data/lib/public/stylesheets/print.css +30 -0
  37. data/lib/public/stylesheets/screen.css +249 -0
  38. data/lib/public/stylesheets/src/body.png +0 -0
  39. data/lib/public/stylesheets/src/grid.png +0 -0
  40. data/lib/public/stylesheets/src/make_background_images.sh +11 -0
  41. data/lib/public/stylesheets/src/shattered_mirror.png +0 -0
  42. data/lib/public/stylesheets/uv.css +121 -0
  43. data/lib/views/ar.rdiscount +5 -0
  44. data/lib/views/datamapper.rdiscount +43 -0
  45. data/lib/views/layout.rdiscount +38 -0
  46. data/lib/views/main.rdiscount +47 -0
  47. data/lib/views/mongodb.rdiscount +41 -0
  48. data/lib/views/redis.rdiscount +20 -0
  49. data/lib/views/ruby-intro.rdiscount +37 -0
  50. data/lib/views/serializacja-danych.rdiscount +75 -0
  51. data/lib/views/skel.rdiscount +3 -0
  52. data/lib/views/summary.rdiscount +32 -0
  53. metadata +175 -0
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+
3
+ convert -size 1x913 xc:'#FEF9F0' a.png
4
+ convert -size 1x22 xc:'#0B030C' -alpha set -channel A -fx '0.61' b.png
5
+ convert a.png b.png -append -rotate 90 body.png
6
+ rm a.png b.png
7
+ #convert -size 1x913 xc:'#0B030C' -alpha set -channel A -fx '0.61' a.png
8
+ #convert -size 1x22 xc:'#0B030C' -alpha set -channel A -fx '0.61' b.png
9
+ #convert a.png b.png -append -rotate 90 h1.png
10
+ #rm a.png b.png
11
+ #convert -size 1024x100 xc:'#0B030C' -alpha set -channel A -fx '0.61' h1.png
@@ -0,0 +1,121 @@
1
+ pre.dawn .MetaSeparator {
2
+ font-weight: bold;
3
+ background-color: #DCDCDC;
4
+ color: #19356D;
5
+ }
6
+ pre.dawn .SupportVariable {
7
+ color: #234A97;
8
+ }
9
+ pre.dawn .Constant {
10
+ font-weight: bold;
11
+ color: #811F24;
12
+ }
13
+ pre.dawn .EmbeddedSource {
14
+ background-color: #829AC2;
15
+ }
16
+ pre.dawn .StringRegexpConstantCharacterEscape {
17
+ font-weight: bold;
18
+ color: #811F24;
19
+ }
20
+ pre.dawn .Support {
21
+ color: #691C97;
22
+ }
23
+ pre.dawn .MarkupList {
24
+ color: #693A17;
25
+ }
26
+ pre.dawn .Storage {
27
+ color: #A71D5D;
28
+ font-style: italic;
29
+ }
30
+ pre.dawn .line-numbers {
31
+ background-color: #7496CF;
32
+ color: #000000;
33
+ }
34
+ pre.dawn .StringConstant {
35
+ font-weight: bold;
36
+ color: #696969;
37
+ }
38
+ pre.dawn .MarkupUnderline {
39
+ text-decoration: underline;
40
+ color: #080808;
41
+ }
42
+ pre.dawn .MarkupHeading {
43
+ font-weight: bold;
44
+ color: #19356D;
45
+ }
46
+ pre.dawn .SupportConstant {
47
+ color: #B4371F;
48
+ }
49
+ pre.dawn .MarkupQuote {
50
+ background-color: #C5C5C5;
51
+ color: #0B6125;
52
+ font-style: italic;
53
+ }
54
+ pre.dawn .StringRegexpSpecial {
55
+ font-weight: bold;
56
+ color: #CF5628;
57
+ }
58
+ pre.dawn .InvalidIllegal {
59
+ background-color: #B52A1D;
60
+ color: #F8F8F8;
61
+ font-style: italic;
62
+ }
63
+ pre.dawn .MarkupDeleted {
64
+ color: #B52A1D;
65
+ }
66
+ pre.dawn .MarkupRaw {
67
+ background-color: #C5C5C5;
68
+ color: #234A97;
69
+ }
70
+ pre.dawn .SupportFunction {
71
+ color: #693A17;
72
+ }
73
+ pre.dawn .PunctuationSeparator {
74
+ color: #794938;
75
+ }
76
+ pre.dawn .StringRegexp {
77
+ color: #CF5628;
78
+ }
79
+ pre.dawn .StringEmbeddedSource {
80
+ background-color: #829AC2;
81
+ color: #080808;
82
+ }
83
+ pre.dawn .MarkupLink {
84
+ color: #234A97;
85
+ font-style: italic;
86
+ }
87
+ pre.dawn .MarkupBold {
88
+ font-weight: bold;
89
+ color: #080808;
90
+ }
91
+ pre.dawn .StringVariable {
92
+ color: #234A97;
93
+ }
94
+ pre.dawn .String {
95
+ color: #0B6125;
96
+ }
97
+ pre.dawn .Keyword {
98
+ color: #794938;
99
+ }
100
+ pre.dawn {
101
+ background-color: #F5F5F5;
102
+ color: #080808;
103
+ }
104
+ pre.dawn .MarkupItalic {
105
+ color: #080808;
106
+ font-style: italic;
107
+ }
108
+ pre.dawn .InvalidDeprecated {
109
+ font-weight: bold;
110
+ color: #B52A1D;
111
+ }
112
+ pre.dawn .Variable {
113
+ color: #234A97;
114
+ }
115
+ pre.dawn .Entity {
116
+ color: #BF4F24;
117
+ }
118
+ pre.dawn .Comment {
119
+ color: #5A525F;
120
+ font-style: italic;
121
+ }
@@ -0,0 +1,5 @@
1
+ #### {% title "ORM na przykładzie ActiveRecord" %}
2
+
3
+ # ORM na przykładzie ActiveRecord
4
+
5
+ TODO
@@ -0,0 +1,43 @@
1
+ #### {% title "Datamapper" %}
2
+
3
+ # Datamapper: dm-couchdb, …
4
+
5
+
6
+ ## Instalacja
7
+
8
+ Instalujemy następujące gemy:
9
+
10
+ sudo gem install dm-core dm-more
11
+ sudo gem install do_sqlite3 do_postgres
12
+ sudo gem install dm-validations dm-timestamps
13
+ sudo gem install dm-aggregates dm-types
14
+
15
+ oraz trochę wtyczek. Wszystkie są
16
+ [opisane tutaj](http://datamapper.org/doku.php?id=docs:more).
17
+
18
+
19
+ ## Zestawianie połączenia z bazą SQL
20
+
21
+ SQLite
22
+
23
+ :::ruby
24
+ # baza danych w RAM
25
+ DataMapper.setup(:default, 'sqlite3::memory:')
26
+ # baza danych plikiem
27
+ DataMapper.setup(:default, "sqlite3:///#{Dir.pwd}/test.sqlite")
28
+
29
+ PostgreSQL
30
+
31
+ :::ruby
32
+ # Postgres 8.2+
33
+ DataMapper.setup(:default, 'postgres://localhost/test')
34
+
35
+ **Uwaga**: You may be wondering how to be more specific about your database
36
+ connection. The second argument can be a hash, containing :host,
37
+ :adapter, :database, :username, :password, :socket, etc. These are
38
+ database-specific but this ought to get you going.
39
+
40
+
41
+ ## Zestawianie połączenia z bazą noSQL
42
+
43
+ TODO
@@ -0,0 +1,38 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
5
+
6
+ <%= stylesheet_link_tag "/stylesheets/screen.css", "/stylesheets/uv.css", "/stylesheets/nosql.css" %>
7
+ <%= stylesheet_link_tag "/stylesheets/print.css", :media => "print" %>
8
+ <!--[if IE]>
9
+ <%= stylesheet_link_tag "css/blueprint/ie.css" %>
10
+ <![endif]-->
11
+
12
+ <title><%= "WB_NOSQL" + page_title %></title>
13
+ </head>
14
+ <body>
15
+ <div class="span-21" id="header">
16
+ <div class="push-1 span-7">
17
+ <a href="/nosql/"><span id="wb">WB</span>@<span id="tutorial">NOSQL</span></a>
18
+ </div>
19
+ <div class="span-13 last">
20
+ <div class="append-1" id="links">
21
+ <a href="http://sigma.ug.edu.pl/~wbzyl/">home</a>
22
+ <a href="http://sigma.ug.edu.pl/~wbzyl/galeria/zakopane/2009-08-28-zawrat/">galeria</a>
23
+ </div>
24
+ </div>
25
+ </div>
26
+
27
+ <div class="span-21 container"><!-- showgrid -->
28
+ <div class="push-1 span-12" id="content">
29
+
30
+ <%= yield %>
31
+
32
+ </div>
33
+ <div class="span-8 last">
34
+ </div>
35
+ </div>
36
+
37
+ </body>
38
+ </html>
@@ -0,0 +1,47 @@
1
+ # Not only SQL – Data Persistence
2
+
3
+ <blockquote>
4
+ {%= image_tag "/images/conan_doyle.jpg", :alt => "[Sir Arthur Conan Doyle]" %}
5
+ <p>
6
+ I never guess. It is a capital mistake to theorize before one has
7
+ data. Insensibly one begins to twist facts to suit theories, instead
8
+ of theories to suit facts.
9
+ </p>
10
+ <p class="author">— Sir Arthur Conan Doyle</p>
11
+ </blockquote>
12
+
13
+ Na początek dwa cytaty.
14
+
15
+ [L. Carlson, L. Richardson][ruby receptury]:
16
+ Wszyscy chcą pozostawić po sobie coś trwałego. […]
17
+ Każdy program, który piszemy, pozostawia jakiś ślad swojego działania
18
+ (w najprostszym przypadku są to dane wyświetlane na standardowym
19
+ urządzeniu wyjściowym). Większość bardziej rozbudowanych programów
20
+ idzie o krok dalej: zapisują one – w pliku o określonej strukturze –
21
+ dane stanowiące rezultat jednego uruchomienia, by przy następnym
22
+ uruchomieniu rozpocząć działanie w stanie, w którym zakończyła się
23
+ poprzednia sesja. **Istnieje wiele sposobów takiego
24
+ *utrwalania danych*, zarówno bardzo prostych, jak i wielce
25
+ skomplikowanych.**
26
+
27
+ [K. Haines][key-value stores part 1]:
28
+ „Applications, whether web apps, simple dynamic websites or command
29
+ line apps, frequently need some sort of persistent data store. As a
30
+ result, databases have become ubiquitous on modern systems, and
31
+ because of this chicken and egg relationship, programmers will often
32
+ habitually reach for a relational database when the project only calls
33
+ for a way to persist data.”
34
+
35
+ ## Notatki do wykładów
36
+
37
+ 1. {%= link_to "Co już było…", "/summary" %}
38
+ 1. {%= link_to "Wprowadzenie do języka Ruby", "/ruby-intro" %}
39
+ 1. {%= link_to "Serializacja danych", "/serializacja-danych" %}
40
+ 1. {%= link_to "Redis datastore", "/redis" %}
41
+ 1. {%= link_to "ORM na przykładzie ActiveRecord", "/ar" %}
42
+ 1. {%= link_to "Datamapper dla SQL i noSQL", "/datamapper" %}
43
+ 1. {%= link_to "MongoDB", "/mongodb" %}
44
+
45
+
46
+ [key-value stores part 1]: http://www.engineyard.com/blog/2009/key-value-stores-in-ruby/ "Kirk Haines, Key-Value Stores in Ruby: Part 1"
47
+ [ruby receptury]: http://helion.pl/ksiazki/rubyre.htm "Ruby Receptury, Bazy danych i trwałość obiektów."
@@ -0,0 +1,41 @@
1
+ #### {% title "MongoDB" %}
2
+
3
+ # [MongoDB] [mongodb]
4
+
5
+ MongoDB can be thought of as the goodness that erupts when a
6
+ traditional key-value store collides with a relational database
7
+ management system, mixing their essences into something that’s not
8
+ quite either, but rather something novel and fascinating.
9
+
10
+ MongoDB is written in C++ and offers the following features:
11
+
12
+ * Collection oriented storage: easy storage of object/JSON-style data
13
+ * Dynamic queries
14
+ * Full index support, including on inner objects and embedded arrays
15
+ * Query profiling
16
+ * Replication and fail-over support
17
+ * Efficient storage of binary data including large objects (e.g. photos and videos)
18
+ * Auto-sharding for cloud-level scalability (currently in alpha)
19
+
20
+ MongoDB is a document-oriented database.
21
+
22
+ Zob. też [Ruby driver for MongoDB] [mongodb ruby].
23
+
24
+ [MongoDB: A Light in the Darkness!] [mongodb-light]
25
+
26
+ [MongoDB Example: centralized logging](http://blog.mongodb.org/post/172254834/mongodb-is-fantastic-for-logging)
27
+
28
+ [MongoDB Blog] [mongodb-blog]
29
+
30
+ [Getting Started With MongoMapper and Rails](http://railstips.org/2009/7/23/getting-started-with-mongomapper-and-rails)
31
+
32
+ [MongoMapper Indy.rb Presentation](http://railstips.org/2009/8/19/mongomapper-indy-rb-presentation)
33
+
34
+ [What If A Key/Value Store Mated With A Relational Database System?](http://railstips.org/2009/6/3/what-if-a-key-value-store-mated-with-a-relational-database-system)
35
+
36
+
37
+ [mongodb-light]: http://www.engineyard.com/blog/2009/mongodb-a-light-in-the-darkness-key-value-stores-part-5/ "A Light in the Darkness"
38
+ [mongodb-blog]: http://blog.mongodb.org/ "MongoDB Blog"
39
+
40
+ [mongodb]: http://www.engineyard.com/blog/2009/mongodb-a-light-in-the-darkness-key-value-stores-part-5/ "A Light in the Darkness"
41
+ [mongodb ruby]: "http://github.com/mongodb/mongo-ruby-driver" "Ruby driver for the 10gen MongoDB"
@@ -0,0 +1,20 @@
1
+ #### {% title "Redis" %}
2
+
3
+ # Redis datastore
4
+
5
+ [To Redis or Not To Redis?] [redis-or-not]
6
+
7
+ [Redis] [redis] is key/value store:
8
+
9
+ * which is blazingly fast
10
+ * works best when data set is small enough that it can fit in available RAM
11
+ * it's OK if some recently updated records are lost in a catastrophic failure
12
+ * makes your life would a lot easier whenever you want cheap and easy
13
+ set and list operations
14
+
15
+ Zob. też [Object-Hash Mapping for Redis] [ohm].
16
+
17
+
18
+ [redis]: http://www.engineyard.com/blog/2009/key-value-stores-for-ruby-part-4-to-redis-or-not-to-redis/ "Redis or not…"
19
+ [ohm]: "http://ohm.keyvalue.org/" "Object-Hash Mapping for Redis"
20
+ [redis-or-not]: http://www.engineyard.com/blog/2009/key-value-stores-for-ruby-part-4-to-redis-or-not-to-redis/ "Redis orn not…"
@@ -0,0 +1,37 @@
1
+ #### {% title "Wprowadzenie do języka Ruby" %}
2
+
3
+ # Wprowadzenie do języka Ruby
4
+
5
+ * David Flanagan, Yukihiro Matsumoto.
6
+ [Ruby. Programowanie] [ruby]
7
+ * Aleksander Pohl. [Ruby Intro] [apohllo ruby]
8
+ * [Why's (Poignant) Guide to Ruby] [poignant guide]
9
+ * [Mr. Neighborly's Humble Little Ruby Book] [humblelittlerubybook]
10
+ ([pdf](http://www.humblelittlerubybook.com/book/hlrb.pdf)
11
+
12
+
13
+ ## Kilka przykładów na początek
14
+
15
+ TODO
16
+
17
+
18
+ ## Klasy IO, File, Dir…
19
+
20
+ [Dokumentacja klasy IO][ruby io].
21
+
22
+
23
+ ## Gemy: Mail, ActionMailer
24
+
25
+ TODO: wysyłanie i pobieranie.
26
+
27
+
28
+ ## Pobieramy dane za pomocą RSS
29
+
30
+ TODO: repertuar kin w trójmieście.
31
+
32
+
33
+ [ruby]: http://helion.pl/ksiazki/rubypr.htm "Ruby. Programowanie"
34
+ [apohllo ruby]: http://www.apohllo.pl/dydaktyka/ruby/intro/ "Ruby Intro"
35
+ [poignant guide]: http://www.ember.co.nz/files/resources/whys-poignant-guide-to-ruby.pdf "Poignant Guide to Ruby"
36
+ [humblelittlerubybook]: http://www.humblelittlerubybook.com/book/html/index.html
37
+ [ruby io]: http://ruby-doc.org/core/classes/IO.html "Class: IO"
@@ -0,0 +1,75 @@
1
+ #### {% title "Serializacja danych" %}
2
+
3
+ # Serializacja danych
4
+
5
+ Po kolei: Marshal, PStore, CSV, YAML
6
+
7
+
8
+ ## Marshall
9
+
10
+ TODO
11
+
12
+
13
+ ## PStore datastore
14
+
15
+ Ruby comes with a simple hash based key-value store called *PStore*.
16
+ If you’ve never used it, it’s definitely worth learning. For simple
17
+ data storage, PStore can be very useful.
18
+
19
+ [PStore] [pstore] implements a file based persistance mechanism based
20
+ on a Hash. User code can store hierarchies of Ruby objects (values)
21
+ into the data store file by name (keys). An object hierarchy may be
22
+ just a single object.
23
+
24
+
25
+ ## YAML
26
+
27
+ Sesja irb:
28
+
29
+ :::ruby
30
+ hash = { :one => 1, :two => 2, :colors => ["red", "green", "blue"] }
31
+ require 'yaml'
32
+ puts hash.to_yaml
33
+ y_hash = hash.to_yaml
34
+ new_hash = YAML.load(y_hash)
35
+ new_hash == hash #=> true
36
+
37
+ <b>You need a way</b> to automate the storage and retrieval of professional
38
+ and personal contacts (an address book), but you want it to be in
39
+ plain text so that you can edit the entries in a text editor as well
40
+ as alter them <i>programmatically</i>.
41
+
42
+
43
+ ## Proste bazy danych
44
+
45
+ You want a simple contact manager, and you need to share the files
46
+ with someone who may not have access to YAML.
47
+
48
+ ### Rozwiązanie
49
+
50
+ Our hypothetical YAML crisis provides a chance to look at a gdbm-based
51
+ solution. We'll aim for something that's as close as possible to
52
+ the YAML version of the contact manager, and the best way to guarantee
53
+ that closeness is to use a similar test suite.
54
+
55
+
56
+ ## Stone: Dead-Simple Data Persistence
57
+
58
+ To może być ciekawe [Dead-Simple Data Persistence] [stone].
59
+
60
+ For small applications, a database can be overkill for storing your
61
+ data in a consistent and organized manner. Therefore, Stone was built
62
+ to provide plug-and-play data persistence for any application or
63
+ framework. It is fast, and it is easy… therefore it is good.
64
+
65
+ Instalacja:
66
+
67
+ sudo gem install stone
68
+
69
+ Czy to będzie działać z Sinatrą? Przykład: Fortunka?
70
+
71
+
72
+ #### Linki
73
+
74
+ [stone]: http://stone.rubyforge.org/ "Dead-Simple Data Persistence"
75
+ [pstore]: http://www.ruby-doc.org/stdlib/libdoc/pstore/rdoc/classes/PStore.html "PStore"