Task | PowerShell Command | macOS Bash Terminal Command |
---|---|---|
Current directory | Get-Location |
pwd |
List files and folders | Get-ChildItem |
ls |
Change directory | Set-Location <path> |
cd <path> |
Create a directory | New-Item -ItemType Directory -Name <name> |
mkdir <name> |
Create an empty file | New-Item -ItemType File -Name <name> |
touch <name> |
Copy a file | Copy-Item <source> <destination> |
cp <source> <destination> |
Move/rename a file | Move-Item <source> <destination> |
mv <source> <destination> |
Remove a file | Remove-Item <file> |
rm <file> |
const axios = require('axios') | |
const cheerio = require('cheerio') | |
async function getPrice(symbol) { | |
try { | |
let { data } = await axios.get(`https://finance.yahoo.com/quote/${symbol}?p=${symbol}&.tsrc=fin-srch`) | |
let $ = cheerio.load(data) | |
// use this one for bitcoin | |
// console.log(`The current price of ${symbol} is:`, '$' + $('span[data-reactid="33"]').eq(1).text()) | |
// use this one for aftermarket hours |
let maximum = parseInt(prompt("Enter the maximum number!")); | |
while (!maximum) { | |
maximum = parseInt(prompt("Enter a valid number!")); | |
} | |
const targetNum = Math.floor(Math.random() * maximum) + 1; | |
let guess = parseInt(prompt("Enter your first guess!")); | |
let attempts = 1; |
function isSelfDescribing(num) { | |
let numArray = String(num).split('').map(str => Number(str)); | |
// 123 => '123' => ['1', '2', '3'] => [1, 2, 3] | |
let i = 0; | |
for (const num of numArray) { | |
// check to see how many times the current index appears in the numArray | |
// and does that total match the current element/number for this iteration | |
if (numArray.filter(n => n === i).length !== num) { | |
return false; | |
} |
RabbitMQ is a message broker that facilitates communication between different parts of a software application or multiple applications. It's particularly useful when building a React app with a Django backend, especially in a containerized environment using Docker. Let's break down its benefits in this context:
-
Asynchronous Communication: In a web application, there are tasks that can be performed asynchronously, such as sending emails, processing data, or handling background jobs. RabbitMQ enables you to decouple these tasks from the main application flow. For instance, when a user submits a form in your React app, you can send a message to RabbitMQ, which the Django backend can pick up and process. This ensures that your main application remains responsive even during resource-intensive operations.
-
Scalability: Docker containers allow you to scale your application components as needed. When you have multiple instances of your Django backend running in containers, RabbitMQ can help distribute
def sentiment(message):
happy_count = 0
sad_count = 0
if len(message) < 3:
return "none"
for i in range(len(message) - 2):
if message[i] == ":" and message[i+1] == "-":
if message[i+2] == ")":
HTML (Hypertext Markup Language) is the standard markup language for creating web pages. It defines the structure and content of a web page using a system of tags and attributes.
- HTML Document Structure: An HTML document consists of a
<!DOCTYPE>
,<html>
,<head>
(with<title>
), and<body>
sections. - Elements and Tags: HTML elements are represented by tags (e.g.,
<p>
,<a>
,<div>
). - Attributes: Elements can have attributes (e.g.,
href
,src
,class
) that provide additional information. - Text Content: You can add text content using elements like
<p>
,<h1>
,<span>
, etc. - Links: Create hyperlinks using the
<a>
tag with thehref
attribute.
1. Variable Assignment:
my_variable = 42 # now my_variable references 42
2. Primitive Data Types:
my_integer = 42 # int
Welcome to the exciting world of Python programming!
Python's simplicity and power make it a top choice for software engineering, data analysis, and beyond. With Python, you can automate tasks, analyze data, build web applications, and even create AI. Today, we'll delve into the basics, setting the stage for your exploration of Python's endless possibilities. Let's dive in and unlock the potential of Python together!
By the end of this lecture, you will:
- Understand essential programming concepts in Python.
dict = {"a": 0, "b": 2, "c": 3} | |
def print_dict(d): | |
for key in d: | |
print(d[key]) | |
return d | |
new_dict = print_dict(dict) | |
print_dict(new_dict) |