This file contains hidden or 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
| def make_hash(csv) | |
| # オーガニックcsvからURLと流入のハッシュ作成 | |
| hash = {} | |
| open(csv) do |f| | |
| while line = f.gets | |
| /(.*?)\t(\d+)/ =~ line.sub("index.html", "") | |
| hash[$1] = $2 | |
| end | |
| end | |
| hash |
This file contains hidden or 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
| def has_img_ext(f) | |
| /(png|gif|jpg)$/ =~ f | |
| end | |
| files = Dir.glob("**/*.**") | |
| puts "<html>" | |
| files.each do |f| | |
| puts "<img src=\"#{f}\" /><p>#{f}</p>" if has_img_ext(f) | |
| end |
This file contains hidden or 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
| apiを使ってgoogle docにデータを自動読み込み | |
| http://analytics.blogspot.jp/2012/08/automate-google-analytics-reporting.html | |
| URLメイカー | |
| http://ga-dev-tools.appspot.com/explorer/ | |
| 使用可能なメトリクス | |
| https://developers.google.com/analytics/devguides/reporting/core/dimsmets |
This file contains hidden or 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 'oven' | |
| require 'big_bowl' | |
| class Bread | |
| def initialize | |
| first_ingredients = { | |
| 'Warm Water' => '220 ml', # add 5% more if half_milk | |
| 'flour' => '300 g' | |
| 'Yeast' => '6 g', | |
| 'Salt' => '6 g', |
This file contains hidden or 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
| # -*- encoding: utf-8 -*- | |
| def encode_this(all_files) | |
| all_files.each do |s| | |
| f = open(s) | |
| line = f.read.encode('sjis', 'utf-8') | |
| file_name = "new_" + s | |
| open(file_name, "w") do |w| | |
| w.write line | |
| end |
This file contains hidden or 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
| $ heroku login | |
| $ heroku create app名 | |
| $ heroku config | |
| # 環境変数確認 | |
| $ heroku config:add TZ=Asia/Tokyo | |
| $ heroku run console |
This file contains hidden or 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
| #! /usr/bin/local/ruby | |
| # -*- encoding: utf-8 -*- | |
| def add_up_same_dir_counts(domain_name, file_name) | |
| h = Hash.new | |
| open(file_name) do |file| | |
| while line = file.gets | |
| if line =~ /(www\.#{domain_name}\/index\.html),(\d+?),/ | |
| h[$1] = $2.to_i | |
| elsif line =~ /(www\.#{domain_name}\/.*?\/).*?,(\d+?),/ |
This file contains hidden or 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
| jQuery(function($) { | |
| var _thisUrl = $(location).attr('href'); | |
| $.each($('a,area,input:image,input:submit'), function() { | |
| var _thisId = $(this).closest("[id]").attr("id"); | |
| $(this).click(function() { | |
| _gaq.push(['_trackEvent', _thisUrl, _thisId, $(this).attr('href')]); | |
| }); | |
| }); | |
| }); |
This file contains hidden or 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 'rubygems' | |
| require 'amazon/ecs' | |
| def fetch_info(isbn) | |
| item_hash = {} | |
| Amazon::Ecs.options = { | |
| :associate_tag => 'YOUR_AMAZON_TAG', | |
| :AWS_access_key_id => 'YOUR_ACCESS_KEY', | |
| :AWS_secret_key => 'YOUR_SECRET_KEY' |