Skip to content

Instantly share code, notes, and snippets.

Dmitry Menshikov WoZ

Block or report user

Report or block WoZ

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@WoZ
WoZ / event_emitter_setImmediate_example.js
Created Jul 1, 2019
event_emitter_setImmediate_example.js
View event_emitter_setImmediate_example.js
const {EventEmitter} = require('events');
const ee = new EventEmitter();
function log(...args) {
console.log(Date.now() / 1000, ...args);
}
function blockingOperation() {
log('-- Blocking operation has started');
@WoZ
WoZ / promise_executor_error_handling.js
Last active Jul 1, 2019
promise_executor_error_handling.js
View promise_executor_error_handling.js
setTimeout(() => { process.exit(); }, 200);
function f() {
try {
return new Promise((resolve, reject) => {
throw new Error('Error: Threw right in the executor');
});
} catch (err) {
console.log('Error caught in f()', err);
}
@WoZ
WoZ / test_message_loss_2.js
Created Jun 21, 2019
Advanced example of a data loss
View test_message_loss_2.js
const cluster = require('cluster');
async function waitForMessage(child) {
return new Promise(resolve => {
child.once('message', msg => {
console.log('Master. waitForMessage. Message is received', msg);
return resolve();
});
});
}
@WoZ
WoZ / test_message_loss_1.js
Last active Jun 21, 2019
Simplified example of a data loss
View test_message_loss_1.js
const {EventEmitter} = require('events');
const ee = new EventEmitter();
function waitForMessage() {
return new Promise(resolve => {
ee.once('message', msg => {
console.log('waitForMessage. Message is received', msg);
resolve();
console.log('waitForMessage. Ooops, resolve will run in microtask. not immediately');
View getaddrinfo.c
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
int main(int argc, char *argv[])
{
struct addrinfo hints, *res, *p;
View getaddrinfo.c
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
int main(int argc, char *argv[])
{
struct addrinfo hints, *res, *p;
View addr_and_hostname.c
#include <arpa/inet.h>
#include <net/if.h>
#include <ifaddrs.h>
#include <netdb.h>
#include <stdio.h>
int main(int argc, char* argv[], char* envp[]) {
struct ifaddrs *ifa=NULL,*ifEntry=NULL;
void *addPtr = NULL;
int rc = 0;
View openvz-tg3-patch.diff
diff -upr linux-2.6.32-696.18.7.el6.orig/drivers/net/tg3.c linux-2.6.32-696.18.7.el6-042stab127_2/drivers/net/tg3.c
--- linux-2.6.32-696.18.7.el6.orig/drivers/net/tg3.c 2017-12-29 01:55:16.000000000 +0300
+++ linux-2.6.32-696.18.7.el6-042stab127_2/drivers/net/tg3.c 2018-01-04 15:28:20.074107990 +0300
@@ -234,6 +234,11 @@ static int tg3_debug = -1; /* -1 == use
module_param(tg3_debug, int, 0);
MODULE_PARM_DESC(tg3_debug, "Tigon3 bitmapped debugging message enable value");
+static int tg3_pcie_mrrs_boost = 0;
+module_param(tg3_pcie_mrrs_boost, int, S_IRUGO);
+MODULE_PARM_DESC(tg3_pcie_mrrs_boost, "Increase Tigon3 PCI MRRS "
@WoZ
WoZ / README.md
Last active Jan 5, 2018
Strace reads and writes analyzer
View README.md

Usage: node strace_log_analyzer.js strace.log /tmp

This scripts parses input file that must contain strace log from a single thread. Then script calculates:

  • execution time of read/write syscall for each file descriptor and summarize execution time for each 1 sec period,
  • calulates amount of read/write syscalls for each file descriptor

strace log must be collcted with -t -T -f options.

@WoZ
WoZ / dts_and_realtime.gp
Created Jan 4, 2018
Gnuplot script for ffprobe analysis
View dts_and_realtime.gp
reset
set ylabel "Frames in period"
set xlabel "Time"
set xdata time
set timefmt "%s"
set format x "%H:%M:%S"
set grid
set style line 1 lc rgb '#388e3c' lt 1 lw 1 pt 5 ps 0.5
set style line 2 lc rgb '#6a1b9a' lt 1 lw 1 pt 5 ps 0.5
You can’t perform that action at this time.