Skip to content

Instantly share code, notes, and snippets.

@j3tm0t0
j3tm0t0 / gist:1509338
Created December 22, 2011 07:17
check instance shutdown behavior of instances in all regions
for region in `ec2-describe-regions | awk '{print $2}'` ; do for i in `ec2-describe-instances --region $region -F "root-device-type=ebs" | grep ^INSTANCE | awK '{print $2}'` ; do echo -n "$region " ; ec2-describe-instance-attribute --region $region --instance-initiated-shutdown-behavior $i ; done ; done
@j3tm0t0
j3tm0t0 / s3upload.ps1
Created January 27, 2012 03:20
upload files in some directory to s3 bucket
Add-Type -Path "C:\Program Files\AWS SDK for .NET\bin\AWSSDK.dll"
$secretKeyID="secretkeyid"
$secretAccessKeyID="accesskeyid"
$client=[Amazon.AWSClientFactory]::CreateAmazonS3Client($secretAccessKeyID,$secretKeyID)
$backup_directory="C:\hoge\"
foreach($file in Get-ChildItem -Path $backup_directory){
@j3tm0t0
j3tm0t0 / gist:1918684
Created February 26, 2012 19:58
Monitor Google Reader Unread Count with CloudWatch
#!/usr/bin/python
# coding=utf-8
# http://moimoitei.blogspot.com/2011/03/google-python-google-reader-api.html を参考にさせていただきました
import gdata.service
import json
import re
import boto
@j3tm0t0
j3tm0t0 / s3client.ps1
Created March 8, 2012 11:53
S3 Client .NET
Add-Type -Path "C:\Program Files\AWS SDK for .NET\bin\AWSSDK.dll"
$secretKeyID="secretkeyid"
$secretAccessKeyID="accesskeyid"
$client=[Amazon.AWSClientFactory]::CreateAmazonS3Client($secretAccessKeyID,$secretKeyID)
$backup_directory="C:\target\"
foreach($file in Get-ChildItem -Path $backup_directory){
@j3tm0t0
j3tm0t0 / Program.cs
Created March 12, 2012 21:36
Route53 Client Sample of AWS SDK for .NET C#
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Amazon;
using Amazon.Route53;
using Amazon.Route53.Model;
#!/usr/bin/env perl
$|=1;
for(;;)
{
print ".";
sleep 1;
}
@j3tm0t0
j3tm0t0 / ip_mapper.rb
Created April 18, 2012 20:35
mapper for S3 accesslog IP address check
#!/usr/bin/env ruby
ARGF.each do |line|
line = line.chomp
data = line.split(/ /)
# IP address is 5th column if split by space
ip = data[4]
key = ip
@j3tm0t0
j3tm0t0 / domain_mapper.rb
Created April 18, 2012 20:37
mapper to check domain of IP
#!/usr/bin/env ruby
require 'socket'
ARGF.each do |line|
line = line.chomp
data = line.split(/\t/)
ip = data[0]
# resolve IP to hostname and split by '.'
hostname=Socket.getnameinfo([nil, nil, nil, ip])[0]
@j3tm0t0
j3tm0t0 / reducer.rb
Created April 18, 2012 20:38
simple aggregator
#!/usr/bin/env ruby
# Ruby code for reduce.rb
prev_key = nil
key_total = 0
ARGF.each do |line|
# remove any newline
line = line.chomp
@j3tm0t0
j3tm0t0 / NiconicoToggleNew.user.js
Created May 3, 2012 12:14
NicoNico Ranking Filter (switch view all or newly uploaded with 'v' key)
// ==UserScript==
// @name NiconicoToggleNew
// @namespace j3tm0t0.gmail.com
// @description Toggle Showing All or New
// @include http://www.nicovideo.jp/ranking/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// ==/UserScript==
(function(){
var onKeyDown = function(event)