Skip to content

Instantly share code, notes, and snippets.

View evgeniyp's full-sized avatar
☯️

Evgeniy Petukhov evgeniyp

☯️
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
public enum Suit { Spades = '♠', Clubs = '♣', Diamonds = '♦', Hearts = '♥' }
public enum Rank { Two = '2', Three = '3', Four = '4', Five = '5', Six = '6', Seven = '7', Eight = '8', Nine = '9', Ten = 'T', Jack = 'J', Queen = 'Q', King = 'K', Ace = 'A' }
public class Card {
public static Card Parse(string rankSuit) {
if (rankSuit.Length != 2) {
@evgeniyp
evgeniyp / keymap,c
Created August 18, 2018 08:46
Preonic layout rev. 8
[_QWERTY] = LAYOUT_preonic_grid( \
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL, \
KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT, \
KC_LCTL, KC_LGUI, KC_LALT, KC_BSLASH, LOWER, KC_SPC, KC_SPC, RAISE, KC_SLSH, KC_LEFT, KC_DOWN, KC_RIGHT \
),
[_LOWER] = LAYOUT_preonic_grid( \
_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, \
@evgeniyp
evgeniyp / limitedPromises.ts
Created March 24, 2018 10:01
Limiting promises
import * as promiseLimit from "promise-limit";
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function log(value: any) {
// tslint:disable-next-line:no-console
console.log(`>> ${value}`);
}
@evgeniyp
evgeniyp / promises.js
Created January 21, 2018 21:29
JS callback functions and promises chaining
"use strict";
var typicalCallbackFunction = function(argument, callback) {
argument = '<' + argument + '>';
callback(null, argument);
}
var promisifiedTypicalCallbackFunction = (argument) => new Promise((resolve, reject) => {
typicalCallbackFunction(argument, (err, result) => err ? reject(err) : resolve(result));
});
@evgeniyp
evgeniyp / gist:e2e6842e7c84881d7611869482c0c930
Created August 11, 2017 11:58
PokerStars hand history example
PokerStars Hand #174088855475: Hold'em No Limit (50/100) - 2017/08/08 23:16:30 MSK [2017/08/08 16:16:30 ET]
Table 'Euphemia II' 6-max (Play Money) Seat #3 is the button
Seat 1: adevlupec (53368 in chips)
Seat 2: Dette32 (10845 in chips)
Seat 3: Drug08 (9686 in chips)
Seat 4: FluffyStutt (11326 in chips)
FluffyStutt: posts small blind 50
adevlupec: posts big blind 100
*** HOLE CARDS ***
Dealt to FluffyStutt [2h Ks]
let handleEx ex =
printfn "Exception: %s" (ex.ToString())
false
let DelDir dir =
try
Directory.Delete(dir, true)
true
with ex -> handleEx ex
float KP = 300, KI = 15, KD = 600;
float pTerm = 0, iTerm = 0, dTerm = 0;
float last_pitch = 0;
void loop()
{
float pitch = get_pitch(); // угол отклонения от вертикальной оси
pTerm = KP * pitch;
iTerm = KI * pitch + iTerm;
> Arduino: scenario_track request: 1
> SoundHandler: player: stop
> SoundHandler: player: playfile scenario 001
>>> Player::play: /usr/bin/aplay /home/pi/woodbot/sounds/card.reader/scenario/001.wav
> Sending: controls: mouth=1; hgurdy=0
/home/pi/woodbot/sounds/card.reader/scenario/001.wav: No such file or directory
>>> Player::run(): playback finished...
> Play back finished
@evgeniyp
evgeniyp / script.py
Last active December 15, 2015 18:01
import http.client
import time
import json
import ctypes
import os
from tkinter import *
import urllib.parse
import hashlib
import re
import socket
namespace WpfSonarAnalyzer
{
/// <summary>
/// https://en.wikipedia.org/wiki/Low-pass_filter
/// </summary>
public class Lowpass
{
private double x, xPrev,
y, yPrev;