Skip to content

Instantly share code, notes, and snippets.

import bleio
import board
import digitalio
import time
import binascii
import microcontroller
# User service UUID: Change this to your generated service UUID
USER_SERVICE_UUID = "91E4E176-D0B9-464D-9FE4-52EE3E9F1552"
# User service characteristics
#include <bluefruit.h>
#include <Wire.h>
/**
* BLE Plantation Kit (Capacitive soil moisture sensor and water pump)
* Sensor: https://www.dfrobot.com/wiki/index.php/Capacitive_Soil_Moisture_Sensor_SKU:SEN0193
* Water pump: http://blog.digit-parts.com/archives/52070424.html
*/
// Device Name: Maximum 30 bytes
@techno
techno / 00_syspro_indentation.txt
Last active August 29, 2015 14:24
システムプログラム (syspro) のインデンテーションスタイル
# http://www.coins.tsukuba.ac.jp/~syspro/2015/shui/1stHalf.html#sec:indentation
# 以下のコマンドで、大体上記のスタイルに適合するように、自動でスタイルを修正してくれる
# 綺麗で美しいコードを書こう。
$ indent -nbad -bap -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 -d0 -di1 -nfc1 -i8 -ip0 -l80 -lp -npcs -npsl -sob -nut test.c
@techno
techno / test.c.004t.gimple
Last active August 29, 2015 14:23
GIMPLE, RTL
function (int * array, int n)
{
long unsigned int D.1839;
long unsigned int D.1840;
int * D.1841;
int D.1842;
int i;
i = 0;
goto <D.1836>;
00000000 <function>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 ec 10 sub $0x10,%esp
6: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
d: eb 1c jmp 2b <function+0x2b>
f: 8b 45 fc mov -0x4(%ebp),%eax
12: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
19: 8b 45 08 mov 0x8(%ebp),%eax
1c: 01 c2 add %eax,%edx
@techno
techno / seccamp2015_q5.txt
Created June 27, 2015 06:57
seccamp2015_q5.txt
以下のようなC言語の関数functionがあるとします。
void function(int *array, int n) {
int i;
for(i = 0; i < n; i++) {
array[i] = i * n;
}
}
上記プログラムをコンパイルした結果の一例 (i386)は以下となりました。
@techno
techno / overflow.c
Created February 9, 2015 09:26
test overflow
#include <stdio.h>
int main(void)
{
volatile char test, i;
__asm__ volatile("mov $82, %0 \n"
"mov $0, %1 \n"
"addb $127, %0 \n"
"jno hogehoge \n"
@techno
techno / cs43l22.py
Created September 15, 2014 07:30
Micro Python cs43l22 driver
import pyb
from pyb import I2C
from pyb import Pin
DEVICE_ADDR = 0x4a
BEEPTONE_ADDR = 0x1e
class CS43L22:
def __init__(self):
self.reset = Pin(Pin.board.PD4, Pin.OUT_PP)
@techno
techno / avx2_strlen.c
Last active August 29, 2015 14:03
AVX2 strlen()
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <immintrin.h>
#define LENGTH 1000000010
/*
coins syspro strlen()