Skip to content

Instantly share code, notes, and snippets.

// messagepack-0.3.9 exsample for C
// http://msgpack.sourceforge.jp/
// http://msgpack.sourceforge.jp/c:doc.ja (C API)
/*
$ make
gcc msgpack.c -o msgpack -lmsgpackc
$ ldd ./msgpack
linux-gate.so.1 => (0xffffe000)
libmsgpackc.so.1 => /usr/local/lib/libmsgpackc.so.1 (0xb7f0d000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7dd9000)
#!/bin/sh
# ~$ clang-format-4.0 --version 21:58:56
# clang-format version 4.0.0-svn291336-1~exp1 (trunk)
#http://algo13.net/clang/clang-format-style-oputions.html
# excludet directory is Drivers, .git, dot-directory
# Target suffix is *.c, *.h
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int unused_val; /* 使ってない */
int ary[] = {0, 1, 2, 3};
int *p;
p = malloc(sizeof(int) * 16); /* 代入してるが使ってない */
@osaboh
osaboh / demo_cppcheck.c
Last active February 24, 2018 11:52
demo_cppcheck
/* bug.c */
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int unused_val; /* 宣言してるが使ってない */
int ary[] = {0, 1, 2, 3};
int *p;
/* original */
setL3GD20(); // 何を set するのか ? 他の初期化関数名では init を使用している。
int getGyroZ( void )
{
int ret;
// *0.070 because you read l3gd20 manual // 重要そうな値なので名前つけて欲しい。マニュアル見るのめんどくさい。
ret = ( readShiftByte(OUT_Z_H) | readByte(OUT_Z_L) ) * 0.070; // 左記の記述だとリード関数が複数必要な理由を読み手が考えてしまう。
// どうしても関数を分けたいなら readByte() のラッパー関数を作る。
@osaboh
osaboh / nemuisan_linux.sh
Last active April 25, 2018 12:55
'Nemuisan itsumono' build configurater for Linux.
#!/bin/sh
# 'Nemuisan itsumono' build configurater for Linux.
# http://nemuisan.blog.bai.ne.jp/
# Validated for archive Ver 20180301
#
# created by osaboh
#
# usage:
# $ 7z x STM32F4xxxx_FatFs_DISP_20180301.7z
@osaboh
osaboh / typesafe_enum.c
Created September 18, 2018 14:47
typesafe enum in c
// https://stackoverflow.com/questions/14822342/typesafe-enums-in-c
#include <stdio.h>
/* type safe enum 1 */
typedef enum { one, two, } num_t;
typedef struct { num_t num; } ts_num_t;
#define ONE ((ts_num_t){ one })
#define TWO ((ts_num_t){ two })
#if 0
@osaboh
osaboh / xtimecomposer.diff
Last active November 28, 2018 18:03
fix tofu Eclipse for xtimecomposer http://www.xcore.com/viewtopic.php?t=4582
XMOS/xTIMEcomposer/Community_14.3.3/bin$ diff -u xtimecomposer.org xtimecomposer
--- xtimecomposer.org 2018-11-29 02:30:44.964052684 +0900
+++ xtimecomposer 2018-11-29 02:30:57.992111646 +0900
@@ -158,7 +158,7 @@
# have a go with the supplied webkit browser...
$vmargs .= "-vmargs";
$vmargs .= " -Dorg.eclipse.swt.browser.UseWebKitGTK=True";
- $ENV{LD_LIBRARY_PATH} = "$installpath/xtimecomposer_bin/swtbrowserlibs:$ENV{LD_LIBRARY_PATH}";
+# $ENV{LD_LIBRARY_PATH} = "$installpath/xtimecomposer_bin/swtbrowserlibs:$ENV{LD_LIBRARY_PATH}";
}
# Pythonのデコレータを理解するための12Step
# https://qiita.com/_rdtr/items/d3bc1a8d4b7eb375c368#2-11
# クロージャ
def outer(x):
def inner():
print(x)
return inner
@osaboh
osaboh / read_bno055.json
Created May 30, 2020 14:32
Node-RED read sensor data from serial port.
[
{
"id": "adcc31eb.53895",
"type": "tab",
"label": "フロー 1",
"disabled": false,
"info": ""
},
{
"id": "1a1addc9.464b02",