Skip to content

Instantly share code, notes, and snippets.

@szczys
szczys / main.c
Created April 19, 2024 19:59
Golioth Bluetooth Gateway Demo
/* main.c - Application main entry point */
/*
* Copyright (c) 2020 SixOctets Systems
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include <stddef.h>
@szczys
szczys / conftest.py
Last active April 2, 2024 16:31
Embedded firmware test using pytest
import pytest
import re
import serial
from time import time
# Used to flash binary to nrf52840dk
from pynrfjprog import LowLevel
@pytest.fixture(scope='session')
def anyio_backend():
@szczys
szczys / spi-interrupt-test.ino
Created May 15, 2020 23:44
ESP32 Interrupt Based SPI Slave (receive only)
// Using ESP32 HSPI (SPI2)
// CS is SS -->
// WR is SCK -->
// DATA is MOSI -->
#define SO 12
#define SI 13
#define SCLK 14
#define SS 15
void setup() {
BeanHid.enable();
// Serial port is initialized automatically; we don't have to do anything
}
void loop() {
AccelerationReading accel = Bean.getAcceleration();
int16_t x = accel.xAxis;
int16_t y = accel.yAxis;
int16_t z = accel.zAxis;
// Add a deadzone. If Bean is reasonabally flat, don't move the mouse pointer
APPLICATION="${0##*/}"
USAGE="$APPLICATION [options]
Wraps enter-chroot to start a Mint session.
By default, it will log into the primary user on the first chroot found.
Options are directly passed to enter-chroot; run enter-chroot to list them."
exec sh -e "`dirname "$0"`/enter-chroot" "$@" startx /bin/bash cinnamon-session-cinnamon
@szczys
szczys / gist:347f9d1804661d96fdd5
Created September 29, 2014 00:30
c710 trusty cannot start cinnamon Xorg.1.log
(cinnamon)mike@localhost:~$ cat /var/log/Xorg.1.log
[ 3456.659]
X.Org X Server 1.15.1
Release Date: 2014-04-13
[ 3456.659] X Protocol Version 11, Revision 0
[ 3456.660] Build Operating System: Linux 3.2.0-61-generic x86_64 Ubuntu
[ 3456.660] Current Operating System: Linux localhost 3.4.0 #1 SMP Thu Aug 7 12:45:28 PDT 2014 x86_64
[ 3456.660] Kernel command line: cros_secure console= loglevel=7 init=/sbin/init cros_secure oops=panic panic=-1 root=/dev/dm-1 rootwait ro dm_verity.error_behavior=3 dm_verity.max_bios=-1 dm_verity.dev_wait=1 dm="2 vboot none ro 1,0 2545920 bootcache PARTUUID=65d66091-d5a9-1e4b-8371-d0f34c140f4d/PARTNROFF=1 2545920 2d5664ebe1cccbf3fba4354ef0527586a7e4b18d 512 20000 100000, vroot none ro 1,0 2506752 verity payload=254:0 hashtree=254:0 hashstart=2506752 alg=sha1 root_hexdigest=dce2a9eb47021759c5b0cd4d2d19fbb3a9a01e20 salt=13bc2b92aca86cc26dd125d4a897540d8b4e4fffa7d2f86beb5ab30e336467e9" noinitrd vt.global_cursor_default=0 kern_guid=65d66091-d5a9-1e4b-8371-d0f34c140f4d add_efi_m
namesFile = '/home/mike/Desktop/hgttg.txt'
easyPass = 'ilovehackaday'
hardCount = 10
import random
import string
complexityLimit = 3
with open(namesFile, 'r') as f:
@szczys
szczys / stm32f05x-flash-control.diff
Created June 10, 2012 21:08
STM32F05x defines for controlling flash memory
diff --git src/stlink-common.c src/stlink-common.c
index 08bd0bb..1e3c480 100644
--- src/stlink-common.c
+++ src/stlink-common.c
@@ -48,6 +48,38 @@
#define FLASH_CR_STRT 6
#define FLASH_CR_LOCK 7
+/**************************
+ Begin stm32f05x flash controller defines
@szczys
szczys / led-balance.c
Created December 16, 2011 20:34
Balancing LED brightness for Binary Burst Clock
#include <avr/io.h>
#include <avr/interrupt.h>
#define F_CPU 1000000
void init_IO(void) {
DDRD |= (1<<PD0) | (1<<PD1) | (1<<PD2);
PORTD |= (1<<PD0) | (1<<PD1) | (1<<PD2);
}
@szczys
szczys / vcard-split.py
Created December 14, 2011 20:22
Python script for splitting a VCARD file to a user-set number of VCARDs per output file
#split vcf files
working_dir = '/home/mike/compile/'
input_file = 'final.vcf'
output_seed = 'contacts-part-'
vcards_per_file = 75
with open(working_dir + input_file,'r') as f:
count = 0
output_count = 1