Instantly share code, notes, and snippets.

View data_extraction.rake
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?
View radio_button_with_label.rb
<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>
View clean_local_branch.sh
git branch --merged | grep -v "\*" | grep -v master | grep -v dev | xargs -n 1 git branch -d
View link_to_ireko.rb
View git_config_global_alias.sh
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
View git_settings.sh
git config --global user.name "Your Name"
git config --global user.email you@example.com
View input_on_click_focus.js
$(document).ready(function(){
$('.jsInputOnClickFocus').focus(function(){
$(this).select();
});
});
View simple_select_with_hash.rb
<%= 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 => '選択してください' } %>
View contact_form_7_select_default.php
// ex) test_type = 'テスト1'
[select* test_type include_blank default:get "テスト1" "テスト2" "テスト3" "テスト4" "テスト5(test)"]
View 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.