駅データ.jp から以下のようなファイルをダウンロードし、 db/seeds/ekidata とか適当な場所に置く:
- station20121102free.csv
- line20121030free.csv
- company20121010.csv
マイグレーション:
# db/migrate/XXXXXXXXXXXXXX_create_ekidata_stations.rb| class AddHstoreExtension < ActiveRecord::Migration | |
| def up | |
| execute 'CREATE EXTENSION hstore' | |
| end | |
| def down | |
| execute 'DROP EXTENSION hstore' | |
| end | |
| end |
| # Set the number of connections AR pool | |
| # | |
| # place in an initializer such as: config/connection_pool.rb | |
| Rails.application.config.after_initialize do | |
| ActiveRecord::Base.connection_pool.disconnect! | |
| ActiveSupport.on_load(:active_record) do | |
| config = Rails.application.config.database_configuration[Rails.env] | |
| config['pool'] = ENV['DB_POOL'] || 6 |
| # DelegateToAll. Like delegate.rb from Ruby's std lib but lets you have multiple target/delegate objects. | |
| require 'delegate' | |
| class DelegatorToAll < Delegator | |
| # Pass in the _obj_ to delegate method calls to. All methods supported by | |
| # _obj_ will be delegated to. | |
| # | |
| def initialize(*targets) | |
| __setobj__(targets) |
| gifify() { | |
| if [[ -n "$1" ]]; then | |
| if [[ $2 == '--good' ]]; then | |
| ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png | |
| time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif | |
| rm out-static*.png | |
| else | |
| ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif | |
| fi | |
| else |
| #!/usr/bin/env ruby | |
| cmd = %q[echo '3...'; sleep 1; | |
| echo '2...'; sleep 1; | |
| echo '1...'; sleep 1; | |
| echo 'Liftoff!'] | |
| puts '------ beginning command ------' | |
| output_log = [] | |
| IO.popen(cmd).each do |line| |
| # Add this to your application.rb | |
| config.middleware.use Rack::Cors do | |
| allow do | |
| origins '*' | |
| # location of your API | |
| resource '/api/*', :headers => :any, :methods => [:get, :post, :options, :put] | |
| end | |
| end |
| <?php | |
| // get next and prev products | |
| // Author: Georgy Bunin ([email protected]) | |
| // forked from https://gist.github.com/2176823 | |
| function ShowLinkToProduct($post_id, $categories_as_array, $label) { | |
| // get post according post id | |
| $query_args = array( 'post__in' => array($post_id), 'posts_per_page' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'tax_query' => array( | |
| array( | |
| 'taxonomy' => 'product_cat', |
| module AuthHelper | |
| def http_login | |
| user = 'username' | |
| pw = 'password' | |
| request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user,pw) | |
| end | |
| end | |
| module AuthRequestHelper | |
| # |
駅データ.jp から以下のようなファイルをダウンロードし、 db/seeds/ekidata とか適当な場所に置く:
マイグレーション:
# db/migrate/XXXXXXXXXXXXXX_create_ekidata_stations.rb/etc/hosts
127.0.0.1 myapp.de
nginx.conf
http {