set mysql default password

one thing that tripped me up on a new install of mySQL and wonder why I couldn’t get the default password to work and why even the reset methods where not working. well turns out that on Ubuntu 18 the most recent version of mysql server does not use password auth at all for the root user by default. So this means it doesn’t matter what you set it to, it won’t let you use it. it’s expecting you to login from a privileged socket. so

mysql -u root -p

will not work at all, even if you are using the correct password!!! it will deny access no matter what you put in.

Instead you need to use

sudo mysql

that will work with out any password. then once you in you need type in

 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Password you want to use';

then log out and now the bloody thing will finally accept your password

Simple ajax waiting layout in pure CSS

css:

#waiting {
top: 0;
left: 0;
display: none;
position: fixed;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.5) url(‘../default-loader.gif’) no-repeat center center ;
}

 

html:

<body>

..

</body>

js:

$(‘#waiting’).show();

or

$(‘#waiting’).hide();

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);
//    }
}

Tomcat 7 JDBC Session Persistence

as root run:

export CATALINA_OPTS=”-Dorg.apache.catalina.session.StandardSession.ACTIVITY_CHECK=true”

create table in mysql:

createtabletomcat_sessions (
  session_id     varchar(100) notnullprimarykey,
  valid_session  char(1) notnull,
  max_inactive   intnotnull,
  last_access    bigintnotnull,
  app_name       varchar(255),
  session_data   mediumblob,
  KEYkapp_name(app_name)
);
cd /usr/share/java
wget http://search.maven.org/remotecontent?filepath=mysql/mysql-connector-java/5.1.44/mysql-connector-java-5.1.44.jar
cd /usr/share/tomcat7/lib and run:
/usr/share/tomcat7/lib# ln -s ../../java/mysql-connector.jar mysql-connector.jar
in META-INF create context.xml
paste Manager section:
<Context antiJARLocking="true" >
    <Loader className="org.apache.catalina.loader.VirtualWebappLoader"
        virtualClasspath="/home/link/config"
        searchVirtualFirst="true" />

    <Manager className="org.apache.catalina.session.PersistentManager"
             maxIdleBackup="10">
        <Store className="org.apache.catalina.session.JDBCStore"
               connectionURL="jdbc:mysql://localhost/tomcat?user=root&amp;password=password"
               driverName="com.mysql.jdbc.Driver"
               sessionAppCol="app_name"
               sessionDataCol="session_data"
               sessionIdCol="session_id"
               sessionLastAccessedCol="last_access"
               sessionMaxInactiveCol="max_inactive"
               sessionTable="tomcat_sessions"
               sessionValidCol="valid_session" />
    </Manager>
</Context>