Skip to content

Commit 10d2e87

Browse files
author
dvogt23
committed
Notes/2023-02-28.md
Notes/tech/coding/basic.md Notes/tech/coding/javascript.md Notes/tech/coding/rails.md Notes/tech/coding/ruby.md Notes/tech/misc.md
1 parent 1c6b647 commit 10d2e87

File tree

6 files changed

+64
-2
lines changed

6 files changed

+64
-2
lines changed

Notes/2023-02-28.md

Whitespace-only changes.

Notes/tech/coding/basic.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ allow reusability as much as possible. Mostly useful for frontend design.
1111
- ...
1212

1313
Source: [Brad Frost](https://bradfrost.com/blog/post/atomic-web-design/)
14+
15+
## Coding style
16+
17+
At the linux kernel guideline are some good advices: [The linux kernel - coding style](https://www.kernel.org/doc/html/v4.10/process/coding-style.html#linux-kernel-coding-style)
18+
Google have some [guidelines](https://google.github.io/styleguide/) for some languages as well.

Notes/tech/coding/javascript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Source: [markodenic](https://markodenic.com/use-console-log-like-a-pro/)
4343

4444
## React location listener
4545

46-
To trigger event son laction change in React:
46+
To trigger events on location change in React, i.e. for integrate tracking code:
4747

4848
```js
4949
import { useEffect } from 'react';

Notes/tech/coding/rails.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,28 @@ Learning from some youtube guys:
2222
- Some great articles about coding [johnnunemaker](https://www.johnnunemaker.com/)
2323
- rails, ruby, ...
2424

25+
## Data class
26+
27+
Similiar to the [value-alike objects](https://docs.ruby-lang.org/en/master/Data.html) in ruby(3.2), here an example for rails:
28+
29+
```ruby
30+
class DataClass
31+
ATTRIBUTES = %i[first_name last_name city zipcode phone_number].freeze
32+
33+
include ActiveModel::Model
34+
35+
attr_accessor *ATTRIBUTES
36+
37+
def ==(object)
38+
ATTRIBUTES.all? { |attribute| public_send(attribute) == object.public_send(attribute) }
39+
end
40+
end
41+
42+
ConsumerClass.new(DataClass({first_name: "Bill", last_name: "...", ...}))
43+
```
44+
45+
Links: [Polyfill - Data gem](https://github.com/saturnflyer/polyfill-data)
46+
2547
## RSpec factory trait & transient
2648

2749
```ruby

Notes/tech/coding/ruby.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,35 @@ IP_REGEX = /
8787
}
8888
# => true
8989
```
90-
Source: [dev.to/baweaver](https://dev.to/baweaver/pattern-matching-interfaces-in-ruby-1b15)
90+
Source: [dev.to/baweaver](https://dev.to/baweaver/pattern-matching-interfaces-in-ruby-1b15)
91+
92+
## Refinement
93+
94+
Extend/overwrite string behavior in module (specific scope)
95+
96+
```ruby
97+
module PatchedString
98+
refine String do
99+
def +(value)
100+
self << ", #{value}"
101+
end
102+
end
103+
end
104+
105+
module RegularNamespace
106+
def self.append_strings(a, b)
107+
a + b
108+
end
109+
end
110+
111+
module PatchedNamespace
112+
using PatchedString
113+
114+
def self.append_strings(a, b)
115+
a + b
116+
end
117+
end
118+
119+
RegularNamespace.append_strings("1", "2") # => "12"
120+
PatchedNamespace.append_strings("1", "2") # => "1, 2"
121+
```

Notes/tech/misc.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ docker ps -q | xargs -n 1 docker inspect --format '{{ .NetworkSettings.Networks.
3030

3131
Show the model in shell `cat /sys/firmware/devicetree/base/model`
3232

33+
### Kubernetes
34+
35+
Some security [guidelines for kubernetes (OWASP)](https://sysdig.com/blog/top-owasp-kubernetes/)
36+
3337
### SSH
3438

3539
#### Articles

0 commit comments

Comments
 (0)