Skip to content

Commit

Permalink
initial notes on es6 and ruby/rails
Browse files Browse the repository at this point in the history
  • Loading branch information
d-a-s committed Nov 18, 2017
1 parent 62548b1 commit 8da344e
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ typings/
# dotenv environment variables file
.env

#vi temp files
*~
*.swp
67 changes: 67 additions & 0 deletions js_es6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
### [browser support](http://kangax.github.io/compat-table/es6/)

### [default function parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters)
```
function test(a=1, b={}, c=false){ }
```

### [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters)
```
function test(a, ...b) {}
```

### [spread (...) operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator)
```
test(...a);
[a, ...b, c];
```

### [object literal extensions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer)
```
var o={a:1, b, c:false};
```

### [for...of loops](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of)
```
for(let q of iterable) { }
typeof a[Symbol.iterator] == 'function' // check if a is an iterable
// iterable function
let q = function*() {
yield 1;
yield 2;
};
//make an object iterable:
let q = {
a:1, b:2, c:3, d:4,
[Symbol.iterator]: function*() {
for(let i of Object.keys(this)) yield this[i];
}
};
```

### [numeric literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Numeric_literals)
```
// leading 0 with all other numbers 0-7 = octal
let i = 0754; //decimal 492
// 0o, 0x, 0b prefix, can also be uppercase
i = 0o754; // also octal, dec 492
i = 0x754; // hex, dec 1876
i = 0b1010100100 // binary, dec 676
// toString - es1 standard
x = (676).toString(16); // hex of number, in string form
x = (676).toString(8); // octal
x = (676).toString(2); // binary
// works for bases 2 - 36
```

### [string template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
```
let a = `string test ${variable} ${function(a)} ${3+2}`;
let b = `line 1
line 2
line 3 with tab
line 4 with ${varForLine4}`;
```
37 changes: 37 additions & 0 deletions ruby_rails_install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
* install rvm
`\curl -L https://get.rvm.io | bash -s stable --ruby`

* possibly need stuff to sign
```
sudo apt-get install gnupg2
gpg2 --recv-keys ...
\curl -L https://get.rvm.io | bash -s stable --ruby
```

* update
```
gem update --system
rvm gemset list
rvm gemset use global
gem list
gem outdated
gem update
gem install bundler
gem install nokogiri
```
[current version of Rails.](http://rubygems.org/gems/rails)
```
rvm use [email protected] --create
gem install rails
rails -v
```

* new rails application
```
mkdir myapp
cd myapp
rvm use ruby-2.4.1@myapp --ruby-version --create
gem install rails
rails new .
```

0 comments on commit 8da344e

Please sign in to comment.