Skip to content

Instantly share code, notes, and snippets.

View bindiego's full-sized avatar
🎸
be cool

Bin Wu bindiego

🎸
be cool
View GitHub Profile
@bindiego
bindiego / default.conf
Last active March 26, 2020 10:59
nginx reverse proxy your site
server {
listen 80;
# server_name _;
# ssl_protocols TLSv1.2;
charset utf-8;
location /hc {
access_log /var/log/nginx/health-check-access.log;
@bindiego
bindiego / readme.md
Created March 11, 2020 05:17
Linux cpu monitoring

CPU monitoring

5 seconds average, threshold: 90%

#!/bin/bash

CPU=$(sar 1 5 | grep "Average" | sed 's/^.* //')
CPU=$( printf "%.0f" $CPU )
@bindiego
bindiego / readme.md
Created March 3, 2020 12:29
Elasticsearch Shards Management

Elasticsearch Shards Management

Elasticsearch 分片管理

Before you start, curl with credentials 如果需要认证,就使用--user参数就好了

curl --user username:password -XPUT 'localhost:9200/myindex'
@bindiego
bindiego / readme.md
Last active March 24, 2020 10:05
Add images to Gist

Add images to Gist 添加图片到Gist

  1. Create your Gist with some contents, e.g. readme.md file

  2. Clone locally

# with ssh
git clone git@gist.github.com:<hash>.git mygist
@bindiego
bindiego / firewall.png
Last active February 27, 2020 08:47
GCP adding multiple NICs to one VM
firewall.png
@bindiego
bindiego / events.sql
Last active January 8, 2024 12:08
Firebase data in BigQuery
-- get number of events for each
SELECT
event_dim.name,
COUNT(event_dim.name) as event_count
FROM
[firebase-analytics-sample-data:android_dataset.app_events_20200101]
GROUP BY
event_dim.name
ORDER BY
event_count DESC
@bindiego
bindiego / kube.sh
Created October 16, 2019 02:28
kubernets useful commands
# get service external ip address
EXTERNAL_IP=$(kubectl get svc <service_name> -o yaml | grep ip | awk -F": " '{print $NF}')
@bindiego
bindiego / readme.md
Created October 8, 2019 07:10
parquet-mr tool

Suppose you already have your java development environment ready

Get the source code

git clone https://github.com/apache/parquet-mr.git

Build it

cd parquet-mr/parquet-tools/ && mvn clean package -Plocal

@bindiego
bindiego / bq_dataaccess_view.sql
Last active May 30, 2022 23:45
GCP Billing export to BigQuery and Datastudio Visualization
SELECT
timestamp AS Date,
resource.labels.project_id AS ProjectId,
protopayload_auditlog.serviceName AS ServiceName,
protopayload_auditlog.methodName AS MethodName,
protopayload_auditlog.status.code AS StatusCode,
protopayload_auditlog.status.message AS StatusMessage,
protopayload_auditlog.authenticationInfo.principalEmail AS UserId,
protopayload_auditlog.servicedata_v1_bigquery.jobCompletedEvent.job.jobName.jobId AS JobId,
protopayload_auditlog.servicedata_v1_bigquery.jobCompletedEvent.job.jobConfiguration.query.query AS Query,
# ___ ___ __ __
# / | __ ______/ (_) /_____/ /
# / /| |/ / / / __ / / __/ __ /
# / ___ / /_/ / /_/ / / /_/ /_/ /
# /_/ |_\__,_/\__,_/_/\__/\__,_/
#
# Linux Audit Daemon - Best Practice Configuration
# /etc/audit/audit.rules
# Remove any existing rules