hamayuzinの日記

エンジニアとかデータサイエンティストとかやってます。あの時 あれやってたな的な備忘録にできれば。

2017-05-01から1ヶ月間の記事一覧

【Ruby/tmpfile】ruby で tmpfileで CSVを作成する

Ruby Railsで tmpfileを使ってCSVを使う方法 単純でありきたいだけどいつもわすれる。 今回は、SJISでencordingしつつ アーティスト名と曲名の一覧のCSVを作成する。 (また、所要でFTPに上げる) # tmpfile作成 tf = Tempfile.new(["hogehoge", '.csv'], en…

【Rails/Bootstrap/modal】rails bootstrapのmodalをajaxで操作する

とあるアーティストの曲を取得したい場合を考える 「曲の一覧」というリンクをクリックすると そのアーティストの一覧を取得して、曲の一覧をモーダルで出す。 index.haml:曲の一覧を表示する %a.open_modal{disable: true, id: @artist.id} 曲の一覧 - con…

【rails/heroku/sitemap】heroku環境下のrailsでsitemapを設定する

heroku環境下で動いているrailsは、sitemap_generator gemだけではうまく動かない (作成したファイルを置けないなんだよ。。。) github.com そこで、AWSのS3に置く方法を用いる sitemapの作成 sitemap_generator gemをインストールして rake sitemap:insta…

【Rails/iframe】Railsでiframeのheightを設定する方法

railsでiframeの高さを設定するのが以外とめんどくさかった cssで設定するとよろし レスポンシブにもなる test.css .iframe { width: 100%; height: 500px; } @media screen { .iframe-wrapper { position: relative; width: 100%; } .iframe { position: ab…

【rspec/rails】railsのrspecでhelperをテストする

rspecを使った、helperのテスト方法 基本は他のテストと同じ 記述方法 app/helpers/test_helper.rb module TestHelper def test_method 'テストだよ' end end spec/helpers/test_helper.rb require 'rails_helper' RSpec.describe TestHelper do include Tes…

【heroku/ridgepole】herokuでridgepole/mysqlを動かす

herokuにrailsプロダクトをアップロードするにあたり、 ridgepoleでつまづいた エラー1:[ERROR] No such file or directory @ rb_sysopen - /app/config/database.yml ridgpoleを実行する際、下記コードを実行するのだが heroku run 'bundle exec ridgepole…

【heroku/ridgepole】herokuでridgepole/mysqlを動かす

herokuにrailsプロダクトをアップロードするにあたり、 ridgepoleでつまづいた エラー1:[ERROR] No such file or directory @ rb_sysopen - /app/config/database.yml ridgpoleを実行する際、下記コードを実行するのだが heroku run 'bundle exec ridgepole…

【まじ簡単】awsのg2インスタンスで、GPUを使ってkerasを動かす

Kerasでモデルの学習を行っていると、時間だけを浪費している瞬間がどうしてもでてくる。 そこで、AWSのg2インスタンスで、GPUを使って効率化を図った 今回は、GPUを使うための環境設定と、kerasのインストールを行う AWS g2.2xlergeの立ち上げ kerasのバッ…

【Rails/パンくず】Railsでパンくずリストを作る簡単な方法

Webサイト作っていると、パンくずリスト作りたくなる。 railsではいい感じにしてくれるgemがある。 github.com gemfileに上記gem追加して、bundle installする。 アーティスト>曲の場合 app/controllers/songs_controller.rb class SongsController < Appli…

【Rails/favicon】railsでロゴとfavicon作って設定する

デザインセンスが無い場合に、ロゴとfaviconをどう作成するのか。 そして、それをどう反映させるのか ロゴの作成 いい感じに素早く作るならここ http://emblemmatic.org/markmaker/#/ 入力してダウンロードするだけ faviconの作成 ここが、全てのタイプのfav…

【Rails/action_cable】action_cableをnginx+unicornで動かす

action cableを本番のnginx uninorn下で動かく設定のメモ 今回はAWSのEC2とLBを使う 前提 昔からあるLoad Balancer(現在はCLB)では動かないので 諦めて、Application Load Balancer(ALB)を使う また、AWS上でredisの設定もしておくこと nginx location /cabl…

ridgepole本番deploy時に invalid multibyte char (US-ASCII)

ridgepoleを使って、rails project deploy時に bundle stderr: fatal: Not a git repository (or any of the parent directories): .git fatal: Not a git repository (or any of the parent directories): .git fatal: Not a git repository (or any of the…