summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bash.html.markdown4
-rw-r--r--hu-hu/go.html.markdown42
-rw-r--r--id-id/css-id.html.markdown245
-rw-r--r--json.html.markdown48
-rw-r--r--lua.html.markdown151
-rw-r--r--ro-ro/bash-ro.html.markdown171
-rw-r--r--ro-ro/ruby-ro.html.markdown479
-rw-r--r--yaml.html.markdown139
8 files changed, 1177 insertions, 102 deletions
diff --git a/bash.html.markdown b/bash.html.markdown
index 70a3b52a..d5d08e9d 100644
--- a/bash.html.markdown
+++ b/bash.html.markdown
@@ -46,6 +46,10 @@ echo '$VARIABLE'
echo ${VARIABLE/Some/A}
# This will substitute the first occurance of "Some" with "A"
+# Substring from a variable
+echo ${VARIABLE:0:7}
+# This will return only the first 7 characters of the value
+
# Default value for variable
echo ${FOO:-"DefaultValueIfFOOIsMissingOrEmpty"}
# This works for null (FOO=), empty string (FOO=""), zero (FOO=0) returns 0
diff --git a/hu-hu/go.html.markdown b/hu-hu/go.html.markdown
index 621ebdbf..638c9489 100644
--- a/hu-hu/go.html.markdown
+++ b/hu-hu/go.html.markdown
@@ -6,6 +6,7 @@ contributors:
- ["Sonia Keys", "https://github.com/soniakeys"]
translators:
- ["Szabó Krisztián", "https://github.com/thenonameguy/"]
+ - ["Árpád Goretity", "https://github.com/H2CO3"]
---
A Go programozási nyelv az életszerű feladatok könnyebb elvégzése miatt született.
@@ -38,14 +39,14 @@ import (
"strconv" // Stringek átalakítására szolgáló csomag
)
-// Funkció deklarálás, a main nevű funkció a program kezdőpontja.
+// Függvénydeklarálás, a main nevű függvény a program kezdőpontja.
func main() {
// Println kiírja a beadott paramétereket a standard kimenetre.
- // Ha más csomagot funkcióját akarjuk használni, akkor azt jelezni kell a
+ // Ha más csomagot függvényeit akarjuk használni, akkor azt jelezni kell a
// csomag nevével
fmt.Println("Hello world!")
- // Meghívunk egy másik funkciót ebből a csomagból
+ // Meghívunk egy másik függvényt ebből a csomagból
beyondHello()
}
@@ -92,7 +93,7 @@ func learnTypes() {
// lebegőpontos szám
c := 3 + 4i // complex128, belsőleg két float64-gyel tárolva
- // Var szintaxis változó típus definiálással
+ // Var szintaxis változótípus-definiálással
var u uint = 7 // unsigned, az implementáció dönti el mekkora, akárcsak az
// int-nél
var pi float32 = 22. / 7
@@ -105,8 +106,8 @@ func learnTypes() {
a3 := [...]int{3, 1, 5} // egy tömb 3 int-tel, láthatóan inicalizálva egyedi
// értékekre
- // Szeleteknek dinamikus a méretük. A szeleteknek és a tömböknek is meg
- // vannak az előnyeik de a szeleteket sokkal gyakrabban használjuk.
+ // A "szeleteknek" (slices) dinamikus a méretük. A szeleteknek és a tömböknek is
+ // megvannak az előnyeik de a szeleteket sokkal gyakrabban használjuk.
s3 := []int{4, 5, 9} // vesd össze a3-mal, nincsenek pontok.
s4 := make([]int, 4) // allokál 4 int-et, mind 0-ra inicializálva
var d2 [][]float64 // ez csak deklaráció, semmi sincs még allokálva
@@ -129,8 +130,8 @@ func learnTypes() {
learnFlowControl()
}
-// A Go nyelv teljesen szemétgyűjtött (garbage-collected). Megtalálhatók benne
-// mutatók, de nincs mutató aritmetika. Ez azt jelenti, hogy üres mutatóval még
+// A Go nyelvben szemétgyűjtés (garbage collection) működik. Megtalálhatók benne
+// mutatók, de nincs pointeraritmetika. Ez azt jelenti, hogy üres (null) mutatóval még
// mindig hibázhatsz, de hozzáadni/műveleteket végezni már nem lehet.
func learnMemory() (p, q *int) {
// Elnevezett visszatérési változóknak int-re mutató a típusa
@@ -213,7 +214,7 @@ type pair struct {
}
// Definiáljunk egy metódust a pair struktúrának, ezzel teljesítve a Stringer interfészt.
-func (p pair) String() string { // p lesz a "vevő"
+func (p pair) String() string { // p lesz a "fogadó" (receiver)
// Sprintf az fmt csomag egy publikus függvénye, műkődése megegyezik a C-s
// megfelelőjével. A pontokkal érjük el a mindenkori p struktúra elemeit
return fmt.Sprintf("(%d, %d)", p.x, p.y)
@@ -230,7 +231,7 @@ func learnInterfaces() {
// Meghívjuk i String metódusát, az eredmény ugyanaz, mint az előbb.
fmt.Println(i.String())
- // Az fmt csomag funckciói automatikusan meghívják a String funkciót
+ // Az fmt csomag függvényei automatikusan meghívják a String függvényt
// hogy megtudják egy objektum szöveges reprezentációját.
fmt.Println(p) // ugyan az az eredmény mint az előbb, a Println meghívja
// a String metódust.
@@ -267,8 +268,8 @@ func inc(i int, c chan int) {
// Az inc-et fogjuk arra használni, hogy konkurensen megnöveljünk számokat
func learnConcurrency() {
- // Ugyan az a make funkció amivel korábban szeleteket hoztunk létre.
- // Make allokál mapokat, szeleteket és csatornákat.
+ // Ugyanaz a make függvény, amivel korábban szeleteket hoztunk létre.
+ // A make allokál map-eket, szeleteket és csatornákat.
c := make(chan int)
// Indítsunk három konkurens goroutine-t. A számok konkurensen lesznek
// megnövelve, ha a számítógép képes rá és jól be van állítva, akkor pedig
@@ -299,14 +300,14 @@ func learnConcurrency() {
case <-cc: // üres csatorna, soha nem fog rajta semmi se érkezni
fmt.Println("sose futok le :'( ")
}
- // Ezen a ponton vagy c vagy a cs goroutineja lefutott.
+ // Ezen a ponton vagy c vagy a cs goroutine-ja lefutott.
// Amelyik hamarabb végzett, annak a megfelelő case-e lefutott, a másik
// blokkolva vár.
- learnWebProgramming() // Go képes rá. Te is képes akarsz rá lenni.
+ learnWebProgramming() // a Go képes rá. Te is képes akarsz rá lenni.
}
-// Egy funkció a http csomagból elindít egy webszervert.
+// Egy függvény a http csomagból elindít egy webszervert.
func learnWebProgramming() {
// A ListenAndServe első paramétre egy TCP port, amin kiszolgálunk majd.
// Második paramétere egy interfész, pontosabban a http.Handler interfész.
@@ -315,7 +316,7 @@ func learnWebProgramming() {
}
// Csináljunk a pair-ból egy http.Handler-t úgy, hogy implementáljuk az
-// egyetlen metódusát a ServeHTTP-t.
+// egyetlen metódusát, a ServeHTTP-t.
func (p pair) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Minden kapcsolatra elküldjük ezt a http.ResponseWriter-rel
w.Write([]byte("Megtanultad a Go-t Y perc alatt!"))
@@ -325,11 +326,12 @@ func (p pair) ServeHTTP(w http.ResponseWriter, r *http.Request) {
## További olvasmányok
Minden Go-val kapcsolatos megtaláható a [hivatalos Go weboldalon](http://golang.org/).
-Ott követhetsz egy tutorialt, játszhatsz a nyelvvel az interneten és sok érdekességet olvashatsz.
+Ott követhetsz egy tutorialt, játszhatsz a nyelvvel az interneten, és sok érdekességet olvashatsz.
A nyelv specifikációját kifejezetten érdemes olvasni, viszonylag rövid és sokat tanul belőle az ember.
-Ha pedig jobban bele akarod vetni magad a Go-ba, akkor a standard könyvtárban a legjobb praktikákat kilesheted.
-TIPP: a dokumentációban kattints egy funkció nevére és rögtön megmutatja a hozzá tartozó kódot!
+Ha pedig jobban bele akarod vetni magad a Go-ba, akkor a legjobb praktikákat kilesheted a standard könyvtárból.
+TIPP: a dokumentációban kattints egy függvény nevére és rögtön megmutatja a hozzá tartozó kódot!
-Ha pedig a nyelvnek egy bizonyos részéről szeretnél hasonló leírást találni, akkor a [gobyexample.com](https://gobyexample.com/)-on megtalálod, amit keresel.
+Ha pedig a nyelvnek egy bizonyos részéről szeretnél hasonló leírást találni, akkor a
+[gobyexample.com](https://gobyexample.com/)-on megtalálod, amit keresel.
diff --git a/id-id/css-id.html.markdown b/id-id/css-id.html.markdown
new file mode 100644
index 00000000..d0798ec7
--- /dev/null
+++ b/id-id/css-id.html.markdown
@@ -0,0 +1,245 @@
+language: css
+contributors:
+ - ["Mohammad Valipour", "https://github.com/mvalipour"]
+translators:
+ - ["Eka Y Saputra", "http://github.com/ekajogja"]
+lang: id-id
+filename: learncss-id.css
+---
+
+Pada mulanya, web tidak memiliki elemen visual, murni teks saja.
+Tapi seiring perkembangan peramban, laman web dengan elemen visual menjadi umum.
+CSS adalah bahasa standar yang ada untuk menjaga keterpisahan antara
+konten (HTML) serta tampilan-dan-kesan laman web.
+
+Singkatnya, fungsi CSS ialah menyajikan sintaks yang memampukan kita
+untuk memilih elemen tertentu dalam sebuah laman HTML
+dan menerapkan berbagai properti visual bagi elemen tersebut.
+
+Seperti bahasa lainnya, CSS memiliki banyak versi.
+Di artikel ini, kita fokus pada CSS2.0 - yang meskipun bukan versi termutakhir
+namun paling kompatibel dan didukung secara luas.
+
+**CATATAN:** Lantaran keluaran dari CSS berwujud efek-efek visual,
+maka untuk mempelajarinya, kita perlu mencoba berbagai hal dalam dunia olah CSS
+semisal [dabblet](http://dabblet.com/).
+Fokus utama artikel ini ialah pada sintaks dan sejumlah tips umum.
+
+
+```css
+/* komentar terletak diantara sepasang tanda garis miring dan bintang,
+persis seperti larik ini! */
+
+/* ####################
+ ## SELEKTOR
+ ####################*/
+
+/* Secara garis besar, statemen utama dalam CSS sangat sederhana */
+selektor { properti: nilai; /* properti lainnya */ }
+
+/* selektor berfungsi untuk memilih suatu elemen dalam sebuah laman.
+
+Kita juga bisa memilih semua elemen di sebuah halaman! */
+* { color:red; }
+
+/*
+Dengan menentukan sebuah elemen seperti ini pada sebuah laman:
+
+<div class='suatu-class class2' id='suatuId' attr='nilai' />
+*/
+
+/* kita bisa memilih elemen berdasarkan nama class-nya */
+.suatu-class { }
+
+/*atau dengan dua class sekaligus! */
+.suatu-class.class2 { }
+
+/* atau dengan nama tag-nya */
+div { }
+
+/* atau id-nya */
+#suatuId { }
+
+/* atau - jika ada - dengan attribute-nya! */
+[attr] { font-size:smaller; }
+
+/* atau jika attribute tersebut memiliki nilai spesifik */
+[attr='nilai'] { font-size:smaller; }
+
+/* dibuka dengan sebuah nilai*/
+[attr^='nil'] { font-size:smaller; }
+
+/* atau ditutup dengan nilai */
+[attr$='ai'] { font-size:smaller; }
+
+/* atau bahkan disisipi nilai */
+[attr~='la'] { font-size:smaller; }
+
+
+/* dan yang lebih penting lagi, kita bisa mengombinasikannya sekaligus
+dengan syarat tidak ada spasi diantara selektor-selektor. sebab adanya spasi
+akan membuat selektor itu memiliki makna yang berbeda.*/
+div.suatu-class[attr$='ai'] { }
+
+/* kita juga bisa memilih sebuah elemen berdasarkan posisi elemen induknya.*/
+
+/*sebuah elemen yang merupakan anak langsung dari elemen induk (diseleksi dng
+cara yang sama) */
+div.suatu-induk > .-suatu-class {}
+
+/* atau salah satu induk elemennya dalam hirarki elemen */
+/* berikut ini dimaksudkan pada elemen manapun dengan class "class-entah" dan
+merupakan anak elemen dari suatu div dengan class "induk-entah" PADA LEVEL
+HIRARKI MANAPUN */
+div.suatu-induk .suatu-class {}
+
+/* peringatan: selektor yang sama jika tanpa ada spasi akan bermakna lain.
+misalnya? */
+div.suatu-induk.suatu-class {}
+
+/* kita juga bisa memilih sebuah elemen berdasarkan saudara elemen yang muncul
+tepat sebelumnya */
+.aku-muncul-tepat-sebelum + .elemen-ini { }
+
+/*atau saudara elemen manapun yang pernah muncul selang beberapa elemen
+sebelumnya */
+.aku-pernah-muncul-sebelum ~ .elemen-ini {}
+
+/* Ada beberapa pseudo-class yang memampukan kita memilih suatu elemen
+berdasarkan perilaku lamannya (bukan struktur lamannya) */
+
+/* semisal ketika sebuah elemen ditimpa hover (pointer mouse) */
+:hover {}
+
+/* atau link yang sudah pernah diklik*/
+:visited {}
+
+/* atau link yang belum pernah diklik*/
+:link {}
+
+/* atau elemen input yang menjadi fokus */
+:focus {}
+
+
+/* ####################
+ ## PROPERTI
+ ####################*/
+
+selektor {
+
+ /* Unit */
+ width: 50%; /* dalam persen */
+ font-size: 2em; /* angka kali jumlah font-size saat ini */
+ width: 200px; /* dalam pixel */
+ font-size: 20pt; /* dalam point */
+ width: 5cm; /* dalam centimeter */
+ width: 50mm; /* dalam milimeter */
+ width: 5in; /* dalam inci */
+
+ /* Warna */
+ background-color: #F6E; /* dalam short hex */
+ background-color: #F262E2; /* dalam format long hex */
+ background-color: tomato; /* warna yang sudah punya konvensi nama */
+ background-color: rgb(255, 255, 255); /* dalam rgb */
+ background-color: rgb(10%, 20%, 50%); /* dalam persen rgb */
+ background-color: rgba(255, 0, 0, 0.3); /* dalam rgb semi-transparan*/
+
+ /* Gambar */
+ background-image: url(/folder-gambar/image.jpg);
+
+ /* Font */
+ font-family: Arial;
+ font-family: "Courier New"; /* jika nama font memiliki spasi,
+ ia diketik dalam tanda petik ganda */
+ font-family: "Courier New", Trebuchet, Arial; /* jika font pertama tidak
+ ditemukan, peramban menggunakan font berikutnya,
+ demikian secara berturut-turut */
+}
+
+```
+
+## Penggunaan
+
+Simpan semua CSS yang hendak kita pakai dengan ekstensi `.css`.
+
+```xml
+<!-- kita harus menautkan file css itu ke laman di bagian <head>: -->
+<link rel='stylesheet' type='text/css' href='folder/namafile.css' />
+
+<!-- kita juga bisa mengetik CSS secara inline di dalam markup.
+Namun, sebisa mungkin metode ini dihindari. -->
+<style>
+ selektor { properti:nilai; }
+</style>
+
+<!-- atau langsung mengetik properti CSS pada sebuah elemen.
+Metode ini harus dihindari sebisa mungkin. -->
+<div style='properti:nilai;'>
+</div>
+
+```
+
+## Prioritas
+
+Kita tahu bahwa sebuah elemen bisa dipilih dengan lebih dari satu selektor,
+serta bisa diberi lebih dari satu properti.
+Dalam kasus seperti ini, hanya salah satu properti saja yang akan diterapkan
+pada elemen dengan prioritas tertentu.
+
+Dengan susunan CSS:
+
+```css
+
+/*A*/
+p.class1[attr='nilai']
+
+/*B*/
+p.class1 {}
+
+/*C*/
+p.class2 {}
+
+/*D*/
+p {}
+
+/*E*/
+p { properti: nilai !important; }
+
+```
+
+dan susunan markup:
+
+```xml
+<p style='/*F*/ properti:nilai;' class='class1 class2' attr='nilai'>
+</p>
+```
+
+Maka prioritas penerapan style-nya ialah sbb.:
+Ingat, penerapan ini untuk masing-masing **properti**,
+bukan keseluruhan larik.
+
+* `E` prioritas pertama sebab ada kata `!important`.
+ Dianjurkan untuk menghindari kata ini jika tidak benar-benar perlu.
+* `F` prioritas kedua sebab ia diketik secara inline.
+* `A` prioritas ketiga sebab selektor ini lebih spesifik dibanding yang lain.
+ lebih spesifik = lebih banyak unsur selektor. contoh ini punya 3 unsur:
+ 1 tagname `p` + 1 nama class `class1` + 1 attribute `attr='nilai'`
+* `C` prioritas berikutnya sebab meski sama spesifik dengan `B` namun
+ ia muncul lebih akhir.
+* Lalu `B`
+* dan terakhir baru `D`.
+
+## Kompatibilitas
+
+Sebagian besar fitur dalam CSS2 (dan lambat laun juga CSS3) kompatibel dengan
+semua peramban dan perangkat. Namun selalu vital untuk memastikan kompatibilitas
+unsur dan nilai yang kita ketikkan dalam CSS dengan peramban yang ditargetkan.
+
+[QuirksMode CSS](http://www.quirksmode.org/css/) ialah salah satu sumber terbaik untuk memeriksa kompatibilitas CSS dan peramban.
+
+## Referensi Lanjut
+
+* [Understanding Style Precedence in CSS: Specificity, Inheritance, and the Cascade](http://www.vanseodesign.com/css/css-specificity-inheritance-cascaade/)
+* [QuirksMode CSS](http://www.quirksmode.org/css/)
+* [Z-Index - The stacking context](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Understanding_z_index/The_stacking_context)
+
diff --git a/json.html.markdown b/json.html.markdown
new file mode 100644
index 00000000..f86f0ae9
--- /dev/null
+++ b/json.html.markdown
@@ -0,0 +1,48 @@
+---
+language: json
+filename: learnjson.json
+contributors:
+ - ["Anna Harren", "https://github.com/iirelu"]
+---
+
+As JSON is an extremely simple data-interchange format, this is most likely going
+to be the simplest Learn X in Y Minutes ever.
+
+JSON in its purest form has no actual comments, but most parsers will accept
+C-style (//, /\* \*/) comments. For the purposes of this, however, everything is
+going to be 100% valid JSON. Luckily, it kind of speaks for itself.
+
+```json
+{
+ "numbers": 0,
+ "strings": "Hellø, wørld. All unicode is allowed, along with \"escaping\".",
+ "has bools?": true,
+ "nothingness": null,
+
+ "big number": 1.2e+100,
+
+ "objects": {
+ "comment": "Most of your structure will come from objects.",
+
+ "array": [0, 1, 2, 3, "Arrays can have anything in them.", 5],
+
+ "another object": {
+ "comment": "These things can be nested, very useful."
+ }
+ },
+
+ "silliness": [
+ {
+ "sources of potassium": ["bananas"]
+ },
+ [
+ [1, 0, 0, 0],
+ [0, 1, 0, 0],
+ [0, 0, 1, "neo"],
+ [0, 0, 0, 1]
+ ]
+ ],
+
+ "that was short": "And, you're done. You know know everything JSON has to offer."
+}
+```
diff --git a/lua.html.markdown b/lua.html.markdown
index bdd59999..be9f3141 100644
--- a/lua.html.markdown
+++ b/lua.html.markdown
@@ -12,15 +12,13 @@ filename: learnlua.lua
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
-
-----------------------------------------------------
+--------------------------------------------------------------------------------
-- 1. Variables and flow control.
-----------------------------------------------------
+--------------------------------------------------------------------------------
num = 42 -- All numbers are doubles.
--- Don't freak out, 64-bit doubles have 52 bits for
--- storing exact int values; machine precision is
--- not a problem for ints that need < 52 bits.
+-- Don't freak out, 64-bit doubles have 52 bits for storing exact int
+-- values; machine precision is not a problem for ints that need < 52 bits.
s = 'walternate' -- Immutable strings like Python.
t = "double-quotes are also fine"
@@ -60,8 +58,8 @@ aBoolValue = false
-- Only nil and false are falsy; 0 and '' are true!
if not aBoolValue then print('twas false') end
--- 'or' and 'and' are short-circuited.
--- This is similar to the a?b:c operator in C/js:
+-- 'or' and 'and' are short-circuited. This is similar to the a?b:c operator
+-- in C/js:
ans = aBoolValue and 'yes' or 'no' --> 'no'
karlSum = 0
@@ -81,10 +79,9 @@ repeat
num = num - 1
until num == 0
-
-----------------------------------------------------
+--------------------------------------------------------------------------------
-- 2. Functions.
-----------------------------------------------------
+--------------------------------------------------------------------------------
function fib(n)
if n < 2 then return n end
@@ -93,8 +90,8 @@ end
-- Closures and anonymous functions are ok:
function adder(x)
- -- The returned function is created when adder is
- -- called, and remembers the value of x:
+ -- The returned function is created when adder is called, and remembers the
+ -- value of x:
return function (y) return x + y end
end
a1 = adder(9)
@@ -102,10 +99,9 @@ a2 = adder(36)
print(a1(16)) --> 25
print(a2(64)) --> 100
--- Returns, func calls, and assignments all work
--- with lists that may be mismatched in length.
--- Unmatched receivers are nil;
--- unmatched senders are discarded.
+-- Returns, func calls, and assignments all work with lists that may be
+-- mismatched in length. Unmatched receivers are nil; unmatched senders are
+-- discarded.
x, y, z = 1, 2, 3, 4
-- Now x = 1, y = 2, z = 3, and 4 is thrown away.
@@ -118,16 +114,15 @@ end
x, y = bar('zaphod') --> prints "zaphod nil nil"
-- Now x = 4, y = 8, values 15..42 are discarded.
--- Functions are first-class, may be local/global.
--- These are the same:
+-- Functions are first-class, may be local/global. These are the same:
function f(x) return x * x end
f = function (x) return x * x end
-- And so are these:
local function g(x) return math.sin(x) end
local g = function(x) return math.sin(x) end
--- Equivalent to local function g(x)..., except referring
--- to g in the function body won't work as expected.
+-- Equivalent to local function g(x)..., except referring to g in the function
+-- body won't work as expected.
local g; g = function (x) return math.sin(x) end
-- the 'local g' decl makes g-self-references ok.
@@ -136,19 +131,16 @@ local g; g = function (x) return math.sin(x) end
-- Calls with one string param don't need parens:
print 'hello' -- Works fine.
--- Calls with one table param don't need parens
--- either (more on tables below):
+-- Calls with one table param don't need parens either (more on tables below):
print {} -- Works fine too.
-
-----------------------------------------------------
+--------------------------------------------------------------------------------
-- 3. Tables.
-----------------------------------------------------
+--------------------------------------------------------------------------------
--- Tables = Lua's only compound data structure;
--- they are associative arrays.
--- Similar to php arrays or js objects, they are
--- hash-lookup dicts that can also be used as lists.
+-- Tables = Lua's only compound data structure; they are associative arrays.
+-- Similar to php arrays or js objects, they are hash-lookup dicts that can
+-- also be used as lists.
-- Using tables as dictionaries / maps:
@@ -164,14 +156,13 @@ t.key2 = nil -- Removes key2 from the table.
u = {['@!#'] = 'qbert', [{}] = 1729, [6.28] = 'tau'}
print(u[6.28]) -- prints "tau"
--- Key matching is basically by value for numbers
--- and strings, but by identity for tables.
+-- Key matching is basically by value for numbers and strings, but by identity
+-- for tables.
a = u['@!#'] -- Now a = 'qbert'.
b = u[{}] -- We might expect 1729, but it's nil:
--- b = nil since the lookup fails. It fails
--- because the key we used is not the same object
--- as the one used to store the original value. So
--- strings & numbers are more portable keys.
+-- b = nil since the lookup fails. It fails because the key we used is not the
+-- same object as the one used to store the original value. So strings &
+-- numbers are more portable keys.
-- A one-table-param function call needs no parens:
function h(x) print(x.key1) end
@@ -191,16 +182,15 @@ v = {'value1', 'value2', 1.21, 'gigawatts'}
for i = 1, #v do -- #v is the size of v for lists.
print(v[i]) -- Indices start at 1 !! SO CRAZY!
end
--- A 'list' is not a real type. v is just a table
--- with consecutive integer keys, treated as a list.
+-- A 'list' is not a real type. v is just a table with consecutive integer
+-- keys, treated as a list.
-----------------------------------------------------
+--------------------------------------------------------------------------------
-- 3.1 Metatables and metamethods.
-----------------------------------------------------
+--------------------------------------------------------------------------------
--- A table can have a metatable that gives the table
--- operator-overloadish behavior. Later we'll see
--- how metatables support js-prototypey behavior.
+-- A table can have a metatable that gives the table operator-overloadish
+-- behavior. Later we'll see how metatables support js-prototypey behavior.
f1 = {a = 1, b = 2} -- Represents the fraction a/b.
f2 = {a = 2, b = 3}
@@ -221,10 +211,9 @@ setmetatable(f2, metafraction)
s = f1 + f2 -- call __add(f1, f2) on f1's metatable
--- f1, f2 have no key for their metatable, unlike
--- prototypes in js, so you must retrieve it as in
--- getmetatable(f1). The metatable is a normal table
--- with keys that Lua knows about, like __add.
+-- f1, f2 have no key for their metatable, unlike prototypes in js, so you must
+-- retrieve it as in getmetatable(f1). The metatable is a normal table with
+-- keys that Lua knows about, like __add.
-- But the next line fails since s has no metatable:
-- t = s + s
@@ -236,11 +225,12 @@ myFavs = {food = 'pizza'}
setmetatable(myFavs, {__index = defaultFavs})
eatenBy = myFavs.animal -- works! thanks, metatable
--- Direct table lookups that fail will retry using
--- the metatable's __index value, and this recurses.
+--------------------------------------------------------------------------------
+-- Direct table lookups that fail will retry using the metatable's __index
+-- value, and this recurses.
--- An __index value can also be a function(tbl, key)
--- for more customized lookups.
+-- An __index value can also be a function(tbl, key) for more customized
+-- lookups.
-- Values of __index,add, .. are called metamethods.
-- Full list. Here a is a table with the metamethod.
@@ -261,12 +251,12 @@ eatenBy = myFavs.animal -- works! thanks, metatable
-- __newindex(a, b, c) for a.b = c
-- __call(a, ...) for a(...)
-----------------------------------------------------
+--------------------------------------------------------------------------------
-- 3.2 Class-like tables and inheritance.
-----------------------------------------------------
+--------------------------------------------------------------------------------
--- Classes aren't built in; there are different ways
--- to make them using tables and metatables.
+-- Classes aren't built in; there are different ways to make them using
+-- tables and metatables.
-- Explanation for this example is below it.
@@ -286,22 +276,20 @@ mrDog = Dog:new() -- 7.
mrDog:makeSound() -- 'I say woof' -- 8.
-- 1. Dog acts like a class; it's really a table.
--- 2. function tablename:fn(...) is the same as
--- function tablename.fn(self, ...)
--- The : just adds a first arg called self.
--- Read 7 & 8 below for how self gets its value.
+-- 2. "function tablename:fn(...)" is the same as
+-- "function tablename.fn(self, ...)", The : just adds a first arg called
+-- self. Read 7 & 8 below for how self gets its value.
-- 3. newObj will be an instance of class Dog.
--- 4. self = the class being instantiated. Often
--- self = Dog, but inheritance can change it.
--- newObj gets self's functions when we set both
--- newObj's metatable and self's __index to self.
+-- 4. "self" is the class being instantiated. Often self = Dog, but inheritance
+-- can change it. newObj gets self's functions when we set both newObj's
+-- metatable and self's __index to self.
-- 5. Reminder: setmetatable returns its first arg.
--- 6. The : works as in 2, but this time we expect
--- self to be an instance instead of a class.
+-- 6. The : works as in 2, but this time we expect self to be an instance
+-- instead of a class.
-- 7. Same as Dog.new(Dog), so self = Dog in new().
-- 8. Same as mrDog.makeSound(mrDog); self = mrDog.
-----------------------------------------------------
+--------------------------------------------------------------------------------
-- Inheritance example:
@@ -315,17 +303,16 @@ end
seymour = LoudDog:new() -- 3.
seymour:makeSound() -- 'woof woof woof' -- 4.
+--------------------------------------------------------------------------------
-- 1. LoudDog gets Dog's methods and variables.
-- 2. self has a 'sound' key from new(), see 3.
--- 3. Same as LoudDog.new(LoudDog), and converted to
--- Dog.new(LoudDog) as LoudDog has no 'new' key,
--- but does have __index = Dog on its metatable.
--- Result: seymour's metatable is LoudDog, and
--- LoudDog.__index = Dog. So seymour.key will
--- = seymour.key, LoudDog.key, Dog.key, whichever
+-- 3. Same as "LoudDog.new(LoudDog)", and converted to "Dog.new(LoudDog)" as
+-- LoudDog has no 'new' key, but does have "__index = Dog" on its metatable.
+-- Result: seymour's metatable is LoudDog, and "LoudDog.__index = Dog". So
+-- seymour.key will equal seymour.key, LoudDog.key, Dog.key, whichever
-- table is the first with the given key.
--- 4. The 'makeSound' key is found in LoudDog; this
--- is the same as LoudDog.makeSound(seymour).
+-- 4. The 'makeSound' key is found in LoudDog; this is the same as
+-- "LoudDog.makeSound(seymour)".
-- If needed, a subclass's new() is like the base's:
function LoudDog:new()
@@ -335,13 +322,13 @@ function LoudDog:new()
return setmetatable(newObj, self)
end
-----------------------------------------------------
+--------------------------------------------------------------------------------
-- 4. Modules.
-----------------------------------------------------
+--------------------------------------------------------------------------------
---[[ I'm commenting out this section so the rest of
--- this script remains runnable.
+--[[ I'm commenting out this section so the rest of this script remains
+-- runnable.
```
```lua
@@ -367,8 +354,8 @@ local mod = require('mod') -- Run the file mod.lua.
local mod = (function ()
<contents of mod.lua>
end)()
--- It's like mod.lua is a function body, so that
--- locals inside mod.lua are invisible outside it.
+-- It's like mod.lua is a function body, so that locals inside mod.lua are
+-- invisible outside it.
-- This works because mod here = M in mod.lua:
mod.sayHello() -- Says hello to Hrunkner.
@@ -376,8 +363,8 @@ mod.sayHello() -- Says hello to Hrunkner.
-- This is wrong; sayMyName only exists in mod.lua:
mod.sayMyName() -- error
--- require's return values are cached so a file is
--- run at most once, even when require'd many times.
+-- require's return values are cached so a file is run at most once, even when
+-- require'd many times.
-- Suppose mod2.lua contains "print('Hi!')".
local a = require('mod2') -- Prints Hi!
diff --git a/ro-ro/bash-ro.html.markdown b/ro-ro/bash-ro.html.markdown
new file mode 100644
index 00000000..fa91cca4
--- /dev/null
+++ b/ro-ro/bash-ro.html.markdown
@@ -0,0 +1,171 @@
+---
+category: tool
+tool: bash
+contributors:
+ - ["Max Yankov", "https://github.com/golergka"]
+ - ["Darren Lin", "https://github.com/CogBear"]
+ - ["Alexandre Medeiros", "http://alemedeiros.sdf.org"]
+ - ["Denis Arh", "https://github.com/darh"]
+translators:
+ - ["Adrian Bordinc", "https://github.com/ellimist"]
+lang: ro-ro
+filename: LearnBash-ro.sh
+---
+
+Bash este numele shell-ului unix, care a fost de asemenea distribuit drept shell pentru pentru sistemul de operare GNU si ca shell implicit pentru Linux si Mac OS X.
+Aproape toate exemplele de mai jos pot fi parte dintr-un script sau pot fi executate direct in linia de comanda.
+
+[Citeste mai multe:](http://www.gnu.org/software/bash/manual/bashref.html)
+
+```bash
+#!/bin/bash
+# Prima linie din script se numeste "shebang" care spune systemului cum sa execute scriptul
+# http://en.wikipedia.org/wiki/Shebang_(Unix)
+# Dupa cum te-ai prins deja, comentariile incep cu #. Shebang este de asemenea un comentariu.
+
+# Exemplu simplu de hello world:
+echo Hello world!
+
+# Fiecare comanda incepe pe o linie noua, sau dupa punct si virgula ;
+echo 'Prima linie'; echo 'A doua linie'
+
+# Declararea unei variabile se face astfel:
+VARIABLE="Niste text"
+
+# DAR nu asa:
+VARIABLE = "Niste text"
+# Bash va crede ca VARIABLE este o comanda care trebuie executata si va
+# returna o eroare pentru ca nu va putea fi gasita.
+
+# Folosind variabila:
+echo $VARIABLE
+echo "$VARIABLE"
+echo '$VARIABLE'
+# Atunci cand folosesti variabila, o atribui, o exporti sau altfel, numele ei se scrie fara $.
+# Daca vrei sa folosesti valoarea variabilei, atunci trebuie sa folosesti $.
+# Atentie la faptul ca ' (apostrof) nu va inlocui variabla cu valoarea ei.
+
+# Inlocuirea de caractere in variabile
+echo ${VARIABLE/Some/A}
+# Asta va inlocui prima aparitie a "Some" cu "A" in variabila de mai sus.
+
+# Substring dintr-o variabila
+echo ${VARIABLE:0:7}
+# Asta va returna numai primele 7 caractere din variabila.
+
+# Valoarea implicita a unei variabile:
+echo ${FOO:-"ValoareaImplicitaDacaFOOLipsesteSauEGoala"}
+# Asta functioneaza pentru null (FOO=), sir de caractere gol (FOO=""), zero (FOO=0) returneaza 0
+
+# Variabile pre-existente
+echo "Ulima valoare returnata de ultimul program rulat: $?"
+echo "ID-ul procesului (PID) care ruleaza scriptul: $$"
+echo "Numarul de argumente: $#"
+echo "Argumentele scriptului: $@"
+echo "Argumentele scriptului separate in variabile: $1 $2..."
+
+# Citind o valoare din consola
+echo "Care e numele tau?"
+read NAME # Observa faptul ca nu a trebuit sa declaram o variabila noua
+echo Salut, $NAME!
+
+# Avem obisnuita instructiune "if"
+# Foloseste "man test" pentru mai multe informatii despre instructinea conditionala
+if [ $NAME -ne $USER ]
+then
+ echo "Numele tau este username-ul tau"
+else
+ echo "Numele tau nu este username-ul tau"
+fi
+
+# Este de asemenea si executarea conditionala de comenzi
+echo "Intotdeauna executat" || echo "Executat numai daca prima instructiune esueaza"
+echo "Intotdeauna executat" && echo "Executat numai daca prima instructiune NU esueaza"
+
+# Expresiile apar in urmatorul format
+echo $(( 10 + 5 ))
+
+# Spre deosebire de alte limbaje de programare bash este un shell - asa ca
+# functioneaza in contextul directorului curent. Poti vedea fisiere si directoare
+# din directorul curent folosind comanda "ls":
+ls
+
+# Aceste comenzi au optiuni care la controleaza executia
+ls -l # Listeaza fiecare fisier si director pe o linie separata
+
+# Rezultatele comenzii precedente poate fi trimis urmatoarei comenzi drept argument
+# Comanda grep filtreaza argumentele trimise cu sabloane. Astfel putem vedea fiserele
+# .txt din directorul curent.
+ls -l | grep "\.txt"
+
+# De asemenea poti redirectiona o comanda, input si error output
+python2 hello.py < "input.in"
+python2 hello.py > "output.out"
+python2 hello.py 2> "error.err"
+# Output-ul va suprascrie fisierul daca acesta exista.
+# Daca vrei sa fie concatenate poti folosi ">>"
+
+# Comenzile pot fi inlocuite in interiorul altor comenzi folosind $( ):
+# Urmatoarea comanda afiseaza numarul de fisiere si directoare din directorul curent
+echo "Sunt $(ls | wc -l) fisiere aici."
+
+# The same can be done using backticks `` but they can't be nested - the preferred way
+# is to use $( ).
+# Acelasi lucru se poate obtine folosind apostrf-ul inversat ``, dar nu pot fi folosite
+# unele in interiorul celorlalte asa ca modalitatea preferata este de a folosi $( )
+echo "Sunt `ls | wc -l` fisiere aici."
+
+# Bash foloseste o instructiune 'case' care functioneaza in mod similar cu instructiunea
+# switch din Java si C++
+case "$VARIABLE" in
+ 0) echo "Este un zero.";;
+ 1) echo "Este un unu.";;
+ *) echo "Nu este null";;
+esac
+
+# Instructiunea for parcurge toate elementele trimise:
+# Continutul variabilei $VARIABLE este printat de 3 ori
+for VARIABLE in {1..3}
+do
+ echo "$VARIABLE"
+done
+
+# while loop:
+while [true]
+do
+ echo "in interiorul iteratiei aici..."
+ break
+done
+
+# De asemenea poti defini functii
+# Definitie:
+function foo ()
+{
+ echo "Argumentele functioneaza ca si argumentele scriptului: $@"
+ echo "Si: $1 $2..."
+ echo "Asta este o functie"
+ return 0
+}
+
+# sau mai simplu
+bar ()
+{
+ echo "Alta metoda de a declara o functie"
+ return 0
+}
+
+# Invocarea unei functii
+foo "Numele meu este: " $NAME
+
+# Sunt o multime de comenzi utile pe care ar trebui sa le inveti:
+tail -n 10 file.txt
+# printeaza ultimele 10 linii din fisierul file.txt
+head -n 10 file.txt
+# printeaza primele 10 linii din fisierul file.txt
+sort file.txt
+# sorteaza liniile din file.txt
+uniq -d file.txt
+# raporteaza sau omite liniile care se repeta, cu -d le raporteaza
+cut -d ',' -f 1 file.txt
+# printeaza doar prima coloana inainte de caracterul ","
+```
diff --git a/ro-ro/ruby-ro.html.markdown b/ro-ro/ruby-ro.html.markdown
new file mode 100644
index 00000000..27c6c462
--- /dev/null
+++ b/ro-ro/ruby-ro.html.markdown
@@ -0,0 +1,479 @@
+---
+language: ruby
+contributors:
+ - ["David Underwood", "http://theflyingdeveloper.com"]
+ - ["Joel Walden", "http://joelwalden.net"]
+ - ["Luke Holder", "http://twitter.com/lukeholder"]
+ - ["Tristan Hume", "http://thume.ca/"]
+ - ["Nick LaMuro", "https://github.com/NickLaMuro"]
+ - ["Marcos Brizeno", "http://www.about.me/marcosbrizeno"]
+translators:
+ - ["Adrian Bordinc", "https://github.com/ellimist"]
+filename: learnruby-ro.rb
+lang: ro-ro
+---
+
+```ruby
+# Acesta este un comentariu
+
+=begin
+Acesta este un comentariu pe mai multe linii
+Nimeni nu le foloseste
+Si nici tu nu ar trebui sa o faci
+=end
+
+# In primul rand: totul este un obiect
+
+# Numerele sunt obiecte
+
+3.class #=> Fixnum
+
+3.to_s #=> "3"
+
+
+# Aritmetica de baza
+1 + 1 #=> 2
+8 - 1 #=> 7
+10 * 2 #=> 20
+35 / 5 #=> 7
+
+# Aritmetica este doar "zahar sintactic"
+# pentru a putea chema metode pe un obiect
+1.+(3) #=> 4
+10.* 5 #=> 50
+
+# Valorile speciale sunt obiecte
+nil # Nimic
+true # true
+false # false
+
+nil.class #=> NilClass
+true.class #=> TrueClass
+false.class #=> FalseClass
+
+# Egalitate
+1 == 1 #=> true
+2 == 1 #=> false
+
+# Inegalitate
+1 != 1 #=> false
+2 != 1 #=> true
+!true #=> false
+!false #=> true
+
+# Excluzand "false", "nil" este singura valoare "falsa"
+
+!nil #=> true
+!false #=> true
+!0 #=> false
+
+# Mai multe comparatii
+1 < 10 #=> true
+1 > 10 #=> false
+2 <= 2 #=> true
+2 >= 2 #=> true
+
+# Sirurule de caractere sunt obiecte
+
+'Sunt un sir de caractere'.class #=> String
+"Si eu sunt un sir de caractere".class #=> String
+
+fi_inlocuit = "inlocui o valoare in string"
+"Pot #{fi_inlocuit} atunci cand folosesc dublu apostrof"
+#=> "Pot inlocui o valoare intr-un sir de caractere atunci cand folosesc dublu apostrof"
+
+
+# Printeaza
+puts "Afisez rezultate!"
+
+# Variabile
+x = 25 #=> 25
+x #=> 25
+
+# Retineti faptul ca atribuire unei valori, o si returneaza pe aceasta
+# Asta inseamna ca poti sa faci atribuire multipla:
+
+x = y = 10 #=> 10
+x #=> 10
+y #=> 10
+
+# Prin conventie se foloseste "snake_case" in denumirea variabilelor
+snake_case = true
+
+# Folositi nume descriptive pentru variablie
+adresa_radacina_proiect = '/nume/bun/'
+adresa = '/nume/nu atat de bun/'
+
+# Simbolurile (sunt obiecte)
+# Simbolurile sunt constante imutabile, reutilizabile, reprezentate intern
+# de o valoare numerica. Sunt deseori folosite in locul sirurilor de caractere pentru a da un nume reprezentativ unei valori
+
+:exemplu_simbol.class #=> Symbol
+
+status = :exemplu_simbol
+
+status == :exemplu_simbol #=> adevarat
+
+status == 'exemplu_simbol' #=> fals
+
+status == :aprobat #=> fals
+
+# Vectori
+
+# Acesta este un vector
+vector = [1, 2, 3, 4, 5] #=> [1, 2, 3, 4, 5]
+
+# Vectorii pot contine diferite tipuri de date
+
+[1, "salut", false] #=> [1, "salut", false]
+
+# Vectorii pot fi indexati
+# de la inceput
+vector[0] #=> 1
+vector[12] #=> nil
+
+# Ca si aritmetica, accessul [valoare]
+# este doar "zahar sintactic"
+# pentru a chema metoda [] a unui obiect
+vector.[] 0 #=> 1
+vector.[] 12 #=> nil
+
+# De la sfarsit
+vector[-1] #=> 5
+
+# Cu un index de inceput si o lungime
+vector[2, 3] #=> [3, 4, 5]
+
+# Sau cu un interval
+vector[1..3] #=> [2, 3, 4]
+
+# Adauga elemente intr-un vector in felul urmator:
+vector << 6 #=> [1, 2, 3, 4, 5, 6]
+
+# Hash-urile sunt dictionarele din Ruby cu perechi cheie/valoare.
+# Hash-urile sunt notate cu acolade
+hash = {'culoare' => 'verde', 'numar' => 5}
+
+hash.keys #=> ['culoare', 'numar']
+
+# Poti lua valoare unui element dintr-un hash foarte rapid folosind cheia
+hash['culoare'] #=> 'verde'
+hash['numar'] #=> 5
+
+# Incercand sa accesezi un element dintr-un hash printr-o cheie care nu exista va returna "nil".
+hash['nimic_aici'] #=> nil
+
+# Incepand cu Ruby 1.9, este o sintaxa speciala pentru atunci cand se folosesc simboluri drept chei:
+
+hash_nou = { defcon: 3, actiune: true}
+
+hash_now.keys #=> [:defcon, :actiune]
+
+# Pont: Atat vectorii (Array) si hash-urile (Hash) sunt enumerabile (Enumerable)
+# Ele impart o multime de metode utile precum each, map, count si altele
+
+
+# Structuri de control
+
+if true
+ "instructiune if"
+elsif false
+ "else if, optional"
+else
+ "else, de asemenea optional"
+end
+
+for numar in 1..5
+ puts "iteratia #{numar}"
+end
+#=> iteratia 1
+#=> iteratia 2
+#=> iteratia 3
+#=> iteratia 4
+#=> iteratia 5
+
+# TOTUSI, Nici una nu foloseste instructiunea for
+# In locul acesteia ar trebui sa folosesti metoda "each" si sa ii trimiti un block
+# Un bloc este o bucata de cod pe care o poti trimite unei metode precum "each".
+# Este analog pentru "lambda", functii anonime, sau closures in alte limbaje de programare.
+#
+# The "each" method of a range runs the block once for each element of the range.
+# Metoda "each" a unui interval, ruleaza block-ul o data pentru fiecare element din interval.
+# Block-ul primeste ca si parametru un index
+# Invocand metoda "each" cu un block, arata in urmatorul fel:
+
+(1..5).each do |index|
+ puts "iteratia #{index}"
+end
+#=> iteratia 1
+#=> iteratia 2
+#=> iteratia 3
+#=> iteratia 4
+#=> iteratia 5
+
+# Poti de asemenea sa pui block-ul intre acolade
+(1..5).each {|index| puts "iteratia #{index}"}
+
+# Continutul unei structuri de date poate fi parcurs folosind "each".
+array.each do |element|
+ puts "#{element} parte din vector"
+end
+hash.each do |cheie, valoare|
+ puts "#{cheie} este #{valoare}"
+end
+
+index = 1
+while index <= 5 do
+ puts "iteratia #{index}"
+ index += 1
+end
+#=> iteratia 1
+#=> iteratia 2
+#=> iteratia 3
+#=> iteratia 4
+#=> iteratia 5
+
+nota = 'B'
+
+case nota
+when 'A'
+ puts "Bravo pustiule!"
+when 'B'
+ puts "Mai mult noroc data viitoare"
+when 'C'
+ puts "Poti mai mult"
+when 'D'
+ puts "Incet, incet..."
+when 'F'
+ puts "Ai esuat!"
+else
+ puts "Sistem de notare alternativ?!"
+end
+
+# Functii
+
+def dublu(x)
+ x * 2
+end
+
+# Functille (si toate block-urile) returneaza implicit valoarea ultimei instructiuni
+dublu(2) #=> 4
+
+# Parantezele sunt optionale cand rezultatul nu este ambiguu
+dublu 3 #=> 6
+
+dublu dublu 3 #=> 12
+
+def suma(x,y)
+ x + y
+end
+
+# Argumentele metodei sunt separate printr-o virgula
+suma 3, 4 #=> 7
+
+suma suma(3,4), 5 #=> 12
+
+# yield
+# Toate metodele au un parametru block, implicit si optional
+# care poate fi invocat folosit cuvantul cheie 'yield'
+
+def incercuieste
+ puts "{"
+ yield
+ puts "}"
+end
+
+incercuieste { puts 'Salut Mihai!' }
+
+# {
+# Salut Mihai!
+# }
+
+
+# Poti trimite un block unei functii.
+# "&" marcheaza o referinta trimisa unui block
+def vizitatori(&block)
+ block.call "un_parametru"
+end
+
+# Poti trimite o lista de argumente, care va fi convertita intr-un vector (array).
+# Pentru asta se foloseste ("*")
+def vizitatori(*vector)
+ vector.each { |vizitator| puts "#{vizitator}" }
+end
+
+# Defineste o clasa folosind cuvantul cheie "class"
+class Om
+
+ # O variabila apartinand clasei. Este folosita in toate instantele clasei
+ @@specie = "H. sapiens"
+
+ # Constructor
+ def initialize(nume, varsta=0)
+ # Atribuie argumentul, variabilei "nume", care apartine doar unei instante
+ @nume = nume
+ # Daca varsta nu este data, o sa ii atribuim valoarea implicita din lista de argumente (0, in cazul nostru)
+ @varsta = varsta
+ end
+
+ # Metoda pentru a seta valoarea unei variabile
+ def nume=(nume)
+ @nume = nume
+ end
+
+ # Metoda pentru a lua valoarea unei variabile
+ def nume
+ @nume
+ end
+
+ # Functionalitatea de mai sus poate fi obtinuta folosing metoda "attr_accessor" dupa cum urmeaza:
+ attr_accessor :nume
+
+ # Metodele pentru a lua si a seta valoarea unei variabile pot fi de asemenea obtinute individial:
+ attr_reader :nume
+ attr_writer :nume
+
+ # O metoda apartinand unei clase foloseste "self" pentru a se diferentia de metodele unei instante ale clasei respective
+ # Poate fi invocata doar pe clasa, si nu pe o instanta a acesteia
+ def self.spune(msg)
+ puts "#{msg}"
+ end
+
+ def specie
+ @@specie
+ end
+
+end
+
+
+# Creaza o instanta a unei clase
+ion = Om.new("Ionut Popescu")
+
+eugen = Om.new("Eugen Ionescu")
+
+# Sa invocam niste metode
+ion.specie #=> "H. sapiens"
+ion.nume #=> "Ionut Popescu"
+ion.nume = "Ionut Popescu JR." #=> "Ionut Popescu JR."
+ion.nume #=> "Ionut Popescu JR."
+eugen.specie #=> "H. sapiens"
+eugen.nume #=> "Eugen Ionescu"
+
+# Invoca o metoda a unei clase
+Om.spune("Salut") #=> "Salut"
+
+
+# Scopul unei variabile este definit de modul in care le numim
+# Variabilele care incep cu $ au scop global
+$var = "Sunt o variabila globala"
+defined? $var #=> "global-variable"
+
+# Variabilele care incep cu @ apartin unei instante
+@var = "Sunt o variabila a unei instante"
+defined? @var #=> "instance-variable"
+
+# Variabilele care incep cu @@ apartin unei clase
+@@var = "Sunt variabila unei clase"
+defined? @@var #=> "class variable"
+
+# Variabilele care incep cu litera mare sunt constante
+Var = "Sunt o constanta"
+defined? Var #=> "constant"
+
+# Clasele sunt de asemenea obiecte in ruby. Astfel incat clasele pot avea variabile care apartin unei instante
+# O variabila care apartine unei clase poate fi accesata de toate instantele acesteia si de clasele care o extind
+
+# clasa parinte
+class Om
+ @@foo = 0
+
+ def self.foo
+ @@foo
+ end
+
+ def self.foo=(valoare)
+ @@foo = valoare
+ end
+end
+
+# clasa copil
+class Muncitor < Om
+end
+
+Om.foo # 0
+Muncitor.foo # 0
+
+Om.foo = 2 # 2
+Muncitor.foo # 2
+
+# Variabilele care apartin unei instante ale unei clase, nu sunt impartite de (copii acesteia) clasele care o extind
+class Om
+ @bar = 0
+
+ def self.bar
+ @bar
+ end
+
+ def self.bar=(valoare)
+ @bar = valoare
+ end
+end
+
+class Doctor < Om
+end
+
+Om.bar # 0
+Doctor.bar # nil
+
+module ExempluModul
+ def foo
+ 'foo'
+ end
+end
+
+# Incluzand modulul instantei unui obiect
+# Extinzand modulul unei instante ale unei clase
+
+class Persoana
+ include ExempluModul
+end
+
+class Carte
+ extend ExempluModul
+end
+
+Persoana.foo # => NoMethodError: undefined method `foo' for Persoana:Class
+Persoana.new.foo # => 'foo'
+Carte.foo # => 'foo'
+Carte.new.foo # => NoMethodError: undefined method `foo'
+
+# Callbacks atunci cand includerea si extinderea unui modul sunt executate
+
+module ModulExempluCallBack
+ def self.included(base)
+ base.extend(ClassMethods)
+ base.send(:include, InstanceMethods)
+ end
+
+ module ClassMethods
+ def bar
+ 'bar'
+ end
+ end
+
+ module InstanceMethods
+ def qux
+ 'qux'
+ end
+ end
+end
+
+class CevaRelevant
+ include ModulExempluCallBack
+end
+
+CevaRelevant.bar # => 'bar'
+CevaRelevant.qux # => NoMethodError: undefined method `qux'
+CevaRelevant.new.bar # => NoMethodError: undefined method `bar'
+CevaRelevant.new.qux # => 'qux'
+```
diff --git a/yaml.html.markdown b/yaml.html.markdown
new file mode 100644
index 00000000..c5d15895
--- /dev/null
+++ b/yaml.html.markdown
@@ -0,0 +1,139 @@
+---
+language: yaml
+filename: learnyaml.yaml
+contributors:
+ - ["Adam Brenecki", "https://github.com/adambrenecki"]
+---
+
+YAML is a data serialisation language designed to be directly writable and
+readable by humans.
+
+It's a strict superset of JSON, with the addition of syntactically
+significant newlines and indentation, like Python. Unlike Python, however,
+YAML doesn't allow literal tab characters at all.
+
+```yaml
+# Comments in YAML look like this.
+
+################
+# SCALAR TYPES #
+################
+
+# Our root object (which continues for the entire document) will be a map,
+# which is equivalent to a dictionary, hash or object in other languages.
+key: value
+another_key: Another value goes here.
+a_number_value: 100
+scientific_notation: 1e+12
+boolean: true
+null_value: null
+key with spaces: value
+# Notice that strings don't need to be quoted. However, they can be.
+however: "A string, enclosed in quotes."
+"Keys can be quoted too.": "Useful if you want to put a ':' in your key."
+
+# Multiple-line strings can be written either as a 'literal block' (using |),
+# or a 'folded block' (using '>')
+literal_block: |
+ This entire block of text will be the value of the 'literal_block' key,
+ with line breaks being preserved.
+
+ The literal continues until de-dented, and the leading indentation is
+ stripped.
+
+ Any lines that are 'more-indented' keep the rest of their indentation -
+ these lines will be indented by 4 spaces.
+folded_style: >
+ This entire block of text will be the value of 'folded_style', but this
+ time, all newlines will be replaced with a single space.
+
+ Blank lines, like above, are converted to a newline character.
+
+ 'More-indented' lines keep their newlines, too -
+ this text will appear over two lines.
+
+####################
+# COLLECTION TYPES #
+####################
+
+# Nesting is achieved by indentation.
+a_nested_map:
+ key: value
+ another_key: Another Value
+ another_nested_map:
+ hello: hello
+
+# Maps don't have to have string keys.
+0.25: a float key
+
+# Keys can also be multi-line objects, using ? to indicate the start of a key
+? |
+ This is a key
+ that has multiple lines
+: and this is its value
+
+# YAML also allows collection types in keys, but many programming languages
+# will complain.
+
+# Sequences (equivalent to lists or arrays) look like this:
+a_sequence:
+ - Item 1
+ - Item 2
+ - 0.5 # sequences can contain disparate types
+ - Item 4
+ - key: value
+ another_key: another_value
+ -
+ - This is a sequence
+ - inside another sequence
+
+# Since YAML is a superset of JSON, you can also write JSON-style maps and
+# sequences:
+json_map: {"key": "value"}
+json_seq: [3, 2, 1, "takeoff"]
+
+#######################
+# EXTRA YAML FEATURES #
+#######################
+
+# YAML also has a handy feature called 'anchors', which let you easily duplicate
+# content across your document. Both of these keys will have the same value:
+anchored_content: &anchor_name This string will appear as the value of two keys.
+other_anchor: *anchor_name
+
+# YAML also has tags, which you can use to explicitly declare types.
+explicit_string: !!str 0.5
+# Some parsers implement language specific tags, like this one for Python's
+# complex number type.
+python_complex_number: !!python/complex 1+2j
+
+####################
+# EXTRA YAML TYPES #
+####################
+
+# Strings and numbers aren't the only scalars that YAML can understand.
+# ISO-formatted date and datetime literals are also parsed.
+datetime: 2001-12-15T02:59:43.1Z
+datetime_with_spaces: 2001-12-14 21:59:43.10 -5
+date: 2002-12-14
+
+# The !!binary tag indicates that a string is actually a base64-encoded
+# representation of a binary blob.
+gif_file: !!binary |
+ R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
+ OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
+ +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
+ AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=
+
+# YAML also has a set type, which looks like this:
+set:
+ ? item1
+ ? item2
+ ? item3
+
+# Like Python, sets are just maps with null values; the above is equivalent to:
+set2:
+ item1: null
+ item2: null
+ item3: null
+```