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 / 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)
@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 / aliases
Created October 19, 2013 07:39
alias g="git status"
function gg {
git commit -v -a -m "$*"
}
alias gco='git checkout'
alias gbr='git branch'
alias ga='git add'
%h2 Users
%table
%tr
%th Name
%th Email
%th Role
- User.all.each do |u|
%tr
%td= u.name
%td= u.email
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run focus: true
config.run_all_when_everything_filtered = true