Skip to content

Instantly share code, notes, and snippets.

View sidorares's full-sized avatar

Andrey Sidorov sidorares

View GitHub Profile
// repro for https://github.com/sidorares/node-mysql2/issues/2090
// the code prints "done" bit after cpu spikes to 100% and the process never finishes
class TextRow {
constructor(fields) {}
next(packet, fields, options) {
this.packet = packet;
const result = {};
// "t_id_0": LONGLONG
result["t_id_0"] = packet.parseLengthCodedInt(false);
// "t_id_1": LONGLONG
@sidorares
sidorares / README.md
Last active October 2, 2025 21:59
node.js conventions and best practices

Node.JS best practices and conventions

This is not about JS style

Advice: if you have style guide / policy, apply it automatically ( in the editor or git hook ) https://github.com/jshint/fixmyjs

Collection of (mostly) JS styles (pick one you like or write another one if none fits you)

{
"basics": {
"name": "Thomas Edison",
"label": "Inventor and Businessman",
"picture": "https://example.com/photo.jpg",
"email": "thomas.edison@example.com",
"phone": "(123) 456-7890",
"website": "https://thomasedison.com",
"summary": "Prolific inventor and businessman known for developing many devices that greatly influenced life around the world, including the phonograph, the motion picture camera, and the electric light bulb.",
"location": {
{
"basics": {
"name": "Thomas Edison",
"label": "Inventor and Businessman",
"picture": "https://example.com/photo.jpg",
"email": "thomas.edison@example.com",
"phone": "(123) 456-7890",
"website": "https://thomasedison.com",
"summary": "Prolific inventor and businessman known for developing many devices that greatly influenced life around the world, including the phonograph, the motion picture camera, and the electric light bulb.",
"location": {
@sidorares
sidorares / nodeconf_2011.md
Created May 7, 2011 01:16 — forked from guybrush/nodeconf_2011.md
a list of slides from nodeconf 2011
@sidorares
sidorares / benchmark.md
Last active March 29, 2022 12:30
node-mysql2 benchmarks

Benchmarks of node-mysql vs node-mysql2 drivers

Test1:

for each http request, query first 3 rows of mysql.user table and render results using jade template.

Notes: This tests column definition parser (user table has 43 columns), row parser (3x43 values) and access time to result. Also this is test of how well event loop, GC, http parser and mysql driver work together. To compare mysql overhead with http + jade rendering + data transfer, there is another endpoint that renders exactly the same rows of data from memory without fetching them from mysql server.

@sidorares
sidorares / createpixmap.c
Created May 3, 2012 04:09
create 32 bit pixmap test
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdio.h>
int ApplicationErrorHandler(Display *display, XErrorEvent *theEvent)
{
(void) fprintf(stderr,
"Ignoring Xlib error: error code %d request code %d\n",
theEvent->error_code,
const { performance } = require("perf_hooks");
const minus = "-".charCodeAt(0);
const plus = "+".charCodeAt(0);
const dot = ".".charCodeAt(0);
const exponent = "e".charCodeAt(0);
const exponentCapital = "E".charCodeAt(0);
function bufToFloat(buf, start, len) {
let offset = start;
;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var BigNumber = require('bignumber.js');
/*
json_parse.js
2012-06-20
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
// scraped from https://mariadb.com/kb/en/mariadb/documentation/sql-language-structure/mariadb-error-codes/
//
module.exports = [
[
"1000",
"HY000",
"ER_HASHCHK",
"hashchk"
],
[