Archive

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.
)

CRC16 in big endian order

// CRC16 in big endian order
const crcArr = new Uint8Array(2);
crcArr[0] = crcByte1;
crcArr[1] = crcByte2;
const buffer = crcArr.buffer;
const datav = new DataView(buffer);
const uint16 = datav.getUint16(0, false); // big endian
byteArr[index++] = uint16 & 0xff;
byteArr[index++] = uint16 >> 8;