This file contains 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/env python | |
#coding:utf-8 | |
# Exchange usd to any currency, or any currency to usd | |
# help: python convert_usd.py -h | |
import os.path | |
from datetime import date, datetime | |
import argparse | |
import urllib |
This file contains 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
# Clustering with Lance-Williams updating formula | |
# http://ibisforest.org/index.php?Lance-Williams%20updating%20formula | |
calcSquare = (n) -> n * n | |
haversine = (lat1, lng1, lat2, lng2) -> | |
6371000 * 2 * Math.asin(Math.sqrt(Math.pow(Math.sin((lat1 - Math.abs(lat2)) * Math.PI / 180 / 2), 2) + Math.cos(Math.abs(lat1) * Math.PI / 180 ) * Math.cos(Math.abs(lat2) * Math.PI / 180) * Math.pow(Math.sin((lng1 - lng2) * Math.PI / 180 / 2), 2) )) | |
## | |
# calculate distance between 2 numbers |
This file contains 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/env bash | |
set -e | |
abort() { echo "$@" 1>&2; exit 1; } | |
USAGE=" | |
Usage: $0 [-xhn] [-c CAL_NUMBER] [-i INTERVAL] [-t DURATION] (-D DATETIME | -S SECONDS | -M MINUTES | -H HOURS | -d DAYS) TITLE | |
-x) Debug (show all commands) | |
-h) help |
This file contains 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/env bash | |
# reverse arp | |
USAGE=' | |
Example: | |
rarp 00:0a:95:9d:68:16 | |
=> 192.168.0.253 | |
' | |
abort() { |
This file contains 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/env ruby | |
# https://goo.gl/JJ8BaU | |
class Integer | |
def prime? | |
n = self.abs() | |
return true if n == 2 | |
return false if n == 1 || n & 1 == 0 | |
d = n-1 # nは奇数だからdは偶数 | |
d >>= 1 while d & 1 == 0 # n-1 = d * 2^s |
This file contains 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/env bash | |
# read from argument or stdin | |
mask="$1"; [[ -z "$mask" ]] && read -r mask < /dev/stdin | |
# remove 0x | |
mask="${mask##0x}" | |
count=0 | |
while [ "$mask" != "" ]; do |
This file contains 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
# https://github.com/docker/distribution/blob/master/docs/configuration.md | |
# https://github.com/docker/distribution/blob/master/cmd/registry/config-example.yml | |
# usage: | |
# docker run -d -p 5000:5000 --name registry \ | |
# -v /path/to/this/config.yml:/etc/docker/registry/config.yml \ | |
# -e REGISTRY_STORAGE_S3_ACCESSKEY= \ | |
# -e REGISTRY_STORAGE_S3_SECRETKEY= \ | |
# -e REGISTRY_STORAGE_S3_REGION= \ | |
# -e REGISTRY_STORAGE_S3_BUCKET= \ |
This file contains 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
server { | |
listen 80; | |
charset utf-8; | |
auth_basic "Restricted"; | |
auth_basic_user_file /etc/nginx/.htpasswd; | |
location / { | |
root /usr/share/nginx/html; | |
index index.html; |
This file contains 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
# : how to create key pair which is used to ssh login to ec2 instances | |
# keypair_name=mykey1 | |
# ssh-keygen -t rsa -f ~/.ssh/${keypair_name} | |
# aws ec2 import-key-pair --key-name ${keypair_name} --public-key-material file://$HOME/.ssh/${keypair_name}.pub | |
# : modify these variables to fit your situation | |
# StackName=ec2-run-instance | |
# yaml2json > /tmp/parameters.json << 'EOF' | |
# - ParameterKey: KeyName | |
# ParameterValue: mykey1 |
This file contains 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/env node | |
/* | |
# Usage | |
``` | |
: list objects | |
node aws-sdk-tips.js -b bucket-name -k path/to/dir |
OlderNewer