Skip to content

Instantly share code, notes, and snippets.

View absyah's full-sized avatar

Ardian Bahtiarsyah absyah

  • Semarang, Indonesia
View GitHub Profile
@absyah
absyah / A helpful ActiveRecord setting only 1 person has ever used
Created August 2, 2019 03:23
Nate Berkopec's Ruby Performance Newsletters
A memory-saving ActiveRecord setting has been used by just one application ever, according to GitHub
There's a common performance problem in many Rails background jobs.
Background jobs often do operations across large sets of data. Basically, they do silly things like User.all.each(&:send_daily_newsletter).
So, there's a problem with that query. In development and test environments, User.all will probably return a few rows, maybe a dozen at most. Most developers have extremely limited seed data on their local machines.
In production, however, User.all will probably return quite a few rows. Depending on the app you work on, maybe a few hundred thousand.
There's a tiiiiiny issue with a result set that returns 100,000 rows, and it's not just that the SQL query will take a long time to return. It will have irreversible effects on your Ruby app too!
@absyah
absyah / daily-payload.json
Last active February 7, 2024 13:48
Shift Generator Payloads
{
"required_members": 9,
"classes": [
{
"id": 1,
"name": "A",
"required_members": {
"morning": 2,
"naptime": 2,
"other": 2
@absyah
absyah / gist:b17cf5cb87db36195f3478eab5eb7de0
Created October 17, 2023 15:34
[DELETE ME] HLS debug
[log] >
instrument.js:109 [log] > stopLoad
instrument.js:109 [log] > loadSource:https://stream.mux.com/m2x0101omwAeb02XfOkLbpVD4rXgwv5wwrrzEfXLd5ZDlA.m3u8?max_resolution=1080p
instrument.js:109 [log] > [stream-controller]: Trigger BUFFER_RESET
instrument.js:109 [log] > attachMedia
instrument.js:109 [log] > [buffer-controller]: Media source opened
instrument.js:109 [log] > [subtitle-stream-controller]: STOPPED->IDLE
instrument.js:109 [Fast Refresh] rebuilding
instrument.js:109 [Fast Refresh] done in 228ms
instrument.js:109 [log] > [level-controller]: manifest loaded, 5 level(s) found, first bitrate: 2564100
{
"textPayload": "checkViews [{\"id\":\"0YCzsPvYG0gdOEe8xfGn\",\"ref\":{\"_firestore\":{\"projectId\":\"vidbase-ee21b\"},\"_path\":{\"segments\":[\"workspaces\",\"MWsnEB09rbWJ97fUUM7M\",\"embeds\",\"alrzekAMId1VXOL6rpRP\",\"views\",\"0YCzsPvYG0gdOEe8xfGn\"],\"projectId\":\"vidbase-ee21b\",\"databaseId\":\"(default)\"},\"_converter\":{}},\"uid\":\"d8UZhrc570Q7FDjUMeaw4m22ZJj2\",\"referrer\":\"https://lp.sakura.ad.jp/\",\"marketoLeadId\":\"37963412\",\"isMarketoLeadSyncToSalesforce\":false,\"contentId\":\"8FmJMCDR63oiZZLg6cXZ\",\"type\":\"embed\",\"embedId\":\"alrzekAMId1VXOL6rpRP\",\"munchkinAccountId\":\"941-NEO-212\",\"workspaceId\":\"MWsnEB09rbWJ97fUUM7M\",\"createdAt\":{\"_seconds\":1683694898,\"_nanoseconds\":385000000},\"viewSeconds\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27],\"totalViewTime\":36,\"updatedAt\":{\"_seconds\":1683704013,\"_nanoseconds\":121000000},\"actionButtonShowCounts\":0,\"actionClickCounts\":0,\"formShowCounts\":0,\"formSubmittedCounts\":0},{\"id\
@absyah
absyah / summary.md
Created August 4, 2023 02:16 — forked from angelialau/summary.md
(Summary) The Art of Readable Code

A summary of The Art of Readable Code by Dustin Boswell and Trevor Foucher

  • Overall metric for readability: code should be written to minimise the time it would take someone else to fully understand it (able to modify the code and spot bugs) Ways to improve readability (ranked from easiest change to most time intensive)
  1. Naming of variables and functions:
    • Use specific, descriptive, succinct names that say the entity's value or purpose
    • Use concrete names instead of abstract names e.g. canListenOnPort > serverCanStart
    • Add important attributes e.g. units or state e.g. unsafeUrl, safeUrl > url
    • Can use shorter variable names for smaller scope
@absyah
absyah / base.rb
Created December 28, 2018 05:46 — forked from sunny/base.rb
Rails utility class for objets to act like ActiveRecord::Base
# encoding: utf-8
# Base class to inherit from for objects to act like ActiveRecord::Base
# without using a database. Lets you use validations, errors, forms, routes.
#
# Example:
# class Exporter < Base
# attributes_accessor :email, :data
# end
class Base
extend ActiveModel::Naming
require: rubocop-rails
Style/StringLiterals:
Enabled: false
AllCops:
NewCops: enable
TargetRubyVersion: 3.0
Exclude:
- 'db/**/*'
@absyah
absyah / gist:2bbb7e253e72d211c4f736dd72eb2202
Created May 2, 2023 14:46
RVM install with openssl dir
rvm install x.x.x --with-openssl-dir=$HOME/.rvm/usr
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import ElementClickInterceptedException, NoSuchElementException
from time import sleep
from selenium.common.exceptions import NoSuchElementException
EMAIL = "email@quipper.com"
PASSWORD = "password"
@absyah
absyah / gist:fee9e61302910e0be952f92e5894515f
Created June 17, 2021 03:21
COMMON_LOCAL_TOPIC_ATTEMPT
localUsages
localTopicAttemptsIds
0"60ca11f4997eac001e3defed"
1"60ca12cdfcae46001cc75654"
2"60ca134a997eac001e3deffa"
3"60ca1375997eac001e3df004"
4"60ca13d9997eac001e3df00a"
5"60ca166afcae460019c755d5"
topicAttemptsByIds
60ca11f4997eac001e3defed{