text:
Q: Show routes between multiple points on Google Maps I've created my own custom map to show my current location and multiple points on map. it works fine,but now i would like to show a route from my current location to every point on the map.Can you give me some suggestions how i can do that? thx.
this is my customMap activity:
public class CustomMapActivity extends MapActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);

         String   provider = "";
         Criteria crit = new Criteria();
         Location loc = new Location("");
         LocationManager mlocManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

         MapView mapView = (MapView) findViewById(R.id.mapview);
         mapView.setBuiltInZoomControls(true);

         List<Overlay> mapOverlays = mapView.getOverlays();
         Drawable drawable = this.getResources().getDrawable(R.drawable.marker);
         ItemizedOverlayedClass itemizedoverlay = new ItemizedOverlayedClass(drawable, this);

            try
            {
             MyLocationOverlay mylocationOverlay = new MyLocationOverlay(this, mapView);
             mylocationOverlay.enableMyLocation();
             mapView.getOverlays().add(mylocationOverlay);
             provider = mlocManager.getBestProvider(crit, false);
             loc = mlocManager.getLastKnownLocation(provider);
            }
            catch(Exception ex)
            {
            //Toast.makeText(this, "Unable to retrive provider", Toast.LENGTH_LONG).show();
            }

        for (ServiceActivity activity : DataSources.ActivitiesList)
        {
            try
            {
                Location siteLocation =  new Location("");
                siteLocation.setLatitude(activity.SiteLatitude);
                siteLocation.setLongitude(activity.SiteLongitude);

                GeoPoint point = new GeoPoint((int)(activity.SiteLatitude * 1e6),(int)(activity.SiteLongitude * 1e6));
                OverlayItem overlayitem = new OverlayItem(point, activity.SiteName+ " " + activity.SiteAddress, "Distance to this location: " + String.valueOf(loc.distanceTo(siteLocation)/1000) + " km");

                itemizedoverlay.addOverlay(overlayitem);
                mapOverlays.add(itemizedoverlay);
            }
            catch(Exception ex)
            {
                @SuppressWarnings("unused")
                AlertDialogClass alert =  new AlertDialogClass(this,ex.getMessage());
            }
        }

    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        //mylocationOverlay.enableMyLocation();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_map, menu);
        return true;
    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }

}

and this is the overlay class:
package com.example.srwebservice;

import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class ItemizedOverlayedClass extends ItemizedOverlay {

    private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
    Context mContext;

    public ItemizedOverlayedClass(Drawable defaultMarker)
    {
        super(boundCenterBottom(defaultMarker));
        // TODO Auto-generated constructor stub
    }

    public ItemizedOverlayedClass(Drawable defaultMarker, Context context)
    {
      super(boundCenterBottom(defaultMarker));
      mContext = context;
    }

    @Override
    protected OverlayItem createItem(int i)
    {
        // TODO Auto-generated method stub
         return mOverlays.get(i);
    }

    @Override
    public int size()
    {
      return mOverlays.size();
    }

    public void addOverlay(OverlayItem overlay)
    {
        mOverlays.add(overlay);
        populate();
    }
    @Override
    protected boolean onTap(int index) {
      OverlayItem item = mOverlays.get(index);
      AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
      dialog.setTitle(item.getTitle());
      dialog.setMessage(item.getSnippet());
      dialog.show();
      return true;
    }
}

A: This link have tutorial to draw route path on map in our app. this may help you and
use below to link with map app... this will take to you in google map application
String uri = "http://maps.google.com/maps?f=d&hl=en&saddr="+source_latitude+","+source_longitude+"&daddr="+destination_latitude+","+destination_longitude;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);

OR
refter this link how to display the driving routes

A: i found a simpler solution.I can use google maps intent directly, and i don't need to create a custom map activity anymore:
if(DataSources.ActivitiesList.length >0)
{
  String address = "http://maps.google.com/maps?daddr=" +    DataSources.ActivitiesList[0].SiteLatitude.toString() + "," + DataSources.ActivitiesList[0].SiteLongitude.toString();
for (int i= 1 ;i <  DataSources.ActivitiesList.length ; i++)
{
    if(DataSources.ActivitiesList[i].SiteLatitude != null)
        address += "+to:" + DataSources.ActivitiesList[i].SiteLatitude + "," + DataSources.ActivitiesList[i].SiteLongitude;
}
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(address));
    startActivity(intent);
    break;
}


text:
Q: IE doesn't mark anchor links as visited correctly I am using in the CSS a:visited to mark visited links differently.
The links I am using are anchor links, in the form of #news33.
After clicking, the links are marked in IE with the correct color, but on reloading the page, the color is missing. This works perfectly fine with Chrome. Does anyone has an idea on what I should do?
Btw, I am using IE 10 on Windows 8.
I am posting some example code, where the problem can be seen in IE, which I adapted from the example of Twitter Bootstrap.

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

Launch demo modal
Launch demo modal 22

    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>

Modal header

One fine body…

    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    <button class="btn btn-primary">Save changes</button>

One important  thing to notice is that the link is used to display a modal, and the modal JS library is not following the link.
Thanks and best regards
Theo

