- People talk about two servers: a web server (e.g. Nginx, Apache, etc.) and a app server (e.g. Language specific servers like Unicorn, Node.js, Tomcat, Http-Kit, etc.). There are exceptions where app servers not required at all (as web server itself provides preprocessors for handling), but let's not talk about now.
- Web servers are really fast and supports lot of standard and commonly used MIME-type requests. Concept of serving a file is -- forming and sending a response of bytes of data and labeling it with requested MIME-type by a client (e.g. web browser).
- Every response format (in layman's language, a file) is recognized by it's MIME-type, for e.g. a PNG image file has "image/png" MIME-type. JavaScript file has "text/javascript". HTML responses (or files) has "text/html". Plain text files have "text/plain".
- Modern Browsers supports a lot of standard MIME-types. Images, videos, text files (XML, HTML, SVG, JS), and they better know how to visualize it. Browser also knows unrec
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
## Clone a running OS from SD card to USD SSD, Raspberry 4B 8G | |
### Main guide | |
https://medium.com/xster-tech/move-your-existing-raspberry-pi-4-ubuntu-install-from-sd-card-to-usb-ssd-52e99723f07b | |
### References: | |
https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-boot-modes | |
https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-4-boot-flow | |
https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-4-boot-eeprom |
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
# Generate du command to check disk | |
# Ignore all the mount points nfs4. Modify the "df -t nfs4" as you want | |
# Run with lowest CPU priority and lowest diskio priority | |
# extract the content from the last column and store it in an array | |
IFS=$'\n' read -d '' -ra MOUNT_POINTS <<< "$(df -h -t nfs4 | awk '{print $NF}')" | |
# construct the new du command with the excluded mount points | |
DU_COMMAND="nice -n 19 ionice -c 3 du -shxc /* --exclude=/proc" | |
for mount_point in "${MOUNT_POINTS[@]}"; do |
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
Different from bash, PowerShell is object-orriented. Understanding objects are necessary to utilize PowerShell | |
Get-NetIPAddress -AddressFamily IPV4 -AddressState Preferred -IncludeAllCompartments | Get-Member | |
TypeName: Microsoft.Management.Infrastructure.CimInstance#ROOT/StandardCimv2/MSFT_NetIPAddress | |
Name MemberType Definition | |
---- ---------- ---------- | |
ifIndex AliasProperty ifIndex = InterfaceIndex |
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
### | |
### This gist contains 2 files : settings.json and lambda_function.py | |
### | |
### settings.json | |
{ | |
"extensions" : ["*.hdr", "*.glb", "*.wasm"] | |
} | |
### lambda_function.py |
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
# Stack size check for HTTPD thread | |
ps aux | grep "[h]ttpd" | awk '{print $2}' > /tmp/httpd.list | |
while IFS= read -r line | |
do | |
echo "$line" | |
cat /proc/$line/status | |
ls /proc/$line/task | xargs -I % bash -c "cat /proc/$line/task/%/status" | grep VmStk | |
done < /tmp/httpd.list | |
rm -f /tmp/httpd.list | |
### Since on all thread of process share everything except stack, we only check VmStk here |
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
# Create user-defined overlay network | |
Prerequisites: | |
Firewall rules for Docker daemons using overlay networks | |
You need the following ports open to traffic to and from each Docker host participating on an overlay network: | |
"TCP port 2377 for cluster management communications | |
TCP and UDP port 7946 for communication among nodes | |
UDP port 4789 for overlay network traffic" | |
Before you can create an overlay network, you need to either initialize your Docker daemon as a swarm manager using: docker swarm init | |
or join it to an existing swarm using: docker swarm join | |
Either of these creates the default ingress overlay network which is used by swarm services by default. You need to do this even if you never plan to use swarm services. Afterward, you can create additional user-defined overlay networks. |
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
proxy_cache_path /tmp/cacheapi levels=1:2 keys_zone=microcacheapi:100m max_size=1g inactive=1d use_temp_path=off; | |
server { | |
listen 443 ssl http2 default_server; | |
listen [::]:443 ssl http2 default_server; | |
server_name example.com; | |
location /api/ { | |
# Rate Limiting | |
limit_req zone=reqlimit burst=20; # Max burst of request |
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
#!/bin/bash | |
set -u | |
set -e | |
set -o pipefail | |
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
cat <<'EOF' > /etc/modprobe.d/blacklist-ipv6.conf |
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
### Handling error example | |
import sys | |
import traceback | |
try: | |
f = open('myfile.txt') | |
s = f.readline() | |
i = int(s.strip()) | |
except OSError as err: |
NewerOlder