log queries with high execution time in postgresql

nano /etc/postgresql/9.5/main/postgresql.conf

change: log_min_duration_statement = 1000

restart

tail -f /var/log/postgresql/postgresql-9.5-main.log -n 500
Advertisements

close out port with iptables

iptables -I INPUT -d 127.0.0.1/8 -j ACCEPT
iptables -A INPUT -p tcp –dport 8080 -j DROP

If you wantpersistent:

The easy way is to use iptables-persistent.

Install iptables-persistent:

sudo apt-get install iptables-persistent

After it’s installed, you can save/reload iptables rules anytime:

sudo /etc/init.d/iptables-persistent save 
sudo /etc/init.d/iptables-persistent reload

postgres import export

Export

pg_dump -c -h 127.0.0.1 -U linkin –column-inserts linkin > dump.sql

IMPORT

in psql:
REVOKE CONNECT ON DATABASE linkin FROM public;

SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = ‘linkin’;

drop database linkin;
CREATE DATABASE linkin;
GRANT ALL privileges ON DATABASE linkin TO linkin;

 

in terminal:
psql –file=dump.sql –host=127.0.0.1 –port=5432 –username=linkin –dbname=linkin

java wsdl import for wsdl with java-reserved word

wsimport -keep -b bind.xml -J-Djavax.xml.accessExternalSchema=all https://policyrw.mtsbu.ua/v3/ChangeContracts.svc?wsdl

 

<?xml version=”1.0″ encoding=”UTF-8″?>
<jaxws:bindings wsdlLocation=”https://policyrw.mtsbu.ua/v3/ChangeContracts.svc?wsdl=wsdl0&#8243;
xmlns:jaxws=”http://java.sun.com/xml/ns/jaxws&#8221;
xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/”&gt;
<jaxws:bindings node=”wsdl:definitions/wsdl:portType[@name=’IDigitalPolicy’]/wsdl:operation[@name=’New’]”>
<jaxws:method name=”MyNewContract”/>
</jaxws:bindings>
</jaxws:bindings>

digitalocean spaces example

import boto3

# Initialize a session using Spaces
session = boto3.session.Session()
client = session.client('s3',
                        region_name='ams3',
                        endpoint_url='https://ams3.digitaloceanspaces.com',
                        aws_access_key_id='xxx',
                        aws_secret_access_key='yyy')

unique_name = ['play', 'strim', 'strim-in', 'crowd']
for s in unique_name:
    client.create_bucket(Bucket=s)

# List all Spaces in the region
# response = client.list_buckets()
# for s in [space['Name'] for space in response['Buckets']]:
#     print(s)

# Add a file to a Space
res = client.upload_file('/home/icdu/projects/link/amazonTest/test.docx', 'play', 'test2.docx')
print res

digitalocean spaces java example

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.util.List;

import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.Bucket;
import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.PutObjectRequest;
import com.amazonaws.services.s3.model.S3ObjectSummary;

public class Test {

    private static final String SUFFIX = "/";

    public static void main(String[] args) {
        AWSCredentials credentials = new BasicAWSCredentials(
                "xxx",
                "yyy");

        AmazonS3 s3client = new AmazonS3Client(credentials);
        s3client.setEndpoint("https://ams3.digitaloceanspaces.com");
        String bucketName = "ubi-example-bucket";
        s3client.createBucket(bucketName);

        for (Bucket bucket : s3client.listBuckets()) {
            System.out.println(" - " + bucket.getName());
        }

        String folderName = "testfolder";
        createFolder(bucketName, folderName, s3client);

        String fileName = folderName + SUFFIX + "test.docx";
        s3client.putObject(new PutObjectRequest(bucketName, fileName,
                new File("/home/icdu/projects/link/amazonTest/test.docx"))
                .withCannedAcl(CannedAccessControlList.PublicRead));

//        deleteFolder(bucketName, folderName, s3client);
//        s3client.deleteBucket(bucketName);
    }

    public static void createFolder(String bucketName, String folderName, AmazonS3 client) {
        ObjectMetadata metadata = new ObjectMetadata();
        metadata.setContentLength(0);

        InputStream emptyContent = new ByteArrayInputStream(new byte[0]);

        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName,
                folderName + SUFFIX, emptyContent, metadata);

        client.putObject(putObjectRequest);
    }


//    public static void deleteFolder(String bucketName, String folderName, AmazonS3 client) {
//        List fileList =
//                client.listObjects(bucketName, folderName).getObjectSummaries();
//        for (S3ObjectSummary file : fileList) {
//            client.deleteObject(bucketName, file.getKey());
//        }
//        client.deleteObject(bucketName, folderName);
//    }
}