Skip to content

Instantly share code, notes, and snippets.

View kshoji's full-sized avatar
💭
My mother fell ill & is currently hospitalized. I'm very busy dealing with her.

Kaoru Shoji kshoji

💭
My mother fell ill & is currently hospitalized. I'm very busy dealing with her.
View GitHub Profile
@kshoji
kshoji / MidiSampleScene_record_sequence.cs
Created May 22, 2024 09:59
The sequence recording part of MidiSampleScene.cs
if (GUILayout.Button("Start recording SMF") && isSequencerOpened)
{
var transmitters = new HashSet<ITransmitter>();
if (selectedInputDeviceId != null)
{
var transmitter = MidiSystem.GetTransmitter(selectedOutputDeviceId);
if (transmitter != null)
{
transmitters.Add(transmitter);
}
@kshoji
kshoji / MIDITester.ino
Created February 1, 2022 02:28
MIDI Send Tester for Arduino MIDI Shield
#include <MIDI.h>
// MIDI Library https://www.arduino.cc/reference/en/libraries/midi-library/
// MIDI Shield https://www.sparkfun.com/products/12898
// Usage: when LED D6 is ON, push D2 button. then 20 kind of MIDI data will send.
MIDI_CREATE_DEFAULT_INSTANCE();
byte sysex[] = { 0x01, 0x02, 0x04, 0x08 };
@kshoji
kshoji / deviceConnection.cs
Last active August 14, 2021 02:32
MIDI Plugin for Mobile devices examples
public void OnMidiInputDeviceAttached(string deviceId)
{
// will be called when a new Input device connected
// Input device can receive MIDI events
}
public void OnMidiOutputDeviceAttached(string deviceId)
{
// will be called when a new Output device connected
// Output device can send MIDI events
@kshoji
kshoji / game-of-life-scrollbit.ts
Created July 19, 2019 07:24
Game of Life for scroll:bit
let cell: number[] = []
let newCell: number[] = []
let dotBrightness: number = 64
function newGeneration() {
scrollbit.clear()
for (let m = 0; m <= scrollbit.rows() - 1; m++) {
for (let o = 0; o <= scrollbit.cols() - 1; o++) {
cell[m * scrollbit.cols() + o] = Math.randomRange(0, 1)
scrollbit.setPixel(o, m, cell[m * scrollbit.cols() + o] * dotBrightness)
}
@kshoji
kshoji / Illegal Prime.md
Last active March 14, 2019 06:06
I found the shortest illegal prime.

34856938471298877281521768684250279520041
is a prime number.

→ to HEX
666F72283B3B29616C65727428277D2729

→ to String
for(;;)alert('}')

It's a crime in Japan!

@kshoji
kshoji / README.md
Last active January 31, 2019 03:41
Slackbotのアイコンを旧アイコンに戻すスクリプト with Custom JavaScript for websites

前提

  • Chromeでslackを閲覧している

手順

  • Custom JavaScript for websites を入れる。
  • slackのタブを開き、拡張(cjsという文字のアイコン)を開いて、 enable cjs for this host のチェックボックスにチェックする。
  • 下記のスクリプトをコピペして、 save ボタンを押す。

スクリプト

(毎秒処理するのがなんか微妙…)

@kshoji
kshoji / 🍣.c
Created January 25, 2018 04:43
😀👉🖥
// gcc -finput-charset=UTF-8 -fextended-identifiers 🍣.c && ./a.out
#include <stdio.h>
#include <wchar.h>
#include <locale.h>
#define 😀 setlocale(LC_ALL, "");
#define 👉(x) wprintf(L"%lc", L'鮪' + x)
#define 🐟 0
#define 🍵 10
#define 🌀 for
#define 🍣🍣🍣 int main()
@kshoji
kshoji / README.md
Last active August 10, 2021 09:55
秋月電子と共立エレショップのWebサイトのセッションが切れてたらリロードするChrome拡張

インストール方法

  • manifest.json と script.js を適当な、同じディレクトリ内に保存します。
  • Chromeの設定画面を開き、拡張機能の画面を出します。
  • 「デベロッパーモード」のチェックボックスにチェックを入れます。
  • 「パッケージされていない拡張機能を読み込む」ボタンを押し、先程のディレクトリを選択します。
@kshoji
kshoji / MyNumberLister.java
Last active November 10, 2015 07:06
有効な個人用マイナンバーを全て列挙するコード
public class MyNumberLister {
public static void main(String[] args) {
for (long i = 0; i < 100000000000L; i++) {
String myNumber = String.format("%011d", i);
int sum = 0;
for (int j = 1; j < 12; j++) {
int digit = Integer.parseInt(myNumber.substring(11 - j, 12 - j));
int multiplier = (j < 7) ? j + 1 : j - 5;
sum += digit * multiplier;
@kshoji
kshoji / OffsetTime.java
Created May 11, 2015 09:00
Add offset to Time, for WatchFace app on the Android Wear
package jp.kshoji.watchface;
import android.support.annotation.NonNull;
import android.text.format.Time;
/**
* <h2>Time with Offset</h2>
*
* For example, construct an instance with `new Offset(300);`,
* When the real time: `9:00`, this OffsetTime returns `9:05`