Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View atushi's full-sized avatar

Atushi Yamazaki atushi

View GitHub Profile
@atushi
atushi / How_to_create_the_tomcat_pid_file.md
Last active December 21, 2015 13:49
How to create the Tomcat pid file.

How to create the Tomcat pid file.

You can easily to create the pid file by the CATALINA_PID which is catalina.sh supports it.

e.g ~/.bashrc
export CATALINA_PID=/usr/local/tomcat/tomcat.pid

Run the tomcat with to create the pid file.

> ./startup.sh
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

@atushi
atushi / How_to_use_the_CloudWatch_API_about_getting_the_instance_status_with_proxy.sh
Created August 22, 2013 11:56
How to use the Cloud Watch API about getting the instance status with proxy.
#!/bin/bash
# setting for proxy
export EC2_JVM_ARGS="-Dhttp.proxySet=true -DproxyHost=YOURPROXYHOST -DproxyPort=YOURPROXYPORT"
export SERVICE_JVM_ARGS=${EC2_JVM_ARGS}
# setting for cloud watch
export AWS_CREDENTIAL_FILE=$AWS_CLOUDWATCH_HOME/credentials
export AWS_CLOUDWATCH_URL=https://monitoring.amazonaws.com
export PATH=$AWS_CLOUDWATCH_HOME/bin:$PATH
@atushi
atushi / projecteuler7.rb
Last active December 19, 2015 17:48
Project Euler . Problem 7 . 10001st prime : By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number?
$TARGETNUM = 10001
$primeNum = []
$i = 1
$cnt = 0
loop do
flag = true
x = 2
while x<$i
# p x
if $i % x==0 then
@atushi
atushi / projecteuler6.js
Created July 14, 2013 06:23
Project Euler . Problem 6 . Sum square difference : The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)2 = 552 = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 302…
var MAXNUM = 100;
var sumA = 0;
for (var i=1; i<=MAXNUM; i++) {
sumA = sumA + (i*i)
}
var sumB = 0;
for (var i=1; i<=MAXNUM; i++) {
sumB = sumB + i
}
sumB = (sumB * sumB)
@atushi
atushi / projecteuler5.rb
Created July 14, 2013 06:15
Project Euler . Problem 5 . Smallest multiple : 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
$MAXNUM = 20
$target = [$MAXNUM]
$x = $MAXNUM
p 'Target : ' + $x.to_s
while $x >= 2
if $MAXNUM % $x != 0 then
$target.push($x)
p 'Target : ' + $x.to_s
end
$x -= 1
@atushi
atushi / projecteuler4.js
Created July 14, 2013 03:41
Project Euler . Problem 4 . Largest palindrome product : A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers.
var check = function() {
rtnNum = a*b;
console.log(a + ' * ' + b + ' = ' + rtnNum);
strAns = String(rtnNum);
flag = true;
// check
for (var x=0; x<strAns.length/2; x++) {
//console.log('strAns[x] : ' + strAns[x]);
//console.log('strAns[strAns.length-(x+1)] : ' + strAns[strAns.length-(x+1)]);
if (strAns[x] != strAns[strAns.length-(x+1)]) { flag = false; return 0; }
@atushi
atushi / projecteuler3.js
Created July 12, 2013 10:50
Project Euler . Problem 3 . Largest prime factor : The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ?
var TARGETNUM = 600851475143;
var t = TARGETNUM;
var i = 2;
var answer = 0;
while (true) {
answer = t;
if ((t%i)==0) t=(t/i);
if (t<=i) break;
i++;
}
@atushi
atushi / projecteuler2.js
Created July 12, 2013 09:46
Project Euler . Problem 2 . Even Fibonacci numbers : Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the ev…
var TARGETNUM = 4000000;
var i = 0;
var b = 0;
var a = 1;
var answer = 0;
while (true) {
if (b%2==0) answer = answer + b;
tmp = b;
b = a;
if (TARGETNUM < b) break;
@atushi
atushi / projecteuler1.js
Created July 12, 2013 09:23
Project Euler . Problem 1 . Multiples of 3 and 5 : If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.
var TARGETNUM = 1000;
var i = 1;
var answer = 0;
while (true) {
flag = false;
if (TARGETNUM <= i) break;
if ((i%3==0) && (!flag)) { answer = answer + i; flag = true; }
if ((i%5==0) && (!flag)) { answer = answer + i; flag = true; }
i++;
}
@atushi
atushi / How_to_use_the_CloudWatch_API_about_getting_the_JVM_info_with_proxy.sh
Last active February 27, 2018 18:53
How to use the Cloud Watch API about getting the JVM info with proxy.
#!/bin/bash
# setting for proxy
export EC2_JVM_ARGS="-Dhttp.proxySet=true -DproxyHost=YOURPROXYHOST -DproxyPort=YOURPROXYPORT"
export SERVICE_JVM_ARGS=${EC2_JVM_ARGS}
# setting for cloud watch
export AWS_CREDENTIAL_FILE=$AWS_CLOUDWATCH_HOME/credentials
export AWS_CLOUDWATCH_URL=https://monitoring.amazonaws.com
export PATH=$AWS_CLOUDWATCH_HOME/bin:$PATH