Skip to content

Commit bad9c40

Browse files
adding 100daysofcode R1.D1
1 parent 7ddf7b3 commit bad9c40

File tree

5 files changed

+89
-2
lines changed

5 files changed

+89
-2
lines changed

components/ArticleTag.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,12 @@ a::before {
5151
color: white;
5252
background-color: green;
5353
}
54+
[class='100daysofcode'] {
55+
background-color: #004d4d;
56+
color: #ffff7d;
57+
}
58+
.elixir {
59+
background-color: #4a245d;
60+
color: #fff;
61+
}
5462
</style>

content/articles/round-1-day-1.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: Round 1 Day 1
3+
published: true
4+
description: Back to school. Back to school. Learning Elixir.
5+
tags: 100daysofcode, elixir
6+
cover_image: https://cdn.hashnode.com/res/hashnode/image/upload/v1613181428296/AE6zOKS_p.jpeg?auto=compress
7+
date: 2021-02-12
8+
---
9+
10+
## TIL
11+
Currently during the 100DaysOfCode Challenge, I'm learning elixir. I'll be documenting everything I learn or build as I go. I'm starting off with learning the elixir basics at [ElixirSchool](http://elixirschool.com).
12+
13+
## Basics
14+
- Everything is truthy except for `false` and `nil`
15+
- Booleans are atoms (:true, :false)
16+
- Modules are atoms
17+
- You can access erlang libraries using atoms
18+
- Aka atoms are important :)
19+
- Strings use double quotes
20+
- No modulo operator, but there are the `div` and `rem` functions.
21+
- Each basic type has a rank :/
22+
- number < atom < reference < function < port < pid < tuple < map < list < bistring
23+
- I'll never memorize this lawl
24+
- String interpolation "hello #{world}" or "hello " <> "world" ... Pretty Basic.
25+
26+
## Collections
27+
- Lists
28+
- Mixed types
29+
- Not unique
30+
- Linked List → faster to prepend than append
31+
> In computer science, a linked list is a linear collection of data elements whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes which together represent a sequence.
32+
- List concat `++/2` - cool
33+
- List sub `--/2` - cool cool
34+
- Head/Tail - cool cool cool
35+
- By pattern matching `[head | tail] = list` #=> head is the first element. tail will be all the others
36+
- `hd list` #=> returns the first element
37+
- `tl list` #=> returns all elements after the first
38+
- Tuples
39+
- Stored with a set amount of memory
40+
- Access = fast; modification = slow
41+
- Common for return info from function
42+
- Keyword lists
43+
- commonly used to pass options to functions
44+
- Maps
45+
- The Go-to key-value store
46+
- Similar to ruby's hash
47+
- Updating syntax is cool?
48+
- useMap.put/3 to create a new key
49+
50+
## Enum
51+
- Not much to go over here if you are familiar with any other languages Enum methods
52+
53+
## Pattern Matching
54+
- The Holy Grail of Elixir
55+
- If you ask any dev what they love about elixir chances are they will mention pattern matching
56+
- Curveball `=` is actually a match operator similar to the equals sign in algebra :exploading-head:
57+
- [1| tail] = list #=> tail has not been matched so it binds to the last elements of the list
58+
59+
## Control Structures
60+
61+
- `if` and `unless` => straight forward
62+
- `case/2`
63+
- Similar to `switch`(in javascript) or `case` (ruby) except it uses pattern matching
64+
- `_` is a catch all like `default` in JavaScript
65+
- `Cond`
66+
- Used for matching multiple cases similar to an `else if`
67+
- `With`
68+
- This one is bit trickier coming from other languages
69+
- Can be used to replace multiple `case` statements

content/articles/using-github-to-crosspost-to-dev-to.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Want to crosspost to dev.to? There's a GitHub action for that.
33
published: true
4+
date: 2021-01-25
45
description: When I create a new markdown article, I don't want to have to copy and paste that markdown to multiple other blog sites. So, why not let an Octokit handle this work for me with a GitHub action?
56
tags: typescript, github, opensource, actions
67
cover_image: https://cdn.nanalyze.com/uploads/2018/07/automation-rpa-teaser.jpg

content/articles/when-a-simple-react-context-gets-out-of-hand.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
title: When a simple React context gets out of hand.
33
published: true
4+
date: 2020-12-21
45
description: It seemed like a good idea to start. Separate state into different "contexts". Just use `useState`. Then, `useEffect` and multiple if branches snuck in and it became a nightmare.
56
tags: react, javascript, redux
67
cover_image: https://content.altexsoft.com/media/2018/09/code-refactoring.jpg
78
devToId: 539076
8-
devToSlug: when-a-simple-react-context-gets-out-of-hand-28k
99
---
1010

1111
# TL;DR:

pages/index.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ export default {
1616
watchQuery: ['tag'],
1717
async asyncData({ $content, params, query }) {
1818
const articles = await $content('articles')
19-
.only(['title', 'description', 'img', 'slug', 'tags', 'cover_image'])
19+
.only([
20+
'title',
21+
'description',
22+
'img',
23+
'slug',
24+
'tags',
25+
'cover_image',
26+
'date',
27+
])
28+
.sortBy('date', 'desc')
2029
.where({ tags: { $contains: query.tag || '' }, published: true })
2130
.sortBy('createdAt', 'asc')
2231
.fetch()

0 commit comments

Comments
 (0)