Skip to content

Instantly share code, notes, and snippets.

@nagataka
nagataka / ec2-create-snapshot-ext
Created July 9, 2013 15:31
ec2-create-snapshot extension can specifying some tags.
#!/bin/sh
if [ "$1" = "" ]
then
echo usage $0 volume_id [--tag key[=value] [--tag key[=value] ...]]
exit 0
else
snapshotid=`ec2-create-snapshot $1 | awk '{print $2}'`
shift
while [ "$1" != "" ]; do
ec2-create-tags $snapshotid --tag $1
@nagataka
nagataka / ec2-run-instances-with-tagged-volume
Last active December 20, 2015 11:48
create EC2 instance with adding arbitrary number of tags to attached EBS volume.
#!/bin/sh
if [ "$1" = "" ]
then
echo usage $0 key=value [[key=value] ... ]
exit 0
else
instance=`ec2-run-instances ami-39b23d38 | awk '{print $2}' | grep i-`
sleep 3
volume=`ec2-describe-volumes | grep $instance | awk '{print $2}'`
for vol in ${volume[@]}; do
@nagataka
nagataka / shebang.sh
Created August 5, 2013 19:57
This is a script to automate writing shebang at the top of the file. You can add any extension to 'case' statement.
#!/bin/sh
#set this script as alias of editor like
#alias vim='/path/shebang.sh'
if [ "${1}" = "" ]; then
vim
fi
filename=${1}
if [ -e $filename ]; then
vim $filename
@nagataka
nagataka / "Page top" template
Created September 16, 2013 03:48
template of making "page top" link using jquery
//script
$(function() {
topBtn.click(function () {
$('body,html').animate({
scrollTop: 0
}, 1000);
return false;
});
});
@nagataka
nagataka / template for using processing.js
Last active December 23, 2015 16:59
template for using processing.js
<!DOCTYPE html>
<html>
<head>
<title>HERE IS TITLE</title>
<script type="text/javascript" src="processing.js"></script>
<script type="text/javascript">
window.onload = function(){
//var canvas = document.getElementById('canvas1');
//var codeElm = document.getElementById('processing-code');
//var code = codeElm.textContent || codeElm.innerText;
@nagataka
nagataka / removeAd_fb.user.js
Created October 7, 2013 05:35
Greasemonkey script for removing ad from facebook
// ==UserScript==
// @name remove_add.user.js
// @namespace http://nagataka.net/remove_add.user.js
// @include http://*.facebook.com/*
// @include https://*.facebook.com/*
// @version 1
// @grant none
// ==/UserScript==
var rightCol = document.getElementById("rightCol");
rightCol.parentNode.removeChild(rightCol);
@nagataka
nagataka / listS3Objects_notRecomended.html
Created December 9, 2013 09:00
Basic sample to list objects in S3 bucket using AWS SDK for JavaScript ※Not recommended, just a sample coz this code directly include security credentials...
<!DOCTYPE html>
<html>
<head>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.0.0-rc1.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
AWS.config.update({
accessKeyId: ‘YOUR ACCESS KEY ID’,
secretAccessKey: ‘YOUR SECRET ACCESS KEY’
@nagataka
nagataka / identityFederation_fb.html
Created December 9, 2013 12:14
Listing objects in S3 bucket by AWS SDK for javaScript using facebook as Identity Provider.
<!DOCTYPE html>
<html>
<head>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.0.0-rc1.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
//for Identity Federation
var appId = 'YOUR FB APP ID';
var roleArn = 'arn:aws:iam::xxxxxxxxxxxx:role/IdentityFederationRole';
@nagataka
nagataka / dropdownbtn-with-caret
Created December 29, 2013 20:18
tips for using bootstrap dropdown btn with caret
<div class="btn-group">
<button class="btn btn-primary">Manu</span></button>
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="">Action</a></li>
<li><a href="">Action</a></li>
<li class="divider"></li>
<li><a href="">Action</a></li>
</ul>
</div>
@nagataka
nagataka / ocLogin2ec2
Created March 8, 2014 06:10
TeraTerm macro for one click login to your EC2 host
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
username = 'ec2-user'
hostname = '54.xxx.xxx.xx'
keyfile = 'C:\PathToYourAuthenticatedKeyFile\xxxxx.pem'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
msg = hostname
strconcat msg ':22 /ssh /auth=publickey /user='
strconcat msg username
strconcat msg ' /keyfile='