Skip to content

Instantly share code, notes, and snippets.

Avatar

mizdra mizdra

View GitHub Profile
@mizdra
mizdra / git-sy
Last active Oct 1, 2021
リモートリポジトリとブランチを良しなに同期してくれる君
View git-sy
#!/usr/bin/env bash
# usage: git sy
set -e
# run に渡されたコマンドを実行しつつ、コマンドの名前をログに出力する
run() {
echo -e "\e[1m+$@\e[0m"
"$@"
}
@mizdra
mizdra / main.ino
Last active Oct 8, 2021
二酸化炭素濃度測定機 (M5StickC Plus + MH-Z19C)
View main.ino
// based https://gist.github.com/YujiSoftware/9274366a93f1ac7f9208bd4abf096527
#include <M5StickCPlus.h>
#include "MHZ19.h"
#define RX_PIN 36 // Rx pin which the MHZ19 Tx pin is attached to
#define TX_PIN 0 // Tx pin which the MHZ19 Rx pin is attached to
#define BAUDRATE 9600 // Device to MH-Z19 Serial baudrate (should not be changed)
#define LCD_MODE_DIGIT 0
View ghq.sh
########################################
## peco
## (ref http://k0kubun.hatenablog.com/entry/2014/07/06/033336)
########################################
export GHQ_ROOT="$HOME/src"
hash -d gomi=~/src/localhost/gomi
function peco-src() {
# ディレクトリ構成
View item-data-form.tsx
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button';
import Grid from '@material-ui/core/Grid';
import InputLabel from '@material-ui/core/InputLabel';
import { makeStyles } from '@material-ui/core/styles';
import useForm from 'react-hook-form';
const useStyles = makeStyles((theme) => ({
labelContainer: {
@mizdra
mizdra / index.tsx
Created Aug 21, 2019
`is` で絞込むやつ
View index.tsx
type Modify<T, K extends keyof T, Value> = Pick<T, Exclude<keyof T, K>> &
{
[P in K]: Value
}
function isError<TData, TVariables>(
result: QueryResult<TData, TVariables>,
): result is Modify<typeof result, 'error', ApolloError> {
return !!result.error
}
@mizdra
mizdra / error.h
Last active Aug 3, 2019
Cでまともなエラーメッセージを出すマクロ (based on http://doi-t.hatenablog.com/entry/2013/12/10/094837)
View error.h
#pragma once
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#define PANIC(fmt, ...) \
{ \
err_msg(__FILE__, __FUNCTION__, __LINE__, "panic", fmt, ##__VA_ARGS__); \
View Cargo.lock
[[package]]
name = "cfg-if"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "itoa"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@mizdra
mizdra / 230.gif
Last active Apr 1, 2018
実行にはImageMagick, zshのインストールが必要です.
View run-webpack-wasm-skeleton.sh
# Run docker
docker run -p 8080:8080 -ti node:latest /bin/bash
# Install yarn
curl -o- -L https://yarnpkg.com/install.sh | bash
# Install rust
curl https://sh.rustup.rs -sSf > rustup-init.sh
sh rustup-init.sh -y
export PATH="$HOME/.cargo/bin:$PATH"
View index.js
import { add } from './math.rs'
console.log(add(1, 2))