Skip to content

Instantly share code, notes, and snippets.

View aamsur-mkt's full-sized avatar

Aam S aamsur-mkt

View GitHub Profile
@aamsur-mkt
aamsur-mkt / install-phalcon-dev.sh
Last active March 11, 2020 06:31
Install Phalcon Dev Tools
DEVTOOLS_VERSION=3.4.1
curl -LO https://github.com/phalcon/phalcon-devtools/archive/v$DEVTOOLS_VERSION.tar.gz \
&& tar xzf v${DEVTOOLS_VERSION}.tar.gz \
&& mv phalcon-devtools-${DEVTOOLS_VERSION} /usr/local/phalcon-devtools \
&& ln -s /usr/local/phalcon-devtools/phalcon.php /usr/local/bin/phalcon \
&& rm -f v${DEVTOOLS_VERSION}.tar.gz
@aamsur-mkt
aamsur-mkt / convert-log-tgz.sh
Last active March 23, 2020 04:37
Convert All Log to Tgz
# go to your folder then run this script
# this script will loop by file names (*.log) in current folder, create tgz then remove source file
for d in ./*.log; do tar zcvf $d.tgz $d && rm $d; done
# with +30 days old filter
for d in `find ./*.log -type f -mtime +30`; do tar zcvf $d.tgz $d && rm $d; done
@aamsur-mkt
aamsur-mkt / install-filebeat.sh
Last active March 19, 2020 07:46
Install Filebeat
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.0.1-amd64.deb
sudo dpkg -i filebeat-7.0.1-amd64.deb
sudo apt-get install -f
@aamsur-mkt
aamsur-mkt / show-incoming-connection.sh
Created March 6, 2020 14:47
Show incoming connection and port via
netstat -ntu|awk '{print $5" "$4}'|cut -d ":" -f1,3 -s|sort|uniq -c|sort -nk1 -r
# example output :
3 140.213.45.65:22 # 3 connection income to this server from ip 140.213.45.65 via port 22
1 222.186.42.7:22 # 1 connection income to this server from ip 222.186.42.7 via port 22
1 222.186.30.145:22
1 172.19.0.3:9200
1 172.19.0.2:51952
@aamsur-mkt
aamsur-mkt / dynamic-wildcard-subdomain.htaccess
Created March 2, 2020 08:08
Dynamic Wildcard Subdomain Apache CORS
SetEnvIf Origin "^http(s)?://(.+\.)?(localhost|localhost:8000|booking\.google\.com|booking\.yahoo\.com)$" origin_is=$0
Header set Access-Control-Allow-Origin %{origin_is}e env=origin_is
@aamsur-mkt
aamsur-mkt / http-request.js
Created March 2, 2020 07:53
Simple js http request
var theUrl = "https://google.co.id";
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false );
xmlHttp.send( null );
alert(xmlHttp.responseText);
@aamsur-mkt
aamsur-mkt / create-master-user.sql
Last active March 4, 2020 09:03
Create master user that can create other user
create user master_user@'%' identified by 'yourfpassword';
grant CREATE USER on *.* to master_user@'%';
grant GRANT OPTION USER on *.* to master_user@'%';
grant ALL on *.* to master_user@'%';
FLUSH PRIVILEGES;
@aamsur-mkt
aamsur-mkt / README.md
Created February 25, 2020 10:51 — forked from NiceGuyIT/README.md
nginx JSON to Filebeat to Logstash to Elasticsearch

Intro

This is an example configuration to have nginx output JSON logs to make it easier for Logstash processing. I was trying to get nginx > Filebeat > Logstash > ES working and it wasn't until I connected Filebeat directly to Elasticsearch that I saw the expected data. Google led me to ingest-convert.sh and I realized filebeat setup works for Filebeat > ES but not Filebeat > Logstash > ES. This is because Logstash does not use ingest pipelines by default. You have to enable them in the elasticsearch output block.

Having nginx log JSON in the format required for Elasticsearch means there's very little processing (i.e. grok) to be done in Logstash. nginx can only output JSON for access logs; the error_log format cannot be changed.

Extra fields are output and not used by the Kibana dashboards. I included them in case they might be useful. Since they are not declared in the filebeat setup, their default is "string" when yo

@aamsur-mkt
aamsur-mkt / docker-android.txt
Last active February 19, 2020 10:59
Docker Android Seleniun RnD Notes
===DOCKER COMPOSE===
version: '3'
services:
selenium_hub:
image: selenium/hub
ports:
- "4444:4444"
emulator:
@aamsur-mkt
aamsur-mkt / php-package.sh
Created February 18, 2020 09:37
List all php package on Linux
dpkg -l | grep php | tee packages.txt
# This will save your current packages to packages.txt file in your working directory.