Skip to content

Instantly share code, notes, and snippets.

View idandagan1's full-sized avatar
🎯
Focusing

Idan Dagan idandagan1

🎯
Focusing
View GitHub Profile
function processTicksAndRejections() {
let tock;
do {
while (tock = queue.shift()) {
...
try {
const callback = tock.callback;
if (tock.args === undefined) {
callback();
function unhandledRejection(promise, reason) {
...
const emit = (reason, promise, promiseInfo) => {
try {
...
return process.emit('unhandledRejection', reason, promise);
} finally {
popAsyncContext(asyncId);
}
function processPromiseRejections() {
...
...
let len = pendingUnhandledRejections.length;
while (len--) {
const promise = ArrayPrototypeShift(pendingUnhandledRejections);
const promiseInfo = maybeUnhandledPromises.get(promise);
if (promiseInfo === undefined) {
continue;
@idandagan1
idandagan1 / load_data.sql
Created April 13, 2022 05:05
Populate MySQL table with random data
DELIMITER $$
CREATE PROCEDURE insert_data()
BEGIN
DECLARE i INT DEFAULT 0;
WHILE i < 13000000 DO
INSERT INTO customer (session, customer_id, product_id) VALUES
(CONCAT(i+1, '-', '4949-a976-3b125797f641'), i, i),
(CONCAT(i+2, '-', '4949-a976-3b125797f641'), i, i),
(CONCAT(i+3, '-', '4949-a976-3b125797f641'), i, i),
(CONCAT(i+4, '-', '4949-a976-3b125797f641'), i, i),
ALTER TABLE customer DROP PRIMARY KEY, ADD PRIMARY KEY(customer_id, session);
CREATE TABLE customer (
session varchar(36),
customer_id int,
product_id int,
primary key (session)
);
SELECT *
FROM customer
WHERE session = '0509853c-a14e-4949-a976–3b125797f642';
String selectByIdAndSession = String.format("select * from customer where customer_id = %s and session = %s", customerId, session);
String selectBySession = String.format("select * from customer where session = %s", session);
if (enableNewQuery) {
return CustomerDao(selectByIdAndSession);
} else {
return CustomerDao(selectBySession);
}
ALTER TABLE customer ADD INDEX (customer_id);