Skip to content

Instantly share code, notes, and snippets.

@mechamogera
mechamogera / Gemfile
Created Mar 11, 2014
S3のstaticsホスティングをする構成のCloudFormationのTemplate
View Gemfile
# A sample Gemfile
source "https://rubygems.org"
# gem "rails"
gem "aws-sdk"
@mechamogera
mechamogera / Gemfile
Created May 13, 2014
JenkinsのRole-based Authorization Strategy pluginを利用した認証においてUserをRoleにAssignする
View Gemfile
# A sample Gemfile
source "https://rubygems.org"
gem 'trollop'
@mechamogera
mechamogera / Gemfile
Last active Aug 29, 2015
CloudWatch LogsのGroupから一括でLogを取得するスクリプト
View Gemfile
# A sample Gemfile
source "https://rubygems.org"
gem 'trollop'
gem "json"
gem "aws-sdk-core"
@mechamogera
mechamogera / Gemfile
Last active Aug 29, 2015
AssumeRoleテスト用のS3アップロードスクリプト
View Gemfile
# A sample Gemfile
source "https://rubygems.org"
gem 'aws-sdk', '< 2.0'
@mechamogera
mechamogera / jmockit_System_getenv.java
Created May 22, 2012
jmokitによる環境変数(System.getenv())の追加
View jmockit_System_getenv.java
package mymock.test;
import junit.framework.TestCase;
import mockit.Mocked;
import mockit.NonStrictExpectations;
import java.util.Map;
public class SystemTest extends TestCase {
private Map<String, String> envs = null;
@mechamogera
mechamogera / capybara_dsl_test.rb
Created May 22, 2012
capybara(webdriver)を用いてyahooで検索する
View capybara_dsl_test.rb
# -*- encoding: UTF-8 -*-
gem 'capybara', '>= 1.1.2'
gem 'selenium-webdriver' ,'>= 2.20.0'
require 'capybara'
require 'capybara/dsl'
require "selenium-webdriver"
include Capybara::DSL
# ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil # proxyを使わない場合
@mechamogera
mechamogera / getCsvLastLineFirstColumnValue.js
Created Jul 2, 2012
最終行の最初のカラムを数値として取得するjavascriptのサンプル
View getCsvLastLineFirstColumnValue.js
function getCsvLastLineFirstColumnValue(text) {
var lines = text.split("\n");
var i = 0;
for (i = 0; i < lines.length; i++) {
var items = lines[lines.length - 1 -i].split(",");
var val = parseInt(items[0].replace("\"", ""));
if (isFinite(val)) { // <= NG: val != Number.NaN
return val;
}
}
@mechamogera
mechamogera / show_ec2_dnsname_and_tags.rb
Created Aug 8, 2012
全てのEC2インスタンスのDNS名とタグ表示
View show_ec2_dnsname_and_tags.rb
gem 'aws-sdk'
require 'rubygems'
require 'aws-sdk'
ec2 = AWS::EC2.new(:access_key_id => nil,
           :secret_access_key => nil,
:proxy_uri => ENV['HTTPS_PROXY'] || ENV['https_proxy'] || ENV['HTTP_PROXY'] || ENV['http_proxy'])
ec2 = ec2.regions['ap-northeast-1']
ec2.instances.each do |x|
puts x.dns_name
@mechamogera
mechamogera / show_title.js
Created Aug 9, 2012
タイトル表示ブックマークレット
View show_title.js
javascript:(function(){window.alert(document.title)})();
@mechamogera
mechamogera / s3_downloader.rb
Created Aug 9, 2012
AWSの簡易S3ダウンロードRubyスクリプト
View s3_downloader.rb
require 'rubygems'
gem 'aws-sdk'
require 'aws'
require 'optparse'
access_key_id = nil
secret_access_key = nil
endpoint = 's3-ap-northeast-1.amazonaws.com'
bucket = nil
object_key = nil