Skip to content

Instantly share code, notes, and snippets.

Aleksey Gureiev alg

Block or report user

Report or block alg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View main.c
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 Jul 30, 2018
ETS metrics
View metrics_test.exs
defmodule Metrics do
use GenServer
@type metric_pid :: pid()
@type server :: term()
@type time_tag :: :daily | :hourly | :minutely
@type metric :: {term(), term()}
View dets_test.exs
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
View keybase.md

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:

View Main.elm
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 Aug 23, 2017
Invalidating item sizes with collection view resizing
View mycollectionview.swift
class MyCollectionView: NSCollectionView {
override var frame: NSRect {
didSet {
collectionViewLayout?.invalidateLayout()
}
}
}
View aliases
alias g="git status"
function gg {
git commit -v -a -m "$*"
}
alias gco='git checkout'
alias gbr='git branch'
alias ga='git add'
View front.html.haml
%h2 Users
%table
%tr
%th Name
%th Email
%th Role
- User.all.each do |u|
%tr
%td= u.name
%td= u.email
View spec_helper.rb
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run focus: true
config.run_all_when_everything_filtered = true
@alg
alg / multi-dispatch.rb
Created Sep 30, 2013
Ruby Multi-dispatch
View multi-dispatch.rb
module Kernel
MDEF_DEFINED = {}
def mdef(name, *types, &block)
sig = gen_sig(name, types)
MDEF_DEFINED[name] = (MDEF_DEFINED[name] || []) + [ sig ]
Kernel.send(:define_method, sig, &block)
end
def gen_sig(name, types)
You can’t perform that action at this time.