Q: Spark job submission error on EMR: java.net.URISyntaxException: Expected scheme-specific part at index 3: s3 I submit Spark jobs to EMR via Managed Airflow service of AWS (MWAA). The jobs were running fine with the MWAA version 1.10.12. Recently, AWS released a newer version of MWAA i.e. 2.0.2. I created a new environment with this version and tried submitting the same job to EMR. But it failed with the following error :
Exception in thread "main" java.lang.IllegalArgumentException: java.net.URISyntaxException: Expected scheme-specific part at index 3: s3:
    at org.apache.hadoop.fs.Path.initialize(Path.java:263)
    at org.apache.hadoop.fs.Path.<init>(Path.java:221)
    at org.apache.hadoop.fs.Path.<init>(Path.java:129)
    at org.apache.hadoop.fs.Globber.doGlob(Globber.java:229)
    at org.apache.hadoop.fs.Globber.glob(Globber.java:149)
    at org.apache.hadoop.fs.FileSystem.globStatus(FileSystem.java:2096)
    at org.apache.hadoop.fs.FileSystem.globStatus(FileSystem.java:2078)
    at org.apache.spark.deploy.DependencyUtils$.resolveGlobPath(DependencyUtils.scala:192)
    at org.apache.spark.deploy.DependencyUtils$.$anonfun$resolveGlobPaths$2(DependencyUtils.scala:147)
    at org.apache.spark.deploy.DependencyUtils$.$anonfun$resolveGlobPaths$2$adapted(DependencyUtils.scala:145)
    at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:245)
    at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
    at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:38)
    at scala.collection.TraversableLike.flatMap(TraversableLike.scala:245)
    at scala.collection.TraversableLike.flatMap$(TraversableLike.scala:242)
    at scala.collection.AbstractTraversable.flatMap(Traversable.scala:108)
    at org.apache.spark.deploy.DependencyUtils$.resolveGlobPaths(DependencyUtils.scala:145)
    at org.apache.spark.deploy.SparkSubmit.$anonfun$prepareSubmitEnvironment$5(SparkSubmit.scala:364)
    at scala.Option.map(Option.scala:230)
    at org.apache.spark.deploy.SparkSubmit.prepareSubmitEnvironment(SparkSubmit.scala:364)
    at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:902)
    at org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:180)
    at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:203)
    at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:90)
    at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:1038)
    at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:1047)
    at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: java.net.URISyntaxException: Expected scheme-specific part at index 3: s3:
    at java.net.URI$Parser.fail(URI.java:2847)
    at java.net.URI$Parser.failExpecting(URI.java:2853)
    at java.net.URI$Parser.parse(URI.java:3056)
    at java.net.URI.<init>(URI.java:746)
    at org.apache.hadoop.fs.Path.initialize(Path.java:260)
    ... 27 more
Command exiting with ret '1'

The spark-submit command looks like this:
spark-submit --deploy-mode cluster
             --master yarn
             --queue low
             --jars s3://bucket-name/jars/mysql-connector-java-8.0.20.jar,s3://bucket-name/jars/postgresql-42.1.1.jar,s3://bucket-name/jars/delta-core_2.12-1.0.0.jar
             --py-files s3://bucket-name/dependencies/spark.py, s3://bucket-name/dependencies/helper_functions.py
             --files s3://bucket-name/configs/spark_config.json
             s3://bucket-name/jobs/data_processor.py [command-line-args]

The job submission failed in under 10 seconds. Hence, the YARN application ID did not get created.
What I tried to resolve the error:

*

*I added amazon related package to requirements.txt:

apache-airflow[mysql]==2.0.2
pycryptodome==3.9.9
apache-airflow-providers-amazon==1.3.0

*I changed the import statements from:

from airflow.contrib.operators.emr_add_steps_operator import EmrAddStepsOperator
from airflow.contrib.operators.emr_create_job_flow_operator import EmrCreateJobFlowOperator
from airflow.contrib.operators.emr_terminate_job_flow_operator import EmrTerminateJobFlowOperator
from airflow.contrib.sensors.emr_step_sensor import EmrStepSensor
from airflow.hooks.S3_hook import S3Hook
from airflow.operators.python_operator import PythonOperator
from airflow.operators.bash_operator import BashOperator
from airflow.models import Variable

to
from airflow.providers.amazon.aws.operators.emr_create_job_flow import EmrCreateJobFlowOperator
from airflow.providers.amazon.aws.operators.emr_add_steps import EmrAddStepsOperator
from airflow.providers.amazon.aws.operators.emr_terminate_job_flow import EmrTerminateJobFlowOperator
from airflow.providers.amazon.aws.sensors.emr_step import EmrStepSensor
from airflow.providers.amazon.aws.hooks.s3 import S3Hook
from airflow.operators.python import PythonOperator
from airflow.operators.bash import BashOperator
from airflow import DAG
from airflow.models import Variable

*Changed the URI scheme to s3n and s3a

I checked the official documentation and blogs on MWAA as well as Airflow 2.0.2 and made the above changes. But nothing has worked so far. I seek help in resolving this error at the earliest. Thanks in advance


Q: How to iterate column in CSV output on this beautifulsoup Python script? I have a beautifulsoup Python script that looks for href links in a component on a website and outputs those links line-by-line to a CSV file. I'm planning on running the script every day via a cron job, and I'd like to add a second column in the CSV labeled "Number of times seen". So when the script runs, if it finds a link already in the list, it would just add to the number in that column. For example, if it's the second time it's seen a particular link, it would be "N+1" or just 2 in that column. But if it's the first time the Python script saw that link, it would just add the link to the bottom fo the list. I'm not sure how to attack this as I'm pretty new to Python.
I've developed the Python script to scrape the links from the component on all of the pages in a XML sitemap. However, I'm not sure how to iterate on the "Number of times seen" column in the CSV output as the cron job runs the script every day. I don't want the file to be overwritten, I only want the "Number of times seen" column to iterate, or if it's the first time the link was seen, for the link to be put at the bottom of the list.
Here's the Python script that I have so far:
sitemap_url = 'https://www.lowes.com/sitemap/navigation0.xml'

import requests
from bs4 import BeautifulSoup
import csv
from tqdm import tqdm
import time

# def get_urls(url):
page = requests.get(sitemap_url)
soup = BeautifulSoup(page.content, 'html.parser')
links = [element.text for element in soup.findAll('loc')]
# return links
print('Found {:,} URLs in the sitemap! Now beginning crawl of each URL...'\
        .format(len(links)))

csv_file = open('cms_scrape.csv', 'w')
csv_writer = csv.writer(csv_file)
csv_writer.writerow(['hrefs', 'Number of times seen:'])

for i in tqdm(links):
    #print("beginning of crawler code")
    r = requests.get(i)
    data = r.text

    soup = BeautifulSoup(data, 'lxml')

    all_a = soup.select('.carousel-small.seo-category-widget a')
    for a in all_a:
         hrefs = a['href']
         print(hrefs)
         csv_writer.writerow([hrefs, 1])

csv_file.close()

Current state: Currently, every time the script runs, the "Number of times seen:" column in the CSV output is overwritten.
Desired state: I want the "Number of times seen:" column to iterate whenever the script finds a link it's seen in a previous crawl, or if it's the first time that link has been seen, I want it to say "1" in this column in the CSV.
Thanks a ton for your help!!

A: So, this isn't actually a questing about bs4, but more about how to handle data structures in python.
Your script lacks the part that loads the data you already know. One way to go about this would be the build a dict that has all your hrefs as keys and then the count as value.
So given a csv with rows like this...
href,seen_count
https://google.com/1234,4
https://google.com/3241,2

... you first need to build the dict
csv_list = list(open("cms_scrape.csv", "r", encoding="utf-8"))
# we skip the first line, since it hold your header and not data
csv_list = csv_list[1:]

# now we convert this to a dict
hrefs_dict = {}
for line in csv_list:
    url, count = line.split(",")
    # remove linebreak from count and convert to int
    count = int(count.strip())
    hrefs_dict[url] = count

That yields a dict like this:
{
  "https://google.com/1234": 4,
  "https://google.com/3241": 2
}

Now you can check if all hrefs you come across exist as a key in this dict. If yes - increase the count by one. If no, insert the href in the dict and se the count to 1.
To apply this to your code I'd suggest you scrape the data first and write to file once all scraping is completed. Like so:
for i in tqdm(links):
    #print("beginning of crawler code")
    r = requests.get(i)
    data = r.text
    soup = BeautifulSoup(data, 'lxml')
    all_a = soup.select('.carousel-small.seo-category-widget a')
    for a in all_a:
         href = a['href']
         print(href)
         # if href is a key in hrefs_dict increase the value by one
         if href in hrefs_dict:
             hrefs_dict[href] += 1

         # else insert it into the hrefs_dict and set the count to 1
         else:
             hrefs_dict[href] = 1

Now when the scraping is done, go through every line in the dict and write it to your file. It's generally recommended that you use context managers when you write to files (to avoid blocking if you accidentally forget to close the file). So the "with" takes care of both the opening and closing of the file:
with open('cms_scrape.csv', 'w') as csv_file:
    csv_writer = csv.writer(csv_file)
    csv_writer.writerow(['hrefs', 'Number of times seen:'])

    # loop through the hrefs_dict
    for href, count in hrefs_dict.items():
        csv_writer.writerow([href, count])

So if you don't actually have to use a csv-file for this I'd suggest using JSON or Pickle. That way you can read and store the dict without needing to convert back and forth to csv.
I hope this solves your problems...


