Skip to content

Instantly share code, notes, and snippets.

View 2garryn's full-sized avatar

Artem Golovinsky 2garryn

  • Russia, Saint-Petersburg
View GitHub Profile
var f1 = function() { return 1}
undefined
var arr = [f1];
undefined
arr;
[f1()]
arr.filter(function(r) { r != f1 });
[]
arr;
[f1()]
void btn_loop(void) {
uint16_t port0 = GPIO_ReadInputData(BTN_PORT_0);
uint16_t port1 = GPIO_ReadInputData(BTN_PORT_1);
if(port0 & (BTN_PORT_0_PINS)) {
if(port0 & BTN_PORT_0_PIN_0) btn_callback_clicked_0_0()
else if(port0 & BTN_PORT_0_PIN_1) btn_callback_clicked_0_1()
else if(port0 & BTN_PORT_0_PIN_2) btn_callback_clicked_0_2()
else if(port0 & BTN_PORT_0_PIN_3) btn_callback_clicked_0_3();
} else if(port1 & (BTN_PORT_1_PINS)) {
if(port1 & BTN_PORT_1_PIN_0) btn_callback_clicked_1_0()
void btn_init_port_pins(GPIO_TypeDef* GPIOx, uint32_t RCClocking, uint32_t pins) {
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCClocking, ENABLE);
GPIO_InitStructure.GPIO_Pin = pins;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOx, &GPIO_InitStructure);
}
DMA_DeInit(DMA1_Stream5);
DMA_INIT.DMA_Channel = DMA_Channel_7;
DMA_INIT.DMA_PeripheralBaseAddr = (uint32_t)&DAC->DHR12L1;//->DHR12R1;// &DAC->DHR12L1; DHR8R1;
DMA_INIT.DMA_Memory0BaseAddr = (uint32_t)&dac_buff;
DMA_INIT.DMA_DIR = DMA_DIR_MemoryToPeripheral;
DMA_INIT.DMA_BufferSize = 512;
DMA_INIT.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_INIT.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_INIT.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_INIT.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
@2garryn
2garryn / .c
Created September 5, 2017 13:21
void lcd_implementation_init() {
GPIO_InitTypeDef ports;
RCC_AHB1PeriphClockCmd(RCC_GPIO, ENABLE);
//Declare pins to configure
ports.GPIO_Pin = CS_PIN | RST_PIN | DC_PIN | DIN_PIN | SCK_PIN | LED_PIN;
ports.GPIO_Speed = GPIO_Speed_100MHz;
ports.GPIO_Mode = GPIO_Mode_OUT;
ports.GPIO_OType = GPIO_OType_PP;
//Init Port
GPIO_Init(GPIO_PORT, &ports);
@2garryn
2garryn / *.c
Created September 5, 2017 13:47
#include "lcd_5110_imp.h"
static void init_display();
static void write_to_display(uint8_t data, uint8_t mode);
static void clear_lcd();
static void lcd_cs(uint8_t state);
static void lcd_rst(uint8_t state);
static void lcd_dc(uint8_t state);
static void lcd_din(uint8_t state);
static void lcd_sck(uint8_t state);
package main
import (
"fmt"
"flag"
"os"
"bufio"
"strings"
"golang.org/x/text/encoding/charmap"
"strconv"
func message_new() (hnd eventHandler, name string, stmt string) {
type newMessage struct {
Date json.Number `json:"date"`
UserId json.Number `json:"user_id"`
}
table := config.GetDbConfig().Database + ".event_message_new"
name = "message_new"
stmt = "insert into " + table + "(groupid,timestamp,sender,unique_key,amount) VALUES($1,$2,$3,$4,1) on conflict(unique_key) DO UPDATE SET amount=event_message_new.amount + 1;"
hnd = func (groupid string, object json.RawMessage, inserter database.EventInserter) error {
var nm newMessage
package erabbit
import (
"sync"
"vkanalyze/libs/config"
"vkanalyze/libs/log"
"vkanalyze/libs/vkerr"
"github.com/streadway/amqp"
)
package erabbit
import (
"sync"
"vkanalyze/libs/config"
"vkanalyze/libs/log"
"vkanalyze/libs/vkerr"
"github.com/streadway/amqp"
)