Skip to content

Instantly share code, notes, and snippets.

//TCCR0Bをいじっても同じ時間待てるようにするdelay
void delay_tccr0b(float ms){
delay(ms * 64.0 / pow(8, TCCR0B-1));
}
void setup(){
//leonardoではTCCR0Bは3ピンに影響
pinMode(3, OUTPUT);
//PWMの周波数が62.5kHzになる
TCCR0B=(TCCR0B & 0b11111000) | 0x01;
@zyouyowa
zyouyowa / odnoronokabaytomo.py
Created November 19, 2016 03:33
"。うせどdのろのかばyとも"
# -*- coding: utf_8 -*-
import sys
import subprocess
import pykakasi
def romaji(txt):
"Japanese->Romaji"
kks = pykakasi.kakasi()
kks.setMode('H', 'a')
kks.setMode('K', 'a')
@zyouyowa
zyouyowa / upload.py
Created February 27, 2017 13:33
Slack APIのfiles.uploadで画像を投稿するやつ
# -*- coding: utf-8 -*-
import requests
url = 'https://slack.com/api/'
token = 'Slack Bot API Token'
def upload(filename, image, channels, filetype='jpg'):
joind_channels = ','.join(channels)
arguments = {
'token': token,
@zyouyowa
zyouyowa / postMessage.py
Created February 27, 2017 13:36
Slack APIのchat.postMessageでBotに任意の発言をさせる
import requests
url = 'https://slack.com/api/'
token = 'Slack Bot API Token'
def postMessage(msg, channel):
arguments = {
'token': token,
'channel': channel,
#!/bin/sh
# Example:
# ./sjis2utf8.sh sample8th/*.asm
for i in $@; do
echo $i
iconv -f SJIS -t UTF8 $i > tmp.sh
cp tmp.sh $i
rm tmp.sh
@zyouyowa
zyouyowa / 12_5.cpp
Last active July 7, 2017 05:46
例のアレ
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]){
int a[] = {10, 13, 13, 15, 20, 25};
int b[] = {6, 6, 8, 8, 11, 13};
int n = 6, w = 21;
int i = n-1, j = 0;
int i2 = i, j2 = j;
@zyouyowa
zyouyowa / WaitWhileExperiment.cs
Created September 22, 2017 06:18
UnityのWaitWhileでループを作れるっぽい
void Start () {
StartCoroutine (WaitWhileExperiment ());
}
IEnumerator WaitWhileExperiment(){
int a = 0;
yield return new WaitWhile (() => {
a++;
Debug.Log(a);
return a < 10;
@zyouyowa
zyouyowa / ShowData.compute
Created August 22, 2018 16:13
RenderTextureにdataをプロットするだけ
#pragma kernel ShowData
StructuredBuffer<float> data;
RWTexture2D<float4> Result;
[numthreads(1024,1,1)]
void ShowData (uint id : SV_DispatchThreadID)
{
for (int i = 0; i < 256; i++) {
uint2 idx = uint2(id, i);
using UnityEngine;
using UnityEngine.UI;
public class ImageProcesser : MonoBehaviour {
public ComputeShader shader;
public RawImage srcImg;
public RawImage dstImg;
void Start () {
#pragma kernel CSMain
Texture2D<float4> srcTex;
RWTexture2D<float4> dstTex;
[numthreads(32, 32, 1)]
void CSMain(uint3 id : SV_DispatchThreadID) {
float4 up = srcTex[id.xy + int2(0, 1)];
float4 down = srcTex[id.xy + int2(0, -1)];
float4 left = srcTex[id.xy + int2(-1, 0)];