Skip to content

Instantly share code, notes, and snippets.

View zyqxd's full-sized avatar
⛩️

David Zhang zyqxd

⛩️
  • Square
  • Toronto / Remote
  • X @zyqxd
View GitHub Profile
@zyqxd
zyqxd / coupons.sql
Last active July 10, 2024 23:45
Coupons SQL
<!-- Delete coupons from staging test merchant -->
select coupons.id, coupons.code, request_token
from coupons
left join coupon_codes on coupon_codes.code = coupons.code
left join discounts on discounts.id = coupons.discounts_id
where reason = 5 and coupon_codes.merchant_token = 'ML0T5T2PZE4EK';
sq mysql run coupons staging --metacluster coupons-staging-aurora-005 --db coupons_0_staging --cname rw
delete d
@zyqxd
zyqxd / bash
Created June 4, 2024 17:14
Bash scripts
# Kill background process (using ctrl + z)
ps -eaf | grep <CMD>
@zyqxd
zyqxd / farm.rb
Last active June 21, 2024 14:47
FARM code snippets
###
# Print id, deliveries, created_at in table
#
ActiveRecord::Base.logger.silence do
Promotion.where(theme_campaign: ThemeCampaign.recurring_lapsed_style).each do |p|
delivery_campaign = p.delivery_campaigns.first
processed = delivery_campaign.sms_deliveries.processed
link_window_start = processed.order(created_at: :asc).first&.created_at
link_window_end = processed.order(delivered_at: :desc).first&.delivered_at
@zyqxd
zyqxd / advent_of_code_2021.rb
Created December 13, 2021 18:18
Advent Of Code 2021 Day 11, 12, 13
# frozen_string_literal: true
# https://adventofcode.com/2021
module AdvantOfCode2021
URL = 'https://adventofcode.com/2021/day/%d/input'
COOKIE = 'Nope'
def parse_reading(day)
day_url = URL % day
HTTParty.get(day_url, headers: { 'Cookie' => COOKIE }).body.split("\n")
@zyqxd
zyqxd / advent_of_code_2021.rb
Last active December 10, 2021 17:08
Advent Of Code Day 1-10, no edits
# https://adventofcode.com/2021
module AdventOfCode2021
URL = 'https://adventofcode.com/2021/day/%d/input'
COOKIE = 'NOPE'
def parse_reading(day)
day_url = URL % day
HTTParty.get(day_url, headers: { 'Cookie' => COOKIE }).body.split("\n")
end