Skip to content

Instantly share code, notes, and snippets.

View icarrr's full-sized avatar
🚴
Cycling anywhere and Work from everywhere

Faizar Septiawan icarrr

🚴
Cycling anywhere and Work from everywhere
View GitHub Profile
@icarrr
icarrr / immortal.bat
Created November 25, 2019 11:57
Can move files that are more than 2 days old
@echo off
set X=2
set "source=source"
set "destination=destination"
robocopy "%source%" "%destination%" /move /minage:%X%
@icarrr
icarrr / main.py
Created November 21, 2019 09:11
Access a function variable outside the function without using “global”
def hi():
# other code...
hi.bye = 42 # Create function attribute.
sigh = 10
hi()
print(hi.bye) # -> 42
@icarrr
icarrr / main.sh
Created November 20, 2019 15:47
Dump data osTicket on MySQL
localTime=$(date '+%Y%m%d_%H%M%S' -d "$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')")
mysqldump -u root -p --databases osTicket > dump-osTicket-$localTime.sql
@icarrr
icarrr / pretty.py
Created November 20, 2019 15:38
prettify the html
from bs4 import BeautifulSoup as bs
import sys
# But, we'll read from standard input, so we can pipe output to it
# i.e. run with cat filename.html | this_file.py
data = sys.stdin.readlines()
data = "".join(data)
soup = bs(data) #make BeautifulSoup
prettyHTML=soup.prettify() #prettify the html
@icarrr
icarrr / main.sh
Created November 20, 2019 15:36
Test send mail via API Sendgrid using curl
curl --request POST --url https://api.sendgrid.com/v3/mail/send \
--header 'authorization: Bearer API_KEY' \
--header 'content-type: application/json' \
--data '{"personalizations":[{"to":[{"email":"update me!", "name":"Orang Ganteng"}],"subject":"Hello!"}],"content": [{"type": "text/plain", "value": "Nice Works"}],"from":{"email":"sendgrid@localhost","name":"Sendgrid"}}'
@icarrr
icarrr / main.sh
Created November 20, 2019 10:55
test connect to site and show certs. Ex, connect to api.sendgrid.com
openssl s_client -showcerts -connect api.sendgrid.com:443
@icarrr
icarrr / nginx-tuning.md
Created November 19, 2019 14:27 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@icarrr
icarrr / Nginx + Apache reverse proxy REAL IP.md
Created November 19, 2019 14:27 — forked from patrocle/Nginx + Apache reverse proxy REAL IP.md
Real IP for Apache (Nginx reverse proxy)

NGINX 1.10 + APACHE 2.4 real IP for reverse proxy

Edit nginx conf

default.conf or what you want

vim /etc/nginx/conf.d/default.conf

add proxy_set_header for php files

@icarrr
icarrr / main.sh
Created November 18, 2019 06:33
Get IP Public using 3rd party web-sites on command line
curl ifconfig.me
curl icanhazip.com
curl ipecho.net/plain
curl ifconfig.co
@icarrr
icarrr / main.py
Created November 17, 2019 14:58
Get list file from site by extension
from bs4 import BeautifulSoup
import requests
url = 'https://www.example.com/2019/11/13/presentasi/'
ext = 'pdf'
def listFD(url, ext=''):
page = requests.get(url).text
soup = BeautifulSoup(page, 'html.parser')
return [node.get('href') for node in soup.find_all('a') if node.get('href').endswith(ext)]