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 / vscode-server-update.md
Created November 9, 2023 02:43
Manually install vscode on server side

First of all, open the vscode editor and check the commit version from "About Visual Studio Code" tab, it should be something like 2b35e1e6d88f1ce073683991d1eff5284a32690f.

Save the bellow script and pass it the commit code to run will do the job.

#!/bin/bash

code_server=~/vscode-server-linux-x64.tar.gz

curl -L https://update.code.visualstudio.com/commit:${@}/server-linux-x64/stable > $code_server
@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 / storage_pricing.sql
Last active September 6, 2023 07:39
BigQuery Storage Pricing comparison 比较BigQuery在每个Dataset(数据集)的物理存储和逻辑存储的价格
DECLARE active_logical_gib_price FLOAT64 DEFAULT 0.02;
DECLARE long_term_logical_gib_price FLOAT64 DEFAULT 0.01;
DECLARE active_physical_gib_price FLOAT64 DEFAULT 0.04;
DECLARE long_term_physical_gib_price FLOAT64 DEFAULT 0.02;
WITH
storage_sizes AS (
SELECT
table_schema AS dataset_name,
-- Logical
@bindiego
bindiego / glibc.c
Created May 29, 2023 12:55
Check glibc version
#include <stdio.h>
#include <stdlib.h>
#include <gnu/libc-version.h>
int main(int argc, char *argv[])
{
// Print glibc version
printf("GNU libc version: %s\n", gnu_get_libc_version());
exit(EXIT_SUCCESS);
}
@bindiego
bindiego / dailyjob.py
Created April 27, 2023 08:03
Test Bigquery table existence then implement business logic
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from datetime import date
from datetime import datetime
import time
import uuid
t = time.time()
t_ms = int(t * 1000)
@bindiego
bindiego / firebase_bigquery_dedup.sql
Last active February 28, 2023 14:29
BigQuery Deduplication
with n_dups as
(
SELECT event_name, event_timestamp, user_pseudo_id, count(1)-1 as n_duplicates
FROM `project.dataset.events_20190610`
group by event_name, event_timestamp, user_pseudo_id
)
select n_duplicates, count(1) as n_cases
from n_dups
group by n_duplicates
order by n_cases desc
var crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'd6F3Efeq';
function encrypt(buffer){
var cipher = crypto.createCipher(algorithm,password)
var crypted = Buffer.concat([cipher.update(buffer),cipher.final()]);
return crypted;
}
@bindiego
bindiego / arr2dict.js
Last active August 10, 2022 00:42
Use filebeat to deal with csv / tsv with header as first line
function convert_csv_to_dict(csv_headers_row, csv_values_row) {
var json_from_csv = csv_values_row.reduce(function(result, field, index) {
result[csv_headers_row[index]] = field;
return result;
}, {})
return json_from_csv;
}
var headers_fn = (function() {
# ___ ___ __ __
# / | __ ______/ (_) /_____/ /
# / /| |/ / / / __ / / __/ __ /
# / ___ / /_/ / /_/ / / /_/ /_/ /
# /_/ |_\__,_/\__,_/_/\__/\__,_/
#
# Linux Audit Daemon - Best Practice Configuration
# /etc/audit/audit.rules
# Remove any existing rules
@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,