Skip to content

Instantly share code, notes, and snippets.

@h-sakano
h-sakano / file0.c
Last active November 18, 2017 14:44
初めてのArduino(Lチカまで) ref: https://qiita.com/h-sakano/items/ae57617f06a107bee3f3
int led = 13;
void setup() {
// put your setup code here, to run once:
pinMode(led, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(led, HIGH);
@h-sakano
h-sakano / ADC0832.py
Last active November 7, 2017 02:35
センサのアナログ出力をA/D変換し、アラートをチャットアプリに飛ばす ref: http://qiita.com/h-sakano/items/a3cffbe460e64f9ed064
def setup(cs=11, clk=12, dio=13):
global ADC_CS, ADC_CLK, ADC_DIO
ADC_CS = cs
ADC_CLK = clk
ADC_DIO = dio
GPIO.setwarnings(False)
- GPIO.setmode(GPIO.BOARD) # Number GPIOs by its physical location
+ GPIO.setmode(GPIO.BCM)
GPIO.setup(ADC_CS, GPIO.OUT) # Set pins' mode is output
GPIO.setup(ADC_CLK, GPIO.OUT) # Set pins' mode is output
@h-sakano
h-sakano / httpd-vhosts.conf
Created October 21, 2017 14:22
Mac OSにXAMPP7.1.10-0のインストール・設定 ref: http://qiita.com/h-sakano/items/77fb8367348aeb019209
# 下の2つの設定はコメントアウト
# <VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot "/opt/lampp/docs/dummy-host.example.com"
# ServerName dummy-host.example.com
# ServerAlias www.dummy-host.example.com
# ErrorLog "logs/dummy-host.example.com-error_log"
# CustomLog "logs/dummy-host.example.com-access_log" common
# </VirtualHost>
@h-sakano
h-sakano / _form.html.erb
Last active October 11, 2017 14:37
nested_form + bootstrapでネストしたモデルの入力フォームをタブ表示する ref: http://qiita.com/h-sakano/items/3f7c253b461aa9cfc7ab
<%= bootstrap_nested_form_for(@model_a, layout: :horizontal, label_col: "col-xs-2", control_col: "col-xs-10") do |f| %>
<%= f.text_field :column_a, label: "カラムA" %>
<%= f.text_field :column_b, label: "カラムB" %>
.
.
.
<ul class="nav nav-tabs" role="tablist" id="model-b-tab-list">
</ul>
<div class="tab-content" id="model-b-tab-contents">
@h-sakano
h-sakano / file0.txt
Created October 7, 2017 14:19
デフォルト値が設定されているモデルのreject_ifの指定方法 ref: http://qiita.com/h-sakano/items/06c11c9208e62e69491a
has_many :users
accepts_nested_attributes_for :users, reject_if: :all_blank
@h-sakano
h-sakano / file0.erb
Created October 7, 2017 14:14
Nested Formで動的に追加するフォームをテーブルに追加する ref: http://qiita.com/h-sakano/items/6409ddc22284e618d2b1
<table class="table table-responsive alias-table">
<%= f.fields_for :part_number_aliases, wrapper: false do |pnaf| %>
<tr class="fields">
<td>
<%= pnaf.text_field :alias_code, label: "氏名" %>
<%= pnaf.text_field :alias_name, label: "年齢" %>
<%= pnaf.link_to_remove 'ユーザー削除', class: "btn btn-default" %>
</td>
</tr>
<% end %>