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 / 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 / git_rm_hist.sh
Created April 13, 2021 02:27
remove git history
#!/bin/bash
git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch <Path to File>" HEAD
git push --all
@bindiego
bindiego / 01.README.md
Last active January 29, 2021 03:46 — forked from matsukaz/01.README.md
Find a geolocation of an IP address in BigQuery

This query is to find geolocation of an IP address including latitude, longitude, city and country.

Legacy SQL doesn't support range conditions such as BETWEEN when using JOIN, so we need to filter data by WHERE. This means if IP address does not match any of the data inside geolite_city_bq_b2b, records will not be able to receive.

Use Standard SQL if you want to receive records no matter you succeed to find geolocation or not.

Please refer to the following post for more detail.

https://cloudplatform.googleblog.com/2014/03/geoip-geolocation-with-google-bigquery.html

import argparse
import base64
import datetime
import hashlib
import hmac
from six.moves import urllib
# [START sign_url]
@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() {
@bindiego
bindiego / readme.md
Created March 30, 2020 03:26
Highlight duplicated lines in Vim

Highlight duplicated lines in Vim

:syn clear Repeat | g/^\(.*\)\n\ze\%(.*\n\)*\1$/exe 'syn match Repeat "^' . escape(getline('.'), '".\^$*[]') . '$"' | nohlsearch
@bindiego
bindiego / TriggerExample.java
Last active March 24, 2020 10:09
Apache Beam & GCP Dataflow triggers explained
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0