Skip to content

Commit f01e70a

Browse files
committed
Add MVC notes. Add Google Sheets timestamp script. Expand and reformat mysql, restful and security notes.
1 parent 877f678 commit f01e70a

File tree

7 files changed

+125
-8
lines changed

7 files changed

+125
-8
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
- Typescript
4444

4545
### Architecture
46+
- [MVC](./topics/mvc.md)
4647
- [Architecture](./topics/architecture.md)
4748
- Use Cases
4849
- [RESTful](./topics/restful.md)

pics/mvc_full_stack.jpg

106 KB
Loading

topics/excel.md

+26
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,30 @@ Sub URLPictureInsert()
2828
ActiveSheet.Shapes.AddPicture Filename:=cell, LinkToFile:=msoFalse, SaveWithDocument:=msoCTrue, Left:=xRg.Left + (xRg.Width - w) / 2, Top:=xRg.Top + (xRg.Height - h) / 2, Width:=w, Height:=h
2929
Next
3030
End Sub
31+
```
32+
33+
# Google Sheets Cell Update Timestamp
34+
35+
1. Modify code with corresponding sheet, cells and update cells.
36+
2. Go to Tools/Script Editor.
37+
3. Paste the code and click save.
38+
39+
```javascript
40+
function onEdit(e) {
41+
var sh = e.source.getActiveSheet();
42+
var sheets = ['Sheet1']; // Which sheets to run the code.
43+
44+
// Columns with the data to be tracked. 1 = A, 2 = B...
45+
var ind = [1, 2, 3].indexOf(e.range.columnStart);
46+
47+
// Which columns to have the timestamp, related to the data cells.
48+
// Data in 1 (A) will have the timestamp in 4 (D)
49+
var stampCols = [4, 5, 6]
50+
51+
if(sheets.indexOf(sh.getName()) == -1 || ind == -1) return;
52+
53+
// Insert/Update the timestamp.
54+
var timestampCell = sh.getRange(e.range.rowStart, stampCols[ind]);
55+
timestampCell.setValue(typeof e.value == 'object' ? null : new Date());
56+
}
3157
```

topics/mvc.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
![mvc](../pics/mvc_full_stack.jpg)

topics/mysql.md

+18-7
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,33 @@ systemctl restart mysql
2828
# sudo service mysql start
2929
```
3030

31+
# Status
32+
33+
```bash
34+
sudo systemctl status mysql
35+
sudo systemctl start mysql
36+
37+
sudo /etc/init.d/mysql status
38+
sudo /etc/init.d/mysql start
39+
```
40+
41+
# Login
42+
```bash
43+
# Log into MySQL as root, with password.
44+
sudo mysql -u root -p
45+
```
46+
3147
# Command line
3248

