问:
MySQL Workbench - Apply Changes icon in Inserts tab not responding when clicked
I'm new to MySQL so this might be a very simple question.  I'm trying to add new data to an existing table in the MySQL Model in the Workbench using the "Inserts" tab.  I can enter the data with no problem, but when I click the "Apply Changes" icon nothing seems to happen.  No script is generated, the table isn't updated, nothing.  I've been digging around reading through the Oracle manual, looking through Stack Overflow, watching YouTube videos, you name it, and can't find an answer as to why it doesn't respond.  It does look like there was a bug that got fixed years ago (MySQL Bug #54456) that was the same or very similar to the issue I'm having.  I'm unable to attach images at this point, please ask me if you need any clarification.  Thanks!

Since I can't post a screenshot please see this link for a very similar problem.  When I click on the green "Apply Changes" icon nothing happens.  mysqlworkbech 6.1 how to apply inserts data changed

答:
Maybe a little bit late but what you insert in that tab it's only for when you do a forward engineering of the model, also you must check the box that says generate INSERTS statements for tables when doing it.
Have a great day.</p>


来源: stackexchange

问:
display grid empty div as spacer?
Building out a navbar that will look something like this:

```<code>|----------------------------------------------------------|
|                  link     Logo     link            link  |
|----------------------------------------------------------|
</code>```

My thought process for creating this layout is to have a html structure that looks like:

```<code><nav>
  <div></div>
  <div>
    link
    logo
    link
  </div>
  <div>
    link
  </div>
</nav>
</code>```

and then with CSS, I would do something like:

```<code>display: grid;
grid-template-columns: 200px auto 200px;
...
</code>```

My question here is: is there a better way to recreate this layout? I don't like how I use an empty div to create the space.

I know I can remove the empty div and put something like margin-left: 200px on the 2nd div but that seems kinda hacky as well.

Appreciate the input.

答:
Here's a basic implementation based on your code. It's basically a combination of CSS Grid Layout and Flexible Box Layout.

Inside the main  container use grid-template-columns to distribute the available width using the fr unit. Then use flexbox to layout the content inside each of the
 containers:

nav {
  display: grid;
  grid-template-columns: 2fr 1fr;
}

.links-and-logo,
.just-link {
  display: flex;
  justify-content: flex-end;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><nav>
  <div class="links-and-logo">
    Link
    <img src="https://source.unsplash.com/100x100/?technology" alt="Nature">
    Link
  </div>
  <div class="just-link">
    Link
  </div>
</nav></code>```

ContentLicense: CC BY-SA 4.0

Title: display grid empty div as spacer?

Body:
Building out a navbar that will look something like this:

|----------------------------------------------------------|
|                  link     Logo     link            link  |
|----------------------------------------------------------|

My thought process for creating this layout is to have a html structure that looks like:

    link
    logo
    link

    link

and then with CSS, I would do something like:

display: grid;
grid-template-columns: 200px auto 200px;
...

My question here is: is there a better way to recreate this layout? I don't like how I use an empty div to create the space.

I know I can remove the empty div and put something like margin-left: 200px on the 2nd div but that seems kinda hacky as well.

Appreciate the input.

Body:
Here's a basic implementation based on your code. It's basically a combination of CSS Grid Layout and Flexible Box Layout.

Inside the main <nav> container use grid-template-columns to distribute the available width using the fr unit. Then use flexbox to layout the content inside each of the <div> containers:

nav {
  display: grid;
  grid-template-columns: 2fr 1fr;
}

.links-and-logo,
.just-link {
  display: flex;
  justify-content: flex-end;
}

<nav>
  <div class="links-and-logo">
    <a href="#">Link</a>
    <img src="https://source.unsplash.com/100x100/?technology" alt="Nature">
    <a href="#">Link</a>
  </div>
  <div class="just-link">
    <a href="#">Link</a>
  </div>
</nav>


问:
How can I convert an array into an Android resource?
I'm new to Android programming, so please let me know if I'm doing anything stupid. However, I currently have an array String[] gamesList that is dynamically generated from a database.

I want to use each element of an array in a Spinner, but the Adapter has a method signature of (Context, int, int). The first and third inputs I can do, but the second is asking for the id of a resource; but I don't have a R.array.someRandomName resource, I only have a local array.

Is there some way to make the array a resource, or if not, how do I do this?

答: Create an ArrayAdapter out of your array (read this), then call the Spinner's  setAdapter() method.

ContentLicense: CC BY-SA 3.0


问:
Python save output of SQL query to Excel
First of all I am trying to retrieve a list of all possible databases, that works fine.

In the second part it executes a query for each database in the list. And it will give me back the name and create_Date for each database where the create_Date is equal or greater than 01-01-2020.

So when I when do 'print(row)' it gives me exaclty what I want.

But how do I write the result of the query to an Excel file? I already import pandas as pd.

```<code>cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};'f'Server={server};'f'Database=
{db};'f'UID={username};'f'PWD={password};')

cursor = cnxn.cursor()
cursor.execute("SELECT name  FROM master.dbo.sysdatabases")
result = cursor.fetchall()
ams_sql02 = []
for row in result:
    ams_sql02.append(row[0])
    ams_sql02 = [databases.lower() for databases in ams_sql02]

cursor = cnxn.cursor()
for db in ams_sql02:
     cursor.execute(f'SELECT name, convert(varchar(10),create_date,103) as dateCreated fROM
     sys.databases where name = \'{db}\' and create_date > \'2020-01-01 10:13:03.290\'
     order by create_date')

      result = cursor.fetchall()
      for row in result:
          print(row)
</code>```

答: Why not put SQL query to Excel without Python? Excel works with datasources like MS SQL Server quite well.</p>

Body:
First of all I am trying to retrieve a list of all possible databases, that works fine.

In the second part it executes a query for each database in the list. And it will give me back the name and create_Date for each database where the create_Date is equal or greater than 01-01-2020.

So when I when do 'print(row)' it gives me exaclty what I want.

But how do I write the result of the query to an Excel file? I already import pandas as pd.

cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};'f'Server={server};'f'Database=
{db};'f'UID={username};'f'PWD={password};')

cursor = cnxn.cursor()
cursor.execute("SELECT name  FROM master.dbo.sysdatabases")
result = cursor.fetchall()
ams_sql02 = []
for row in result:
    ams_sql02.append(row[0])
    ams_sql02 = [databases.lower() for databases in ams_sql02]

cursor = cnxn.cursor()
for db in ams_sql02:
     cursor.execute(f'SELECT name, convert(varchar(10),create_date,103) as dateCreated fROM
     sys.databases where name = \'{db}\' and create_date > \'2020-01-01 10:13:03.290\'
     order by create_date')

      result = cursor.fetchall()
      for row in result:
          print(row)


问:
Git: How to switch branches without touching working directory?
I'm working on a temporary branch foo. After satisfied with changes, I want to move master (which is not current) to the HEAD of foo. I think the common way of doing that on Git is this:

```<code>git checkout master
git reset --hard foo
</code>```

The problem is that when I do git checkout master, Git modifies files at working directory and my IDE goes crazy. I have to close it and open again.

My first workaround was this:

```<code>git branch -D master && git checkout -b master
</code>```

But it makes me loose the upstream setting of master. The following actually works:

```<code>git branch -D master && git checkout -b master && git push --set-upstream origin master
</code>```

But the command is too big.

Is there a better alternative using Git only? i.e. Without add a batch file or macro in the path...

答:
```<code>git switch -C master
</code>```

This will move master to point at the current HEAD, keeping any configuration the branch has such as its upstream, then performs git checkout to that branch.

Body:
I'm working on a temporary branch foo. After satisfied with changes, I want to move master (which is not current) to the HEAD of foo. I think the common way of doing that on Git is this:

git checkout master
git reset --hard foo

The problem is that when I do git checkout master, Git modifies files at working directory and my IDE goes crazy. I have to close it and open again.

My first workaround was this:

git branch -D master && git checkout -b master

But it makes me loose the upstream setting of master. The following actually works:

git branch -D master && git checkout -b master && git push --set-upstream origin master

But the command is too big.

Is there a better alternative using Git only? i.e. Without add a batch file or macro in the path...

Body:
git switch -C master

This will move master to point at the current HEAD, keeping any configuration the branch has such as its upstream, then performs git checkout to that branch.


问:
How to split a list to certain number of lists

with open(path) as file:
    h=file.read().split('\n')
links = list(filter(None, h)) #147 length
chunks = [i.tolist() for i in np.array_split(links, 10) if i.size>0]
```

<p>How can I achieve the same output without using <code>numpy</code> or any external library (not pre-installed with python3)?</p>

<p>A reproducible code without any external libraries would be:</p>

<pre class="lang-py prettyprint-override"><code>links=range(147)
chunks = [i.tolist() for i in np.array_split(links, 10) if i.size>0]
</code>```

The desired output is 10 sub-lists: first 7 sub-list's lengths would be 15 and last 3 sub-list's length would be 14.

答:
It's not pretty, but this approach should be easily understandable.

import math

L = 147
N = 10
links = range(L)

big_size = math.ceil(L/N)
small_size = math.floor(L/N)
num_big_size = round(N * (L/N - small_size))

chunks = []
ind = 0
for i in range(N):
    if i < num_big_size:
        chunks.append(list(links[ind:ind+big_size]))
        ind += big_size
    else:
        chunks.append(list(links[ind:ind+small_size]))
        ind += small_size
```

<p>Note: this doesn't handle edge cases like some arrays being of size 0. Depending what you want you could filter them out.</p>

<p><strong>A different approach using padding</strong></p>

<pre class="lang-py prettyprint-override"><code>import math

L = 147
N = 10
links = range(L)

big_size = math.ceil(L/N)
small_size = math.floor(L/N)
num_big_size = round(N * (L/N - small_size))

links = list(links)
for i in range((num_big_size+1)*big_size-1, N*big_size, big_size):
    links.insert(i, None)
chunks = [links[i:i+big_size] for i in range(0,N*big_size,big_size)]
chunks = [ [el for el in line if el is not None] for line in chunks]
</code>```

Body:
with open(path) as file:
    h=file.read().split('\n')
links = list(filter(None, h)) #147 length
chunks = [i.tolist() for i in np.array_split(links, 10) if i.size>0]

How can I achieve the same output without using numpy or any external library (not pre-installed with python3)?

A reproducible code without any external libraries would be:

links=range(147)
chunks = [i.tolist() for i in np.array_split(links, 10) if i.size>0]

The desired output is 10 sub-lists: first 7 sub-list's lengths would be 15 and last 3 sub-list's length would be 14.

Body:
It's not pretty, but this approach should be easily understandable.

import math

L = 147
N = 10
links = range(L)

big_size = math.ceil(L/N)
small_size = math.floor(L/N)
num_big_size = round(N * (L/N - small_size))

chunks = []
ind = 0
for i in range(N):
    if i < num_big_size:
        chunks.append(list(links[ind:ind+big_size]))
        ind += big_size
    else:
        chunks.append(list(links[ind:ind+small_size]))
        ind += small_size

Note: this doesn't handle edge cases like some arrays being of size 0. Depending what you want you could filter them out.

A different approach using padding

import math

L = 147
N = 10
links = range(L)

big_size = math.ceil(L/N)
small_size = math.floor(L/N)
num_big_size = round(N * (L/N - small_size))

links = list(links)
for i in range((num_big_size+1)*big_size-1, N*big_size, big_size):
    links.insert(i, None)
chunks = [links[i:i+big_size] for i in range(0,N*big_size,big_size)]
chunks = [ [el for el in line if el is not None] for line in chunks]


问:
I can't xcom_push an arguments through BashOperator
I am new to the Airflow's xcom feature. i tried it out with PythonOperator and it was working fine(i.e., i can push and pull the value out of the context), but when i tried it out on BashOperator, it didn't work. However i can pull only the final stdout statement by adding the xcom_push=True attribute during the task creation. that's one thing. 2) But i also wish to push and pull the values based on their keys (to and from the BashOp) like the way we do it in PythonOp.. It would be really helpful since i need to pass tons of variables from one script to another.</p>

答:
@SpaceyBot & Lucas answered your first question.
Regarding second question raised

Blockquote

2) But i also wish to push and pull the values based on their keys (to and from the BashOp) like the way we do it in PythonOp.. It would be really helpful since i need to pass tons of variables from one script to another.

Blockquote

this is not advisable. All XCom pull/push actions are translated to Insert/Select statements in airflow DB.
This will degrade the scheduler performance in time  and slow down the whole processing either because of high number of pull(queries) run or the large amounts of rows retrieved which will be retrieved through Full Table scans instead of Index based scans.

So it's better to consider a different mechanism here - storing info in external json/csv/txt files/.. etc.

Bottom line - XCom is designed for transferring small amounts of data only, mostly counters and status variables.


问:
mySQL query: for a given typeId, getting all entries with their answerCount
I have a mySQL table called entry.  It has 2 test records in it:

```<code>SELECT * FROM entry WHERE typeId = 2
</code>```

I have different types.  For example when typeId = 2 that is a question.  When typeId = 3 that is an answer.  When an answer is inserted into this table the linkId column gets populated with the entryId of the question it is answering.

For example:

```<code>SELECT * FROM entry WHERE typeId = 3
</code>```

As you can see both of these records are typeId = 3 and the linkId both point to entryId = 1.

In the following query I'm only getting the question that has answers associated to it.

```<code>SELECT SQL_CALC_FOUND_ROWS
entry.entryId, entry.entryText, entry.voteCount AS voteCount,
USER.userName, USER.fbId, COUNT(e2.entryId) AS answerCount
FROM entry
INNER JOIN USER ON entry.userId = USER.userId
INNER JOIN entry AS e2 ON e2.linkId = entry.entryId AND e2.active=1
WHERE entry.active = 1
AND entry.typeId = 2
ORDER BY entry.voteCount DESC
</code>```

According to the above statements I have 2 entries that are of typeId = 2.  So I would really like this statement to return both entries but obviously the answerCount for the entry with out any answers would be 0.

Does anyone have any ideas with what I've shown you to fix this query to get the desired results?

UPDATE:

Based off of the suggestion below.  I changed the inner join to a left join:

```<code>SELECT SQL_CALC_FOUND_ROWS DISTINCT
entry.entryId, entry.entryText, entry.voteCount AS voteCount,
USER.userName, USER.fbId
FROM entry
INNER JOIN USER ON entry.userId = USER.userId
LEFT JOIN entry AS e2 ON e2.linkId = entry.entryId AND e2.active=1
WHERE entry.active = 1
AND entry.typeId = 2
ORDER BY entry.voteCount DESC
</code>```

In this statement I took out the count statement (COUNT(e2.entryId) AS answerCount).

This is the result:

When I put in the COUNT statement it only returns the 1 record that returned when it was the inner join:

UPDATE:

I was able to get the rows to return properly by making sure the LEFT JOIN was correct and when I added a GROUP BY, then the row with 0 answers returned properly.

See my query below.

答:
I actually got it to work...

Here is my updated statement:

```<code>SELECT  e1.entryId, e1.entryText, e1.voteCount AS voteCount,
USER.userName, USER.fbId, COUNT(e2.linkId)
FROM    entry e1
INNER JOIN USER ON e1.userId = USER.userId
LEFT JOIN entry e2
ON  e2.linkId = e1.entryId
WHERE e1.active = 1
AND e1.typeId = 2
GROUP BY e1.entryId
ORDER BY e1.voteCount DESC
</code>```

I added the LEFT JOIN as suggested but I also made sure the join was correct and the final piece of the puzzle was the GROUP BY.  Once I put that in, I got my 2 rows that I was originally looking for.

Thanks for all the help!

Body:
I have a mySQL table called entry.  It has 2 test records in it:

SELECT * FROM entry WHERE typeId = 2

I have different types.  For example when typeId = 2 that is a question.  When typeId = 3 that is an answer.  When an answer is inserted into this table the linkId column gets populated with the entryId of the question it is answering.

For example:

SELECT * FROM entry WHERE typeId = 3

As you can see both of these records are typeId = 3 and the linkId both point to entryId = 1.

In the following query I'm only getting the question that has answers associated to it.

SELECT SQL_CALC_FOUND_ROWS
entry.entryId, entry.entryText, entry.voteCount AS voteCount,
USER.userName, USER.fbId, COUNT(e2.entryId) AS answerCount
FROM entry
INNER JOIN USER ON entry.userId = USER.userId
INNER JOIN entry AS e2 ON e2.linkId = entry.entryId AND e2.active=1
WHERE entry.active = 1
AND entry.typeId = 2
ORDER BY entry.voteCount DESC

According to the above statements I have 2 entries that are of typeId = 2.  So I would really like this statement to return both entries but obviously the answerCount for the entry with out any answers would be 0.

Does anyone have any ideas with what I've shown you to fix this query to get the desired results?

UPDATE:

Based off of the suggestion below.  I changed the inner join to a left join:

SELECT SQL_CALC_FOUND_ROWS DISTINCT
entry.entryId, entry.entryText, entry.voteCount AS voteCount,
USER.userName, USER.fbId
FROM entry
INNER JOIN USER ON entry.userId = USER.userId
LEFT JOIN entry AS e2 ON e2.linkId = entry.entryId AND e2.active=1
WHERE entry.active = 1
AND entry.typeId = 2
ORDER BY entry.voteCount DESC

In this statement I took out the count statement (COUNT(e2.entryId) AS answerCount).

This is the result:

When I put in the COUNT statement it only returns the 1 record that returned when it was the inner join:

UPDATE:

I was able to get the rows to return properly by making sure the LEFT JOIN was correct and when I added a GROUP BY, then the row with 0 answers returned properly.

See my query below.

Body:
I actually got it to work...

Here is my updated statement:

SELECT  e1.entryId, e1.entryText, e1.voteCount AS voteCount,
USER.userName, USER.fbId, COUNT(e2.linkId)
FROM    entry e1
INNER JOIN USER ON e1.userId = USER.userId
LEFT JOIN entry e2
ON  e2.linkId = e1.entryId
WHERE e1.active = 1
AND e1.typeId = 2
GROUP BY e1.entryId
ORDER BY e1.voteCount DESC

I added the LEFT JOIN as suggested but I also made sure the join was correct and the final piece of the puzzle was the GROUP BY.  Once I put that in, I got my 2 rows that I was originally looking for.

Thanks for all the help!


问:
How to give a nested table as a default parameter?
I have a function that take a nested table and integer as parameter.

I can create any default argument for the integer paramater.
But for the nested table, I can give only an empty table.

```<code>function  a return packageName.tOfmyrecord(i in integer:=2,j in integer:=2, k in tableofmyrecord2 package.n)  PIPELINED
is
begin
    --do its work
end
</code>```

PLS-00653: aggregate/table functions are not allowed

I want to give as a default parameter the result of the function b which return a nested table.
This solution works. But it's cumbersome. How can I do better?

```<code>function  a return packageName.tOfmyrecord  PIPELINED
is
        c packageName.myrecord;
        m_cur SYS_REFCURSOR;
begin
        OPEN m_cur FOR select * from table(
             packageName.a(2,2,  packageName.b)); --I give the 3 default parameters. 2,2 for the integer and the table returns by the funciton b
        loop
            fetch m_cur into c;
            exit when m_cur%notfound;
            PIPE ROW(c);
        end loop;
        close  m_cur;
 end;
</code>```

I've tried this solution too but it does'nt work. Maybe there is only a little bit to change so that it works-

```<code>function  a return packageName.a  PIPELINED
is
begin
      return packagename(2,2,packagename.b);
end;
</code>```

PLS_00633: return statement in a pipelined function cannot contain an expression.

答:
Create the collection type in an SQL scope:

CREATE TYPE stringlist IS TABLE OF VARCHAR2(20);
```

<p>Then you can use it in SQL statements and in PL/SQL (whereas, if you define the collection in a PL/SQL scope then you can only use it in PL/SQL).</p>

<p>Then you can define your package specification:</p>

<pre class="lang-sql prettyprint-override"><code>CREATE PACKAGE test_package IS
  FUNCTION test_fn(
    a IN INTEGER    DEFAULT 1,
    b IN stringlist DEFAULT stringlist('a','b','c')
  ) RETURN stringlist PIPELINED;
END;
/
</code>```

And package body:

CREATE PACKAGE BODY test_package IS
  FUNCTION test_fn(
    a IN INTEGER    DEFAULT 1,
    b IN stringlist DEFAULT stringlist('a','b','c')
  ) RETURN stringlist PIPELINED
  IS
  BEGIN
    IF b IS NULL THEN
      RETURN;
    END IF;

    FOR i IN 1 .. b.COUNT LOOP
      PIPE ROW ( b(i) || a );
    END LOOP;
  END;
END;
/
```

<p>And use it in SQL with the default arguments:</p>

<pre class="lang-sql prettyprint-override"><code>SELECT *
FROM   TABLE( test_package.test_fn() );
</code>```

Which outputs:

```
| COLUMN_VALUE |
| :----------- |
| a1           |
| b1           |
| c1           |
```

Or provide your own arguments:

SELECT *
FROM   TABLE(
         test_package.test_fn(
           b => stringlist('d','e','f','g')
         )
       );
```

<p>Which outputs:</p>

<blockquote>
```
| COLUMN_VALUE |
| :----------- |
| d1           |
| e1           |
| f1           |
| g1           |
```

db<>fiddle here

Body:
I have a function that take a nested table and integer as parameter.

I can create any default argument for the integer paramater.
But for the nested table, I can give only an empty table.

function  a return packageName.tOfmyrecord(i in integer:=2,j in integer:=2, k in tableofmyrecord2 package.n)  PIPELINED
is
begin
    --do its work
end

PLS-00653: aggregate/table functions are not allowed

I want to give as a default parameter the result of the function b which return a nested table.
This solution works. But it's cumbersome. How can I do better?

function  a return packageName.tOfmyrecord  PIPELINED
is
        c packageName.myrecord;
        m_cur SYS_REFCURSOR;
begin
        OPEN m_cur FOR select * from table(
             packageName.a(2,2,  packageName.b)); --I give the 3 default parameters. 2,2 for the integer and the table returns by the funciton b
        loop
            fetch m_cur into c;
            exit when m_cur%notfound;
            PIPE ROW(c);
        end loop;
        close  m_cur;
 end;

I've tried this solution too but it does'nt work. Maybe there is only a little bit to change so that it works-

function  a return packageName.a  PIPELINED
is
begin
      return packagename(2,2,packagename.b);
end;

PLS_00633: return statement in a pipelined function cannot contain an expression.

Body:
Create the collection type in an SQL scope:

CREATE TYPE stringlist IS TABLE OF VARCHAR2(20);

Then you can use it in SQL statements and in PL/SQL (whereas, if you define the collection in a PL/SQL scope then you can only use it in PL/SQL).

Then you can define your package specification:

CREATE PACKAGE test_package IS
  FUNCTION test_fn(
    a IN INTEGER    DEFAULT 1,
    b IN stringlist DEFAULT stringlist('a','b','c')
  ) RETURN stringlist PIPELINED;
END;
/

And package body:

CREATE PACKAGE BODY test_package IS
  FUNCTION test_fn(
    a IN INTEGER    DEFAULT 1,
    b IN stringlist DEFAULT stringlist('a','b','c')
  ) RETURN stringlist PIPELINED
  IS
  BEGIN
    IF b IS NULL THEN
      RETURN;
    END IF;

    FOR i IN 1 .. b.COUNT LOOP
      PIPE ROW ( b(i) || a );
    END LOOP;
  END;
END;
/

And use it in SQL with the default arguments:

SELECT *
FROM   TABLE( test_package.test_fn() );

Which outputs:

| COLUMN_VALUE |
| :----------- |
| a1           |
| b1           |
| c1           |

Or provide your own arguments:

SELECT *
FROM   TABLE(
         test_package.test_fn(
           b => stringlist('d','e','f','g')
         )
       );

Which outputs:

| COLUMN_VALUE |
| :----------- |
| d1           |
| e1           |
| f1           |
| g1           |

db<>fiddle here


问:
Submit telemetry via gateway mode on HTTP & MQTT adaptors
I can create things, set up connections and apply the connection policy to the thing so I can submit telemetry from a thing via HTTP and MQTT and receive it on my MQTT server/connection. I've got all this working.

But when I try to switch to using gateway mode via HTTP or MQTT adaptor it no longer works.

I'm not sure how to authorise a thing to act on behalf of another thing.

When I use the HTTP adaptor I get "gateway unknown, disabled or not authorized to act on behalf of device".

答: As Kai Hudalla pointed out the when registering a device you can set the via property to authorise a gateway to act on it's behalf and its documented at https://docs.bosch-iot-suite.com/hub/general-concepts/gatewaymode.html</p>


问:
How to make specific bit manipulation?
I'm doing practice of bit manipulation in arduino with a 74HC595 shift register.

I would like to create an algorithm that allows the binary digit to perform this way:

1 0 0 0 0 0 0 1

0 1 0 0 0 0 1 0

0 0 1 0 0 1 0 0

.

.

.

1 0 0 0 0 0 0 1

In this type of function the decimal values are: (129,66,36,24,24,36,66,129) and so on in a loop.

How can I perform this type of shifting? I don't have any fluency thinking this type of operation, I have only performed a circular shift with "an algorithm" like:

```<code>//my circular shift

myByte = myByte*128 + myByte/2
</code>```

But I don't know how to perform the output that I showed.

How can I do this? Thanks

答:
You're looking for a single operation that can be applied to an 8 bit number and result in the given pattern.

You want

```<code>x_(n+1) = f(x_(n))
</code>```

for all given inputs and outputs. The problem is that there are a few potential inputs that have one of two possible outputs. You want both

```<code>36 = f(66)
</code>```

and

```<code>129 = f(66)
</code>```

This can't be done using only one variable. You can either implement a lookup table for the sequence you want (which is what I suggest). Or you can take two variables, implement circular shifts (in opposite directions) on each, and take the bitwise OR of the results.

```<code>uint8_t n1 = 128, n2 = 1;
for(;;)
{
    std::cout << n1 | n2 << "\n";
    n1 = circular_right_shift(n1);
    n2 = circular_left_shift(n2);
}
</code>```

Title: How to make specific bit manipulation?

Body:
I'm doing practice of bit manipulation in arduino with a 74HC595 shift register.

I would like to create an algorithm that allows the binary digit to perform this way:

1 0 0 0 0 0 0 1

0 1 0 0 0 0 1 0

0 0 1 0 0 1 0 0

.

.

.

1 0 0 0 0 0 0 1

In this type of function the decimal values are: (129,66,36,24,24,36,66,129) and so on in a loop.

How can I perform this type of shifting? I don't have any fluency thinking this type of operation, I have only performed a circular shift with "an algorithm" like:

//my circular shift

myByte = myByte*128 + myByte/2

But I don't know how to perform the output that I showed.

How can I do this? Thanks

Body:
You're looking for a single operation that can be applied to an 8 bit number and result in the given pattern.

You want

x_(n+1) = f(x_(n))

for all given inputs and outputs. The problem is that there are a few potential inputs that have one of two possible outputs. You want both

36 = f(66)

and

129 = f(66)

This can't be done using only one variable. You can either implement a lookup table for the sequence you want (which is what I suggest). Or you can take two variables, implement circular shifts (in opposite directions) on each, and take the bitwise OR of the results.

uint8_t n1 = 128, n2 = 1;
for(;;)
{
    std::cout << n1 | n2 << "\n";
    n1 = circular_right_shift(n1);
    n2 = circular_left_shift(n2);
}


问:
Creating NuGet package: NU5128 exception - not clear on how to fix
I have a DLL addressing the .NET 4.7.1 library.

Probably irrelevant, but it's written in C# and consumes NuGet packages using the "packages.config" pattern, rather than the newer PackageReference configuration.

I publish this as a NuGet package (have been doing this for several years).  But now when I execute the following:

```<code>nuget pack -Properties Configuration=Release
</code>```

I get the following warning:

Error NU5128: Some target frameworks declared in the dependencies
  group of the nuspec and the lib/ref folder do not have exact matches
  in the other location. Consult the list of actions below:
  - Add a dependency group for .NETFramework4.7.1 to the nuspec

I don't have anything in the dependencies group of the nuspec:

```<code><?xml version="1.0"?>
<package >
    <metadata>
        <id>*******</id>
        <version>*******</version>
        <title>*******</title>
        <authors>*******</authors>
        <owners>*******</owners>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>*******</description>
        <releaseNotes>*******</releaseNotes>
        <copyright>*******</copyright>
        <tags>*******</tags>
   </metadata>
</package>
</code>```

This consumes the following NuGet packages:

Microsoft.AspNet.WebApi.Client v5.2.7

Microsoft.AspNet.WebApi.Core v5.2.7

Microsoft.CodeAnalysis.FxCopAnalyzers v2.9.8

Microsoft.CodeAnalysis.VersionCheckAnalyzer v2.9.8

Microsoft.CodeQuality.Analyzers v2.9.8

Microsoft.NetCore.Analyzers v2.9.8

Microsoft.NetFramework.Analyzers v2.9.8

Newtonsoft.Json v12.0.3

StyleCop.Analyzers v1.1.118

When I look under the References, I see the following (used ~ to shorten the path):

Microsoft.CSharp ~.NETFramework\v4.7.1\Microsoft.CSharp.dll

Newtonsoft.Json ~\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll

System ~\NETFramework\v4.7.1\System.dll

System.Configuration ~.NETFramework\v4.7.1\System.Configuration.dll

System.Core ~.NETFramework\v4.7.1\System.Core.dll

System.Data ~.NETFramework\v4.7.1\System.Data.dll

System.Data.DataSetExtensions ~.NETFramework\v4.7.1\System.Data.DataSetExtensions.dll

System.Net.Http ~.NETFramework\v4.7.1\System.Net.Http.dll

System.Net.Http.Formatting ~\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll

System.Web.Http ~\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll

System.Xml ~.NETFramework\v4.7.1\System.Xml.dll

System.Xml.Linq ~.NETFramework\v4.7.1\System.Xml.Linq.dll

So to my mind, everything looks like it's .NET 4.7.1 compatible, so why this warning?

Following the details given in NuGet Warning NU5128, I therefore added a dependency group:

```<code><?xml version="1.0"?>
<package >
    <metadata>
        <id>*******</id>
        <version>*******</version>
        <title>*******</title>
        <authors>*******</authors>
        <owners>*******</owners>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>*******</description>
        <releaseNotes>*******</releaseNotes>
        <copyright>*******</copyright>
        <tags>*******</tags>
        <dependencies>
          <group targetFramework=".NETFramework4.7.1" />
        </dependencies>
   </metadata>
</package>
</code>```

But this has no effect, I still get the error.

答: As per NU5128 doc, This warning was added during NuGet 5.3's development, and first was available in .NET Core SDK 3.0 Preview 9. NuGet/Home#8583 tracks an issue where the warning was being raised in too many scenarios. You can use the NoWarn MSBuild property (add $(NoWarn);NU5128 to any PropertyGroup in your project file). If you have multiple projects affected, you can use Directory.Build.targets to automatically add NoWarn to all projects

Body:
I have a DLL addressing the .NET 4.7.1 library.

Probably irrelevant, but it's written in C# and consumes NuGet packages using the "packages.config" pattern, rather than the newer PackageReference configuration.

I publish this as a NuGet package (have been doing this for several years).  But now when I execute the following:

nuget pack -Properties Configuration=Release

I get the following warning:

Error NU5128: Some target frameworks declared in the dependencies
  group of the nuspec and the lib/ref folder do not have exact matches
  in the other location. Consult the list of actions below:
  - Add a dependency group for .NETFramework4.7.1 to the nuspec

I don't have anything in the dependencies group of the nuspec:

<?xml version="1.0"?>
<package >
    <metadata>
        <id>*******</id>
        <version>*******</version>
        <title>*******</title>
        <authors>*******</authors>
        <owners>*******</owners>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>*******</description>
        <releaseNotes>*******</releaseNotes>
        <copyright>*******</copyright>
        <tags>*******</tags>
   </metadata>
</package>

This consumes the following NuGet packages:

Microsoft.AspNet.WebApi.Client v5.2.7

Microsoft.AspNet.WebApi.Core v5.2.7

Microsoft.CodeAnalysis.FxCopAnalyzers v2.9.8

Microsoft.CodeAnalysis.VersionCheckAnalyzer v2.9.8

Microsoft.CodeQuality.Analyzers v2.9.8

Microsoft.NetCore.Analyzers v2.9.8

Microsoft.NetFramework.Analyzers v2.9.8

Newtonsoft.Json v12.0.3

StyleCop.Analyzers v1.1.118

When I look under the References, I see the following (used ~ to shorten the path):

Microsoft.CSharp ~.NETFramework\v4.7.1\Microsoft.CSharp.dll

Newtonsoft.Json ~\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll

System ~\NETFramework\v4.7.1\System.dll

System.Configuration ~.NETFramework\v4.7.1\System.Configuration.dll

System.Core ~.NETFramework\v4.7.1\System.Core.dll

System.Data ~.NETFramework\v4.7.1\System.Data.dll

System.Data.DataSetExtensions ~.NETFramework\v4.7.1\System.Data.DataSetExtensions.dll

System.Net.Http ~.NETFramework\v4.7.1\System.Net.Http.dll

System.Net.Http.Formatting ~\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll

System.Web.Http ~\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll

System.Xml ~.NETFramework\v4.7.1\System.Xml.dll

System.Xml.Linq ~.NETFramework\v4.7.1\System.Xml.Linq.dll

So to my mind, everything looks like it's .NET 4.7.1 compatible, so why this warning?

Following the details given in NuGet Warning NU5128, I therefore added a dependency group:

<?xml version="1.0"?>
<package >
    <metadata>
        <id>*******</id>
        <version>*******</version>
        <title>*******</title>
        <authors>*******</authors>
        <owners>*******</owners>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>*******</description>
        <releaseNotes>*******</releaseNotes>
        <copyright>*******</copyright>
        <tags>*******</tags>
        <dependencies>
          <group targetFramework=".NETFramework4.7.1" />
        </dependencies>
   </metadata>
</package>

But this has no effect, I still get the error.


问:
In Azure templates repository, is there a way to mention repository for a filePath parameter of azure task 'pythonScript'?
I have a template repository for build pipelines say 'azure-templates-repo', I have python task template as mentioned below:

```<code>steps:
- task: PythonScript@0
  inputs:
    scriptSource: 'filepath'
    scriptPath: 'python_test.yml' #this is located on repo: 'azure-templates-repo'
</code>```

My question is on scriptPath, when I use this template in a build pipeline azure-pipeline.yml in a repository my-great-app, azure attempts to find the file in my-great-app instead where it really located azure-templates-repo.

So, Is there a way to mention repository for a filePath parameter of azure task 'pythonScript'?

答:
When you use a template in a pipeline, you are only consuming the .yml template file, not the entire repository that contains the template. So by default no other additional files (besides the template itself) that may exist in the template repository will be available when the primary pipeline is composed.

If you need access to scripts or other files that exist in your template repository you will need to use the checkout task and actually checkout the template repository.

- checkout: git://MyProject/MyTemplateRepo

One thing to be aware of if you go down the path of checking out multiple repositories is that it will cause the structure of your $(Build.SourcesDirectory) to change. In practice this can cause pain as you have to update any tasks that expected your primary repository location to be at the root of $(Build.SourcesDirectory).

That mutation of the $(Build.SourcesDirectory) might not be a big deal for you for new pipelines. It can turn into a pain if you have lots of pipelines that you want to consume a new template in, that require supporting scripts.

One option is to package the supporting template scripts, and publish them to an internal package feed. Then within your template block pull down the required script as a package. I have used this strategy before with templates that needed supporting powerShell scripts. We pipeline those scripts and publish them as a universal packages, then consume them at the template level.

Body:
I have a template repository for build pipelines say 'azure-templates-repo', I have python task template as mentioned below:

steps:
- task: PythonScript@0
  inputs:
    scriptSource: 'filepath'
    scriptPath: 'python_test.yml' #this is located on repo: 'azure-templates-repo'

My question is on scriptPath, when I use this template in a build pipeline azure-pipeline.yml in a repository my-great-app, azure attempts to find the file in my-great-app instead where it really located azure-templates-repo.

So, Is there a way to mention repository for a filePath parameter of azure task 'pythonScript'?


问:
Can I create a new object with the results of a query?
If there's a better way to do this, let me know, but this is kind of how i envisioned it. Can it be done?

Customer is a table in the database/datacontext. What I want is to query that table and build a new object with it.

If i were to insert a record, I would do something like this:

```<code>Customer cust = new Customer(){ FirstName = "A", LastName = "B", Age = 31 }
db.Customers.InsertOnSubmit(cust);
db.SubmitChanges();
</code>```

What I want to do is instantiate that object with a query result. Something like this:

```<code>var query =
     from a in db.Customers
     where a.FirstName == "A"
     select a;

Customer cust = new Customer(){ query };
</code>```

or maybe even

```<code>Customer cust = new Customer(){
     from a in db.Customers
     where a.FistName == "A"
     select a;
}
</code>```

is there some way to do this?

答:
```<code>db.Customers
    .Where(x => x.FirstName == "A")
    .Select(x => new Customer{ FirstName =x.FirstName , LastName = x.LastName, Age = x.Age})
    .FirstOrDefault();
</code>```

Body:
If there's a better way to do this, let me know, but this is kind of how i envisioned it. Can it be done?

Customer is a table in the database/datacontext. What I want is to query that table and build a new object with it.

If i were to insert a record, I would do something like this:

Customer cust = new Customer(){ FirstName = "A", LastName = "B", Age = 31 }
db.Customers.InsertOnSubmit(cust);
db.SubmitChanges();

What I want to do is instantiate that object with a query result. Something like this:

var query =
     from a in db.Customers
     where a.FirstName == "A"
     select a;

Customer cust = new Customer(){ query };

or maybe even

Customer cust = new Customer(){
     from a in db.Customers
     where a.FistName == "A"
     select a;
}

is there some way to do this?


问:
Bootstrap 4 row breaks for no reason
I know there have already been questions on this subject, but none of the solutions I found here were helpful. Hopefully someone can help me here:
I have a row with 4 columns of data as follows:

Here is the code:

```<code><hr class="mb-4">
    <div>
        <h3>{{ player.full_name }}</h3>
        <h4> {{ player.position }}</h4>
        <h5> {{ player.team }}</h5>
    </div>
    <hr class="mb-4">
    <div class="row">
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                Form
            </div>
            <div class="text-center ">
                {{ player.form }}
            </div>
        </div>
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                Price
            </div>
            <div class="text-center">
                <span>£</span>{{ player.price }}
            </div>
        </div>
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                Total
            </div>
            <div class="text-center">
                {{ player.total_points }}
            </div>
        </div>
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                TSB
            </div>
            <div class="text-center">
                {{ player.tsb }}%
            </div>
        </div>
    </div>
</code>```

As far as I understand, the 4 columns should keep in one row even in smaller screen, especially as there is definitely enough space to show them all together. On small screens this is what I get:

Nothing I change seem to help in this matter. I would like all columns to be shown in the same row even on smaller screens. Appreciate your help

Edit
The source of the problem is in the  of my page.

```<code><head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round">
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css"
          href="https://cdn.datatables.net/v/bs4/dt-1.10.20/b-1.6.1/cr-1.5.2/r-2.2.3/sl-1.3.1/datatables.min.css"/>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
            integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
            crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
            integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
            crossorigin="anonymous"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.10.20/b-1.6.1/cr-1.5.2/r-2.2.3/sl-1.3.1/datatables.min.js"></script>
</head>
</code>```

So the problem is when using the Bootstrap 4 tag instead of Bootstrap 3 like in the example below. Is that by design?

答: if you want it to be in 4 columns at any device width, just use the class col-3 instead col-xs-3 col-sm-3

Title: Bootstrap 4 row breaks for no reason

Body:
I know there have already been questions on this subject, but none of the solutions I found here were helpful. Hopefully someone can help me here:
I have a row with 4 columns of data as follows:

Here is the code:

{{ player.full_name }}

 {{ player.position }}

 {{ player.team }}

                Form

                {{ player.form }}

                Price

                £{{ player.price }}

                Total

                {{ player.total_points }}

                TSB

                {{ player.tsb }}%

As far as I understand, the 4 columns should keep in one row even in smaller screen, especially as there is definitely enough space to show them all together. On small screens this is what I get:

Nothing I change seem to help in this matter. I would like all columns to be shown in the same row even on smaller screens. Appreciate your help

Edit
The source of the problem is in the  of my page.

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round">
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css"
          href="https://cdn.datatables.net/v/bs4/dt-1.10.20/b-1.6.1/cr-1.5.2/r-2.2.3/sl-1.3.1/datatables.min.css"/>

So the problem is when using the Bootstrap 4 tag instead of Bootstrap 3 like in the example below. Is that by design?


问:
iCal STANDARD or DAYLIGHT error when already defined
I have an iCal file that I am validating here

https://icalendar.org/validator.html?url=https://www.youreontime.com/calendar/syncstaff/d72e6edb-90da-4cc7-86c0-16fee6f3ad2e

It is giving an error At least one STANDARD or DAYLIGHT property must be defined here near line # 4

Here is the file which does have a time zone section at the top.

```<code>BEGIN:VCALENDAR
PRODID:-//github.com/rianjs/ical.net//NONSGML ical.net 4.0//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Australia/Sydney
X-LIC-LOCATION:Australia/Sydney
END:VTIMEZONE
BEGIN:VEVENT
ATTENDEE;CN=Adriane Bews;ROLE=REQ-PARTICIPANT:MAILTO:demo@youreontime.com
DESCRIPTION:Walter Jones (Ph 12456788)  Dry off. Staff Adriane Bews
DTEND;TZID=Australia/Sydney:20200215T133500
DTSTAMP:20200215T105625Z
DTSTART;TZID=Australia/Sydney:20200215T132000
SEQUENCE:0
STATUS:TENTATIVE
SUMMARY:Walter Jones Dry off
UID:yot-10025135
END:VEVENT
END:VCALENDAR
</code>```

答:
Craig, Evan pointed you in the right direction.

What the message is saying is that "AT LEAST ONE STANDARD OR DAYLIGHT PROPERTY" must be defined IF one defines a VTIMEZONE.   A VTIMEZONE is a full definition of the timezone for the period of your events -ie if there is daylight saving, then one must define when there is a changeover, as per the example

```<code>  BEGIN:VTIMEZONE
  TZID:US-Eastern
  LAST-MODIFIED:19870101T000000Z
  BEGIN:STANDARD
  DTSTART:19971026T020000
  RDATE:19971026T020000
  TZOFFSETFROM:-0400
  TZOFFSETTO:-0500
  TZNAME:EST
  END:STANDARD
  BEGIN:DAYLIGHT
  DTSTART:19971026T020000
  RDATE:19970406T020000
  TZOFFSETFROM:-0500
  TZOFFSETTO:-0400
  TZNAME:EDT
  END:DAYLIGHT
  END:VTIMEZONE
</code>```

Personally I think it would be great if one were able to assume that both one's own system and the receiving system had the latest Olson database timezone definitions and thus that any recurring events would end up with the same day & time.   However I supposed there is no guarantee of that, so the VTIMEZONE allows one to define the daylight saving changes etc that one's system is using.

Many systems may accept ics files without VTIMEZONES BUT they are supposed to be there and correctly defined.

Body:
I have an iCal file that I am validating here

https://icalendar.org/validator.html?url=https://www.youreontime.com/calendar/syncstaff/d72e6edb-90da-4cc7-86c0-16fee6f3ad2e

It is giving an error At least one STANDARD or DAYLIGHT property must be defined here near line # 4

Here is the file which does have a time zone section at the top.

BEGIN:VCALENDAR
PRODID:-//github.com/rianjs/ical.net//NONSGML ical.net 4.0//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Australia/Sydney
X-LIC-LOCATION:Australia/Sydney
END:VTIMEZONE
BEGIN:VEVENT
ATTENDEE;CN=Adriane Bews;ROLE=REQ-PARTICIPANT:MAILTO:demo@youreontime.com
DESCRIPTION:Walter Jones (Ph 12456788)  Dry off. Staff Adriane Bews
DTEND;TZID=Australia/Sydney:20200215T133500
DTSTAMP:20200215T105625Z
DTSTART;TZID=Australia/Sydney:20200215T132000
SEQUENCE:0
STATUS:TENTATIVE
SUMMARY:Walter Jones Dry off
UID:yot-10025135
END:VEVENT
END:VCALENDAR

Body:
Craig, Evan pointed you in the right direction.

What the message is saying is that "AT LEAST ONE STANDARD OR DAYLIGHT PROPERTY" must be defined IF one defines a VTIMEZONE.   A VTIMEZONE is a full definition of the timezone for the period of your events -ie if there is daylight saving, then one must define when there is a changeover, as per the example

  BEGIN:VTIMEZONE
  TZID:US-Eastern
  LAST-MODIFIED:19870101T000000Z
  BEGIN:STANDARD
  DTSTART:19971026T020000
  RDATE:19971026T020000
  TZOFFSETFROM:-0400
  TZOFFSETTO:-0500
  TZNAME:EST
  END:STANDARD
  BEGIN:DAYLIGHT
  DTSTART:19971026T020000
  RDATE:19970406T020000
  TZOFFSETFROM:-0500
  TZOFFSETTO:-0400
  TZNAME:EDT
  END:DAYLIGHT
  END:VTIMEZONE

Personally I think it would be great if one were able to assume that both one's own system and the receiving system had the latest Olson database timezone definitions and thus that any recurring events would end up with the same day & time.   However I supposed there is no guarantee of that, so the VTIMEZONE allows one to define the daylight saving changes etc that one's system is using.

Many systems may accept ics files without VTIMEZONES BUT they are supposed to be there and correctly defined.


问:
Cannot Create Extra Operator Link on DatabricksRunNowOperator in Airflow
I'm currently trying to build an extra link on the DatabricksRunNowOperator in airflow so I can quickly access the databricks run without having to rummage through the logs. As a starting point I'm simply trying to add a link to google in the task instance menu. I've followed the procedure shown in this tutorial creating the following code placed within my airflow home plugins folder:

```<code>from airflow.plugins_manager import AirflowPlugin
from airflow.models.baseoperator import BaseOperatorLink
from airflow.contrib.operators.databricks_operator import DatabricksRunNowOperator

class DBLogLink(BaseOperatorLink):
    name = 'run_link'

    operators = [DatabricksRunNowOperator]

    def get_link(self, operator, dttm):
        return "https://www.google.com"

class AirflowExtraLinkPlugin(AirflowPlugin):
    name = "extra_link_plugin"
    operator_extra_links = [DBLogLink(), ]
</code>```

However the extra link does not show up, even after restarting the webserver etc:

Here's the code I'm using to create the DAG:

```<code>from airflow import DAG
from airflow.contrib.operators.databricks_operator import DatabricksRunNowOperator
from datetime import datetime, timedelta

DATABRICKS_CONN_ID = '____'

args = {
    'owner': 'Airflow',
    'depends_on_past': False,
    'start_date': datetime(2020, 2, 13),
    'retries': 0
}

dag = DAG(
    dag_id = 'testing_notebook',
    default_args = args,
    schedule_interval = timedelta(days=1)
)

DatabricksRunNowOperator(
    task_id = 'mail_reader',
    dag = dag,
    databricks_conn_id = DATABRICKS_CONN_ID,
    polling_period_seconds=1,
    job_id = ____,
    notebook_params = {____}
)
</code>```

I feel like I'm missing something really basic, but I just can't figure it out.

Additional info

Airflow version 1.10.9

Running on ubuntu 18.04.3

答: I've worked it out. You need to have your webserver running as RBAC. This means setting up airflow with authentication and adding users. RBAC can be turned on by setting rbac = True in your airflow.cfg file.

Body:
I'm currently trying to build an extra link on the DatabricksRunNowOperator in airflow so I can quickly access the databricks run without having to rummage through the logs. As a starting point I'm simply trying to add a link to google in the task instance menu. I've followed the procedure shown in this tutorial creating the following code placed within my airflow home plugins folder:

from airflow.plugins_manager import AirflowPlugin
from airflow.models.baseoperator import BaseOperatorLink
from airflow.contrib.operators.databricks_operator import DatabricksRunNowOperator

class DBLogLink(BaseOperatorLink):
    name = 'run_link'

    operators = [DatabricksRunNowOperator]

    def get_link(self, operator, dttm):
        return "https://www.google.com"

class AirflowExtraLinkPlugin(AirflowPlugin):
    name = "extra_link_plugin"
    operator_extra_links = [DBLogLink(), ]

However the extra link does not show up, even after restarting the webserver etc:

Here's the code I'm using to create the DAG:

from airflow import DAG
from airflow.contrib.operators.databricks_operator import DatabricksRunNowOperator
from datetime import datetime, timedelta

DATABRICKS_CONN_ID = '____'

args = {
    'owner': 'Airflow',
    'depends_on_past': False,
    'start_date': datetime(2020, 2, 13),
    'retries': 0
}

dag = DAG(
    dag_id = 'testing_notebook',
    default_args = args,
    schedule_interval = timedelta(days=1)
)

DatabricksRunNowOperator(
    task_id = 'mail_reader',
    dag = dag,
    databricks_conn_id = DATABRICKS_CONN_ID,
    polling_period_seconds=1,
    job_id = ____,
    notebook_params = {____}
)

I feel like I'm missing something really basic, but I just can't figure it out.

Additional info

Airflow version 1.10.9

Running on ubuntu 18.04.3


问:
MVC - Get Drop Down list Selected value in Window.Open
In my MVC View I have a DropDownList in a form

```<code> @Html.DropDownList("ddlAbb"
        , new List<SelectListItem>(){
            new SelectListItem { Selected = true, Text = "All", Value = "-1"},
            new SelectListItem { Selected = false, Text = "Some", Value = "1"},
            new SelectListItem { Selected = false, Text = "Not Some", Value = "0"}
        }
        , new { @id = "ddlAbb", @class = "form-control", @onchange = "$(this).closest('form').submit();" })
</code>```

and for me is easy to get its value on submit.

But in the same page i have another button not in the form:

```<code><input type="button" value="Report" onclick="window.open('@Url.Action("GetPdf", "PrintList", new { listId = Url.RequestContext.RouteData.Values["id"], ddlAbb = [selectedValue]})')" />
</code>```

As you can see, I need to get the DDL selected value for use it as parameter in a windows.open function.

Is there any way to do this in a MVC View?

Thank you

答:
Ok, shame for me.

I was only looking the problem from a wrong view.

I simply needed to create a function to get the selected value of the DDL and open the new windows. Then I need to call this function onclick instead of window.open.

Body:
In my MVC View I have a DropDownList in a form

 @Html.DropDownList("ddlAbb"
        , new List<SelectListItem>(){
            new SelectListItem { Selected = true, Text = "All", Value = "-1"},
            new SelectListItem { Selected = false, Text = "Some", Value = "1"},
            new SelectListItem { Selected = false, Text = "Not Some", Value = "0"}
        }
        , new { @id = "ddlAbb", @class = "form-control", @onchange = "$(this).closest('form').submit();" })

and for me is easy to get its value on submit.

But in the same page i have another button not in the form:

<input type="button" value="Report" onclick="window.open('@Url.Action("GetPdf", "PrintList", new { listId = Url.RequestContext.RouteData.Values["id"], ddlAbb = [selectedValue]})')" />

As you can see, I need to get the DDL selected value for use it as parameter in a windows.open function.

Is there any way to do this in a MVC View?

Thank you


问:
Is there replacement for cat on Windows
I need to join two binary files with a *.bat script on Windows.

How can I achieve that?

答:
Windows type command works similarly to UNIX cat.

Example 1:

```<code>type file1 file2 > file3
</code>```

is equivalent of:

```<code>cat file1 file2 > file3
</code>```

Example 2:

```<code>type  *.vcf > all_in_one.vcf
</code>```

This command will merge all the vcards into one.

OwnerDisplayName: Artem Tikhomirov

Title: Is there replacement for cat on Windows

LastEditorDisplayName: Greg Hewgill

Body:
Windows type command works similarly to UNIX cat.

Example 1:

type file1 file2 > file3

is equivalent of:

cat file1 file2 > file3

Example 2:

type  *.vcf > all_in_one.vcf

This command will merge all the vcards into one.

OwnerDisplayName: Nathan Jones

LastEditorDisplayName: Nathan Jones


问:
Modular web site with zend framework, stack of actions
How to build modular web site with Zend framework. I have pages in db, every page is represented as url. Every page has 1toN contents. Every content has controller, action and position (+other now not important columns). So, one request is one page and multiple contents (multiple actions). How can I build all actions before the output? I would like to have layout design like example bellow, where contents are put in there containers (actions are run before layout print-out).

```<code><div id="left">
   <?= $this->layout()->left_container ?>
</div>
<div id="center">
   <?= $this->layout()->center_container ?>
</div>
<div id="right">
   <?= $this->layout()->right_container ?>
</div>
</code>```

Until now I called actions from layout view, but I do not like this approach:

```<code>foreach ($contents as $item) {
    echo $this->action($item['action'], $item['controller'], null, array('content' => $item));
}
</code>```

Thanks.

p.s.

adepretis's code is similar to my, views of my actions are run inside layout, which means that when error occurres it is printed in layout where the action is called. Is there no whey that actions are build before layout output? Another bad thing is that in every action I must run ...->setResponseSegment, I would like this to be automated.

p.s. #2

I have found answer, it is listed bellow as answer. If there is a whey I can do this easier please write it down.

答:
I found my answer on other forum. Here is the asnwer:

MyPlugin

```<code>class MyPlugin extends Zend_Controller_Plugin_Abstract
{

    public function routeStartup(Zend_Controller_Request_Abstract $request)
    {
        $action_stack = new Zend_Controller_Action_Helper_ActionStack();
        // here I will read actions from db and run it in loop, but for example few are staticly added bellow
        $action_stack->actionToStack('index', 'content', 'default', array('position' => 'left'));
        $action_stack->actionToStack('index', 'content', 'default', array('position' => 'center'));
        $action_stack->actionToStack('index', 'edo', 'default', array('position' => 'center'));
        $action_stack->actionToStack('left', 'edo', 'default', array('position' => 'left'));
        $action_stack->actionToStack('right', 'edo', 'default', array('position' => 'right'));
    }

}
</code>```

BaseController, that every controller extends

```<code>class BaseController extends Zend_Controller_Action
{

    public function preDispatch()
    {
        $position = $this->_request->getParam('position', false);
        if ($position) {
            $this->_helper->viewRenderer->setResponseSegment($position);
        }
    }

}
</code>```

Layout.phtml

```<code><div>
    <h2><u>LEFT:</u></h2>
    <?=$this->layout()->left?>
</div>
<div>
    <h2><u>CENTER:</u></h2>
    <?=$this->layout()->center?>
</div>
<div>
    <h2><u>RIGHT:</u></h2>
    <?=$this->layout()->right?>
</div>
</code>```

This is what I wanted, if anyone has a better solution please answer the question and I will accept his answer.

OwnerDisplayName: Glavič

ContentLicense: CC BY-SA 2.5

Body:
How to build modular web site with Zend framework. I have pages in db, every page is represented as url. Every page has 1toN contents. Every content has controller, action and position (+other now not important columns). So, one request is one page and multiple contents (multiple actions). How can I build all actions before the output? I would like to have layout design like example bellow, where contents are put in there containers (actions are run before layout print-out).

   <?= $this->layout()->left_container ?>

   <?= $this->layout()->center_container ?>

   <?= $this->layout()->right_container ?>

Until now I called actions from layout view, but I do not like this approach:

foreach ($contents as $item) {
    echo $this->action($item['action'], $item['controller'], null, array('content' => $item));
}

Thanks.

p.s.

adepretis's code is similar to my, views of my actions are run inside layout, which means that when error occurres it is printed in layout where the action is called. Is there no whey that actions are build before layout output? Another bad thing is that in every action I must run ...->setResponseSegment, I would like this to be automated.

p.s. #2

I have found answer, it is listed bellow as answer. If there is a whey I can do this easier please write it down.

LastEditorDisplayName: glavić

Body:
I found my answer on other forum. Here is the asnwer:

MyPlugin

class MyPlugin extends Zend_Controller_Plugin_Abstract
{

    public function routeStartup(Zend_Controller_Request_Abstract $request)
    {
        $action_stack = new Zend_Controller_Action_Helper_ActionStack();
        // here I will read actions from db and run it in loop, but for example few are staticly added bellow
        $action_stack->actionToStack('index', 'content', 'default', array('position' => 'left'));
        $action_stack->actionToStack('index', 'content', 'default', array('position' => 'center'));
        $action_stack->actionToStack('index', 'edo', 'default', array('position' => 'center'));
        $action_stack->actionToStack('left', 'edo', 'default', array('position' => 'left'));
        $action_stack->actionToStack('right', 'edo', 'default', array('position' => 'right'));
    }

}

BaseController, that every controller extends

class BaseController extends Zend_Controller_Action
{

    public function preDispatch()
    {
        $position = $this->_request->getParam('position', false);
        if ($position) {
            $this->_helper->viewRenderer->setResponseSegment($position);
        }
    }

}

Layout.phtml

<div>
    <h2><u>LEFT:</u></h2>
    <?=$this->layout()->left?>
</div>
<div>
    <h2><u>CENTER:</u></h2>
    <?=$this->layout()->center?>
</div>
<div>
    <h2><u>RIGHT:</u></h2>
    <?=$this->layout()->right?>
</div>

This is what I wanted, if anyone has a better solution please answer the question and I will accept his answer.

OwnerDisplayName: glavić


问:
Multiple where with $or sequelize
I trying get all users by provided emails using where clause and $or in sequelize.

Where in sequelize

So i created query from my emails array for multiple where like this:

```<code>[ { email: 'email1@gmail.com' }, { email: 'email@gmail.com' } ]
</code>```

Then i try to get it in many way for example like that:

```<code>const allExistedUsers = await User.findAll({
  where: { $or: multileWhere }
});
</code>```

According to  answer in this post and doc it should work:

```<code>{ $and: [{"Key1": "Value1"}, {"Key2": "Value2"}] }
</code>```

But it does not work. I can't figure out how to do it.

答:
I did it using another approach from this post
here

```<code>const allExistedUsers = await User.findAll({
  where: { email: { [Op.or]: usersEmailsToAssign } }
});
</code>```

usersEmailsToAssign is a array with strings

Title: Multiple where with $or sequelize

Body:
I trying get all users by provided emails using where clause and $or in sequelize.

Where in sequelize

So i created query from my emails array for multiple where like this:

[ { email: 'email1@gmail.com' }, { email: 'email@gmail.com' } ]

Then i try to get it in many way for example like that:

const allExistedUsers = await User.findAll({
  where: { $or: multileWhere }
});

According to  answer in this post and doc it should work:

{ $and: [{"Key1": "Value1"}, {"Key2": "Value2"}] }

But it does not work. I can't figure out how to do it.

Body:
I did it using another approach from this post
here

const allExistedUsers = await User.findAll({
  where: { email: { [Op.or]: usersEmailsToAssign } }
});

usersEmailsToAssign is a array with strings


问:
React native: Use button to run a class
I am trying to run a class using a button but I can't make it work. I know that if I want to run a class I just need to use:

```<code> <className />
</code>```

So, I tried to do this:

```<code>    <Button
    title="Right button"
    onPress={() => <className />}
  />
</code>```

However, I got an error so I'm probably doing something wrong. Can anyone help?

答:
"Running a class" doesn't really mean anything, so I'm going to have a stab at what you mean. Probably you want to render a class component when you click a button. In that case use something like:

```<code>  <Button
    title="Right button"
    onPress={() => this.setState({showMyComponent: true})}
  />
  { this.state.showMyComponent && <className /> }
</code>```

Note this isn't complete - you probably want to also be able to hide it and so on, but it's a start.

Title: React native: Use button to run a class

Body:
I am trying to run a class using a button but I can't make it work. I know that if I want to run a class I just need to use:

 <className />

So, I tried to do this:

    <Button
    title="Right button"
    onPress={() => <className />}
  />

However, I got an error so I'm probably doing something wrong. Can anyone help?

Body:
"Running a class" doesn't really mean anything, so I'm going to have a stab at what you mean. Probably you want to render a class component when you click a button. In that case use something like:

  <Button
    title="Right button"
    onPress={() => this.setState({showMyComponent: true})}
  />
  { this.state.showMyComponent && <className /> }

Note this isn't complete - you probably want to also be able to hide it and so on, but it's a start.


问:
html extra works in cli, but not in Jenkins
when running this in cli, it generates the report. but when I use the same command in Jenkins, no report is generated.
newman run "C:\WORK\getMix-REST.postman_collection.json" --reporters htmlextra --reporter-htmlextra-export "C:\Jenkins\workspace\getMix_report.html"

This is the message shown in Jenkins.

newman: could not find "htmlextra" reporter
  ensure that the reporter is installed in the same directory as newman
  please install reporter using npm

I have verified that newman and html extra are installed in the correct directories

newman installation:

I'm stuck. please help. Thanks

**Update: when I use just newman-reporter-html instead of newman-reporter-htmlextra, it works fine and report is generated. both reporters are installed on the same level, not sure why html extra doesn't work??

答:
The solution was as follows:

1.- Look for the folder: C: \ Program Files (x86) \ Jenkins \ tools \ jenkins.plugins.nodejs.tools.NodeJSInstallation \ Node3 \ node_modules

** Node3 may vary the name you assigned in Jenkins.

2.- Copy and paste newman and newman-reporter-htmlextra on the folder and try again.


问:
Changing an array code to a vector
So I have been trying to look all over, but can't seem to find a whole lot on what exactly needs to be changed in order to convert an array to vector.  Or rather, I suppose I just don't know what exactly to search for.

The array is this:

```<code>public class Member{

 private int id;
 private String name;
 private String[] books = new String[5];
 //replace the String books array with a Vector variable named books
 //that functions exactly the same way

 public Member() {
     id = 0;
     name = "John Doe";
 }

 public Member(int pId, String pName) {
     id = pId;
     name = pName;
 }

 public int getId(){
     return id;
 }

 public void setId(int pId){
     id=pId;
 }

 public String getName(){
     return name;
 }

 public void setName(String pName){
     name=pName;
 }

 public String[] getBooks(){
     return books;
 }

 public void setBooks(String[] pBooks){
     books=pBooks;
 }

 public String toString(){
     StringBuffer buf = new StringBuffer();
     buf.append("ID: " + getId() + "  Member: " + getName() + "\n");
     for(int x=0; x<books.length; x++ ) {
         buf.append("Book: " + books[x] + "\n");
     }
     return buf.toString();
 }

/**
 * @param args
 */
public static void main(String[] args) {
    String[] list = {"Java Data Structures", "The Bible", "Grapes of Wrath",
                    "Goldfinger", "Sam I Am", "The Cat in the Hat", "Shawshenk Redemption",
                    "Green Eggs and Ham", "Linus and Lucy", "Abraham Lincoln"};

    Member m1 = new Member();
    m1.setId(431);
    m1.setName("William Wallace");
    for(int i=0; i<5; i++) {
        m1.books[i] = list[i];
    }

    Member m2 = new Member(7010, "Bonny Clyde");
    for(int i=5; i<list.length; i++) {
        int x = i-5;
        m2.books[x] = list[i];
    }

    System.out.println(m1.toString());
    System.out.println();
    System.out.println(m2.toString());
}

}
</code>```

Now, I have been trying to convert it, but to be honest, I don't know what I am doing.

```<code>import java.util.Vector;

public class Member{

 private int id;
 private String name;
 private Vector<String> books = new Vector<String>(5);
 //replace the String books array with a Vector variable named books
 //that functions exactly the same way

 public Member() {
     id = 0;
     name = "John Doe";
 }

 public Member(int pId, String pName) {
     id = pId;
     name = pName;
 }

 public int getId(){
     return id;
 }

 public void setId(int pId){
     id=pId;
 }

 public String getName(){
     return name;
 }

 public void setName(String pName){
     name=pName;
 }

 public String getBooks(){
     return books;
 }

 public void setBooks(String pBooks){
     books=pBooks;
 }

 public String toString(){
     StringBuffer buf = new StringBuffer();
     buf.append("ID: " + getId() + "  Member: " + getName() + "\n");
     for(int x=0; x<books.length; x++ ) {
         buf.append("Book: " + books<x> + "\n");
     }
     return buf.toString();
 }

/**
 * @param args
 */
public static void main(String args) {
    String list = {"Java Data Structures", "The Bible", "Grapes of Wrath",
                    "Goldfinger", "Sam I Am", "The Cat in the Hat", "Shawshenk Redemption",
                    "Green Eggs and Ham", "Linus and Lucy", "Abraham Lincoln"};

    Member m1 = new Member();
    m1.setId(431);
    m1.setName("William Wallace");
    for(int i=0; i<5; i++) {
        m1.books<i> = list<i>;
    }

    Member m2 = new Member(7010, "Bonny Clyde");
    for(int i=5; i<list.length; i++) {
        int x = i-5;
        m2.books<x> = list<i>;
    }

    System.out.println(m1.toString());
    System.out.println();
    System.out.println(m2.toString());
}

}
</code>```

Any help would be greatly appreciated.

答:
Here is your example using a vector. I would highly recommend using the ArrayList class though as Vector is not used much anymore. </p>

```<code>import java.util.Vector;

public class Member{

 private int id;
 private String name;
 private Vector<String> books = new Vector<String>();
 //replace the String books array with a Vector variable named books
 //that functions exactly the same way

 public Member() {
     id = 0;
     name = "John Doe";
 }

 public Member(int pId, String pName) {
     id = pId;
     name = pName;
 }

 public int getId(){
     return id;
 }

 public void setId(int pId){
     id=pId;
 }

 public String getName(){
     return name;
 }

 public void setName(String pName){
     name=pName;
 }

 public Vector<String> getBooks(){
     return books;
 }

 public void add(String book) {
    books.add(book);
 }

 public void setBooks(Vector<String> pBooks){
     books=pBooks;
 }

 public String toString(){
     StringBuffer buf = new StringBuffer();
     buf.append("ID: " + getId() + "  Member: " + getName() + "\n");
     for(int x=0; x<books.size(); x++ ) {
         buf.append("Book: " + books.get(x) + "\n");
     }
     return buf.toString();
 }

/**
 * @param args
 */
public static void main(String[] args) {
    String[] list = new String[]{"Java Data Structures", "The Bible", "Grapes of Wrath",
                    "Goldfinger", "Sam I Am", "The Cat in the Hat", "Shawshenk Redemption",
                    "Green Eggs and Ham", "Linus and Lucy", "Abraham Lincoln"};

    Member m1 = new Member();
    m1.setId(431);
    m1.setName("William Wallace");
    for(int i=0; i<5; i++) {
        m1.add(list[i]);
    }

    Member m2 = new Member(7010, "Bonny Clyde");
    for(int i=5; i<list.length; i++) {
        int x = i-5;
        m2.add(list[x]);
    }

    System.out.println(m1.toString());
    System.out.println();
    System.out.println(m2.toString());
}

}
</code>```

Title: Changing an array code to a vector

Body:
So I have been trying to look all over, but can't seem to find a whole lot on what exactly needs to be changed in order to convert an array to vector.  Or rather, I suppose I just don't know what exactly to search for.

The array is this:

public class Member{

 private int id;
 private String name;
 private String[] books = new String[5];
 //replace the String books array with a Vector variable named books
 //that functions exactly the same way

 public Member() {
     id = 0;
     name = "John Doe";
 }

 public Member(int pId, String pName) {
     id = pId;
     name = pName;
 }

 public int getId(){
     return id;
 }

 public void setId(int pId){
     id=pId;
 }

 public String getName(){
     return name;
 }

 public void setName(String pName){
     name=pName;
 }

 public String[] getBooks(){
     return books;
 }

 public void setBooks(String[] pBooks){
     books=pBooks;
 }

 public String toString(){
     StringBuffer buf = new StringBuffer();
     buf.append("ID: " + getId() + "  Member: " + getName() + "\n");
     for(int x=0; x<books.length; x++ ) {
         buf.append("Book: " + books[x] + "\n");
     }
     return buf.toString();
 }

/**
 * @param args
 */
public static void main(String[] args) {
    String[] list = {"Java Data Structures", "The Bible", "Grapes of Wrath",
                    "Goldfinger", "Sam I Am", "The Cat in the Hat", "Shawshenk Redemption",
                    "Green Eggs and Ham", "Linus and Lucy", "Abraham Lincoln"};

    Member m1 = new Member();
    m1.setId(431);
    m1.setName("William Wallace");
    for(int i=0; i<5; i++) {
        m1.books[i] = list[i];
    }

    Member m2 = new Member(7010, "Bonny Clyde");
    for(int i=5; i<list.length; i++) {
        int x = i-5;
        m2.books[x] = list[i];
    }

    System.out.println(m1.toString());
    System.out.println();
    System.out.println(m2.toString());
}

}

Now, I have been trying to convert it, but to be honest, I don't know what I am doing.

import java.util.Vector;

public class Member{

 private int id;
 private String name;
 private Vector<String> books = new Vector<String>(5);
 //replace the String books array with a Vector variable named books
 //that functions exactly the same way

 public Member() {
     id = 0;
     name = "John Doe";
 }

 public Member(int pId, String pName) {
     id = pId;
     name = pName;
 }

 public int getId(){
     return id;
 }

 public void setId(int pId){
     id=pId;
 }

 public String getName(){
     return name;
 }

 public void setName(String pName){
     name=pName;
 }

 public String getBooks(){
     return books;
 }

 public void setBooks(String pBooks){
     books=pBooks;
 }

 public String toString(){
     StringBuffer buf = new StringBuffer();
     buf.append("ID: " + getId() + "  Member: " + getName() + "\n");
     for(int x=0; x<books.length; x++ ) {
         buf.append("Book: " + books<x> + "\n");
     }
     return buf.toString();
 }

/**
 * @param args
 */
public static void main(String args) {
    String list = {"Java Data Structures", "The Bible", "Grapes of Wrath",
                    "Goldfinger", "Sam I Am", "The Cat in the Hat", "Shawshenk Redemption",
                    "Green Eggs and Ham", "Linus and Lucy", "Abraham Lincoln"};

    Member m1 = new Member();
    m1.setId(431);
    m1.setName("William Wallace");
    for(int i=0; i<5; i++) {
        m1.books = list;
    }

    Member m2 = new Member(7010, "Bonny Clyde");
    for(int i=5; i<list.length; i++) {
        int x = i-5;
        m2.books<x> = list;
    }

    System.out.println(m1.toString());
    System.out.println();
    System.out.println(m2.toString());
}

}

Any help would be greatly appreciated.

Body:
Here is your example using a vector. I would highly recommend using the ArrayList class though as Vector is not used much anymore.

import java.util.Vector;

public class Member{

 private int id;
 private String name;
 private Vector<String> books = new Vector<String>();
 //replace the String books array with a Vector variable named books
 //that functions exactly the same way

 public Member() {
     id = 0;
     name = "John Doe";
 }

 public Member(int pId, String pName) {
     id = pId;
     name = pName;
 }

 public int getId(){
     return id;
 }

 public void setId(int pId){
     id=pId;
 }

 public String getName(){
     return name;
 }

 public void setName(String pName){
     name=pName;
 }

 public Vector<String> getBooks(){
     return books;
 }

 public void add(String book) {
    books.add(book);
 }

 public void setBooks(Vector<String> pBooks){
     books=pBooks;
 }

 public String toString(){
     StringBuffer buf = new StringBuffer();
     buf.append("ID: " + getId() + "  Member: " + getName() + "\n");
     for(int x=0; x<books.size(); x++ ) {
         buf.append("Book: " + books.get(x) + "\n");
     }
     return buf.toString();
 }

/**
 * @param args
 */
public static void main(String[] args) {
    String[] list = new String[]{"Java Data Structures", "The Bible", "Grapes of Wrath",
                    "Goldfinger", "Sam I Am", "The Cat in the Hat", "Shawshenk Redemption",
                    "Green Eggs and Ham", "Linus and Lucy", "Abraham Lincoln"};

    Member m1 = new Member();
    m1.setId(431);
    m1.setName("William Wallace");
    for(int i=0; i<5; i++) {
        m1.add(list[i]);
    }

    Member m2 = new Member(7010, "Bonny Clyde");
    for(int i=5; i<list.length; i++) {
        int x = i-5;
        m2.add(list[x]);
    }

    System.out.println(m1.toString());
    System.out.println();
    System.out.println(m2.toString());
}

}


答:
I can't seem to reproduce this on my end. My guess is there's some difference in your CSS somewhere:

```<code><!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">
    <!-- Bootstrap core CSS -->
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" rel="stylesheet">
  </head>

  <body>
<hr class="mb-4">
    <div>
        <h3>Mohamed Salah</h3>
        <h4>Midfielder</h4>
        <h5>Liverpool</h5>
    </div>
    <hr class="mb-4">
    <div class="row">
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                Form
            </div>
            <div class="text-center ">
                7.5
            </div>
        </div>
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                Price
            </div>
            <div class="text-center">
                <span>£</span>12.8
            </div>
        </div>
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                Total
            </div>
            <div class="text-center">
                165
            </div>
        </div>
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                TSB
            </div>
            <div class="text-center">
                45.3%
            </div>
        </div>
    </div>

    </div>
    <script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
  </body>
</html>
</code>```

test it out and see:
https://codepen.io/davidgbiggs/pen/JjdXpGq

Title: Bootstrap 4 row breaks for no reason

Body:
I can't seem to reproduce this on my end. My guess is there's some difference in your CSS somewhere:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">
    <!-- Bootstrap core CSS -->
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" rel="stylesheet">
  </head>

  <body>
<hr class="mb-4">
    <div>
        <h3>Mohamed Salah</h3>
        <h4>Midfielder</h4>
        <h5>Liverpool</h5>
    </div>
    <hr class="mb-4">
    <div class="row">
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                Form
            </div>
            <div class="text-center ">
                7.5
            </div>
        </div>
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                Price
            </div>
            <div class="text-center">
                <span>&#163;</span>12.8
            </div>
        </div>
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                Total
            </div>
            <div class="text-center">
                165
            </div>
        </div>
        <div class="col-xs-3 col-sm-3">
            <div class="text-center font-weight-bold">
                TSB
            </div>
            <div class="text-center">
                45.3%
            </div>
        </div>
    </div>

    </div>
    <script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
  </body>
</html>

test it out and see:
https://codepen.io/davidgbiggs/pen/JjdXpGq


问:
Memory Leak within nested while loop even though I free after both loops
Valgrind is telling me my memory is leaking where "result" is allocated in two different locations. I free result in my code. I'm really stuck. Interestingly, commenting out the second free doesn't worsen my memory leak, meaning it's not actually doing anything. Thoughts?

```<code>void index_build(const char *pathname, index_t *index)
{
    char *filename = count_malloc(strlen(pathname) + 5);
    int id = 1;
    sprintf(filename, "%s/%d", pathname, id);
    FILE *fp = fopen(filename, "r");
    while (fp != NULL) {
        char *url = count_malloc(200);
        fgets(url, 50000, fp);
        char *depth = count_malloc(sizeof(fgets(depth, 5000000, fp)) + 1);
        fgets(depth, 500000, fp);
        int d = atoi(depth);
        webpage_t *page = pageDir_load(url, d);
        int pos = 0;
        char *result = count_malloc(sizeof(webpage_getNextWord(page, &pos)) + 1);
        result = webpage_getNextWord(page, &pos);
        while (result != NULL) {
            if (index_find(index, result) == NULL) {
                counters_t *new = counters_new();
                counters_add(new, id);
                index_insert(index, result, new);
            }
            else {
                counters_t *current = index_find(index, result);
                counters_add(current, id);
            }
            free(result);
            result = count_malloc(sizeof(webpage_getNextWord(page, &pos)) + 1);
            result = webpage_getNextWord(page, &pos);
        }
        free(result);
        id++;
        fclose(fp);
        sprintf(filename, "%s/%d", pathname, id);
        fp = fopen(filename, "r");
        free(depth);
        webpage_delete(page);
    }
    free(filename);
}
</code>```

valgrind error:

```<code>54 bytes in 6 blocks are definitely lost in loss record 1 of 2
==3516925==    at 0x483980B: malloc (vg_replace_malloc.c:309)
==3516925==    by 0x40227D: count_malloc (memory.c:54)
==3516925==    by 0x401572: index_build (indexer.c:63)
==3516925==    by 0x40146C: main (indexer.c:46)
==3516925==
==3516925== 495 bytes in 55 blocks are definitely lost in loss record 2 of 2
==3516925==    at 0x483980B: malloc (vg_replace_malloc.c:309)
==3516925==    by 0x40227D: count_malloc (memory.c:54)
==3516925==    by 0x40161B: index_build (indexer.c:76)
==3516925==    by 0x40146C: main (indexer.c:46)
</code>```

答:
I grep'd your code for all malloc's and frees like this:

```<code>egrep "malloc|free"
</code>```

I got these results:

```<code>char *filename = count_malloc(strlen(pathname) + 5);
    char *url = count_malloc(200);
    char *depth = count_malloc(sizeof(fgets(depth, 5000000, fp)) + 1);
    char *result = count_malloc(sizeof(webpage_getNextWord(page, &pos)) + 1);
        free(result);
        result = count_malloc(sizeof(webpage_getNextWord(page, &pos)) + 1);
    free(result);
    free(depth);
free(filename);
</code>```

Above, I see that url is never free'd.

Body:
Valgrind is telling me my memory is leaking where "result" is allocated in two different locations. I free result in my code. I'm really stuck. Interestingly, commenting out the second free doesn't worsen my memory leak, meaning it's not actually doing anything. Thoughts?

void index_build(const char *pathname, index_t *index)
{
    char *filename = count_malloc(strlen(pathname) + 5);
    int id = 1;
    sprintf(filename, "%s/%d", pathname, id);
    FILE *fp = fopen(filename, "r");
    while (fp != NULL) {
        char *url = count_malloc(200);
        fgets(url, 50000, fp);
        char *depth = count_malloc(sizeof(fgets(depth, 5000000, fp)) + 1);
        fgets(depth, 500000, fp);
        int d = atoi(depth);
        webpage_t *page = pageDir_load(url, d);
        int pos = 0;
        char *result = count_malloc(sizeof(webpage_getNextWord(page, &pos)) + 1);
        result = webpage_getNextWord(page, &pos);
        while (result != NULL) {
            if (index_find(index, result) == NULL) {
                counters_t *new = counters_new();
                counters_add(new, id);
                index_insert(index, result, new);
            }
            else {
                counters_t *current = index_find(index, result);
                counters_add(current, id);
            }
            free(result);
            result = count_malloc(sizeof(webpage_getNextWord(page, &pos)) + 1);
            result = webpage_getNextWord(page, &pos);
        }
        free(result);
        id++;
        fclose(fp);
        sprintf(filename, "%s/%d", pathname, id);
        fp = fopen(filename, "r");
        free(depth);
        webpage_delete(page);
    }
    free(filename);
}

valgrind error:

54 bytes in 6 blocks are definitely lost in loss record 1 of 2
==3516925==    at 0x483980B: malloc (vg_replace_malloc.c:309)
==3516925==    by 0x40227D: count_malloc (memory.c:54)
==3516925==    by 0x401572: index_build (indexer.c:63)
==3516925==    by 0x40146C: main (indexer.c:46)
==3516925==
==3516925== 495 bytes in 55 blocks are definitely lost in loss record 2 of 2
==3516925==    at 0x483980B: malloc (vg_replace_malloc.c:309)
==3516925==    by 0x40227D: count_malloc (memory.c:54)
==3516925==    by 0x40161B: index_build (indexer.c:76)
==3516925==    by 0x40146C: main (indexer.c:46)

Body:
I grep'd your code for all malloc's and frees like this:

egrep "malloc|free"

I got these results:

char *filename = count_malloc(strlen(pathname) + 5);
    char *url = count_malloc(200);
    char *depth = count_malloc(sizeof(fgets(depth, 5000000, fp)) + 1);
    char *result = count_malloc(sizeof(webpage_getNextWord(page, &pos)) + 1);
        free(result);
        result = count_malloc(sizeof(webpage_getNextWord(page, &pos)) + 1);
    free(result);
    free(depth);
free(filename);

Above, I see that url is never free'd.


问:
Django Unhasable Type List even though im passing in an object ?(many to many field)
I am trying to run a migration script for my django app, but I keep getting TypeError: unhashable type: 'list' even though I am clearly passing in an Object:

I get:

```<code> error line 87, in buildCisc
    c.exclusions.add(exclus)
line 944, in add
    self._add_items(
line 1119, in _add_items
    target_ids = self._get_target_ids(target_field_name, objs)
line 1059, in _get_target_ids
    target_ids.add(target_id)
TypeError: unhashable type: 'list'
</code>```

when I run the following code

```<code>...

        for ex in exclusionList:
            if len(Course.objects.filter(ID=ex)) > 0:  # exclusion course already exsists
                exclus = Course.objects.filter(ID=ex)
                c.exclusions.add(exclus[0])
            else:  # exclusion course does not exsist yet so we must create it first
                exclus = Course(ID=ex)
                exclus.save()
                c.exclusions.add(exclus) #this is line 87 causing the error
</code>```

where c is a Course object create in prior code, exclusions is a many to many field from Course to itself, 'ex' is just a string.
if I try using exclus = Course.objects.create(ID=ex) instead that also gives the same error. The error seems to be saying that the exclus that I am passing in to c.exclusions.add is a list, but it is very clearly an object. I even tried switching exclus to exclus[0] to see if it somehow thought it was a list, but this gave me error: Course Object not iterable so it is saying it is of type Object, so I am very confused with error message. any ideas?

edit: I believe to have solved the issue, the exclus = Course(ID=ex) was the problem, specifically ex. For some reason in my read in phase, it got set to a list somehow and not a string like I thought it was

答: Since c is a Course object, it contains a list and that's the part that cannot be hashed. Try using .append() instead of .add(). The add() method is for sets and those require that the object be hashed since it needs to compare items for uniqueness.

Body:
I am trying to run a migration script for my django app, but I keep getting TypeError: unhashable type: 'list' even though I am clearly passing in an Object:

I get:

 error line 87, in buildCisc
    c.exclusions.add(exclus)
line 944, in add
    self._add_items(
line 1119, in _add_items
    target_ids = self._get_target_ids(target_field_name, objs)
line 1059, in _get_target_ids
    target_ids.add(target_id)
TypeError: unhashable type: 'list'

when I run the following code

...

        for ex in exclusionList:
            if len(Course.objects.filter(ID=ex)) > 0:  # exclusion course already exsists
                exclus = Course.objects.filter(ID=ex)
                c.exclusions.add(exclus[0])
            else:  # exclusion course does not exsist yet so we must create it first
                exclus = Course(ID=ex)
                exclus.save()
                c.exclusions.add(exclus) #this is line 87 causing the error

where c is a Course object create in prior code, exclusions is a many to many field from Course to itself, 'ex' is just a string.
if I try using exclus = Course.objects.create(ID=ex) instead that also gives the same error. The error seems to be saying that the exclus that I am passing in to c.exclusions.add is a list, but it is very clearly an object. I even tried switching exclus to exclus[0] to see if it somehow thought it was a list, but this gave me error: Course Object not iterable so it is saying it is of type Object, so I am very confused with error message. any ideas?

edit: I believe to have solved the issue, the exclus = Course(ID=ex) was the problem, specifically ex. For some reason in my read in phase, it got set to a list somehow and not a string like I thought it was


问:
Can someone help explain the recursion in this back tracking algorithm?
This is a program that solves a sudoku board using python and the back-tracking algorithm, but I don't seem to understand the recursion in solve(bo). Like it seems like if the condition is not met, then the index is reset to 0 and it continues to try numbers at the same position.

Can someone help explain in simpler terms perhaps, how the function back tracks and rechecks conditions?

```<code>board = [
    [7,8,0,4,0,0,1,2,0],
    [6,0,0,0,7,5,0,0,9],
    [0,0,0,6,0,1,0,7,8],
    [0,0,7,0,4,0,2,6,0],
    [0,0,1,0,5,0,9,3,0],
    [9,0,4,0,6,0,0,0,5],
    [0,7,0,3,0,0,0,1,2],
    [1,2,0,0,0,7,4,0,0],
    [0,4,9,2,0,6,0,0,7]
]

def solve(bo):
    find = find_empty(bo)
    if not find:
        return True
    else:
        row, col = find

    for i in range(1,10):
        if valid(bo, i, (row, col)):
            bo[row][col] = i

            if solve(bo):
                return True

            bo[row][col] = 0

    return False

def valid(bo, num, pos):
    # Check row
    for i in range(len(bo[0])):
        if bo[pos[0]][i] == num and pos[1] != i:
            return False

    # Check column
    for i in range(len(bo)):
        if bo[i][pos[1]] == num and pos[0] != i:
            return False

    # Check box
    box_x = pos[1] // 3
    box_y = pos[0] // 3

    for i in range(box_y*3, box_y*3 + 3):
        for j in range(box_x * 3, box_x*3 + 3):
            if bo[i][j] == num and (i,j) != pos:
                return False

    return True

def print_board(bo):
    for i in range(len(bo)):
        if i % 3 == 0 and i != 0:
            print("- - - - - - - - - - - - - ")

        for j in range(len(bo[0])):
            if j % 3 == 0 and j != 0:
                print(" | ", end="")

            if j == 8:
                print(bo[i][j])
            else:
                print(str(bo[i][j]) + " ", end="")

def find_empty(bo):
    for i in range(len(bo)):
        for j in range(len(bo[0])):
            if bo[i][j] == 0:
                return (i, j)  # row, col

    return None

print_board(board)
solve(board)
print("___________________")
print_board(board)
</code>```

答: Right! So the way this solution operates is it finds the next empty field on the board, attempts to insert number from range 1..9 there and then check the validity. The validity check is a tentative answer to whether a given number is correct, i.e. whether it does not produce a violation of the rules. If so, the number gets inserted into the array and solve is called recursively. Now, here the implicit backtracking is taking place. If this recursive call to solve fails to produce a fully consistent solution to the puzzle, then the whole "branch" starting with our tentative guess gets removed from the call stack, the failed guess is reset on the board (removed), and we continue to the next guess.

Body:
This is a program that solves a sudoku board using python and the back-tracking algorithm, but I don't seem to understand the recursion in solve(bo). Like it seems like if the condition is not met, then the index is reset to 0 and it continues to try numbers at the same position.

Can someone help explain in simpler terms perhaps, how the function back tracks and rechecks conditions?

board = [
    [7,8,0,4,0,0,1,2,0],
    [6,0,0,0,7,5,0,0,9],
    [0,0,0,6,0,1,0,7,8],
    [0,0,7,0,4,0,2,6,0],
    [0,0,1,0,5,0,9,3,0],
    [9,0,4,0,6,0,0,0,5],
    [0,7,0,3,0,0,0,1,2],
    [1,2,0,0,0,7,4,0,0],
    [0,4,9,2,0,6,0,0,7]
]

def solve(bo):
    find = find_empty(bo)
    if not find:
        return True
    else:
        row, col = find

    for i in range(1,10):
        if valid(bo, i, (row, col)):
            bo[row][col] = i

            if solve(bo):
                return True

            bo[row][col] = 0

    return False

def valid(bo, num, pos):
    # Check row
    for i in range(len(bo[0])):
        if bo[pos[0]][i] == num and pos[1] != i:
            return False

    # Check column
    for i in range(len(bo)):
        if bo[i][pos[1]] == num and pos[0] != i:
            return False

    # Check box
    box_x = pos[1] // 3
    box_y = pos[0] // 3

    for i in range(box_y*3, box_y*3 + 3):
        for j in range(box_x * 3, box_x*3 + 3):
            if bo[i][j] == num and (i,j) != pos:
                return False

    return True

def print_board(bo):
    for i in range(len(bo)):
        if i % 3 == 0 and i != 0:
            print("- - - - - - - - - - - - - ")

        for j in range(len(bo[0])):
            if j % 3 == 0 and j != 0:
                print(" | ", end="")

            if j == 8:
                print(bo[i][j])
            else:
                print(str(bo[i][j]) + " ", end="")

def find_empty(bo):
    for i in range(len(bo)):
        for j in range(len(bo[0])):
            if bo[i][j] == 0:
                return (i, j)  # row, col

    return None

print_board(board)
solve(board)
print("___________________")
print_board(board)