Skip to content

Instantly share code, notes, and snippets.

View kamiyaowl's full-sized avatar
🤔
:thinking_face:

Kamiya kamiyaowl

🤔
:thinking_face:
View GitHub Profile
@kamiyaowl
kamiyaowl / vfd_emit.ino
Last active March 5, 2017 14:40
VFD(IV-18)を光らせる
const uint8_t sw_out = 9;
uint16_t target_value = 1023;
const uint8_t segments_pin[] = {0, 1, 2, 3, 4, 5, 6};
const uint8_t orders_pin[] = {A4, A3, A2, A1, 13, 12, 11, 10};
const uint8_t segments_count = 7;
const uint8_t orders_count = 8;
const uint8_t segment_data[] = {
0b11111100,//0
0b01100000,//1
@kamiyaowl
kamiyaowl / hellocv.scala
Created May 13, 2014 02:08
scala + opencv with sbt
$sudo apt-get install libopencv-dev
$mkdir hellocv
$cd hellocv
$mkdir lib
#get opencv-2XX.jar and copy into hellocv/lib
#sudo dpkg -L libopencv-dev
$cp /usr/share/OpenCV/java/opencv-248.jar lib/
$sbt run
@kamiyaowl
kamiyaowl / Program.cs
Last active June 28, 2016 09:36
C# + Sprache Lambda-Expr
using Sprache;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace lambda_calc
{
abstract class Statement { }
abstract class Expr : Statement
@kamiyaowl
kamiyaowl / color_table.scala
Last active August 29, 2015 14:26
たまにこういうの欲しくなる
def loopSeq = ((0 to 0xff) ++ (0x0 to 0xff).reverse)
val arr = {loopSeq map{x => s"{ $x, 0, 0,}, "}} ++
{loopSeq map{x => s"{ 0, $x, 0,}, "}} ++
{loopSeq map{x => s"{ 0, 0, $x,}, "}} ++
{loopSeq map{x => s"{ $x, $x, 0,}, "}} ++
{loopSeq map{x => s"{ 0, $x, $x,}, "}} ++
{loopSeq map{x => s"{ $x, 0, $x,}, "}} ++
{loopSeq map{x => s"{ $x, $x, $x,}, "}}
@kamiyaowl
kamiyaowl / main.c
Created June 21, 2015 07:07
Number -> Hex for Embedded
#include <stdio.h>
typedef unsigned short uint16;
typedef unsigned char uint8;
const char numberTable[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
void itoa(uint16 src, char* buf){
uint8 i;
buf[0] = '0';
buf[1] = 'x';
@kamiyaowl
kamiyaowl / main.c
Created June 17, 2015 11:16
ガウスの消去法
#include <stdio.h>
// 未知数の数/方程式の数
#define N 2
int main(void){
// x + 2y = 5
//2x + 3y = 8
double matrix[N][N + 1] = {
{ 1, 2, 5 },
@kamiyaowl
kamiyaowl / ImageData.h
Last active August 29, 2015 14:23
ATMEGA328p LS027B4DH01
#ifndef IMAGEDATA_H_
#define IMAGEDATA_H_
#include <avr/pgmspace.h>
PROGMEM const uint8_t img_src[240][50] = {
{ 0x7, 0xf8, 0xff, 0xff, 0x3, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x31, 0xfe, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, },
{ 0xc0, 0xff, 0xff, 0xff, 0xff, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x19, 0xff, 0xff, 0x8f, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, },
{ 0xfc, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x99, 0xff, 0xff, 0xc7, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe1, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff,
@kamiyaowl
kamiyaowl / Main.scala
Created March 12, 2015 05:36
多角形衝突判定
object Main {
implicit class Point[T <% Double](val self:(T,T)) {
lazy val abs = math.sqrt(self._1 * self._1 + self._2 * self._2)
def -[U <% Double](p:(U,U)) = (self._1 - p._1, self._2 - p._2)
def cross[U <% Double](p:(U,U)) = self._1 * p._2 - self._2 * p._1
}
def crossProduct[T <% Double](polygon:List[(T,T)],points:List[(T,T)]) : List[List[Double]] =
points.map { p => polygon zip(polygon.tail :+ polygon.head) map{ case(a,b) => (a - p) cross (b - p)} }
def isCrossVector(xs:List[Double]) : Boolean = xs.forall(_ > 0) || xs.forall(_ < 0)
def isCross[T <% Double](poly1:List[(T,T)],poly2:List[(T,T)]) : Boolean =
@kamiyaowl
kamiyaowl / Main.scala
Last active August 29, 2015 14:16
reversepolish calculator(Do not use parsercombinator)
import scala.collection.immutable.Stack
object Main {
def binOp(q:Stack[Double])(f:(Double,Double) => Double) : Stack[Double] = {
val (b,q2) = q.pop2
val (a,q3) = q2.pop2
q3.push(f(a,b))
}
def unaryOp(q:Stack[Double])(f:(Double) => Double) : Stack[Double] = {
val (a,q2) = q.pop2
println(((s:String) => s.drop(5 + 7).take(5).zip(s.drop(5).take(7)).zip(s.take(5)).map{case ((a,b),c) => s"$a $b $c"}.++(s.drop(5 + 5).take(2).map{x => s" $x"}).mkString("\r\n"))("なかぬならなかせてみようホトトギス"))