3349
[Digital Ocean tutorial](https://www.digitalocean.com/community/tutorials/a-basic-mysql-tutorial)
34-
Commands are **not** case sensitive, but table names are. **All commands must end with** `;`.
3550

36-
`sudo mysql -u root -p` - Log into MySQL as root, with password.
51+
Commands are **not** case sensitive, but table names are. **All commands must end with** `;`.
52+
3753
`;` - Execute/End current command.
3854
`ENTER` - Starts a new line. `;` is expected.
3955

4056
# Users
4157

42-
```bash
43-
# Log in as new user, with password.
44-
sudo mysql -u user -p
45-
```
46-
4758
```sql
4859
-- Create user
4960
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';

topics/restful.md

+78
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,84 @@ Treat it like a sub-resource with RESTful principles. For example, GitHub's API
4545

4646
Sometimes you really have no way to map the action to a sensible RESTful structure. For example, a multi-resource search doesn't really make sense to be applied to a specific resource's endpoint. In this case, /search would make the most sense even though it isn't a resource. This is OK - just do what's right from the perspective of the API consumer and make sure it's documented clearly to avoid confusion.
4747

48+
# Naming Convention
49+
50+
Use consistent resource naming conventions and URI formatting for minimum ambiguily and maximum readability and maintainability. You may implement below design hints to achieve consistency:
51+
52+
### **Use forward slash (/) to indicate a hierarchical relationships**
53+
54+
The forward slash (/) character is used in the path portion of the URI to indicate a hierarchical relationship between resources. e.g.
55+
56+
```
57+
http://api.example.com/device-management
58+
http://api.example.com/device-management/managed-devices
59+
http://api.example.com/device-management/managed-devices/{id}
60+
http://api.example.com/device-management/managed-devices/{id}/scripts
61+
http://api.example.com/device-management/managed-devices/{id}/scripts/{id}
62+
```
63+
64+
### **Do not use trailing forward slash (/) in URIs**
65+
66+
As the last character within a URI’s path, a forward slash (/) adds no semantic value and may cause confusion. It’s better to drop them completely.
67+
68+
```
69+
http://api.example.com/device-management/managed-devices/
70+
http://api.example.com/device-management/managed-devices /*This is much better version*/
71+
```
72+
### **Use hyphens (-) to improve the readability of URIs**
73+
74+
To make your URIs easy for people to scan and interpret, use the hyphen (-) character to improve the readability of names in long path segments.
75+
76+
```
77+
http://api.example.com/inventory-management/managed-entities/{id}/install-script-location //More readable
78+
http://api.example.com/inventory-management/managedEntities/{id}/installScriptLocation //Less readable
79+
```
80+
81+
### **Do not use underscores ( _ )**
82+
83+
It’s possible to use an underscore in place of a hyphen to be used as separator – But depending on the application’s font, it’s possible that the underscore (_) character can either get partially obscured or completely hidden in some browsers or screens.
84+
85+
To avoid this confusion, use hyphens (-) instead of underscores ( _ ).
86+
87+
```
88+
http://api.example.com/inventory-management/managed-entities/{id}/install-script-location //More readable
89+
http://api.example.com/inventory_management/managed_entities/{id}/install_script_location //More error prone
90+
```
91+
92+
### **Use lowercase letters in URIs**
93+
94+
When convenient, lowercase letters should be consistently preferred in URI paths.
95+
96+
RFC 3986 defines URIs as case-sensitive except for the scheme and host components. e.g.
97+
```
98+
http://api.example.org/my-folder/my-doc //1
99+
HTTP://API.EXAMPLE.ORG/my-folder/my-doc //2
100+
http://api.example.org/My-Folder/my-doc //3
101+
```
102+
In above examples, 1 and 2 are same but 3 is not as it uses My-Folder in capital letters.
103+
104+
### **Never use CRUD function names in URIs**
105+
106+
URIs should not be used to indicate that a CRUD function is performed. URIs should be used to uniquely identify resources and not any action upon them. HTTP request methods should be used to indicate which CRUD function is performed.
107+
```
108+
HTTP GET http://api.example.com/device-management/managed-devices //Get all devices
109+
HTTP POST http://api.example.com/device-management/managed-devices //Create new Device
110+
111+
HTTP GET http://api.example.com/device-management/managed-devices/{id} //Get device for given Id
112+
HTTP PUT http://api.example.com/device-management/managed-devices/{id} //Update device for given Id
113+
HTTP DELETE http://api.example.com/device-management/managed-devices/{id} //Delete device for given Id
114+
```
115+
116+
### **Use query component to filter URI collection**
117+
118+
Many times, you will come across requirements where you will need a collection of resources sorted, filtered or limited based on some certain resource attribute. For this, do not create new APIs – rather enable sorting, filtering and pagination capabilities in resource collection API and pass the input parameters as **query parameters**. e.g.
119+
120+
```http://api.example.com/device-management/managed-devices
121+
http://api.example.com/device-management/managed-devices?region=USA
122+
http://api.example.com/device-management/managed-devices?region=USA&brand=XYZ
123+
http://api.example.com/device-management/managed-devices?region=USA&brand=XYZ&sort=installation-date
124+
```
125+
48126
# SSL everywhere - all the time
49127

50128
Always use SSL. No exceptions. Today, your web APIs can get accessed from anywhere there is internet (like libraries, coffee shops, airports among others). Not all of these are secure. Many don't encrypt communications at all, allowing for easy eavesdropping or impersonation if authentication credentials are hijacked.

topics/security.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ Tokens vs cookies.
3131
Localhost vs direct.
3232

3333
### User groups
34-
Linux permissions.
34+
Linux permissions.

0 commit comments

Comments
 (0)