text:
Q: CameraX ImageCapture Hit timeout for jpeg callback I'm trying to implement Image capture as per https://developer.android.com/training/camerax/take-photo, I'm running my device on Temi Robot, the preview seems to work fine but I run into this error and the callback does not get executed when I attempt to capture an image.
Error
This is the Fragment where the camerax code is called
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    viewModel = new ViewModelProvider(getActivity()).get(GlobalViewModel.class);
    cameraProviderFuture = ProcessCameraProvider.getInstance(getContext());
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.patrol_fragment, container, false);
}

    @Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    previewView = view.findViewById(R.id.previewView);
    cameraProviderFuture.addListener(() -> {
        try {
            ProcessCameraProvider cameraProvider = cameraProviderFuture.get();
            bindPreview(cameraProvider, view);
        } catch (ExecutionException | InterruptedException e) {
            Log.e(TAG, "CameraProvider initialization error: " + e.toString());
        }
    }, ContextCompat.getMainExecutor(getContext()));
         Just for testing
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                takePicture();
            }
        }, 10000);
}

private void bindPreview(ProcessCameraProvider cameraProvider, View view) {
    Preview preview = new Preview.Builder().build();
    CameraSelector cameraSelector = new CameraSelector.Builder()
            .requireLensFacing(CameraSelector.LENS_FACING_FRONT)
            .build();

    preview.setSurfaceProvider(previewView.getSurfaceProvider());

    imageCapture = new ImageCapture.Builder()
            .setTargetRotation(view.getDisplay().getRotation())
            .setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
            .build();

    Camera camera = cameraProvider.bindToLifecycle(getActivity(), cameraSelector, imageCapture,
            preview);

    takePicture();

}

private void takePicture() {
    File mediaFile = getMediaFile();

    ImageCapture.OutputFileOptions outputFileOptions =
            new ImageCapture.OutputFileOptions.Builder(mediaFile).build();
    imageCapture.takePicture(outputFileOptions, viewModel.getExecutorService(),
            new ImageCapture.OnImageSavedCallback() {
                @Override
                public void onImageSaved(ImageCapture.OutputFileResults outputFileResults) {
                    // insert your code here.
                    Log.i(TAG, "Capture success!");
                }

                @Override
                public void onError(ImageCaptureException error) {
                    // insert your code here.
                    Log.e(TAG, "Capture failed :( " + error.toString());

                }
            }
    );
}

private File getMediaFile() {
    File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_PICTURES), "TemiPatrol");
    if (! mediaStorageDir.exists()){
        if (! mediaStorageDir.mkdirs()){
            Log.d(TAG, "failed to create directory");
            return null;
        }
    }
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    return new File(mediaStorageDir.getPath() + File.separator +
            "IMG_"+ timeStamp + ".jpg");
}

private void sendImageToServer(JSONObject requestJson) {
    // for testing
    viewModel.getExecutorService().execute(() -> {
        JsonPostman postman = new JsonPostman(getActivity());
        postman.postRequest(requestJson);
    });
}

}

A: You aren't able to take pictures because the ImageCapture wasn't set up correctly, you aren't binding it when calling ProcessCameraProvider.bindToLifecycle(). You should write something like this:
Preview preview = ...;
preview.setSurfaceProvider(...);

ImageCapture imageCapture = ...;

// bind both preview and imageCapture
cameraProvider.bindToLifecycle(lifecycleOwner, cameraSelector, preview, imageCapture);

This will (should) allow calls to takePicture() to succeed.
I have 2 other comments about your code.

*

*The code that you added for testing purposes (where you schedule an image capture after 10 seconds) should only be executed if the camera setup works. You could run it after the call to bindToLifecycle() for example.

*Binding the use cases to the lifecycle of the fragment's Activity is probably not a good idea. The lifecycleOwner in bindToLifecycle(LifecycleOwner, ...) controls when the camera is opened and closed, so you'd typically want to have the camera start when the fragment or its view starts, and have it stop when the fragment or its view stops. Since you're displaying a preview, you can tie the opening/closing of the camera to the lifecycle of the fragment's view, so you can write:
cameraProvider.bindToLifecycle(getViewLifecycleOwner(), cameraSelector, preview, imageCapture);


text:
Q: Clicking button game logic not working properly In my script whenever you click a "Button" it adds 1 to your score. When you miss the button 10 times total it loads a new scene and you lose the game. When you click the button it resets the total back to 0. The problem im having is that if you miss the button 9 times and then click it on the 10th time it still counts to 10 and it loads the new screen and you lose.
What it should be doing is resetting it back to 0 and you can continue to play.
loseObject sets the amount to 0 when the game begins and when the button is pressed.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
[RequireComponent(typeof(AudioSource))]

public class ButtonReposition : MonoBehaviour
{
public Button prefab;
public GameObject loseObject;
private int count;
public Text countText;

// Use this for initialization

void Start()
{
    count = 0;
    SetCountText();
    float x = Random.Range(325f, -600f);
    float y = Random.Range(250f, -450f);
    Debug.Log(x + "," + y);
    prefab.GetComponent<RectTransform>().anchoredPosition = new Vector2(x, y);
    loseObject.GetComponent<Lose>().amount = 0;
}

public void Move()
{
    float x = Random.Range(325f, -600f);
    float y = Random.Range(250f, -450f);
    Debug.Log(prefab.transform.position.x + "," + prefab.transform.position.y);
    prefab.GetComponent<RectTransform>().anchoredPosition = new Vector2(x, y);
    loseObject.GetComponent<Lose>().amount = 0;
    count = count + 1;
    SetCountText();
}

void SetCountText()
{
    countText.text = "Count: " + count.ToString();
}
}

And on get mouse button down it adds 1 to the total and loads the next scene.
using UnityEngine.Audio;
using UnityEngine.UI;

public class Lose : MonoBehaviour
{
public GameObject Button;
public GameObject Target;
public GameObject loseObject;
public int amount;
public ButtonReposition script;
public void ChangeScene(int changeTheScene)

{
    SceneManager.LoadScene(changeTheScene);
}

void Start()
{

}
void Update()
{
    if (Input.GetMouseButtonDown(0))
    {
        amount += 1;
        Debug.Log(amount);
        if (amount == 10)
        {
            SceneManager.LoadScene(2);
            Destroy(Button);
        }
    }
}
}

A: In other to get this right, you have to find a way to determine when the moue button is down and Button is clicked. You are not doing that now. What you are doing now is checking when left mouse Button is clicked with if (Input.GetMouseButtonDown(0)).
This is one of the cases, where using the Image component is better than using the Button component. Unless you really need the Button component here, the Image component should be used.
This can be done with IPointerDownHandler, IPointerUpHandler interface with their OnPointerDown and OnPointerUp functions.
Disable your ButtonReposition script for now. Use the script below and see if that's doing what you expected. If everything is fine you can then enable your ButtonReposition script and remove the unnecessary stuff inside it.
Attach the ButtonDetector to your Image Component:
public class ButtonDetector : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
    public bool clicked = false;

    public void OnPointerDown(PointerEventData eventData)
    {
        clicked = true;
        //Debug.Log("Pointer Down!");
    }

    public void OnPointerUp(PointerEventData eventData)
    {
        //Reset
        clicked = false;
        // Debug.Log("Pointer Up!");
    }

    // Use this for initialization
    void Start()
    {

    }
}

Your new Lose script:
public class Lose : MonoBehaviour
{
    public GameObject Button;
    public GameObject Target;
    public GameObject loseObject;

    public int missedAmount = 0;
    public int clickedAmount = 0;
    const int MISSED_MAX_AMOUNT = 10;

    //public ButtonReposition script;
    public void ChangeScene(int changeTheScene)

    {
        SceneManager.LoadScene(changeTheScene);
    }

    private ButtonDetector buttonImage;

    void Start()
    {
        GameObject obj = GameObject.Find("ButtonImage");
        buttonImage = obj.GetComponent<ButtonDetector>();
    }

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            if (buttonImage.clicked)
            {

                Debug.Log("Mouse Clicked on Button!");
                clickedAmount++;
                //Reset missedAmount to 0
                missedAmount = 0;
            }
            else
            {
                Debug.LogWarning("Mouse Click on SOMETHING ELSE");
                missedAmount++;
            }

            if (missedAmount == 10)
            {
                Debug.LogWarning("GameOver!");
                Debug.LogWarning("Missed 10 times in a row!");
                SceneManager.LoadScene(2);
                //Destroy(buttonImage.gameObject);
            }
        }
    }
}

A: I think the easiest fix for you would be to make sure your loseObject script executes after your first script. You can do that with the script execution order. If you go to Edit -> Project Settings -> Script Execution Order you can add your loseObject script and draw it below "Default". Then your other script will execute first and set the amount to 0 as you would expect. However, after it gets set to 0, loseObject will still increment by one, so what you actually want to do is set amount to -1.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Codeforces 4C Runtime Error Hi I'm using a Trie implementation to solve this problem, but oin the codeforces' servers I'm getting runtime error, and on my pc and on Ideone is normal.
Any Ideas ?
http://codeforces.com/contest/4/problem/C
https://ideone.com/dvRL3b
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;
#define MAXN  ('z'-'a'+2)
#define VALUE(c) ( (c)-'a' )

struct Trie
{
    Trie *m[MAXN];
    int count;
}trie;

int insert(Trie *  t, char * w){
    if(w[0]=='\0'){
        t->count++;
        return t->count;
    }
    if(t->m[VALUE(w[0])] == NULL){
        t->m[VALUE(w[0])] =(Trie *) malloc(sizeof(Trie));
    }
    return insert(t->m[VALUE(w[0])] , w+1);
}

int main(){

    int t;
    scanf("%d",&t);

    for (int i = 0; i < t; ++i)
    {
        char *w = NULL;
        w = (char *)malloc(sizeof(char));
        scanf("%s",w);
        //printf("%s\n", w);
        int resp = insert(&trie,w);
        if(resp > 1){
            printf("%s%d\n", w,resp-1);
        }else{
            printf("OK\n");
        }
    }

    return 0;

}

A: This line:
w = (char *)malloc(sizeof(char));

