Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am anvol on github.
  • I am anvol (https://keybase.io/anvol) on keybase.
  • I have a public key ASA1Xf6Q2NpSMkl1TnAfgcnsaWPeNLTN5k5lcQdm974usgo

To claim this, I am signing this object:

#include <linux/input.h>
#include <linux/module.h>
#include <linux/init.h>
#include <asm/irq.h>
#include <asm/io.h>
static struct input_dev *button_dev;
static irqreturn_t button_interrupt(int irq, void *dummy)
@anvol
anvol / kmp_stream.c
Last active July 20, 2018 11:55
Knuth–Morris–Pratt algorithm modified to use with byte streams
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
typedef struct {
int32_t * lps; // longest proper prefix
uint16_t lps_size; // pattern size == lps size
char * pattern;
int32_t step;
find_max(long*, long):
cmp r1, #1
ldr r2, [r0, #0]
ble .L2
mov r3, #1
.L3:
ldr ip, [r0, #4]!
add r3, r3, #1
cmp r2, ip
movlt r2, ip
__zero_reg__ = 1
find_max(long*, long):
push r12
push r13
push r14
push r15
push r16
push r17
mov r12,r20
mov r13,r21
@anvol
anvol / max.c
Last active April 14, 2018 14:26
long find_max(long *arr, long count) {
long ret = arr[0];
for(long i=1; i < count; i++){
if (ret < arr[i]) ret = arr[i];
}
return ret;
}
@anvol
anvol / main.c
Created April 13, 2018 14:10
STM32F103 Overclocking
#include "main.h"
#include "stm32f1xx_hal.h"
#include "i2c.h"
#include "gpio.h"
#include "oled.h"
void SystemClock_Config(void);
void TM_SystemClock_Config(uint32_t PLLMUL);
void TM_UpdateStatus(void);
#!/bin/sh -x
# Script usage example
# sudo sh azure-disk.sh /dev/sdc /datadisk
DEVICE="$1"
MOUNT_DIR="$2"
sfdisk $DEVICE << EOF
start=2048, type=83