Skip to content

Instantly share code, notes, and snippets.

@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 %>
@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 / _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 / 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 / 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 / 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 / file0.sh
Last active November 21, 2017 06:11
ArduinoとRaspberry Pi間をZigBeeで接続する ref: https://qiita.com/h-sakano/items/15e1b269d3ceb03cf499
# ベースのアップデート
$ sudo apt-get update
$ sudo apt-get upgrade -y
$ sudo apt-get dist-upgrade
# 必要なライブラリのインストール
$ sudo pip install xbee
@h-sakano
h-sakano / file0.sh
Last active November 28, 2017 08:57
Google Cloud IoT CoreでMQTTを試す ref: https://qiita.com/h-sakano/items/8a4960595e3359ad9ea4
$ openssl genrsa -out rsa_private.pem 2048
$ openssl rsa -in rsa_private.pem -pubout -out rsa_cert.pem
@h-sakano
h-sakano / file0.sh
Last active December 20, 2017 12:08
EC-CUBEでフロント画面テンプレートを追加 ref: https://qiita.com/h-sakano/items/d593f3ba85de92452fec
$ cp -r app/template/default/ app/template/[テンプレートコード]/
$ cp -r src/Eccube/Resource/template/default/* app/template/[テンプレートコード]/
@h-sakano
h-sakano / apache2.conf
Last active December 23, 2017 09:26
GKEのコンテナ内のディレクトリにGCSバケットをマウントする ref: https://qiita.com/h-sakano/items/f82713347eb192586489
.
.
.
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
.
.
.