A: The CSS order matters with some browsers. I know with older versions of IE if you don't have the order of the rules correct the properties will not display as expected. I would hope IE10 would not still have this issue.
a:link {color:#FF0000;}         /* unvisited link */
a:visited {color:#00FF00;}      /* visited link */
a:hover {color:#FF00FF;}        /* mouse over link */
a:active {color:#0000FF;}       /* selected link */

http://www.w3schools.com/css/css_pseudo_classes.asp

redpajama_set_name: RedPajamaStackExchange


text:
Q: Can't create thread because "Takes 1 positional argument but 4 given" only when I give it a string longer than 1 I am making a chat server in python. I have been creating threads fine so far, but when I try to create one, with the argument of a username, it fails with the above error - but only when the username is more than 1 character.
If I give it the username "A", it works fine, but the username "Alex" gives the error. How do I fix this?
They are in the same class.
I create the thread with
Thread(target=Main.ManageClientHighLevel, args=(Username)).start()
And the start of that function is:
def ManageClientHighLevel(Username):
How do I fix this?

A: Thread's args argument expects an Iterable, so you will have to provide your single argument in a tuple:
Thread(target=Main.ManageClientHighLevel, args=(Username,)).start()

Otherwise, it will handle your single provided string as an Iterable and iterate over each character.

A: You must convert Username to a tuple: (Username,) since a string is an interable, which means that "username" would actually be considered as "(u,s,e,r,n,a,m,e)".


text:
Q: Python script having issues setting up a tmp folder Trying to run a Python script (downloaded from a university site) and keep getting an error where it aparrently fails to set up a temporary directory. I'm running this under Windows 10 and have tried Python 2.6 and 2.7. Whenever I run the code, I get this error:
Traceback (most recent call last):
  File "Calign.py", line 116, in <module>
    tmpbase = '/tmp/' + os.environ['USER'] + '_' + str(os.getpid())
  File "C:\Python27\lib\os.py", line 425, in __getitem__
    return self.data[key.upper()]
KeyError: 'USER

It seems that there is error in the "Calign" Python script. Initially I thought that it was just flipping the slashes (using / where Windows uses \ in a path), but that fix just generated more errors. Ultimately any attempts to fix the script did not work -- my Python is not sufficient and I'm not sure what the script is doing.
I did a verbose run of the python script if that will help:
ente# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# C:\Python26\lib\site.pyc matches C:\Python26\lib\site.py
import site # precompiled from C:\Python26\lib\site.pyc
# C:\Python26\lib\os.pyc matches C:\Python26\lib\os.py
import os # precompiled from C:\Python26\lib\os.pyc
import errno # builtin
import nt # builtin
# C:\Python26\lib\ntpath.pyc matches C:\Python26\lib\ntpath.py
import ntpath # precompiled from C:\Python26\lib\ntpath.pyc
# C:\Python26\lib\stat.pyc matches C:\Python26\lib\stat.py
import stat # precompiled from C:\Python26\lib\stat.pyc
# C:\Python26\lib\genericpath.pyc matches C:\Python26\lib\genericpath.py
import genericpath # precompiled from C:\Python26\lib\genericpath.pyc
# C:\Python26\lib\warnings.pyc matches C:\Python26\lib\warnings.py
import warnings # precompiled from C:\Python26\lib\warnings.pyc
# C:\Python26\lib\linecache.pyc matches C:\Python26\lib\linecache.py
import linecache # precompiled from C:\Python26\lib\linecache.pyc
# C:\Python26\lib\types.pyc matches C:\Python26\lib\types.py
import types # precompiled from C:\Python26\lib\types.pyc
# C:\Python26\lib\UserDict.pyc matches C:\Python26\lib\UserDict.py
import UserDict # precompiled from C:\Python26\lib\UserDict.pyc
# C:\Python26\lib\_abcoll.pyc matches C:\Python26\lib\_abcoll.py
import _abcoll # precompiled from C:\Python26\lib\_abcoll.pyc
# C:\Python26\lib\abc.pyc matches C:\Python26\lib\abc.py
import abc # precompiled from C:\Python26\lib\abc.pyc
# C:\Python26\lib\copy_reg.pyc matches C:\Python26\lib\copy_reg.py
import copy_reg # precompiled from C:\Python26\lib\copy_reg.pyc
# C:\Python26\lib\locale.pyc matches C:\Python26\lib\locale.py
import locale # precompiled from C:\Python26\lib\locale.pyc
import encodings # directory C:\Python26\lib\encodings
# C:\Python26\lib\encodings\__init__.pyc matches C:\Python26\lib\encodings\__init__.py
import encodings # precompiled from C:\Python26\lib\encodings\__init__.pyc
# C:\Python26\lib\codecs.pyc matches C:\Python26\lib\codecs.py
import codecs # precompiled from C:\Python26\lib\codecs.pyc
import _codecs # builtin
# C:\Python26\lib\encodings\aliases.pyc matches C:\Python26\lib\encodings\aliases.py
import encodings.aliases # precompiled from C:\Python26\lib\encodings\aliases.pyc
# C:\Python26\lib\functools.pyc matches C:\Python26\lib\functools.py
import functools # precompiled from C:\Python26\lib\functools.pyc
import _functools # builtin
import _locale # builtin
# C:\Python26\lib\re.pyc matches C:\Python26\lib\re.py
import re # precompiled from C:\Python26\lib\re.pyc
# C:\Python26\lib\sre_compile.pyc matches C:\Python26\lib\sre_compile.py
import sre_compile # precompiled from C:\Python26\lib\sre_compile.pyc
import _sre # builtin
# C:\Python26\lib\sre_parse.pyc matches C:\Python26\lib\sre_parse.py
import sre_parse # precompiled from C:\Python26\lib\sre_parse.pyc
# C:\Python26\lib\sre_constants.pyc matches C:\Python26\lib\sre_constants.py
import sre_constants # precompiled from C:\Python26\lib\sre_constants.pyc
import operator # builtin
# C:\Python26\lib\encodings\cp1252.pyc matches C:\Python26\lib\encodings\cp1252.py
import encodings.cp1252 # precompiled from C:\Python26\lib\encodings\cp1252.pyc
Python 2.6 (r26:66721, Oct  2 2008, 11:06:43) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
# C:\Python26\lib\getopt.pyc matches C:\Python26\lib\getopt.py
import getopt # precompiled from C:\Python26\lib\getopt.pyc
# C:\Python26\lib\wave.pyc matches C:\Python26\lib\wave.py
import wave # precompiled from C:\Python26\lib\wave.pyc
# C:\Python26\lib\struct.pyc matches C:\Python26\lib\struct.py
import struct # precompiled from C:\Python26\lib\struct.pyc
import _struct # builtin
# C:\Python26\lib\chunk.pyc matches C:\Python26\lib\chunk.py
import chunk # precompiled from C:\Python26\lib\chunk.pyc
# C:\Python26\lib\io.pyc matches C:\Python26\lib\io.py
import io # precompiled from C:\Python26\lib\io.pyc
# C:\Python26\lib\__future__.pyc matches C:\Python26\lib\__future__.py
import __future__ # precompiled from C:\Python26\lib\__future__.pyc
import _fileio # builtin
# C:\Python26\lib\threading.pyc matches C:\Python26\lib\threading.py
import threading # precompiled from C:\Python26\lib\threading.pyc
import thread # builtin
import time # builtin
# C:\Python26\lib\traceback.pyc matches C:\Python26\lib\traceback.py
import traceback # precompiled from C:\Python26\lib\traceback.pyc
# C:\Python26\lib\collections.pyc matches C:\Python26\lib\collections.py
import collections # precompiled from C:\Python26\lib\collections.pyc
import _collections # builtin
# C:\Python26\lib\keyword.pyc matches C:\Python26\lib\keyword.py
import keyword # precompiled from C:\Python26\lib\keyword.pyc
import _bytesio # builtin
Traceback (most recent call last):
  File "Calign.py", line 116, in <module>
    tmpbase = '/tmp/' + os.environ['USER'] + '_' + str(os.getpid())
  File "C:\Python26\lib\os.py", line 423, in __getitem__
    return self.data[key.upper()]
KeyError: 'USER'
# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# clear sys.flags
# clear sys.float_info
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] __future__
# cleanup[1] chunk
# cleanup[1] locale
# cleanup[1] functools
# cleanup[1] encodings
# cleanup[1] site
# cleanup[1] operator
# cleanup[1] io
# cleanup[1] abc
# cleanup[1] threading
# cleanup[1] sre_constants
# cleanup[1] re
# cleanup[1] collections
# cleanup[1] _codecs
# cleanup[1] getopt
# cleanup[1] nt
# cleanup[1] _warnings
# cleanup[1] zipimport
# cleanup[1] encodings.cp1252
# cleanup[1] _collections
# cleanup[1] codecs
# cleanup[1] _bytesio
# cleanup[1] wave
# cleanup[1] _struct
# cleanup[1] _functools
# cleanup[1] _locale
# cleanup[1] keyword
# cleanup[1] thread
# cleanup[1] signal
# cleanup[1] traceback
# cleanup[1] encodings.aliases
# cleanup[1] time
# cleanup[1] exceptions
# cleanup[1] _fileio
# cleanup[1] sre_compile
# cleanup[1] _sre
# cleanup[1] struct
# cleanup[1] sre_parse
# cleanup[2] copy_reg
# cleanup[2] types
# cleanup[2] errno
# cleanup[2] _abcoll
# cleanup[2] ntpath
# cleanup[2] genericpath
# cleanup[2] stat
# cleanup[2] warnings
# cleanup[2] UserDict
# cleanup[2] os.path
# cleanup[2] linecache
# cleanup[2] os
# cleanup sys
# cleanup __builtin__
# cleanup ints: 26 unfreed ints
# cleanup floats: 2 unfreed floatsr code here


text:
Q: How to link UWP Class Library into an WPF Application? How to link UWP Class Library into an WPF Application?
I have created an UWP Class Library with a single test class. I have an WPF .NET application which wants to consume that class library. What are the steps I need to follow?
Following this tutorial, I wanted to add library MyLib in my Application MyApp. But I am finding following compiler errors,

Severity  Code    Description Project File    Line    Suppression State
Error NU1201  Project MyLib is not compatible with netcoreapp3.1
(.NETCoreApp,Version=v3.1). Project MyLib supports:
uap10.0.19041 (UAP,Version=v10.0.19041)   MyApp C:\Users....\MyApp.csproj

##UPDATE
After adding following code,
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5.0-windows</TargetFramework>
    <AssetTargetFallback>uap10.0.19041</AssetTargetFallback>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\MyLib\MyLib.csproj" />
  </ItemGroup>

</Project>

as suggested by TamBui in the answer, I am getting build error. However there have been two compiler warnings from the beginning. Sharing if it can give any clue,

*

*Warning    NETSDK1137  It is no longer necessary to use the
Microsoft.NET.Sdk.WindowsDesktop SDK. Consider changing the Sdk
attribute of the root Project element to
'Microsoft.NET.Sdk'.  MyApp   C:\Program Files\dotnet\sdk\5.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets   376

*Warning    MSB3270 There was a mismatch between the processor
architecture of the project being built "MSIL" and the processor
architecture of the reference
"C:\Users...\MyLib\bin\x64\Debug\MyLib.dll",
"AMD64". This mismatch may cause runtime failures. Please consider
changing the targeted processor architecture of your project through
the Configuration Manager so as to align the processor architectures
between your project and references, or take a dependency on
references with a processor architecture that matches the targeted
processor architecture of your project.   MyApp   C:\Program Files
(x86)\Microsoft Visual
Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets  2123

A: You need to add the AssetTargetFallback that matches your UWP project's target version to your WPF project's PropertyGroup.  Select your WPF project in the Solution Explorer, and you will be able to edit the project's properties.
<PropertyGroup>
  <OutputType>WinExe</OutputType>
  <TargetFramework>netcoreapp3.1</TargetFramework>
  <RootNamespace>_68824006</RootNamespace>
  <AssetTargetFallback>uap10.0.19041</AssetTargetFallback>
  <UseWPF>true</UseWPF>
</PropertyGroup>

A: A WPF application cannot reference a UWP class library. In short, the two different platforms or frameworks are not compatible with each other.
You should change the target framework of your class library (MyLib.csproj) to either .NET Standard or the same framework that your WPF app targets:
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

</Project>


text:
Q: Finding a specific partitioning of a finite ordered set of positive integers. Definition of partitioning
Let $S$ be a finite ordered set of positive integers.
$$S = \{s_i \mid s_i \in \Bbb{Z}^+\}$$
E.g. $S = \{4, 7, 9, 8, 3, 2, 5\}$
Given this set $S$, we define $P$ as a partition of set $S$ such that:

*

*$P = \{p_1, p_2, p_3, \ldots, p_k\}$.

*$p_j$ (for some $j$) is either a singleton set or if $s_l, s_m \in p_j $ and if $l < m$, then $s_i \in p_j\ \forall i \in (l,m)$.

*Given $p_j = \{s_i \mid l\leq i\leq m\}$, we define function $f^-$ on $p_j$ as
$$f^-(p_j) =
\begin{cases}
s_i,  & \text{if $p_j$ is a singleton} \\
\sum_{i=l}^{m-1} |s_{i+1} - s_i|, & \text{otherwise}
\end{cases}$$
Problem
Given a set $S$, find a $P$ such that,

*

*$\sum f^-(p_j), \forall p_j \in P$ is minimized and,

*$\max(|p_j|), \forall p_j \in P$ is minimized (where $|p_i|$ represents the cardinality of set $p_j$)
Example:
Let $S = \{1, 2, 8\}$, one partitioning of this set could be $P = \{\{1\}, \{2, 8\}\}$. You can verify easily that $P$ is passing the two constraints defined above.


text:
Q: Why is xterm installed when trying to uninstall gnome-terminal? I use Alacritty as my main terminal emulator. I tried to uninstall the gnome-terminal package, but when I type apt remove gnome-terminal, it says:
The following additional packages will be installed:
libutempter0 xterm

And proceeds to install the packages.
What does gnome-terminal or xterm do that is necessary, that Alacritty does not?

A: That's because of dependencies. On a standard Ubuntu installation, the Ubuntu Desktop depends on X.Org which further depends on either GNOME terminal or XTerm or X term emulator which is basically a virtual package.
If you run
aptitude why gnome-terminal

the output will be
i   ubuntu-desktop Depends xorg
i A xorg           Depends gnome-terminal | xterm | x-terminal-emulator

Here i means package is installed, A is automatic and | is OR.
Arguably a terminal shouldn't be a dependency of display server such as X.Org.  This has been already reported on launchpad as Bug #1116791 in 2013.
According to Comment #7 by Bryce Harrington:

For the xorg source package it looks like the dependency was added long ago just as a convenience to ensure a terminal program was included. Possibly there might be a debian failsafe session that pops it up, but I'm not spotting evidence of such; in any case that wouldn't be important to us.

Moreover, as per Oliver Grawert's comment #8:

i guess at least using x-terminal-emulator as the dep would help so it is enough to have only one terminal installed

Bryce Harrington later changed the status of the bug to triaged stating

Perhaps that's a good thing to experiment with in S? I'm reticent to drop it from raring given how late in the game we are, since we don't know exactly what that'd break...

And then it's status was never updated. However in May 2019, Daniel van Vugt changed the status to won't fix just because 13.04 reached EOL in 2014. I believe that wasn't specific to the release version any way.
On the other hand, as pointed out by Jörg W Mittag in their comment, Alacritty should also provide X term emulator. But Alacritty isn't maintained and provided by Ubuntu, so I'm not sure if it is a bug or intended to work like that. As of now, according to x-terminal-emulator - Ubuntu Packages, x-terminal-emulator virtual package is provided by 22 packages.


text:
Q: Exclude generic function at runtime using PropertyInfo lI have the following function:
private static Expression<Func<TEntity, TValue>> BuildLambda<TEntity, TValue>(string property) where TEntity : class
        {
            var param = Expression.Parameter(typeof (TEntity), "e");
            var prop = Expression.PropertyOrField(param, property);
            return Expression.Lambda<Func<TEntity, TValue>>(prop, param);
        }

I am playing around with reflections:
How can exclude this function at runtime with a dynamic TEntity and TValue. Is it even possible?
Example:
public static void ValidateEntity<TEntity>(AbstractValidator<TEntity> validator,PropertyRule propRule) where TEntity : class, new()
        {
            var propertyName = propRule.Expression.GetMember().Name;
            var propType = typeof(TEntity).GetProperty(propertyName);
            //trying to exclude BuildLamdba don't know TValue only have PropertyInfo
            //var expresssion = BuildLambda<TEntity, IEnumerable<TValue>>(propertyName);

....
}

A: It was really hard to understand what may be your problem, if I didn't guess right please provide runnable code sample using .NET Fiddle or similar site:
namespace Foo {

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;

public class Program
{
    public static void Main()
    {
        var parent = new Parent {
            Children = new List<Child> {
                new Child(),
                new Child(),
                new Child()
            }
        };

        {
        // works

        var expr = BuildLambda<Parent, IEnumerable<Child>>("Children");

        expr.Compile().Invoke(parent).ToList().ForEach(x => Console.WriteLine(x));
        }

        // works too
        {

        var expr2 = BuildLambda<Parent, IEnumerable<object>>("Children");

        expr2.Compile().Invoke(parent).ToList().ForEach(x => Console.WriteLine(x));
        }

        // and this works too
        ValidateEntity(parent);

    }

    public static void ValidateEntity<TEntity>(TEntity e)
        where TEntity : class, new()
        {
            var propertyName = "Children";
            var propType = typeof(TEntity).GetProperty(propertyName);

            var expr = typeof(Program)
                .GetMethod("BuildLambda", BindingFlags.Public | BindingFlags.Static)
                .MakeGenericMethod(new[] { typeof(TEntity), propType.PropertyType })
                .Invoke(null, new[] {propertyName});

            // Here we invoke artificial method and inject property type there
            typeof(Program).GetMethod("ProcessExpr")
                .MakeGenericMethod(new[] { typeof(TEntity), propType.PropertyType })
                .Invoke(null, new [] { expr, e });

        }

    public static void ProcessExpr<TEntity, TValue>(Expression<Func<TEntity, TValue>> expr, TEntity parent) {
        // here we know both types
        Console.WriteLine("Yay works too!");
        ((IEnumerable<Child>)expr.Compile().Invoke(parent)).Cast<Child>().ToList().ForEach(x => Console.WriteLine(x));
    }

    public static Expression<Func<TEntity, TValue>> BuildLambda<TEntity, TValue>(string property) where TEntity : class
        {
            var param = Expression.Parameter(typeof (TEntity), "e");
            var prop = Expression.PropertyOrField(param, property);
            return Expression.Lambda<Func<TEntity, TValue>>(prop, param);
        }
}

public class Parent {

    public List<Child> Children { get; set; }
}

public class Child { }

}


text:
Q: When does node-mysql return `fields` as part of a query result According to the node-mysql documentation, the callback to a query will get three parameters - an error, the row(s) or result of the query, and something called fields which may or may not be passed everytime.

fields will contain information about the returned results fields (if any)

I recently ran into a bug which resulted from node-mysql returning fields in my production environment, but not in my staging environment. I was using async.auto and passed the step callback directly to mysql.query. In production, async.auto combined rows and fields into an arguments array, which lead to that part of the service breaking down because it got data in an unexpected format.
I could not get my staging environment to have fields be passed to the callback, and when I tried locally I could not get mysql to not pass fields. Is there any way to know when fields will be passed by mysql.query and when will it not?
Essentially
async.auto({
  runQuery: (next) => {
    mysql.query(sql, values, next);
  }
},
(err, results) => {
  // if `fields` is not passed to the callback by mysql.query,
  // then results.runQuery will be a row, or an array of rows -
  // [
  //   [
  //   [
  //     {
  //       "columnValue": 1
  //     }
  //   ],
  //   [
  //     {
  //       "columnValue": 1
  //     }
  //   ]
  // ]
  //
  // instead, if `fields` is passed to the callback by mysql.query,
  // then results.queryQuery will be an array containing the row(s)
  // and the fields
  //
  // [
  //   [
  //     [
  //       {
  //         "columnValue": 1
  //       }
  //     ],
  //     [
  //       {
  //         "columnValue": 1
  //       }
  //     ]
  //   ],
  //   [
  //     [
  //       {
  //         "catalog": "def",
  //         "db": "",
  //         "table": "",
  //         "orgTable": "",
  //         "name": "columnValue",
  //         "orgName": "",
  //         "charsetNr": 63,
  //         "length": 21,
  //         "type": 8,
  //         "flags": 129,
  //         "decimals": 0,
  //         "zeroFill": false,
  //         "protocol41": true
  //       }
  //     ],
  //     [
  //       {
  //         "catalog": "def",
  //         "db": "",
  //         "table": "",
  //         "orgTable": "",
  //         "name": "columnValue",
  //         "orgName": "",
  //         "charsetNr": 63,
  //         "length": 21,
  //         "type": 8,
  //         "flags": 129,
  //         "decimals": 0,
  //         "zeroFill": false,
  //         "protocol41": true
  //       }
  //     ]
  //   ]
  // ]
});


text:
Q: What's the difference between  and  in ASP.NET Core? This is a fundamental question:
What's the real difference between test and classic test in ASP.NET Core?
The end result appears to be the same always (it's an href attribute always in the end)
Does it somehow protect against clickjacking or something similar behind the scenes??
In other words, does using asp-page bring any security advantages?

A: You can customise the routing for Razor Pages, so that your LinkHere Razor Page and the URL to the page may be different. In that case, the asp-page approach ensures that the URL will match the page, but the href approach would need to be updated accordingly.
For an example of how a Razor Page URL can be customised, see Configure a page route:

options.Conventions.AddPageRoute("/Contact", "TheContactPage/{text?}");

In this example, the page Contact has a URL of TheContactPage with an optional extra segment.


text:
Q: If $\{f_n\}$ and $\{g_n\}$ be uniformly convergent sequences of bounded functions on S, then $\{f_ng_n\}$ is uniformly convergent on S. If $\{f_n\}$ converges uniformly to $f$ and $\{g_n\}$ converges uniformly to $g$, does it mean $\{f_ng_n\} $ will converge uniformly to $fg$?
I am absolutely stuck on this. Please help.

A: Hint
\begin{align}||f_ng_n-fg||_\infty&\le||f_ng_n-f_ng+f_ng-fg||_\infty\\&\le||f_n||_\infty||g_n-g||_\infty+||g||_\infty||f_n-f||_\infty\end{align}
and use the hypothesis that those functions are bounded.


text:
Q: HTML Datalist won't restrict to 5 or x items to be visible with a scroll I tried to no avail to get HTML, CSS and Javascript to limit number of items in datalist, for whatever reason, it is isn't working. The list is populated by a loop on a array.
<datalist id="trainNoList">
 <script>
if (markers)
{
  var options = '';
  var trainNoList = [];

  for (var i = 0; i < markers.length; i++) {
    var trainNo = markers[i][20];
    trainNoList.push(trainNo);
    options += "<option value='" + trainNoList[i] + "'></option>";
  }

}
</script>
</datalist>

<!-- Use JavaScript to pan to the train when an option is selected -->

<script>
  $("#trainNoInput").on("input", function() {
    var selectedTrainNo = $(this).val();

    // Check if the input is a range
    var rangeCheck = selectedTrainNo.split("-");
    if (rangeCheck.length === 2) {
      vehiclestart = rangeCheck[0];
      vehicleend = rangeCheck[1];

    } else {
      // Perform the same actions as in the original code
      for (var i = 0; i < markers.length; i++) {
        var trainNo = markers[i][20];
        if (trainNo == selectedTrainNo) {
          var lat = parseFloat(markers[i][2]);
          var lng = parseFloat(markers[i][3]);
          var setcontentforpopup = "Vehicle"+markers[i][0]+"";
            vehiclestart = 1;
      vehicleend = 99999999999999;
          var popup = L.popup()
            .setLatLng([lat, lng])
            .setContent(setcontentforpopup)
            .addTo(map);
          map.flyTo([lat, lng], 16);
          break;
        }
      }
    }
  });

$("#trainNoInput").on("focus", function() {
    console.debug("The trainNoInput field has received a keyup event");
clearTimeout(ajaxtimeout);
});

$("#trainNoInput").on("blur", function() {
ajaxtimeout = setTimeout(foo, 10000);
console.debug("no");
});

$("#trainNoInput").on("keyup", function(event) {
if (event.keyCode === 13) {
    markerLookup = {};
     markerClusters.clearLayers();
foo();
}
});

</script>

enter image description here
The desire result is simple - limit number of items shown down to 5 or whatever set amount and add a scroll bar to scroll down to see the remainder of the records
enter image description here


text:
Q: BizTalk 2016 support "multisubnetfailover" if we connect staging database with WCF-Custom sql binding? We had issue during connection from BT to staging DB ( it has setup under AG listeners) and couldn't able to enable RL and SP because by default WCF Custom sql bindings set "multisubnetfailover" to true.
Is there any work around to use AG listeners on Biztalk sql connection string without disable "multisubnetfailover" property to "False" ?

A: No.
From High Availability using SQL Server Always On Availability Groups - BizTalk Server

Support Availability Group Multi-Subnet Failovers
BizTalk Server uses Microsoft OLE DB for database connections, which does not support the MultiSubnetFailover connection option. BizTalk Server does not support the MultiSubnetFailover (=TRUE) connection option, and this may cause higher recovery time during multi-subnet failover.

Note: Although the above documentation has not been updated to state it, BizTalk 2020 may allow this for that adapters. See MultiSubnetFailover connection option in BizTalk.


text:
Q: Call options convexity detail here is an example I am studying to prepare for a quant interview:
Nine months call options with strikes 20 and 25 on a non-dividend-paying underlying asset with spot price 22 are trading for 5.5 and 1, respectively. Can you find an arbitrage?
I already know the answer: we consider one unit of the asset as a third option, namely we have $c_1 = 22$, $c_2 = 5.5$ and $c_3 = 1$ with $k_1 = 0$, $k_2 = 20$ and $k_3 = 25$. Where $c$ is the option price and $k$ in the strike price.
At this point $$k_2 = \frac{1}{5}k_1 + \frac{4}{5}k_3$$ at the same time $$\frac{1}{5}c_1 + \frac{4}{5}c_3 = 5.2 < 5.5 = c_2$$
therefore the convexity is violated and there is an arbitrage. The arbitrage strategy is "buy 100 units of asset for 2200, buy 400 calls ($k_3$) for 400 and sell 500 calls ($k_2$) for 2750." This way the profit is 150.
Here is my question:
If the convexity wasn't violated and let's say $c_2 = 5$, couldn't we just flip the strategy like the following?
"buy 500 calls ($k_2$) for 2500, sell 100 units of asset for 2200, sell 400 calls ($k_3$) for 400."
This way we would make a profit of 100.
where am I going wrong?

A: If you do that what happens if at maturity the stock price is $S_T = k_2 = 20$?
Then your portoflio's value is $\Pi_T = -100 (k_2 - k_1) + 0 + 0 = -2000$.
An arbitrage opportunity means that you have a positive profit with probability $1$ or in other words for all scenario.


text:
Q: Using Chrome extensions on PDF Files It is well known that Google can load PDF files properly, via PDF Viewer extensions.
My aim is to open a PDF file, and use the extensions like Google Dictionary, dict.cc, Google Translator on this file. These extensions work like this: You select a word by double clicking (just selection is enough) and its description pops out immediately.
No matter which extension I use, this function seems to work on only web pages, and not on PDF files, even though they both contain selectable text.
Is there any way to get these extensions to cooperate properly?
Update:
In JIRA, I have noticed that when one clicks to view an already uploaded PDF, the software brings the PDF in without opening a new tab, like a single page application does. I have tested Google dictionary and Google translator there, and they function pretty well. Thus, a possible way to deal with the issue would be to find an extension which runs the PDF like a single page application in a web page.

A: open your PDF file`s using this website: http://pdfviewer.softgateon.net/
(or similar website), then you can use Google Dictionary extensions

A: try using mac osx instead.... I guess there's no way easy to solve this, except altering chrome's source code to replace the adobe pdf plugin.
"Due to technical restrictions, you cannot select text and translate it by a shortcut in PDF files in any browser. Unfortunately, we can do nothing with this. However, in Google Chrome you can select text and translate it instantly from the context menu."  ----matetranslate.com

A: I would recommend Read Aloud, a text-to-speech Chrome App. One of its awesome features is its built-in PDF viewer; it allows you to upload PDF files, then behaves as it would with a webpage. Alternatively, you can upload PDFs to Google Keep.

A: I use Mendeley website for reading and managing my PDF files. In this way, the google-translate extension pop-up works on the text properly.
However, I understand that this is not an ideal solution as you need to register on the mentioned website and upload your PDF file which could be done by the Chrome browser itself ideally.

A: A Chrome extension called Instant Multilingual PDF/HTML/TXT Translator can translate the selected text in the Chrome pdf viewer.
Although some reviews mention a "free quota" problem, I have not encountered this yet. At least it is constantly being updated.


text:
Q: prove arctan(x) is continuous in $\epsilon$-$\delta$ I am trying to prove that $f(x) = \arctan(x)$ is $\epsilon$-$\delta$ continuous. I know I want to show that for all $\epsilon>0$, $x,y \in \mathbb{R}$, there exists $\delta > 0$ such that $|x-y| < \delta$ implies that $|f(x) - f(y)|< \epsilon$
Unforutnately, I cannot get anywhere from here
Any help would be greatly appreciated.

A: We have
$$
\arctan(x) -\arctan(y) =\arctan( ( x - y)/(1 + xy) ),
$$
hence, for nonnegative $xy$,
$$
|\arctan(x) -\arctan(y)|\leq|\arctan ( x - y)|\leq|x-y|
$$
and one can choose $\delta=\varepsilon$. The case $xy<0$ is easy to reduce to the previous one by taking $|x-y|\leq|x-0|+|y-0|$.

A: Note that $\tan:(-{ \pi \over 2}, {\pi \over 2}) \to \mathbb{R}$ is
 strictly increasing and surjective.
Since $\tan$ is strictly increasing, it follows that $\arctan$ is also strictly increasing.
Pick $x \in \mathbb{R}$ and $\epsilon>0$. Let $y_1 = (\arctan x)-\epsilon$,
$y_2 = (\arctan x)+\epsilon$, $x_1 = \tan y_1, x_2 = \tan y_2$.
Since $y_1 < \arctan x < y_2$, we have $x_1 < x < x_2$. Let $\delta = \min(x-x_1,x_2-x)$.
Then if $|x'-x| < \delta$, we have $x' \in (x_1, x_2)$ and hence $\arctan x'
\in (y_1,y_2) = ((\arctan x)-\epsilon, (\arctan x)+\epsilon )$ and so
$|\arctan x' - \arctan x| < \epsilon$.


text:
Q: javascript using variables in style.display I have a webpage that overlays village and guard tower locations on an imagemap for a game.
I created a javascript function to show and hide the transparent .png grid and the legend.
I would like to also use this function to show/hide the guard towers. Script works just fine but when I try to hide the towers the script only picks the first tower in the database.

I then have a button to call the function.
<form method="get" action="javascript:toggleLayer('tower');"><button class="botbuttprefs" type="submit">Show/Hide Towers</button></form>
ECHO "

";

A: It's not entirely clear what question you're asking.
document.getElementById works with an id value and returns only a single element and there should only ever be one item in your page with a given id.  So, if you were expecting it to somehow magically work with multiple elements with the same id, it will not.
To select multiple elements in the page, there are a number of ways to do that but the simplest would be to give each element a common class name.  You can then use document.querySelectorAll(".myClass") and it will return a list of DOM nodes which you can then iterate over to apply a change to all of them.
You may also want to know that reading element.style.display may return an empty string if there is no explicit style set on that node.  element.style.display does not return a setting that may be in effect because of a default condition or because of a style sheet rule.  If you wanted to get the actual value in effect, you would need to use getComputedStyle().

Also, there is no reason to use this:
if (document.getElementById)

All browsers have that method.


text:
Q: Making a wordpress page print friendly I'm trying to use an existing plugin in order to make my posts print friendly. I haven't got any support from the plugin developer. I think I have narrowed down the script to the function that places the 'Print' text in the posts.
Problem is that this plugin places the 'Print' button automatically. But I would like to place it in a template and prevent the automatic placement.
This is the code that does the job of placing the print button. Can someone suggest a modification so that the following script 1. DOES NOT place the 'Print' button automatically. 2.What would be the function to call/place in my single.php page.
if ( !$_GET['print'] == 1  ) {
    add_filter( 'the_content', 'printme_add_link' );
}

function printme_add_link( $content ) {
    if ( is_singular() ) {
        $printme_options = get_option( 'printme_options' );
        $print_stub = $printme_options['print_text'];
        }
        wp_enqueue_script( 'jquery' );
        wp_register_script( 'printme', plugins_url( '/printme.js', __FILE__ ), false, '1', true );
        wp_enqueue_script( 'printme' );
        $link = add_query_arg( 'print', '1', get_permalink() );
        $content = '<a href="' . $link . '" target="_blank">' . $print_stub . ' </a>' . $content;
        return $content;

    }

add_action( 'template_redirect', 'printme', 5 );
function printme() {
    if ( $_GET["print"] == 1 ) {
        include( plugin_dir_path(__FILE__) . 'print.php' );
        exit();
    }
}

A: remove_filter( 'the_content', 'printme_add_link' ) will prevent the link from being placed. You can just call printme_add_link() in your template to generate the print button. Alternately, you can just add_query_arg( 'print', 1, get_permalink() ) and use that as the link if you would prefer to do the link some different way.


text:
Q: approximate solution for ODE, error estimation with Picard-Lindelöf's Theorem Let be
$$y'= \frac{t}{y^2+1} $$
$y(0)=0 $
I want to determine an approximate solution $ \tilde{y} $ from the starting point $ \phi_0 =0 $
so that the error is : $ \lVert \tilde{y} -y \rVert_{ C[-1,1]} \leq 0,14 $
Well, I want to use  Picard- Lindelöf's Theorem:
Let be$ R:= [x_o-a,x_o+a] \times[y_o-b,y_0+b] $ a rectangle $ \in \mathbb{R^2} $ and $f: R \rightarrow \mathbb{R} $ a continous function.
If $f$ is lipschitz-continous in the second argument ($y$)
then the initial value problem $$y'=f(x,y) $$, $y(x_0)=y_0$ has a solution $y$ on the intervall $ J=[x_0- \alpha,x_0+ \alpha] $
where $ \alpha:= min( a, \frac{b}{ \lVert f\rVert_{C(R)}} ) $
The solution is the uniformly limes of the series of the iterations $ \phi_n $
$ \phi_n(x)= y_0 + \int_{x_0}^x f(t, \phi_{n-1}(t)) dt $
with the error estimates
$$ | y(x) - \phi_n (x) | \leq \sum_{k=n}^{ \infty} \frac{ ( \alpha L)^k }{k!} \lVert \phi_1 - \phi_o \rVert_{ C(J) } $$
and
$$ |y(x) - \phi_n (x) | \leq \frac{ (\alpha L)^n }{n!} e^{ \alpha L } \lVert \phi_1 - \phi_0 \rVert $$First, I want to use the last equations to see how many iteration steps I need to do, to get $ \leq 0,14 $ but here I do get suck.
$ \tilde{y}_1(x)= \int_0^t f(x, \phi_0 (x)) dt= \int_0^t x dx= \frac{1}{2} t^2 $
so
$ \lVert \phi_1- \phi_0 \rVert_{ C[-1,1] } = max_{t \in [-1,1]}  \frac{1}{2} t^2= \frac{1}{2} $
and for the Lipschitz-Constant I do get:
$ max_{t,y \in \mathbb{R} }| \frac{ \partial f }{ \partial y } | = max_{t,y \in \mathbb{R} } | - \frac{2ty}{(y^2+1)^2 } | =2=L$ is this right?
then putting together:
$ | y(x)- \phi_n | \leq \sum_{k=n}^{ \infty} \frac{ ( \alpha L)^k }{k!} \lVert \phi_1 - \phi_o \rVert_{ C[-1,1] } = \sum_{k=n}^{ \infty } \frac{2^k}{2k!} $
What is wrong? I want to be able to determine the correct error estimation, without having to determine the actual solution.
I appreciate any help and thank you in advance !


text:
Q: The output of my flask app is not showing on Windows machine i have this weird issue, my flask app works perfectly fine as long as i am opening the page from Mac machine.
but when i open the page from Windows machine (Chrome/IE) when i click the bottom to return the output, it just shows me a blank page. i cant understand why that's happening and i don't know how to google it :)
with that being said, i have moved the entire app to a windows server but again i cant see the output page on a windows machine whereas i see it perfectly fine from Mac Machine.
any tip will be much appreciate it!!!
here's a sample code that i have in the app
@app.route('/vxlan_config', methods=["GET", "POST"])
def vxlan_config():
    vxlan_config_file = open("/Users/ahmad/ShcConfigs/vxlan_config.txt", "w")
    if request.method == "POST":
        vlanid = request.form["vlanid"]
        description = request.form["description"]
        vrf = request.form["vrf"]
        ip = request.form["ip"]
        mask = request.form["mask"]
        vxlan_conf = SHCDCConfig(vlanid, description, vrf, ip, mask)
        vxlan_config_file.write(vxlan_conf.vxlan_config())
        return send_file("/Users/ahmad/ShcConfigs/vxlan_config.txt",
                         attachment_filename='vxlan_config.txt')
    return render_template('vxlan_config.html')

A: "/Users/ahmad/ShcConfigs/vxlan_config.txt" is a path to a file on your Mac!
Here is python code to help you make a platform-agnostic path to your file:
https://docs.python.org/3/library/pathlib.html
This will help find the available directories to place your file:
def vxlan_config():
    import os
    print( os.getcwd() )
    print( os.path.dirname(os.path.abspath(__file__)) )
    print( os.path.dirname(os.path.dirname(os.path.abspath(__file__))) )
    print( os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) )

    print( os.path.join(os.path.dirname(__file__), 'vxlan_config.txt') )

I put all these here because I do not know your directory tree.  Hopefully, you will recognize it now.


text:
Q: how can i implement date conversions in typo3 repository methods I have a query
SELECT * FROM `my_table`
WHERE DATEDIFF(CURDATE(), CAST(from_unixtime(tstamp) AS DATE)) >=365

How can I convert to repository method
$query = $this->createQuery();
$query->statement();
$query->matching(
        $query->greaterThanOrEqual(????, 365)
    );
return $query->execute();

A: You can just calculate that date with PHP:
$timestamp = time() - 86400 * 365;
$query->matching(
    $query->lessThanOrEqual('tstamp', $timestamp )
);

A: This is not directly possible in extbase. However I see 2 possible options
Variant 1
Use the native SQL query to return the uids of the records and use those in the extbase query:
 $query->in('uid', $idList)

Variant 2
It is possible to manipulate the query, however this is quite an overhead. You can take a look at https://github.com/TYPO3-extensions/news/blob/master/Classes/Domain/Repository/AbstractDemandedRepository.php#L90 to get an idea.


text:
Q: One corda node is not running I have developed one sample cordapp. There is a total of 4 nodes(Notary, Dealer, Manufacturer, and HDFC). All the nodes are running successfully apart from the Dealer node. I am getting the below error. I am also sharing the build.gradle file.
error screenshot
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
    nodeDefaults {
        projectCordapp {
            deploy = false
        }
        cordapp project(':contracts')
        cordapp project(':workflows')
    }
    node {
        name "O=Notary,L=London,C=GB"
        notary = [validating : false]
        p2pPort 10002
        rpcSettings {
            address("localhost:10003")
            adminAddress("localhost:10043")
        }
    }
    node {
        name "O=Dealer,L=London,C=GB"
        p2pPort 10005
        rpcSettings {
            address("localhost:10006")
            adminAddress("localhost:10046")
        }
        rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
    }
    node {
        name "O=Manufacturer,L=New York,C=US"
        p2pPort 10006
        rpcSettings {
            address("localhost:10009")
            adminAddress("localhost:10049")
        }
        rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
    }
    node {
        name "O=HDFC,L=New York,C=US"
        p2pPort 10008
        rpcSettings {
            address("localhost:10012")
            adminAddress("localhost:10052")
        }
        rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
    }
}

A: You seem to be getting a port binding issue, which means the ports 10046 and 10006 are already in use in your system.
Either change the ports in your node config block in the build.gradle file, or kill the processes running in your port.
Linux
Use below command to find information about process bind to a particular port.
lsof -i :<portNumber>

Use below command to kill the process.
kill <process_id>

Windows
If you are on windows see this SO post to find a kill process on a port: How can you find out which process is listening on a port on Windows?

A: *

*Always remember to shutdown your nodes properly by typing bye inside each node terminal (including the notary); otherwise you'll run into your current problem (some Java process is still allocating a port that you require for a certain node).

*Personally I don't like using runNodes command and its XTerm window; I prefer to do the following:

*

*Browse to a certain node: cd /path-to-project/build/nodes/PartyA

*Start the node: java -jar corda.jar

*To shutdown the node: bye


text:
Q: 'python -m unittest discover' works locally but unable to discover tests on CircleCi I am trying to add unittests to my project on CircleCi. Locally, when I run 'python -m unittest discover' from terminal, its able to find and run all 16 tests. But on CircleCi, it says:
Ran 0 tests in 0.000s

Any idea as to what might be going on??
Is there some configuration or environment variable that I am missing??
My project structure:
project
├── src
│   ├── main
│       ├── python
│           ├── testing
│               ├──Test1.py
|               ├──Test2.py

config.yml
version: 2
docker:
  - image: circleci/python:3.7.5
jobs:
  build:
    steps:
      - checkout
      - restore_cache:
          key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}
      - run:
          name: Install Python deps in a venv
          command: |
            python3 -m venv venv
            . venv/bin/activate
            pip install -r requirements/dev.txt
      - save_cache:
          key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}
          paths:
          - "venv"
      - run:
          name: Running tests
          command: |
            cd ~/project/src/main/python/testing/
            python3 -m unittest discover

A: Try setting the working_directory for that particular step, rather than using cd, e.g.
- run:
    name: Running tests
    working_directory: ~/project/src/main/python/testing/
    command: |
        python3 -m unittest discover

A: I finally soved this.
My test classes started with a capital 'T' and unittest by default looks for test*.py. So I had to add additional configuration as shown below:
python -m unittest discover -p "Test*.py"

Locally it was able to discover the tests as the Windows commandline is not case-sensitive.
But the Linux commandline that CircleCi spins up, is case-sensitive and that is why the tests were not getting discovered.


text:
Q: building a binary tree from its preOrder and inOrder in java I hava a problem with this code and I searched in many sites but I didn't
get  my desired answer . I copy this code from GeeksforGeeks but I  don't know what is the problem . I test this code on other platforms like  linux but it doesn't work there , also I tested it on eclipse IDE and it doesn't work  there and this is my code :
class SolveBT<E>  {

Node<E> treeRoot;
int preIndex = 0;

public SolveBT() {
    treeRoot = new Node<>(null);
}
 public void buildTree(E[] preOrder, E[] inOrder) {
     treeRoot = makeTree(preOrder, inOrder, 0, inOrder.length - 1);

}

private Node<E> makeTree(E[] preOrder, E[] inOrder, int start, int end) {
    if (start > end)
        return null;

    Node<E> node = new Node<>(preOrder[preIndex++]);

    if (start == end)
        return node;

    int index = find(inOrder, start, end, node.getData());

    node.setLeft(makeTree(inOrder, preOrder, start, index - 1));
    node.setRight(makeTree(inOrder, preOrder, index + 1, end));

    return node;
}

public int find(E[] arr, int start, int end, E value) {
    int i;
    for (i = start; i <end; i++) {
        if (arr[i] == value)
            return i;
    }
    return i;

}

}
   public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    SolveBT<String> tree = new SolveBT<>();

    String[] preOrder = scanner.nextLine().trim().split(" ");
    String[] inOrder = scanner.nextLine().trim().split(" ");

    tree.buildTree(preOrder, inOrder);

   AND THIS IS INPUT AND EXCEPTION :

   A B D E C F
   D B E A F C
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index
    6 out of bounds for length 6
at SolveBT.makeTree(ForStudents.java:290)
at SolveBT.makeTree(ForStudents.java:299)
at SolveBT.makeTree(ForStudents.java:299)
at SolveBT.makeTree(ForStudents.java:299)
at SolveBT.makeTree(ForStudents.java:299)
at SolveBT.makeTree(ForStudents.java:299)
at SolveBT.makeTree(ForStudents.java:299)
at SolveBT.buildTree(ForStudents.java:281)
at ForStudents.main(ForStudents.java:15)

A: The error is in the line
 Node<E> node = new Node<>(preOrder[preIndex++]);

The preIndexvariable is getting incremented on each function call. Check its usage and logic. According to my opinion, it should be static.


text:
Q: Implicit conversion of C pointer warning I am using a linked list defined as follows:
typedef struct {
    struct foo* next;
} foo;

Assuming that it has already been set up with the head pointer called linked_list and I want to iterate through the linked list as follows:
foo* curr = linked_list;
while(curr->next) {
    curr = curr->next;
}

My compiler (Clang) throws a warning about converting from struct foo* to foo* [-Wincompatible-pointer-types]
I know that I can suppress this warning by casting it, but is there a better way of doing this?

A: The problem is that the structure struct foo used in this declaration
typedef struct {
    struct foo* next;
    ^^^^^^^^^^
} foo;

is never defined.
As result in this expression statement
curr = curr->next;

the left operand has the type foo * while the right operand has the type struct foo *.
Rewrite the structure definition the following way
typedef struct foo {
    struct foo* next;
} foo;


text:
Q: Python: How to pass output of the map function as arguments I need to pass some arguments to the starmap_async function. I have a list my_list that has different values in it and some constants that are repeated. I have a way to pass the arguments as bellow:
import multiprocessing as mp
from itertools import repeat

def f(a,b,c,d):
    return (a,b,c,d)

my_list = [1,2,3,4,5]

with mp.Pool(cpu_num) as pool:
    res = pool.starmap_async(f, zip(my_list, repeat(a),repeat(b),repeat(c),repeat(d)))
    pool.close()
    pool.join()
    res.get()

It works and generates arguments like this which is the desired output:
(1,a,b,c,d)
(2,a,b,c,d)
(3,a,b,c,d)
(4,a,b,c,d)
(5,a,b,c,d)

Now I want to use the map function to do something like this:
res = pool.starmap_async(f, zip(my_list, repeat(list(map(repeat,
[a, b, c, d])))))

but then I end up with arguments like this:
(1,(a,b,c,d))
(2,(a,b,c,d))
(3,(a,b,c,d))
(4,(a,b,c,d))
(5,(a,b,c,d))

How can I fix that issue?

A: Try this:
import multiprocessing as mp
from itertools import repeat

def f(a,b,c,d):
    return (a,b,c,d)

my_list = [1,2,3,4,5]

with mp.Pool(cpu_num) as pool:
    res = pool.starmap_async(f, zip(my_list, *map(repeat, (a,b,c,d))))
    pool.close()
    pool.join()
    res.get()


text:
Q: Markdown and footnotes: most natural format missing? Markdown and footnotes so far
I'm referring to Markdown: Syntax at daringfireball.net, which seems to be primary source for Markdown syntax.
Markdown is known to be based on already existing formatting in mails and newsgroups. In mails and newsgroup, I often see something like this for footnote and forwarded references:
Blah, blah [1] blah, blah.

[1] http://somesite.com/somepage.html#someanchor

Surprisingly, this very common format, is not part of the primary Markdown reference. It only knows something like:
Blah, blah [some title][id] blah, blah.

[id]: http://somesite.com/somepage.html#someanchor

And I have never seen any using this spontaneously in either a newsgroup or a mailing list, while the former is very common.
I could just find something called PHP Markdown Extra, which has something closer to the common spontaneous usage, while different enough:
Blah, blah [^id] blah, blah.

[id]: http://somesite.com/somepage.html#someanchor

Closer, but I still never seen anyone using this in a newsgroup or mail.
The question
I wonder why a so much common usage is not part of the primary markdown reference, and even not part of any variant I know. If someone knows some reason for this, I'm interested in knowing this reason. On the other hand, if I just missed something, like missing a markdown variant which is of very common use and includes the in practice most natural way of writing a footnote or forwarded reference (the first one introduced in this post), then I would like to know it.

A:
...why a so much common usage is not part of the primary markdown reference, and even not part of any variant I know.

It looks like some of it is available per How do I format my posts using Markdown or HTML?:
Links
Here's an inline link to [Google](http://www.google.com/). Here's a
reference-style link to [Google][1]. Here's a very readable link to
[Yahoo!][yahoo].

  [1]: http://www.google.com
  [yahoo]: http://www.yahoo.com/

Advanced Links
Links can have a title attribute, which will show up on hover. Title attributes can also be added; they are helpful if the link itself is not descriptive enough to tell users where they're going.
Here's a [poorly-named link](http://www.google.com/ "Google").
Never write "[click here][^2]".
Visit [us][web].

  [^2]: http://www.w3.org/QA/Tips/noClickHere
        (Advice against the phrase "click here")
  [web]: http://programmers.stackexchange.com/ "Programmers Stack Exchange"

Also see Markdown footnotes? at Meta. The page mentions Markdown With Footnotes.

A: There're a few Markdown variations or 'flavours' out there that implement footnotes (besides Php Markdown Extra, which you mentioned). Those I'm aware of are Pandoc's Markdown, R Markdown, ScholarlyMarkdown, and MultiMarkdown.
I believe footnotes work this way in all of these variations:

This is some text with a footnote.[^] And another.[^]
[^]: Here is the first footnote.
   [^]: Here is the second footnote.

Or inline:

This is some text with a footnote.^[Here is the first footnote.] And another ^[Here is the second footnote.]

They should both render this way:

This is some text with a footnote.1 And another.2

*

*Here is the first footnote. ↩

*Here is the second footnote. ↩

You can add links to footnotes too, for instance:

This is some text with a footnote and link.[^Here is an example of a footnote with a link at the end. [link](http://stackoverflow.com)]

Which should render like this:

This is some text with a footnote.1

*

*Here is an example of a footnote with a link at the end. link ↩

Btw, if you use an editor such as Atom or VSCode, you may want to add the extension Markdown Preview Enhanced. As the name indicates, it allows previewing the rendered text as you type (it supports previewing and exporting with Pandoc).
Pandoc's documentation on the matter: https://pandoc.org/MANUAL.html#footnotes


text:
Q: Git clone only works with ssh://git@.. and not with git@ Any idea why a GIT repo would work only when using ssh://git@server.com/repo.git and not also when using git@server.com/repo.git?
It's a server setup by someone else so no idea how it was setup but on BitBucket or GitHub I can just use git@server.com/repo.git and it works and clones the repo using SSH protocol. Any idea why for this server iy only works when using ssh://git@server.com/repo.git ?
So i need to add the ssh:// in front.

A: You are using the incorrect syntax.
When you remove the scheme:// prefix, git no longer interprets your address in URL style anymore, but instead as rcp/scp style. But for rcp/scp style addresses, the path must be separated from user@host using a colon : (specifying a port is not supported). For example:
git clone daniels@server.com:repo.git

git clone git@bitbucket.com:daniels/example.git

Without the colon, git will only interpret the address as a local path.
(You can see more details in the git clone or git fetch manual page.)


text:
Q: Prime decomposition of pR where R=$\mathbb{A}\cap \mathbb{Q}[\alpha]$ with $\alpha^5=5(\alpha+1)$, exercise 27 chapter 3 of Marcus I'm trying to do exercise 27 in chapter of Marcus but it seems to me there is a typo or maybe it's me not understanding.
The exercise is the following

Let $\alpha^5=5(\alpha+1)$ R=$\mathbb{A}\cap \mathbb{Q}[\alpha]$.
Let $p\neq 3$ be a prime of $\mathbb{Z}$.
Show that the prime decomposition of pR can be determined by factoring $x^5-5x-5 \; mod\; p$
Do it for p=2

The hint is to use a previous exercise that tells us that the discriminant of $\alpha$, root of the irreducible polynomial $x^5+ax+b$ is $disc(\alpha)=4^4a^5+5^5b^4$ so in our case the discriminant is $5^5*3^3*41$ (isn't it?).
Another theorem (27 chapter 3 of Marcus Number Fields) tells us that we can decompose pR factoring the minimal polynomial of $\alpha$ if $p\not||S/R[\alpha]|$ where S is the integer ring of L and R is the integer ring of K, with L:K.
If I'm not wrong in our case we have $|S/R[\alpha]|=|\mathbb{A}\cap\mathbb{Q}[\alpha]/\mathbb{Z}[\alpha]|$.
A last corollary tells us that if $p^2\not| disc(\alpha)$ then the hypotesis of the theorem are satisfied.
This allows me to say that all the primes but maybe 3 and 5 satisfy the theorem hypotesis, however I don't know how to say that actually 5 is good but 3 is not.
My last option is to compute an integral basis but it seems a long process so I'm asking if there is another way to do it.

A: There is also a useful theorem: let $\alpha$ be an algebraic integer, let $L=\mathbb{Q}(\alpha)$. Assume the minimial polynomial of $\alpha$ is $p$-Eisenstein. Then $p\nmid [O_L:\mathbb{Z}[\alpha]]$, where $O_L$ is the ring of integers of $L$.
IN your case, the minimal polynomial is $X^5-5X-5$, which is $5$-Eisenstein. So the decomposition of $5$ is reflected by the decomposition of s $X^5-5X-5\mod 5.$
Note that the exercise does not ask to show that it does not work ofr $3$. It indeed does not work: modulo $3$, $X^5-5X-5$ has a decomposition into irreducble factors of the form $f_1^2f_2$, while $3$ actually does not ramify in $L$. A way to see htat would be to compute the discriminant, which is $5^2\cdot 41$, but I on't see an easy argument to do so at this moment.


text:
Q: Start gnome-shell from another session/terminal/user sometimes my gnome shell gets a weird bug. What I need to do then is to click e.g Ctrl + Alt + F3 When I am there i can login and then
killall gnome-shell

Then I go back to the first Ctrl + Alt + F1 (what do you call them tty1, tty2, tty3 ... )
back there I can sometimes open a terminal and enter:
gnome-shell

but sometimes it doesn't work, like now, because the browser window has the focus and no other windows has, and I can't start gnome-shell from the browser, so that's why I am asking the question now :) .
The thing that I have tried is to export the display when I am in the tty2 or tty3, not the one with graphics in
export DISPLAY=:0.0
gnome-shell

but I guess that the :0.0 display isn't the main display?, anyway I can at least start the gnome-shell but it results in an error. It is not the can't find an X display error, but another one that has something to do with the top-bar and the extensions.
Does anyone know how to start the gnome-shell from another "tty" thing?

A: Please try
$ DISPLAY=:0 gnome-shell

Also you should take a look at your ~/.xsession-errors, finding out as to why gnome-shell crashed. Maybe you can even do a backtrace and report a bug.

A: When gnome-shell starts behaving oddly you can also do the following.

*

*Switch to another console Ctrl + Alt + F2

*login using the same account that's running the desktop

*Run the command pkill -HUP gnome-shell
Once the above kill has taken effect, gnome-shell will automatically restart itself.

A: What are you doing it is not possible anymore in wayland sessions, because with Shell having taken the role of the X server, killing it would kill the entire interface. On the bright side shell now is capable or restarting itself when there's a crash or an hang of some sort.


text:
Q: court smell -- what does that mean? From the song Memory:

When the dawn comes
  Tonight will be a memory too
  And a new day will begin
  Burnt out ends of smoky days
  The stale court smell of morning
  A street lamp dies
  Another night is over
  Another day is dawning

How do you understand that?

A: It's a typo! (of sorts)

The still cold smell of morning here
The stale cold smell of morning here


text:
Q: How to create a cumulative count distinct with partition by in SQL? I have a table with user data and want to create a cumulative count distinct but this type of window function does not exist. This is my table
date       | user-id | purchase-id
2020-01-01 | 1       | 244
2020-01-03 | 1       | 244
2020-02-01 | 1       | 524
2020-03-01 | 2       | 443

Now, I want a cum count distinct for purchase id like this:
date       | user-id | purchase-id | cum_purchase
2020-01-01 | 1       | 244         | 1
2020-01-03 | 1       | 244         | 1
2020-02-01 | 1       | 524         | 2
2020-03-01 | 2       | 443         | 1

I tried
Select
dt,
user_id,
count(distinct purchase_id) over (partition by user_id ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as cum_ct
from table

I get an error that I cannot use count distinct with an order by statement. What to do?

A: Something like this
Select
  dt as [date],
  user_id,
  purchase_id
  SUM(CASE WHEN rn = 1 THEN 1 ELSE 0 END) over (partition by user_id ORDER BY dt ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as cum_ct
from (
  SELECT
    dt,
    user_id,
    purchase_id,
    ROW_NUMBER() OVER (PARTITION BY user_id, purchase_id ORDER BY dt) as RN
  FROM sometable
) sub


text:
Q: Storing NFT metadata on IPFS with BaseURI, can I update the JSON dynamically for tokens when they are minted? I'm trying to create a collection of 10,000 (ERC-721) tokens, whose metadata are stored on IPFS.
Each image associated to a token would be uploaded on IPFS beforehand with its unique CDI.
Since tokens will not be minted all at once, at first I want each metadata json to be empty and link to a placeholder image.
My question is: without setting specific TokenURI in my contract (which I want to avoid), how can I change the json file associated with a token when it's minted, without changing the BaseURI which must be common for all tokens?
This is how it should work:
ipfs://Qx000000000000000000/1.json  // json file points to nothing
// token 1 is minted
ipfs://Qx000000000000000000/1.json  // json file is updated but keeps the same ipfs base URI

I guess it should involve IPNS, but I can't find a specific guide on the best practice for this. Although I see this method is used all the time, for example even by the Bored Ape Yacht Club collection.


text:
Q: Unable to upload file more than 1MB in size we have a multisite installation with following configuration:
bash-5.0# cat /usr/local/etc/php/conf.d/uploads.ini
file_uploads = On
memory_limit = 500M
upload_max_filesize = 100M
post_max_size = 100M
max_execution_time = 600
max_file_uploads = 50000
max_execution_time = 5000
max_input_time = 5000

Our /usr/local/etc/php/php.ini has:
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
; http://php.net/file-uploads
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://php.net/upload-tmp-dir
;upload_tmp_dir =

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 2M

; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20

but on the wp-admin panel we see this:

How an we fix this? None of the existing answers helped here. we checked functions.php file. It does not have any ini_set calls in it.
Running phpinfo we have observed:
Loaded Configuration File => /usr/local/etc/php/php.ini
Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini,
...
/usr/local/etc/php/conf.d/uploads.ini

post_max_size => 100M => 100M
upload_max_filesize => 100M => 100M

https://developer.wordpress.org/reference/functions/wp_max_upload_size/
in
function wp_max_upload_size() {
    $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
    $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );

    /**
     * Filters the maximum upload size allowed in php.ini.
     *
     * @since 2.5.0
     *
     * @param int $size    Max upload size limit in bytes.
     * @param int $u_bytes Maximum upload filesize in bytes.
     * @param int $p_bytes Maximum size of POST data in bytes.
     */
    return apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes );
}

A: Upon debugging we found the wp_max_upload_size function was returning 1MB. The u_bytes and p_bytes were as expected and equal to 100MB as defined in our uploads.ini file but the application of upload_size_limit filter changed the size to 1MB i.e., the problem was at:
return apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes );

A upload_size_limit_filter is defined in wp-includes/ms-functions.php and is wired up to execute only for a multisite installation. (the wiring code is in wp-includes/ms-default-filters.php. The filename has a ms prefix standing for multisite):
// this function runs only for a multisite installation of wordpress
function upload_size_limit_filter( $size ) {
        $fileupload_maxk = KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 );
        if ( get_site_option( 'upload_space_check_disabled' ) ) {
                return min( $size, $fileupload_maxk );
        }

        return min( $size, $fileupload_maxk, get_upload_space_available() );
}

and tracing the code path we found that fileupload_maxk equalled 1536000 and so this is what was causing the issue. The fileupload_maxk value is fetched from MySQL.
Continuing, we could see this in MySQL DB. The wp_sitemeta table only exists for a multisite installation:
mysql> select * from wp_sitemeta where meta_key = 'fileupload_maxk';
+---------+---------+-----------------+------------+
| meta_id | site_id | meta_key        | meta_value |
+---------+---------+-----------------+------------+
|       7 |       1 | fileupload_maxk | 1500       |
+---------+---------+-----------------+------------+
1 row in set (0.00 sec)

and so the fix for this problem is to update this value. It can be done using wp-cli as follows. We are using a multisite installation so have to use wp site command:
bash-5.0# wp site option update fileupload_maxk 10000 --allow-root
Success: Updated 'fileupload_maxk' site option.

This updates the entry in MySQL and the issue is fixed. In short, it seems that the fileupload_maxk does not seem to be well known. None of our Google searches on original query led us to it. Here is another answer on SO that talks about fileupload_maxk.


text:
Q: How To Retrieve Custom Columns For DriveItems in MS Graph I'm trying to use the Graph API to retrieve a hierarchy of files in a Sharepoint document library. Since document libraries are stored in "drives" (is it technically correct to call it OneDrive?), I'm using the /drives endpoint to fetch a list of files, like this:
https://graph.microsoft.com/beta/drives/{driveid}/root/children

I would like to get information from some of the custom columns that exist when viewing these items through Sharepoint. Using ?expand=fields doesn't work because fields only exists in listItem object of the /sites endpoint, not in the driveItem object of /drives endpoint. If I try obtaining the listItem from a single driveItem (traversing the Graph from OneDrive to Sharepoint), and then expanding the fields, like
https://graph.microsoft.com/beta/drives/{driveid}/items/{driveItemId}/listItem?expand=fields

this retrieves built-in columns (Author, DocIcon, and some others) but doesn't seem to retrieve the custom columns.
I've also tried getting the list of files from the /sites endpoint, and using ?expand=fields will get the custom columns, but it gets every file from every subfolder, rather than the current folder path. But I feel that deserves its own SO question.
Is it possible to retrieve custom column information from driveItems?

A: I spent a lot of time digging around with the different syntax possibilities and was finally able to get custom library properties using this query format. This is the only one that has produced my custom/user-defined fields for a document library.
https://graph.microsoft.com/v1.0/drives/insert_drive_id_here/root/children?expand=listItem
Shortened result:
{
"@odata.context": "...",
"value": [
        {
        "@microsoft.graph.downloadUrl": "...",
        "listItem@odata.context": "...",
        "listItem": {
            "@odata.etag": "...",
            "fields@odata.context": "...",
            "fields": {
                "@odata.etag": "...",
                "Title": "...",
                "Other_Custom_Property": "..."
                }
            }
        }
    ]
}

A: I did some testing.  What SHOULD work is:
https://graph.microsoft.com/beta/drives/{driveid}/root/children?$select=id,MyCustomColumnName
However, when I did that, it just returned that id field. In my opinion, that is a bug in the graph because this same type of query does work in the SharePoint REST api.
If this helps, you can accomplish this by using the SharePoint REST api.  Your endpoint query would be something like:
https://{yoursite}.sharepoint.com/sites/{sitename}/_api/web/lists/(' {DocumentLibraryID}')/items?$select=id,MyCustomColumnName
There are other ways to do the same query.

A: Try the list endpoint then expand driveItem and fields. You now have both custom column fields and drive item fields.
 /beta/sites/[site-id]/lists/[list-id]/items?expand=driveitem,fields&filter=(fields/customColumn eq 'someValue')


text:
Q: Filtering json response in Vue I am having trouble with filtering a json response in Vue.
return this.offers.filter(type => type.offers == 'Junior');

Whenever I leave it as return this.offers, in my html this is being displayed:
{"-MN5agCddYAdy7c8GSSz": { "companyName": "dawdwad", "image": "da", "jobDescription": "dada", "location": "daw", "salary": "dadaw", "skill": "dawda", "tags": "dada", "title": "dwa" }, "-MN7vsTsNohgQigd3S26": { "companyName": "ejadfjaq", "image": "", "jobDescription": "dada", "location": "2sjawdja", "salary": "40324032", "skill": "Junior", "tags": "ux", "title": "fawd" } }

But I want only the fields with "skill": "Junior" to appear.

A: Your JSON is an object but filter only works on arrays.  You can use the for...in loop in a computed to reformat it and filter it the way you like:
computed: {
  filteredOffers() {
    const filteredOffers = [];
    for(const key in this.offers) {
      if (this.offers[key].skill == 'Junior') filteredOffers.push(this.offers[key]);
    }
    return filteredOffers;
  }
}

This returns an array of the objects you want.  If you just want to display them raw in your template:

   {{ filteredOffers }}

Here's a demo:

new Vue({
  el: "#app",
  data() {
    return {
      offers: {
        "-MN5agCddYAdy7c8GSSz": {
          "companyName":"dawdwad",
          "image":"da",
          "jobDescription":"dada",
          "location":"daw",
          "salary":"dadaw",
          "skill":"dawda",
          "tags":"dada",
          "title":"dwa"
        },
        "-MN7vsTsNohgQigd3S26":{
          "companyName":"ejadfjaq",
          "image":"",
          "jobDescription":"dada",
          "location":"2sjawdja",
          "salary":"40324032",
          "skill":"Junior",
          "tags":"ux",
          "title":"fawd"
        }
      }
    }
  },
  computed: {
    filteredOffers() {
      const filteredOffers = [];
      for(const key in this.offers) {
        if (this.offers[key].skill == 'Junior') filteredOffers.push(this.offers[key]);
      }
      return filteredOffers;
    }
  },
});

   {{ filteredOffers }}


text:
Q: how can i modify my code so that the user can input the same colour four times but not anything outside my list range? #Colours

colourRange = ["red", "green", "blue","yellow", "magenta","cyan"]
print("Please enter colours from: ", colourRange)
colour1 = input("Please press Enter after you have entered your colour\n\
Enter your 1st colour?: ")
colour2 = input("Enter 2nd colour?: ")
colour3 = input("Enter 3rd colour?: ")
colour4 = input("Enter 4th colour?: ")
colour = [colour1,colour2,colour3,colour4]

#loop for four colour choice within list

for i in range(4):
    while colour[i] not in colourRange:
        print(colour[i], "is not a valid colour, please \
            select another from :  ", colourRange)
        colour[i] = (input("Replace with: "))
    else:
        colourRange.remove(colour[i])

A: This is much simpler if you write a function to get one valid colour, then call it several times.
def get_colour(prompt, valid_colours):
    """Allow the user to enter a single valid colour."""
    while True:
        colour = input(prompt)
        if colour in valid_colours:
            return colour
        print("Not a valid colour.")

def get_colours(n, valid_colours):
    """Get n valid colours from the user."""
    return [get_colour("Input colour {}: ".format(i+1), valid_colours)
            for i in range(n)]

colours = get_colours(4, {"red", "green", "blue", "yellow", "magenta", "cyan"})

Note that:

*

*n and valid_colours are parameters, to make the code more flexible and reusable;

*I have used a list comprehension to simplify the code;

*the valid_colours are a set, which makes membership testing (colour in valid_colours) much faster (O(1) vs. O(n) for a tuple or list); and

*I have used str.format rather than concatenation +.

In use:
>>> colours = get_colours(4, {"red", "green", "blue", "yellow", "magenta", "cyan"})
Input colour 1: purple
Not a valid colour.
Input colour 1: cyan
Input colour 2: green
Input colour 3: yellow
Input colour 4: red
>>> colours
['cyan', 'green', 'yellow', 'red']


text:
Q: android button.getWidth() returns value 0 I'm dynamically creating buttons and I want to place them randomly on the screen.
In order to do that, I'm substracting the width of the button from the screen's width.
The thing is, the function button.getWidth() always return 0.
I saw in other posts that people recommended using
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    placeButtonsOnScreen();
 }

But even when I'm using it, it doesn't work.
private void placeButtonsOnScreen() {

    Random r = new Random();

    LinearLayout layout = (LinearLayout) findViewById(R.id.ordered_buttons_layout);

    for (int i = 0; i < NUMBER_OF_BUTTONS; i++) {
        Button hiddenButton = buttonsArr[i];
        // Get random horizontal margin for the button
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        horizontalMargin = r
                .nextInt(SCREEN_WIDTH - hiddenButton.getWidth());
        layoutParams.setMargins(horizontalMargin, 50, 0, 0);
        // Add the button to the screen
        layout.addView(hiddenButton, layoutParams);
        Log.d("button width",String.valueOf(hiddenButton.getWidth()));
    }
}

Any ideas how can I position the buttons on the screen minus their width? Cos right now they get cut off from intersection with the right side of the screen.

A: myView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {

            myView.getViewTreeObserver().removeGlobalOnLayoutListener(this);

           placeButtonsOnScreen();
        }
    });

A: You should use RelativeLayouts and make buttons position according to each other (Aligning of course the one closest to the right side of the screen as alignedToParentRight = true)


text:
Q: How to get affected rows after update statement in mysql? How to get affected rows (not just the number of rows affected) after update statement in mysql.

A: mysql_info — Get information about the most recent query
$recent = mysql_info();

Useful implementation Example

A: If you want the actual rows and not the amount of affected rows, simply fetch them before doing the update.
Afterwards you can compare update values with selected values and filter them by difference.
Example with CodeIgniter:
$arr_where = array('date >=' => date('Y-m-d H:i:s'));

$query = $this->db->get_where('table', $arr_where);

$arr_update = array('status' => 'TRUE');

if ($this->db->update('table', $arr_update, $arr_where)) {

    foreach($query->result() as $row)
        foreach(array_keys($arr_update) as $h)
            if ($row->$h != $arr_update[$h])
                echo "This row ({$row->id}) had it's {$h} changed!
";

}

Sorry for supplying solution in CodeIgniter, but I found it to be the simpliest example.
To see what the $this->db functions do, see Active Records.

A: You could try using:
SET @uids := '';
UPDATE

 SET <column1> = <value>
 WHERE <column2> = <value>
   AND ( SELECT @uids := CONCAT_WS(',', @uids, id) );
SELECT TRIM(LEADING ',' FROM @uids);

A: Since you  are using php you can use mysql_affected_rows() to get the number of affected rows.


text:
Q: Rails 3, i18n: Interpolating html tags into text My problem is exactly the one described in this question. Only difference: I'm using Rails 3 (3.0.4 exactly), which uses the %{...} syntax rather than the old {{...}}.
Problem: Rails 3 escapes all tags inside %{...} so I cannot interpolate, say, links in there.
Is there any way to overcome this?

A: I finally figured it out, you have to use _html as a suffix for any yaml-keys, that you do not want html-escaped:
paragraph_html: "This is some text with a %{link}"
paragraph_linktext: "really cool link"

and then
link = link_to t( paragraph_linktext ), "http://www.example.com"
<%= t( paragraph_html, :link => link ) %>

and voila, there you have your i18n-ized link.

A: You can do like this
my_translation: "Click to access %{link} page"

then:
<%= t( my_translation, :link => link_to("Google", "http://google.com") ).html_safe %>

And everything will be ok!


text:
Q: Java: simple program to attach document or image I have two buttons and one textset on JFrame. I need the first button to allow the user to browse for files and the second button to attach documents or images and displayed in textset.

A: You can use JFileChooser to find the image on the hard drive and you can display the image on a JLabel


text:
Q: Mysql Fetch Records When Foreign Key Value Is Zero I've created some tables as follows.
countries

con_id   con_name
99       India
100      China

cities

cty_id     cty_name         country_id
1          Bangalore        99
2          Chennai          99
3          Delhi NCR        99

fees

f_id     st_dt        end_dt        city_id         country_id
1        2014-05-05   2014-05-05    1               99
2        2014-05-10   2014-05-10    2               99
3        2014-05-15   2014-05-15    3               99
4        2014-05-20   2014-05-20    0               100
5        2014-05-22   2014-05-22    0               100

I'm writing a query fetch the records from fees table by country_id as follows.
SELECT *
FROM fees as fe
JOIN countries as con
   ON con.con_id = fe.country_id
JOIN cities as cty
   ON cty.cty_id = fe.city_id

For country india, it fetches first 3 records from fees table and for country china, its not fetching any records due to joinings.
So I want the results like null for city columns and correct values for fees and country tables.
Please help me how to get the solution for this. The work would be more appreciated.

A: You can use LEFT JOIN (or right, depending on the join sequence):
SELECT *
FROM countries c
LEFT JOIN fees f
  ON c.con_id = f.country_id
LEFT JOIN cities ci
  ON ci.country_id = c.con_id

The left join will fill with nulls the columns which don't have a match in the join.


text:
Q: What are the trade-offs between "separating module interface/implementation unit in a different source file" and using "private module fragment" On the surface, using private module fragment to separate interface and implementation looks superior over separating module interface and implementation unit in a different source file since you only have to manage single source file when using private module fragment.
But is using private module fragment simply better than separating module interface/implementation unit in a different source file as it looks? What are the trade-offs?

A: The tradeoff is pretty obvious based on the limitations. A private module fragment (PMF) can only appear in a primary module interface unit, and there can be no other module units that contribute to a module that has a PMF. This means that the primary downside of using a PMF is that you're restricted to putting everything for a module in a single file.
The performance of module importing, broadly speaking, is not based on how much stuff is in a module. As such, putting a lot of stuff into a module is a pretty good idea. But putting all of those things in a single file can be long-winded and difficult to maintain. As libraries get bigger, splitting them into multiple files is usually better for organization.
The PMF construct is mainly for making it easy to distribute a library that provides module and non-module builds. The main code lives in (mostly) regular headers and source files, which are used to build the non-module version. For the module version, you have a single module unit. In the global fragment, you #include any headers that your interface headers use that are not part of your library (standard library headers, dependent libraries, etc). In that module unit's purview, you #include all of the interface headers within a big export{} block. The private module fragment can #include all of the .cpp files used to compile the library, so that the compiler can just build that one module file and get everything.


text:
Q: VSCode: after upgrade git command failing Host key verification failed After my windows vscode upgrade, my git command stop working and show below log message. my git check out work in command line. not sure what changed during the upgrade.
How to resolve this error message?
> git pull
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

A: This worked for me:

*

*delete known_hosts in ~/.ssh

*genrate or regenerate ssh keys

*run ssh vs-ssh.visualstudio.com

*answer yes.


text:
Q: Excel VBA - Range(Find().Adress).Row I have googled and struggled with this for hours now.
I have a Control workbook, that pulls data from a varied amount of other workbooks (the Control workbook also creates the other workbooks and saves the names and dir of said workbooks so that they can be called later)
This piece of code is the problem.

Application.DisplayAlerts = False
Application.ScreenUpdating = False

Declare_Sheets

Dim SearchresultROW
Dim Searchresult As String
Dim complexrow As Integer
Dim CurrSheet As Worksheet
Dim Stype As String

Dim startROW As Integer
Dim endROW As Integer, SearchCOL As Integer, OffROW As Integer
Dim PDATArange As Range, CDATArange As Range
Dim Dateyear, Datemonth, datetest As String

Stype = WSRD.Range("B11")

'Find complex to work with
complexrow = WSSS.Range("F7")
WSSS.Activate
SearchresultROW = Range(Cells(7, 15), Cells(complexrow, 15).Find(Callsheet).Address).Row
Searchresult = WSSS.Cells(SearchresultROW, 15).Offset(0, 1)

Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub

The below code is the problem extract
complexrow = WSSS.Range("F7")
WSSS.Activate
SearchresultROW = Range(Cells(7, 15), Cells(complexrow, 15).Find(Callsheet).Address).Row
Searchresult = WSSS.Cells(SearchresultROW, 15).Offset(0, 1)

1st problem
I cant get the find() to work without activating worksheet - WSSS
Declare_Sheets gets run at the start which declares WSSS, this works everywhere else in my code, but not with this find().
2nd problem
The code below compiles and finishes, BUT - It does not return the correct data.
This code calls starts the macro
Cancel = True
Dim Calsheet As String
If Target.Column <> 1 Then Exit Sub
Calsheet = Target.Value
Call Call_Readings(Calsheet)
End Sub

There are currently 2 possibilities

I double click on Casper Tcomp 4.
Callsheet = "Casper Tcomp 4" - Which is correct (target of the double click)
Complexrow = "9" - Which is correct (this will increment as new sheets are added)
SearchresultROW = "7" - This is wrong, it should be 8
I have tried adding LookAt:=xlWhole and LookIn:-xlValues, doesnt change a thing

A:
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Declare_Sheets

Dim SearchresultROW
Dim Searchresult As String
Dim complexrow As Integer
Dim CurrSheet As Worksheet
Dim Stype As String
Dim FindResult As Range

Dim startROW As Integer
Dim endROW As Integer, SearchCOL As Integer, OffROW As Integer
Dim PDATArange As Range, CDATArange As Range
Dim Dateyear, Datemonth, datetest As String

Stype = WSRD.Range("B11")

'Find complex to work with
complexrow = WSSS.Range("F7")
On Error Resume Next 'next line will error if nothing is found
Set FindResult = WSSS.Range(WSSS.Cells(7, 15), WSSS.Cells(complexrow, 15)).Find(What:=Callsheet, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, MatchByte:=False)
On Error GoTo 0 'always re-activate error reporting!

If Not FindResult Is Nothing Then  'check if find was successful
    SearchresultROW = FindResult.Row
    Searchresult = WSSS.Cells(SearchresultROW, 15).Offset(0, 1)
Else  'if nothing was found show message
    MsgBox "NO WB FOUND.", vbCritical
End If

This solved the problem, thanks for the assistance Pᴇʜ

A: Your code without .Activate would look something like below. Note that every Range, Cells, Rows or Columns object needs to be referenced with the correct Workbook/Worksheet:
complexrow = WSSS.Range("F7")

'try to find something
Dim FindResult As Range
On Error Resume Next 'next line will error if nothing is found
Set FindResult = WSSS.Cells(complexrow, 15).Find(What:=Callsheet, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, MatchByte:=False)
On Error GoTo 0 'always re-activate error reporting!

If Not FindResult Is Nothing Then  'check if find was successful
    SearchresultROW = WSSS.Range(WSSS.Cells(7, 15), FindResult).Row
    Searchresult = WSSS.Cells(SearchresultROW, 15).Offset(0, 1)
Else  'if nothing was found show message
    MsgBox "nothing found.", vbCritical
End If

Note that if using the Range.Find method you need to check if something was found before you can use the result of Find. Otherwise it will throw an error. Also note that the documentation of Find says that …

The settings for LookIn, LookAt, SearchOrder, and MatchByte are saved each time you use this method.

So if you don't define them each time using Find it will use whatever was used last by either VBA or the user interface. Since you have no control about what was used last by the user interface I highly recomment to define them everytime using Find or you will get random results.
Also note that Callsheet is not defined in your code yet, so check that.


text:
Q: How do you publish an Access 2013 DB to a local website? My computer is Windows 7 Pro.  I have IIS 7 installed and running.  I've created a new site under port 81 called "access"
I have Access 2013.  I'm just testing using the basic Asset Tracking template.  I give my app a name "test" and my web location is http://localhost:81.
When I try to create the app, I get the message:
An error occurred while attempting to connect to the server http://locahost:81.  Check spelling of the server name.
HTTP Status Code:  404
I can browse to the local URL.  I have a default.htm file in the root folder of the website and I can clearly see what's in my htm file.  I know the web server is working.
What could be going on with my access app?  I couldn't find anything on google related to a local website - just stuff about publishing to SharePoint.

A: Just an IIS is not enough. You will need Sharepoint running locally if you want to save it locally. You can either save the Access App on OneDrive / OneDrive Business or a Sharepoint / Sharepoint Online Teamsite.
Here you can read more about the requirements.


text:
Q: TIBCO SPOTFIRE KPI i have a kpi depending on a property setting (check-box). Then in the check-box list i have two different value: a, b (corresponding to the values in column propertycolumn).
Depending on this value i want to calculate a kpi value in this way: SUM of the amaunt with propertycolumn = DocumentProperty("property1") (a or b) / sum of the total amount (propertycolumn = a + propertycolumn =b).

*

*If i do: Data -> Limit data using expression [property1 column]=DocumentProperty("property1")
i can sum only on the filterd values. I.e

*If i remove Limit data using expression i have two different KPIs (but i want only one kpi depending on the checkbox selected value).


text:
Q: rsync exclude folder contents but still create folder I have my application:
folder1
folder2
cache
     something_cached1
     something_cached2

now I want to rsync my project to the server
BUT
if I do
 --exclude=cache

the folder won't be existing in the server so, I will get an error from the application as it tries to write to a non existent location

A: quite simple I see,
just add:
--exclude 'cache/*'