Skip to content

Instantly share code, notes, and snippets.

Avatar

Yuriy Nazarov nazarov-yuriy

View GitHub Profile
View pytorch_pretrained_bert_download.py
from pytorch_pretrained_bert.file_utils import url_to_filename
import requests
url = 'https://s3.amazonaws.com/models.huggingface.co/bert/gpt2-pytorch_model.bin'
response = requests.head(url, allow_redirects=True)
etag = response.headers.get("ETag")
url_to_filename(url, etag)
View port_manip.ino
#include <Arduino.h>
#include "avr/pgmspace.h"
#include "avr/io.h"
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
void setup() {
cbi (TIMSK0, TOIE0);
pinMode(13, OUTPUT);
View noise.ino
#include <Arduino.h>
#define maxWaveform 4
#define maxSamplesNum 120
static int waveformsTable[maxWaveform][maxSamplesNum] = {
// Sin wave
{
0x7ff, 0x86a, 0x8d5, 0x93f, 0x9a9, 0xa11, 0xa78, 0xadd, 0xb40, 0xba1,
View hello.ino
#include <Arduino.h>
#define maxWaveform 4
#define maxSamplesNum 120
static int waveformsTable[maxWaveform][maxSamplesNum] = {
// Sin wave
{
0x7ff, 0x86a, 0x8d5, 0x93f, 0x9a9, 0xa11, 0xa78, 0xadd, 0xb40, 0xba1,
View gist:c2c367d0f53b4f12ca54ddca0282cec0
$ fio --filename=file.dat --direct=1 --rw=read --ioengine=libaio --bs=512k --iodepth=32 --numjobs=1 --name=benchtest --size=64G
benchtest: (g=0): rw=read, bs=512K-512K/512K-512K/512K-512K, ioengine=libaio, iodepth=32
fio-2.2.10
Starting 1 process
Jobs: 1 (f=1): [R(1)] [100.0% done] [3026MB/0KB/0KB /s] [6051/0/0 iops] [eta 00m:00s]
benchtest: (groupid=0, jobs=1): err= 0: pid=21042: Sun Jul 2 19:01:18 2017
read : io=65536MB, bw=3043.3MB/s, iops=6086, runt= 21535msec
slat (usec): min=45, max=2387, avg=63.45, stdev=10.47
clat (usec): min=3142, max=9691, avg=5192.45, stdev=269.67
lat (usec): min=3250, max=9755, avg=5255.98, stdev=269.30
View sr.fio
$ fio ~/sr.fio
sequential-read: (g=0): rw=read, bs=512K-512K/512K-512K/512K-512K, ioengine=libaio, iodepth=32
...
fio-2.2.10
Starting 20 processes
Jobs: 20 (f=20), CR=3840/0 IOPS: [R(20)] [100.0% done] [1921MB/0KB/0KB /s] [3841/0/0 iops] [eta 00m:00s]
sequential-read: (groupid=0, jobs=1): err= 0: pid=20500: Sun Jul 2 18:43:23 2017
read : io=16384MB, bw=98306KB/s, iops=192, runt=170664msec
slat (usec): min=56, max=2596, avg=142.09, stdev=42.15
clat (usec): min=371, max=45930, avg=999.17, stdev=1253.47
@nazarov-yuriy
nazarov-yuriy / recv.ino
Created Jun 19, 2016
Wireless termometer.
View recv.ino
#include <Arduino.h>
#include "nRF24L01.h"
#include "RF24.h"
int msg[2];
RF24 radio(9, 10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
void setup(void) {
Serial.begin(9600);
View calc.c
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
enum states {
in_sum, in_mult
};
enum errors {
no_error, unexpected_character, unbalanced_parentheses
};
View OddPair.groovy
// https://habrahabr.ru/post/280192/
class OddPair {
static int[] getPair(List<Integer> data) {
int[][] x = [new int[32], new int[32]]
data.each { (0..31).each { i -> x[it>>i & 1][i] ^= it; } }
return [(0..31).findAll { x[0][it] != 0 && x[1][it] != 0 }, 0].flatten().collect({ [x[0][it], x[1][it]] })[0];
}
public static void main(String[] args) {
println getPair([0, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6 ])
View bdo.cpp
#define WINVER 0x0500
#include <windows.h>
#include <stdio.h>
typedef COLORREF (CALLBACK *ABCPTR)(HDC,int,int);
int main()
{
ABCPTR pGetPixel;
You can’t perform that action at this time.