Skip to content

Instantly share code, notes, and snippets.

@0xff07
0xff07 / README.md
Last active June 1, 2024 07:35
An Example of Linux Kernel Module using GPIO Subsystem

An Example of Linux Kernel Module using GPIO Subsystem

This is a kernel module, with DT Overlay, to illustrate usage of GPIO subsystem in Linux kernel.

Hardware Envoronment

  1. Raspberry Pi 3 Model B Rev 1.2
  2. Arduino UNO

Software Environment

Mounting VirtualBox shared folders on Ubuntu Server 18.04 LTS (Bionic Beaver)

This guide will walk you through the steps on how to setup a VirtualBox shared folder inside your Ubuntu Server guest.

Prerequisites

This guide assumes that you are using the following setup:

You could still make this guide work with other setups (possibly with some modifications to the commands and whatnot).

@0xff07
0xff07 / brainfucc.c
Created April 25, 2020 16:41 — forked from Ricket/brainfucc.c
Brainfuck to C translator
/*
* A simple, non-optimizing brainfuck to C translator.
* 2010-08-31 - Version 1.0 (Cory Burgett)
*
* This code is hereby placed into the public domain.
*
* Originally located at: http://www4.ncsu.edu/~cmburget/brainfucc.c
*/
#include <stdio.h>
@0xff07
0xff07 / molar_mass.py
Created November 6, 2019 14:20
Simple program to calculate molar mass of molecules with formulae without braces
ELEMENT_TABLE = {'C':12.011, 'O':15.999, 'H':1.008, 'N':14.007, 'Cl':35.45, 'Br':79.904, 'K':39.098, 'S':32.06}
def molar_mass(name, elements=ELEMENT_TABLE):
buf = ''
digit = ''
molar_mass = 0.0
for i in range(len(name)):
c = name[i]
nxt = ''
if not (i == len(name) - 1):
nxt = name[i + 1]
" size of a hard tabstop
set tabstop=4
" always uses spaces instead of tab characters
set expandtab
" size of an "indent"
set shiftwidth=4
" recursively find tags
@0xff07
0xff07 / buildroot-x86-kernel-5.0.10-QEMU-config
Created May 18, 2019 16:47
A x86 buildroot config for QEMU
#
# Automatically generated file; DO NOT EDIT.
# Buildroot 2019.05-git-00959-gd54b0e22ae Configuration
#
BR2_HAVE_DOT_CONFIG=y
BR2_HOST_GCC_AT_LEAST_4_5=y
BR2_HOST_GCC_AT_LEAST_4_6=y
BR2_HOST_GCC_AT_LEAST_4_7=y
BR2_HOST_GCC_AT_LEAST_4_8=y
BR2_HOST_GCC_AT_LEAST_4_9=y
@0xff07
0xff07 / Kernel 5.0.10 QEMU config
Created May 18, 2019 16:46
A kernel config for QEMU environment
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86_64 5.0.10 Kernel Configuration
#
#
# Compiler: x86_64-buildroot-linux-gnu-gcc.br_real (Buildroot 2019.05-git-00959-gd54b0e22ae) 7.4.0
#
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=70400
@0xff07
0xff07 / Project 1.py
Created April 10, 2019 14:11
Plotting script of Digital Control System in NTU. Mainly with SciPy and Matplotlib.
from scipy import signal
import matplotlib.pyplot as plt
import math
import numpy as np
plt.rc('text', usetex=True)
W_RANGE = np.arange(-4, 6, 0.001).tolist()
W_RANGE = [10**i for i in W_RANGE]
def plot_bode(sys, legend, tittle = ''):
fig, axs = plt.subplots(2, 1, constrained_layout=True)
@0xff07
0xff07 / brick.lsp
Last active January 4, 2019 03:07
Simple AutoLisp script to draw some common LEGO parts.
(defun c:LEGO ( / name)
(if (setq name (getstring "Enter component Name (Brick/Plate/round_brick/round_plate)"))
(if (or (eq name "plate") (eq name "P"))(draw_plate)
(if (or (eq name "brick") (eq name "B"))(draw_brick)
(if (or (eq name "round_plate") (eq name "RP"))(draw_round_plate)
(if (or (eq name "round_cone") (eq name "RC"))(draw_round_cone)
(if (or (eq name "round_brick") (eq name "RB"))(draw_round_brick))))))
);end if
)
@0xff07
0xff07 / octoprint_pligins.sh
Created July 27, 2018 13:48
A script to install plugins that I use.
#! /bin/bash
# install print history plugin. See
# https://plugins.octoprint.org/plugins/printhistory/
pip install "https://github.com/imrahil/OctoPrint-PrintHistory/archive/master.zip"
# install print statistics plugin. See
# https://plugins.octoprint.org/plugins/stats/
pip install "https://github.com/amsbr/OctoPrint-Stats/archive/master.zip"
# install zoomable temperature graph. See