Skip to content

Instantly share code, notes, and snippets.

View locatw's full-sized avatar

locatw locatw

  • Japan
View GitHub Profile
@locatw
locatw / servo.cpp
Last active February 2, 2019 00:46
#include <iostream>
#include <wiringPi/wiringPi.h>
int main()
{
if (wiringPiSetupGpio() == -1) {
std::cout << "cannot setup gpio." << std::endl;
return 1;
}
@locatw
locatw / Program.cs
Created January 17, 2019 13:13
Google Cloud IoT Coreに登録されている端末の一覧を取得するプログラム
using Google.Apis.Auth.OAuth2;
using Google.Apis.CloudIot.v1;
using Google.Apis.Services;
using System;
using System.Threading.Tasks;
namespace Sample
{
class Program
{
@locatw
locatw / main.fsx
Created March 18, 2018 04:31
Parallel execution patterns of F#
let func1 () =
async {
printfn "func1 start"
Async.Sleep 3000 |> Async.RunSynchronously
printfn "func1 end"
}
let func2 () =
async {
printfn "func2 start"
@locatw
locatw / mayoi.fs
Last active December 20, 2015 11:39
マヨイドーロ問題の解答
open System
open System.Collections.Generic
open System.Numerics
// マヨイドーロ問題を解く。
// http://www.hyuki.com/codeiq/#c19
//
// Pが大きな数になるのでBigIntegerを使う。
[<EntryPoint>]
let main _ =
@locatw
locatw / replaceAmpersandHyphenToAmpersand.fs
Last active August 29, 2015 14:27
Replace "&-" to "&" in byte list in F#. This is used for IMAP-UTF7 decoding.
let replaceAmpersandHyphenToAmpersand (input : byte list) =
let replacedTail =
input
|> List.windowed 2
|> List.choose (fun chunk -> match chunk with
// 0x26 : '&', 0x2d : '-'
| [a; b] when a = (byte)0x26 && b = (byte)0x2d -> None
| [_; b] -> Some(b)
| _ -> failwith "invalid chunk")
input.Head :: replacedTail
@locatw
locatw / rake-for-cpp
Created March 16, 2014 14:14
rakefile for C++ source build.
# coding: utf-8
require 'fileutils'
### 定数 ###
COMPILER = "g++"
CPPFLAGS = %w{}
LDFLAGS = %w{}
INC_DIRS = []
LIB_DIRS = []
TARGET = "app"