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
export PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/usr/lib/pkgconfig | |
export PATH=/usr/bin:$PATH | |
export LDFLAGS=-L/usr/lib64:/usr/lib | |
export LD_LIBRARY_PATH=/usr/lib64:/usr/lib | |
export CPPFLAGS=-I/usr/include | |
PREFIX=/usr | |
sudo yum-config-manager --enable epel | |
sudo yum -y update && sudo yum -y upgrade |
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 python3 | |
""" | |
Using Fermat's little theorem to calculate nCk mod m, for k < m and m is prime | |
Two versions: | |
1. Pre-Compute factorials and multiplicative inverses in O(n*logn) --> later lookup in O(1) | |
2. Compute directly --> no lookup --> each time O(n) | |
""" |
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 |
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
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
# 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
#!/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
#!/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 | |
# 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 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 |
NewerOlder