Skip to content

Instantly share code, notes, and snippets.

View sidorares's full-sized avatar

Andrey Sidorov sidorares

View GitHub Profile
var Chrome = require('chrome-remote-interface');
var chooseTab = function(tabs) {
return 0;
};
Chrome({ chooseTab: chooseTab }, function(chrome) {
var CSS = chrome.CSS;
CSS.styleSheetAdded(function() {
console.log('added');
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
module.exports['ch.epfl.mobots.AsebaNetwork'] = function(bus) {
this.addListener = this.on = function(signame, callback) {
bus.addMatch('type=\'signal\',member=\'' + signame + '\'', function(err, result) {
if (err) throw new Error(err);
});
var signalFullName = bus.mangle('/', 'ch.epfl.mobots.AsebaNetwork', signame);
bus.signals.on(signalFullName, function(messageBody) {
callback.apply(null, messageBody);
});
};
@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.

// scraped from https://mariadb.com/kb/en/mariadb/documentation/sql-language-structure/mariadb-error-codes/
//
module.exports = [
[
"1000",
"HY000",
"ER_HASHCHK",
"hashchk"
],
[
var x11 = require('x11');
var PNG = require('png-js');
var bl = require('bl');
require('child_process').exec('locate png | grep 48').stdout.pipe(bl(function(err, files) {
var pngNames = files.toString().split('\n');
var pngIndex = 0;
x11.createClient(function(err, display) {
@sidorares
sidorares / launcher-test.desktop
Created September 30, 2014 03:29
Unity integration for node-x11
[Desktop Entry]
Name=Unity Launcher test
GenericName=Oooooooooooooooooooooooooooo
Comment=Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Exec=/home/laplace/ltest/test.js
Icon=system-software-update
Terminal=false
Type=Application
Categories=System;Settings;
> x11@0.10.0 test /tmp/node-x11
> node test-runner.js
Atoms and atom names cache
✓ should be used directly when requesting std atoms with InternAtom
✓ should be used directly when requesting atom names with GetAtomName
✓ should be used after the first request for non-std atoms
✓ should be used after the first request for non-std atom_names
@sidorares
sidorares / README.md
Last active January 31, 2024 20:18
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)

Statistical profiling result from v8-3.22.24.19.log, (91 ticks, 0 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
45 49.5% 0.0% /usr/local/bin/node
10 11.0% 0.0% [vdso]
2 2.2% 0.0% /lib/i386-linux-gnu/libc-2.15.so
[JavaScript]:
ticks total nonlib name