Skip to content

Instantly share code, notes, and snippets.

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

Maechan maecha

🏠
Working from home
View GitHub Profile
@maecha
maecha / data_extraction.rake
Last active May 11, 2017 07:13
Data extraction
require "csv"
namespace :extract_hoge do
desc 'Data extraction'
task extraction: :environment do
p 'start task'
hoges = Hoge.all.order(id: :asc)
CSV.open('path/to/hoge.csv','w') do |row|
hoges.each do |hoge|
row << [ hoge.id, hoge.name, hoge.tel ] if hoge.tel.present?
@maecha
maecha / radio_button_with_label.rb
Created May 11, 2017 07:13
radio button with label
<div class="form-check form-check-inline">
<%= f.collection_radio_buttons(:hoge_id, @hoges, :id, :name) do |b| %>
<%= b.label(class: 'form-check-label', 'data-value': b.value) { b.radio_button(class: 'form-check-input') + b.text } %>
<% end %>
</div>
@maecha
maecha / clean_local_branch.sh
Created May 11, 2017 07:17
ローカルブランチのお掃除
git branch --merged | grep -v "\*" | grep -v master | grep -v dev | xargs -n 1 git branch -d
@maecha
maecha / link_to_ireko.rb
Created May 11, 2017 07:21
link_toを入れ子で
@maecha
maecha / git_config_global_alias.sh
Created May 11, 2017 07:24
Gitコマンド省略
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.cm commit
git config --global alias.fc fetch
git config --global alias.df diff
git config --global alias.gr grep
@maecha
maecha / git_settings.sh
Created May 11, 2017 07:27
Gitの設定
git config --global user.name "Your Name"
git config --global user.email you@example.com
@maecha
maecha / input_on_click_focus.js
Created May 17, 2017 07:00
インプットをクリックでテキストを選択状態にする
$(document).ready(function(){
$('.jsInputOnClickFocus').focus(function(){
$(this).select();
});
});
@maecha
maecha / simple_select_with_hash.rb
Last active June 30, 2017 02:42
HASHから簡易選択 select, select_tag
<%= f.select :hoge_type, options_for_select(Hoge::TYPE_HASH.invert), { include_blank: '選択してください' }, { class: 'test', required: true } %>
<%= select_tag :hoge_type, options_from_collection_for_select(Hoge::TYPE_HASH.invert, :first, :last), { :include_blank => '選択してください' } %>
@maecha
maecha / contact_form_7_select_default.php
Last active June 30, 2017 02:52
WordPress Contact Form 7 selectのデフォルトを動的に
// ex) test_type = 'テスト1'
[select* test_type include_blank default:get "テスト1" "テスト2" "テスト3" "テスト4" "テスト5(test)"]
@maecha
maecha / seattleWeather_1948-2017.ipynb
Created February 28, 2018 02:16
anaconda3/py_learning/seattleWeather_1948-2017.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.