2021-06-13

AWS essentials - 2 - try Java SDK - S3 example

1. Set up env (this step is done before)

https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html

2. Get the code from ASW Java SDK 

2.1. Set up pom.xml

(waiting for IntelliJ finished it's background tasks,indexing etc)

(I'd use Java 11,  not 1.7)

(dealing with duplicates in pom.xml - "build" section)

ok, the issue is fixed - it's time to run the code

find AWS SDK for Java 2.0 documentation examples

(fixing missing  imports: org.apache.logging.log4j.Logger;TestInstance)

Looks like all the issues are fixed - time to run the test - confirm S3 bucket is created

the bucket is created - bucket-name-2021-06-13, it is empty now - let's upload a file - it says "Test 3 passed" - let's see AWS S3 contents - looks good: the file asdf.txt is copied to S3 as "asdf.in.s3.txt"


2021-06-09

AWS essentials - Step 1 - Create AIM admin user


 1. Create IAM user (we should not use AWS Root account for programmatic access to AWS - we will create corresponding IAM user instead)

2. Install AWS CLI - Command Line Interface

for Linux:
https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html#cliv2-linux-install
 
for Windows:
https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html#cliv2-windows-install 
 
3. Set up AWS credentials
you may use default (us-east-1) region. I will use eu-central-1 for now.

4. Make sure your user is able to connect AWS resources - for example, let's examine S3 access
$ aws s3 mb s3://bucket-name-2021-06-09
and from AWS UI we see the bucket is created: bucket-name-2021-06-09
 
So, first step is done - we've created IAM user and confirmed it has access to AWS 
 
SIMPLE MONTHLY CALCULATOR: 
https://calculator.s3.amazonaws.com/index.html
A newer version of the S3 calculator is available 
https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/home.html
AWS Code Sample: 
https://docs.aws.amazon.com/code-samples/latest/catalog/code-catalog-javav2-example_code-ses.html 
https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/example_code/ses 

AWS SDK for Java, version 2:

https://docs.aws.amazon.com/sdk-for-java/index.html

2021-05-08

Простой надежный прерыватель указателя поворотов

Не претендую на оригинальность решения, если где-то кто-то раньше опубликовал подобное - пишите, добавлю ссылку в описании

 



2021-03-11

AWS

 aws lambda invoke --function-name=<fn> --region=us-west-1 out.txt

asw s3 ls

awsconsole > my security credentials > Access keys
 aws configure


aws ec2 describe-regions

aws s3 mb s3://asfg

aws s3 sync s3://asdf --delete

aws s3 cp /path/to/file s3://sample_bucket --acl public-read


    final static String ACCESS_KEY = "";
final static String SECRET_KEY = "";
final static Regions REGION = Regions.EU_CENTRAL_1;


// final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient();
final AmazonS3 s3 = AmazonS3ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(ACCESS_KEY, SECRET_KEY)))
.withRegion(REGION)
.build();
List<Bucket> list = s3.listBuckets();

 

2021-02-26

Windows cleanup

win+r disk cleanup

win+r %temp%

Select the Start button, then select Settings > Apps > Startup.

 

Ubuntu autorun

alt+F2 gnome-session-properties

 gnome-startup-applications

2021-02-24

AWS

SIMPLE MONTHLY CALCULATOR
https://calculator.s3.amazonaws.com/index.html
   

AWS Free Tier
https://aws.amazon.com/free/?nc2=smc&all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc&awsf.Free%20Tier%20Categories=categories%23databases

aws configure

aws dynamodb describe-table --table-name BaseballStats

 aws dynamodb batch-write-item --request-items file://./teams.json

aws dynamodb scan --return-consumed-capacity "TOTAL" --table-name BaseballStats

 aws ec2 describe-instances --profile prod-user


AWS credentials provider chain that looks for credentials in this order:

  • Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (RECOMMENDED since they are recognized by all the AWS SDKs and CLI except for .NET), or AWS_ACCESS_KEY and AWS_SECRET_KEY (only recognized by Java SDK)
  • Java System Properties - aws.accessKeyId and aws.secretKey
  • Web Identity Token credentials from the environment or container
  • Credential profiles file at the default location (~/.aws/credentials) shared by all AWS SDKs and the AWS CLI
  • Credentials delivered through the Amazon EC2 container service if AWS_CONTAINER_CREDENTIALS_RELATIVE_URI" environment variable is set and security manager has permission to access the variable,
  • Instance profile credentials delivered through the Amazon EC2 metadata service

Credential retrieval order

sudo yum remove java-1.6.

sudo yum install java-1.8.0-openjdk-devel

sudo alternatives --config java

sudo yum install apache-maven

mvn -v

export JAVA_HOME=

mvn -v


aws sr mb s3://asdf.com

aws s3 ls s3://asdf.com


./mvnw clean install

maven reload all projects

./mvnw clean verify

2021-01-14

RESTfull API

REST API Architectural Constraints:

 A Restful system consists of a:

  • client who requests for the resources.
  • server who has the resources.

 Architectural Constraints of RESTful API: 

  • Uniform Interface
  • Stateless
  • Cacheable
  • Client-Server
  • Layered System
  • Code on Demand

RESTfull = REST over HTTP

GET 200 OK 404 Not Found
POST 201 Created 404 Not Found
401 Unauthoriized
409 Conflict
PUT
PATCH
200 OK 404 Not Found
401 Unauthoriized
405 Method Not Allowed
DELETE 200 OK 404 Not Found
401 Unauthoriized
OPTIONS 200 OK
HEAD 200 OK 404 Not Found

Response code:
1xx Information
2xx Success
3xx Redirect
4xx Client error
   400 - Bad request
   401 - Unauthorized
   403 - Forbidden
   404 - Not found
   405 - Method not allowed
5xx Server error

https://restcountries.com/#endpoints-all

2020-11-12

MySQL

 connect phpMyAdmin to localhost:3307


https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-ubuntu-18-04#step-2-%E2%80%94-installing-mysql


vim /etc/phpmyadmin/config-db.php

/etc/init.d/apache2 restart
 

ALTER USER 'asdf'@'%' IDENTIFIED WITH mysql_native_password
BY '123';
FLUSH PRIVILEGES;

SELECT user,authentication_string,plugin,host FROM mysql.user;

2020-11-09

MS SQL

https://docs.microsoft.com/en-us/sql/relational-databases/databases/view-a-list-of-databases-on-an-instance-of-sql-server?view=sql-server-ver15 

SELECT name, database_id, create_date FROM sys.databases ; GO 

SELECT name FROM sys.databases ;

USE AdventureWorks2012;

SELECT DATEADD(month, 1, '20060830');

UPDATE column SET am=DATEADD(month, 1, column)   

2020-11-03

AMD compatibility

 https://dlcdnets.asus.com/pub/ASUS/mb/SocketAM4/PRIME_A320M-E/Memory_QVL_for_AMD_Ryzen_2nd_Generation_Processors.pdf

 https://www.amd.com/en/products/apu/7th-gen-a6-9500e-apu

https://dlcdnets.asus.com/pub/ASUS/mb/LGA1151/Z170-K/E11133_MB_Pin_Definition_v2_web_only.pdf 

https://dlcdnets.asus.com/pub/ASUS/mb/SocketAM4/PRIME_A320M-E/PRIME_A320M-E_Devices_report.pdf?_ga=2.150868278.121035418.1589210573-1092435267.1587983989