Archive

EC2 Mac

#
# On your laptop, connect to the Mac instance with SSH (similar to Linux instances)
#
ssh -i ec2-user@

#
# On the Mac
#

# Set a password for ec2-user

sudo passwd ec2-user

# Enable VNC Server (thanks arnib@amazon.com for the feedback and tests)

sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
-activate -configure -access -on \
-configure -allowAccessFor -specifiedUsers \
-configure -users ec2-user \
-configure -restart -agent -privs -all

sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
-configure -access -on -privs -all -users ec2-user

exit

#
# On your laptop
# Create a SSH tunnel to VNC and connect from a vnc client using user ec2-user and the password you defined.
#

ssh -L 5900:localhost:5900 -C -N -i ec2-user@

# open another terminal

open vnc://localhost

#
# On the mac, resize the APFS container to match EBS volume size
#

PDISK=$(diskutil list physical external | head -n1 | cut -d” ” -f1)
APFSCONT=$(diskutil list physical external | grep “Apple_APFS” | tr -s ” ” | cut -d” ” -f8)
sudo diskutil repairDisk $PDISK
# Accept the prompt with “y”, then paste this command
sudo diskutil apfs resizeContainer $APFSCONT 0

Linux check occupied space in folder

sudo du -sh /var/lib/*

View all npm global packages installed

npm list -g --depth 0

How to add your repo branch to npm proj

npm i –save github:frank10gm/react-native-material-textfield#bugfix/proptypes-deprecation

Nginx configuration

nginx.conf
user francesco staff;
worker_processes 1;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
include /usr/local/etc/nginx/sites-enabled/*.conf;
}

[windows] nginx.conf
#user nobody;
worker_processes 1;

error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;

pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
keepalive_timeout 65;
include c:/nginx/conf/sites/*.conf;
}

default.conf
server {
listen 80;
server_name localhost;
root /Users/francesco/workspace/hackweb;

location / {
index index.php index.html index.htm;
autoindex on;
}

location ~ \.php {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
}

[hackweb] default.conf
server {
listen 80;
server_name localhost;
root c:/Users/Francesco/workspace/hackweb/hackweb/www;
index index.php index.html index.htm;
port_in_redirect on;
client_max_body_size 100M;
fastcgi_read_timeout 1800;
error_page 404 /index.php;

location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
autoindex on;
try_files $uri $uri/ /index.php$is_args$args;
}

# if (!-e $request_filename) {
# rewrite ^(.*)$ $scheme://$http_host/index.php break;
# }

# if (-d $request_filename) {
# rewrite ^(.*)$ $scheme://$http_host/index.php break;
# rewrite [^/]$ $scheme://$http_host/index.php permanent;
# rewrite [^/]$ $scheme://$http_host$uri/ permanent;
# }
location ~ /\. {
deny all;
}

location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
access_log off;
}

location ~ \.php {
try_files $uri =404;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9123;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
}
}

[windows] init.bat
@ECHO OFF
REM Start Nginx
taskkill /IM "nginx.exe" /F
taskkill /IM "php-cgi.exe" /F
tasklist /FI "IMAGENAME eq nginx.exe" 2>NUL | find /I /N "nginx.exe">NUL
IF NOT "%ERRORLEVEL%"=="0" (
REM Nginx is NOT running, so start it
c:
cd C:\nginx
start nginx.exe
ECHO Nginx started.
ECHO Starting PHP FastCGI...
c:\bin\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9123
) else (
ECHO Nginx is already running.
)