Q: Can I choose the kind of org that is provisioned via trialforce? We have an OEM managed package and we provision new org to customers during the trial. Most of the customers run out of storage during the trial. Can we decide the kind of organization that is provisioned during trial via trialforce?
What is the best way to solve this problem? One solution is to create a case for Salesforce to provision more storage.

A: You can create any org you want from the environment hub although if you use a template I believe that the org will be the same type as your TSO (someone will correct me if I am wrong as it has been over a year since I created my last Trialforce Org):

The template is a snapshot or exact copy of your TSO at a specific
  instance in time

https://developer.salesforce.com/docs/atlas.en-us.packagingGuide.meta/packagingGuide/environment_hub_create_organization.htm

You can create new organizations directly from the Environment Hub,
  for the following purposes.

*

*Development — Development organizations for creating and uploading managed packages.

*Test/Demo— Trial organizations created for test and demonstration purposes, similar to organizations created from
  www.salesforce.com/trial. You can specify a Trialforce template for
  creating trial organizations. This enables you to configure and test
  exactly how your prospects experience the trial.

*Trialforce—You can create Trialforce Source Organizations (TSOs) from the Environment Hub, as an alternative to using a Trialforce
  Management Organization (TMO).


Q: Will reconfiguring Zabbix clear out the database? I have a quick question. I need Zabbix to have access to CURL. However, I don't think that when it was installed the with-libcurl was set:
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl

Is it safe to run that command again even though we have Zabbix setup and monitoring all of our servers? We really need CURL support however we don't want to lose our current monitoring setup.
Thanks!

A: OK, so if anyone else has this question, no it does not. I took a backup of the DB just in-case.

A: I haven't done it but I don't see why it would.
The server binary you built is just a user of the database. You had to loaded the SQL files during deployment to initialize it, not the server binary.
All it's going to do is access the database and process events and triggers.


Q: In search for a replacement for w3c.dom.Node Is there a library for Java that replaces the org.w3c.dom.Node with some better Node implementation?
I's so sick of the bad implementation of the whole default HTML parsing in Java.

A: For HTML parsing, I'd suggest jsoup:

jsoup is a Java library for working with real-world HTML. It provides
  a very convenient API for extracting and manipulating data, using the
  best of DOM, CSS, and jquery-like methods.
jsoup implements the WHATWG HTML5 specification, and parses HTML to
  the same DOM as modern browsers do.

A: After some searching I found Jericho.
I use XPath with the help of this article and Jaxen
I'm just not sure if this is the best way...


Q: how can I completely disable the horizontal scrolling system enter image description herewhen I one line too long, my full editor get horizontally large & scrollbar comes (like 1st image)
enter image description here
I want long lines will break in multiple short lines
(like 2nd image)

A: You have to turn on the WORD-WRAP Feature in Visual Studio Code.
There are 2 ways to do this:

*

*By using the View menu (View* → Toggle Word Wrap)

*By using the Keyboard Shortcut
Windows/Linux: ALT + Z
Mac: ⌥ + Z


Q: Styling last menu item on multilevel menu I'm trying to stylize the last menu choice on a menu that has dropdowns in it.
This is kind of what it looks like.  The > means it's a drop down.
Home   AAA>  BBB>  CCC   DDD  Contact Donate
I'm trying to make JUST the Donate choice have a red background with white letters, so I've put this in:
#main-nav  li:last-child a {
   color:#ffffff;
   background-color:rgb(178, 45, 58);
   border-top-right-radius: 5px;
   border-bottom-right-radius: 5px;
   padding: 5px;
}

But that is making the last item in each of the dropdowns red too!
How can I make just the last item of the main menu be stylized?
Thanks!

A: You need to target the immediate children of the navigation list. Use this selector:
#main-nav > ul > li:last-child > a

A: I'm going to post this, but please accept Chris' answer as his is right, except he did not have the correct Id name for the navigation.
#navigation > ul > li:last-child > a{
    color:Red;
}

Here is a JSFiddle demonstrating that the 'Donate' is the only thing being turned red.


Q: How to simplify the JS code in this R shiny code? The below code I found at How to display a scaled up image in an popup window on mouse hover or on click event on an image displayed in a rhandsontable cell in RShiny? (but wrapped in Shiny) almost gets at what I'm trying to do with widgets in rhandsontable. But I don't know enough JS to modify it to do what I want.
I'd like to create a column with a question mark in each row of the table, and hovering over the question mark causes explanatory text to appear in a bubble. Sort of like what happens when running the below code, but the below code is more complex because it renders a miniature image in each column row, and hovering over the miniature images causes the image to bubble out large. I'd like to replace the miniature images with question marks, and when hovering over the question mark explanatory text pops up in a bubble, different text for each row. As shown in the below image:

Any recommendations for how to achieve this?
Code:
library(magrittr)
library(htmlwidgets)
library(rhandsontable)
library(shiny)

DF = data.frame(
  comments = c(
    "I would rate it ★★★★☆",
    "This is the book about JavaScript"
  ),
  cover = c(
    "http://ecx.images-amazon.com/images/I/51bRhyVTVGL._SL500_.jpg",
    "http://ecx.images-amazon.com/images/I/51gdVAEfPUL._SL500_.jpg"
  ),
  stringsAsFactors = FALSE
)

ui <- fluidPage(br(),rHandsontableOutput('my_table'))

server <- function(input, output, session) {

  output$my_table <- renderRHandsontable({

    rhandsontable::rhandsontable(DF, allowedTags = "<big>",
        callback = htmlwidgets::JS(
        "$(document).ready(function() {
        $('body').prepend('

');
        // onClick function for all plots (img's)
        $('img:not(.zoomImg)').click(function() {
          $('.zoomImg').attr('src', $(this).attr('src')).css({width: '100%'});
          $('.zoomDiv').css({opacity: '1', width: 'auto', border: '1px solid white', borderRadius: '5px', position: 'fixed', top: '50%', left: '50%', marginRight: '-50%', transform: 'translate(-50%, -50%)', boxShadow: '0px 0px 50px #888888', zIndex: '50', overflow: 'auto', maxHeight: '100%'});
        });
        // onClick function for zoomImg
        $('img.zoomImg').click(function() {
          $('.zoomDiv').css({opacity: '0', width: '0%'});
        });
      });"
      ),
      width = 800, height = 450, rowHeaders = FALSE) %>%
      hot_cols(colWidths = c(200, 80)) %>%
      hot_col(1, renderer = htmlwidgets::JS("safeHtmlRenderer")) %>%
      hot_col(2, renderer = "
        function(instance, td, row, col, prop, value, cellProperties) {
          var escaped = Handsontable.helper.stringify(value),
            img;

          if (escaped.indexOf('http') === 0) {
            img = document.createElement('IMG');
            img.src = value; img.style.width = 'auto'; img.style.height = '80px';

            Handsontable.dom.addEvent(img, 'mousedown', function (e){
              e.preventDefault(); // prevent selection quirk
            });

            Handsontable.dom.empty(td);
            td.appendChild(img);
          }
          else {
            // render as text
            Handsontable.renderers.TextRenderer.apply(this, arguments);
          }
          return td;
        }")
    })
  }

shinyApp(ui, server)

A: Here's an option that doesn't totally do what you're asking, but should get you close if you add some css:

library(magrittr)
library(htmlwidgets)
library(rhandsontable)
library(shiny)

DF = data.frame(
  comments = c(
    "I would rate it ★★★★☆",
    "This is the book about JavaScript"
  ),
  cover = c(
    "https://as1.ftcdn.net/v2/jpg/03/35/13/14/1000_F_335131435_DrHIQjlOKlu3GCXtpFkIG1v0cGgM9vJC.jpg",
    "https://as1.ftcdn.net/v2/jpg/03/35/13/14/1000_F_335131435_DrHIQjlOKlu3GCXtpFkIG1v0cGgM9vJC.jpg"
  ),
  text = c(
    "descriptive text about img 1",
    "descriptive text about img 2"
  ),
  stringsAsFactors = FALSE
)

ui <- fluidPage(br(),rHandsontableOutput('my_table'))

