This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import urllib.request | |
import requests | |
import os | |
with urllib.request.urlopen('Your URL') as response: | |
html_doc = response.read() | |
def download_file(url): | |
local_filename = url.split('/')[-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let a; // falsy value | |
let b = predefinedFunctionWhichReturnsFalse(); // false | |
let c = computationallyHeavyFunctionWhichReturnsFalse(); // falsy value | |
let d = false; | |
let e = true; | |
// Needs to evalaute every condition. | |
let result = a | b | c | d | e; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public user = await asyncUserFunction(); | |
public cat = await asyncCatFunction(); | |
public isCatVisible = user.cat.id === cat.id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Vague conditions that need investigating ❌ | |
<div> *ngIf="user?.cat.id === cat?.id;" | |
Cute cat pictures need to be seen by that user. | |
</div> | |
// You can understand from naming and simpler expressions ✅ | |
<div> *ngIf="isCatVisible" | |
Cute cat pictures need to be seen by that user. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compileOnSave": false, | |
"compilerOptions": { | |
"baseUrl": "./src", | |
"outDir": "./dist/out-tsc", | |
"sourceMap": true, | |
"declaration": false, | |
"downlevelIteration": true, | |
"experimentalDecorators": true, | |
"module": "esnext", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Can be used instead of Array functions | |
const a = [1,2,4]; | |
const b = [3,7,6]; | |
const c = 1; | |
// a.concat(b); | |
let arr = [...a,...b]; | |
// Unshift, push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example is from = https://www.javascripttutorial.net/es6/javascript-arrow-function/ | |
// Normal/Traditional function | |
function Car() { | |
this.speed = 0; | |
this.speedUp = function (speed) { | |
this.speed = speed; | |
let self = this; | |
// Creates it's own scope. You have to create another variable to access the upper scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ❌ | |
<div *ngIf="condition; else elseBlock"> | |
<div class="cool-content">My beautiful styled content</div> | |
</div> | |
<ng-template #elseBlock> | |
<div>Same content but not cool </div> | |
</ng-template> | |
✅ | |
<div [class.cool-content]="condition">My beautiful styled content with nicer syntax</div> |