Skip to content

Instantly share code, notes, and snippets.

View Wintus's full-sized avatar
📡
on the ground

wint Wintus

📡
on the ground
  • Tokyo
  • 03:52 (UTC +09:00)
  • X @wint7
View GitHub Profile
@Wintus
Wintus / div-rel.rb
Last active February 8, 2025 09:54
discrete mathematics
# make Rel in Hasse diagram
# 0 and 1 are trivial and omitted
require 'prime'
Graph = Data.define(:nodes, :edges) do
def initialize(nodes: [], edges: [])
super
end
end
@Wintus
Wintus / bb26.rb
Created November 22, 2024 16:14
The bijective base-26 system
def naive(n)
s = ?A
(n-1).times { s.succ! }
s
end
def digits(n, base=10)
ds = []
while n > 0
case n.divmod(base)
Copyright (c) <year> <copyright holders>
This software is provided ‘as-is’, without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
@Wintus
Wintus / FizzBuzz.sh
Created August 4, 2024 14:24
find mkdir system
mkdir -p d/x
find d -regextype posix-extended -regex 'd(/x){1,29}' -exec mkdir -p '{}'/x \;
find d -regextype posix-extended \
-regex 'd((/x){3})+' -printf "Fizz" , \
-regex 'd((/x){5})+' -printf "Buzz" , \
-regex 'd((/x){3})+' -o \
-regex 'd((/x){5})+' -o \
-regex 'd(/x)+' -printf "%d" , \
@Wintus
Wintus / solution.sql
Last active July 24, 2024 15:48
GSP787
SELECT sum(cumulative_confirmed) as total_cases_worldwide
FROM `bigquery-public-data.covid19_open_data.covid19_open_data`
WHERE date=?
;
WITH
deaths_by_states AS (
SELECT
subregion1_name AS state,
SUM(cumulative_deceased) AS death_count
@Wintus
Wintus / ec.sql
Last active July 24, 2024 14:02
GSP341
CREATE OR REPLACE MODEL `ecommerce.customer_classification_model`
OPTIONS
(
model_type='logistic_reg',
labels = ['will_buy_on_return_visit']
)
AS
#standardSQL
SELECT
* EXCEPT(fullVisitorId)
@Wintus
Wintus / GCL-jobCompleted-sink.sql
Last active June 24, 2024 11:20
Google Cloud: GIG
CREATE OR REPLACE VIEW bq_logs.v_querylogs AS
WITH job_completed_event AS (
SELECT
resource.labels.project_id,
protopayload_auditlog.authenticationInfo.principalEmail,
protopayload_auditlog.servicedata_v1_bigquery.jobCompletedEvent.job AS job,
severity
FROM `bq_logs.cloudaudit_googleapis_com_data_access_*`
)
SELECT
SELECT dt,
DATETIME_DIFF(DATETIME(dt), FIRST_VALUE(DATETIME(dt)) OVER (w), SECOND) /
DATETIME_DIFF(LAST_VALUE(DATETIME(dt)) OVER (wall), FIRST_VALUE(DATETIME(dt)) OVER (w), SECOND) AS progress
FROM UNNEST(GENERATE_DATE_ARRAY('2024-01-01', '2025-01-01')) AS dt
QUALIFY progress < 1
WINDOW w AS ( ORDER BY dt ),
wall AS ( ORDER BY dt ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING )
;
SELECT t,
ruby -r'uri' -lpe 'uri=URI.parse($_);(uri.query||uri.path).gsub!(/\.$/,"%2E");$_=uri.to_s'