Bootstrap

ARTS - Week Three

Algorithm

Problem

Move Zeroes

Given an array , write a function to move all 's to the end of it while maintaining the relative order of the non-zero elements.

Solution

var moveZeroes = function(nums) {
    let j = 0
    for (let i = 0; i < nums.length; i++) {
        if (nums[i] != 0) {
            if (i != j) {
                nums[j] = nums[i]
                nums[i] = 0
            }    
            j++
        }
    }
};

Review

Artical

Hardening Your HTTP Security Headers

Link

Review

Seven different HTTP security headers:

1. Content Security Policy

This example below allows scripts from both the current domain (defined by 'self') as well as google-analytics.com

Content-Security-Policy: script-src 'self' https://www.google-analytics.com

2. 

The  header is designed to enable the cross-site scripting (XSS) filter built into modern web browsers. 

X-XSS-Protection: 1; mode=block

3. HTTP Strict Transport Security (HSTS)

The  header is a security enhancement that restricts web browsers to access web servers solely over HTTPS.

Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

4. 

The  header provides clickjacking protection by not allowing iframes to load on your website.

X-Frame-Options: SAMEORIGIN

5. 

The  header prevents misissued certificates from being used by allowing websites to report and optionally enforce Certificate Transparency requirements. 

Expect-CT: max-age=604800, enforce, report-uri="https://www.example.com/report"

6. 

The  header prevents Internet Explorer and Google Chrome from sniffing a response away from the declared . 

X-Content-Type-Options: nosniff

7. 

The  header grants the ability to allow or deny browser features, whether in its own frame or content within an inline frame element ().

Feature-Policy: autoplay 'none'; camera 'none'
How to check your HTTP security headers

1. KeyCDN's HTTP Header Checker tool

2. Chrome DevTools response headers

3. Scan your website with Security Headers

Taobao is in grade R; Baidu is in grade F; Google is in grade D;The website itself is A.

Tips

What do you do when you nend to exchange the value of two variables?

// Traditional approach
int a = 10;
int b = 12;
int temp;
temp = a;
a = b;
b = temp;

// here may be something new to you
int a = 10;
int b = 12;
a = a^b
b = a^b
a = a^b // now a and b have exchanged their value.
// this is because a = a^b^a;  ^ means Exclusive OR (xor)  

Share

Artical

Open Source Benefits to Innovation and Organizational Agility

Link

Summary

Open Source Generations

Five leading open source benefits