server <- function(input, output, session) {

  output$my_table <- renderRHandsontable({

    rhandsontable::rhandsontable(DF, allowedTags = "<big>",
      width = 800, height = 450, rowHeaders = FALSE) %>%
      hot_cols(colWidths = c(200, 80)) %>%
      hot_col(1, renderer = htmlwidgets::JS("safeHtmlRenderer")) %>%
      hot_col(2, renderer = "
        function(instance, td, row, col, prop, value, cellProperties) {
          var escaped = Handsontable.helper.stringify(value),
            img;

          if (escaped.indexOf('http') === 0) {
            img = document.createElement('IMG');
            img.src = value; img.style.width = 'auto'; img.style.height = '80px';

            Handsontable.dom.addEvent(img, 'mousedown', function (e){
              var exists = document.getElementById('test')
              if (exists === null){
              var textBlock = instance.params.data[[row]][[2]];
              var popup = document.createElement('div');
              popup.className = 'popup';
              popup.id = 'test';
              var cancel = document.createElement('div');
              cancel.className = 'cancel';
              cancel.innerHTML = 'close';
              cancel.onclick = function(e) {
                popup.parentNode.removeChild(popup)
              }
              var message = document.createElement('span');
              message.innerHTML = '' + textBlock + '';
              popup.appendChild(message);
              popup.appendChild(cancel);
              document.body.appendChild(popup);

              }

            });

            Handsontable.dom.empty(td);
            td.appendChild(img);

          }
          else {
            // render as text
            Handsontable.renderers.TextRenderer.apply(this, arguments);
          }
          return td;
        }") %>%
      hot_cols(colWidths = ifelse(names(DF) != "text", 150, 0.1))
  })
}

shinyApp(ui, server)


Q: Is there a way to have SQL server validate object references in Stored Procs? The following code executes fine in SQL Server
create proc IamBrokenAndDontKnowIt as
select * from tablewhichdoesnotexist

Of course if I try to run it, it fails with

Invalid object name 'tablewhichdoesnotexist'.

Is there any way to compile or verify that Stored Proc are valid?

A: You can use
SET FMTONLY ON
EXEC dbo.My_Proc
SET FMTONLY OFF

You'll need to capture the error(s) somehow, but it shouldn't take much to put together a quick utility application that takes advantage of this for finding invalid stored procedures.
I haven't used this extensively, so I don't know if there are any side-effects to look out for.

A: You used to get a warning message when you tried to create a stored procedure like that.  It would say:

Cannot add rows to sysdepends for the current stored procedure because it depends on the missing object 'dbo.nonexistenttable'. The stored procedure will still be created.

For some reason I'm not getting it now, I'm not sure if it's been changed or if there's just some setting that turns the warning on or off.  Regardless, this should give you a hint as to what's happening here.
SQL Server does track dependencies, but only dependencies which actually exist.  Unfortunately, none of the dependency tricks like sp_depends or sp_MSdependencies will work here, because you're looking for missing dependencies.
Even if we could hypothetically come up with a way to check for these missing dependencies, it would still be trivial to concoct something to defeat the check:
CREATE PROCEDURE usp_Broken
AS

DECLARE @sql nvarchar(4000)
SET @sql = N'SELECT * FROM NonExistentTable'
EXEC sp_executesql @sql

You could also try parsing for expressions like "FROM xxx", but it's easy to defeat that too:
CREATE PROCEDURE usp_Broken2
AS

SELECT *
FROM
    NonExistentTable

There really isn't any reliable way to examine a stored procedure and check for missing dependencies without actually running it.
You can use SET FMTONLY ON as Tom H mentions, but be aware that this changes the way that the procedure is "run".  It won't catch some things.  For example, there's nothing stopping you from writing a procedure like this:
CREATE PROCEDURE usp_Broken3
AS

DECLARE @TableName sysname

SELECT @TableName = Name
FROM SomeTable
WHERE ID = 1

DECLARE @sql nvarchar(4000)
SET @sql = N'SELECT * FROM ' + @TableName
EXEC sp_executesql @sql

Let's assume you have a real table named SomeTable and a real row with ID = 1, but with a Name that doesn't refer to any table.  You won't get any errors from this if you wrap it inside a SET FMTONLY ON/OFF block.
That may be a contrived problem, but FMTONLY ON does other weird things like executing every branch of an IF/THEN/ELSE block, which can cause other unexpected errors, so you have to be very specific with your error-handling.
The only truly reliable way to test a procedure is to actually run it, like so:
BEGIN TRAN

BEGIN TRY
    EXEC usp_Broken
END TRY
BEGIN CATCH
    PRINT 'Error'
END CATCH

ROLLBACK

This script will run the procedure in a transaction, take some action on error (in the CATCH), and immediately roll back the transaction.  Of course, even this may have some side-effects, like changing the IDENTITY seed if it inserts into a table (successfully).  Just something to be aware of.
To be honest, I wouldn't touch this problem with a 50-foot pole.

A: No (but read on, see last line)
It's by design: Deferred Name Resolution
Erland Sommarskog raised an MS Connect for SET STRICT_CHECKS ON
The connect request has a workaround (not tried myself):

Use check execution plan. The only
  weakness is that you may need
  permissions to see the execution plan
  first

A: You could run sp_depends (see http://msdn.microsoft.com/en-us/library/ms189487.aspx) and use that information to query the information schema (http://msdn.microsoft.com/en-us/library/ms186778.aspx) to see if all objects exist. From what I read here (http://msdn.microsoft.com/en-us/library/aa214346(SQL.80).aspx) you only need to check referenced tables, which is doable.

A: You could check information_schema.tables to check whether a table exist or not and then execute the code
here is quickly slung function to check
 create function fnTableExist(@TableName varchar(64)) returns int as
    begin
        return (select count(*) from information_schema.tables where table_name=@tableName and Table_type='Base_Table')
    end

go

    if dbo.fnTableExist('eObjects') = 0
        print 'Table exist'
    else
        print 'no suchTable'

like wise you can check for existance of Stored procs / functions in
.INFORMATION_SCHEMA.ROUTINES.Routine_name  for th name of the Stored proc/function

A: In SQL 2005 or higher, you can test a stored procedure using transactions and try/catch:
BEGIN TRANSACTION

BEGIN TRY
  EXEC (@storedproc)
  ROLLBACK TRANSACTION
END TRY
BEGIN CATCH
  WHILE @@TRANCOUNT > 0
    ROLLBACK
END CATCH

The algorithm to test all stored procedures in a database is a bit more complicated, as you need to workaround SSMS restrictions if you have many SPs which return many result sets. See my blog for complete solution.

A: I've just discovered that VS2010 with database projects will do syntax and name reference checking. Seems like the best option.


Q: Dimension of eigenspaces w/o multiplicity Is it possible to show that the sum of the dimensions of all eigenspaces of an n x n matrix cannot be greater than n (in other words, that you cannot find more than n linearly independent eigenvectors), without using the fact that the geometric multiplicity is less than or equal to the algebraic multiplicity?
My text book of algebra indirectly implied this (in explaining how to confirm that a matrix is diagonizable) before introducing the theorem of geometric and algebraic multiplicity. Is there some obvious reason I don't see?

A: In $\mathbb R^n$ you can't have more than $n$ independent vectors (eigen or not) so certainly you can't have more than $n$ independent eigenvectors of any $n\times n$ matrix. This follows immediately by showing that the dimension of $\mathbb R^n$ is $n$, a fact that does not involve any consideration of algebraic or geometric multiplicity of anything.

A: If we denote $E_{\lambda}$ the eigenspace of the eigenvalue $\lambda$, and since $$E_{\lambda_i}\cap E_{\lambda_j}=\{0\}$$ for different eigenvalues $\lambda_i$ and $\lambda_j$ we then find $$\dim(\oplus_iE_{\lambda_i})=\sum_i\dim E_{\lambda_i}\leq n$$


Q: Cannot create "Analysis Services Multidimentional and Datamining" project in Visual Studio 2019 In Visual Studio 2019, I cannot create "Analysis Services Multidimensional and Datamining project" even "Microsoft Analysis Services Projects" extension v2.9.10 is installed and I am able to create "Analysis Services Tabular" project.
Any idea why?

A: I had the same problem.
In extension tab go to -Manage Extensions- -Installed- -Turn off Analysis services extension-
Reopen Visual studio, turn Analysis services extension on.
Reopen Visual studio.
It worked for me :)


Q: Using react hooks, how would you write an event listener dependent on state that does not need to be added and removed every time the state changes? The code below shows a working, but inefficient implementation of an Android BackHandler within React Native to have the app exit after two presses in two seconds. This is implemented using React hooks within the main functional component of the app.
However, due to dependency on a state variable recentlyPressedHardwareBack, the useEffect hook will cleanup then run each time the state changes, causing the BackHandler event listener to be detached and re-attached whenever the back button is pressed. How do you set up this event listener just once without constant creation and deletion, while allowing it to access a changing component state?
const [recentlyPressedHardwareBack, setRecentlyPressedHardwareBack] =
    useState(false);

  useEffect(() => {
    const backHandler = BackHandler.addEventListener(
      'hardwareBackPress',
      () => {
        // Exit app if user pressed the button within last 2 seconds.
        if (recentlyPressedHardwareBack) {
          return false;
        }

        ToastAndroid.show(
          'Press back again to exit the app',
          ToastAndroid.SHORT,
        );

        setRecentlyPressedHardwareBack(true);

        // Toast shows for approx 2 seconds, so this is the valid period for exiting the app.
        setTimeout(() => {
          setRecentlyPressedHardwareBack(false);
        }, 2000);

        // Don't exit yet.
        return true;
      },
    );

    return () => backHandler.remove();
  }, [recentlyPressedHardwareBack]);

A: You could use useRef for this.
const recentlyPressedHardwareBackRef = useRef(false);
useEffect(() => {
    const backHandler = BackHandler.addEventListener(
      'hardwareBackPress',
      () => {
        // Exit app if user pressed the button within last 2 seconds.
        if (recentlyPressedHardwareBackRef.current) {
          return false;
        }

        ToastAndroid.show(
          'Press back again to exit the app',
          ToastAndroid.SHORT,
        );

        recentlyPressedHardwareBackRef.current = true;

        // Toast shows for approx 2 seconds, so this is the valid period for exiting the app.
        setTimeout(() => {
          recentlyPressedHardwareBackRef.current = false;
        }, 2000);

        // Don't exit yet.
        return true;
      },
    );

    return () => backHandler.remove();
}, [])


Q: How to execute simultaneous PHP CLI scripts in Mac I have 50 php files that I would like to run simultaneously from the command line. Right now, I am running them in multiple CLI windows using the code:
php Script1.php
I would like to be able to call one single script file that would execute all 50 php files simultaneously. I have been reading about how to make the command line not wait for the output, but I can't seem to make it work.
I am new to both MAC and Scripting - maybe I don't need a script? Is there another mac based solultion that can do this without me having to open 50 separate terminal windows?

A: You can just add ampersand '&' to separate each command:
php script1.php & php script2.php & php script3.php ...

This ampersand symbol will tell the shell to run command on background.
To check the output, you can redirect it to a file:
php script1.php > script1.log.txt & php script2.php > script2.log.txt

And you can just do a tail on it to read the log:
tail -f script1.log.txt

A: If you script is nicely numbered from 1 to 50, you can try the following in a .command file:
i=1;
while [ $i -lt 51 ]
do
osascript -e 'tell app "Terminal"
    do script "php Script$i.php"
end tell' &
i=$[$i+1]
done

This should open 50 separate terminal windows each running script{$i}.php

A: You could also run them at the same time but not in the background.
php test1.php; php test2.php;

I don't know why you would want to "interact" with the script after its running.


Q: BASH: how to store subshell variables into an array? I have array1, array2 and a function.
I am trying in a for j=0 to ARRAY_SIZE loop to get the data from array2[j], pass it to a function and the returning output store it in array1[j].
Below is the part of the code that I am working on:
exec 3>&1
${ppart_block_fstype[$i]}=_ppart_block_fstype < <(
    for i in $(eval echo {0..$ARRAY_END})
    do
        if [[ ppart_block_alloc[$i] -eq "ALLOC" ]]
        then
            printf "%s\n" "${ppart_block_num[$i]}" >&3
        fi
    done)
exec 3>&-

_ppart_block_fstype is the function that I have previously defined and will return an output that I will store in array ppart_block_fstype.
The problem of above function is that is using some "heavy tools", hence is not really possible to invoke it at every loop cycle.
This! was a good starting point, but I am stuck on how to make $i visible out of the subshell, and I am also not sure if I am invoking < <( )* in the correct way.


Q: Issue on creating an application for facebook Currently i am creating an sample facebook application. The problem is its asking for my application url in two types. Canvas url and Secure canvas url i had hosted my application on this link Fb app url but the hosting is not providing me ssl i.e. the link with https Because of this problem i am unable to include the Secure canvas url
How can i overcome this issue. How can i solve this. Is there any way to submit the facebook application without secure canvas url or is there any free webhosting site which also provides ssl (https). Please suggest me

A: no you have to get the ssl certificate to secure url
check this What is SSL and what are Certificates? and Https connection without SSL certificate
this is Free SSL Certificate :by Comodo for 90 days but never tried by me

A: try heroku . Facebook provides you that option while you are registering your app.


Q: Присваивание и логические операторы java Во время написания одной программы возник интересный вопрос:
"Можно ли как-то присвоить нескольким переменным одинаковое значение с помощью одного оператора присваивания?"
То есть если я, например, не хочу каждой переменной отдельно присваивать каждое значение?

A: Или так (необходимо отметить, что данный способ работает только для примитивных типов):
int a, b, c;
a = b = c = 1;
System.out.println(a + " " + b + " " + c);
// выведет 1 1 1
// изменяем значение одной из переменных
c = 2;
System.out.println(a + " " + b + " " + c);
//выведет 1 1 2, т.е. значение "с" изменилось, а остальных - нет

В случае работы с ссылочными типами будет совсем другая картина:
class Proba{
    public static void main(String[] args){

        MyClass a, b, c; //объявляем три ссылки типа MyClass
        a = b = c = new MyClass();
        //присваиваем полю "x" значение 1 в ссылке "а"
        a.setX(1);
        //при выводе всех значений "x" получаем одинаковые значения везде
        System.out.println(a.getX() + " " +
            b.getX() + " " + c.getX());
        //присваиваем значение 2 полю "x" в ссылке "b"
        //получаем 2 при выводе "x" во всех ссылках
        b.setX(2);
        System.out.println(a.getX() + " " +
            b.getX() + " " + c.getX());
    }
}
class MyClass{
    private int x;
    public void setX(int param){
        x = param;
    }
    public int getX(){
        return x;
    }
}

В данном случае все три ссылки "a", "b" и "c" являются типом класса MyClass и указывают на один и тот же объект (экземпляр этого класса). Значение поля "x" в данном классе будет единственным, хотя обращаться к нему можно через методы по любой ссылке a.getX(), b.getX() или c.getX(). При выводе возвращаемых значений этих методов "x" будет один и тот же. При изменении поля "x" в данном классе по любой из ссылок "a", "b" или "с" значение поля "x" будет снова одно, т.к. объект всего один, на него всего лишь указывают (в данном примере) три переменные одинакового типа.

A: Разве что так
int a;
int b;
a = b = 42;


Q: How to analyse my time series experiment I have a question about how I can analyze the data from a time series experiment. I'm still a student and therefore am not really familiar with all the procedures and analyzes in SPSS, so i hope someone with the proper knowledge can help me with this problem.
The goal is to show a relation between advertising en sales. To show this we have conducted a experiment with an experimental and control group. The experimental group is a province in which the people gets to see more advertising. In the control group the advertising stays the same as usual.
The dataset contains weekly sales data from several stores throughout the country from the control area and experimental area. And how much advertising is used in all the periods. The data goes back for 1.5 years so there are 70 measures before the experiment, and 10 measures in/after the experiment.
So my question is, how can I prove a relation between those two factors. I know I can do a simple t-test to test the difference between the two groups. But this doesn’t  take care of any trends of long/short term effects.

A: In order to test for the effect of a change in a known variable (advertising spend) one needs to control for both known and unknown impacts that have affected sales. Weekly indicators are certainly known as is the history of the advertising variable. If the series has had a level shift or a change in trend in the history of the data prior to the advertising change then this needs to be empirically identified along with any one time unusual activity and incorporated into the model providing robust estimates of the model parameters. Furthermore there may be autoregressive structure in the tentative model residuals that needs to be addressed in order to render an error process to be Gaussian and any subsequent F or T test to be meaningful. With this in place one can then form a test of the importance of the change in the advertising variable as a Level Shift at the point of the change in advertising would be detected. Unfortunately simple solution tools like SPSS sometimes fall far short of providing this kind of analysis. The literature of the Interrupted Time Series may help you. Search for McCleary and Hay as possible sources to get you started. Unfortunately their work was done in the 80's and is not fully up to date with the modern concepts of Intervention Detection.
EDIT:
Figure 1 from Charles's reference showing a clear level shift(intercept change) and a possible (but probably dubious/insignificant) trend change. Again Charles a thank you for showing the clear need for Intervention Detection procedures.

A: I think that you could consider using a changepoint analysis. Some other methods that you might consider include:

*

*Split-Plot ANOVA

*MANOVA

*Mixed Models

In the split-plot ANOVA, we model the data as follows: $$Y_{ijk} = \mu + \alpha_i + \beta_{j(i)}+ \tau_{k}+(\alpha \tau)_{ik}+ \epsilon_{ijk}$$
where $Y_{ijk}$ denotes the sales for treatment $i$ from store $j$ at time $k$. Also, $\alpha_i$ is a treatment effect and $\beta_{j(i)}$ is a random effect of store $j$ receiving treatment $i$. Likewise, $\tau_k$ is a time effect, $(\alpha \tau)_{ik}$ is a treatment-time interaction term, and $\epsilon_{ijk}$ is an error term.
In the MANOVA approach, we would collect the sales data for each store over time and put it in a vector. So let $$\textbf{Y}_{ij} = \begin{bmatrix} Y_{ij1} \\ \  \vdots \\ Y_{ijt} \end{bmatrix}$$
denote the sales data for store $j$ receiving treatment $i$. Doing a MANOVA would test if there is an overall difference between the mean vectors of the two treatments.
The mixed models approach is very similar to the split-plot ANOVA approach except that assumptions are made about the error structure within a single unit.


Q: How do I extract the matrix from an density matrix equation? I have a density matrix equation and I wish to put it in the form of a matrix.
For example, if I have:
$$\rho =Ax_{1}x_{1}+Bx_{1}x_{2}+Cx_{2}x_{1}+Dx_{2}x_{2}$$
Copy-and-paste version
ρ =
  A Subscript[x, 1]^2 + B Subscript[x, 1] ** Subscript[x, 2] +
  C Subscript[x, 2] ** Subscript[x, 1] + D Subscript[x, 2]^2

I want the result to be:
\begin{bmatrix}A&B\\C&D\end{bmatrix}
Is there a simple way to do it for an n by n matrix?

A: Update
It was not clear from your original question that you were using noncommutative variables. In that case, the input needs to indicate this. In particular, x^2 is used for commutative multiplication, so it would be better to use x**x instead. So:
ρ = a Subscript[x, 1]**Subscript[x, 1] + b Subscript[x, 1]**Subscript[x, 2] + c Subscript[x, 2]**Subscript[x, 1] + d Subscript[x, 2]**Subscript[x, 2];

Then, you can use Coefficient:
Map[
    Coefficient[ρ, #]&,
    Outer[NonCommutativeMultiply, {Subscript[x, 1],Subscript[x, 2]}, {Subscript[x, 1], Subscript[x, 2]}]
]

{{a, b}, {c, d}}

Original answer
You can use CoefficientArrays:
ρ = A Subscript[x, 1]^2 + B Subscript[x, 1] Subscript[x, 2] + C Subscript[x, 2] Subscript[x, 1] + D Subscript[x, 2]^2

Normal @ CoefficientArrays[ρ, {Subscript[x, 1], Subscript[x, 2]}][[3]] //TeXForm

$\left(
\begin{array}{cc}
 A & B+C \\
 0 & D \\
\end{array}
\right)$


Q: Java: How to parse string? Just started a programming class a few months ago, and I'm going over some review questions for a test. I'm not sure how to tackle this one. We have to format a few lines of text.
So something that looks like this: 2002/Bourne Identity/Action/1:58
Will have to look like this: 2002 - Bourne Identity Action 118 minutes
There are a few of these, and then we have to add up the total running time for each genre. Would I be right in using the split function here?
Thanks

A: I am assuming that the input data are 4 variables. For example
public String parse(Integer year, String title, String genere, Date duration)

So you just have to operate the values. For example
return year + " - " + title + " " + genere + " " + toMinutes(duration) + " minutes"

where toMinutes(duration) is a function which parse a date to minutes.


Q: If column 1 is a match, change value of column 3 using Awk I have to edit a big file where the columns for each record are not delimited by a character but have a fixed lenght. I would like to search a value in the first column and if found, change the value of the 3rd column.
I can't take the file out from where it is so I can only use the command line with awk, sed and maybe java 5. otherwise I would try other solutions.
bigfile.dat structure:
Column1Col2Column3Column4Col5

Example:
id12345TEXTVALUE01SOMCODETEXT
id23456TEXTVALUE02SOMCODETEXT
id34567TEXTVALUE02SOMCODETEXT
id45678TEXTVALUE01SOMCODETEXT
id56789TEXTVALUE03SOMCODETEXT

What I need: set VALUE04 for id45678
id12345TEXTVALUE01SOMCODETEXT
id23456TEXTVALUE02SOMCODETEXT
id34567TEXTVALUE02SOMCODETEXT
id45678TEXTVALUE04SOMCODETEXT
id56789TEXTVALUE03SOMCODETEXT

I don't know if this is possible. Here is some pseudo code that I thought maybe could work with awk:
if (match id = subtr(Column1))
print subtr(Column1+Col2) + "mychange" +substr(Column4+Col5)
else
print unchanged line

I'm not asking to do my work for me I just don't know I'm wasting my time with the tools I have or I just lack the knowledge.
Thanks.

A: This is actually quite easy to do with awk:
pax: awk <input.txt '/^id45678/{$0=substr($0,1,11)"VALUE04"substr($0,19)}1'
id12345TEXTVALUE01SOMCODETEXT
id23456TEXTVALUE02SOMCODETEXT
id34567TEXTVALUE02SOMCODETEXT
id45678TEXTVALUE04SOMCODETEXT
id56789TEXTVALUE03SOMCODETEXT

It just finds lines beginning with id45678 and modifies that part of the line that you want changed.
The 1 at the end is simply a command to print the line whether changed or not (it's a "trick" using a truth value 1 to select the (default) action of printing the line).

A: Using GNU awk's FIELDWIDTHS for fixed width fields:
$ awk '
BEGIN {
    FIELDWIDTHS="7 4 7 7 4"  3  # set the field widths
    OFS=""
}
$1=="id45678" {                 # when the first field has the given value
    $3="VALUE04"                # replace the third field
}1' file                        # output
Column1Col2Column3Column4Col5
id12345TEXTVALUE01SOMCODETEXT
id23456TEXTVALUE02SOMCODETEXT
id34567TEXTVALUE02SOMCODETEXT
id45678TEXTVALUE04SOMCODETEXT
id56789TEXTVALUE03SOMCODETEXT

A: With GNU sed:
sed -E 's/^(id45678....)......./\1VALUE04/' file

or shorter:
sed -E 's/^(id45678.{4}).{7}/\1VALUE04/' file

and with variables:
s="id45678"
r="VALUE04"
sed -E 's/^('"$s"'.{4}).{7}/\1'"$r"'/' file

Output:

id12345TEXTVALUE01SOMCODETEXT
id23456TEXTVALUE02SOMCODETEXT
id34567TEXTVALUE02SOMCODETEXT
id45678TEXTVALUE04SOMCODETEXT
id56789TEXTVALUE03SOMCODETEXT

If you want to edit your file "in place" use sed's option -i.


Q: Is there any difference between normal and static local variables in static methods? class A
{
    static void f(void)
    {
        int a;
        static int b;
    }
};

Is there any (formal or practical) difference between a and b?

A: Yes, consider the following:
#include <iostream>
using namespace std;

class A
{
    public:
    static void func()
    {
        static int a = 10;
        int b = 10;
        a++;
        b++;
        std::cout << a << " " << b << endl;
    }
};

int main() {
    A a, b;
    a.func();
    b.func();
    a.func();
    return 0;
}

a is shared across all instances of func, but b is local to each instance, so the output is:
11 11
12 11
13 11

http://ideone.com/kwlra3

A: Yes both are different. For every call a will be created whereas b will be created only once and it is same for all the objects of type A. By same I mean, all the objects share a single memory of b.


Q: Mule connector config needs dynamic attributes I have develop a new Connector. This connector requires to be configured with two parameters, lets say:

*

*default_trip_timeout_milis

*default_trip_threshold

Challenge is, I want read ${myValue_a} and ${myValue_a} from an API, using an HTTP call, not from a file or inline values.
Since this is a connector, I need to make this API call somewhere before connectors are initialized.
FlowVars aren't an option, since they are initialized with the Flows, and this is happening before in the Mule app life Cycle.
My idea is to create an Spring Bean implementing Initialisable, so it will be called before Connectors are init, and here, using any java based libs (Spring RestTemplate?) , call API, get values, and store them somewhere (context? objectStore?) , so the connector can access them.
Make sense? Any other ideas?
Thanks!

A: mmm you could make a class that will create the properties in the startup and in this class obtain the API properties via http request. Example below:
 public class PropertyInit implements InitializingBean,FactoryBean {

    private Properties props = new Properties();

    @Override
    public Object getObject() throws Exception {
        return props;
    }

    @Override
    public Class getObjectType() {
        return Properties.class;
    }
 }

Now you should be able to load this property class with:
  <context:property-placeholder properties-ref="propertyInit"/>

Hope you like this idea. I used this approach in a previous project.

A: I want to give you first a strong warning on doing this. If you go down this path then you risk breaking your application in very strange ways because if any other components depend on this component you are having dynamic components on startup, you will break them, and you should think if there are other ways to achieve this behaviour instead of using properties.
That said the way to do this would be to use a proxy pattern, which is a proxy for the component you recreate whenever its properties are changed. So you will need to create a class which extends Circuit Breaker, which encapsulates and instance of Circuit Breaker which is recreated whenever its properties change. These properties must not be used outside of the proxy class as other components may read these properties at startup and then not refresh, you must keep this in mind that anything which might directly or indirectly access these properties cannot do so in their initialisation phase or your application will break.
It's worth taking a look at SpringCloudConfig which allows for you to have a properties server and then all your applications can hot-reload those properties at runtime when they change. Not sure if you can take that path in Mule if SpringCloud is supported yet but it's a nice thing to know exists.


Q: background-image doesn't appear with span class

However the arrow doesn't show up. I double checked the path. It's correct. What wrong am I doing?
I even tried display:block;
No change.

A: You have to triple check you path :)

For a cleaner code, you can write your CSS code outside of style attribute, in a separate file.


Q: How to convert timezone inside bindings? I tried to calculate unfinished downtime duration. Start time is stored in GMT timezone and finish time is local datetime in my timezone (GMT+2 or GMT+3). I want to calculate difference in seconds.
Null datetime is 1900-01-01 00:00:00, so I have expression that means start time is after end time to find unfinished downtimes. Than I get current time and convert it into epoch seconds consigering timezone difference and subtract start time converted into epoch seconds.
In code it looks like
LoadingDowntimes
   (globalobjectid == $CurrentDowntimeGOId &&
   downtimeend.toEpochSecond(ZoneOffset.ofHours(0)) < downtimestart.toEpochSecond(ZoneOffset.ofHours(0)),
   $DowntimesTimeUnfinished : (LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours($CurrentZoneOffset.offset)) - downtimestart.toEpochSecond(ZoneOffset.ofHours(0))))

All parts of this code work corretly in another places, but in this place I have error message
Variables can not be used inside bindings.
Variable [$CurrentZoneOffset] is being used in binding '(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours($CurrentZoneOffset.offset)) - StringToLocalDateTime(downtimestart).toEpochSecond(ZoneOffset.ofHours(0)))'

I don't know how to make it another way so I need a help with solving this problem.


Q: select sum() from multiple table with same column I have a table for product, sales_item and a stock with following structure
Product table:
+----+-----+-------------+
| id |name |description  |
+----+-----+-------------+
| 1  |Pr1  |prod1        |
+----+-----+-------------+
| 2  |Pr2  |prod2        |
+----+-----+-------------+
| .. |...  |.....        |
+----+-----+-------------+

sales_item_details table
+-----+----------+------------+-----+
| id  | sales_id | product_id | qty |
+-----+----------+------------+-----+
| 517 |      211 |          1 | 200 |
+-----+----------+------------+-----+
| 518 |      211 |          1 | 120 |
+-----+----------+------------+-----+

and production
+----+------------+-------+
| id | product_id | qty   |
+----+------------+-------+
|  1 |          1 |    20 |
|  2 |          2 |   200 |
|  3 |          1 |    20 |
|  4 |          3 |    30 |
|  5 |          9 |    30 |
|  6 |         65 |    10 |
|  7 |         65 |    50 |
|  8 |         71 |    10 |
|  9 |         71 |    10 |
| 10 |         71 |    10 |
+----+------------+-------+

And now I am creating multiple database with same table defination and need to maintain stock
production table and product table will be maintained from single database
only sales_item_details table will be different but product id will same
So how will be the query to get SUM(qty) of sales item details and view the inventory in stock
I have tried this:
SELECT
        `pr`.`id`,
        `pr`.`name`,
        sl.size,
        IFNULL(SUM(s.qty), 0) AS sales,
        IFNULL((SELECT SUM(qty) FROM production st WHERE st.product_id = `pr`.`product-id`), 0) AS stock_added
    FROM products pr
        LEFT JOIN (
            SELECT qty, product_id FROM db1.sales_item_details
            UNION ALL
            SELECT qty, product_id FROM db2.sales_item_details
        ) s ON pr.`id` = s.product_id
        LEFT JOIN size_list sl ON sl.id = `pr`.`product-size`
    GROUP BY s.product_id
    ORDER BY sales DESC

but getting the product which is sold
Any help will be appriciated

A: 1st I created a view holding all sales items grouped by product id in the main database:
CREATE OR REPLACE VIEW unit_sold_all  AS
    SELECT
        p.`product-id` AS product_id,
        (
            (SELECT IFNULL(SUM(s0.qty), 0) FROM db_1.sales_item_details s0 WHERE s0.product_id = p.`product-id`) +
            (SELECT IFNULL(SUM(s1.qty), 0) FROM db_2.sales_item_details s1 WHERE s1.product_id = p.`product-id`) +
            (SELECT IFNULL(SUM(s2.qty), 0) FROM db_3.sales_item_details s2 WHERE s2.product_id = p.`product-id`) +
            (SELECT IFNULL(SUM(s3.qty), 0) FROM db_4.sales_item_details s3 WHERE s3.product_id = p.`product-id`) +
            (SELECT IFNULL(SUM(s4.qty), 0) FROM db_5.sales_item_details s4 WHERE s4.product_id = p.`product-id`)
        ) as total_unit_sales
FROM products p

Then in another sql, I selected the sum of the sales.
PS: I answered this question myself because this might need by another person in the future.


Q: Jquery how to make div visible after valid mail is written I wanna make form, which will show its next part, after valid email adress is written in input. I have some code to validate, but i need some code, which will wait until email adress is in input.
<input style="border-radius: 4px;" name="editsubsemail" type="text" id="editsubsemail" size="40"/>

This is jquery code and i need to replace that .click (just placeholder) with something, that will check, if that "editsubsemail" is filled with email
var visibility_edit = false;
$("#changesubs-wraper").click(function(){
if( visibility_edit == false ){
    $('#change-info-wraper').show("slow");
    $('#delete-subs-wraper').show("slow");
    visibility_edit = true;
} else {
    $('#change-info-wraper').hide("slow");
    $('#delete-subs-wraper').hide("slow");
    visibility_edit = false;
}
});

A: Check out this seminar registration demo form on css-tricks. It looks like it could solve your problem with a little tweaking. Here is the source.

A: For: <input name='email' type='email' id='email'> and

This is some untested code:
$('#email').on( 'change', function() {
  if( email_regex_must_be_here ) {
    //this is a valid email
    $('#somediv').show();
  }
  else {
    $('#somediv').hide();
  }
} );

Harry's link might be better at helping you though.


Q: Halmos, Frechet-Neumann theorem, and polarization in vector spaces Look at Halmos' book on vector spaces (1987); Ch. III, page 123,
exercise 2.
If $x$ and $y$ are vectors in a unitary space then the scalar
product is given by the formula
$$
4(x,y)=\|x+y\|^2-\|x-y\|^2+i\|x+iy\|^2-i\|x-iy\|^2.
$$
What confuses me here is the absent of a parallelogram identity. But
the Frechet-Neumann theorem, with the same statement, exploits this
very `parallelogram'.
To put this differently,

*

*One has a vector space with some (Hermitian) inner product
$(x,y)$.

*One has a norm $\|x\|$ on the space.

*Should we imply a correspondence, say $(x,x)=\|x\|^2$, between
axioms of $(x,y)$ and $\|x\|$? If not, what would change in this
case?
Then, again, the question above: statement in the exercise and the
parallelogram identity -- where it is hiding? -- by Frechet-Neumann? Do
I overlook something? Incidentally, Halmos' definition of $(x,y)$,
and of unitary space (p. 121) does not touch upon the structure of a
norm.


Q: How can i show the count value as well as % on my highchart pie chart?

var json=
[
    {
        "a": "OOCBER",
        "b": "OOCL BERLIN",
        "c": "CHINA",
        "d": "GREAT BRITAIN",
        "e": "*PI",
        "f": "NGB",
        "g": "CN",
        "i": "GB",
        "j": "9PIO5090196",
        "k": "2PI5090420",
        "l": "WL15802C/D",
        "m": "NB1500682",
        "n": 9,
        "o": 6,
        "p": "2015-09-14",
        "q": "2015-09-14",
        "s": 4,
        "u": "40HC",
        "v": "TLU7564566",
        "w": "CN074909",
        "x": "LEIGH",
        "y": "NINGBO",
        "z": 395,
        "B": 68,
        "C": 7987.5,
        "D": "534",
        "E": "Chunghy",
        "F": "07405",
        "G": "PIF",
        "H": "FB",
        "I": "NIGBO",
        "J": "NGB",
        "K": "2015-09-12",
        "L": "2015-09-29T10:05",
        "M": "2015-09-29T10:05",
        "Y": "SOUTHAMPTON",
        "zp": "SOU",
        "N": "2015-10-21",
        "O": "2015-09-22T17:40",
        "P": "2015-09-22T17:40",
        "Q": "2015-10-21T12:54",
        "R": "2015-10-22T14:13",
        "S": "2015-10-27T10:30",
        "T": "2015-10-27T10:30",
        "U": "2015-10-27T10:30",
        "V": true,

    }, etc......

I am looking to display the actual count number as well as the % on my pie chart. As it stand it just shows the % but I want the actual count number to be displayed next to it. On my snippet look for *** Actual count here value ***. I tried point.y but that didn't give me the correct value. Please help.
$(function() {
  var ContainerCounts = {};
  var ContainerTypes = [];
  var totalCount = 0;

  //loop through the object
  $.each(json, function(key, val) {
    //get the container name
    var ContainerType = val["u"];

    //build array of unique container names
    if ($.inArray(ContainerType, ContainerTypes) == -1) {
      ContainerTypes.push(ContainerType);
    }

    //add or increment a count for the container name
    if (typeof ContainerCounts[ContainerType] == 'undefined') {
      ContainerCounts[ContainerType] = 1;
    } else {
      ContainerCounts[ContainerType] ++;
    }

    //increment the total count so we can calculate %
    totalCount++;
  });

  //console.log(ContainerTypes);

  var data = [];
  //loop through unique countries to build data for chart
  $.each(ContainerTypes, function(key, ContainerType) {
    data.push({
      name: ContainerType,
      y: Math.round((ContainerCounts[ContainerType] / totalCount) * 100)
    });
  });
  //console.log(data);

  function popchart_shipment_breakout() {
    $('#container_shipment_breakout').highcharts({
      chart: {
        type: 'pie',
        options3d: {
          enabled: false,
          alpha: 45,
          beta: 0
        }
      },
      title: {
        text: 'Break out of shipments'
      },
      tooltip: {
        pointFormat: '*** Actual count here value *** {point.percentage:.1f}%'
      },
      plotOptions: {
        pie: {
          allowPointSelect: true,
          cursor: 'pointer',
          depth: 35,
          innerSize: 150,

          dataLabels: {
            enabled: true
          }
        }
      },
    });
    chart = $('#container_shipment_breakout').highcharts();
    chart.addSeries({
      data: data
    });
  }

  popchart_shipment_breakout();
});

A: Just use this.y instead of point.percentage
OR
Use below code to format the tooltip.
tooltip: {
        formatter: function () {
            return '' + this.y + '';
        }
    }


Q: input capacitor for buck converter To calculate the input capacitor for buck converter, I follow TI Application Report SLTA055–FEBRUARY 2006 "Input and Output Capacitor Selection".
It says to determine the input capacitor "75 mVpp is recommended for maximum input voltage ripple. This will yield approximately 22 mVrms of ripple voltage"
The question is how we select this value 75 mVpp?
thanks

A: From section 1.1

As a general rule of thumb, keeping the peak to peak ripple amplitude
below 75 mV keeps the rms currents in the bulk capacitors within
acceptable limits.

Emphasis mine


Q: Find elements of a set that divide an expression. I have to determine the elements of the following set:
$A = \{x\in\ \mathbb Z \vert \sqrt[3]{\frac {7x + 2}{x+5}} \in \mathbb Z \}$
I know that $x+5 \not=0$ and $x+5$ must divide $7x + 2$ but I cannot figure out how to use the second condition and how to write down the complete solution step by step. Could someone, please, show me how it can be done? Thank you in advance.

A: What you said is correct. Use the fact that $7x+2 = 7(x+5) - 33$, and since $x+5$ divides $7x+2$, then $x+5$ must divide $33$, so you have
$x + 5 = \pm1, \pm3, \pm11, \pm33$. What is left is to check which of these are exact cubes.


Q: Bottleneck of Web Applications I am developing a web application using django, postgreSQL, html5 and javascript. The application is javacript intensive and is both read/write intensive. What are some common bottlenecks? What are some things to keep in mind when designing a web application that scales well? What are some tips to improve performance?
Thanks!

A: Database database database. Make sure you can add more db servers without lots of pain.
Adding app servers is usually fairly straightforward, but DB replication/clustering can get tricky.

A: It depends. It depends on how your application is used. You cannot tell until you know how many users will do concurrent requests. Most of the time it will be your database, depending on how many requests per second it can manage.
So if you know your application patterns (read intensive or write intensive) you can design it for easier scaling. Would it be enough to just do replication?

A: Your problem from day 1 will be the time taken for the client to download the content from your server. CDN's, minification and combining assets should be a primary concern.
(Un)fortunatly, unless you go Google, you won't become big enough to require multiple application, database servers (no offence).

A: A couple suggestions:
1) Since you said read write intensive you need to decide how you will be structuring your database to be more read or write friendly. What will be happening most often. If it is reads then indexes are your friend. If it is writes then be careful of going index crazy.
2) On the client side be careful of writing to the live DOM too often. If you need to do do a lot of loads of say table rows, load them into a parent element in memory and then load that parent element into the DOM all at once.

A: You may take a look at http://ilian.i-n-i.org/tag/cache/ there are three articles about caching and how it will help your website.
As for the scales well... are you sure that your application needs it?
Do not get me wring, it is awesome to have multiple database servers, CDN, load balancers etc. but do you really need it? If you are starting a new project you should focus on providing a stable features more than optimizing it for a million hits per day cause you are probably not going to make them(at least in the beginning).
Start with caching, it is easy to implement and effective if it is correctly used. When your visitors get so much that you reach the bottle necks think for them then but not earlier.
The above does not mean that you should write the slowest code that is possible. It only means that the need for extreme scalability comes when you have working application and that if you waste 1 year and a ton gold to build it probably you will miss the moment.


Q: Convert AMPL Model to ORTools I am trying to convert my AMPL Model to ORTools. This is the model:
set NUTR;
set FOOD;

param cost {FOOD} > 0;
param f_min {FOOD} >= 0;
param f_max {j in FOOD} >= f_min[j];

param n_min {NUTR} >= 0;
param n_max {i in NUTR} >= n_min[i];

param amt {NUTR,FOOD} >= 0;

var Buy {j in FOOD} >= f_min[j], <= f_max[j];

minimize Total_Cost:  sum {j in FOOD} cost[j] * Buy[j];

subject to Diet {i in NUTR}:
   n_min[i] <= sum {j in FOOD} amt[i,j] * Buy[j] <= n_max[i];

This is my semi python code for ORTools. I don't know if Buy is correct and how to add the constraint:
Buy = {}
for f_ in FOOD:
    Buy[f_] = solver.IntVar(0, 1000, 'Buy[%s]' % (f_,))

##  Objective Function
Total_Cost = solver.Sum([cost[j_] * Buy[j_] for j_ in FOOD])

##  Constraints
for i in NUTR:
    for j in FOOD:
        print(amt[i,j] *Buy[j])
        #solver.Add( solver.Sum(amt[i,j] * Buy[j] <= n_max[i]  ))

solver.Minimize(Total_Cost)

A: wrong parenthesis
  solver.Add( solver.Sum(amt[i,j] * Buy[j]) <= n_max[i] )


Q: How to reference Column data in a rolling window calculation? Error ValueError: window must be an integer 0 or greater I am currently working on a large DF and need to reference the data in a column for a rolling window calculation. All rows have a separate rolling window value so i need to reference the column but i am getting the out put
    ValueError: window must be an integer 0 or greater

    import numpy as np
    import pandas as pd

    df = pd.DataFrame(np.random.randint(0,20,size=(20, 4)), columns=list('abcd'))

    df['op'] = (np.random.randint(0,20, size=20))

        a   b   c   d   op
    0   6   17  3   5   9
    1   8   3   13  7   2
    2   19  12  18  3   8
    3   8   8   5   4   17
    4   0   5   9   3   19
    5   0   5   19  9   11
    6   7   7   13  8   10
    7   7   5   12  0   4
    8   13  17  4   4   17
    9   7   0   16  9   7
    10  7   8   13  10  13
    11  18  3   1   11  16
    12  4   4   5   13  4
    13  9   8   14  19  9
    14  13  10  10  7   10
    15  9   16  11  16  3
    16  5   7   3   0   11
    17  13  14  10  1   16
    18  6   14  13  4   18
    19  1   9   8   0   19

trying to reference the value in df['op'] for a rolling average.
    df['SMA'] = df.a.rolling(window=df.op).mean()

produces Error ValueError: window must be an integer 0 or greater
As mentioned i am working on a large data frame so the above is example code.

A: Solution
    import numpy as np
    import pandas as pd

    df = pd.DataFrame(np.random.randint(0,20,size=(20, 4)),
    columns=list('abcd'))

    df['op'] = (np.random.randint(0,20, size=20))

    def lookback_window(row, values, lookback, method='mean', *args, **kwargs):
        loc = values.index.get_loc(row.name)
        lb = lookback.loc[row.name]
        return getattr(values.iloc[loc - lb: loc + 1], method)(*args, **kwargs)

    df['SMA'] = df.apply(lookback_window, values=df['a'], lookback=df['op'], axis=1)

    df

    a      b    c   d   op  SMA
    0   17  19  11  9   0   17.000000
    1   0   10  9   11  19  NaN
    2   13  8   11  2   16  NaN
    3   9   2   4   4   8   NaN
    4   11  10  0   17  18  NaN
    5   14  19  17  10  17  NaN
    6   6   12  17  1   4   10.600000
    7   10  1   3   18  2   10.000000
    8   7   6   12  3   19  NaN
    9   1   9   7   5   9   8.800000
    10  17  1   3   13  1   9.000000
    11  19  17  0   2   7   10.625000
    12  18  5   2   4   12  10.923077
    13  18  5   4   2   1   18.000000
    14  5   11  17  11  11  11.250000
    15  16  9   2   11  16  NaN
    16  15  17  1   8   14  11.933333
    17  15  2   0   3   6   15.142857
    18  18  3   18  3   10  13.545455
    19  7   0   12  15  3   13.750000


Q: text from With statement to geometry and geography WITH values(location, userid) as (
VALUES (st_geomfromewkt('0101000000000000C04141464000000000FE174440'),5))

SELECT st_distance(p.location,(SELECT location FROM values where v.userid = "blacklisterId")::geometry)
FROM values as v,live.partners as p
Inner JOIN backend.cars c ON (c."userId" = p."partnerId" AND c.active = true)
Inner JOIN backend."carCompatibleTariffs" cCT ON c."carId" = cCT."carId" and  1 = cCT."tariffId" AND cCT.active = true
LEFT JOIN backend."userBlacklist" bl on 5 = bl."blacklisterId" AND p."partnerId" = bl."blacklistedId"
WHERE bl."blacklistedId" ISNULL
--AND st_dwithin(p.location::geography,(SELECT FROM values where v.userid = "blacklisterId")::geography,1500)
--ORDER BY st_distance(p.location,(SELECT location FROM values where v.userid = "blacklisterId")::geometry) ASC;

How to take text values table as geometry or geography,I tried to make it with ST_GeographyFromText,ST_GeogmetryFromText and with st_makepoint((Select st_x),(Select st_y)) but it always return null,how can I solve this ?

A: Your problem might be somewhere else. Your geometry seems to be valid:
WITH values(location, userid) AS
(VALUES ('0101000000000000C04141464000000000FE174440',5),
        ('0101000000000000200A45464000000000D7174440',16))
SELECT ST_Distance(location::GEOMETRY,ST_GeomFromText('POINT(44 45)')) FROM values;

   st_distance
------------------
 4.83948955585514
 4.84387473202619
(2 Zeilen)

Here a few examples on different types of geometry literals:
ST_GeomFromText
db=# SELECT ST_GeomFromText('POINT(1 2)');
              st_geomfromtext
--------------------------------------------
 0101000000000000000000F03F0000000000000040
(1 Zeile)

ST_GeomFromGeoJSON:
db=# SELECT ST_GeomFromGeoJSON('{"type":"Point","coordinates":[1,2]}');
             st_geomfromgeojson
--------------------------------------------
 0101000000000000000000F03F0000000000000040
(1 Zeile)

ST_GeomFromEWKT:
db=# SELECT ST_GeomFromEWKT('SRID=4269;POINT(1 2)');
                  st_geomfromewkt
----------------------------------------------------
 0101000020AD100000000000000000F03F0000000000000040
(1 Zeile)

ST_GeomFromGML:
db=# SELECT ST_GeomFromGML('<gml:Point><gml:coordinates>1,2</gml:coordinates></gml:Point>');
               st_geomfromgml
--------------------------------------------
 0101000000000000000000F03F0000000000000040
(1 Zeile)

ST_GeomFromKML:
db=# SELECT ST_GeomFromKML('<Point><coordinates>1,2</coordinates></Point>');
                   st_geomfromkml
----------------------------------------------------
 0101000020E6100000000000000000F03F0000000000000040
(1 Zeile)

A: This could have been your intention:

WITH vvv(location, userid) as (
    VALUES (st_geomfromewkt('0101000000000000C04141464000000000FE174440'),5)
    )
SELECT st_distance(p.location, v.location::geometry) AS THE_DISTANCE
FROM vvv as v
JOIN live.partners as p
    ON p."partnerId" = v.userid
WHERE EXISTS (
    SELECT *
    FROM backend.cars c
    JOIN backend."carCompatibleTariffs" cCT
            ON c."carId" = cCT."carId"
            AND cCT."tariffId" = 1 AND cCT.active = true
    WHERE c."userId" = p."partnerId"
    AND c.active = true
    )
AND NOT EXISTS(
    SELECT * FROM backend."userBlacklist" bl
    WHERE p."partnerId" = bl."blacklistedId"
    AND 5 = bl."blacklisterId"
    )
    ;


Q: How do I deduplicate a list based on hourly intervals in Java? First of all, I have this object that I call MyObject;
public class MyObject{
    private google.protobuf.Timestamp timestamp;
    private String description;
}

Then I have this list:
List<MyObject> myList = new ArrayList<>();

Now let's imagine that myList contains 500 items. What I want, is to eliminate duplicates (identical descriptions) that occur within the same hour.
So two different items with identical descriptions should not both exist in the list within the same hour. If they do, we want to only keep one and delete the other.
Example:
If the list contains the following two items:
06-07-2022T01:30:00, "some random description" and 06-07-2022T01:35:00, "some random description"
Then we want to delete one of them because they have identical description and are within the same hour.
But if we have this:
06-07-2022T01:30:00, "some random description" and 06-07-2022T03:20:00, "some random description"
Then we don't want to delete any of them as they are not within the same hour.
How do I do that?

A: Based on the clarifications you've given in the comments I've used a LocalDateTime to simplify the sample entry and retrieve the hour, but I'm sure that google.protobuf.Timestamp can be converted to a proper date and extract its hour.
To keep only one object according to description, date and hour, I've added a helper method to your POJO to get a concatenation of these fields and then group by their result value in order to get a Map where to each key (description, date and hour) there is only one object associated. Lastly, I've collected the Map's values into a List.
List<MyObject> list = new ArrayList<>(List.of(
        new MyObject(LocalDateTime.parse("06-07-2022T01:30:00", DateTimeFormatter.ofPattern("dd-MM-yyyy'T'HH:mm:ss")), "some random description"),
        new MyObject(LocalDateTime.parse("06-07-2022T01:35:00", DateTimeFormatter.ofPattern("dd-MM-yyyy'T'HH:mm:ss")), "some random description"),
        new MyObject(LocalDateTime.parse("06-07-2022T03:20:00", DateTimeFormatter.ofPattern("dd-MM-yyyy'T'HH:mm:ss")), "some random description"),
        new MyObject(LocalDateTime.parse("06-07-2022T04:30:00", DateTimeFormatter.ofPattern("dd-MM-yyyy'T'HH:mm:ss")), "some random description2"),
        new MyObject(LocalDateTime.parse("06-07-2022T04:35:00", DateTimeFormatter.ofPattern("dd-MM-yyyy'T'HH:mm:ss")), "some random description2"),
        new MyObject(LocalDateTime.parse("06-07-2022T06:20:00", DateTimeFormatter.ofPattern("dd-MM-yyyy'T'HH:mm:ss")), "some random description2"),
        new MyObject(LocalDateTime.parse("08-07-2022T01:30:00", DateTimeFormatter.ofPattern("dd-MM-yyyy'T'HH:mm:ss")), "some random description")
));

List<MyObject> listRes = list.stream()
        .collect(Collectors.toMap(
                obj -> obj.getDescrDateHour(),
                Function.identity(),
                (obj1, obj2) -> obj1
        ))
        .values()
        .stream().
        collect(Collectors.toList());

POJO Class
class MyObject {
    private LocalDateTime timestamp;
    private String description;

    public MyObject(LocalDateTime timestamp, String description) {
        this.timestamp = timestamp;
        this.description = description;
    }

    public LocalDateTime getTimestamp() {
        return timestamp;
    }

    public String getDescription() {
        return description;
    }

    public String getDescrDateHour() {
        return description + timestamp.toLocalDate().toString() + timestamp.getHour();
    }

    @Override
    public String toString() {
        return timestamp + " - " + description;
    }
}

Here is a link to test the code
https://www.jdoodle.com/iembed/v0/sZV
Output
Input:
2022-07-06T01:30 - some random description
2022-07-06T01:35 - some random description
2022-07-06T03:20 - some random description
2022-07-06T04:30 - some random description2
2022-07-06T04:35 - some random description2
2022-07-06T06:20 - some random description2
2022-07-08T01:30 - some random description

Output:
2022-07-06T04:30 - some random description2
2022-07-08T01:30 - some random description
2022-07-06T06:20 - some random description2
2022-07-06T03:20 - some random description
2022-07-06T01:30 - some random description

A: A quiet simple solution would be a HashMap. You use description as key and timestamp as value. So you always save only the last timestamp to given description and overwrite it automaticly.
If you want to hold your Object I would just sort the list by date, then fill in a HashMap and transform the HashMap to List again. It has not the best Performance, but its easy. You can Sort by Date with functional Java sorting a Collection in functional style

A: You could define an equality calculating class (or do it in the MyObject class, depending on what it actually represents) and use it to find unique values based on the equality definition. In this case equality would mean: same description and same timestamp with hourly precision.
Here's an example (might need some tweaking, just a concept presentation):

class UniqueDescriptionWithinHourIdentifier {

    // equals and hashCode could also be implemented in MyObject
    // if it's only purpose is data representation
    // but a separate class defines a more concrete abstraction

    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMddHH");

    private Date timestamp;
    private String description;

    UniqueDescriptionWithinHourIdentifier(MyObject object) {
        timestamp = object.timestamp;
        description = object.description;
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) {
            return true;
        }
        if (object == null || getClass() != object.getClass()) {
            return false;
        }
        var other = (UniqueDescriptionWithinHourIdentifier) object;
        return description.equals(other.description)
               // compare the timestamps however you want - format used for simplicity
               && DATE_FORMAT.format(timestamp)
                             .equals(DATE_FORMAT.format(other.timestamp));
    }

    @Override
    public int hashCode() {
        // cannot contain timestamp - a single hash bucket will contain multiple elements
        // with the same definition and the equals method will filter them out
        return Objects.hashCode(description);
    }
}

class MyObjectService {

    // here a new list without duplicates is calculated

    List<MyObject> withoutDuplicates(List<MyObject> objects) {
        return List.copyOf(objects.stream()
                                  .collect(toMap(UniqueDescriptionWithinHourIdentifier::new,
                                                 identity(),
                                                 (e1, e2) -> e1,
                                                 LinkedHashMap::new))
                                  .values());
    }

}

A: Add equals & hashcode method to your MyObject class with equals has some logic like below:
@Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        MyObject other = (MyObject) obj;

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(timestamp);
        int hour1=calendar.HOUR;
        int date1 = calendar.DATE;
        calendar.setTime(other.timestamp);
        int hour2 = calendar.HOUR;
        int date2  =calendar.DATE;
        return Objects.equals(hour1, hour2) && Objects.equals(date1, date2);
    }

Here, basically I am checking if 2 objects has same hour & date & if so, just ignore another object.
Once you do that, you can just use :
List<MyObject> myList = new ArrayList<>();
myList.stream().distinct().collect(Collectors.toList()); // returns you new distinct objects list.

Please note, you can use default implementation of hashCode generated via your editor for this case. distinct() method of stream is checking if you have equals & hashcode available for underlying streams class.
Note: you can extend equals to check day , date, month, year etc. for verifying exact date.


Q: Huge mishap: Upgrade from 14.10 to 15.4 froze, now I cant get passed the login-screen I tried to make an update from Kubuntu 14.10 to 15.4 via the Muon Updater. During installation (while installing cups to be precise), the muon window froze. I imagine it might have been because of some EULA I needed to except, however no window popped up and I couldn't press the button "terminal", because the application was frozen. So I terminated the muon window. But now muon can't be opened again and when I try to do the update via a konsole I get:
~$ sudo kubuntu-devel-release-upgrade
Error: "/var/tmp/kdecache-IamTheUser" is owned by uid 1000 instead of uid 0.
New Release of Ubuntu is searched for
No new Release found

Alternatively:
~$ sudo do-release-upgrade
[sudo] password for ...:
New Release of Ubuntu is searched for
No new Release found

Also:
~$ muon-updater
muon-updater: error while loading shared libraries: libGL.so.1: cannot open shared object file: No such file or directory

And:
~$ sudo muon
muon: error while loading shared libraries: libGL.so.1: cannot open shared object file: No such file or directory

Moreover, pressing Ctrl + Esc and searching for a process containing "muon" did not turn anything up.
Because of the earlier error I executed
~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 15.04
Release:        15.04
Codename:       vivid

but if I call the system settings I get the error (translated into English):
The command cannot be executed. The file or folder file:///usr/share/applications/kde4/systemsettings.desktop does not exist.

So I tried
~$ sudo apt-get -f dist-upgrade
[sudo] password for ...:
E: Could not get lock /var/lib/dpkg/lock - open (11: The resource is not available at the moment)
E: Locking of the administration folders (/var/lib/dpkg/) is not possible, is it used by a different process?

and thus
~$ pgrep dpkg
14527
~$ sudo kill 14527
~$ sudo apt-get -f dist-upgrade

Which now worked. However, trying to open the system settings, still produced the same error!
I rebooted the system by now. I get up until the login-screen, but when I put in my passwort it runs for a while and brings me back to the login-screen. I went into Going into recover mode and ran the dpkg repair packages menu  two times, until no packages where installed or deinstalled anymore. However, I still can't get passed the login-screen.
What should I do?