Skip to content

Instantly share code, notes, and snippets.

View nim4n136's full-sized avatar
🏠
Working from home

NIM4N nim4n136

🏠
Working from home
View GitHub Profile
@nim4n136
nim4n136 / MainActivity.java
Created March 19, 2021 08:34 — forked from rduplain/MainActivity.java
A very simple full-screen WebView activity for Android native wrappers, as a starting point.
package com.willowtreeapps.demo;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
@nim4n136
nim4n136 / pysftp_sample.py
Created March 8, 2021 06:10
Pysftp sample
import pysftp
credentials = {
"host":'xx',
"username": 'xx',
"password": 'xx'
}
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
@nim4n136
nim4n136 / nginx.yaml
Created February 10, 2021 03:40
nginx error log
timestamps : 2021/02/10 10:30:02
level_error : [error] 1404#1404: *1 no live upstreams while connecting to upstream ( war | error | crit | emerg )
client : 202.10.22.1 (Public ip client)
server : subdomain.domain.com (Server)
request : GET /checkout/cart/1 HTTP/1.1 (Request http)
upstream : http://localhost:8080/checkout/cart/1 (Example upstream nodejs)
host : localhost (Host server)
@nim4n136
nim4n136 / sector_build.sql
Created February 2, 2021 06:05
Build sector function postgis
-- Radian
create or replace function misc_normalizeRadians(rad double precision)
returns double precision
as $$
SELECT r-floor(r/pi())*(2*pi()) FROM (SELECT (floor(rad/(2*pi()))*-(2*pi())+rad) as r) as t;
$$ LANGUAGE sql immutable;
-- Heading by angle
create or replace function misc_rotateHeadingByAngle(heading double precision,angle double precision)
returns double precision
@nim4n136
nim4n136 / oport.sh
Created January 22, 2021 03:45
Open port postgres centos
sudo firewall-cmd --zone=public --add-port=5432/tcp --permanent
sudo firewall-cmd --reload
@nim4n136
nim4n136 / posgis-docker.md
Last active January 22, 2021 03:42
Use exists data postgres/postgis docker

docker run -d --name pg-postgis-nrp -p 5432:5432 -e PGDATA=/var/lib/postgresql/data/pgdata -v /gluster/postgis:/var/lib/postgresql/data postgis/postgis

@nim4n136
nim4n136 / TileBBox.sql
Created January 17, 2021 08:15
Function Bbox Tile Postgis
/******************************************************************************
### TileBBox ###
Given a Web Mercator tile ID as (z, x, y), returns a bounding-box
geometry of the area covered by that tile.
__Parameters:__
- `integer` z - A tile zoom level.
- `integer` x - A tile x-position.
- `integer` y - A tile y-position.
- `integer` srid - SRID of the desired target projection of the bounding
box. Defaults to 3857 (Web Mercator).
@nim4n136
nim4n136 / clean_pg_wal.sh
Last active January 5, 2021 02:43
Clean pg_wal
# Check checkpoint pg wal
pg_controldata -D /var/lib/postgresql/data/
##
# Find this line
# Latest checkpoint's REDO WAL file: 000000010000000000000001
# Check pg wal / Dryrun
pg_archivecleanup -n /var/lib/postgresql/data/ 000000010000000000000001
#!/bin/bash
ARCHIVEDIR='/var/lib/pgsql/wal_archive'
LAST_BACKUP=$(ls -lto ${ARCHIVEDIR})
FILE_LIST=$(pg_archivecleanup -n "${ARCHIVEDIR}" "${LAST_BACKUP}")
## TEST FIRST
pg_archivecleanup -n "${ARCHIVEDIR}" "${LAST_BACKUP}" | find -type f -mmin +30 | xargs ls -lh
@nim4n136
nim4n136 / apache_revese_proxy_nodejs.md
Last active December 29, 2020 05:56
Nodejs revese proxy path apache

1. Add module proxy

Edit file config httpd

sudo nano /etc/httpd/conf/httpd.conf

Add this code to config httpd

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so