This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rstan) | |
options(mc.cores = parallel::detectCores()) | |
rstan_options(auto_write = TRUE) | |
# AB: 打席数 | |
# H: 打数 | |
# alpha_pre: 事前分布(ベータ分布)の α パラメータ | |
# beta_pre: 事前分布(ベータ分布)の β パラメータ | |
dat <- list(AB = 10, H = 2, alpha_pre = 2, beta_pre = 6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
config.vm.box = 'nrel/CentOS-6.5-x86_64' | |
config.ssh.insert_key = false | |
# config.vm.box_check_update = false | |
config.vm.define :develop do |develop| | |
develop.vm.hostname = 'develop' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enumerableな対象の要素の引数指定したラムダ式の結果が全て真であることを検証します。 | |
RSpec::Matchers.define :be_all do |p| | |
match do |items| | |
@empty = true if items.empty? | |
return false if @empty | |
items.all? { |item| p.call(item) } | |
end | |
failure_message do |items| | |
if @empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// saveボタン | |
@IBOutlet weak var save: UIBarButtonItem! | |
// UITextFieldが編集されると呼ばれるデリゲートメソッド | |
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool { | |
var textLength: Int; | |
// (UITextField の文字数 - カット、ペースト、デリートされた文字数)+ キーボードから入力された文字数 | |
textLength = ( textField.text!.characters.count - range.length ) + string.characters.count; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
register_instance_option :link_icon do | |
"fa fa-sort" // FontAwsome Icons | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zds = [] | |
loop.lazy.map{ ['ズン', 'ドコ'].sample }.each do |zd| | |
print zd | |
zds << zd | |
break if zds.last(5) == ["ズン", "ズン", "ズン", "ズン", "ドコ"] | |
end | |
print " キ・ヨ・シ!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :str_utils do | |
desc "英語の語尾変化を確認します。" | |
task :check_inflection, ['word'] => :environment do |task, args| | |
word = args.word | |
puts "単数形.......... " << word.singularize | |
puts "複数形.......... " << word.pluralize | |
puts "キャメルケース.. " << word.camelize | |
puts "スネークケース.. " << word.underscore | |
puts "テーブル名...... " << word.tableize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
// Here your code ! | |
var Clazz = function(name) { | |
// インスタンスプロパティ | |
this.name = name; | |
// instance method bad | |
this.say = function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ファイル読み込まれ順によるエラーの恐れをなくすため、同一ファイルの先頭にRailsAdminEnumを記述しています。 | |
module ActiveRecord | |
module RailsAdminEnum | |
def enum(definitions) | |
super | |
definitions.each do |name, values| | |
define_method("#{ name }_enum") { self.class.send(name.to_s.pluralize).to_a } | |
define_method("#{ name }=") do |value| | |
if value.kind_of?(String) and value.to_i.to_s == value | |
super value.to_i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require Rails.root.join('lib', 'display_order_action.rb') | |
RailsAdmin.config do |config| | |
config.actions do | |
dashboard # mandatory | |
index # mandatory | |
new | |
export | |
bulk_delete | |
show |
NewerOlder