Skip to content

Instantly share code, notes, and snippets.

@nyatla
nyatla / TBSKmodemMicroModulator
Last active February 19, 2023 08:01
TBSKmodemをMicroPythonで動くようにしたもの。GP2から8/16kHz矩形波を出して、文字列を送信する。送信した文字列はここのライブデモで受信できるはずhttps://nyatla.jp/tbskmodem/ 簡易変調なので通信品質はご容赦ください。
""" Copyright 2023 nyatla
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEA
@nyatla
nyatla / gist:dd46364b6e8cefddf96a5f1d7975f0ca
Created July 26, 2022 10:48
二度と作りたくない遅延読み出しできるリングバッファ
from typing import Deque, Iterator,TypeVar,Sequence,Iterable,Union
from ..interfaces import IPeekableStream
T=TypeVar("T")
@nyatla
nyatla / jsonpicklite.py
Last active April 28, 2020 12:44
lightweight picklelike implementation to json format.
"""pickle可能なオブジェクトをJSONと相互変換します。
Copyright 2020 nyatla
pickle可能なオブジェクトをJSONに変換してシリアライズ/復元します。
変換元のオブジェクトは、配列,辞書,JsonPicklableの継承クラスです。
再帰構造の動作チェックはしてません。
オブジェクトは、{"__cls":str,"d":object}の辞書形式に変換します。
JSONからオブジェクトに戻すときは、"__cls"キーに文字列を持つ要素をクラスインスタンスと判定し、
@nyatla
nyatla / CloseableBlockingQueue.java
Created January 14, 2020 16:27
シャットダウン機能のあるマルチスレッドのキューオブジェクト.JavaのBlockingQueueはシャットダウン機能がないのでつくった。
import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
/**
* シャットダウン機能のあるマルチスレッドのキューオブジェクト.
@nyatla
nyatla / pyarraybenchmark.py
Created November 3, 2019 14:01
Array access benchmark of Python multi-process.
"""
共有メモリのオーバヘッドを計測する。
"""
import time
import numpy as np
import multiprocessing
import ctypes
import random
@nyatla
nyatla / rpl.php
Last active February 27, 2018 07:53
RPL encode/decode implementation for PHP
<?php
class Rlp{
/**
* 数値をRpl Lengthに変換する
*/
private static function int2HexLen($l,$off)
{
if($l<56){
public class FreakKeyPointTest extends AwtSketch{
/**
* @param args
*/
public static void main(String[] args)
{
try {
new FreakKeyPointTest().run();
} catch (Exception e) {
// TODO Auto-generated catch block
// ==UserScript==
// @name mbedIDE Theme - Nyatlan Black
// @namespace http://nyatla.jp
// @include https://developer.mbed.org/compiler/*
// @version 3
// @grant none
// ==/UserScript==
var head_tag=document.getElementsByTagName('head')[0];
var css=
@nyatla
nyatla / LeftBehaviour.cs
Created May 11, 2013 09:03
It is a sample to handle two webcamera at the same time the on NyARToolkit Unity3D. Object hirarchy left +CameraL +Directionallight +MarkerObjectL +Cube +PlaneL right +CameraR +Directionallight +MarkerObjectR +Cube +PlaneR
using UnityEngine;
using System;
using System.Collections;
using jp.nyatla.nyartoolkit.cs.markersystem;
using jp.nyatla.nyartoolkit.cs.core;
using NyARUnityUtils;
using System.IO;
/// <summary>
/// AR camera behaviour.