Skip to content

Instantly share code, notes, and snippets.

View sidorares's full-sized avatar

Andrey Sidorov sidorares

View GitHub Profile
{
"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": {
// 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
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;
const mysql = require('mysql2');
const server = mysql.createServer();
server.listen(3307);
let connectionId = 0;
server.on('connection', conn => {
connectionId++;
console.log(`New connection ${connectionId}`);
let acceptSalt = null;
import React, {Component} from 'react';
import ReactHardware from 'react-hardware';
import {createStore} from 'redux';
import Leap from 'leapjs';
import {Provider, connect} from 'react-redux';
class LeapServo extends Component {
componentDidMount() {
const controller = new Leap.Controller();
controller.on('frame', frame => {
const http = require('http');
const parse = require('url').parse;
const spawn = require('child_process').spawn;
const script = `
(function() {
document.addEventListener('mousedown', function(e) {
var dom = e.target;
for (var key in dom) {
if (key.startsWith("__reactInternalInstance$")) {
function crc16 (buf) {
var crc = 0xffff;
var i;
var c;
var len = buf.length;
var start = 0;
while (len--) {
c = buf[start];
for (i = 0; i < 8; i++) {
var SerialPort = require('serialport');
// /dev/tty.usbserial-FTZ2C9FV
var port = new SerialPort(process.argv[2], {
baudRate: 1200
}, function (err) {
if (err) {
return console.log('Error: ', err.message);
}
port.on('data', function (data) {
console.log('Data: ' + data.toString('hex') );
function bytes() {
var buffer = new ArrayBuffer(arguments.length);
var view = new Uint8Array(buffer);
for (var i = 0; i < arguments.length; i++) {
var val = arguments[i];
if ((typeof val) == "string") val = val.charCodeAt(0);
view[i] = val | 0;
}
return buffer;
}