Skip to content

Instantly share code, notes, and snippets.

🤔
:thinking_face:

Kamiya kamiyaowl

🤔
:thinking_face:
Block or report user

Report or block kamiyaowl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kamiyaowl
kamiyaowl / Tsp.scala
Created Apr 13, 2014
travering salesman problem : depth first search with scala
View Tsp.scala
import scala.io.Source
object City {
private def randoms(m:Int) : Stream[Int] = Stream.cons(scala.util.Random.nextInt(m), randoms(m))
def create(count:Int)(implicit max:Int) = randoms(max).zip(randoms(max)).take(count).zipWithIndex.map(x => x._2 -> x._1).toMap
}
implicit class CsvConverter(filepath: String) {
//Map[Int,(Int,Int)] : Index -> (X, Y)
def toCities = Source.fromFile(filepath).getLines.toSeq.map(x => x.split(",")).filter(_.size == 2).map(x => (x(0).toInt, x(1).toInt)).zipWithIndex.map(x => x._2 -> x._1).toMap
}
@kamiyaowl
kamiyaowl / Program.cs
Last active Apr 28, 2019
C# + OpenTK.Audio.OpenAL sample
View Program.cs
using OpenTK;
using OpenTK.Audio.OpenAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4 {
class Program {
View brainfxxk.cpp
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <stdint.h>
using namespace std;
int main() {
vector<uint8_t> mem(30000,0);
stack<int> branchStack;
@kamiyaowl
kamiyaowl / dmx_receiver.c
Last active Jan 25, 2019
dmx receive for avr
View dmx_receiver.c
/*
* dmx_receiver.c
*
* Created: 2014/07/15 19:43:52
* Author: kamiya
*/
#include <avr/io.h>
#include <avr/interrupt.h>
#include "dmx_receiver.h"
View gke-cronjob.yml
apiVersion: "batch/v1beta1"
kind: CronJob
metadata:
name: "<workload-name>"
namespace: "default"
labels:
app: "app-label"
spec:
schedule: "0 */4 * * *"
startingDeadlineSeconds: 120
View CsvRead.cs
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections.Generic;
static class Extension {
public static IEnumerable<int> CreateSource(this string[] src) {
return src.SelectMany(x => x.Split(',')).Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => int.Parse(x));
}
@kamiyaowl
kamiyaowl / vfd_emit.ino
Last active Mar 5, 2017
VFD(IV-18)を光らせる
View vfd_emit.ino
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
scala + opencv with sbt
View hellocv.scala
$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 Jun 28, 2016
C# + Sprache Lambda-Expr
View Program.cs
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 Aug 29, 2015
たまにこういうの欲しくなる
View color_table.scala
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,}, "}}
You can’t perform that action at this time.