Skip to content

Instantly share code, notes, and snippets.

@bakoushin
bakoushin / verify.apple.attestation.js
Created February 21, 2022 19:34 — forked from yackermann/verify.apple.attestation.js
Snippet code to verify apple anonymous attestation
const crypto = require('crypto');
const base64url = require('base64url');
const cbor = require('cbor');
const asn1 = require('@lapo/asn1js');
const jsrsasign = require('jsrsasign');
/* Apple Webauthn Root
* Original is here https://www.apple.com/certificateauthority/Apple_WebAuthn_Root_CA.pem
*/
let appleWebAuthnRoot = 'MIICEjCCAZmgAwIBAgIQaB0BbHo84wIlpQGUKEdXcTAKBggqhkjOPQQDAzBLMR8wHQYDVQQDDBZBcHBsZSBXZWJBdXRobiBSb290IENBMRMwEQYDVQQKDApBcHBsZSBJbmMuMRMwEQYDVQQIDApDYWxpZm9ybmlhMB4XDTIwMDMxODE4MjEzMloXDTQ1MDMxNTAwMDAwMFowSzEfMB0GA1UEAwwWQXBwbGUgV2ViQXV0aG4gUm9vdCBDQTETMBEGA1UECgwKQXBwbGUgSW5jLjETMBEGA1UECAwKQ2FsaWZvcm5pYTB2MBAGByqGSM49AgEGBSuBBAAiA2IABCJCQ2pTVhzjl4Wo6IhHtMSAzO2cv+H9DQKev3//fG59G11kxu9eI0/7o6V5uShBpe1u6l6mS19S1FEh6yGljnZAJ+2GNP1mi/YK2kSXIuTHjxA/pcoRf7XkOtO4o1qlcaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUJtdk2cV4wlpn0afeaxLQG2PxxtcwDgYDVR0PAQH/BAQDAgEGMAoGCCqGSM49BAMDA2cAMGQCMFrZ+9DsJ1PW9hfNdBywZDsWDbWFp28it1d/5w2RPkRX3Bbn/UbDTNLx7Jr3jAGGiQIwHFj+dJZYUJR786osByBelJYsVZd2GbHQu209b5
const parseArgs = require('minimist');
const io = require('socket.io')();
const tf = require('@tensorflow/tfjs-node');
const { model: modelDir = 'model', speed: maxSpeed = 30 } = parseArgs(
process.argv.slice(2)
);
tf.loadLayersModel(`file://${modelDir}/model.json`).then((model) => {
io.on('connection', async (socket) => {
async function* dataGenerator() {
while (true) {
const csvStream = fs.createReadStream(pathToCSV).pipe(csv({
headers: ['center', 'left', 'right', 'steering', 'throttle', 'brake', 'speed'],
mapValues: ({ value }) => value.trim()
}));
for await (const { center, left, right, steering } of csvStream) {
const centerImageBuffer = fs.promises.readFile(center);
const leftImageBuffer = fs.promises.readFile(left);
@bakoushin
bakoushin / README-Template.md
Created July 16, 2019 05:02 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@bakoushin
bakoushin / promise-chain.js
Created December 10, 2018 16:55
Start downloading files simultaneously, but display them in order
const files = [fetch('file1'), fetch('file2'), fetch('file3')];
let chain = Promise.resolve();
for (const file of files) {
chain = chain
.then(() => {
return file;
})
.then(file => console.log(file));
@bakoushin
bakoushin / @ SimpleDB.md
Created November 13, 2018 14:30
Simple DB

SimpleDB - Like Indexed DB, but Simple

A simple asynchronous data store.

STATUS: This is a thought experiment, not a serious proposal. Would basic async storage like this be useful? With this plus some locking primitive, could you build Indexed DB?

Like Indexed DB:

  • rich value types - store anything you can structured clone
  • rich key types - Number, String, Date, Array (of other key types)
@bakoushin
bakoushin / 90-monitor-hotplug.rules
Last active May 30, 2023 02:51
Lubuntu 18.04 external HDMI display hotplug
ACTION=="change", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/USER/.Xauthority", RUN+="/bin/bash /home/USER/bin/monitorhotplug.sh"
@bakoushin
bakoushin / index.js
Last active April 11, 2018 08:19
Request
'use strict';
class Request {
constructor() {
this._history = [];
this._promiseChain = Promise.resolve();
}
get(url, resolve, reject) {
this._promiseChain = this._promiseChain
.then(() => __fetch(url))
const streets = [
'Абельмановская улица',
'площадь Абельмановская Застава',
'Абрамцевская просека',
'Абрамцевская улица',
'Абрикосовский переулок',
'Авангардная улица',
'улица Авиаконструктора Микояна',
'улица Авиаконструктора Миля',
'улица Авиаконструктора Сухого',
@bakoushin
bakoushin / task.md
Created April 7, 2018 16:52 — forked from dima117/task.md

Упражнения

  1. Сортировка пузырьком
  2. Сортировка выбором
  3. Сортировка вставками
  4. Развернуть односвязный список
  5. Обход дерева в глубину
  6. Обход дерева в ширину
  7. Найти все простые числа от 1 до N
  8. Бинарный поиск в отсортированном массиве