will only allocate one byte of memory.
The requests in this problem are at most 32 characters so try:
w = (char *)malloc(sizeof(char)*33); // include 1 extra byte for zero termination byte

In addition, you should probably use calloc when allocating memory for each new Trie, i.e. change
t->m[VALUE(w[0])] =(Trie *) malloc(sizeof(Trie));

to
t->m[VALUE(w[0])] =(Trie *) calloc(sizeof(Trie),1);

as otherwise the pointers will not be cleared.


text:
Q: Working with files through binary representation So this question is probably horribly misguided, if it is please let me know what I need to know/understand or where I need to go to get this information.
So say I have 2 separate PDF files, and convert them each to a binary representation.
Could I combine those two files by converting the binary to a string and combining them?
Further, could I find and alter information as text by finding and replacing binary in either string?


text:
Q: How to get pointer to data in struct via getElementPtr? (in the llvm package) I'm trying to create a struct and access elements in it in llvm via the llvm-3.0.0.0 package on ghc 7.4.1 and am running into some hairy types. Here's a sample code, I'm trying to get the structure's second element (i.e. the Word32 in TestStruct.
{-# LANGUAGE TypeOperators #-}
import LLVM.Core
import Data.Word

type TestStruct = Struct (Word16 :& Word32 :& Word64)
getTestPtr :: Value (Ptr TestStruct) -> CodeGenFunction r (Value (Ptr Word32))
getTestPtr u = getElementPtr u (0 :: Word32, (1  :: Word32, ()))

But I get the following error on ghc 7.4.1:
Test.hs:8:16:
    Overlapping instances for llvm-3.0.0.0:LLVM.Core.Instructions.GetField
                                (Word32, Word64) i Word32
      arising from a use of `getElementPtr'
    Matching instances:
      instance [overlap ok] (llvm-3.0.0.0:LLVM.Core.Instructions.GetField
                               as i b,
                             Succ i i') =>
                            llvm-3.0.0.0:LLVM.Core.Instructions.GetField (a, as) i' b
        -- Defined in `llvm-3.0.0.0:LLVM.Core.Instructions'
      instance [overlap ok] llvm-3.0.0.0:LLVM.Core.Instructions.GetField
                              (a, as) D0 a
        -- Defined in `llvm-3.0.0.0:LLVM.Core.Instructions'
    (The choice depends on the instantiation of `i'
     To pick the first instance above, use -XIncoherentInstances
     when compiling the other instance declarations)
    In the expression: getElementPtr u (0 :: Word32, (0 :: Word32, ()))
    In an equation for `getTestPtr':
        getTestPtr u = getElementPtr u (0 :: Word32, (0 :: Word32, ()))

Test.hs:8:16:
    No instances for (Data.TypeLevel.Num.Sets.PosI Word32,
                      Data.TypeLevel.Num.Ops.IsZero Word32 yz,
                      DivMod10 Word32 yi yl)
      arising from a use of `getElementPtr'
    Possible fix:
      add instance declarations for
      (Data.TypeLevel.Num.Sets.PosI Word32,
       Data.TypeLevel.Num.Ops.IsZero Word32 yz,
       DivMod10 Word32 yi yl)
    In the expression: getElementPtr u (0 :: Word32, (0 :: Word32, ()))
    In an equation for `getTestPtr':
        getTestPtr u = getElementPtr u (0 :: Word32, (0 :: Word32, ()))

A: Indexing into a Struct in the llvm package requires type level numbers so the field type can be computed statically. This is the reason for the nested tuple that describes the record fields. If you use getElementPtr the first index value needs to be a regular integer (Word32 or whatever), or just use getElementPtr0 instead.
{-# LANGUAGE TypeOperators #-}
import LLVM.Core
import Data.TypeLevel
import Data.Word

type TestStruct = Struct (Word16 :& Word32 :& Word64)
getTestPtr :: Value (Ptr TestStruct) -> CodeGenFunction r (Value (Ptr Word32))
-- getTestPtr u = getElementPtr u ((0 :: Word32) & d1 & ())
getTestPtr u = getElementPtr0 u (d1 & ())


text:
Q: String replace specific part of string I have text which looks like this
Key:Value
Key2:Value2
Key3:Value3

i have
a very
long
uncommom
text which i need to drop

Key4:Valu4

A second example would be
Key:Value
Key2:Value2
Key3:Value3
i have a very long uncommom text which i need to drop

Key4:Valu4

The point is to remove sentence
i have a very long uncommom text which i need to drop

from those two SQL strings. I need to mention in contains CHAR(10) and CHAR(13) inside.
I need to keep new lines on key:value pairs.
How to achieve this?
This wont work.
Replace(@string,'i have a very long uncommom text which i need to drop
','')

Edit: Also is there any way to replace double/triple/quadruple new line breaks with just one?

A: The following code demonstrates one way of splitting the string into separate lines and reassembling the lines that contain a colon. It maintains the order of the input lines and does not require any recent features, e.g String_Split.
-- Sample data.
declare @Newline as VarChar(2) = Char(10) + Char(13);
declare @Sample as VarChar(1024) =
  'Key:Value' + @Newline +
  'Key2:Value2' + @Newline +
  'Key3:Value3' + @Newline +
  @Newline +
  'i have' + @Newline +
  'a very ' + @Newline +
  'long ' + @Newline +
  'uncommom' + @Newline +
  'text which i need to drop' + @Newline +
  @Newline +
  'Key4:Valu4';

-- Display the sample data.
select @Sample as Sample, Replace( @Sample, @Newline, '¶' ) as VisibleSample;

-- Test the splitter.
select ItemNumber, Item, Replace( Item, @Newline, '¶' ) as VisibleItem
  from dbo.DelimitedSplit8K( @Sample, @Newline )
  where Item like '%:%';

-- Reassemble the items that include a colon.
declare @Result as NVarChar(1024) = Stuff(
  ( select @Newline + Item
      from dbo.DelimitedSplit8K( @Sample, @Newline )
      where Item like '%:%'
      order by ItemNumber for XML path(''), type).value('.[1]', 'VarChar(max)' ),
    1, Len( @NewLine ), '' );
select @Result as Result, Replace( @Result, @Newline, '¶' ) as VisibleResult;

The splitter is a modified version of Jeff Moden's code which handles a variable length delimiter:
CREATE FUNCTION [dbo].[DelimitedSplit8K]
--===== Define I/O parameters
        (@pString VARCHAR(8000), @pDelimiter VARCHAR(16))
--WARNING!!! DO NOT USE MAX DATA-TYPES HERE!  IT WILL KILL PERFORMANCE!
RETURNS TABLE WITH SCHEMABINDING AS
 RETURN
--===== "Inline" CTE Driven "Tally Table" produces values from 1 up to 10,000...
     -- enough to cover VARCHAR(8000)
  WITH E1(N) AS (
                 SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL
                 SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL
                 SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1
                ),                          --10E+1 or 10 rows
       E2(N) AS (SELECT 1 FROM E1 a, E1 b), --10E+2 or 100 rows
       E4(N) AS (SELECT 1 FROM E2 a, E2 b), --10E+4 or 10,000 rows max
 cteTally(N) AS (--==== This provides the "base" CTE and limits the number of rows right up front
                     -- for both a performance gain and prevention of accidental "overruns"
                 SELECT TOP (ISNULL(DATALENGTH(@pString),0)) ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM E4
                ),
cteStart(N1) AS (--==== This returns N+1 (starting position of each "element" just once for each delimiter)
                 SELECT 1 UNION ALL
                 SELECT t.N+ Len( @pDelimiter ) FROM cteTally t WHERE SUBSTRING(@pString,t.N, Len( @pDelimiter ) ) = @pDelimiter
                ),
cteLen(N1,L1) AS(--==== Return start and length (for use in substring)
                 SELECT s.N1,
                        ISNULL(NULLIF(CHARINDEX(@pDelimiter,@pString,s.N1),0)-s.N1 ,8000)
                   FROM cteStart s
                )
--===== Do the actual split. The ISNULL/NULLIF combo handles the length for the final element when no delimiter is found.
 SELECT ItemNumber = ROW_NUMBER() OVER(ORDER BY l.N1),
        Item       = SUBSTRING(@pString, l.N1, l.L1)
   FROM cteLen l
;

A: This should work:
declare @string nvarchar(max) =
'Key:Value
Key2:Value2
Key3:Value3
i have a very
long uncommom text which i need to drop

Key4:Valu4'

DECLARE @Str NVARCHAR(MAX);
DECLARE @Result NVARCHAR(MAX)='';

--This is just for test the cursor query
SELECT REPLACE(REPLACE(value, CHAR(13), ''), CHAR(10), '')
FROM STRING_SPLIT(@string, CHAR(13))
WHERE CHARINDEX(':', value) != 0

DECLARE db_cursor CURSOR FOR
    SELECT REPLACE(REPLACE(value, CHAR(13), ''), CHAR(10), '')
    FROM STRING_SPLIT(@string, CHAR(13))
    WHERE CHARINDEX(':', value) != 0

OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @Str

WHILE @@FETCH_STATUS = 0
BEGIN
      SET @Result += @Str + CHAR(13) + CHAR(10);

      FETCH NEXT FROM db_cursor INTO @Str
END

CLOSE db_cursor
DEALLOCATE db_cursor

SELECT @Result

The Query uses the "STRING_SPLIT" function to reach to each row individually and then decide to keep the row or not based on existing of the ":" character. In the end the cursor loop creates attach all the valid rows (Key/Value).


text:
Q: Algorithm advice: Find count of number in sorted array The problem:

Let A = A[1]<=A[2]....A[n] be a sorted array of n numbers. Let x be a number. Design  an O(log n) time algorithm to find the number of times x appears in the array. What is the time complexity.

My answer:
Using a binary search find if x = middle. If x is middle then there is a chance x could appear in left and right side of middle. So create left array L[] and right array R[]. Using binary search find the the first time x appeared in L[]. Do the same thing for R[], but to find the last time x appeared in R[]. Note the indexes. So the number of time x appeared = Lastindex - FirstIndex + 1. Time complexity 2log n + c = O(log n).  It's just a 'skeleton part' of algorithm since the  answer doesn't have to be elaborated. This is what I found, but is there a better solution?

A: Use a binary search to find the position of the first element >=x (or the end if there is no such element), and another binary search to find the position of the first element > x.  The difference between these positions is the number of elements == x.
int countXs(int[] array, int len, int x)
{
    int low, high, test;
    for (low=0, high=len; low<high;)
    {
        test = low+((high-low)>>1);
        if (array[test]>=x)
            high=test;
        else
            low=test+1;
    }
    int startPos = low;
    for (low=0, high=len; low<high;)
    {
        test = low+((high-low)>>1);
        if (array[test]>x)
            high=test;
        else
            low=test+1;
    }
    int endPos = low;
    return endPos - startPos;
}

Note that low+((high-low)>>1) is floor((low+high)/2), but protected from overflows.  This is ALWAYS >= low and < high, so we can safely access array[test].


text:
Q: Insert Image in RichTextBox with XAML property I want insert a image into the RichTextBox control in WP7/8.
I can do it in XAML and it work fine.
<RichTextBox>
       <Paragraph>
           <InlineUIContainer>
               <Image Source="/ApplicationIcon.png"/>
           </InlineUIContainer>
       </Paragraph>
  </RichTextBox>

I can do it in code C#:
        Image MyImage = new Image();
        MyImage.Source = new BitmapImage(new Uri("/ApplicationIcon.png", UriKind.RelativeOrAbsolute));
        MyImage.Height = 50;
        MyImage.Width = 50;
        InlineUIContainer MyUI = new InlineUIContainer();
        MyUI.Child = MyImage;

        Paragraph myParagraph = new Paragraph();
        myRichTextBox.Blocks.Add(myParagraph);

        myParagraph.Inlines.Add(MyUI);

But I can't do this way.
        string xaml =
                @"

                    <Paragraph>
                        <InlineUIContainer>
                             <Image Source=""/ApplicationIcon.png""/>
                        </InlineUIContainer>
                    </Paragraph>

";
        myRichTextBox.Xaml = xaml;

I have the error.
I read about it here :

That is happening because the XAML parser does not know how to resolve
  the Paragraph, Underline, etc. elements. In order to fix this, the
  paragraphs with the actual content must be wrapped in a Section
  element that defines the namespace so that the elements can be
  resolved!

But
 don't help.
This is not my whim, for me really easy to create content this way. (I use StringFormat, Replace, etc).
In what could be the problem?
Thanks in advance!
UPDATE
From this article:
public MainPage()
{
    InitializeComponent();
    ListBox list = new ListBox();
    list.ItemTemplate = this.CreateDataTemplate();
    list.ItemsSource = new List<string>{"first","second","third","forth"};
    ContentPanel.Children.Add(list);
}

private DataTemplate CreateDataTemplate()
{
      string xaml = @"<DataTemplate
                            xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
                            xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
                            <Grid>
                                <RichTextBox IsReadOnly=""True"">
                                    <Paragraph>
                                        <InlineUIContainer>
                                                <Image  Source=""http://i.stack.imgur.com/m0UAA.jpg?s=32&g=1"" />
                                        </InlineUIContainer>
                                    </Paragraph>
                                </RichTextBox>
                            </Grid>
                            </DataTemplate>";
       DataTemplate dt = (DataTemplate)XamlReader.Load(xaml);
       return dt;
   }

Exception   "System.Windows.Markup.XamlParseException" in line:
 DataTemplate dt = (DataTemplate)XamlReader.Load(xaml);

A: It is not possible to assign image using Xaml Property of RichTextBox. Refer the below link regarding to elements can be included with the Xaml Property.
http://msdn.microsoft.com/en-us/library/system.windows.controls.richtextbox.xaml(v=vs.95).aspx
If you want to design it dynamically using a list, you can create a DataTemplate Dynamically as given in below link.
http://www.geekchamp.com/tips/wp7-dynamically-generating-datatemplate-in-code
Your Template can be like this:
      @"<DataTemplate
    xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
    <Grid>
        <RichTextBox><Paragraph><InlineUIContainer> <Image Height='50' Width='50' Source='/RichTextBoxBinding;component/Desert.jpg' /> </InlineUIContainer></Paragraph></RichTextBox>
    </Grid>
    </DataTemplate>";


text:
Q: Or operation between two and operations Is there an optimal way to write a query for an OR operation between two AND operations in neo4j.
match(x)-[r]->(y) where y.name="a" with n match(n)--(y) where y.name="b"` OR
match(x)-[r]->(y) where y.name="c" with n match(n)--(y) where y.name="d"`

I got an Neo.ClientError.Statement.SyntaxError !

A: Are you searching something similar to this :
MATCH (x)-[r]->(y)
WHERE
  (y.name="a" AND y.name="b") OR
  (y.name="c" AND y.name="d")
RETURN x,r,y
You just have to use parentheses in your where query.


text:
Q: Can anyone help me on how to sort div according to time? js I want to sort these html according to the date and time inside the div .inner h6. I tried many javascript and couldn't make it. I am new to js , please help

        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galle

7/13/2021 8:10:20 PM

        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galle

7/13/2021 8:11:55 PM

        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galle

7/13/2021 8:10:12 PM

        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galle

7/13/2021 8:10:43 PM

        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galle

7/13/2021 8:10:34 PM

A: Something like this?

*

*We are sorting the children via new Date(a.querySelector("h6").innerText) - new Date(b.querySelector("h6").innerText)

*We are re-adding the children in corresponding order

const root = document.getElementById("root");
[...root.querySelectorAll(".inner")]
  .sort((a, b) => (new Date(a.querySelector("h6").innerText) - new Date(b.querySelector("h6").innerText))).forEach(e => root.appendChild(e));

    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galle

7/13/2021 08:10:20 PM

    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galle

7/13/2021 08:11:55 PM

    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galle

7/13/2021 08:10:12 PM

    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galle

7/13/2021 08:10:43 PM

    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galle

7/13/2021 08:10:34 PM


text:
Q: Bootstrap is not picked up by SpringBoot with Thymleafe I am trying to use Thymleafe and Bootstrap in SpringBoot application.
However, I could not understand why SpringBoot is not picking up Bootstrap.
When I am running my project it's just showing plain-old HTML and not picking Bootstrap.
pom.xml
<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>jquery</artifactId>
    <version>3.0.0</version>
</dependency>
<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>bootstrap</artifactId>
    <version>4.0.0</version>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

index.html
<!DOCTYPE html>

<meta charset="ISO-8859-1" />
<title>Home</title>

<link rel="stylesheet" type="text/css"
    href="webjars/bootstrap/4.0.0/css/bootstrap.min.css" />

Please Login

        <form th:action="@{/users/login}" method="POST">

                Email: <input type="email"
                    class="form-control" id="username" placeholder="Enter email"
                    name="username"></input>

                Password: <input type="password"
                    class="form-control" id="password" placeholder="Enter password"
                    name="password"></input>

            <button type="submit" class="btn btn-primary">Submit</button>
        </form>

Can anyone please help what I am missing?

A: If your application is not running in the root context path or if the page is not served at the root path then your script and stylesheet references will not work because they are document-relative.
Consider building the URLs with Theamleaf's URL functionality, like this:
<link rel="stylesheet" th:href="@{/webjars/bootstrap/4.0.0/css/bootstrap.min.css}" />

Same for the


text:
Q: VS 2022 publishing docker image to hub.docker.com Looks like publishing in VS 2022 to hub.docker.com (free account) does not work correctly.
I have registered a free account on hub.docker.com. I did not create any projects.
I made a sample WebApi project and went on to publish it to Docker Hub Container Registry. When you choose Docker Hub as DCR, VS2022 provides 3 options:

*

*Publish to personal repository (checkbox)

*username

*password (optional)

So, I left 1 options checked (wanted it as personal), I entered docker hub username (not email) and password.
When I clicked on publish, image was published to docker hub into the public repository (not private), with the name: myusername/myprojectname:latest
I can live with the bug with not publishing to private repository, but I would like to change the name of the image. So this is what I did:

*

*I deleted repository from docker hub to start over.

*I edited publish options in VS to change the tag from latest to automatically generated - that works OK (now its published as myusername/myprojectname:20220806160216).

*I edited project settings and added line with DockerfileBuildArguments:
<PropertyGroup>
  <TargetFramework>net6.0</TargetFramework>
  <Nullable>enable</Nullable>
  <ImplicitUsings>enable</ImplicitUsings>
  <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
  <DockerfileBuildArguments>-t myusername/customname</DockerfileBuildArguments>

However, it did not made any difference, image was still published as myusername/myprojectname. I tried with
  <DockerfileBuildArguments>-t customname</DockerfileBuildArguments>

and also did not make any difference, image still published with project name.
Anyone knows if this is a known bug with VS, or I am doing something wrong?
Edit:
I just looked at the build output, and I can see that VS passes two -t parameters, which obviously should not happen:
docker build -f "...SolutionDir\myProjectName\Dockerfile" --force-rm -t myprojectname -t myusername/customname --label "com.microsoft.created-by=visual-studio" --label "com.microsoft.visual-studio.project-name=MyProjectName" "...SolutionDir"


text:
Q: Example when two strings compared by == and equals() will give different results? When is a == b is true but a.equals(b) is false, or vice versa?
I know that equals() is used to compare the values of the Strings and the == to check if two variables point at the same instance of a String object.
But in which case will these two be different ?

A: Consider this code,
String str1 = "ABC";
String str2 = new String("ABC");
System.out.println(str1==str2); // false
System.out.println(str1.equals(str2)); //true

The reason for this is that when you write String str1="ABC" this string is kept in string pool and String str2 = new String("ABC") creates the new object in heap and it won't check the string pool if it is already present. But as contents of the both string are same, equals method returns true.

A: While most compilers will intern strings so that
a = "Foo";
b = "Foo";
System.out.println(a == b);

will generally print True, you can always construct strings that you know to be identical but the compiler does not:
a = "Foo";
b = "Fo";
c = "o";
System.out.println((a == b + c));

This will just about always print False, while a.equals(b + c) will always be True. Basically, there is no guarantee that strings with the same content will point to the same object.

A: Strings are immutable in nature. So, when we do this,
String a1 = "a";
String a2 = "a";

Actually in memory, only one instance of String "a" is created. Both a1 and a2 will point to the same instance.
That's why, a1 == a2 and a1.equals(a2) are both true.
But, in this,
String a1 = "a";
String a2 = new String("a");

We created a new String instance explicitly. So, a1.equals(a2) will be true. But a1 == a2 will not.


text:
Q: segmentation error when joining 2 height balanced tree in C I am trying to join 2 height balance trees. for that purpose, I am writing join() function in C. I have done everything as per as instruction but for something, it is showing segmentation error. I understand that segmentation error happen when  there is a bad pointer. I am trying to code in C. I could not figure out where is the bad pointer. I could not understand where did I do wrong. in the code, there is the part 2 and 2.1 in join() function. If I could do that, rest of the parts are pretty much identical. Please let me know where is the error and mistake in my code. please do not give any rude comment, I am learning advanced data structure. thank you in advanced.
// I have 2 trees tree1 and tree2. this part is the part when I am joining. there are other parts in the code, but other parts are identical to this part of the code. If I could figure out what I did wrong here, I can figure out for the rest part

    // join() function
    tree_node_t *join(tree_node_t *tree1, tree_node_t *tree2, key_t separating_key)
    { tree_node_t *common_root, *tmp2, *new_node, *tmp_node, *tmp1, *up;
    int finished;
        //------------------introduction----------------------------------------------
        // we have 2 height balanced tree tree1 and tree2. these 2 trees are arguments.

        // all keys in tree1 smaller than all keys of tree2

tree1->key < tree2->key;
//-----------------------------------------------------------------------------
//-------------------part 1----------------------------------------------------
while(abs(tree1->height - tree2->height) <= 1){
    common_root = get_node();// adding a common root
    common_root->left = tree1;// putting tree1 at left
    tree1->upper = common_root;
    common_root->right = tree2;// putting tree2 at right
    tree2->upper = common_root;
    common_root->key = separating_key;
}
//--------------------------------------------------------------------------------
//--------------------part 2------------------------------------------------------
while(tree1->height <= tree2->height - 2){
    tmp2 = tree2;
    /*while(tmp2->left != NULL){
        tmp2 = tmp2->left;
    }*/
    while(tmp2->left != NULL && tmp2->height <= tree1->height){
        // -------------------------start of part 2.1----------------------------
        while(tmp2->left != NULL && tmp2->height == tree1->height && tmp2->upper->height == tree1->height + 2){
            up = tmp2->upper;
            new_node = get_node();
            new_node->height = tree1->height + 1;
            up->left = new_node;
            new_node->right = tmp2;
            new_node->left = tree1;
            new_node = tmp2->upper;
            up = new_node->upper;
            new_node->key = separating_key;
            up->height = tree1->height + 2;
        }


text:
Q: Type mismatch when returning from inside if statement The following code fails to compile:
fn testing() -> i32 {
    let x = 5;
    if x == 5 {
        5
    }
    6
}

with this error:
error E0308: mismatched types. (expected (), found integral variable)

If I put an explicit return in front of the 5, or if I put the 6 inside an else block, everything works fine. What exactly is Rust complaining about?

A: In Rust, nearly everything is an expression, including if-else. if generates a value, but there is no value for the expression if the expression fails (i.e. x != 5). When putting the 6 into the else block, the if-else statement returns an integral (which will be an i32 due to the return type). You can suppress the statement's value with a semicolon.
return 5 (note, that there is no semicolon) is also a statement, which results in (). Now the if expression always returns (), which is fine.
Idiomatically you should prefer the else variant, so you can omit the return:
fn testing() -> i32 {
    let x = 5;
    if x == 5 {
        5
    } else {
        6
    }
}

A: if-else is an assignable expression that has a type. Omitting else {} is equivalent to if { ... } else { () }. If you assign that value to a variable:
// would not compile
let result = if x == 5 {
    5
};

it is equivalent to writing:
let result = if x == 5 {
    5
} else {
    ()
};

Making the type of result either integer or unit, which is invalid.


text:
Q: What is single word or phrase/idiom for "someone speaks alot but works very-very slow" What is single word or phrase/idiom for "someone speaks a lot but works very very slow"
for example.... someone said/planned he would do 100 task but actually finished less than 10 task

A: All talk (and no action)

Much discussion but no action or results
"Don't count on Mary's help—she's all talk"
"Dave has been saying for months that he'll get a summer job, but he's all talk and no action."
This idiom may have begun life as all talk and no cider, which Washington Irving cited as an American proverb in Salmagundi (1807). However, similar sayings antedate it by many years—for example, "The greatest talkers are always the least doers" (John Ray, English Proverbs, 1670).

A: There is a proverb says,
I hear cracking, but I don't see grinding.
It means that someone speaks a lot, but does nothing.


text:
Q: x64 calls to function in another dll Can someone explain to me the following behavior on x64 platform:
If I call from my executable to a function in another dll in x64 the disassembled code looks something like this:
000000014000149E FF 15 34 CF 00 00  call  qword ptr [__imp_CFuncInDll (14000E3D8h)]

I realize that the debugger calculates the relative address to this absolute address 14000E3C0h. However unlike x86 code if I'll disassemble the address 14000E3D8h it looks like garbage:
__imp_CFuncInDll:
000000014000E3D8 19 10                sbb         dword ptr [rax],edx
000000014000E3DA 25 FC FE 07 00       and         eax,7FEFCh
000000014000E3DF 00 14 10             add         byte ptr [rax+rdx],dl
000000014000E3E2 25 FC FE 07 00       and         eax,7FEFCh
000000014000E3E7 00 00                add         byte ptr [rax],al
.......

When I step into the call I can see that instead of getting into the garbage address the code jumps to a valid address:
000007FEFC251019 E9 62 00 00 00       jmp         CFuncInDll (7FEFC251080h)

My question:
How the call instruction is decoded on x64 when the target is in another module?
In x86 the call target of this code:
FF 15 34 CF 00 00    call

was: target = next instruction address + 0x0000CF34
While on x64 it looks like this is not the case.

A: call  qword ptr [__imp_CFuncInDll (14000E3D8h)] is an indirect call through a pointer. The pointer's address is 0x14000E3D8.  If you look at the code bytes of your non-sense disassembly, they turn out to contain the following:
19 10 25 FC FE 07 00 00

Which is a little-endian quadword is: 000007fe.fc251019 - the address of the jmp CFuncInDll instruction you get to when you single step.
Basically, the call to an import function is being assembled as a call through an entry in a table of addresses to a small 'thunk' that jumps to the actual function implementation.

A: You're trying to disassemble a pointer to the code instead of the code.
This instruction
000000014000149E FF 15 34 CF 00 00  call  qword ptr [__imp_CFuncInDll (14000E3D8h)]
reads a pointer from the address that is relative to the beginning of the instruction following it, that is, it adds 14000149EH, 6 (length of this call instruction) and 0CF34H, arrives at address 14000E3D8H, reads 8 bytes from there, and that (those 8 bytes: 19H, 10H, 25H, 0FCH, 0FEH, 7H, 0, 0) is the address 7FEFC251019H where this call transfers control.
You should be disassemblying at address 7FEFC251019H.


text:
Q: Can you print JavaScript variables from a Visual Studio 2008 Tracepoint? After learning about how to print out debug messages using Visual Studio's Tracepoint feature, I was curious to see if it worked in JavaScript files. So far, it does and it doesn't.
If I am editing a .js file in VS 2008, I can click on the margin to create a breakpoint. I can then right-click the breakpoint and select "When Hit" and the dialog comes up to define the action.
I select "Print a Message" and "Continue execution". That way, the breakpoint becomes a tracepoint and prints the message to the output window when the ASP.Net program is running in debug.
This, in itself, is very cool. But, in C# code, I can put variables into the printed message by enclosing them in {}. So I can say "In Function $FUNCTION, x = {x}". When I try to do this with JavaScript tracepoints, no matter what I put in the brackets, it just says "variable is not defined".
Is there any way to print meaningful information other than "You are here" type messages in JavaScript tracepoints?
My intent was to put in timing code that would print to the output console in debug but not have to be commented out for releases.
It does at least kinda support JavaScript because if I use it's builtin variables, like $FUNCTION for the function name it works. Actually I just got it to print "JScript anonymous function" for $FUNCTION, but it was in an anonymous function. If there was a $TIMESTAMP I would be in good shape.

A: There isn't a $TIMESTAMP, but there is a $TICK. It prints the millisecond count 'tick' in hexadecimal, so it looks like this:
Document Ready Start - 0x890A27
Document Ready End - 0x890E7C

So a little calculator work can figure out the difference between the two.
Still don't know how to evaluate JavaScript variables though...
UPDATE:
It isn't quite as nice as using tracepoints (since you don't actually add things to the code for them), but Sys.Debug.trace() does what I want as far as timing code sections.


text:
Q: Entity Framework asp net core relationship I have two models:
User:
using System.ComponentModel.DataAnnotations;

namespace EDiary.Models
{
    public class User
    {
        public int Id { get; set; }
        [Required(AllowEmptyStrings = false, ErrorMessage = "Podaj imię")]
        [MaxLength(25, ErrorMessage = "Imię jest zbyt długie. Max. 25 znaków.")]
        public string FirstName { get; set; }
        [Required(AllowEmptyStrings = false, ErrorMessage = "Podaj nazwisko")]
        [MaxLength(25, ErrorMessage = "Nazwisko jest zbyt długie. Max. 25 znaków.")]
        public string LastName { get; set; }

        [EmailAddress(ErrorMessage = "Podaj prawidłowy adres e-mail")]
        public string Email { get; set; }

        [MinLength(7, ErrorMessage = "Hasło musi składać się z conajmniej 7 znaków")]
        public string Password { get; set; }
        public Class Class { get; set; }
    }
}

and Class:
using System.Collections.Generic;

namespace EDiary.Models
{
    public class Class
    {
        public int Id { get; set; }
        public User Educator { get; set; }
        public string ClassName { get; set; }
        public ICollection<User> Users { get; set; }
    }
}

When I do add-migration I get an error: Unable to determine the relationship represented by navigation 'Class.Educator' of type 'User'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'. Why?

A: Add ClassId to User:
public class User
    {
        .....
  public int? ClassId {get; set;}
     [ForeignKey(nameof(ClassId))]
        [InverseProperty("Users")]
        public Class Class { get; set; }
    }

and  EducatorId  to Class
   public class Class
    {
        public int Id { get; set; }
       public string ClassName { get; set; }

         [ForeignKey("Educator")]
       public int? EducatorId {get; set;}
       public User Educator { get; set; }

          [InverseProperty("Class")]
        public ICollection<User> Users { get; set; }
    }


text:
Q: PDE's stability I am struggling with the following PDE's stability, my intuitive is to use the semigroup theory, but it seems that I can not even  compute the eigenvalues, any other idea?
$$w_t=-aw-b^2\int_o^{2\pi}sin\theta B(t,\theta)d\theta \\
  B_t=-w^*B_{\theta}-B^*_\theta w+\lambda B$$
Here a,b are constant and w is a function of t, B is a function of t and $\theta$, $w^*$ and $B^*_\theta$ are known functions.


text:
Q: SonataUserBundle : try to go /profile => route "sonata_customer_addresses" does not exist I can't figured out why I have this error.
Herewith more informations abour my problem :
An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "sonata_customer_addresses" as such route does not exist.") in SonataUserBundle:Profile:action.html.twig at line 27.

to implement my own User Class.
I use Symfony 2.4 with dev-master SonataAdminBundle and SonataUserBundle. I try
you can find my config.yml :
    sonata_user:
    security_acl: true
    manager_type: orm
    profile:
        # Profile show page is a dashboard as in SonataAdminBundle
        dashboard:
            blocks:
                - { position: left, type: sonata.block.service.text, settings: { content: "
Welcome!
 This is a sample user profile dashboard, feel free to override it in the configuration! Want to make this text dynamic? For instance display the user's name? Create a dedicated block and edit the configuration!"} }
                - { position: left, type: sonata.order.block.recent_orders, settings: { title: Recent Orders, number: 5, mode: public }}
                - { position: right, type: sonata.timeline.block.timeline, settings: { max_per_page: 15 }}
                - { position: right, type: sonata.news.block.recent_posts, settings: { title: Recent Posts, number: 5, mode: public }}
                - { position: right, type: sonata.news.block.recent_comments, settings: { title: Recent Comments, number: 5, mode: public }}
        # Customize user portal menu by setting links
        menu:
            - { route: 'sonata_user_profile_show', label: 'sonata_profile_title', domain: 'SonataUserBundle'}
            - { route: 'sonata_user_profile_edit', label: 'link_edit_profile', domain: 'SonataUserBundle'}
            - { route: 'sonata_customer_addresses', label: 'link_list_addresses', domain: 'SonataCustomerBundle'}
            - { route: 'sonata_user_profile_edit_authentication', label: 'link_edit_authentication', domain: 'SonataUserBundle'}
            - { route: 'sonata_order_index', label: 'order_list', domain: 'SonataOrderBundle'}

#sonata_admin:
#    templates:
#        dashboard: SonataAdminBundle:Core:dashboard.html.twig

sonata_admin:
    title:      Admin Panel
    title_logo: /bundles/sonataadmin/logo_title.png
    templates:
        # default global templates
        layout:  SonataAdminBundle::standard_layout.html.twig
        ajax:    SonataAdminBundle::ajax_layout.html.twig

        # default actions templates, should extend a global templates
        list:    SonataAdminBundle:CRUD:list.html.twig
        show:    SonataAdminBundle:CRUD:show.html.twig
        edit:    SonataAdminBundle:CRUD:edit.html.twig
    dashboard:
        blocks:
            # display a dashboard block
            - { position: left, type: sonata.admin.block.admin_list }

sonata_block:
    default_contexts: [cms]
    blocks:
        sonata.admin.block.admin_list:
            contexts:   [admin]

        #sonata.admin_doctrine_orm.block.audit:
        #    contexts:   [admin]
        sonata.user.block.menu:
        sonata.user.block.account:
        sonata.block.service.text:
        sonata.block.service.action:
        sonata.block.service.rss:

sonata_doctrine_orm_admin:
    # default value is null, so doctrine uses the value defined in the configuration
    entity_manager: ~
    templates:
        form:
            - SonataDoctrineORMAdminBundle:Form:form_admin_fields.html.twig
        filter:
            - SonataDoctrineORMAdminBundle:Form:filter_admin_fields.html.twig
        types:
            list:
                array:      SonataAdminBundle:CRUD:list_array.html.twig
                boolean:    SonataAdminBundle:CRUD:list_boolean.html.twig
                date:       SonataAdminBundle:CRUD:list_date.html.twig
                time:       SonataAdminBundle:CRUD:list_time.html.twig
                datetime:   SonataAdminBundle:CRUD:list_datetime.html.twig
                text:       SonataAdminBundle:CRUD:base_list_field.html.twig
                trans:      SonataAdminBundle:CRUD:list_trans.html.twig
                string:     SonataAdminBundle:CRUD:base_list_field.html.twig
                smallint:   SonataAdminBundle:CRUD:base_list_field.html.twig
                bigint:     SonataAdminBundle:CRUD:base_list_field.html.twig
                integer:    SonataAdminBundle:CRUD:base_list_field.html.twig
                decimal:    SonataAdminBundle:CRUD:base_list_field.html.twig
                identifier: SonataAdminBundle:CRUD:base_list_field.html.twig

            show:
                array:      SonataAdminBundle:CRUD:show_array.html.twig
                boolean:    SonataAdminBundle:CRUD:show_boolean.html.twig
                date:       SonataAdminBundle:CRUD:show_date.html.twig
                time:       SonataAdminBundle:CRUD:show_time.html.twig
                datetime:   SonataAdminBundle:CRUD:show_datetime.html.twig
                text:       SonataAdminBundle:CRUD:base_show_field.html.twig
                trans:      SonataAdminBundle:CRUD:show_trans.html.twig
                string:     SonataAdminBundle:CRUD:base_show_field.html.twig
                smallint:   SonataAdminBundle:CRUD:base_show_field.html.twig
                bigint:     SonataAdminBundle:CRUD:base_show_field.html.twig
                integer:    SonataAdminBundle:CRUD:base_show_field.html.twig
                decimal:    SonataAdminBundle:CRUD:base_show_field.html.twig

# Doctrine Configuration
doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        types:
            json: Sonata\Doctrine\Types\JsonType
        # if using pdo_sqlite as your database driver, add the path in parameters.yml
        # e.g. database_path: "%kernel.root_dir%/data/data.db3"
        # path:     "%database_path%"
    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        auto_mapping: true

fos_user:
    db_driver: orm
    firewall_name: main
    user_class: MyProject\UserBundle\Entity\User
    group:
        group_class:   MyProject\UserBundle\Entity\Group
        group_manager: sonata.user.orm.group_manager

    service:
        user_manager: sonata.user.orm.user_manager

and my routing.yml here :
    sonata_user_security:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_security_1.xml"

sonata_user_resetting:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_resetting_1.xml"
    prefix: /resetting

sonata_user_profile:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_profile_1.xml"
    prefix: /profile

sonata_user_register:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_registration_1.xml"
    prefix: /register

sonata_user_change_password:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_change_password_1.xml"
    prefix: /profile

sonata_user:
    resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml'
    prefix: /admin

admin:
    resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
    prefix: /admin

_sonata_admin:
    resource: .
    type: sonata_admin
    prefix: /admin

EDIT 1:
[router] Current routes
 Name                                     Method   Scheme Host Path
 _assetic_bootstrap_css                   ANY      ANY    ANY  /assetic/bootstrap_css.less
 _assetic_bootstrap_css_0                 ANY      ANY    ANY  /assetic/bootstrap_css_bootstrap_1.less
 _assetic_jquery                          ANY      ANY    ANY  /js/jquery.js
 _assetic_jquery_0                        ANY      ANY    ANY  /js/jquery_jquery-2.1.1_1.js
 _assetic_bootstrap_js                    ANY      ANY    ANY  /js/bootstrap.js
 _assetic_bootstrap_js_0                  ANY      ANY    ANY  /js/bootstrap_transition_1.js
 _assetic_bootstrap_js_1                  ANY      ANY    ANY  /js/bootstrap_alert_2.js
 _assetic_bootstrap_js_2                  ANY      ANY    ANY  /js/bootstrap_button_3.js
 _assetic_bootstrap_js_3                  ANY      ANY    ANY  /js/bootstrap_carousel_4.js
 _assetic_bootstrap_js_4                  ANY      ANY    ANY  /js/bootstrap_collapse_5.js
 _assetic_bootstrap_js_5                  ANY      ANY    ANY  /js/bootstrap_dropdown_6.js
 _assetic_bootstrap_js_6                  ANY      ANY    ANY  /js/bootstrap_modal_7.js
 _assetic_bootstrap_js_7                  ANY      ANY    ANY  /js/bootstrap_tooltip_8.js
 _assetic_bootstrap_js_8                  ANY      ANY    ANY  /js/bootstrap_popover_9.js
 _assetic_bootstrap_js_9                  ANY      ANY    ANY  /js/bootstrap_scrollspy_10.js
 _assetic_bootstrap_js_10                 ANY      ANY    ANY  /js/bootstrap_tab_11.js
 _assetic_bootstrap_js_11                 ANY      ANY    ANY  /js/bootstrap_affix_12.js
 _assetic_a56fa94                         ANY      ANY    ANY  /js/a56fa94.js
 _assetic_a56fa94_0                       ANY      ANY    ANY  /js/a56fa94_part_1.js
 _assetic_a56fa94_1                       ANY      ANY    ANY  /js/a56fa94_part_2.js
 _assetic_65cec74                         ANY      ANY    ANY  /css/65cec74.css
 _wdt                                     ANY      ANY    ANY  /_wdt/{token}
 _profiler_home                           ANY      ANY    ANY  /_profiler/
 _profiler_search                         ANY      ANY    ANY  /_profiler/search
 _profiler_search_bar                     ANY      ANY    ANY  /_profiler/search_bar
 _profiler_purge                          ANY      ANY    ANY  /_profiler/purge
 _profiler_info                           ANY      ANY    ANY  /_profiler/info/{about}
 _profiler_import                         ANY      ANY    ANY  /_profiler/import
 _profiler_export                         ANY      ANY    ANY  /_profiler/export/{token}.txt
 _profiler_phpinfo                        ANY      ANY    ANY  /_profiler/phpinfo
 _profiler_search_results                 ANY      ANY    ANY  /_profiler/{token}/search/results
 _profiler                                ANY      ANY    ANY  /_profiler/{token}
 _profiler_router                         ANY      ANY    ANY  /_profiler/{token}/router
 _profiler_exception                      ANY      ANY    ANY  /_profiler/{token}/exception
 _profiler_exception_css                  ANY      ANY    ANY  /_profiler/{token}/exception.css
 _configurator_home                       ANY      ANY    ANY  /_configurator/
 _configurator_step                       ANY      ANY    ANY  /_configurator/step/{index}
 _configurator_final                      ANY      ANY    ANY  /_configurator/final
 fos_user_security_login                  ANY      ANY    ANY  /login
 fos_user_security_check                  POST     ANY    ANY  /login_check
 fos_user_security_logout                 ANY      ANY    ANY  /logout
 sonata_user_security_login               ANY      ANY    ANY  /login
 sonata_user_security_check               POST     ANY    ANY  /login_check
 sonata_user_security_logout              ANY      ANY    ANY  /logout
 fos_user_resetting_request               GET      ANY    ANY  /resetting/request
 fos_user_resetting_send_email            POST     ANY    ANY  /resetting/send-email
 fos_user_resetting_check_email           GET      ANY    ANY  /resetting/check-email
 fos_user_resetting_reset                 GET|POST ANY    ANY  /resetting/reset/{token}
 sonata_user_resetting_request            GET      ANY    ANY  /resetting/request
 sonata_user_resetting_send_email         POST     ANY    ANY  /resetting/send-email
 sonata_user_resetting_check_email        GET      ANY    ANY  /resetting/check-email
 sonata_user_resetting_reset              GET|POST ANY    ANY  /resetting/reset/{token}
 fos_user_profile_show                    GET      ANY    ANY  /profile/
 fos_user_profile_edit_authentication     ANY      ANY    ANY  /profile/edit-authentication
 fos_user_profile_edit                    ANY      ANY    ANY  /profile/edit-profile
 sonata_user_profile_show                 GET      ANY    ANY  /profile/
 sonata_user_profile_edit_authentication  ANY      ANY    ANY  /profile/edit-authentication
 sonata_user_profile_edit                 ANY      ANY    ANY  /profile/edit-profile
 fos_user_registration_register           ANY      ANY    ANY  /register/
 fos_user_registration_check_email        GET      ANY    ANY  /register/check-email
 fos_user_registration_confirm            GET      ANY    ANY  /register/confirm/{token}
 fos_user_registration_confirmed          GET      ANY    ANY  /register/confirmed
 sonata_user_registration_register        ANY      ANY    ANY  /register/
 sonata_user_registration_check_email     GET      ANY    ANY  /register/check-email
 sonata_user_registration_confirm         GET      ANY    ANY  /register/confirm/{token}
 sonata_user_registration_confirmed       GET      ANY    ANY  /register/confirmed
 fos_user_change_password                 GET|POST ANY    ANY  /profile/change-password
 sonata_user_change_password              GET|POST ANY    ANY  /profile/change-password
 sonata_user_admin_security_login         ANY      ANY    ANY  /admin/login
 sonata_user_admin_security_check         ANY      ANY    ANY  /admin/login_check
 sonata_user_admin_security_logout        ANY      ANY    ANY  /admin/logout
 sonata_admin_redirect                    ANY      ANY    ANY  /admin/
 sonata_admin_dashboard                   ANY      ANY    ANY  /admin/dashboard
 sonata_admin_retrieve_form_element       ANY      ANY    ANY  /admin/core/get-form-field-element
 sonata_admin_append_form_element         ANY      ANY    ANY  /admin/core/append-form-field-element
 sonata_admin_short_object_information    ANY      ANY    ANY  /admin/core/get-short-object-description.{_format}
 sonata_admin_set_object_field_value      ANY      ANY    ANY  /admin/core/set-object-field-value
 sonata_admin_search                      ANY      ANY    ANY  /admin/search
 sonata_admin_retrieve_autocomplete_items ANY      ANY    ANY  /admin/core/get-autocomplete-items
 admin_sonata_user_user_list              ANY      ANY    ANY  /admin/sonata/user/user/list
 admin_sonata_user_user_create            ANY      ANY    ANY  /admin/sonata/user/user/create
 admin_sonata_user_user_batch             ANY      ANY    ANY  /admin/sonata/user/user/batch
 admin_sonata_user_user_edit              ANY      ANY    ANY  /admin/sonata/user/user/{id}/edit
 admin_sonata_user_user_delete            ANY      ANY    ANY  /admin/sonata/user/user/{id}/delete
 admin_sonata_user_user_show              ANY      ANY    ANY  /admin/sonata/user/user/{id}/show
 admin_sonata_user_user_export            ANY      ANY    ANY  /admin/sonata/user/user/export
 admin_sonata_user_group_list             ANY      ANY    ANY  /admin/sonata/user/group/list
 admin_sonata_user_group_create           ANY      ANY    ANY  /admin/sonata/user/group/create
 admin_sonata_user_group_batch            ANY      ANY    ANY  /admin/sonata/user/group/batch
 admin_sonata_user_group_edit             ANY      ANY    ANY  /admin/sonata/user/group/{id}/edit
 admin_sonata_user_group_delete           ANY      ANY    ANY  /admin/sonata/user/group/{id}/delete
 admin_sonata_user_group_show             ANY      ANY    ANY  /admin/sonata/user/group/{id}/show
 admin_sonata_user_group_export           ANY      ANY    ANY  /admin/sonata/user/group/export
 myproject_user_default_index            ANY      ANY    ANY  /hello/{name}
 myproject_comment_default_index         ANY      ANY    ANY  /hello/{name}
 myproject_provider_default_index        ANY      ANY    ANY  /hello/{name}
 myproject_provider_providersearch_index ANY      ANY    ANY  /ProviderSearch
 myproject_service_default_index         ANY      ANY    ANY  /hello/{name}
 myproject_geo_default_index             ANY      ANY    ANY  /hello/{name}
 myproject_schedule_default_index        ANY      ANY    ANY  /hello/{name}
 myproject_coupon_couponsearch_index     ANY      ANY    ANY  /couponSearch
 my_filter                                ANY      ANY    ANY  /filter/
 myproject_coupon_default_index          ANY      ANY    ANY  /coupon
 myproject_association_search            ANY      ANY    ANY  /associationSearch
 myproject_association_search_result     ANY      ANY    ANY  /associationSearch/result
 myproject_association_search_show       ANY      ANY    ANY  /association/{slug}
 myproject_contact                       ANY      ANY    ANY  /contact
 myproject_core_homepage                 ANY      ANY    ANY  /
 myproject_city_typeahead                ANY      ANY    ANY  /autocompleteCity
 myproject_assoName_typeahead            ANY      ANY    ANY  /autocompleteAssoName
 myproject_providerName_typeahead        ANY      ANY    ANY  /autocompleteProviderName
 myproject_core_static                   ANY      ANY    ANY  /{page}
 myproject_coupon                        ANY      ANY    ANY  /coupon
 myproject_coupon_search                 ANY      ANY    ANY  /couponSearch
 myproject_coupon_search_result          ANY      ANY    ANY  /couponSearch/result
 myproject_provider_search_show          ANY      ANY    ANY  /provider/{slug}
 fos_js_routing_js                        ANY      ANY    ANY  /js/routing.{_format}

A: Ok I finally got a dashboard by removing all in sonata_user like this :
sonata_user:
    security_acl:           true
    manager_type: orm

I try to get a Dashboard like in this documentation : http://sonata-project.org/bundles/user/2-2/doc/reference/user_dashboard.html without success.
I have a blank page now, I will do all dashboard on my own,I can't see other way...

A: You should copy paste the code from the inatallation documentation into config.yml (like me).
Remove the lines with sonata_customer and sonata_order.
profile:
    # Profile show page is a dashboard as in SonataAdminBundle
    dashboard:
        blocks:
            - { position: left, type: sonata.block.service.text, settings: { content: "
Welcome!
 This is a sample user profile dashboard, feel free to override it in the configuration! Want to make this text dynamic? For instance display the user's name? Create a dedicated block and edit the configuration!"} }
            - { position: left, type: sonata.order.block.recent_orders, settings: { title: Recent Orders, number: 5, mode: public }}
            - { position: right, type: sonata.timeline.block.timeline, settings: { max_per_page: 15 }}
            - { position: right, type: sonata.news.block.recent_posts, settings: { title: Recent Posts, number: 5, mode: public }}
            - { position: right, type: sonata.news.block.recent_comments, settings: { title: Recent Comments, number: 5, mode: public }}
    # Customize user portal menu by setting links
    menu:
        - { route: 'sonata_user_profile_show', label: 'sonata_profile_title', domain: 'SonataUserBundle'}
        - { route: 'sonata_user_profile_edit', label: 'link_edit_profile', domain: 'SonataUserBundle'}
        - { route: 'sonata_customer_addresses', label: 'link_list_addresses', domain: 'SonataCustomerBundle'}
        - { route: 'sonata_user_profile_edit_authentication', label: 'link_edit_authentication', domain: 'SonataUserBundle'}
        - { route: 'sonata_order_index', label: 'order_list', domain: 'SonataOrderBundle'}


text:
Q: How to match a minimum number of regex groups or assertions? OK regex nerds!
I am using regex lookahead assertions for password validation that is similar to the pattern described here:
\A(?=\w{6,10}\z)(?=[^a-z]*[a-z])(?=(?:[^A-Z]*[A-Z]){3})(?=\D*\d)

However, we want to only require that any 3 of the 4 assertions be valid - not necessarily all of them. Any thoughts on how this could be done?

A: To shorten any kind of pattern, factorize:
\A(?:
    (?=\w{6,10}\z) (?=.*[a-z]) (?: (?:.*[A-Z]){3} | .*\d )
   |
    (?=.*\d) (?=(?:.*[A-Z]){3}) (?: .*[a-z] | \w{6,10}\z )
)

Note that you don't need a lookahead to test the last condition.
demo

Other way, where each condition is optional and that uses a named group to count (.net only):
\A
(?<c>(?=\w{6,10}\z))?
(?<c>(?=[^a-z]*[a-z]))?
(?<c>(?=(?:[^A-Z]*[A-Z]){3}))?
(?<c>(?=\D*\d))?
(?<-c>){3} # decrement c 3 times
(?(c)|(?!$)) # conditional: force the pattern to fail if too few conditions succeed.

demo

A: There's no "easy" way to do this in a single regular expression. The only way would be to define all possible permutations of the "three out of four" assertions - e.g.
\A(?=\w{6,10}\z)(?=[^a-z]*[a-z])(?=(?:[^A-Z]*[A-Z]){3})| # Maybe no digit
\A(?=[^a-z]*[a-z])(?=(?:[^A-Z]*[A-Z]){3})(?=\D*\d)| # Maybe wrong length
\A(?=\w{6,10}\z)(?=(?:[^A-Z]*[A-Z]){3})(?=\D*\d)| # Maybe no lower
\A(?=\w{6,10}\z)(?=[^a-z]*[a-z])(?=\D*\d) # Maybe not enough uppers

However, this mind-melting regex is clearly not a good solution.
A better approach would be to perform the four checks separately (with regex or otherwise), and count that there is at least three passed conditions.
...However, let's take a step back here and ask: Why are you doing this?? You're implementing a password entropy check. Based on your fuzzy rules, the following passwords are valid:

*

*AAAa1

*password1

*LETmein

And the following passwords are invalid:

*

*reallylongsecurepassword8374235359232

*HorseBatteryStapleCorrect

I would strongly advise against such a bizarrely restrictive policy.

A: Brief
The easiest method would be to have separate regular expressions and check whether 3/4 of them are successful in your code's language. The only way to do this in regex is to present all cases. That being said, this is probably the easiest method (in regex) to present all options as it allows you to edit the patterns in one location (where they are defined) rather than multiple times (more prone to bugs). The DEFINE constructs in regex are seldom supported, but PCRE regex does.
You can also have your code generate each regex permutation. See this question about generating all permutations of a list in python
I don't know why you want to do this for passwords, it's considered malpractice, but, since you're asking for it, I figured I'd give you the easiest solution possible in regex... You really should only check minimum length (and complexity if you want [based on algorithms] to show the user how secure your system finds their password to be).

Code
(?(DEFINE)
   (?<w>(?=\w{6,10}\z))
   (?<l>(?=[^a-z]*[a-z]))
   (?<u>(?=(?:[^A-Z]*[A-Z]){3}))
   (?<d>(?=\D*\d))
)
\A(?:
    (?&w)(?&l)(?&u)|
    (?&w)(?&l)(?&d)|
    (?&w)(?&u)(?&d)|
    (?&l)(?&u)(?&d)
)

Note: The regex above uses the x modifier (ignore whitespace) so that we can nicely organize the content.


text:
Q: Possible meaning of "PR" abbreviation I already know that PR can mean Public Relations or Puerto Rico, but none of these definition works in my context. I was on github, and an author basically said :

If you like this plugin and want to say thanks please send a PR or donation. Both are equally appreciated!

(Source)
In this context, what does PR stand for ?

A: I would guess PR stands for "Pull Request" (you can see a tab for pull requests at the top of the page). That is, he'd like other people to try and contribute to his project.


text:
Q: How can you tell if a request came in via HTTP vs. HTTPS? in Visual Studio Using Visual Studio 2017, I'm building an ASP.NET Core site.
How can you tell, in the controller, if a web request came in via HTTP vs. HTTPS?

A: Use Request.IsHttps
public IActionResult Index()
{
    var isSecure = Request.IsHttps;

    // Do Something

    return View();
}

A: Request.IsSecureConnection will tell you if the request came over SSL.
If you are using .Net Core, the property name is Request.IsHttps.


text:
Q: Why are there so many copies of my Downloads directory in ~/Library? I was recently playing around with the command line utility fzf, when I discovered that direct copies of my downloads directory exist several times across the data in the apps after ~/Library/Containers. Is this intended behavior? If not, what can I do not make sure this doesn't happen and doesn't waste space. On top of this, why are all these arbitrary apps allowed access to all my personal data? This sincerely  worries me.
Thanks to all.
P.S. if there is any extra information you need, please feel free to ask.
EDIT: with more investigation, it appears it is not just my Downloads directory, but everything superseding my home directory; this makes the issue 10 times more important.
EDIT 2: after looking at it some more, it seems as if Desktop and Downloads are there as Symlinks, but why are all these apps allowed to access this data?

A: The purpose of ~/Library/Containers is to provide what amount to virtualized home directories for sandboxed applications. When a sandboxed application "asks for" the user's home directory (via NSHomeDirectory), it is given the path to its container directory. These features do not allow sandboxed apps to access the data in these directories, nor do they occupy (more than a trivial amount of) additional storage. (In fact, to the former point, this feature is designed to restrict apps' access to your data; to the latter, the "duplicate folders" are just symbolic links, which function as references back to the actual directories they represent.)
An application that is sandboxed may only read from and write to locations that are subdirectories of its own container. The symlinked folders in each Container (e.g., Downloads and Documents) are not accessible by default to sandboxed apps. Sandboxed apps can only access external file system locations if explicitly granted access to them through an NSOpenPanel or NSSavePanel (one of the pop-up dialogs that asks you to select a file to open or a location to which to save a file) via the Powerbox API (this is the model used by document-based applications—for instance, this lets you save and open documents that you edit with a sandboxed text editor in your Documents folder). In fact, apps that don't use App Sandbox (and thus don't have a container directory) can access virtually any file within your home directory (although there will be some further restrictions implemented in macOS Mojave), whereas those that do use App Sandbox (i.e., those that are given a container) cannot. Also, it's worth noting that all apps on the Mac App Store are required to use App Sandbox.
In summary: yes, those "replicated home folders" are supposed to be there—that is intended behavior; no, they are not consuming any meaningfully significant amount of extra disk space; and the feature that causes these folders to appear is actually preventing these apps from accessing your personal data, not enabling them to.
Further reading:

*

*Another Ask Different thread about ~/Library/Containers

*Apple's developer documentation about app sandboxing and pseudo-home directories


text:
Q: Show that the largest rectangle with a perimeter of $20$ meters is a square. Show that the largest rectangle with a perimeter of $20$ meters is a square.

A: Hint: You know that $2W+2H=20$. Use that to compute the maximum of $W\cdot H$.

A: To expand on the other answers, I posted a solution below that is hidden. Simply hover your mouse over it to check your work.

As Andrew noted, the perimeter is given by $2h+2w = 20$ where $h$ is the height and $w$ is the width of the rectangle. Dividing through by $2$ gives us $h + w = 10$.  Rewriting $h + w = 10$ as $w = 10 - h$, we can plug that expression for $w$ into our area formula. So, we are left with $h\cdot{w} = h(10-h) = 10h-h^2$. Now, since we are trying to maximize this, we want to take the derivative and set it equal to $0$ (finding critical points - an essential tool in introductory calculus courses.) So, the derivative would be $10 - 2h$. Setting that equal to $0$ and solving for $h$ leaves us $h = 5$. Plugging in $h = 5$ into our expression $h + w = 10$ tells us that the width must also be $5$ meters. So, since the height and width are both $5$ meters, the largest rectangle with a perimeter of $20$ meters is indeed a square.

A: And you can avoid taking the derivative
by writing
$$10 w - w^2 = 25 - 25 + 10 w - w^2
= 25 - (25 -10w + w^2)
= 25 - (5-w)^2
\le 25
$$
with equality if and only if
$w = 5$.
This also works for any value, not just $20$.

A: The short and long sides of the rectangle have lengths $5-x$ and $5+x$ respectively, for some $x$ between $0$ and $5.$ The area is $A=(5-x)(5+x)=25-x^2.$ So how should you pick $x$ to make the area the largest?

A: Perimeter $P=2h+2w=20$.  So $h+w=10 \implies h=10-w$
$hw=w(10-w)=10w-w^2$
Find the maximum of this function by setting the derivative equal to 0 and solving for $w$.


text:
Q: JQuery slider breaks on second click of thumbnail I have an ongoing problem with a video slider panel (using stacked iframes and z-index), which breaks when a thumbnail is clicked the second time.  I have searched high and low for a solution but am stuck; everything I've tried has not worked.
The live website is http://www.nishasamuel.com.  When you click on a thumbnail, you are scrolled to the top of the page and the new video fades in over the top, using z-index. That's fine, but if you click on the currently selected thumbnail a second time it breaks in the main panel at the top.
So the best idea I've come up with, but am struggling to implement correctly, is to flag the thumbnail with a 'current' class as soon as it's been clicked. Then if it's clicked again an if statement in the JQuery function can prevent the function from running again, thus circumventing the problem. But how to do this? I think I'm close with the lines that are commented out below but I'm not quite there, struggling with how reactivate the click functionality on the selected thumbnail when another one is cliked. It's likely to simply be my lack of JQuery expertise. I really have tried :-/
Here's the JQuery code:

...and the relevant excerpt of the HTML (feel free to check the source at the above link if needed):

Motion Graphics

Motion Graphics Showreel

Highlights of exciting motion graphics projects and animation work I have been involved in.

VFX

St. Mungo’s TV Advert

St. Mungo's Christmas TV Ad "When You've Lost Everything"

Motion Graphics

Doctor Care Anywhere

A video animation for a new online medical service. I received this video from my client which I had to revise the characters in the animation and create and replace a section seamlessly to make the animation more relevant to their business.

Motion Graphics

Motion Graphics Showreel

VFX

St. Mungo’s TV Advert

Motion Graphics

Doctor Care Anywhere

Hoping someone can help - I know there are lots of JQuery experts out there :-)
Thanks

A: Solved, finally. It simply took a well-placed 'if not...' check that the current thumbnail wasn't already selected (ie had the 'selected' class) before running the function's z-index switching:
if (!$targetItem.hasClass('selected')) {...}

The full function is now:
    function selectWsImage(controlElement, fadeSpeed) { // find this thumbnail's image and display it in the content panel
        var targetId = controlElement.attr('data-toggle');
        var $selectedItem = $('#video_gallery_panel li.selected');
        var $targetItem = $(targetId);
            if (!$targetItem.hasClass('selected')) {
                $selectedItem.removeClass('selected').css('z-index', 2);
                $targetItem.addClass('selected').hide().css('z-index', 3).fadeIn(fadeSpeed, function() {
                    $selectedItem.css('z-index', 1);
                    });
            }
        }
        wsGalleryFadeInterval = 1000;
        $(document).ready(function(){
            $('#homepage_top_right_panel a').click( function(event) {
                $("html, body").animate({ scrollTop: "180px" });
                event.preventDefault();
                selectWsImage($(this), wsGalleryFadeInterval);
            });
        })

Hope this saves someone with the same issue a few headaches in the future.


text:
Q: Tensorflow error running retrain.py in colab.research.google.com Any help on what this means. I got code from tensorflow for poets and it seemed to train but right near the end it fails with a non descriptive error running
retrain.py.  I am running this in cloud on the google colaboratory.
Final test accuracy = 90.7% (N=353)
INFO:tensorflow:Froze 2 variables.
Converted 2 variables to const ops.
An exception has occurred, use %tb to see the full traceback.
SystemExit
/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py:2890: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
  warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)

A: Final test accuracy = 90.7% (N=353) INFO:tensorflow:Froze 2 variables. Converted 2 variables to const ops.
This means that the model has been tested, and successfully saved to a frozen graph, ready to be served.
UserWarning: To exit: use 'exit', 'quit', or Ctrl-D. warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
Is not an error, it's a warning, so no big deal. It's not even tensorflow related. What really caused that warning to happen is beyond me, maybe this can help:
https://github.com/spyder-ide/spyder/issues/4639
What the error when I close the dialog


text:
Q: Explain regsub invocations regsub -all "\\\\033" $cmd "\033" cmd
[regsub -all "\\\\c" $cmd "" cmd]
regsub -all "\\\\$i" $cmd [lindex $exp_out $i] cmd

Can someone explain meaning of these three statements?
They are three different statements.

A:
regsub -all "\\\\033" $cmd "\033" cmd

This replaces all instances of a backslash followed by 033 with the ASCII ESC character. It reads the string to process from the cmd variable and writes it back to that variable.

[regsub -all "\\\\c" $cmd "" cmd]

This replaces all instances of a backslash followed by c with the empty string (effectively deleting it). It updates the cmd variable. It substitutes into its calling context the number of substitutions performed.

regsub -all "\\\\$i" $cmd [lindex $exp_out $i] cmd

This one's a bit more complex. For a particular numeric index, stored in the i variable, it replaces all instances of a backslash followed by the index with the i'th element (counting from 0) of the list in exp_out. It updates the cmd variable.


text:
Q: How to create a controller to create a text file after hitting submit? I need to create a controller starting from this view to create a text file to save locally after pressing the submit button, please someone help me.
If you can also explain the process, it will help me learn better as I am a beginner.
Thanks in advance
View
@model WebApplication3.Models.Contact

@{
    ViewBag.Title = "Contact";
}

        <!DOCTYPE html>

            <meta name="viewport" content="width=device-width" />
            <title>Contatto</title>

            @using (Html.BeginForm("Index", "Home", FormMethod.Post))
            {

                        Contattaci

                        Nome:

                            @Html.TextBoxFor(m => m.Nome)

                        Cognome:

                            @Html.TextBoxFor(m => m.Cognome)

                        Email:

                            @Html.TextBoxFor(m => m.Email)

                        Messaggio:

                            @Html.TextBoxFor(m => m.Messaggio)

                        <input type="submit" value="Submit" />

            }


text:
Q: Presto - Concat multiple tables using unique identifier I have multiple tables in the following format:
table users -
ID lang
1  EN
2  EN
3  DE

table A -
ID event1 event2
1  5      1
2  null   1
3  11     null

table B -
ID event1 event10
1  2      1
3  2     null

so after concat/join the tables on ID column my final table would look like this:
final_table -
ID lang A_event1 A_event2 B_event1 B_event10
1  EN   5        1        2        1
2  EN   null     1        null     null
3  DE   11       null     2        null

So I have multiple issues here, first how to properly do the joins so that aliases would match table names and have final unique column names even though the events have same naming inside the columns, and also I would like all the missing values would also have null values (like table B that does not have user ID = 2).
My tries so far were not successful as the column names would be duplicated without unique IDs and missing values were not filled with nulls properly.
example for what I already tried:
select t1.*, t2.*, t3.*
from users t1
left join
A t2
using (ID)
left join
B t3
using (ID)

I can construct the query programmatically to provide flexability, but I would like to know the proper syntax for such case.
Thanks.

A: Your attempt with two left joins looks quite good. I would, however suggest not using the using(id) syntax to join the tables: with 3 tables involved, it is ambiguous to which id column you are referring, which could lead to missing records in the resultset:
select
    u.id,
    u.lang,
    ta.event1 A_event1,
    ta.event2 A_event2,
    tb.event1 B_event1,
    tb.event110 B_event10
from users u
left join tableA ta on ta.id = u.id
left join tableB tb on tb.id = u.id

I don't see how this query would generate duplicate ids in the resultset (as long as the ids are unique in each table, as shown in your sample data).

A: If the non-id columns in the tables were unique, then you could express this as:
select *
from users u left join
     A
     using (ID) left join
     B
     using (ID);

The id means the same thing in the three tables, so it is appropriate to use using.  In fact, using is very handy when working with outer joins (although more so with full join).
I'm not a big fan of using select *.  And it is not appropriate in this case because the columns are not unique.  So a fine way to write the query is:
select u.*,
       a.event1 as a_event1, a.event2 as a_event2,
       b.event1 as b_event1, b.event10 as b_event10
from users u left join
     A
     using (ID) left join
     B
     using (ID);


text:
Q: How I find $\beta$ for to do this function continuous? My function is: $f(x) = x^3 $ if $0\leq x \leq 1 $ or $x^2-\beta x+ \beta$ if $1 < x \leq 2$ .
My answer:
For this function to be continuous the $\lim_{x\to1^+} x^2 - \beta x + \beta = \lim_{x\to1^-} x^3$, when a apply the limit I have this:
\begin{align}
\lim_{x\to1^+} x^2 - \beta x + \beta = 1 - \beta +\beta\\
\end{align}
\begin{align}
\lim_{x\to1^-} x^3 = 1
\end{align}
I want a value for $\beta$ but he is canceling there.

A: I see nothing wrong. Your function is continuous for all $\beta\in\mathbb{R}$.

Now, if you're interested in which $\beta$, if any, that will make $f$ differentiable on $(0,1)$, then you just repeat the analysis but with the difference ratio.
Note:
$$
\lim_{h\downarrow 0}\frac{f(1+h)-f(1)}{h}=\lim_{h\downarrow 0}\frac{(1+h)^2-\beta(1+h)+\beta-1}{h}=\lim_{h\downarrow 0}(2+h-\beta)=2-\beta,
$$
and
$$
\lim_{h\uparrow 0}\frac{f(1+h)-f(1)}{h}=\lim_{h\uparrow 0}\frac{(1+h)^3-1}{h}=3.
$$
What can $\beta$ be? In the end, your $f$ should look something like this:

A: A function $f$ is called continuous in $x=1$ if $\lim\limits_{x\uparrow1}f(x)=\lim\limits_{\downarrow1}f(x)=f(1)$. By your definition of $f$, it follows easily that $f(1)=1^3=\lim\limits_{x\uparrow1}f(x)$ and that for all $\beta\in\mathbb{C}$, it follows that $\lim\limits_{x\downarrow1}f(x)=1$, so $f$ is continuous in $x=1$ for all values of $\beta$.


text:
Q: How many usb devices can I connect to a server? How many USB devices can I connect to a windows 2000, 2003 and 2008 server machine?

A: Many. Practically unlimited if the devices have their own power, though it will depend on your controllers and hubs.
IIRC the USB standard allows 127 devices (with hubs counting as devices too) on each controller, directly or indirectly, but many motherboard chipsets effectively have more than one controller and you can add more via add-on cards.
Some cheap hubs will not cope well with that many devices connected through them though.
The other limit is devices without their own power: each port should deliver 2.5W (0.5A max at 5V). This can be mitigated using powered hubs or devices with their own power supply.

A: u can install USB switch/hub to u r server which have self power and it usb hub come in 24port 48port which i have use already i dont if any product there which has more port..

A: If it is USB Drives, your going to run into mounting issues once your available drives hit Z:.  Ones beyond that will not auto-mount and will require you to go through the computer management drive manager snap in to juggle the various USB devices (or un-map any network drive mappings).
The largest limiting factor will be power.  From my experience, chaining powered hubs doesn't work very well, so your other limit would be the maximum hub slots you could purchase x the number of available usb ports on your server.


text: Q: Debian/Raspbian - Send Email "back in time" For the sake of entertainment i am looking for a way so send an email "back in time". With that i mean sending & receiving an email with a timestamp from the past. For that purpose i am running 2 Postfix&Dovecot-Email-Servers on Raspbian & Debian. Those are the two i want to use for my magical trick, by sending the mail to each other. I tried changing the time on the server A, so that it sends the mail with a timestamp from the past. Of course i get a connection timeout (makes sense why) when trying to send it. Any other ideas? Or how can i fix the problem?