Skip to content

Instantly share code, notes, and snippets.

@morimorihoge
morimorihoge / m5stack-ccs811.c
Created July 12, 2020 21:20
M5Stack+CCS811 with LCD
/******************************************************************************
Compensating the CCS811 with humidity readings from the BME280
Marshall Taylor @ SparkFun Electronics
April 4, 2017
https://github.com/sparkfun/CCS811_Air_Quality_Breakout
https://github.com/sparkfun/SparkFun_CCS811_Arduino_Library
@morimorihoge
morimorihoge / stop_ec2_instances.rb
Created July 6, 2020 09:42
AWS Lambda Ruby 2.7 EC2 Instances Stop
require 'aws-sdk'
require 'json'
# Environments:
# AWS_REGION = 'ap-northeast-1' as default
# TARGET_INSTANCE_IDS = 'i-1234567890abcdef,i-2234567890abcdef' like comma-separated string
AWS_REGION = ENV['AWS_REGION'] || 'ap-northeast-1'
def lambda_handler(event:, context:)
target_instance_ids = ENV['TARGET_INSTANCE_IDS'].split(',')
@morimorihoge
morimorihoge / start_ec2_instances.rb
Created July 6, 2020 09:41
AWS Lambda Ruby 2.7 EC2 Instances Start
require 'aws-sdk'
require 'json'
# Environments:
# AWS_REGION = 'ap-northeast-1' as default
# TARGET_INSTANCE_IDS = 'i-1234567890abcdef,i-2234567890abcdef' like comma-separated string
AWS_REGION = ENV['AWS_REGION'] || 'ap-northeast-1'
def lambda_handler(event:, context:)
target_instance_ids = ENV['TARGET_INSTANCE_IDS'].split(',')
@morimorihoge
morimorihoge / option_command.rb
Created June 12, 2020 09:46
OptionParserを使ったスクリプトテンプレ
#!/usr/bin/env ruby
# requireや初期化を書く
require 'optparse'
opt = OptionParser.new
opt.version = '1.0'
# opt.banner = 'Usage: command [options]'
option_a = nil
# option別の#onを実装
="00001" テストデータ 0 スペース 入り データ ←には空データがあります
# morimorihoge screenrc
escape \233\233
zombie
hardstatus on
defbce on
# Protection from attacks
multiuser off
<?php
$max = 1000;
for($i = 2;$i <= 1000;$i++){
$devidable = false;
for($j = ($i - 1);$j > 1;$j--){
if($i % $j == 0){
$devidable = true;
}
class SimpleSearchForm
include ActiveAttr::Model
class_attribute :_search_model
class_attribute :_like_attributes
class_attribute :_equal_attributes
class_attribute :_join_tables
self._like_attributes = []
self._equal_attributes = []
{
"data":[
{
"0":13101,
"1":100,
"2":1000000,
"3":"トウキョウト",
"4":"チヨダク",
"5":"イカニケイサイガナイバアイ",
"6":"東京都",
@morimorihoge
morimorihoge / instant_data_insersion.rb
Created March 19, 2013 03:15
rails console等で適当にデータを突っ込む使い捨てコード
data = []
data << {:field_1 => 'abcde', :field_2 => 10, :field_3 => '2727291'}
data << {:field_1 => 'fghij', :field_2 => 200, :field_3 => '12177'}
# more data
data.each do |d|
SomeModel.new d
d.save!
end