Skip to content

Instantly share code, notes, and snippets.

@osaboh
osaboh / gist:040455688046759bf348af289f2d8774
Created July 18, 2022 14:08
Vagrant file of vagrant-qemu
# Basic Vagrant config (API version 2)
Vagrant.configure(2) do |config|
config.vm.synced_folder ".", "/vagrant", type: "smb", smb_host: "10.0.2.2", disabled: false
config.vm.provider "qemu" do |qe, override|
override.ssh.username = "rocky"
override.ssh.password = "rocky"
qe.image_path = "~/Proj/RockyLinux9/qemu.qcow2"
qe.arch = "aarch64"
qe.machine = "virt,accel=hvf,highmem=on"
qe.cpu = "host"
@osaboh
osaboh / cgdb.sh
Created June 24, 2020 11:56
cgdb & ST-LINK GDB Server
#!/bin/sh
# https://github.com/cgdb/cgdb/pulls
# https://cgdb.github.io/docs/cgdb.html
# http://miettal.hatenablog.com/entry/20120408/1333917572
GDB=~/Work/tools/gcc-arm-none-eabi-8-2018-q4-major/bin/arm-none-eabi-gdb
cgdb -d $GDB -x target.gdb
# -- target.gdb --
@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",
# Pythonのデコレータを理解するための12Step
# https://qiita.com/_rdtr/items/d3bc1a8d4b7eb375c368#2-11
# クロージャ
def outer(x):
def inner():
print(x)
return inner
@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}";
}
@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 / 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
/* 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 / 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;
#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); /* 代入してるが使ってない */