text:
Q: SCCM - does captured image HW = deployed? Im hoping to use SCCM 2012 R2 to image a slew of machines that will be ordered over the next year. There will be several different vendors which implies different NICs, graphics, RAM, etc.
My question: does the machine that the OS image is captured from have to be the same as what it gets deployed to? IE could I use a VM to create the captured image? Or do I need to create a different image for every piece of hardware?

A: Unless you want to go download new drivers for NICs, display adapters, sound cards, etc., etc.,  each time you get a new model or brand of computer, then you will need to slipstream drivers into your images.  Also you need to think about whether you'll use WDS (Windows Deployment Server), or MDT (Microsoft Deployment Toolkit).  WDS is great for smaller companies that can't use full blown SCCM and don't have hundreds or thousands of computers to image each year.  MDT is great for experienced users who know how to make detailed Task Sequences that will allow you to add all your drivers and applications and other tweaks based on WMI Queries.  You capture info from WMI Queries off of the machines which you want to image, which can then target certain computers and grab certain driver packages based on what those machines are; meaning, you use WMI queries to get certain information off of a computer then put that in your MDT Task Sequence to look for these types of computers when you start the imaging.  If these types of computers are detected then a detailed Task Sequence is kicked off that grabs the right drivers for your particular model of computer.  That way you don't have to have dozens of images as you've described in your question.  My experience with MDT has been pretty good, and using Dell computers in general has also given me good luck.
You don't need a different image for each piece of hardware, just a different set of driver packages per chipset, or per model.  Typically a Dell X9000 (just a fake model for this example) will have the same chipset on all X9000 models with some variance based on when they are manufactured and/or purchased.  If you buy 20 of them though, you should be alright to capture one image then go to the Dell website and look for the Driver CAB for the X9000 or whatever the real model is and download it and add it to your driver packages on your MDT server then add it in as part of a Task Sequence.
Please see this for an in-depth look at MDT so you can get a better grasp on what you'll need.

A: You can capture one image and deploy it to different hardware by creating different task sequences containing the appropriate drivers for each model .
See Introduction to Operating System Deployment in Configuration Manager.

A: Capturing from a VM is actually better than using a physical computer. The VM allows you to take a snapshot right before you run sysprep. A month later you can boot from that snapshot, update all of the software, run sysprep and capture again. SCCM will detect and inject the proper drivers into the image at deployment time.
For SCCM I implore you to read Kent Agerlund's System Center 2012 R2 Configuration Manager: Mastering the Fundamentals. You can find older Kindle versions for $10.

A: Actually, though you can get much more specific about it, a deployment share will automatically use whichever driver it first detects that applies to the hardware in question. While it isn't necessarily recommended, you can simply load all of the drivers for devices into an unorganized deployment share and the deployment will still succeed. See scenario 1 – total chaos here on Johan Arwidmark's blog.
A more up to date resource to introduce you to MDT is the Windows 8.1 Deployment Jump Start at Microsoft Virtual Academy. The content in the video is relevant to anyone deploying any Windows operating system. I would urge anyone who works with Windows deployment who has not yet seen it to give it a watch. Johan and other experts in Windows deployment chime in on the issues facing Windows deployment and how they can be resolved.
Also, it is strongly recommended to use a virtual machine for a reference machine to avoid driver conflicts between the image and the destination hardware.


text:
Q: Deriving another formula for least square In a proof of a theorem in this paper(page 26), they started with what is shown below

The $\|\cdot\|_*$ is the trace norm and I do understand SVD decomposition but I don't understand how they decompose $||Z-W||_F^2$ to what is between brackets?

A: *

