Skip to content

Instantly share code, notes, and snippets.

View hara's full-sized avatar
🏠
Working from home

Yoshihiro Hara hara

🏠
Working from home
View GitHub Profile
#!/usr/bin/env bash
set -euo pipefail
echo "getting temperature and humidity from ${METER_MAC_ADDRESS}"
data="$(/usr/local/bin/switchbot-meter -a "${METER_MAC_ADDRESS}")"
echo "${data}"
body="$(echo "${data}" | jq -c '{(.addr): del(.addr)}')"
ts=$(echo "${data}" | jq -r '.ts')
echo "${body}" | curl -X POST \
@hara
hara / index.js
Last active March 14, 2018 15:01
node-rate-limiter で DynamoDB への putItem をレート制限する
'use strict';
const { RateLimiter } = require('limiter');
// プロビジョニングされた WCU
const PROVISIONED_WCU = 5;
/**
* DynamoDB のレートリミッターを作成する
*
@hara
hara / PATHEXT
Created October 18, 2013 15:03
Windows で %PATHEXT% を利用した which コマンド ref: http://qiita.com/hara/items/37d2659b050269352135
C:\Users\foo>echo %PATHEXT%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
@hara
hara / github.vim
Created July 31, 2013 13:20
github theme of vim-airline
let s:file = [ '#bd2c00' , '#666666' , 1 , 240 , 'bold' ]
" Normal mode
let s:N1 = [ '#ffffff' , '#6cc644' , 255 , 2 ] " mode
let s:N2 = [ '#ffffff' , '#999999' , 255 , 248 ] " info
let s:N3 = [ '#ffffff' , '#666666' , 255 , 240 ] " statusline
let g:airline#themes#github#normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3, s:file)
let g:airline#themes#github#normal_modified = {
\ 'info_separator': [ '#999999' , '#333333' , 248 , 232 , '' ] ,
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
@hara
hara / fn2google.rb
Last active December 17, 2015 13:59
Friends Note の CSV を Google Contacts の Google CSV 形式に変換するスクリプト
# coding: utf-8
require 'csv'
module GoogleContacts
class Contacts
attr_reader :cards
def initialize
@cards = []
end
@hara
hara / atom.xml
Created April 13, 2013 06:28
A Jekyll page file for Atom Feed.
---
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ site.title | xml_escape }}</title>
<link href="{{ site.url }}" />
<updated>{{ site.time | date_to_xmlschema }}</updated>
<author>
<name>{{ site.author | xml_escape }}</name>
@hara
hara / Rakefile
Created April 13, 2013 06:26
Rakefile to write a Jekyll post easily.
require 'yaml'
require 'time'
require 'fileutils'
require 'uuidtools'
CONFIG_YML = File.expand_path('../_config.yml', __FILE__)
CONFIG = YAML.load(File.read(CONFIG_YML, encoding: 'UTF-8'))
SOURCE_DIR = File.expand_path(CONFIG['source'] || File.dirname(__FILE__))
@hara
hara / sass.rb
Created April 13, 2013 03:13
A Jekyll plugin to compile Sass with Compass when building pages.
# -*- coding: utf-8 -*-
#
# Generates css files from Sass source files with Compass.
#
require 'pathname'
require 'sass'
require 'compass'
module Jekyll
"=============================================================================
" Licensed under the MIT license:
" http://www.opensource.org/licenses/mit-license.php
"============================================================
function! unite#sources#outline#aspvbs#outline_info()
return s:outline_info
endfunction
let s:Util = unite#sources#outline#import('Util')