Skip to content

Instantly share code, notes, and snippets.

View alg's full-sized avatar

Aleksey Gureiev alg

View GitHub Profile
@alg
alg / hr.json
Last active December 6, 2022 13:10
{
"openapi": "3.0.0",
"info": {
"title": "HR API",
"version": "3.0.0",
"description": "Manages employees, their roles and profiles.",
"contact": {
"name": "Aleksey Gureiev",
"email": "agureiev@shakuro.com"
}
void pwm_task(void *pvParameter) { DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_LEDC_CLK_EN); DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_LEDC_RST);
// 0 - 8MHz, 1 - 80 MHz
WRITE_PERI_REG(LEDC_CONF_REG, 1 << LEDC_APB_CLK_SEL_S);
// High speed
WRITE_PERI_REG(LEDC_HSTIMER0_CONF_REG, LEDC_TICK_SEL_HSTIMER0 | (0b000000001001010100 << LEDC_DIV_NUM_HSTIMER0_S) | (4 << LEDC_HSTIMER0_LIM_S));
// Low speed
WRITE_PERI_REG(LEDC_LSTIMER1_CONF_REG, (1 << LEDC_TICK_SEL_LSTIMER1_S) | (0b000000001001010100 << LEDC_DIV_NUM_LSTIMER1_S) | (4 << LEDC_LSTIMER1_LIM_S));
@alg
alg / metrics_test.exs
Last active July 30, 2018 09:07
ETS metrics
defmodule Metrics do
use GenServer
@type metric_pid :: pid()
@type server :: term()
@type time_tag :: :daily | :hourly | :minutely
@type metric :: {term(), term()}
@alg
alg / dets_test.exs
Created July 29, 2018 10:22
DETS example
defmodule Server do
use Bitwise
require Record
Record.defrecord :server, id: nil, ip: nil, username: nil, password: nil
def from_id(id) do
ip = "127.#{band(id >>> 16, 0xff)}.#{band(id >>> 8, 0xff)}.#{band(id, 0xff)}"
server(id: id, ip: ip, username: "username_#{band(id, 0xff)}", password: "password")
end

Keybase proof

I hereby claim:

  • I am alg on github.
  • I am spyromus (https://keybase.io/spyromus) on keybase.
  • I have a public key ASBCTumXp4eRSMQ3_aFMeBrhxMcsghCEX53_vdxLO5wUFgo

To claim this, I am signing this object:

@alg
alg / mycollectionview.swift
Created August 23, 2017 07:39
Invalidating item sizes with collection view resizing
class MyCollectionView: NSCollectionView {
override var frame: NSRect {
didSet {
collectionViewLayout?.invalidateLayout()
}
}
}
@alg
alg / Main.elm
Created December 2, 2016 10:45
decodeModel : Json.Decode.Value -> Result String Model
decodeModel modelJson =
Json.Decode.decodeValue modelDecoder modelJson
modelDecoder : Json.Decode.Decoder Model
modelDecoder =
Json.Decode.map4 Model
(field "todos" (Json.Decode.list todoDecoder))
(field "todo" todoDecoder)
(field "filter" filterStateDecoder)
<!-- Created experiment -->
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://api.testbed.deterlab.net/xsd" xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Body>
<tns:createExperiment>
<tns:eid>Beta-Test:Test-Exp</tns:eid>
<tns:owner>spyromus</tns:owner>
<tns:accessLists>
<tns:circleId>Beta-Test:Beta-Test</tns:circleId>
- request:
method: post
uri: https://spidev.isi.deterlab.net:52323/axis2/services/Experiments.ExperimentsHttpsSoap11Endpoint/
body:
encoding: UTF-8
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://api.testbed.deterlab.net/xsd"
xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Body><tns:addExperimentAspects><tns:eid>Alfa-Romeo:ExperimentOne</tns:eid><tns:aspects><tns:type>layout</tns:type><tns:data>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiID8+CjxleHBlcmltZW50PgogPHZlcnNpb24+MS4wPC92ZXJzaW9uPgogPHN1YnN0cmF0ZXM+CiAgPG5hbWU+bGluazI8L25hbWU+CiAgPGNhcGFjaXR5PgogICA8cmF0ZT4xMDAwMDAuMDAwMDAwPC9yYXRlPgogICA8a2luZD5tYXg8L2tpbmQ+CiAgPC9jYXBhY2l0eT4KIDwvc3Vic3RyYXRlcz4KIDxzdWJzdHJhdGVzPgogIDxuYW1lPmxpbmswPC9uYW1lPgogIDxjYXBhY2l0eT4KICAgPHJhdGU+MTAwMDAwLjAwMDAwMDwvcmF0ZT4KICAgPGtpbmQ+bWF4PC9raW5kPgogIDwvY2FwYWNpdHk+CiA8L3N1YnN0cmF0ZXM+CiA8c3Vi
@alg
alg / a.rb
Last active August 29, 2015 14:10
module M
def m
puts "module"
end
end
class A
def m
puts "class"
end