*The Frobenius norm is induced by the inner product $\langle A, B\rangle_F := \text{Tr}(A'B)$ (where $A,B \in \mathbb{R}^{m \times n}$), in the sense that $\|A\|_F^2 = \langle A, A \rangle_F$.

*A useful fact is that if $U$ and $V$ are orthogonal matrices of the appropriate dimension, then $\|UAV\|_F = \|A\|_F$. You can prove this easily using the above inner product formulation of the Frobenius norm.

You can show that
$$\|Z-W\|_F^2 = \|Z\|_F^2 - 2 \langle Z, W \rangle_F + \|W\|_F^2.$$

*

*Note that $\|Z\|_F^2 = \|D\|_F^2 = \sum_{i=1}^n d_i^2$.

*Note that $\langle Z, W\rangle_F = \langle UDV', W \rangle_F
= \text{Tr}(VD'U'W) = \text{Tr}(D'U'WV)$. Think through the definition of trace and matrix multiplication to show that this equals $\sum_{i=1}^n d_i u_i' W v_i$.

*After correcting the typo in the paper ($\|Z\|_F^2$ should be $\|W\|^2_F$), this leads to the desired expression in the paper.

redpajama_set_name: RedPajamaStackExchange


text:
Q: loop between links . is opening simultaneous multiple pages and doesn't stop I know that is a stupid question,but i can't figure it out.(I'm learning, so please be kind )
It's opening simultaneous multiple pages and doesn't stop when var page2 is empty,  still continue opening blank page.
I think the problem whit blank page is if(page.length===0) loop();, but if i use if(page.length===0) return; how can i call the loop function when is done?
I want that after is finish to push the links in var page2, to start loop between that links one by one
    var page = [ "link1" , "link2" , "link3"];
    var page2 = [];
    function pushToPage2Arr() {
        if(page.length===0) loop();
        var url = page.shift();
        var openWindow = window.open(url, "_blank","height=500","width=500");
        setTimeout(function () {
            var cat = openWindow.document.getElementsByClassName("list-id");
            for (var i = 0; i < cat.length ; i++) {
                var id = openWindow.document.getElementsByClassName("list-id")[i].children[0].children[1].textContent;
                var cbn = openWindow.document.getElementsByClassName("list-cbn")[i].children[3].textContent;
                page2.push("http://blabla.com?id="+id+"&cbn="+cbn);
            }
            openWindow.close();
            pushToPage2Arr();
        }, 2000);
    }

    pushToPage2Arr();

    function loop() {
        if(page2.length===0) return;
        var url2 = page2.shift();
        var openWindow2 = window.open(url2, "_blank","height=500","width=500");
        setTimeout(function () {
            //do someting
            openWindow2.close();
            loop();
        }, 3000);
    }

A: So you want to exhaust page1, populating page2 in the process, and then you want to exhaust page2.
You could just correct the error you're already focused on -- that control returns to pushToPage2Arr from loop:
if(page.length===0) loop();
var url = page.shift();
...

Should be:
if(page.length===0) { loop(); return; }
var url = page.shift();

But what you have here is really a 'delayed for-each'.  So why not just write that?
Here's a single page script that sets a span to each number in a list, and then sets it to 'done' after the loop ends.
<!doctype html>

hello:

You could also zip both lists with their corresponding functions, and end with with a dummy object and corresponding finalizer:
function delayedDo(list, delay) {
  function process() {
    var x = list.shift()
    if (x !== undefined) {
      x[1](x[0])
      setTimeout(process, delay)
    }
  }
  process()
}

var text = document.getElementById('text'),
    num = function(x) { text.textContent = '(number: ' + x + ')' },
    str = function(x) { text.textContent = '(string: ' + x + ')' },
    done = function() { text.textContent = 'done!' }
    joblist =
      [ [ 1, num ],
        [ 2, num ],
        [ 3, num ],
        [ 'hello', str ],
        [ 'world', str ],
        [ null, done ] ]

delayedDo(joblist, 1000)


text:
Q: I wand to use a svg with moxe-blend-mode over a video I try to put a svg logo over a video clip (mp4) with mix-blend-mode: difference;
It should be used in shopware 6.
My css:
 #gr-logo svg path { mix-blend-mode: difference; }
I also tried png, tried the blend mode on containers and so on...
The same thing I did with text and it works fine.
It can bee seen here at 991px and smaller.
https://www.giuliaandromeo.com/staging/
Any idea, why it does not work?
Thanks
Tom

A: The element that has the position: fixed rule needs to be the one element with the mix-blend-mode rule. See this answer for more insight on how the stacking context influences the blend mode.
So in your case you can quickly verify this by setting these rules:
header.header-main {
    mix-blend-mode: difference;
}
header.header-main * {
    color: white!important;
    fill: white!important;
}

Just as a proof of concept, note the wildcard rule that sets all the child elements to be white in color. This is to make them appear black on the background, due to nature of the difference blend mode. Obviously you should adapt the existing rules to set the color to be pure white instead.


text:
Q: Migrate complex svn into git (keep history, trunk and branches are not on the right places) I looked for almost all similar questions, but none are match my "strange" structure of svn which I need to migrate.
So I need to migrate:
svnrepo:
ver_1.0/
    |
         trunk/
            |
               Module_A
               Module_B
ver_1.5/
    |
         trunk/
            |
               Module_A  (svn copy from ver_1.0)
               Module_B  (svn copy from ver_1.0)

(Yes, it's strange and wrong)
So instead of branches - modules were just copied, to keep the history.
If you open a history for ver1.5 Module_A - you will changes from ver1.0 and ver1.5.
Now I need to migrate all this into git but in correct way, so git repo looks like:
gitrepo:
Module_A
Module_B

with history (I assume that in this case I should recreate branches manually)
So what is the best way to achieve it ?
Should I migrate each version in local git repo and then merge it ?
Can git svn handle this kind of config ? I tried to set "--trunk" - to latest version and version-folders as "--branches" but that didnt work.


text:
Q: SQL Server: set a variable with more than one possible value I need your help. I have a command to update rows, this works if in a variable @ID contain one value.
DECLARE @ID nvarchar(100)
SET @ID = (select top 1 id from [SERVICES])

DECLARE @UPDATE nvarchar(max)
SET @UPDATE ='UPDATE SERVICES

SET SERVICES.options = t1.options
FROM SERVICES t
JOIN (SELECT *
      FROM OPENQUERY([ORI], ''SELECT ID, options
                              FROM log
                              WHERE ID = ''''' + @ID + ''''' '')) t1 ON t1.id = t.id'

EXEC (@UPDATE)

but I need to update more than 1 rows.
If I specify a condition like this:
SET @ID = (SELECT id FROM [ReportSM].[dbo].[SERVICES])

I get an error:

Subquery returned more than 1 value.

How to fix it?

A: Option 1
In your current setup, you could pass @ID as a CSV to OPENQUERY such that WHERE IN would work.
WHERE ID = ' + @ID + '

could then be replaced with
WHERE ID IN (' + @IDs + ')'

Look here to convert your ID column into a CSV: SQL Server convert select a column and convert it to a string
Be aware of the limit on the length of the IN clause. See this https://dba.stackexchange.com/questions/14161/what-is-the-maximum-number-of-parameters-i-can-pass-using-the-sql-in-clause-in-s
Option 2
Since concatenating data directly into a query has SQL injection concerns, you could also look at a more structured approach of using FOR XML to convert the IDs into an xml fragment and passing that into OPENQUERY and within that reading the ids out using OPENXML.
If both your servers are SQL Server 2016 or above, you could also use JSON as your format for transferring the ids instead of XML. You would use FOR JSON to create a JSON array containing the ids and use OPENJSON on the destination SQL server to convert the JSON back into a rowset that you can join.
declare @json varchar(max) = (select id from [ReportSM].[dbo].[SERVICES] FOR JSON PATH)

This will generate a string like this
[{"id":1},{"id":2},{"id":3},{"id":4}]

You can add this into a variable in the query you are preparing and read it using below
SELECT ID
FROM OPENJSON (@json, '$')
WITH (ID IN '$.id')

Putting it together your query would look like this:
declare @json varchar(max) = (select id from [ReportSM].[dbo].[SERVICES] FOR JSON PATH)

DECLARE @UPDATE nvarchar(max)
SET @UPDATE ='UPDATE SERVICES
    SET SERVICES.options = t1.options
    FROM SERVICES t
    JOIN (SELECT *
        FROM OPENQUERY([ORI], ''DECLARE @json nvarchar(max) = ''''' + @json + '''''
                                SELECT ID, options
                                FROM log
                                WHERE ID IN (SELECT ID FROM OPENJSON (@json, ''$'') WITH (ID IN ''$.id'')))) t1 ON t1.id = t.id'

EXEC (@UPDATE)

A: It sounds like you really want to pass a table valued parameter into the open query, but that's not supported. You can remove that filter and let the join take care of the update accuracy but that will result in a potentially much more expensive remote query than necessary. That solution would just look like this:
UPDATE
    t
SET
    t.options = t1.options
FROM
    Services t
    JOIN (SELECT ID, options FROM OPENQUERY([ORI], 'SELECT ID, options FROM
log')) t1 ON t1.id = t.id

However, if you have control over the ORI linked server, you could set up a linked server there back to your ReportSM server. That would let you create a view on your ORI server that contains all of the IDs from your [ReportSM].[dbo].[SERVICES] table which is what you are trying to filter your log table on. That means you could perform the ID filtering on the ORI side and then run a simpler update on the ReportSM side. Something like this on the ORI side:
CREATE VIEW vReportServiceIDs
AS
SELECT
    ID
FROM
    [ReportSM].[dbo].[SERVICES]

CREATE VIEW vReportServiceLogs
AS
SELECT
    reportService.ID,
    oriLog.options
FROM
    vReportServiceIDs reportService
    JOIN [log] oriLog ON reportService.ID = [log].ID

And then on your ReportSM side:
UPDATE
    t
SET
    t.options = t1.options
FROM
    SERVICES t
    JOIN (
        SELECT
            ID, options
        FROM
            OPENQUERY([ORI], 'SELECT ID, options FROM vReportServiceLogs')

If you do not have that kind of access to the ORI server and the logs table has too much data for you to just query it all and exclude what you don't need during the join, you might want to consider creating a cache of the logs table that you update from a job on the ReportSM server and then just joining on that during your update.


text:
Q: How to add within elements of a list? I'm trying to show the possible combinations of rolling 3 dice and taking the sum of the two highest numbers
dice = {1, 2, 3, 4, 5, 6}
j = Flatten[Outer[List, dice, dice, dice], 2]
j1 = Table[Extract[j, {i, 2}], {i, 1, 216}];
j2 = Table[Extract[j, {i, 3}], {i, 1, 216}];
Transpose[{j1, j2}];

How can I add the two elements up of each part of the last line (Transpose...) to give the sums ranging from 2 to 12?
Thank you

A: You can simply add your j1 and j2:
rowtotals  = j1 + j2;

Total[Transpose[{j1, j2}], {2}] == rowtotals

True

Note that you  can use {2} in the second argument of Total to get row totals.
You can get the same result using a combination of Tuples and Total as suggested by J.M. in comments:
Total[Tuples[Range @ 6, 3][[All, 2 ;;]], {2}] == rowtotals

True

ListLinePlot[rowtotals]


text:
Q: Unit test Tensorflow Transform operations I want to do unit test on my functions that contains Tensorflow Transform operations. Something like this:
@pytest.mark.parametrize("inputs,expected_result",
    [(
        tf.linspace(start=0, stop=10, num=10),
        tf.linspace(start=0, stop=1, num=10),
    )]
)
def test_tft_scale(inputs, expected_result):
    out = tft.scale_to_0_1(inputs)
    assert tf.experimental.numpy.allclose(out, expected_result)

I got error related to eager execution:
RuntimeError: tf.placeholder() is not compatible with eager execution

I tried disabling eager execution by putting tf.compat.v1.disable_eager_execution() but I got another error:
tensorflow.python.framework.errors_impl.OperatorNotAllowedInGraphError: using a `tf.Tensor` as a Python `bool` is not allowed in Graph execution. Use Eager execution or decorate this function with @tf.function.

How to solve this? Thanks!

A: So you are trying to convert Python eager code into graph-compatible TensorFlow ops which you can do so using the AutoGraph library. You can use this by simply adding in the @tf.function decorator and chaining it with your @pytest.mark.parametrize() decorator. @tf.function uses AutoGraph by default and you can read more about it here.
Edit:
I think you are better off using tf.test.TestCase like so, with the removal of using tft.scale_to_0_1() as you can just scale the tensors to a range of 0 to 1 using tensor = tensor / tf.norm(tensor). You would not need to enable tf.compat.v1.enable_eager_execution() with this.
import tensorflow as tf

class TFTScaleTest(tf.test.TestCase):
    def setUp(self):
        super(TFTScaleTest, self).setUp()
        self.input = tf.linspace(start=0, stop=10, num=10)
        self.expected_result = tf.linspace(start=0, stop=1, num=10)

    def test_tft_scale(self):
        tensor = tf.cast(self.input, dtype=tf.float64)
        tensor = tensor / tf.norm(tensor)
        self.assertAllClose(tensor, self.expected_result)

if __name__ == "__main__":
    tf.test.main()

Test case results:
AssertionError:
Not equal to tolerance rtol=1e-06, atol=1e-06
Mismatched value: a is different from b.
not close where = (array([1, 2, 3, 4, 5, 6, 7, 8, 9]),)
not close lhs = [0.05923489 0.11846978 0.17770466 0.23693955 0.29617444 0.35540933
 0.41464421 0.4738791  0.53311399]
not close rhs = [0.11111111 0.22222222 0.33333333 0.44444444 0.55555556 0.66666667
 0.77777778 0.88888889 1.        ]
not close dif = [0.05187622 0.10375245 0.15562867 0.20750489 0.25938112 0.31125734
 0.36313356 0.41500979 0.46688601]
not close tol = [1.11111111e-06 1.22222222e-06 1.33333333e-06 1.44444444e-06
 1.55555556e-06 1.66666667e-06 1.77777778e-06 1.88888889e-06
 2.00000000e-06]
dtype = float64, shape = (10,)
Mismatched elements: 9 / 10 (90%)
Max absolute difference: 0.46688601
Max relative difference: 0.46688601
 x: array([0.      , 0.059235, 0.11847 , 0.177705, 0.23694 , 0.296174,
       0.355409, 0.414644, 0.473879, 0.533114])
 y: array([0.      , 0.111111, 0.222222, 0.333333, 0.444444, 0.555556,
       0.666667, 0.777778, 0.888889, 1.      ])


text:
Q: CSS and JS files not loaded in Laravel 5.4 Hello everyone I'm new to laravel I just finished my first app when I try to publish it in wamp the css and js files are not loaded,
I use
{{URL::to('/assets/css/main.css')}}

to call them, they are in the public folder and they are correctly loaded in PhpStorm, the path generated is

http://localhost:8080/MyApp/assets/css/main.css

and it's not correct, when I add public it works

http://localhost:8080/MyApp/public/assets/css/main.css

Thank you

A: Use this to load your files:
{{ asset('assets/css/main.css') }}
If it doesn't work, that means you have a problem with your WAMP config, but nothing to do with Laravel itself.


text:
Q: How to import scikit-learn in python virtual environment? The Problem
I'm trying to use scikit-learn on a virtual environment and I cannot get it to run.
So, for example, I go to a project folder and install NumPy, SciPy, and scikit-learn
virtualenv venv
source venv/bin/activate
pip install numpy
pip install scipy
pip install scikit-learn

Then I open python and try to import each of them.
import numpy
import scipy
import sklearn

NumPy and SciPy import fine, but when I try to import I get an error saying Library not loaded: @rpath/./libgfortran.3.dylib.
Is there something I'm missing in the installation?
Full error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/Peter/git/dataSandbox/flaskApps/sfSalary/venv/lib/python2.7/site-packages/sklearn/__init__.py", line 57, in <module>
    from .base import clone
  File "/Users/Peter/git/dataSandbox/flaskApps/sfSalary/venv/lib/python2.7/site-packages/sklearn/base.py", line 11, in <module>
    from .utils.fixes import signature
  File "/Users/Peter/git/dataSandbox/flaskApps/sfSalary/venv/lib/python2.7/site-packages/sklearn/utils/__init__.py", line 11, in <module>
    from .validation import (as_float_array,
  File "/Users/Peter/git/dataSandbox/flaskApps/sfSalary/venv/lib/python2.7/site-packages/sklearn/utils/validation.py", line 16, in <module>
    from ..utils.fixes import signature
  File "/Users/Peter/git/dataSandbox/flaskApps/sfSalary/venv/lib/python2.7/site-packages/sklearn/utils/fixes.py", line 324, in <module>
    from scipy.sparse.linalg import lsqr as sparse_lsqr
  File "/Users/Peter/git/dataSandbox/flaskApps/sfSalary/venv/lib/python2.7/site-packages/scipy/sparse/linalg/__init__.py", line 109, in <module>
    from .isolve import *
  File "/Users/Peter/git/dataSandbox/flaskApps/sfSalary/venv/lib/python2.7/site-packages/scipy/sparse/linalg/isolve/__init__.py", line 6, in <module>
    from .iterative import *
  File "/Users/Peter/git/dataSandbox/flaskApps/sfSalary/venv/lib/python2.7/site-packages/scipy/sparse/linalg/isolve/iterative.py", line 7, in <module>
    from . import _iterative
ImportError: dlopen(/Users/Peter/git/dataSandbox/flaskApps/sfSalary/venv/lib/python2.7/site-packages/scipy/sparse/linalg/isolve/_iterative.so, 2): Library not loaded: @rpath/./libgfortran.3.dylib
  Referenced from: /Users/Peter/git/dataSandbox/flaskApps/sfSalary/venv/lib/python2.7/site-packages/scipy/sparse/linalg/isolve/_iterative.so
  Reason: image not found

EDIT:
this was some troubleshooting to host a Heroku app using sklearn.

A: I would strongly recommend against using virtual environments for NumPy/SciPy/Scikit-learn and other packages which include compiled code. Virtual environments deal with pure Python dependencies reasonably well, but for compiled extensions with dependencies outside Python, they can fail in unexpected ways (as you have seen).
If you want to manage multiple environments with different versions of Python packages including compiled extensions, the best tool out there is probably conda, and in particular conda environments.
With it, you can run the following:
$ conda create -n myenv python=3.4 numpy scipy scikit-learn
$ source activate myenv
(myenv) $ python
Python 3.4.3
>>> import sklearn

and you'll be good to go.


text:
Q: How to return user input (string) to where only the first letter is capitalized Such as
Scanner keyboard = new Scanner(System.in);

String  productName1, productName2;
System.out.println("First product's info: ");
System.out.print("Product name: ");
productName1 = keyboard.nextLine();
System.out.println("");
System.out.println("Second product's info: ");
System.out.print("Product name: ");

How would I go about making it to where, when the user, per-say, types in aPPles as productName1.
When i reprint it later, how would I make the system print it was Apples.
User input print :aPPles
reprint: Apples

A: Use
productName1 = productName1.toLowerCase();  //To lower case
productName1 = productName1.substring(0,1).toUpperCase().concat(productName1.substring(1));

This first takes the string and makes it lower case. Then it takes the first letter, makes it uppercase and adds rest of the string to it.

A: Try this
public static void main(String[] args) {
    Scanner keyboard = new Scanner(System.in);
    String  productName1;
    System.out.println("First product's info: ");
    System.out.print("Product name: ");
    productName1 = keyboard.nextLine();
    System.out.print("Product name: ");
    productName1 = productName1.toLowerCase();
    productName1 = Character.toUpperCase(productName1.charAt(0)) + productName1.substring(1);
    System.out.println(productName1);
    keyboard.close();

}


text:
Q: Is this coding wrong it's not working properly The below script inputs data to a database this takes some information from a form then stores them in to the database. And I'm also using uplodify to upload a image file and store the file name in the database but my issue is this data processing script keeps updating the row ID one never jumps to the second line I tried every thing can some one help me with this or show me what I'm doing wrong.
Also this checks the ID and if it's not equal to 1 then does an insertion if it's equal then update it but this not happening.
The ID is auto incrementing.
My script
<?php

/**
 * @author SiNUX
 * @copyright 2013
 */

include ('connect.php');

$getId = mysql_query("SELECT ID FROM poiinfo ORDER BY ID DESC LIMIT 1");
$row = mysql_fetch_array($getId);

$poiName = $_REQUEST['Name'];
$poiDes = $_REQUEST['Descrip'];
$poiCon = $_REQUEST['ConInfo'];
//$poiId = $_REQUEST['pID'];

if($row['ID'] != "1"){
    $dbData = "INSERT INTO poiinfo(`Name`, `Des.`, `Contact`) VALUES ('$poiName','$poiDes','$poiCon')";
    $putData = mysql_query($dbData);

    if ($putData){
        echo "Data inserted";
    }else {
        echo "Not Done";
    }

}else {
    $updLn = "UPDATE `poiinfo` SET `Name`='$poiName',`Des.`='$poiDes',`Contact`='$poiCon'";
    $updDone = mysql_query($updLn);

    if ($updDone){
        echo "Data inserted";
    }else {
        echo "Not Done";
    }
 }
?>

I tried u r suggestions but it's still the same now my code for the update is looks like this.
$updLn = "UPDATE `poiinfo` SET `Name`='$poiName',`Des.`='$poiDes',`Contact`='$poiCon' WHERE `ID`='".$row['ID']."'";

But still it keeps up dating the ID 1 not moving on to the next one.

A: Your update query is missing a WHERE clause. Try this:
$updLn = "UPDATE `poiinfo` SET `Name`='$poiName',`Des.`='$poiDes',`Contact`='$poiCon' WHERE ID = '".$row['ID']."'";

Also be beware of MySQL Injections: http://en.wikipedia.org/wiki/SQL_injection

A:     $updLn = "UPDATE `poiinfo` SET `Name`='$poiName',`Des.`='$poiDes',`Contact`='$poiCon'";

You need a where clause in this sql to specify a record to update. Currently it is updating all records.
    $updLn = "UPDATE `poiinfo` SET `Name`='$poiName',`Des.`='$poiDes',`Contact`='$poiCon' WHERE `ID` = ".$row['id']";";

You will need to set an $id variable for this to work.

A: To check why your update failed, you should call mysql_error in your last else clause :
} else {
    echo mysql_error();
}

As for the first problem : if you never insert a new record (I don't see how that could happen, provided your code), you will never have a record whose ID is 2.


text:
Q: How can I mount folder correctly in kubernetes I'm trying to run nodered in my minikube kubernetes cluster ("cluster", its one node :D).
The docker command to do this is by example:
docker run -it -p 1880:1880 -v /home/user/node_red_data:/data --name mynodered nodered/node-red

But I'm not running it in docker, I'm trying to run it in minikube. The documentation of minikube states that /data on the host is persisted. So what I wanted was a /data/nodered to be mounted up as /data on the nodered container.
I started with adding a storage class:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: Immediate

Then added persistent storage:
apiVersion: v1
kind: PersistentVolume
metadata:
  name: small-pv
spec:
  capacity:
    storage: 1Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-storage
  local:
    path: /data
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - minikube

Then a persistent volume claim for the nodered:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nodered-claim
spec:
  storageClassName: local-storage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

And then the deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: nodered
  name: nodered
spec:
  replicas: 1
  volumes:
    - name: nodered-claim
      persistentVolumeClaim:
        claimName: nodered-claim
  selector:
    matchLabels:
      app: nodered
  template:
    metadata:
      labels:
        app: nodered
    spec:
      containers:
      - name: nodered
        image: nodered/node-red:latest
        ports:
        - containerPort: 1880
      volumeMounts:
      - name: nodered-claim
        mountPath: "/data"
        subPath: "nodered"

I've checked kubernetes dasboard and everything is green and volume is bound. I created a simple http service in nodered and deployed it. It's running but nothing is saved. So if the deployment goes down and gets redeployed it will be empty.
I've checked the /data and /data/nodered folders on the minikube instance running in docker but they are empty.

A: Your deployment spec should return error, try the following:
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: nodered
  name: nodered
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nodered
  template:
    metadata:
      labels:
        app: nodered
    spec:
      containers:
      - name: nodered
        image: nodered/node-red:latest
        ports:
        - containerPort: 1880
        volumeMounts:
        - name: nodered-claim
          mountPath: /data/nodered
          # subPath: nodered <-- not needed in your case
      volumes:
      - name: nodered-claim
        persistentVolumeClaim:
          claimName: nodered-claim


text:
Q: Which of vsize, size and rss should be used in memory leak detection? Which of the three values, vsize, size and rss from ps output is suitable for use in quick memory leak detection? For my purpose, if a process has been running for few days and its memory has kept increasing then that is a good enough indicator that it is leaking memory. I understand that a tool like valgrind should ultimately be used but its use is intrusive and so not always desirable.
For my understanding, I wrote a simple piece of C code that basically allocates 1 MiB of memory, frees it and then allocates 1 MiB again. It also sleeps before every step for 10 seconds giving me time to see output from ps -p <pid> -ovsize=,size=,rss=. Here it is:
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>

#define info(args...) printf(args)

char* bytes(char* str, uint32_t size, uint32_t n)
{
    char* unit = "B";

    if (n > 1000) {
        n /= 1000;
        unit = "KB";
    }
    if (n > 1000) {
        n /= 1000;
        unit = "MB";
    }

    snprintf(str, size, "%u %s", n, unit);
    return(str);
}

void* xmalloc(size_t size)
{
    char msg[64];
    size_t max = sizeof(msg);
    void *p = NULL;

    info("Allocating %s\n", bytes(msg, max, size));
    p = malloc(size);
    memset(p, '1', size);
    return(p);
}

void* xfree(void* p, size_t size)
{
    char msg[64];
    size_t max = sizeof(msg);
    info("Freeing %s\n", bytes(msg, max, size));
    free(p);
    return(NULL);
}
void nap()
{
    const int dur = 10;
    info("Sleeping for %d seconds\n", dur);
    sleep(dur);
}

int main(void)
{
    int err = 0;
    size_t kb = 1024;
    size_t block = 1024 * kb;
    char* p = NULL;

    nap();
    p = xmalloc(block);
    nap();
    p = xfree(p, block);
    nap();
    p = xmalloc(block);
    nap();

    return(err);
}

Now, ps was run every two seconds from a shell script that helped also print the measurements timestamps. Its output was:
# time vsize size rss
1429207116   3940   188   312
1429207118   3940   188   312
1429207120   3940   188   312
1429207122   3940   188   312
1429207124   3940   188   312
1429207126   4968  1216  1364
1429207128   4968  1216  1364
1429207130   4968  1216  1364
1429207132   4968  1216  1364
1429207135   4968  1216  1364
1429207137   3940   188   488
1429207139   3940   188   488
1429207141   3940   188   488
1429207143   3940   188   488
1429207145   5096  1344  1276
1429207147   5096  1344  1276
1429207149   5096  1344  1276
1429207151   5096  1344  1276
1429207153   5096  1344  1276

From the values above, and keeping in mind the descriptions given in the man page for ps(1), it seems to me that the best measure is vsize. Is this understanding correct? Note that the man page says that size is a measure of the total amount of dirty pages and rss the amount of pages in physical memory. These could very much become lower than the total memory used by the process.
These experiments were tried on Debian 7.8 running GNU/Linux 3.2.0-4-amd64.

A: Generally speaking the total virtual size (vsize) of your process is the main measure of process size.  rss is just the portion that happens to be using real memory at the moment.  size is a measure of how many pages have actually been modified.
A constantly increasing vsize, with relatively stable or cyclic size and rss values might suggest heap fragmentation or a poor heap allocator algorithm.
A constantly increasing vsize and size, with a relatively stable rss might suggest a memory leak, heap fragmentation, or a poor heap allocator algorithm.
You will have to understand something of how a given program uses memory resources in order to use just these external measures of process resource usage to estimate whether it suffers from a memory leak or not.
Part of that involves knowing a little bit about how the heap is managed by the C library malloc() and free() routines, including what additional memory it might require internally to manage the list of active allocations, how it deals with fragmentation of the heap, and how it might release unused parts of the heap back to the operating system.
For example your test shows that both the total virtual size of the process, and the number of "dirty" pages it required, grew slightly larger the second time the program allocated the same amount of memory again.  This probably shows some of the overhead of malloc(), i.e. the amount of memory its own internal data structures required up to that point.  It would have been interesting to see what happened if the program had done another free() and sleep() before exiting.  It might also be instructive to modify your code so that it calls sleep() between calling malloc() and memset(), and then observe the results from ps.
So, a simple program which should only require a fixed amount of memory to  run, or which allocates memory to do a specific unit of work and then should free all of that memory once that unit of work is completed, should show a relatively stable vsize, assuming it doesn't ever process more than one unit of work at a time and have a "bad" pattern of allocation that would lead to heap fragmentation.
As you noted, a tool like valgrind, along with intimate knowledge of the program's internal implementation, is necessary to show actual memory leaks and prove they are solely the responsibility of the program.
(BTW, you might want to simplify your code somewhat -- don't use unnecessary macros like info() in particular, and for this type of example trying to be fancy with printing values in larger units, using extra variables to do size calculations, etc., is also more of an obfuscation than a help.  Too many printfs also obfuscate the code -- use only those you need to see what step the program is at and to see values that are not known at compile time.)


text:
Q: Handle Text/csv file Output response in Postman with get Method I have two get end points.
One retruns json output.
Second one with the same URL provides me data with text/csv. Using Produces annotation.
How to invoke the second get end point in Post man.


text:
Q: String argument behaves differently within my script I've tried to parse a text out of some html elements using string argument the way it is described here but failed miserably. I've tried two different ways but every time I encountered the same AttributeError.
How can I use string argument in this very case to fetch the text?
I've tried with:
import re
from bs4 import BeautifulSoup

htmlelement = """

    ASIC registration

"""
soup = BeautifulSoup(htmlelement,"lxml")
try:
    item = soup.find("caption",string="ASIC registration").text
    #item = soup.find("caption",string=re.compile("ASIC registration",re.I)).text
except AttributeError:
    item = ""
print(item)

Expected output (only using string argument):
ASIC registration

A: The issue you're running into is that the string argument searches for strings instead of for tags as it states in the documentation you linked.
The syntax you are using:
soup.find("caption",string="ASIC registration")

is for finding tags.
For finding strings:
soup.find(string=re.compile('ASIC'))

With the first one you are saying find a caption tag with the "string" attribute of your string.  The caption tag has no string attribute so nothing is returned.
The second one is saying find the string that contains 'ASIC', so it returns the string.

A:
How can I use string argument in this very case to fetch the text?

You can't
Note:
I am assuming that you mean by some change string parameter in
item = soup.find("caption",string="ASIC registration").text

As given in the documentation

If a tag has only one child, and that child is a NavigableString, the
  child is made available as .string:

import re
from bs4 import BeautifulSoup
htmlelement = """

    ASIC registration

"""
soup = BeautifulSoup(htmlelement,"lxml")
item = soup.find("caption")
print(item.string)

Output
None

Here the .string is None as caption has more than one child.
If you are trying to get the parent (caption tag in this case) with the text, you could do
item = soup.find(string=re.compile('ASIC registration')).parent

which will give

ASIC registration

Of course, calling a .text on this parent tag will give the full text within that tag, if it is not the full text within it.
item = soup.find(string=re.compile('ASIC')).parent.text

will give an output
ASIC registration

A: Turns out the string parameter doesn't work if a tag has a child tag. The following code is stupid, but it works:
real_item = ""
try:
    items = soup.find_all("caption")
    r = re.compile(u"ASIC registration", re.I)
    for item in items:
        for s in item.strings:
            if r.search(unicode(s)):
                real_item = item
                break

except AttributeError:
    real_item = ""
print(real_item)


text:
Q: converting columns data into row, SQL Server 2008 Please Help me...my current data looks like following:
studentname          course_name              room_name    period   day_name
----------------------------------------------------------------------------
smith, john    Advisory B House       AR90           A         B
smith, john    AP Calculus AB         A03            6         B
smith, john    AP ECE Calculus BC     A03            2         B
smith, john    Maths                  A03            5         B
smith, john    Computer Science       C26            8         B
smith, john    Homeroom/LunchS1       C15            4         B
smith, john    Homeroom/LunchS2       C15            4         B
Avon, Lisa     Maths                  C26            3         B
Avon, Lisa     Copmuter Science       C15            8         B
Avon, Lisa     ACP  English 10        B09            A         B
Avon, Lisa     H Journalism           B09            2         B
Avon, Lisa     H Journalism           B09            3         B
Avon, Lisa     Homeroom/Lunch 11 S1   B09            7         B
Avon, Lisa     Homeroom/Lunch 11 S2   B09            7         B
Avon, Lisa     Science Fiction        B09            3         B

I want to convert rows into columns like following:
studentname period1   period2   period3     period4  period5         period6         period7
smith, john Advisory  Calculus  APCalculs   Maths    ComputerScience Homeroom/S1    Homeroom/LunchS2
           AR90        A03         A03      A03      C26              C15           C15
           A            6           2       5         8               4              4
           B            B           B       B         B               B              B

I really appreciate any help i get on this issue. Thank you so much in advance.
-HT

A: Using Cross Apply and Pivot you can get the result. First by using cross apply u can convert the multiple columns to be pivoted into multiple rows. Then by using Pivot u can get the result.
CREATE TABLE #pivot
  (studentname VARCHAR(50),course_name VARCHAR(50),
     room_name   VARCHAR(50),period      VARCHAR(50),
     day_name    VARCHAR(50))

INSERT INTO #pivot
VALUES      ('smith,john','Advisory B House','AR90','A','B'),
            ('smith,john','AP Calculus AB','A03','6','B'),
            ('smith,john','AP ECE Calculus BC','A03','2','B'),
            ('smith,john','Maths','A03','5','B'),
            ('smith,john','Computer Science','C26','8','B'),
            ('smith,john','Homeroom/LunchS1','C15','4','B'),
            ('smith,john','Homeroom/LunchS2','C15','4','B'),
            ('Avon, Lisa','Maths','C26','3','B'),
            ('Avon, Lisa','Computer Science','C15','8','B'),
            ('Avon, Lisa','ACP  English 10','B09','A','B'),
            ('Avon, Lisa','H Journalism','B09','2','B'),
            ('Avon, Lisa','H Journalism','B09','3','B'),
            ('Avon, Lisa','Homeroom/Lunch 11 S1','B09','7','B'),
            ('Avon, Lisa','Homeroom/Lunch 11 S2','B09','7','B'),
            ('Avon, Lisa','Science Fiction','B09','3','B')

DECLARE @cols   VARCHAR(max)='',@aggcol VARCHAR(max)='',@sql    NVARCHAR(max)

select @cols += Rn from (
SELECT Distinct  ',' + 'period'+ CONVERT(VARCHAR(25), Row_number() OVER (PARTITION by studentname
ORDER BY course_name)) Rn
FROM   #pivot) bb

SELECT @cols = RIGHT(@cols, Len(@cols) - 1)
select @aggcol += Rn from (
SELECT Distinct ',Max(' + 'period'+ CONVERT(VARCHAR(25), Row_number() OVER (PARTITION by studentname ORDER BY course_name))
                  + ') period'+ CONVERT(VARCHAR(25), Row_number() OVER (PARTITION by studentname ORDER BY course_name)) rn
FROM   #pivot) bb

SELECT @aggcol = RIGHT(@aggcol, Len(@aggcol) - 1)

set @sql =
'SELECT studentname,
       '+@aggcol+'
FROM   (SELECT studentname,room_name,cname,data,periods
FROM  (SELECT ''period''+ CONVERT(VARCHAR(25), Row_number() OVER (ORDER BY course_name)) periods,
              *
       FROM   #pivot) a
      CROSS apply (VALUES (''course_name'',course_name),
                          (''room_name'',room_name),
                          (''period'',period),
                          (''day_name'',day_name)) cp (cname, data) )a
       PIVOT (Max(data)
             FOR periods IN('+@cols+')) piv
GROUP  BY studentname,
          cname '

--print @sql
EXEC SP_EXECUTESQL @sql

OUTPUT
studentname period1             period2         period3             period4  period5            period6             period7
----------- ----------------    --------------  ------------------  -------  ----------------   ----------------    ---------------
smith,john  Advisory B House    AP Calculus AB  AP ECE Calculus BC  Maths    Computer Science   Homeroom/LunchS1    Homeroom/LunchS2
smith,john  B                   B               B                   B        B                  B                   B
smith,john  A                   6               2                   5        8                  4                   4
smith,john  AR90                A03             A03                 A03      C26                C15                 C15


text:
Q: Safety - not character sets - [^z]? http://www.jslint.com
states that it does not allow not character sets [^foob] because of security issues. ( I choose not to select the ignore option )
What is an example of how this could be a security issue?


text:
Q: How to map/convert nested params with jersey-media-moxy? I'm programming a RESTful web application with jersey and MOXy for JAXB based JSON support.
My goal is to use a POJO as a method parameter that consumes JSON.
@POST
@Consumes(MediaType.APPLICATION_JSON)
public void postRequest(MyPOJO myPOJO) {
    System.out.println(myPOJO.name);
    System.out.println(myPOJO.currency);
}

This POJO has a string member and a member of type java.util.Currency.
@XmlRootElement
public class MyPOJO {
    public String name;
    public Currency currency;
    public MyPOJO() {};
}

I have also a custom Currency ParamConverter (and Provider), see below. With this I'm able to handle a QueryParam of type Currency correctly.
But if I query my resource by POST with the following JSON content currency is not mapped and will be null while name is mapped correctly.
{ "name": "peter", "currency": "EUR" }

Console output therefor results in:
peter
null

What else I have to do to tell MOXy to correctly map this nested object members?
This is my ParamConverter for Currency:
@Provider
public class CurrencyParamConverterProvider implements ParamConverterProvider {
    @Override
    public <T> ParamConverter<T> getConverter(final Class<T> rawType, Type genericType, Annotation[] annotations) {
        return rawType != Currency.class ? null : new ParamConverter<T>() {
            @Override
            public T fromString(String value) {
                if (value == null) {
                    throw new IllegalArgumentException(LocalizationMessages.METHOD_PARAMETER_CANNOT_BE_NULL("value"));
                }

                try {
                    return rawType.cast(Currency.getInstance(value));
                } catch (IllegalArgumentException e) {
                    throw new ExtractorException("Currency must be a valid ISO 4217 code of the currency.", e);
                }
            }

            @Override
            public String toString(T value) {
                if (value == null) {
                    throw new IllegalArgumentException(LocalizationMessages.METHOD_PARAMETER_CANNOT_BE_NULL("value"));
                }
                return value.toString();
            }
        };
    }
}

A: Currency is an object, so in the JSON world, it should be
{ "name": "peter", "currency": { "fieldName" :"EUR"} }

The reason you don't get any failure notice is that MOXy by default is just meant o ignore these type of missing/unknown property issues.
One way to get around this is to use an XmlAdapter. For example
import javax.xml.bind.annotation.adapters.XmlAdapter;

public class CurrencyAdapter extends XmlAdapter<String, Currency>{

    @Override
    public Currency unmarshal(String v) throws Exception {
        Currency c = new Currency();
        c.type = v;
        return c;
    }

    @Override
    public String marshal(Currency v) throws Exception {
        return v.type;
    }
}

Where Currency.type is simply the field to hold the "EUR" value. Then you just need to annotate the property/field with the adapter
@XmlRootElement
public class MyPojo {
    public String name;
    @XmlJavaTypeAdapter(CurrencyAdapter.class)
    public Currency currency;
}


text:
Q: Error Database locked SQLite C# Whenever I call the test() method
the code runs until it reaches the Messagebox.show()
When i try to insert into the "vandute" table i get the error "DATABASE IS LOCKED"
private void test()
    {
        int z;
        SQLiteConnection dbcon = new SQLiteConnection("Data Source=stefanauto.psa;Version=3;");
        dbcon.Open();
        using (SQLiteCommand sql = new SQLiteCommand(dbcon))
        {
            sql.CommandText = "select ID from clienti where CNP='" + cnp.Text + "'";

            z = Convert.ToInt32(sql.ExecuteScalar());

            MessageBox.Show(z.ToString());//The error begins after this line
            sql.CommandText = "insert into vandute(ID_MASINA,ID_CLIENT)values(1,2)";//Id_MASINA,ID-CLIENT ARE integers
            sql.ExecuteNonQuery();
        }
    }

Can you please explain me what am I doing wrong?

A: Try to move the
dbcon.Open();

inside the using block. Something like
using (SQLiteConnection c = new SQLiteConnection("Data Source=stefanauto.psa;Version=3;"))
{
    c.Open();
    using (SQLiteCommand cmd = new SQLiteCommand(sql, c))
    {
        //your code
    }
}

or else try to dispose your connection explicitly
public void DisposeConnection()
{
    SQLiteConnection.Dispose();
    SQLiteCommand.Dispose();
    GC.Collect();
}

A: Try creating a new command;
private void test()
{
    int z;
    using (SQLiteConnection dbcon = new SQLiteConnection("Data Source=stefanauto.psa;Version=3;"))
    {
        dbcon.Open();
        using (SQLiteCommand sql = new SQLiteCommand(dbcon))
        {
            sql.CommandText = "select ID from clienti where CNP='" + cnp.Text + "'";

            z = Convert.ToInt32(sql.ExecuteScalar());

            MessageBox.Show(z.ToString());
        }

        using (SQLiteCommand sql = new SQLiteCommand(dbcon))
        {
            sql.CommandText = "insert into vandute(ID_MASINA,ID_CLIENT)values(1,2)";
            sql.ExecuteNonQuery();
        }
    }
}


text:
Q: Swfit4. Initial ViewController is the wrong for a split second, then it fixes In my app, the first time the app is used, the user is taken to a specific view controller (TutorialPageViewController). Every other time its used, the user is taken to a different view controller (HomeViewController).
To do this, I created a third view controller (FirstBlankViewController), where I show the logo of the app for one second. After that second, I call the appropriate view controller. This works, however when the app is opened, for a split second, you see the wrong view controller (ie TutorialPageViewController or HomeViewController) then the first one opens, and after a second it does the right thing.
But why is anything appearing before the FirstBlankViewController, which is set as the initial view controller. It shouldn't appear, even for a split second.
Here is the code in the FirstBlankViewController:
 override func viewDidLoad() {
    super.viewDidLoad()

    DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: {

        let launchedBefore = UserDefaults.standard.bool(forKey: "launchedBefore")

        if launchedBefore  {

            print("Not first launch.")
            let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
            let newViewController = storyBoard.instantiateViewController(withIdentifier: "HomeViewController") as! HomeViewController
            self.present(newViewController, animated: false, completion: nil)

        } else {
            print("First launch")
            self.dismiss(animated: false)
            let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
            let newViewController = storyBoard.instantiateViewController(withIdentifier: "TutorialPageViewController") as! TutorialPageViewController

            self.present(newViewController, animated: false, completion: nil)
        }

    })

}

I hope its clear!
Thanks

A: The flicker is an iOS bug/feature that happens with every app, including system applications. It is a caching system that shows a screencap from the application. It tries to replicate the last state of the app, however, it's far from perfect. Note that the flicker occurs regardless you've set a launch screen/launch image or not.
Just ignore it and move on.


text:
Q: I have created a space invader game and want to make it online using Flask. Is it a suitable approach? The game is of 25 Level, each level consists of different enemies with different Shooting Lasers and health bar. So far the player spaceship has 5 powerups which becomes active as he shoots the enemies and a powerup image comes up.

A: A web framework like Flask or Django is just for linking backend scripts and databases to a web page.
Because PyGame will need a python environment to be run.
1.You can either make a game using Javascript like Phaser.js.
2.Or you can create an executable file of your game using pyinstaller and distribute those.
But personally the best choice for a browser game is using Javascript frameworks.


text:
Q: Jinja: compare items in list in a for loop I've got a list this list
[
{'update': datetime.date(2019, 9, 13), 'initiator': 'john', 'change': 'name', 'old_value': 'smith', 'new_value': 'baker'},
{'update': datetime.date(2019, 9, 13), 'initiator': 'john', 'change': 'name', 'old_value': 'baker', 'new_value': 'ford'},
{'update': datetime.date(2019, 10, 25), 'initiator': 'paul', 'change': 'country', 'old_value': 'berlin', 'new_value': 'paris'},
{'update': datetime.date(2019, 10, 25), 'initiator': 'john', 'change': 'status', 'old_value': 'hired', 'new_value': 'fired'}
]

In my template, the list should be displayed in such a way that the date comes first and below all changes to the date.
A new section should be created for a new date:
2019-9-13
john | name | smith | baker
john | name | baker | ford

2019-10-25
paul | country | berlin | paris
john | status | hired | fired

I already tried to loop the list and count the loop.index to compare the actual update to the next update in the loop
{% for line in history %}
    {% if loop.index != loop.length %}
        {% if loop.first %}
            {{ line.update }}
| {{ line.initiator }} | {{ line.change }} | {{ line.old_value }} | {{ line.new_value }}

        {% elif history[loop.index].update == history[loop.index + 1].update %}
            | {{ line.initiator }} | {{ line.change }} | {{ line.old_value }} | {{ line.new_value }}

        {% elif history[loop.index].update != history[loop.index + 1].update %}
            {{ line.update }}
| {{ line.initiator }} | {{ line.change }} | {{ line.old_value }} | {{ line.new_value }}

        {% endif %}
    {% else %}
        {% if  history[loop.index].update == history[loop.index - 1].update%}
            | {{ line.initiator }} | {{ line.change }} | {{ line.old_value }} | {{ line.new_value }}

        {% else %}
            {{ line.update }}
| {{ line.initiator }} | {{ line.change }} | {{ line.old_value }} | {{ line.new_value }}

        {% endif %}
    {% endif %}
{% endfor %}

It's not working.
My next idea was to declare a value to safe the recent date and compare it to the next one in the loop.
{% for line in history %}
    {% if loop.first %}
        {% set date = line.update %}
        {{ line.update }}
| {{ line.initiator }} | {{ line.change }} | {{ line.old_value }} | {{ line.new_value }}

    {% else %}
        {% if date == line.update %}
            | {{ line.initiator }} | {{ line.change }} | {{ line.old_value }} | {{ line.new_value }}

        {% else %}
            {% set date = line.update %}
            {{ line.update }}
| {{ line.initiator }} | {{ line.change }} | {{ line.old_value }} | {{ line.new_value }}

        {% endif %}
    {% endif %}
{% endfor %}

Maybe someone has an advice or a hint for me.
Thanks a lot!

A: Okay, sometime you just need some sleep :-)
This does exactly what I want:
{% set date = history[0].update %}
{% for line in history %}
    {% if loop.first %}
        {{ line.update }}

        {{ line.initiator }} | {{ line.change }} | {{ line.old_value }} | {{ line.new_value }}
    {% else %}
        {% if date == line.update %}

 {{ line.initiator }} | {{ line.change }} | {{ line.old_value }} | {{ line.new_value }}
        {% else %}
            {% set date = line.update %}

{{ line.update }}

            {{ line.initiator }} | {{ line.change }} | {{ line.old_value }} | {{ line.new_value }}
        {% endif %}
    {% endif %}
{% endfor %}


text:
Q: Creating another drop down based on option chosen in a drop down menu I have a drop down being created, it starts with one that has three options "Choose Gender" "Male?", "Female".  What I want to know is how to make it so that when male is selected, a new drop down menu is created with the options of "Choose your race!", "Human", "Dwarf", "Orc".  What I am doing now does not seem to work.  I have to use JavaScript (not JQuery)
What I have so far:
var step1 = ["Choose Gender?", "Male", "Female"];
var step2 = [["Choose your race!", "Human", "Dwarf", "Orc"],["Choose your race!", "Elf", "Dwarf"]];
var step3 = [["Human Class", "Warrior", "Sorcerer", "Theif"], ["Elf Class", "Cleric", "Necromancer", "Priest"], ["Dwarf Class", "Cannonner", "Rifelman", "Engineer"], ["Orc Class", "Beserker","Warlock", "Shaman"]];

function init() {
    menuCreate(step1);
    if (selectValue == step1[1]){

        menuCreate(step2);

    }
}
function menuCreate(step2){
    //console.log(step1);
    var myDiv = document.getElementById("mainDiv");
    var titleElement = document.createElement("h1");

    titleElement.setAttribute('style','color:white');
    titleElement.setAttribute('id','guide');

    var selectForm = document.createElement('select');

    selectForm.id = "form";
    myDiv.appendChild(selectForm);

    for (var i=0; i< step2.length; i++){
        var option = document.createElement('option');
        option.value = step2[i];
        option.text = step2[i];
        selectForm.appendChild(option);

    }

} // end menuCreate()

function getSelectValue(){
    var selectValue = document.getElementById("form").value;

}

Any help would be greatly appreciated! even if it is just a hint to get started! I am new to JavaScript.  All selects have to be dynamically created in JavaScript.  I'm also not allowed to use innerhtml/innertext, the drop downs need to be dynamically created using JS

A: You can get the body element by tag name, and add to the innerHTML of it to create more HTML elements, as shown in my JSFiddle code:
https://jsfiddle.net/qx9cwnuk/
function create() {
    var name = document.getElementById('s1').value;
  document.getElementById('d1').innerHTML = "You selected " + name + "
<select><option>Option 1</option><option>Option 2</option><option>Option 3</option></select>";
}
<select id="s1">
  <option value="male">Male</option>
  <option value="female">Female</option>
  <option value="orc">Orc</option>
</select>
<button onclick="create()">Select</button>

A: You could do this in a slightly neater way if you use make use of events. When you create the options for the "step1" dropdown, attach an event to each of the objects. There are several ways to do that, my recommendation would be:
option.addEventListener("click", <someFunction>);

Where someFunction generates your next level of dropdown.
Now you probably want to pass along some information to that next function so you could use an anonymous function like this:
option.addEventListener("click", () => {
    someFunction(option.value, otherUsefulInformation);
});

Excuse the fancy notation, think of it as a way to execute a statement inside of "addEventListener" instead of giving it a function directly. Now you could nest this as deeply as you like and pass along all relevant information. The last level of this nesting could execute some action based on the information passed along to it.
https://www.w3schools.com/js/js_htmldom_eventlistener.asp
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
Code example:
generateLevel1(optionsArray){
    for(<each element in optionsArray){
        let option = <new dom element>
        <do customization and stuff to option>
        option.addEventListener("click", () => {
            // the following statements will be executed when this option is clicked
            if(option == male)
                generateLevel2(nextOptionsArray);
            if(option == female)
                generateLevel2(otherNextOptionsArray);
        }
    }
}

Using a bunch of if statements is maybe not the best way to do this but if you have a small number of options it will get the job done. Also you might have noticed me using "let" instead of "var". This may or may not be important in this type of nesting, I haven't written js in a long time so I don't know. I know I'm not being super descriptive but you only asked for a hint.


text:
Q: How get the javascript class that created a jQuery element? I am adding Tiles to my Tilegame by using a javascript equivalent of class instances, like this:
for(var i = ... ) {
    var myTile = new Tile();
}

This Tile instance adds a div element to the DOM.
Inside the Tile class it looks something like this:
function Tile(){
    this.init = function(){
         $( "game" ).append( "
yo
" );
    }
    this.doSomething = function(){
       // I want to call this function from a generic single click listener for the entire game
    }
}

Then, the whole game has one single listener that checks if the entire game container is clicked. Using event.target I can then check which div was clicked.
function containerWasClicked(evt){
   console.log("somebody clicked on " + evt.target);
   // BUT I cannot call evt.target.doSomething(); because the div does not know who created it...
}

Now I know which div was clicked, but how do I find the Tile instance that appended the div to the dom? I don't want to add a listener to every single element individually.

A: Rather than doing the delegation work yourself, just use jQuery's built-in ability to do it.
First, when you create your elements, save a reference to your Tile object as data:
this.init = function(){
     var graph = $("
", {
       text: "yo",
       "class": "graph",
       data: { "tile": this }
     });
     $( "#game" ).append( graph );
};

Now you can set up your event handler:
$("#game").on("click", ".graph", function() {
  var theGraph = this;
  var tile = $(theGraph).data("tile");
  // ...
  tile.doSomething();
});

By initializing the jQuery "data" map to have a reference to the Tile instance, you make the object available later.

A: This is a bit of an anti-pattern really; but jQuery allows you to set data on an element; you could use it as follows:
function Tile(){
    this.init = function(){
        var $el = $("
yo
");
        $el.data("creator", this);
        $( "game" ).append( $el );
    }
    this.doSomething = function(){
       // I want to call this function from a generic single click listener for the entire game
    }
}

And then later on to retrieve it:
var instance = $(evt.target).data("creator");
instance.doSomething();

A: Using "this" will refer to the element that is clicked.
$('.graph').on("click", function(){
 $(this).hide();
});

A: All your tiles have a class graph. If you add a listener to that class, then you can access your tile by using $(this) in your callback, like so;
$(function(){
    $(".graph").click(function(){ $(this).remove() });
});


text:
Q: Overlapping range inputs. On click change input with closest value I have two overlapping range inputs, this creates a multi range input effect.
I want it so that whenever a click is made on either of these, the input with the closest value to the newly clicked value, is changed. Not entirely sure how to go about this.
How could I do this?

(function() {
  "use strict";

  var supportsMultiple = self.HTMLInputElement && "valueLow" in HTMLInputElement.prototype;

  var descriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value");

  self.multirange = function(input) {
    if (supportsMultiple || input.classList.contains("multirange")) {
      return;
    }

    var values = input.getAttribute("value").split(",");
    var max = +input.max || 100;
    var ghost = input.cloneNode();

    input.classList.add("multirange", "original");
    ghost.classList.add("multirange", "ghost");

    input.value = values[0] || max / 2;
    ghost.value = values[1] || max / 2;

    input.parentNode.insertBefore(ghost, input.nextSibling);

    Object.defineProperty(input, "originalValue", descriptor.get ? descriptor : {
      // Dang you Safari >:(
      get: function() {
        return this.value;
      },
      set: function(v) {
        this.value = v;
      }
    });

    Object.defineProperties(input, {
      valueLow: {
        get: function() {
          return Math.min(this.originalValue, ghost.value);
        },
        set: function(v) {
          this.originalValue = v;
        },
        enumerable: true
      },
      valueHigh: {
        get: function() {
          return Math.max(this.originalValue, ghost.value);
        },
        set: function(v) {
          ghost.value = v;
        },
        enumerable: true
      }
    });

    if (descriptor.get) {
      // Again, fuck you Safari
      Object.defineProperty(input, "value", {
        get: function() {
          return this.valueLow + "," + this.valueHigh;
        },
        set: function(v) {
          var values = v.split(",");
          this.valueLow = values[0];
          this.valueHigh = values[1];
        },
        enumerable: true
      });
    }

    function update() {
      ghost.style.setProperty("--low", input.valueLow * 100 / max + 1 + "%");
      ghost.style.setProperty("--high", input.valueHigh * 100 / max - 1 + "%");
    }

    input.addEventListener("input", update);
    ghost.addEventListener("input", update);

    update();
  }

  multirange.init = function() {
    Array.from(document.querySelectorAll("input[type=range][multiple]:not(.multirange)")).forEach(multirange);
  }

  if (document.readyState == "loading") {
    document.addEventListener("DOMContentLoaded", multirange.init);
  } else {
    multirange.init();
  }

})();
@supports (--css: variables) {
  input[type="range"].multirange {
    -webkit-appearance: none;
    padding: 0;
    margin: 0;
    display: inline-block;
    vertical-align: top;
    width: 250px;
    margin-top: 50px;
    margin-left: 50px;
    background: lightblue;
  }
  input[type="range"].multirange.original {
    position: absolute;
  }
  input[type="range"].multirange.original::-webkit-slider-thumb {
    position: relative;
    z-index: 2;
  }
  input[type="range"].multirange.original::-moz-range-thumb {
    transform: scale(1);
    /* FF doesn't apply position it seems */
    G z-index: 1;
  }
  input[type="range"].multirange::-moz-range-track {
    border-color: transparent;
    /* needed to switch FF to "styleable" control */
  }
  input[type="range"].multirange.ghost {
    position: relative;
    background: var(--track-background);
    --track-background: linear-gradient(to right, transparent var(--low), var(--range-color) 0, var(--range-color) var(--high), transparent 0) no-repeat 0 45% / 100% 40%;
    --range-color: hsl(190, 80%, 40%);
  }
  input[type="range"].multirange.ghost::-webkit-slider-runnable-track {
    background: var(--track-background);
  }
  input[type="range"].multirange.ghost::-moz-range-track {
    background: var(--track-background);
  }
}
<input type="range" multiple value="10,80" />

A: You'll have to capture a mouse event on the element and calculate how close it is to the high marker vs. the low marker and decide which one to update based on that.  Also, because these are two stacked input elements, you'll probably have to pass the event to the low range input manually.
Here's my go at creating such a function:
function passClick(evt) {
  // Are the ghost and input elements inverted? (ghost is lower range)
  var isInverted = input.valueLow == ghost.value;
  // Find the horizontal position that was clicked (as a percentage of the element's width)
  var clickPoint = evt.offsetX / this.offsetWidth;
  // Map the percentage to a value in the range (note, assumes a min value of 0)
  var clickValue = max * clickPoint;

  // Get the distance to both high and low values in the range
  var highDiff = Math.abs(input.valueHigh - clickValue);
  var lowDiff = Math.abs(input.valueLow - clickValue);

  if (lowDiff < highDiff && !isInverted || (isInverted && lowDiff > highDiff)) {
    // The low value is closer to the click point than the high value
    // We should update the low value input
    var passEvent = new MouseEvent("mousedown", {screenX: evt.screenX, clientX: evt.clientX});
    // Pass a new event to the low "input" element (which is obscured by the
    // higher "ghost" element, and doesn't get mouse events outside the drag handle
    input.dispatchEvent(passEvent);
    // The higher "ghost" element should not respond to this event
    evt.preventDefault();
    return false;
  }
  else {
    console.log("move ghost");
    // The high value is closer to the click point than the low value
    // The default behavior is appropriate, so do nuthin
  }
}

ghost.addEventListener("mousedown", passClick);

I put this code immediately above the input.addEventListener("input", update); line in your sample, and it seems to work. See my fiddle.
Some provisos though:

*

*I only tested in Chrome. IE might have some trouble based on how I replicated the event.  It may use a mechanism other than dispatchEvent... like fireEvent or something.

*Initially I coded it assuming that the "ghost" element always kept track of the high range. I've since updated things to invert the event dispatching when the ghost element has the lower value--but I sped through it.

A: Here's something simple you could use. Although you might want to customize the style.
I am altering the z-index of the slider element based upon its proximity to the cursor.
JSFiddle
HTML
<input id='a' type='range' />
<input id='b' type='range' />
<label role='info'></label>

JS
var a = document.getElementById('a');
var b = document.getElementById('b');

a.onmousemove = function(e) {
    MouseMove.call(a, e);
};
b.onmousemove = function(e) {
    MouseMove.call(b, e);
};

var MouseMove = function(eventArg)
{

    var max = parseInt(a.max),
        min = parseInt(a.min),
        diff = max - min,
        clickPoint = eventArg.offsetX / a.offsetWidth,
        clickPointVal = parseInt(diff * clickPoint) + min;

    /* absolute distance from respective slider values */
    var da = Math.abs(a.value - clickPointVal),
        db = Math.abs(b.value - clickPointVal);

    // Making the two sliders appear above one another only when no mouse button is pressed, this condition may be removed at will
    if (!eventArg.buttons)
    {
        if (da < db)
        {
            a.style.zIndex = 2;
            b.style.zIndex = 1;
        }
        else if (db < da)
        {
            b.style.zIndex = 2;
            a.style.zIndex = 1;
        }
    }
    document.querySelector('label').innerHTML = 'Red: ' + a.value + ', Green: ' + b.value + ', X: ' + eventArg.clientX;
}

CSS
input {
    margin: 0px;
    position: absolute;
    left: 0px;
}

label {
    display: inline-block;
    margin-top: 100px;
}

#a {
    z-index: 2;
}

#b {
    z-index: 1;
}


text:
Q: How to sense collisions between wall and player: Pygame I have a code and i need to sense collisions between the player and the wall. I have looked at other answers and threads but can't understand them:
Here is the code:
    import pygame

    BLACK = (0, 0, 0)
    WHITE = (255, 255, 255)
    BLUE = (0, 0, 255)
    GREEN = (0, 255, 0)
    RED = (255, 0, 0)
    PURPLE = (255, 0, 255)

    class Wall(pygame.sprite.Sprite):
            def __init__(self, x, y, width, height, color):

                    pygame.sprite.Sprite.__init__(self)

                    self.image = pygame.Surface([width, height])
                    self.image.fill(color)

                    self.rect = self.image.get_rect()
                    self.rect.x = x
                    self.rect.y = y

    class Player(pygame.sprite.Sprite):
            speedx = 0
            speedy = 0
            def __init__(self, x, y):

                    pygame.sprite.Sprite.__init__(self)
                    self.image = pygame.Surface([15, 15])
                    self.image.fill(PURPLE)

                    self.rect = self.image.get_rect()
                    self.rect.x = x
                    self.rect.y = y

            def changespeed(self, x, y):

                    self.speedx += x
                    self.speedy += y

            def move(self, walls):
                    self.rect.x += self.speedx

                    block_hit_list = pygame.sprite.spritecollide(self, walls, False)
                    for block in block_hit_list:

                            if self.speedx > 0:
                                    self.rect.right = block.rect.left
                            else:
                                    self.rect.left = block.rect.right

                    self.rect.y += self.speedy

                    block_hit_list = pygame.sprite.spritecollide(self, walls, False)
                    for block in block_hit_list:
                            if self.speedy > 0:
                                    self.rect.bottom = block.rect.top
                            else:
                                    self.rect.top = block.rect.bottom

                    play_col = (self.rect.left, self.rect.right, 10, 10)
                    wall = (10, 200, 10, 10)

                    if ship1.colliderect(ship2):
                            print "ajasj"

    class StartScreen():
            def __init__(self, background, startButton, sbx, sby, sbw, sbh):
                    self.background = background
                    self.startButton = startButton
                    self.sbx = sbx
                    self.sby = sby
                    self.sbw = sbw
                    self.sbh = sbh
                    self.active = True
                    self.b = None
            def drawScreen(self, screen):
                    print "a"
                    print self.background
                    screen.blit(self.background, (0, 0))
                    self.b = screen.blit(self.startButton, (self.sbx, self.sby))
            def onClick(self, event):
                    pos = pygame.mouse.get_pos()
                    if self.b.collidepoint(pos):
                            self.active = False

    class EndScreen():
            def __init__(self, background):
                    self.background = background
                    self.active = True
            def drawBG(self, screen):
                    screen.blit(self.background, (0,0))
    class Room(object):

            wall_list = None
            enemy_sprites = None

            def __init__(self):
                    self.wall_list = pygame.sprite.Group()
                    self.enemy_sprites = pygame.sprite.Group()

    class Room1(Room):
            def __init__(self):
                    Room.__init__(self)

                    walls = [[0, 0, 20, 250, PURPLE],
                                     [0, 350, 20, 250, PURPLE],
                                     [780, 0, 20, 250, PURPLE],
                                     [780, 350, 20, 250, PURPLE],
                                     [20, 0, 760, 20, PURPLE],
                                     [20, 580, 760, 20, PURPLE],
                                     [190, 50, 20, 500, PURPLE],
                                     [590, 50, 20, 500, PURPLE]
                    ]

                    for item in walls:
                            wall = Wall(item[0], item[1], item[2], item[3], item[4])
                            self.wall_list.add(wall)

    class Room2(Room):
            def __init__(self):
                    Room.__init__(self)

                    walls = [[0, 0, 20, 250, PURPLE],
                                     [0, 350, 20, 250, PURPLE],
                                     [780, 0, 20, 250, PURPLE],
                                     [780, 350, 20, 250, PURPLE],
                                     [20, 0, 760, 20, PURPLE],
                                     [20, 580, 760, 20, PURPLE]
                    ]

                    for item in walls:
                            wall = Wall(item[0], item[1], item[2], item[3], item[4])
                            self.wall_list.add(wall)
                    for x in range(100, 800, 100):
                            wall = Wall(x, 100, 20, 400, PURPLE)
                            self.wall_list.add(wall)

    class Room3(Room):
            def __init__(self):
                    Room.__init__(self)

                    walls = [[0, 0, 20, 250, PURPLE],
                                     [0, 350, 20, 250, PURPLE],
                                     [780, 0, 20, 250, PURPLE],
                                     [780, 350, 20, 250, PURPLE],
                                     [20, 0, 760, 20, PURPLE],
                                     [20, 580, 760, 20, PURPLE]
                    ]

                    for item in walls:
                            wall = Wall(item[0], item[1], item[2], item[3], item[4])
                            self.wall_list.add(wall)

                    for x in range(100, 800, 100):
                            for y in range(50, 451, 300):
                                    wall = Wall(x, y, 20, 200, PURPLE)
                                    self.wall_list.add(wall)

                    for x in range(150, 700, 100):
                            wall = Wall(x, 200, 20, 200, PURPLE)
                            self.wall_list.add(wall)

    def main():
            pygame.init()

            screen = pygame.display.set_mode([800, 600])

            pygame.display.set_caption("Wonder Maze")

            player = Player(50, 50)
            movingsprites = pygame.sprite.Group()
            movingsprites.add(player)

            rooms = []

            room = Room1()
            rooms.append(room)
            room = Room2()
            rooms.append(room)
            room = Room3()
            rooms.append(room)
            screen.blit(pygame.image.load("bg.png"), (0,0))
            startScreen = StartScreen(pygame.image.load("bg.png"), pygame.image.load("startbutton.png"), 240, 190, 320, 60)

            current_room_no = 0
            current_room = rooms[current_room_no]

            clock = pygame.time.Clock()

            ingame = True

            while ingame:
                    while startScreen.active:
                            for event in pygame.event.get():
                                    if event.type == pygame.QUIT:
                                            startScreen.active = False
                                            ingame = False
                                            pygame.quit()
                                    if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
                                            startScreen.onClick(event)
                            startScreen.drawScreen(screen)
                            pygame.display.flip()

                    for event in pygame.event.get():
                            if event.type == pygame.QUIT:
                                    done = True
                            if event.type == pygame.KEYDOWN:
                                    if event.key == pygame.K_LEFT:
                                            player.changespeed(-5, 0)
                                    if event.key == pygame.K_RIGHT:
                                            player.changespeed(5, 0)
                                    if event.key == pygame.K_UP:
                                            player.changespeed(0, -5)
                                    if event.key == pygame.K_DOWN:
                                            player.changespeed(0, 5)

                            if event.type == pygame.KEYUP:
                                    if event.key == pygame.K_LEFT:
                                            player.changespeed(5, 0)
                                    if event.key == pygame.K_RIGHT:
                                            player.changespeed(-5, 0)
                                    if event.key == pygame.K_UP:
                                            player.changespeed(0, 5)
                                    if event.key == pygame.K_DOWN:
                                            player.changespeed(0, -5)

                    player.move(current_room.wall_list)

                    if player.rect.x < -15:
                            if current_room_no == 0:
                                    current_room_no = 2
                                    current_room = rooms[current_room_no]
                                    player.rect.x = 790
                            elif current_room_no == 2:
                                    current_room_no = 1
                                    current_room = rooms[current_room_no]
                                    player.rect.x = 790
                            else:
                                    current_room_no = 0
                                    current_room = rooms[current_room_no]
                                    player.rect.x = 790

                    if player.rect.x > 801:
                            if current_room_no == 0:
                                    current_room_no = 1
                                    current_room = rooms[current_room_no]
                                    player.rect.x = 0
                            elif current_room_no == 1:
                                    current_room_no = 2
                                    current_room = rooms[current_room_no]
                                    player.rect.x = 0
                            else:
                                    ingame = False

                    print current_room, current_room_no

                    # --- Drawing ---
                    screen.fill(WHITE)

                    movingsprites.draw(screen)
                    current_room.wall_list.draw(screen)

                    pygame.display.flip()

                    clock.tick(60)

            endScreen = EndScreen(pygame.image.load("wp.png"))
            while endScreen.active:
                    endScreen.drawBG(screen)
                    pygame.display.flip()
                    clock.tick(60)
                    for event in pygame.event.get():
                            if event.type == pygame.QUIT:
                                    endScreen.active = False
                                    pygame.quit()
            pygame.quit()

    if __name__ == "__main__":
            main()

I don't have any idea how to do it i apologies if this is a duplicate.
Any and all help is appreciated very much thank you to everyone who contributes.

A: The collisions are detected in the 'move' method of the 'Player' class.
It is done with a call to the 'spritecollide' method. The first argument is 'self', which represents a player.  The second argument is a list of all the sprites that represent the walls.  The third argument is a boolean telling not to remove the wall sprites (otherwise walls would disappear when a player collides with them).  It returns a list of blocks (sprites used to represent walls) that intersect with the player.
You can look at the documentation in http://www.pygame.org/docs/ref/sprite.html#pygame.sprite.Sprite


text:
Q: Breaking pages with boxes in boiboites-like I want to find a method for breaking boxes of my environments of examples (in arabic, with polyglossia.. see ECM below) I saw that mdframed do something like this, but I'm using my own package "myboiboites" induced from boiboites, for arabization. I post the file and the package... in arabic for the file... you can see that it has 2 very "poor pages" because the box-example refuse  to write in a half-page...
\documentclass[14pt,a4paper]{extbook}
%\usepackage{extsizes}

\usepackage[dvips]{graphicx}
\usepackage{boxedminipage}
\usepackage{slashbox}

\usepackage{titlesec}
\usepackage{xcolor}
\usepackage{framed}

\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{enumitem}

\usepackage{minitoc}

\usepackage{rotating}

\usepackage{fmultico}
\setlength{\columnseprule}{0.1pt}

\usepackage{fancyhdr}
\pagestyle{fancy}

\usepackage{pdflscape}

\usepackage{myboiboites}

\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}

\newfontfamily\arabicfont[Script=Arabic, AutoFakeSlant=-0.02]{Amiri}

\usepackage{minitoc}

\newboxedtheorem[boxcolor=gray!20, background=white, titlebackground=white,titleboxcolor = gray]{example}{مثال}{example}
\newenvironment{solution}{\begin{otherlanguage}{arabic}{\bf\textarabic{الحل \hspace{0.5em}}}\end{otherlanguage}\hspace{-0.7em}}{}

\begin{document}
\begin{example}[مبرهنة كثيرات الحدود]
\rm
كم هناك من معامل في تحليل كثيرات الحدود ل
 $(x_{1} +
x_{2} + \cdots + x_{r})^{n}$؟
\end{example}
\begin{solution}
\[
(x_{1} + x_{2} + \cdots + x_{r})^{n} = \sum \left(\begin{array}{c}n\\
n_{1}, \ldots, n_{r}
\end{array}\right) x_{1}^{n_{1}} \cdots x_{r}^{n_{r}}
\]
حيث هذا الجمع هو على كل القيم الغير سالبة
 $(n_{1}, \ldots, n_{r})$
 التي تحقق
  $n_{1} + \cdots + n_{r} = n$.
  وإذا، حسب النظرية~$6.2$،
   هناك
    $\left(\begin{array}{c}n + r - 1\\
r - 1
\end{array}\right)$
معامل كهذا.
\hfill $\blacksquare$
\end{solution}

\begin{example}
\rm
لنعتبر مرة أخرى المثال ،
أين لنا
 $n$
 عنصر،
 منها
  $m$
 معيبة
  (و لا يمكن تمييزها)
   و ال
    $n - m$
    المتبقية
     (و دائما لا يمكن تمييزها)
     غير معيبة.
 و نريد إيجاد عدد الترتيبات الخطية لهذه العناصر، حيث ليس هناك عنصران معيبان متتاليين.
لإيجاد  عدد الترتيبات، تصور أن العناصر المعيبة مصففة على خط ما و أنه يجب وضع العناصر الغير معيبة في مواضع ما. لنرمز ب
$x_{1}$
عدد العناصر الغير معيبة على يسار المعيب الأول،
 $x_{2}$
 عدد العناصر الغير معيبة بين الأول و الثاني، و هكذا.
 أي أنه لنا
\[
x_{1}\ 0\ x_{2}\ 0 \cdots x_{m}\ 0\ x_{m + 1}
\]
الآن، سيكون على الأقل عنصر غير معيب بين كل زوج من العناصر المعيبة طالما
 $x_{i} > 0$، $i = 2, \ldots, m$.
و إذا، عدد المنتجات المحققة لهذه الشروط هو عدد المتجهات
$x_{1}, \ldots, x_{m + 1}$
التي تحقق المعادلة
\[
x_{1} + \cdots + x_{m + 1} = n - m \quad x_{1} \geq 0,\; x_{m + 1}
\geq 0, \;x_{i} > 0, \; i = 2, \ldots,~m
\]
%\hfill$\blacksquare$
\noindent
لكن، بوضع
 $y_{1} = x_{1} + 1$، $y_{i} = x_{i}$، $i = 2,
\ldots, m$، $y_{m + 1} = x_{m + 1} + 1$،
 نرى أن هذا العدد  يساوي عدد المتجهات بإحداثيات موجبة
 $(y_{1}, \ldots, y_{m + 1})$
التي تحقق المعادلة
\[
y_{1} + y_{2} + \cdots + y_{m + 1} = n - m +~2
\]

و ذاك، حسب النظرية...،
 هناك
  $\left(\begin{array}{c}n - m + 1\\
m
\end{array}\right)$
منتجات كهذه، بتوافق مع نتيجة المثال.

افترض الأن أننا نهتم بعدد المنتجات حيث  أن  هناك على الأقل عنصرين سليمين بين كل زوج من العناصر المعيبة. بنفس المنطق السابق، سيساوي هذا العدد عدد المتجهات المحققة للمعادلة
\[
x_{1} + \cdots + x_{m + 1} = n - m \quad x_{1} \geq 0, \; x_{m + 1}
\geq 0, \; x_{i} \geq 2, \; i = 2, \ldots,~m
\]
بوضع
 $y_{1} = x_{1} + 1$, $y_{i} = x_{i} - 1$, $i = 2, \ldots,
m$, $y_{m+1} = x_{m+1} + 1$,
نرى أن هذا العدد يساوي عدد الحلول الموجبة للمعادلة
\[
y_{1} + \cdots + y_{m + 1} = n - 2m +~3
\]
و إذا.....،
 هناك
  $\left(\begin{array}{c}n - 2m + 2\\
m
\end{array}\right)$
 منتجات كهذه.
\hfill$\blacksquare$
\end{example}
 \end{document}

myboiboites.sty
\RequirePackage{xkeyval} \RequirePackage{tikz}
\RequirePackage{amssymb}

\define@key{boxedtheorem}{titlecolor}{\def\titlecolor{#1}}
\define@key{boxedtheorem}{titlebackground}{\def\titlebackground{#1}}
\define@key{boxedtheorem}{background}{\def\background{#1}}
\define@key{boxedtheorem}{titleboxcolor}{\def\titleboxcolor{#1}}
\define@key{boxedtheorem}{boxcolor}{\def\boxcolor{#1}}
\define@key{boxedtheorem}{thcounter}{\def\thcounter{#1}}
\define@key{boxedtheorem}{size}{\def\size{#1}}
\presetkeys{boxedtheorem}{titlecolor = black, titlebackground = white, background = white,
                         titleboxcolor = black, boxcolor = black, thcounter=, size = .98\textwidth}{}

\newcommand{\couleurs}[1][]{
    \setkeys{boxedtheorem}{#1}
    \tikzstyle{fancytitle} =[draw=\titleboxcolor,  fill=\titlebackground,
                            text= \titlecolor]
    \tikzstyle{mybox} = [draw=\boxcolor, fill=\background, very thick,line width=0.1pt,
                        rectangle,  inner sep=10pt, inner ysep=20pt]
}

\newsavebox{\boiboite}
\newcommand{\titre}{Titre}
\newenvironment{boite}[2][]
    {
    \renewcommand{\titre}{#2}
    \couleurs[#1]
    \begin{lrbox}{\boiboite}
     \begin{minipage}[!h]{\size}
    }
    {
     \end{minipage}
    \end{lrbox}
    \begin{center}
    \begin{tikzpicture}
    \node [mybox] (box){\usebox{\boiboite}};
    \node[fancytitle, left=10pt] at (box.north east) {\titre};
    \end{tikzpicture}
    \end{center}
    }

\newcommand{\newboxedtheorem}[4][]{
    \couleurs[#1]
    \@ifnotempty{#4}{
      \@ifundefined{the#4}{\@ifundefined{\thcounter}{\newcounter{#4}}{
      \newcounter{#4}[\thcounter ] } } { }
    }
    \newenvironment{#2}[1][]{
    \@ifnotempty{#4}{\refstepcounter{#4}}
    \begin{boite}[#1]{\RL{\textbf{#3\@ifnotempty{#4}{ \csname the#4\endcsname.}}\@ifnotempty{##1}{
    ##1}}}
    }
    {
    \end{boite}
    }
}

Any solution please with my packages... Many thanks
Faouzi

A: Have you tried this ?
Breaking Page with Boiboites Package TikZ
If it doesn't suit your need, you can use the framed package as seen here:
http://www.texample.net/tikz/examples/framed-tikz/
A contact of mine did it some time ago and here is what he came up with (not sure it's optimal but it works):
\RequirePackage{xkeyval}
\RequirePackage{tikz}
\RequirePackage{amssymb}
\RequirePackage{framed}
\usetikzlibrary{decorations.pathmorphing,calc}
\pgfmathsetseed{1} % To have predictable results
% Define a background layer, in which the parchment shape is drawn
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

% define styles for the normal border and the torn border
\tikzset{  fond/.style={blue!5,rounded corners=5pt,decorate}}%,
\tikzset{  bordure/.style={orange,very thick,-,rounded corners=5pt}}
\tikzset{  titre/.style={draw,rectangle,rounded corners=5pt,fill=blue!20}}

% Macro to draw the shape behind the text, when it fits completly in the
% page
\def\parchmentframe#1{
\tikz{
  \node[inner sep=5pt] (A) {#1};  % Draw the text of the node
  \noindent
  \begin{pgfonlayer}{background}  % Draw the shape behind
  \fill[fond]
        (A.south east) -- (A.south west) --
        (A.north west) -- (A.north east) -- cycle;
  \draw[bordure]
        (A.south east) -- (A.south west) --
        (A.north west) -- (A.north east) -- cycle;
  \end{pgfonlayer}}}

% Macro to draw the shape, when the text will continue in next page
\def\parchmentframetop#1{
\tikz{
  \node[inner sep=5pt] (A) {#1};    % Draw the text of the node
  \begin{pgfonlayer}{background}
  \fill[fond]              % Draw the ``complete shape'' behind
        (A.south east) -- (A.south west) --
        (A.north west) -- (A.north east) -- cycle;
  \draw[bordure]
        (A.south east) -- (A.south west) --
        (A.north west) -- (A.north east) -- cycle;
  \end{pgfonlayer}}}

% Macro to draw the shape, when the text continues from previous page
\def\parchmentframebottom#1{
\tikz{
  \node[inner sep=5pt] (A) {#1};   % Draw the text of the node
  \begin{pgfonlayer}{background}
  \fill[fond]             % Draw the ``complete shape'' behind
        (A.south east) -- (A.south west) --
        (A.north west) -- (A.north east) -- cycle;
  \draw[bordure]
        (A.south east) -- (A.south west) --
        (A.north west) -- (A.north east) -- cycle;
  \end{pgfonlayer}}}

% Macro to draw the shape, when both the text continues from previous page
% and it will continue in next page
\def\parchmentframemiddle#1{
\tikz{
  \node[inner sep=5pt] (A) {#1};   % Draw the text of the node
  \begin{pgfonlayer}{background}
  \fill[fond]             % Draw the ``complete shape'' behind
        (A.south east) -- (A.south west) --
        (A.north west) -- (A.north east) -- cycle;
  \draw[bordure]
        (A.south east) -- (A.south west) --
        (A.north west) -- (A.north east) -- cycle;
  \end{pgfonlayer}}}

% Define the environment which puts the frame
% In this case, the environment also accepts an argument with an optional
% title (which defaults to ``Th\'eor\`eme'', which is typeset in a box     overlaid
% on the top border
\newcounter{ctheo}[chapter]%définition d'un compteur
\newenvironment{theo}[1][Th\'eor\`eme.]{%
  \noindent
  \stepcounter{ctheo}
  \def\FrameCommand{\parchmentframe}%
  \def\FirstFrameCommand{\parchmentframetop}%
  \def\LastFrameCommand{\parchmentframebottom}%
  \def\MidFrameCommand{\parchmentframemiddle}%
  \vskip\baselineskip
  \MakeFramed {\FrameRestore}
  \noindent  \tikz  \node[inner sep=1ex,titre,anchor=west, overlay] at (0pt,     8pt) {\sffamily#1 \thectheo .}; \par \noindent}%
{\endMakeFramed}

The main problem with this solution is that you have to define every environment this way, you can't use the \newboxedtheorem macro to generate your environments.


text:
Q: Flutter Run Error: Supplied javaHome must be a valid directory. You supplied: C:\Program Files\Java\jdk-17.0.1 in flutter project I tried to downgrade my Java SDK as there was an error with the latest version with flutter. In doing so, I have created this issue, which I cannot fix. The issue comes up when I run Flutter run.
The image is my Environment variables.

If i create a new flutter project it works fine, this error only comes up in my existing project


text:
Q: Slide and Toggle classes of font awesome jQuery I am in a process of learning jQuery. There are many things I still don't understand. Here, I am trying to slide toggle the classes of font awesome. Not sure how can I achieve that. This is what I have so far.
$(function() {
    $("#nav").click(function(){
        $("#naver").slideToggle(function(){
            $("#nav i").removeClass("fa-bars").addClass("fa-eye");
        }, function(
            $("#nav i").removeClass("fa-eye").addClass("fa-bars");
        ));
    });
});

html,

Home

About

Contact

A: You had a slight typo in your second callback function, although you can't use multiple callback functions as you've tried with slideToggle. I've amended your code, preview here: https://jsfiddle.net/4xu16oqn/1/
JS
$(function() {
    $("#nav").click(function(){
        $("#naver").slideToggle(250);
        $("#nav i").toggleClass("fa-bars").toggleClass("fa-eye");
    });
});

HTML

Home

About

Contact

CSS
#naver{ display:none; }

A: You don't really need another callback function for slideToggle(), and using toggleClass() will save you a few lines of code as well. In general, if we have only one event (i.e. click), we can tie in all of the functions associated with that one event within that event.
SNIPPET

$(function() {
  $("#nav").click(function() {
    $("#naver").slideToggle();
    $("#nav i").toggleClass('fa-bars fa-eye');
  });
});
<link rel="stylesheet" href="https://cdn.jsdelivr.net/fontawesome/4.7.0/css/font-awesome.min.css">

Home

About

Contact


text:
Q: How do I typeset a table with a caption within a tabularx within another table with a caption? Unfortunately, it keeps bugging me with forgotten \endgroup, float(s) lost, not in outer par mode and so on.
In other words, why can't I do something like this (the actual table is significantly more complex with rules and stuff):
\documentclass{article}

\usepackage{blindtext}
\usepackage{tabularx}

\begin{document}

\begin{table}
  \begin{tabularx}{\textwidth}{X}
    \begin{table}
      \begin{tabularx}{\textwidth}{X}
        \blindtext
      \end{tabularx}
      \caption{Inner table}
    \end{table}
  \end{tabularx}
  \caption{Outer table}
\end{table}

\end{document}

A: There are two problems here:

*

*Nested table environments: Not in outer par mode
I suggest dropping the inner table environment. (How should the concept of floating be applicable inside a tabular where the contents are fixed, anyway?)

*Nested tabularx environments:

*

*Extra }, or forgotten \endgroup,

*Missing \endgroup inserted and

*Missing } inserted
The solution is to enclose the inner tabularx by a pair of braces.
The the tabularx manual states:

tabular and tabular* environments may be nested with no restriction,
  however if one tabularx environment occurs inside another, then the inner
  one must be enclosed by { }.

Now the inner caption does work without problems and results in a enumerated caption:

Table 1: Inner table

If this is not preferred, one can use the starred version of \caption* for the inner caption from the caption package.

I also replaced \textwidth with \linewidth so that inner tabularx uses the correct remaining horizontal space (→ Difference between \textwidth, \linewidth and \hsize)
Further improvements  could be

*

*enclosing the inner tabularx and its caption inside the center environment or

*providing more vertical space before the inner tabularx, i.e. \\[2ex].

Code
\documentclass{article}

\usepackage{blindtext}
\usepackage{tabularx}

\begin{document}

\begin{table}
  \begin{tabularx}{\linewidth}{X}
     \blindtext \\
      {\begin{tabularx}{\linewidth}{X}
        \blindtext
      \end{tabularx}}
      \caption{Inner table}
     \\
     \blindtext
  \end{tabularx}
  \caption{Outer table}
\end{table}

\end{document}

Output


text:
Q: Is there a tool (like SonarCloud) to check Flutter code quality? As SonarCloud doesn't support Flutter/Dart I was wondering if there is an alternative for checking the code quality of Flutter projects.

A: These tools can be automatized to be used on CI:

*

*https://pub.dev/packages/dart_code_metrics

*https://pub.dev/packages/linter
Also there one some Github actions ready:

*

*https://github.com/marketplace/actions/dart-code-metrics-action


text:
Q: OpenLayers 6 scaleLine too long I am displaying a 50 meters long lineString side by side with a scaleLine.
The 50 meters long scaleLine appears a little bit longer.

LineString Coordinates are : [1663006.541, 8176215.196, 1663056.542, 8176215.307000001]
and projection is EPSG:3949.
I changed the getPointResolution function for my 3949 projection like proposed in OpenLayers 4 ScaleLine with projection answer. After a few tries I found an implementation getPointResolution: function (r) { return r*1.01; } that solved my problem. Now both length coincide. Yet I am not comfortable with this solution. Why are the length different in the first place and how sound is my solution ? I feel like I am resizing the world when I should be correcting the sizing tool.

A: There was a problem before version 6.4.0 https://github.com/openlayers/openlayers/issues/11118 The latest version is working here https://codesandbox.io/s/3949-scale-2hn1g If panned the line fits exactly under the bar. Due to the projection being true only at the latitudes of true scale the true length is about 49.8545 meters