Skip to content

Instantly share code, notes, and snippets.

View yihyang's full-sized avatar
😰
kinda busy

Yih Yang yihyang

😰
kinda busy
View GitHub Profile
Introduction to SQL for BigQuery and Cloud SQL
# Exploring the BigQuery Console
SELECT end_station_name FROM `bigquery-public-data.london_bicycles.cycle_hire`;
SELECT * FROM `bigquery-public-data.london_bicycles.cycle_hire` WHERE duration>=1200;
SELECT start_station_name FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name;
# More SQL Keywords: GROUP BY, COUNT, AS, and ORDER BY
SELECT start_station_name, COUNT(*) FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name;
SELECT start_station_name, COUNT(*) AS num_starts FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name;
@yihyang
yihyang / Gemfile
Last active March 30, 2020 06:06
Small PR script to get all the PRs information and Notion Ticket URL between 2 different branches
source 'https://rubygems.org'
gem "octokit", "~> 4.0"
{
"Ansi 7 Color" : {
"Green Component" : 0.73333334922790527,
"Red Component" : 0.73333334922790527,
"Blue Component" : 0.73333334922790527
},
"Tags" : [
],
"Ansi 12 Color" : {
@yihyang
yihyang / car_model_api_service_spec.rb
Last active July 16, 2019 06:45
Writing tests / specs on Ruby
require 'rails_helper'
describe CarModelAPIService do
shared_examples_for 'fetch method' do
it { is_expected.to eq(result) }
end
describe '#fetch' do
subject { CarModelAPIService.new(params).fetch }
context 'when params is xxx' do
@yihyang
yihyang / jsonb_performance_benchmark.sql
Last active July 5, 2019 09:02
some SQL to test JSONB Performance versus first level columns
--create database testing_json_performance;
--create table test_table (income float, start_period integer, end_period integer, name varchar(50), invitation_only boolean, properties jsonb);
--select * from test_table;
--delete from test_table;
-- -- create index
--create index idx_income on test_table (income);
--create index idx_period on test_table (start_period, end_period);
--create index idx_name on test_table (name);
--create index idx_properties_income on test_table using gin ((properties -> 'income') jsonb_path_ops);
@yihyang
yihyang / bash-critical-css.sh
Last active March 19, 2019 06:17
Bash to generate critical CSS
# check whether critical has been generated
if ! [ -x "$(command -v critical)" ]; then
echo 'Error: critical CSS is not installed.' >&2
exit 1
fi
# ask for website
echo "Website URL (without http / https):"
read -r url
@yihyang
yihyang / csv-to-json.rb
Created November 5, 2018 04:15
Convert CSV to JSON with this simple ruby script!
require 'csv'
require 'json'
reading_filename = 'input.csv'
output_filename = 'output.json'
arr = CSV.read(reading_filename)
File.open(output_filename, 'w') do |f|
f.write(arr.to_json)
require 'byebug'
require 'json'
require 'logger'
require 'octokit'
username = 'x'
github_token = 'x'
organization_name = 'x'
@yihyang
yihyang / pull-request-labels.txt
Created October 11, 2018 06:23
Pull Requests Labels
New Feature - #ccffcc
Bugfix - #ffe6e6
Chore - #cceeff
Epic - #3399ff
Work In Progress - #ff9900
Do Not Merge - #d73a4a
@yihyang
yihyang / .circleci-config.yml
Created September 13, 2018 06:47
CircleCI Config to run multiple test using workflow
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
# TODO: Remove the following when CircleCI Image is using newer version
# Refer to issue here: https://discuss.circleci.com/t/session-not-created-exception-chrome-version-must-be-62-0-3202-0/19258
install_chrome: &install_chrome
name: Install Chrome
command: |
sudo apt-get update