Skip to content

Instantly share code, notes, and snippets.

@macrat
macrat / tic-tac-toe.py
Created May 20, 2018
chainerでマルバツゲーム。失敗作。
View tic-tac-toe.py
import numpy
import chainer
import chainer.links as L
import chainer.functions as F
def judge(board):
"""
>>> judge(numpy.array([[ 1, 1, 1],
... [.5, 0, .5],
@macrat
macrat / dice-count.py
Created Mar 12, 2018
Python/OpenCVで特徴点マッチングして、DBSCANでクラスタリングしたらサイコロの目の合計とか出せないかと思ったやつ。失敗。
View dice-count.py
import os
import cv2
import numpy
import matplotlib.pyplot as plt
from sklearn.cluster import DBSCAN
images = [cv2.imread('dataset/samples/' + x) for x in os.listdir('dataset/samples') if x.endswith('.jpg')] # サイコロの特定の面の教師画像
original = cv2.imread('dataset/random/0.jpg') # ランダムにサイコロを転がした画像
View newdown.html
<!doctype html>
<title>new blankdown design</title>
<meta name=viewport content="width=device-width,initial-scale=1">
<body>
<nav>
<div id=nav-inner>
<textarea id=search-box cols=1 placeholder="search"></textarea>
<ul id=tag-area>
@macrat
macrat / face_finder.py
Created Feb 6, 2018
顔を見付けたら通知するシステム
View face_finder.py
import base64
import cv2
import numpy
import sendgrid
SENDGRID_APIKEY = 'your API key here'
TO_ADDRESS = 'mail-to@example.com'
FROM_ADDRESS = 'mail-from@example.com'
@macrat
macrat / markdown-with-simplexer.go
Created Jan 10, 2018
simplexerでMarkdownをHTMLに変換する実験
View markdown-with-simplexer.go
package main
import (
"fmt"
"os"
"github.com/macrat/simplexer"
)
const (
@macrat
macrat / simplexer.go.y
Last active Jan 10, 2018
simplexerとgoyaccの組み合わせサンプル。
View simplexer.go.y
%{
package main
import (
"fmt"
"io"
"os"
"strconv"
"strings"
@macrat
macrat / mymarkdown.html
Last active Jan 1, 2018
CodeMirrorでMarkdownのモードを自作。の失敗作。 -> [そこそこ動く作](https://github.com/macrat/codemirror-mymarkdown)
View mymarkdown.html
<script src=http://unpkg.com/codemirror></script>
<script src=http://unpkg.com/codemirror/mode/python/python.js></script>
<script src=http://unpkg.com/codemirror/mode/markdown/markdown.js></script>
<script src=http://unpkg.com/codemirror/addon/mode/simple.js></script>
<link rel=stylesheet href=http://unpkg.com/codemirror/lib/codemirror.css />
<style>
.cm-header {
display: inline-block;
padding: .5em 0 .3em;
@macrat
macrat / survey.html
Created Dec 20, 2017
標本数とか標本誤差とかの計算をするやつ
View survey.html
<title>標本数の計算</title>
<meta name="viewport" content="width=device-width">
<style>
body {
margin: 2em;
}
.hint {
color: gray;
}
@macrat
macrat / image.go
Created Nov 9, 2017
golangでグラデーション作ったり、文字入れたり。
View image.go
package main
import (
"image"
"image/color"
"image/png"
"os"
"golang.org/x/image/font"
"golang.org/x/image/font/basicfont"
@macrat
macrat / exceljs.js
Created Sep 12, 2017
node.jsでExcel生成
View exceljs.js
const excel = require('exceljs');
let workbook = new excel.Workbook()
workbook.creator = 'MacRat';
workbook.created = new Date(2000, 1, 1);
workbook.modified = new Date();
let sheet = workbook.addWorksheet('The sheet');