text:
Q: What kind of sentence is "Do your work, John" I am having an arguement with my children about whether or not this is imperative.  It seemed to be, but then we found rules that imperative sentences must have "you" as the subject.  It doesn't appear to be declarative, and is decidedly not either of interrogative or an exclamation.  I have found mention of third party imperative, but I cannot tell if that is the correct description for it.

A: Normal Imperatives and Vocative Address
Yes, that's an imperative sentence whose implied subject is you.

[You] Do your work, John.

The John at the end is a vocative use, a noun of direct address, just like:

Your parents aren't home, John.

In neither case is John the subject, but in the first case the implicit you and John co-refer to the same person.
Third-person imperatives
The third-party imperative you mention is today most often done through  a periphrastic construction using let or may:

*

*Let your sister find him.

*May he never find her.

Formerly it was also possible to create third-person imperatives through a present subjunctive (now in form a bare, uninflected infinitive) as many of our neighboring languages still permit:

*

*God save the queen.

*Devil take the hindmost.

*God rest you merry gentlemen.

But even that familiar line from the carol goes on to a normal periphrastic imperative:

*

*Let nothing you dismay.

Meaning "Let nothing dismay you."
These frozen phrases are no longer productive in present day English, and their grammar is no longer apparent to most modern speakers, any more than is that of things like these:

*

*Till death us do part.

*Come Saturday morning, I'm going away with a friend.


text:
Q: Distance between the solutions of a polynomial I have a polynomial of degree six: $x^6+a_5x^5+a_4x^4+a_3x^3+a_2x^2+a_1x+a_0=0$ for which I know it will always have only two real roots and 4 complex.
The coefficients $a_5\ldots{a}_0$ will change, creating a family of this kind of polynomials. I can find their roots numerically (using Matlab).
Is there a way to evaluate the distance between the real roots (in an analytical form) ? I want to prove that this distance cannot be higher than a threshold.
Thank you.

redpajama_set_name: RedPajamaStackExchange


text:
Q: The Statusbar does not work with false headerShown I am using StatusBar it works fine but when I removed header from react-navigation it stops working. What am I doing wrong?
I am facing this issue on IOS.
<StatusBar barStyle="dark-content" backgroundColor={colors.ICE_BLUE} />
<Tab.Screen name="Wallet" component={WalletScreen} options={{ headerShown: false }} />

A: Use SafeAreaView Component in your WalletScreen.


text:
Q: How do I display customer specific information avoiding using xslt? My place of work currently maintains a website for several customers which is written using classic asp.  Each customer requires specific parts of the website to be written specifically to them.
For example, customer A requires an Address to be input, displayed and stored in the following format:
Address Line 1
Address Line 2
Address Line 3
Address Line 4
Address Line 5
Postcode

whereas customer B requires the Address to be input, displayed and stored as:
Street
Town
City
Postcode

and so forth...
Therefore, my place of work took the path of storing the data as xml in the database and using xsl (of which I currently know little) to transform the data to html.
So if we require information from the user via a html form, the xml is transformed using xsl.  The user then enters the information and submits the data via the form.  An asp page is then used to validate the data.  This asp page is specific to the xsl page used to display the form.  Therefore, we are now in a postion where for each customer we have many xsl pages and many customer specific asp pages (where much of the code is duplicated).
I have been asked to move the site over to asp.net mvc3 and to remove much of the duplication and was wondering what would be the best way to cater for this customer specific field functionality.  My preference would be to keep the data stored as xml as the database layer is accessed using com components which I would like to reuse without changing.
I have read that I could keep the xsl pages and develop an xslt view engine to display the html.  However, I am not sure how I would validate the data when the user submits the form?
What would be the best way to display customer specific fields if I was to remove the xsl completely?  Or would I have to have customer specific views and view models?
Any thoughts would be much appreciated.

A: If you really want to use MVC's built in validation / model functionality I think your best bet would be to use the XmlSerializer or use DataContracts to develop something that serializes to and from your XML (once its retrieved from the COM objects, so you don't need to re-code those), then you can use those classes as Models for MVC and use the standard data annotations for taking advantage of the richer MVC model functionality and skip the XSL step entirely.
To couple this with a custom specific view, what I typically do is override the default view engine to have one that actually will try names that are more specific to the customer/object and then fallback to a general one.
This view engine would allow you to pass a view to pass a view name (ie. FallbackViewEngine.BuildViewName("General", "Customer Name") and it would look for "General.Customer Name.cshtml" first and then "General.cshtml" as a fallback.  This way you can actually use customer specific views in your view folder.
public class FallbackViewEngine : RazorViewEngine
{
    const string NameSeparator = "==";
    const string FileSeparator = ".";

    public static string BuildViewName(string root, params string[] fallbackList)
    {
        if (string.IsNullOrWhiteSpace(root)) throw new ArgumentNullException("root");
        if (fallbackList == null) throw new ArgumentNullException("fallbackList");

        var sb = new StringBuilder(root);

        foreach (var s in fallbackList)
        {
            if (string.IsNullOrWhiteSpace(s)) continue;

            sb.Append(NameSeparator);
            sb.Append(s);
        }

        return sb.ToString();
    }

    public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
    {
        if (string.IsNullOrWhiteSpace(viewName)) throw new ArgumentNullException("viewName");

        var names = viewName.Split(new string[] {NameSeparator}, StringSplitOptions.None);

        var searched = new List<string>();

        //iterate from specific to general
        for (var i = names.Length; i >= 1; i--)
        {
            var result = base.FindView(controllerContext, string.Join(FileSeparator, names, 0, i), masterName, useCache);

            if (result.View != null)
            {
                return result;
            }
            else
            {
                searched.AddRange(result.SearchedLocations);
            }
        }

        return new ViewEngineResult(searched);
    }
}


text:
Q: Selenium chrome webdriver, Python. Translate webpage content Hello i am using selenium.webdriver.chrome in Python and doing some web scraping. I would like to translate website content from english to polish right before obtaining page source. I am aware of the options you can set up:
chrome_options = Options()
chrome_options.add_argument("--lang=pl")

But it isnt what I need. In chrome you can right click anytime and select "translate to ..." option. I am wondering is there any way to translate the content of the page in order to get scraped data already translated for you. Is it possible? And if so how could you do it?
To answear the question about where is the scraped data residing:
I am not sure if thats what you mean but basically when i am at the right page i am running this piece of code:
html_doc = driver.page_source
bs = soup(html_doc, 'html5lib')
tag = bs.find_all('div', attrs={'class':'location-meta-block'})
print(tag[1].text)

This is my output:
POLIN Muzeum Historii Zydow Polskich4,146 reviewsul. Mordechaja Anielewicza 6, Warsaw, Mazovia Province, Central Poland, Polandul. Mordechaja Anielewicza 6, Warsaw
I would like to translate the webpage content before running
html_doc = driver.page_source


text:
Q: SpringMVC: Variables in Annotations I have the following controller defined:
@Controller
@RequestMapping("/test")
public class MyController extends AbstractController
{

    @Autowired
    public MyController(@Qualifier("anotherController") AnotherController anotherController))
    {
     ...
    }

}

I'm wondering if it's possible to use variables in the @Qualifier annotation, so that I can inject different controllers for different .properties files, e.g.:
@Controller
@RequestMapping("/test")
public class MyController extends AbstractController
{

    @Autowired
    public MyController(@Qualifier("${awesomeController}") AnotherController anotherController))
    {
     ...
    }

}

Whenever I try I get:
org.springframework.beans.factory.NoSuchBeanDefinitionException:
No matching bean of type [com.example.MyController] found for dependency:
expected at least 1 bean which qualifies as autowire candidate for this
dependency. Dependency annotations:
{@org.springframework.beans.factory.annotation.Qualifier(value=${awesomeController})

I've included the following bean in my config.xml file:
<bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>classpath:config/application.properties</value>
        </list>
    </property>
</bean>

But the bean doesn't work unless I declare the bean explicitly in the xml file.
How do I do this with annotations??

A: First I think it is bad practice to make the dependency injection rely on configuration properties. You are probably going a wrong direction trying to do this.
However to answer your question: accessing placeHolder properties requires the dependency injection to be finished. To make sure it is, you can put your code that accesses the property inside a @PostContruct annotated method.
You will need to retrieve the bean manually from the applicationContext using getBean() method.
@Value("${awesomeController}")
private String myControllerName;

@PostConstruct
public void init(){
   AnotherController myController = (AnotherController) appContext.getBean(myControllerName);
}

A: I'm not sure if what you're doing is possible but I can suggest a slightly different approach,  but only if you're using Spring 3.1+. You could try using Spring Profiles.
Define the different controllers you want, one per profile:
<beans>
    <!-- Common bean definitions etc... -->

    <beans profile="a">
        <bean id="anotherController" class="...AnotherController" />
    </beans>

    <beans profile="b">
        <!-- Some other class/config here... -->
        <bean id="anotherController" class="...AnotherController"/>
    </beans>
</beans>

Your Controller would lose the @Qualifier and become something like:
@Autowired
public MyController(AnotherController anotherController) {
    ...
}

Then at runtime you can specify which controller bean you want to use by activating the corresponding profile using a system property, e.g.:
-Dspring.profiles.active="a"

or:
-Dspring.profiles.active="b"

It may be possible to set profiles based on a property file but you can find out more about Spring Profiles from this post on the Spring blog. I hope that helps somewhat.


text:
Q: Android rewriting to file creates new one I have a piece of code that creates a xml file:
File directory = new File(Environment.getExternalStorageDirectory() + File.separator + "android/data/com.travip");
directory.mkdirs();

FileOutputStream fos = new FileOutputStream(file);

XmlSerializer xmlSerializer = Xml.newSerializer();
StringWriter writer = new StringWriter();
xmlSerializer.setOutput(writer);
xmlSerializer.startDocument("UTF-8", true);
xmlSerializer.startTag(null, "trip");
xmlSerializer.attribute(null, "name", name);
xmlSerializer.attribute(null, "description", description);
xmlSerializer.attribute(null, "startdate", startdate);
xmlSerializer.attribute(null, "enddate", enddate);
xmlSerializer.endTag(null, "trip");
xmlSerializer.endDocument();
xmlSerializer.flush();
String dataWrite = writer.toString();
fos.write(dataWrite.getBytes());
fos.close();

SharedPreferences sharedpreferences;
SharedPreferences.Editor prefseditor;
sharedpreferences = context.getSharedPreferences("prefs", Context.MODE_PRIVATE);
prefseditor = sharedpreferences.edit();
prefseditor.putString("activeTrip", name);
prefseditor.apply();

This give me a files in the form of "name of the trip.trp". After this file is created, I want to edit it (add some nodes). This is the code:
File file = new File(Environment.getExternalStorageDirectory() + "/" + "android/data/com.travip/" + activeTrip + ".trp");
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(file);
Element root = document.getDocumentElement();
Element activities = document.createElement("activities");
if (root.getElementsByTagName("activities").getLength() == 0) {
    root.appendChild(activities);
    NodeList activitiesNodes = document.getElementsByTagName("activities");
    activities = (Element) activitiesNodes.item(0);
} else {
    NodeList activitiesNodes = document.getElementsByTagName("activities");
    activities = (Element) activitiesNodes.item(0);
}

Element activity = document.createElement("activity");

activity.setAttribute("name", name);
activity.setAttribute("latLng", latLng);
activity.setAttribute("date", date);
activity.setAttribute("time", time);

activities.appendChild(activity);
DOMSource source = new DOMSource(document);

TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
StreamResult result = new StreamResult(file);
transformer.transform(source, result);

But if the filename of the file (which is was edited) contain a space this space is replaced with %20. So now I have two files, one "name of the trip.trp" without the changes and one "name%20of%20the%20trip.trp" with the changes. How do I write these changes to the same file? Thanks for your help.

A: I found the issue:
Don't ask me why, but I had to replace
StreamResult result = new StreamResult(file);

with
StreamResult result = new StreamResult(new FileOutputStream(file));

I sound the soulution here


text:
Q: How do I access fields from a type parameter in Java? I have two classes X e Y with the same static members:
class B {
    public static final String Base = "Base";
}

class X extends B {
    public static final String First = "First A";
    public static final String Second = "Second A";
}

class Y extends B {
    public static final String First = "First B";
    public static final String Second = "Second B";
}

In another class, I need a function that will use one class or the other:
class C {
    public <Data> void f() {
        System.out.println("Operation " + Data.Base);
        System.out.println("Running " + Data.First);
        System.out.println("Running " + Data.Second);
    }
}

The idea is to use C as follows:
C c = new C();
if (whatever()) {
    c.f<X>();
} else {
    c.f<Y>();
}

But the code above is not valid, is there a way to achieve the desired behaviour in Java?

A: You'll need to declare non-static methods
    abstract class B {
        public static final String Base = "Base";
        public abstract String getFirst();
        public abstract String getSecond();
    }

    class X extends B {
        public static final String First = "First A";
        public static final String Second = "Second A";

        public String getFirst() { return First; }
        public String getSecond() { return Second; }
    }

    class Y extends B {
        public static final String First = "First B";
        public static final String Second = "Second B";

        public String getFirst() { return First; }
        public String getSecond() { return Second; }
    }

    class C {
        public void f(B b) {
            System.out.println("Operation " + B.Base);
            System.out.println("Running " + b.getFirst());
            System.out.println("Running " + b.getSecond());
        }
}

A: You are most likely came from C++ where templates can have implicit interfaces and checked by the compiler (probably bad wording, I'm not a C++ guy).
In Java, generic type parameters cannot be used in a static context, so static method calls of a Generic Type parameters are not possible with Java Generics.
Here is some reference from JLS:

It is a compile-time error to refer to a type parameter of a generic
  class C anywhere in:
the declaration of a static member of C (§8.3.1.1, §8.4.3.2, §8.5.1),
or
the declaration of a static member of any type declaration nested
  within C, or
a static initializer of C (§8.7), or
a static initializer of any class declaration nested within C.

A: No, you can't do that. The generic type parameter Data doesn't have any boundary so it could be anything. Besides that you can't use the type parameter like Data.Base etc.
What you could do: pass a Class<Data> to the method and use reflection to get the fields. That's not beautiful though, so you might want to rethink your requirements/approach.
Example (warning: use with care!):
<Data> void f(Class<Data> param ){
    printStaticFieldIfPresent( param, "Base" );
    printStaticFieldIfPresent( param, "First" );
    printStaticFieldIfPresent( param, "Second" );
}

void printStaticFieldIfPresent( Class<?> c, String fieldName ) {
   try {
     System.out.println(c.getField(fieldName).get(null));
   } catch( NoSuchFieldException e) {
     //ignore or log
   }
}

Your use case would then look like this:
C c = new C();
if (whatever()) {
   c.f(X.class);
} else {
  c.f(Y.class);
}

But yet again: you should revisit your design approach first. Java works differently from C++ and classes themselves are often no good option for "singletons" - you're almost always better of creating instances even if only one.

A: package exchange;

import org.apache.poi.ss.formula.functions.T;

import java.lang.reflect.Field;

/**
 * Created by huqingxin on 2018/1/24.
 */
public class TextModel {
    static class B {
        public static final String Base = "Base";
    }

    static class X extends B {
        public static final String First = "First A";
        public static final String Second = "Second A";
    }

    static class Y extends B {
        public static final String First = "First B";
        public static final String Second = "Second B";
    }

   static class C {
        public  void f(Class<? extends B> t) throws IllegalAccessException {
            Field[] declaredFields = t.getDeclaredFields();
            for (Field declaredField : declaredFields) {
                String name = declaredField.getName();
                String o = (String)declaredField.get(name);
                System.out.println(o);
            }

        }
    }

    public static void main(String[] args) throws IllegalAccessException {
        C c = new C();
        if (false) {
            c.f(X.class);
        } else {
            c.f(Y.class);
        }
    }
}

sorry,maybe like this?


text:
Q: É possivel criar dicionarios usando laços de reptição? Queria saber, se consigo criar uma dicionário usando laços de repetição.
Mas não quero criar um dicionário dentro de uma lista [{ }].
exemplo:
from random import randint
jog = dict()
for n in range(1, 5):
   jog['Numb'] = randint(0, 6)
print(jog)

A: Sim, é possível e o seu código já faz isso.
Porém, como comentado, pelo fato de você sempre atribuir à mesma chave no dicionário, você estará sempre sobrescrevendo o valor antigo. Desta forma, a sua saída sempre será algo como {'Numb': 6}, em que o valor 6, neste exemplo, foi definido aleatoriamente.
Se a ideia é armazenar todos os valores em chaves distintas, você poderia concatenar o valor de n, que é a sua variável de iteração, para gerar chaves únicas:
from random import randint
jog = dict()
for n in range(1, 5):
   jog[f'Numb-{n}'] = randint(0, 6)
print(jog)

Assim a saída seria algo como:
{'Numb-1': 1, 'Numb-2': 3, 'Numb-3': 1, 'Numb-4': 0}

Ainda, utilizando a sintaxe de dict comprehension, você pode simplificar em uma linha de código:
jog = {f'Numb-{n}': randint(0, 6) for n in range(1, 5)}

Produzindo um resultado equivalente.


text:
Q: Concat function in a coalesce I am trying to concat two fields in a materialised view. In the concat I also use a concat function. It looks like this.
   coalesce(
     concat(table1.city, '/' ,  REPLACE(table1.name,' ', '-')),
     concat(table2.city, '/' ,  REPLACE(table2.name,' ', '-'))
   ) as slug,

However this will always return the first item in the coalesce function since the slash '/' always returns true.
How can I make this work?


text:
Q: Have two exchange servers to communicate together We have Exchange Server 2007 using our domain ddd.com.
We created an isolated network with a firewall/gateway and installed a DC and Exchange Server 2010 using a demo/test domain (ddd.loc).
We opened all the needed ports in the firewall (10.10.2.88) to the Exchange Server 2010.
In our main Domain Controller (10.10.2.3) we defined the domain ddd.loc with IP 10.10.2.88 (firewalls). We also we defined MX records to the same IP (10.10.2.88)
We did that so when we send email from my email me@ddd.com it will go to the Exchange Server 2010.
Anyways, all the pings test from to any servers are OK.
But we are not able to send or receive emails. Between these Exchange Servers
we can not send any email from the 2010 to any email in general (emails are pending).
Also, in Exchange 2007 we are getting error #550 5.1.1 RESOLVER.ADR.RecipNotFound; not found ##

A: Dont completely understand the whole question but.
Sending an email to the 2010 exchange will entail you creating DNS pointer in you production DNS Server (e.g. your Domain Controller)

how to make it so that the 2010 will send email directly to the 2007

think you want to send email from the dddd.local through the 2007 server this will envolve routing the SMTP to 10.10.2.11 << Link explaining the process
You will though need to make sure your firewall is configured correctly
If you could phase the question better ill do my best to answer if the answers are not what you expected


text:
Q: Why is copying a list using a slice[:] faster than using the obvious way? Why is shallow-copying a list using a slice so much faster than using list builtin?
In [1]: x = range(10)

In [2]: timeit x_ = x[:]
10000000 loops, best of 3: 83.2 ns per loop

In [3]: timeit x_ = list(x)
10000000 loops, best of 3: 147 ns per loop

Usually when I see weird things like this, they're fixed in python3 - but this discrepancy is still there:
In [1]: x = list(range(10))

In [2]: timeit x_ = x[:]
10000000 loops, best of 3: 100 ns per loop

In [3]: timeit x_ = list(x)
10000000 loops, best of 3: 178 ns per loop

A: The difference is in additional function call (just SLICE+0 vs CALL_FUNCTION 1 with extra stack operations):
>>> import dis
>>> def f(lst):
...  return lst[:]
...
>>> def f1(lst):
...  return list(lst)
...
>>> dis.dis(f)
  2           0 LOAD_FAST                0 (lst)
              3 SLICE+0
              4 RETURN_VALUE
>>> dis.dis(f1)
  2           0 LOAD_GLOBAL              0 (list)
              3 LOAD_FAST                0 (lst)
              6 CALL_FUNCTION            1
              9 RETURN_VALUE

From dis docs:

SLICE+0()
  Implements TOS = TOS[:].

(TOS - top of stack)

CALL_FUNCTION(argc)
  Calls a function. The low byte of argc indicates
  the number of positional parameters, the high byte the number of
  keyword parameters. On the stack, the opcode finds the keyword
  parameters first. For each keyword argument, the value is on top of
  the key. Below the keyword parameters, the positional parameters are
  on the stack, with the right-most parameter on top. Below the
  parameters, the function object to call is on the stack. Pops all
  function arguments, and the function itself off the stack, and pushes
  the return value.


text:
Q: Is it possible that $f_X(x)\:f_Y(y) = g(x)\:h(y)$ where $f_X$ and $f_Y$ are valid PDFs and $g$ and $h$ are not valid PDFs? Suppose that the joint PDF $f_{X,Y}$ of X and Y factors into the marginal PDFs of $X$ and $Y$ $f_{X,Y}(x,y) = f_{X}(x)\:f_{Y}(y)$. Then is it possible for $f_{X,Y}$ to also factor as $f_{X,Y}(x,y) = g(x)\:h(y)$ where $g$ and $h$ are nonnegative functions and are not valid PDFs?

A: Sure. Take $g = \dfrac 1 \lambda f_X(x), h = \lambda f_Y(y)$, for some constant $\lambda > 0$ (other than $\lambda = 1$, of course).


text:
Q: Web development: Simulate iphone with a notch in the browser I am developing a website which I want to make compatible with the 'notched' iphone's (Iphone X, 11, etc..), but I am unable to find a tool to properly simulate how my website will look on these types of iPhone's.
For example, this footer with icons gets crossed by the bottom bar. This happens when the app is loaded as a PWA or when the 'bottom action menu' of the browser is collapsed.
There seems to be no solution other that loading the website on a phone.
These are the results from my research:

*

*Safari: Doesn't give an option to simulate the website on a notched iphone

*Chrome: There is an option to show the browser in the dimensions of the iphone X, but it does not simulate the notch or the bottom bar.

*Firefox: Doesn't give an option

A: I found a way to do this on a Mac.
Running /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator -CurrentDeviceID 8528838E-4B47-4F0E-B415-E87F8C8A6163 launches an iphone simulator with you can use to access localhost. You can also install the pwa on this simulator to see what it looks like.
Solution found in this article


text:
Q: Displaying the lowest and higher number in Java after User Input? How to to display the lowest and the higher number in Java? I know that I need use this variables: int max = Integer.MIN_VALUE;  int min = Integer.MIN_VALUE; But I can't get it to work. :/ Any help?
import java.util.Scanner;
public class LoopingNumbersUsingWhile {
public static void main(String args[]) {
    Scanner kb = new Scanner(System.in);

    System.out.println("How Many Numbers You Want To Enter: ");
    int total = kb.nextInt();
    int input = 0;
    int sum = 0;
    int average=0;
    int max = Integer.MIN_VALUE;
    int min = Integer.MIN_VALUE;
    while (input < total) {
        input++;

        System.out.println("Enter " + input + ". Operand: ");

                    sum += kb.nextInt();

   if (min >= sum)
  {
    min = sum;
  }
if (max <= sum)
  {
  max = sum;
  }

       average = ( sum ) / ( input);
    }
    System.out.println("The sum is " + sum + ".");
    System.out.println("The avg  " + average);
    System.out.println("The higher number  " + max);
    System.out.println("The the lowest number " + min);

   }
  }

A: You need to read the next number into a temporary variable then add it to sum.
int temp = kb.nextInt();
sum+=temp

and do these checks against your temporary variable.
if (min >= temp)
{
 min = temp;
}
if (max <= temp)
{
max = temp;
}


text:
Q: Google Maps Markers multiple users I have an application. The user can do a search (5 mi., 10, etc) and it'll show users who are using that app on the google map. I need help with deciding how to go about making the markers, links to users.

A: Making the marker is generally trivial.  Google has a number of complete examples you can study, like this one.
Basically you set up your map:
  var mapOptions = {
    zoom: 4,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

Then set up your coordinate(s):
 var myLatlng = new google.maps.LatLng(-25.363882,131.044922);

Then create and add your marker(s):
  var marker = new google.maps.Marker({
      position: myLatlng,
      map: map,
      title: 'Hello World!'
  });

Simple.  If you want to handle clicks on the marker (to do things like link to a user-details page), you do something like:
  google.maps.event.addListener(marker, 'click', function() {
    //<code to go to user's profile page>
  });

The more challenging problem in your case will be figuring out which coordinates to use for the markers.  That's a much more complicated answer.  The short version is, it depends.


text:
Q: Google Sheets - Conditional Formatting: Highlight cell that contains text found in list (dynamic list) I'm looking for help in finding the proper conditional formatting formula to highlight the cell if it contains a word found in a list I've made in another column. I'd like this list to be dynamic where I will add in more words in the future.
Example:
Column A (conditional formatting to apply)------------Column B (dynamic list)
2015 AUDI Q7 (*highlight)------------------------------------------------Transit
2021 HYUNDAI ELANTRA ---------------------------------------Rogue
2019 FORD ESCAPE -------------------------------------------Q7
2019 FORD TRANSIT VAN (*highlight) -------------------------------------etc, etc
2014 CADILLAC ESCALADE
2018 CHRYSLER PACIFICA
2019 NISSAN ROGUE SPORT (*highlight)
2018 JEEP GRAND CHEROKEE

So within Column A, I'd like for '2015 Audi Q7', '2019 Ford Transit Van', and '2019 Nissan Rogue Sport' to be highlighted because they contain a word found in the Column B list. And if I were to add to the list in the future, it should automatically highlight the cell in Column A if applicable (i.e. if I were to add 'Escalade' to the list, then '2014 Cadillac Escalade' in Column A would be highlighted).
Thanks!

A: Try:
=regexmatch(lower($A1),lower(textjoin("|",1,$B:$B)))

A: Adding answer for when the list is in another sheet.
You could make use of INDIRECT function. (assume the list is in B column)
=REGEXMATCH(LOWER($A1), LOWER(TEXTJOIN("|", 1, INDIRECT("Sheet2!$B:$B"))))

This will work inside Conditional Formating.


text:
Q: Hazelcast: how data is partitioned when using Cluster Groups? In the Hazelcast docs it is stated about Cluster Groups:

You can create cluster groups. To do this, use the group configuration element.
By specifying a group name and group password, you can separate your clusters in a simple way. Example groupings can be by development, production, test, app, etc. <...> Each Hazelcast instance can only participate in one group. Each Hazelcast instance only joins to its own group and does not interact with other groups.
<...>
The cluster members (nodes) and clients having the same group configuration (i.e., the same group name and password) forms a private cluster.
Each cluster will have its own group and it will not interfere with other clusters.

But there are no details about data partitioning.
If I have 5 nodes and 2 cluster groups:

*

*node1, node2 and node3 are members of GroupA

*node4 and node5 are members of GroupB

does it means that no data from GroupA will be stored at nodes4 and node5?

A: Yeah that's what it means. Those groups are independent clusters and have nothing in common (except maybe the network ;-)).
If you look for data partitioning, Hazelcast distributes information based on keys but you can have some kind of influence by utilizing data affinity (http://docs.hazelcast.org/docs/3.8/manual/html-single/index.html#data-affinity).
If you're looking for backup distribution you might be interested in partition groups (http://docs.hazelcast.org/docs/3.8/manual/html-single/index.html#partition-group-configuration).


text:
Q: How to convert JSON.stringify to java object to json? I have a html table that I am converting to json format and sending to my POST type server. Given below is the ajax call to send the data to the url.
$.ajax({
   url: "http://localhost:8090/DocVaccine",
   contentType: "application/json",
   type: 'POST',
   data: JSON.stringify(convertTableToJson()),
   success: function (data) {
       alert("DATA SENT");
   }
 });

On receiving the data, (which is in string format) i simply print to check its format.
 @RequestMapping(
        value = "/DocVaccine",
        method=RequestMethod.POST, headers = "Accept=*/*",
        produces = "application/json", consumes="application/json")
    public void UpdateVaccineCard(@RequestBody String p1) throws IOException
   {
        LOGGER.info(p1);
    }

this is the output i get. How do i convert this into java object?  I have a vaccine class which defines all the headers such as id, dueDate, dateGiven, etc. I need to convert this into proper json format to store into my mongo database.
 "[{\"id\":\"345678\",\"dueDate\":\"07-08-2019\",\"dateGiven\":\"07-02-2016\",\"vaccine\":\"BCG\",\"age\":\"Birth\",\"weight\":\"20\",\"heigth\":\"110\",\"placeName\":\"Hiranandani\",\"bmi\":\"0\"},
 {\"id\":\"345678\",\"dueDate\":\"08-08-2019\",\"dateGiven\":\"08-02-2016\",\"vaccine\":\"HepB\",\"age\":\"Birth\",\"weight\":\"20\",\"heigth\":\"110\",\"placeName\":\"Hiranandani\",\"bmi\":\"0\"},
 {\"id\":\"345678\",\"dueDate\":\"09-08-2019\",\"dateGiven\":\"09-02-2016\",\"vaccine\":\"Polio virus\",\"age\":\"Birth\",\"weight\":\"30\",\"heigth\":\"110\",\"placeName\":\"Hiranandani\",\"bmi\":\"0\"},
 {\"id\":\"345678\",\"dueDate\":\"10-08-2019\",\"dateGiven\":\"10-02-2016\",\"vaccine\":\"Hib\",\"age\":\"6 weeks\",\"weight\":\"30\",\"heigth\":\"110\",\"placeName\":\"Hiranandani\",\"bmi\":\"0\"},
 {\"id\":\"345678\",\"dueDate\":\"11-08-2019\",\"dateGiven\":\"11-02-2016\",\"vaccine\":\"PCV\",\"age\":\"6 weeks\",\"weight\":\"30\",\"heigth\":\"110\",\"placeName\":\"Hiranandani\",\"bmi\":\"0\"},
 {\"id\":\"345678\",\"dueDate\":\"12-08-2019\",\"dateGiven\":\"12-02-2016\",\"vaccine\":\"RV\",\"age\":\"6 weeks\",\"weight\":\"30\",\"heigth\":\"110\",\"placeName\":\"Hiranandani\",\"bmi\":\"0\"},
 {\"id\":\"345678\",\"dueDate\":\"13-08-2019\",\"dateGiven\":\"13-02-2016\",\"vaccine\":\"Typhoid\",\"age\":\"6 weeks\",\"weight\":\"30\",\"heigth\":\"110\",\"placeName\":\"Hiranandani\",\"bmi\":\"0\"},
 {\"id\":\"345678\",\"dueDate\":\"14-08-2019\",\"dateGiven\":\"14-02-216\",\"vaccine\":\"MMR\",\"age\":\"9 months\",\"weight\":\"30\",\"heigth\":\"110\",\"placeName\":\"Hiranandani\",\"bmi\":\"0\"},
 {\"id\":\"345678\",\"dueDate\":\"15-08-2019\",\"dateGiven\":\"15-02-2016\",\"vaccine\":\"Varicella\",\"age\":\"1\",\"weight\":\"30\",\"heigth\":\"110\",\"placeName\":\"Hiranandani\",\"bmi\":\"0\"},
 {\"id\":\"345678\",\"dueDate\":\"16-08-2019\",\"dateGiven\":\"16-02-2016\",\"vaccine\":\"HepA\",\"age\":\"1\",\"weight\":\"30\",\"heigth\":\"110\",\"placeName\":\"Hiranandani\",\"bmi\":\"0\"},
 {\"id\":\"345678\",\"dueDate\":\"17-08-2019\",\"dateGiven\":\"17-02-2016\",\"vaccine\":\"Tdap\",\"age\":\"7\",\"weight\":\"40\",\"heigth\":\"110\",\"placeName\":\"Hiranandani\",\"bmi\":\"0\"}}]"


text:
Q: Flat modules and non-vanishing of simple tensors Let $R$ be a noncommutative ring, and $M$ and $N$ be a right and a left $R$-module respectively. If $M$ or $N$ is projective, then
$$
0 \neq m \otimes n  \in M \otimes_R N, ~~~ \textrm{for all } n \in N, m \in M.
$$
Is this true is $M$ or $N$ are flat, or torsion free.


text:
Q: Safe design for SET SESSION AUTHORIZATION multi-user mod-perl2 connection caching I have a mod_perl2.0.4 / Apache2.2 web app running on CentOS 6.4 with PostgreSQL 9.0.
Until recently, I had this setup: Apache::DBI and DBI->connect_cached for all connections, which was starting to give FATAL: sorry, too many clients already even in my development area where I'm the only user.
In an effort to debug this, I have removed all references to Apache::DBI, upgraded to the latest DBI, and replaced all occurrences of connect_cached with plain DBI->connect.  It seems to me now that somewhat less connections are made and then left <IDLE>.  However, I realize that I haven't been calling disconnect() on all of my statement handles, because it had sounded like under Apache::DBI it wouldn't have made a difference.
My connections currently connect all as the same user, then lower their privileges based on which user it is via SET SESSION AUTHORIZATION.  I do it this way because some other apps that use the database allow for a passworded login, which can pass the credentials directly to the database, but this particular web app uses an honour system login screen whereby you just click your name to log in.  So it's future-security-ready but convenience-enabled at the moment.  Also, database triggers for history and such rely on the session user being set correctly to track who did what.
Because I was concerned about a database handle being reused with the wrong session user, I pass { private_user_login => $login_role_name, PrintError => 0, RaiseError => 1, AutoCommit => 1} to connect_cached to differentiate each connection by user.  But since I always set the session authorization immediately after connecting, I suppose that all the private_user_login hash does is make it so that for a given Apache process, there might be at least as many DB connections created and left idle as there are users, if eventually every user manages to randomly use a given Apache process.  Meanwhile, because I don't disconnect any handles, they eventually get used up.
My question is, is it safe to take out the private_user_login to make all the connection handles look the same, to cut down on the number of connections left open, or is it possible that a connection handle could be re-used in the middle of a script (after setting the session user) by a different user, thus creating a race condition?  Also, although Apache::DBI's docs say I needn't remove disconnect() calls, should I still have such a call at the end of every one of my scripts so that Apache::DBI can decide whether to disconnect?
In other words, without my private connection variable, do SET SESSION AUTHORIZATION's effects persist when the next Apache::DBI->connect() reuses the existing connection?  If so, is it ever possible that a connection is re-used by another request while one request is currently executing but not currently using the database handle?

A: I recommend a somewhat different tack, if you can.
Keep it simple in Apache. Use private sessions per user, if that's what's easiest to make safe and reliable.
Then put a PgBouncer between the PostgreSQL server and your Apache instance. Set it to transaction pooling mode. It'll happily multiplex your connections, and it'll take care of calling DISCARD ALL whenever a connection switches between users.
I think you can still use SET SESSION AUTHORIZATION on connections made via PgBouncer.

A: It seems safe.  To "verify" you can make an artificial race condition like this:
use Apache2::RequestUtil;
use Apache2::RequestRec;
my $r = Apache2::RequestUtil->request;
$r->headers_out->add('Cache-control' => "must-revalidate, no-cache, no-store");
require Apache2::Request;
my $req = Apache2::Request->new($r);
$r->content_type("text/html");
my $login_role_name = $req->param('u');
$r->print($u);
$r->print('<br>' . $$);
use DBI;

my $dbh = DBI->connect_cached("dbi:Pg:dbname=......,{ RaiseError => 1, AutoCommit => 1});
$dbh->do("set session authorization ?; ", undef, $login_role_name);
{
    use warnings NONFATAL => 'all';
    my $rows = $dbh->selectall_arrayref('select pg_backend_pid(), current_user::text');
    warn "pg ${$$rows[0]}[0] mp $$ auth: ${$$rows[0]}[1] original auth: $login_role_name";
    sleep 10;
    $rows = $dbh->selectall_arrayref('select pg_backend_pid(), current_user::text');
    warn "pg ${$$rows[0]}[0] mp $$ auth: ${$$rows[0]}[1] original auth: $login_role_name";
}

...and then hit it with two different '?u=...' URLs.  The auth will always match the original auth, because the dbh is not available to be given away while it's still in a script that's executing.


text:
Q: Firewall keeps setting an incoming connection to allow for com.google.Chrome.helper despite being set to block A few months ago, I made this post, asking why the allow or deny dialogue was appearing every time chrome was opened. Everyone stated that this only happens every time an app is opened if it's self signing, so the OS needs to ask everytime. After a bit of experimentation, I narrowed down the culprit to the Privacy Badger extension, as this didn't occur if it was disabled. The dialogue window stopped about a month ago, just when an update was released, so I assumed this had addressed the problem.
However, having just updated to Ventura today, I checked the firewall options, and it's now set to allow, where previously it was set to block, and never changed. Moreover, even setting it to allow, the dialogue always came up before.
Now, the dialogue still isn't appearing, but no matter how many times I change the setting to block, if I exit settings and go back in, it's set to allow again, for some reason. Any ideas what could be going on here? How is it changing back everytime?


text:
Q: VBA Dynamic Named Range as Listbox RowSource Error I have a dynamic named range that returns a list (array) of some values that are not assigned but once all values are assigned the list returns #N/A
Formula (Array):

=INDEX(EquipTable[Equip], MATCH(0,EquipTable[Flag],0), 1):INDEX(EquipTable[Equip],
  MATCH(0,EquipTable[Flag],0)+COUNTIF(EquipTable[Flag],0)-1, 1)

Problem is that I am using this Ranged named as a Listbox.RowSource and I can't find a way to check for the value of the named range or even to check whether its returns errors or not.
I used:
Application.WorksheetFunction.IsError(ActiveWorkbook.Names("UnassignedEquipment"))
But its always returning False
I also used:
IsEmpty(ActiveWorkbook.Names("UnassignedEquipment"))
and
IsError(ActiveWorkbook.Names("UnassignedEquipment"))

A: One way is to use IFERROR in the formula used for the named range so that if the named range doesn't return anything, it refers to a specific range/cell.
=IFERROR(INDEX(EquipTable[Equip], MATCH(0,EquipTable[Flag],0), 1):INDEX(EquipTable[Equip], MATCH(0,EquipTable[Flag],0)+COUNTIF(EquipTable[Flag],0)-1, 1),A1)

Here A1 is the cell which the named range would refer if nothing a valid range is not returned by the formula. Change A1 in the formula as per your requirement.


text:
Q: redux state is changing but component is not re-rendering I have problem with re-rendering component. Store is updating allright, but the component is no refreshing - don't know why. I
Here is reducer
const initialState = {
    actualCurrencies: [
        {
            id: "GBP",
            sell: null,
            buy: null
        }
    ]
}

        case "updateCurrencies":
        console.log(action.data);
            return {...state,
                actualCurrencies: [
                    {
                        id: "GBP",
                        sell: action.data[0].sell,
                        buy: action.data[0].buy
                    }
                ]
            }

What is wrong with that? I guess that is problem with mutable but why? I'm using spred operation sow it suppose to work.

A: That's my connect component with store
    export default connect(state =>
    ({
        currencies: state.auth.currencies,
        money: state.auth.money
    }),
    { updateCurrencies }
)(BodyLogIn);

I used that in another component, but without array and it's working. Do i need to have some code into render that react know that something changed?


text:
Q: Exporting PPT presentation to PDF from Excel VBA I am trying to export PPT presentation to PDF format from Excel VBA. In code below, I constantly receive Type Mismatch error when attepmting to use ExportAsFixedFormat. Why? Please see the code below
Option Explicit
Private Const ppSaveAsPDF As Long = 2
Private Const ppSaveAsDefault As Long = 11
Private Const ppSaveAsPresentation As Long = 1

Private Const ppFixedFormatTypePDF As Long = 2
Private Const ppFixedFormatIntentPrint As Long = 2
Private Const msoTrue As Long = -1
Private Const ppPrintHandoutHorizontalFirst As Long = 2
Private Const ppPrintOutputType As Long = 2
Private Const ppPrintOutputFourSlideHandouts As Long = 8
Private Const ppPrintOutputTwoSlideHandouts As Long = 2
Sub My_PowerPointToPDF()

Dim oPowerPointApp As Object
Dim oPPT As Object
Dim sPowerPointSourceFileName As String
Dim sPowerPointDestFileName As String

sPowerPointSourceFileName = "C:\Users\xxx\Documents\PPTX 2 PDF Button.pptm"
sPowerPointDestFileName = "C:\Users\xxx\Documents\test.pdf"

On Error Resume Next       'Will error on GetObject if not already open
Set oPowerPointApp = GetObject(, "PowerPoint.Application")
On Error GoTo 0

If oPowerPointApp Is Nothing Then   'If Nothing then GetObject failed because PowerPoint not already open.
    Set oPowerPointApp = CreateObject("PowerPoint.Application")
End If

oPowerPointApp.Visible = True
Set oPPT = oPowerPointApp.Presentations.Open(sPowerPointSourceFileName)

'Line below creates "Type mismatch" error. Why?
oPPT.ExportAsFixedFormat Path:=sPowerPointDestFileName, FixedFormatType:=ppFixedFormatTypePDF

oPPT.Close
oPowerPointApp.Quit

End Sub

A: This appears to be a bug or error in the PowerPoint documentation for ExportAsFixedFormat. PrintRange is not optional. You can fix the error by adding a parameter of PrintRange:=Nothing.
I had the same issue and this answer clued me in to the solution: https://stackoverflow.com/a/32995017/3541707


text:
Q: Is there a way not to generate controller specs by default? I'm a fan of Rspec, but I never use either controller or view specs. I know the following options exist:
Usage:
  rails generate controller NAME [action action] [options]

Rspec options:
  [--controller-specs], [--no-controller-specs]  # Indicates when to generate controller specs
                                                 # Default: true
  [--view-specs], [--no-view-specs]              # Indicates when to generate view specs
                                                 # Default: true

But is there a way for Rspec to skip on generating these by default? I don't want to be typing --no-controller-specs --no-view-specs every time I generate a controller for instance.
How can I disable spec generation by default? (while keeping some others, eg. models)

A: I think you can configure it in application.rb like this:
config.generators do |g|
  g.test_framework :rspec,
    fixtures: true,
    view_specs: false,
    helper_specs: true,
    routing_specs: false,
    controller_specs: false,
    request_specs: true
end


text:
Q: Implementation of Mapping a single key to multiple values using hashmap I have a list of tag_ids configured with the test_id_val in a table.I retrieve the Data using the following query
Select test_id_val , tag_id from p_details

For a straightforward case i would rather use a hash map to store key value pair and retrieve the data,But in my case the test_id_val can accept null values
For ex consider the following structure :
 1. APP TR202
 2. APP TR204
 3. APP TR205
 4.NULL TR206
 5.NULL TR207
 6.NULL SM504
 7.NULL SM505

So i will be having a list of tag_ids values to map to a test_id key which can either be null or contain values.My requirement is to map the test_id key to the list of tag_ids
Is there a specific way to do this?
Thanks for the help and time..

A: You might consider using some implementation of com.google.common.collect.Multimap.
You can put multiple values associated with one key and then retrieve them as a collection with the map.get(key) method. In your case:
Multimap<String, String> mmap = HashMultimap.create();

mmap.put("APP", "TR202");
mmap.put("APP", "TR204");
mmap.put("APP", "TR205");
mmap.put(null, "TR206");
mmap.put(null, "TR207");
mmap.put(null, "SM504");
mmap.put(null, "SM505");

for (String key : mmap.keySet()) {
  for (String value : mmap.get(key)) {
    System.out.println(key + ": " + value);
  }
}

Prints:
null: SM505
null: SM504
null: TR207
null: TR206
APP: TR202
APP: TR205
APP: TR204

A: You can use ArrayList to store the test_id_val. Then in HashMap, store tag_id as a key and index of ArrayList to test_id_val as a value of HashMap. ArrayList allows a null value so you can easily store the null value of specific tag_id. Like this..
KEY     VALUE               ArrayList
TR202     1                 1-->  APP
TR204     2                 2-->  APP
TR205     3                 3-->  APP
TR206     4                 4-->  NULL
TR207     5                 5-->  NULL

A: You might want to reconsider if this really is the best database schema design you have, but if you choose to stick with it, create a wrapper class for test_id_val in which you specify if you really mean null via a boolean:
private class TestIdVal {
    String test_id_val;
    boolean isNull;
}

You can then instantiate new TestIdVal() objects to use as keys for the map. I don't recommend using a list of tag_id as the key, as that doesn't seem to mirror your schema correctly. It seems that you're trying to do test_id_val => List of tag_id.


text:
Q: How does AlarmManager.AlarmClockInfo's PendingIntent work? I am trying to use AlarmManager.AlarmClockInfo to set an alarm.
The constructor to this takes the time and a PendingIntent which is described in the docs as:

an intent that can be used to show or edit details of the alarm clock.

and then setAlarmClock( ) also takes in a pending intent which is described in the docs as:

Action to perform when the alarm goes off

I understand the use of the PendingIntent by setAlarmClock( ), however, how is the PendingIntent used by AlarmClockInfo and how do I use it to edit the details of the alarm clock?

A:
however, how is the PendingIntent used by AlarmClockInfo and how do I use it to edit the details of the alarm clock?

Quoting myself from this book:

The biggest issue with setAlarmClock() is that it is visible to the
  user:

*

*The user will see the alarm clock icon in their status bar, as if
  they had set an alarm with their device's built-in alarm clock app

*The user will see the time of the alarm when they fully slide open
  their notification shade

*

*Tapping on the alarm time in the notification shade will invoke
  the PendingIntent that you put into the AlarmClockInfo object

So, given this code...:
  static void scheduleAlarms(Context ctxt) {
    AlarmManager mgr=
      (AlarmManager)ctxt.getSystemService(Context.ALARM_SERVICE);
    Intent i=new Intent(ctxt, PollReceiver.class);
    PendingIntent pi=PendingIntent.getBroadcast(ctxt, 0, i, 0);
    Intent i2=new Intent(ctxt, EventDemoActivity.class);
    PendingIntent pi2=PendingIntent.getActivity(ctxt, 0, i2, 0);

    AlarmManager.AlarmClockInfo ac=
      new AlarmManager.AlarmClockInfo(System.currentTimeMillis()+PERIOD,
        pi2);

    mgr.setAlarmClock(ac, pi);
  }

(from this sample project)
...when the user taps on the time in the notification shade, EventDemoActivity will appear. The idea is that you should supply an activity here that allows the user to cancel or reschedule this alarm.


text:
Q: Telling sendmail to auth? I've been sitting here for a few hours now attempting to get sendmail to send the emails through an external SMTP server. I've gotten very close, but now I'm completely stuck. It seems that sendmail isn't sending the authentication information I've set. Is there some configuration line I'm missing?
Please help. :(
Running CentOS 5.7
EDIT:
As requested, I'll add a few things from my sendmail here.
Where I've specified to use auth information:
FEATURE(authinfo',hash -o /etc/mail/auth/client-info.db')dnl
/etc/mail/auth/client-info:
AuthInfo:in.mailjet.com "U:myusername" "P:mypassword" "M:PLAIN"
Attempting to send an email:
# sendmail -AM -t -v
to:myemail@gmail.com
from:root@mydomain.com
.
myemail@gmail.com... Connecting to in6.mailjet.com. via relay...
220 in6.mailjet.com ESMTP Mailjet
>>> EHLO mydomain.com
250-in6.mailjet.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN DIGEST-MD5 CRAM-MD5
250-AUTH=PLAIN LOGIN DIGEST-MD5 CRAM-MD5
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
>>> STARTTLS
220 2.0.0 Ready to start TLS
>>> EHLO mydomain.com
250-in6.mailjet.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN DIGEST-MD5 CRAM-MD5
250-AUTH=PLAIN LOGIN DIGEST-MD5 CRAM-MD5
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
>>> MAIL From:<root@mydomain.com> SIZE=37
250 2.1.0 Ok
>>> RCPT To:<myemail@gmail.com>
>>> DATA
554 5.7.1 <myemail@gmail.com>: Relay access denied
554 5.5.1 Error: no valid recipients
>>> RSET
250 2.0.0 Ok
/root/dead.letter... Saved message in /root/dead.letter
Closing connection to in6.mailjet.com.
>>> QUIT
221 2.0.0 Bye

A: i had the same issue. Finally made it with several configurations.
/etc/mail/sendmail.mc
    define('SMART_HOST','smtp.yourdomain.com')dnl
    define('confAUTH_OPTIONS','A')dnl
    FEATURE('authinfo','hash -o /etc/mail/authinfo.db')dnl
    MASQUERADE_AS('yourdomain.com')dnl
    FEATURE(masquerade_envelope)dnl
    FEATURE(masquerade_entire_domain)dnl
    MASQUERADE_DOMAIN('yourdomain.com.')dnl
    FEATURE('relay_based_on_MX')dnl
    FEATURE('genericstable')dnl
    GENERICS_DOMAIN('localhost.localdomain')dnl

/etc/mail/authinfo (660 permissions)
    Authinfo:yourdomain.com "U:yoursmtpuserid" "P:yourpassword" "M:PLAIN"
    Authinfo: "U:yoursmtpuserid" "P:yourpassword" "M:PLAIN"

>makemap hash /etc/mail/authinfo < /etc/mail/authinfo

/etc/mail/access (660 permissions)
    connect:localhost.localdomain RELAY
    connect:localhost RELAY
    connect:127.0.0.1 RELAY

>makemap hash /etc/mail/access < /etc/mail/access

/etc/genericstable
    root youruseremail@yourdomain.com

>makemap hash /etc/mail/genericstable < /etc/mail/genericstable

/etc/named.conf
    options{
          listen-on port 53 {127.0.0.1;};
    };

>cp -f /etc/named.conf /var/named/chroot/etc/

/etc/resolve.conf
    nameserver  127.0.0.1
    nameserver  youriplocal
    domain      localdomain

>chkconfig -> named on
          -> saslauthd on
          -> sendmail on

>service named restart
>service saslauthd restart
>service sendmail restart

To test it you can execute:

sendmail -Am -t -v to:emaildestination from:youremail

I hope it works for you.

A: My short configuration in sendmail.mc for SMTP Auth as a client for mailjet.com :
include(`/etc/mail/sasl/sasl.m4')dnl
define(`SMART_HOST', `[in-v3.mailjet.com]')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl

587 because port 25 is blocked.
STARTTLS and ESMTP are now automaticely in Sendmail.
Before, libsasl2-modules (in addition to the not necessary libsasl2-modules-db) and sasl2-bin must be installed. Thinks to switch to START=yes in /etc/defa
ult/saslauthd (in debian)
In access:
AuthInfo:mailjet.com "U:5xxxxx" "P:f6xxxxxx" "M:LOGIN PLAIN DIGEST-MD5 CRAM-MD5"

And finally, run /usr/share/sendmail/update_auth.
So, there are only 2 files to modify sendmail.mc and access.
After of course, make in /etc/mail then service sendmail restart.
ps: A lot of tutorial, add :587 after AuthInfo:mailjet.com, it's AMHA an error. A debug -d60.5 (different lookup map) it's my prove.

A: For sendmail, I usually manage SMTP auth by adding an entry in /etc/mail/access. A quick example for your setup is here:
# /etc/mail/access
# by default we allow relaying from localhost...
localhost.localdomain           RELAY
localhost                       RELAY
127.0.0.1                       RELAY
AuthInfo:in.mailjet.com "U:smmsp" "I:myusername" "P:mypassword" "M:PLAIN"

Save that and restart the sendmail daemon, /sbin/service sendmail restart.

A: Did you run:
makemap hash client-info < client-info

Unless you build the client-info.db file from the text one using the command above, the information that is in there, is not read by sendmail
EDIT #1:
From the bat book I copy that:

When sendmail connects to another host, and that other host offers to
  authenticate, that connected-to host's IP address, hostname, and
  domain are looked up in the database.
If the IP address, host, or domain is not found, the connection is
  allowed, but sendmail will not attempt to authenticate it. Otherwise,
  the information in the matching right column is returned for sendmail
  to use.

You are connecting to in6.mailjet.com which is an MX for in.mailjet.com. So maybe you have to change your AuthInfo: line to:
AuthInfo:mailjet.com "U:myusername" "P:mypassword" "M:PLAIN"

EDIT #2:
You seem to have a minor typo in the FEATURE(authinfo) declaration:
FEATURE(`authinfo', `hash -o /etc/mail/auth/client-info.db')dnl

A: Remove -o (optional) from feature authinfo and restart/reload sendmail. It will make sendmail refuse to start without access to authinfo map/file.
FEATURE(`authinfo',`hash ...')

Repeat sending you test email with tracking map lookups (includes tracking authinfo map lookups)
sendmail -d60.5 -AM -t -v

Does sendmail look for authinfo entries? [The answear should narrow list of possible problems]


text:
Q: Bezout in $\mathbb C [x,y]$ Let $f_1, f_2 \dots, f_r \in \mathbb C [x,y]$ and suppose $$\gcd(f_1, \dots , f_r)=1$$
Show that $V(f_1, \dots , f_r) \subset \mathbb A^2$ is finite.
Partial Solution: suppose $(x_0,y_0) \in V(p(x,y),q(x,y))$, then for $(x,y_0)$ we can use Bezout and say that exist $a(x),b(x),h(x) \in \mathbb C [x]$ such that $$ a(x)p(x,y_0) + b(x)q(x,y_0)=h(x)$$
So there are finite $x_i \in \mathbb C$ such that $(x_i,y_0)\in V(p(x,y),q(x,y))$. The same holds for $(x_0,y)$.

A: You're on the right track in using Bézout's identity.  Suppose $f, g \in \mathbb{C}[x,y]$ with $\gcd(f, g) = 1$.  Now, $\mathbb{C}[x,y]$ is not a Euclidean domain, but $\mathbb{C}(x)[y]$ is.  By Bézout's identity, then there exist $a,b \in \mathbb{C}(x)[y]$ such that $af + bg = 1$.  Writing
$$
a(x,y) = \frac{a_1(x,y)}{a_2(x)} \quad \text{and} \quad b(x,y) = \frac{b_1(x,y)}{b_2(x)}
$$
then
\begin{align*}
1 &= af + bg = \frac{a_1(x,y)}{a_2(x)} f(x,y) + \frac{b_1(x,y)}{b_2(x)} g(x,y)
\end{align*}
and clearing denominators yields
$$
b_2(x)a_1(x,y) f(x,y) + a_2(x)b_1(x,y)g(x,y) = a_2(x) b_2(x) \, .
$$
Since $a_2, b_2 \in \mathbb{C}[x]$ are polynomials in one variable, they have only finitely many zeroes.  This shows that there are only finitely many possibilities for $x_0$ in a point $(x_0, y_0) \in \mathbb{V}(f,g)$.  Exchanging the roles of $x$ and $y$, the same argument shows there are only finitely many possibilities for $y_0$.


text:
Q: Filling a table in SQL - the fill is just stopping every time it reaches to a random number Filling a table in SQL with C# - the fill is just stopping every time it reaches to a random number. it seems like in a random iteration the random that changes the value of val2 just decides that he doesn't want to change himself.
public static void GenerateLicenseTable()
{
    string[] array = new string[3];
    Random rnd = new Random();
    string tableName = "license_per_state";
    string colsNames = "state_id" + "," + "license_id" + "," + "from_age";
    string values;

    for (int i = 1; i <= 50; i++)
    {
        //array = new string[3];
        Array.Clear(array, 0, array.Length - 1);

        for (int j = 0; j < 3; j++)
        {
            string val1 = i.ToString();
            string val2 = rnd.Next(1, 7).ToString();
            array[j] = val2;

            for(int k = 0; k < j; k++)
            {
                if(array[k] == val2)
                {
                    val2 = rnd.Next(1, 7).ToString();
                }
            }

            string val3 = rnd.Next(16, 22).ToString();
            values = val1 + "," + val2 + "," + val3;
            RanDAL.Instance.NaiveInsertInto(tableName, colsNames, values);
        }
    }
}


text:
Q: Angular : Unable to upload file using web API I want to upload a file on form submit, but its not posting on web API.
And save file in a local physical path using Web API.
Here I am trying to send file using FormData and trying to access the same in api call using HttpContext.Current.Request.Files but its giving 0 count.
Html :
<form [formGroup]="employeeForm" (ngSubmit)="save()" #formDir="ngForm" novalidate style="position:relative;" enctype="multipart/form-data">
  <div>
 <input class="form-control" type="text" formControlName="Name">
        <input type="file" id="FileUploader" (change)="onFileChange($event)" #fileInput accept=".pdf,.doc,.docx,.png">
        <button type="button" class="btn btn-sm btn-default" (click)="clearFile()">clear file</button>
      </div>
</form>

Component :
myFiles: string[] = [];
  form: FormGroup;
  loading: boolean = false;
  @ViewChild('fileInput') fileInput: ElementRef;

onFileChange(e) {
  for (var i = 0; i < e.target.files.length; i++) {
    this.myFiles.push(e.target.files[i]);
   }
  }
save() {
   const frmData = new FormData();
  for (var i = 0; i < this.myFiles.length; i++) {
    frmData.append("fileUpload", this.myFiles[i]);
  }
      this._employeeService.saveEmployee(this.employeeForm.value, frmData)
        .subscribe((data) => {
          this._router.navigate(['/fetch-employee']);
        }, error => this.errorMessage = error)
    }

Service :
saveEmployee(employee, myFile): Observable<any> {
    return this._http.post(this.myAppUrl + 'api/Employee/Create', employee, myFile);
  }

Web API :
 public int Create([FromBody] TblEmployee employee)
            {
System.Web.HttpFileCollection hfc = System.Web.HttpContext.Current.Request.Files;
            // CHECK THE FILE COUNT.
            for (int iCnt = 0; iCnt <= hfc.Count - 1; iCnt++)
            {
                System.Web.HttpPostedFile hpf = hfc[iCnt];
                if (hpf.ContentLength > 0)
                {
                    // CHECK IF THE SELECTED FILE(S) ALREADY EXISTS IN FOLDER. (AVOID DUPLICATE)
                    if (!File.Exists(sPath + Path.GetFileName(hpf.FileName)))
                    {
                        // SAVE THE FILES IN THE FOLDER.
                        hpf.SaveAs(sPath + Path.GetFileName(hpf.FileName));
                        iUploadedCnt = iUploadedCnt + 1;
                    }
                }
            }
                return objemployee.AddEmployee(employee, myFile);
            }
     public partial class TblEmployee
        {
            public int EmployeeId { get; set; }
            public string Name { get; set; }
        }

I am following this link.


text:
Q: Zend Framwork crashed when newrelic was enabled I created a new ZF1 application (1.12.0) with zf tool like this:
zf create project test
I then enabled the layout as follow:
zf enable layout
And when I enabled newrelic I got this error:
PHP Error:
Uncaught exception 'Zend_Layout_Exception' with message 'Invalid method 'getmodulename' called on layout action helper' /usr/local/zend/share/ZendFramework/library/Zend/Layout/Controller/Action/Helper/Layout.php : 184

A: The way in which New Relic names Zend transactions is to hook into Zend_Controller_Plugin_Broker::routeShutdown() and look at various methods in the single argument that that function receives, which is the request. That parameter is supposed to be a class that has several methods: getModuleName(), getControllerName(), and getActionName(). The PHP agent expects to be able to call all of those functions on the request.
If you have highly customized your Zend framework installation, you may need to resort to naming your transaction manually. In this case, in your PHP INI file set newrelic.framework = "none" and at an appropriate place in your router, call newrelic_name_transaction(). You may be able to avoid this by determining why your request object does not have those standard functions.
One possible reason that this may occur is because you have an incomplete overloaded plugin router.
More information on this API call as well as others can be found in the New Relic KB:
https://newrelic.com/docs/php/new-relic-for-php


text:
Q: mv: cannot open shared object file "libstdc++.so.6": too big nesting of symbolic links The error might be a bit different than the one from the topic- I was translating it from my native language.
After everything failed, I tried doing as mjp pointed in this post:
GLIBCXX_3.4.20 not found, how to fix this error?
But as a result every command- apt-get, mv, cp returns the error from the topic title. I cannot go back to the backup version of the file.
At the moment I can't even log into Ubuntu. I got lopped inside the login screen. Everytime I try to login, screen gets black and I get back to login. I can only use the comand via ctrl+alt+F3
What should I do?
Answer for steeldriver (please look at the comment):
lrwxrwxrwx 1 root root 40 Jun 17 21:37 /usr/lib/x86_64-linux-gnu/libstdc++.so.6 -> /usr/lib/x86_64-linux-gnu/libstdc++.so.6

-rw-r--r-- 1 root root 979056 May 7 2016 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.19

lrwxrwrwx 1 root root 19 May 7 2016 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.old -> libstdc++.so.6.0.19

A: [I must admit I'm a bit puzzled why basic utilities like mv or cp would break because of libstdc++.so.6, however asssuming that's the reason, here's what I would try]
Your busybox ls output indicates that you have managed to recursively link /usr/lib/x86_64-linux-gnu/libstdc++.so.6 to itself. Thankfully, it appears that you have not deleted or overwritten the actual /usr/lib/x86_64-linux-gnu/libstdc++.so.6.19 library. So you should be able to recover by re-creating the symbolic link.
The gotcha will be if either sudo or ln or both rely on the libstdc++ library. (Presumably bash doesn't, since you are able to login with a shell at the Ctrl+Alt+F3 virtual terminal.)
If sudo is broken, then you should still be able to boot into a root shell from recovery mode, as described in How do I boot into a root shell?. You will then need to remount the root filesystem in read-write mode
mount -o remount,rw /

After that, you can attempt to fix the broken link
ln -sf libstdc++.so.6.19 /usr/lib/x86_64-linux-gnu/libstdc++.so.6

(this should create a relative symlink that is resolved relative to the target path /usr/lib/x86_64-linux-gnu/, similar to your .old link).
Assuming that fails because ln depends on libstdc++.so, you can try again using the statically-linked busybox executable, which has a built-in ln:
/bin/busybox ln -sf libstdc++.so.6.19 /usr/lib/x86_64-linux-gnu/libstdc++.so.6

If that works, you can exit the root shell to proceed with the normal boot.


text:
Q: google api for glorious info box? I'm guessing this info is privileged since I couldn't find anything on Google's listed APIs.  In fact I'd be amazed if it wasn't proprietary securely fastened Google magic, but thought I'd ask anyway.
Is there an Google API for the information appearing when you do a basic search for say an Actress or Rockband?  You know the box that appears to the right of the results if google figures out exactly what you're looking for. (I'm specifically interested in musicians despite the example below)
I.e.
https://www.google.com/search?q=woody+allen

I can get similar milage using Freebase, but Google's is always better.  For example, It'll even pull upcoming events if it's a Musician, etc.

A: The Freebase Topic API contains the bulk of what you're looking for.
e.g. https://www.googleapis.com/freebase/v1/topic/en/woody_allen


text:
Q: ActionBar not being created even with min SDK version set to 11 I have my min SDK version set to 11 and my target SDK version set to 11. I have an activity with some fragments in it. The style has parent="@android:style/Theme.Light" and doesn't hide the actionbar. In the activity where I expect to see the actionbar, I have an override of onCreateOptionsMenu(). My understanding is that onCreateOptionsMenu() will automatically be called when the activity starts and that will create the actionbar. This is not happening for me. I'm not sure if my understanding is wrong or if I'm doing something wrong that is causing it not to show up.
To be clear, my onCreateOptionsMenu method is not even firing. I suspect the problem is in another part of the code, but I don't know what it could be.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.signin_layout_menu, menu);
    return true;
}

Here is my menu xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/menu_signin_layout"
         android:title="stuff"
         android:showAsAction="ifRoom|withText" />
</menu>

Here is the style that activity is using:
<style name="Theme.MyTheme" parent="@android:style/Theme.Light">
    <!-- Window attributes -->
    <item name="android:windowTitleSize">36dip</item>
    <item name="android:windowTitleStyle">@style/WindowTitle</item>
    <item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground</item>

    <item name="android:textAppearanceButton">@style/TextAppearance.Widget.Button</item>

    <!-- Button styles -->
    <item name="android:buttonStyle">@style/Widget.Button</item>
</style>

A: I'm pretty sure your theme needs to be parent="@android:style/Theme.Holo.Light" for the actionbar to show.

A: Are you inflating the menu and returning "true", to indicate that you've handle the action, correctly in your onCreateOptionsMenu() override? http://developer.android.com/guide/topics/ui/menus.html#Inflating
If you're returning false, the event will bubble up to the parent, which by default does nothing.


text:
Q: Rewrite rule htaccess to ignore everything after last slash I always have a single file per folder named test.* (* = jpg, png, video file etc) which is stored in different sizes as following
https://www.example.com/images/1500/01/100/test.jpg
https://www.example.com/images/1500/01/500/test.jpg
https://www.example.com/images/1500/01/900/test.jpg
https://www.example.com/images/1500/01/1800/test.jpg
I would like to create a rule in htaccess which will allow me to load the different files using a link.
As an example for the first image I would like to be able to load the file using the following links:
https://www.example.com/images/1500/01/100
https://www.example.com/images/1500/01/100/
https://www.example.com/images/1500/01/100/whatever
https://www.example.com/images/1500/01/100/somethingelse
The logic would be to always load the file which will always be named test however without calling it test in the link and in addition be allowed to write anything behind the trailing slash.
Is it possible using plain htaccess. I was trying with the following however it does not give the result I am looking for:
RewriteEngine On
RewriteRule ^images/(.*)/([^/]+) images/$1/$2/test.jpg

A: If you have a hierarchy of 3 folders deep, and they are all numeric you can do something like this:
RewriteEngine On
RewriteRule ^images/([0-9]+)/([0-9]+)/([0-9]+).+?$ images/$1/$2/$3/test.jpg [L]

This will match
https://www.example.com/images/1500/01/100
https://www.example.com/images/1500/01/100/
https://www.example.com/images/1500/01/100/whatever
https://www.example.com/images/1500/01/100/somethingelse

If they are not always numeric:
RewriteEngine On
RewriteRule ^images/([^/]+)/([^/]+)/([^/]+).+?$ images/$1/$2/$3/test.jpg [L]


text:
Q: How to add a custom link in YouTube description? Just as here:
https://www.youtube.com/watch?v=CUxH_rWSI1k
I know that "http://..." link becomes clickable but in the example above it is totally different. And... awesome.
UPD. This IS NOT a question about how to make a link to specific time of YouTube video.

A: It appears that if you just type the timecode you want, like 01:12 into the description field, it will make that a link to that time in the video.

A: What you see there are shortened links, via https://goo.gl/
You can not link some text with an url in a video description in Youtube.

A: The links in the youtube description you shared used the "shortened URL" service by google. To do this, go to "https://goo.gl" and put in the destination URL you want to shorten, them choose "Shorten URL". This will generate a shortened URL of the original link.
There are other services like that on the internet where you can also choose a customized or an alias shortened hyperlink, using your own text. A popular one is https://tinyurl.com/

A: It is very simple. Just type the time point in this format
x:xx or xx:xx
It will become a hyper-link to a specific time point as you given. That's a great for long music albums to select each soundtrack included. Watch an example as follows;
Sinhala Songs MP3 List ► Play Jukebox
https://www.youtube.com/watch?v=u0Ji7XDTo3Q


text:
Q: Animating Textfield Of Cell Using FRC I have a table view that uses an FRC. Whenever the table view is updated by the FRC, I would like the following behavior...
Insert Cell
The cell shows up like normal. However, the text does not all appear at once. It shows up one character at a time with a ~0.1 second delay between characters.
Edit Cell
The text does not change from old -> new right away, but rather one character at a time (again, a ~0.1 second delay between each character change).

I have already written an algorithm that can handle making the minimum changes to the text field. However, I have no idea how to implement any of this into the table view & FRC.
Any ideas?


text:
Q: Why is conductivity defined as the inverse of resistivity? I've been wondering: why is the electrical conductivity of a given material defined as the inverse of its electrical resistivity? In other words, why is
$$ \sigma \equiv \frac{1}{\rho}~?$$
It indeed makes sense to define a number called conductivity such that, when the resistivity of the material decreases, the conductivity increases. However, there are a bunch of functions for which this property holds. So why aren't the following as convenient as the definition given above?
$$ \sigma = \frac{1}{\rho^2} $$
$$ \sigma = - \rho $$
In fact, every decreasing function on $\rho$ could be used here. What is it that makes $\frac{1}{\rho}$ so special and unique?

A: Resistivity relates to resistance in the same way that conductivity relates to conductance.
$$R = \rho\frac{l}{A}  ~~~~~~~~  G = \sigma\frac{A}{l} $$
so
$$ \sigma = \frac{1}{\rho} ~~~~~~~~ G=\frac{1}{R} $$
Now, if we consider...
$$ V = IR $$
$$ \frac{V}{R} = I $$
$$ I = VG $$
It's handy because it relates current to voltage in the same way that the canonical form of Ohms law relates voltage to current.
Voltage is current times resistance (R).
Current is voltage times conductance (G).
The other quantities you might imagine to express (like negative resistivity, the square of resistivity, etc) do not have such useful properties, so we do not use them and do not give them names.

A: In my experience this comes from resistance and conductance in electrical engineering and circuit theory. If you use the loop current analysis method on a circuit of resistors and sources then you get a matrix of linear equations whose coefficients are resistances. If you use the node voltage method on the same circuit you get a matrix whose coefficients are inverse resistances.
So the inverse of resistance shows up very often quite naturally in circuit equations, rather than the negative of resistance or the inverse of resistance squared. Because it shows up naturally it makes sense to give the inverse of resistance a name.
Usually when you run into some quantity that is defined and you are unsure why, that quantity first simply showed up in some important formula. So people needed a way to discuss that part of that formula, and so they gave it a name. But the quantity showed up on its own in the math first and was given a name later.

A: The usual definition matches up with calculations with parallel resistors. For example, the total resistance of two parallel resistors is
$$\frac{1}{R} = \frac{1}{R_1} + \frac{1}{R_2}.$$
If the resistors have the same size and shape, then this can be written in terms of their resistivity like so:
$$\frac{1}{R} = \frac{A}{L}\left(\frac{1}{\rho_1} + \frac{1}{\rho_2}\right),$$
where $A$ is the cross-sectional area and $L$ is the length of the resistor. In terms of conductance and conductivity, we can write this equation as
$$G = \frac{A}{L}\left(\sigma_1 + \sigma_2\right).$$
In fact, just looking at conductance, the equation for a set of parallel resistors is much more intuitive:
$$G = \sum_i G_i$$
as opposed to the usual
$$\frac{1}{R} = \sum_i \frac{1}{R_i}.$$
The total conductance of a set of parallel resistors is equal to the sum of the conductance of all the resistors. This nicely parallels the case of resistors in series:
$$R = \sum_i R_i$$
where the total resistance is the sum of the resistances of each resistor.
Using conductance and conductivity can be useful when trying to calculate the total resistance of a material whose resistivity varies across its geometry. See this question and this answer for an example.

A: In terms of circuits/situations where Ohm's law is obeyed, this is a definition and is physically consistent. As conductivity increases, resistivity decreases. Similarly, as conductivity decreases, resistivity increases. The product of resistivity and conductivity is 1.

It indeed makes sense to define a number called conductivity such that, when the resistivity of the material decreases, the conductivity increases.

That is exactly what the equation
$\sigma = \frac{1}{\rho}$
means.

However, there are a bunch of functions for which this property holds.

No, there is not.

$\sigma = \frac{1}{\rho^2}$

This would imply that incresing the resistivity by two would decrease the conductivity by $\frac{1}{4}$ but increasing the conductivity by two would decrease the resistivity by $\frac{1}{\sqrt{2}}$. Why would nature have such an asymmetry?

$\sigma = - \rho$

This would imply that any resistivity would produce a negative conductivity. What would be the physical  meaning of negative conductivity?

A: The Ohm's law for a conductive material can be expressed locally as a linear relationship between the current density $\boldsymbol{J}$ and the electric field $\boldsymbol{E}$. For an isotropic material, this relationship can take either of the two equivalent forms: $\boldsymbol{J} = \sigma \boldsymbol{E}$ or $\boldsymbol{E} = \rho \boldsymbol{J}$. For these two forms to be really equivalent for a specific material, the relation $\sigma = 1/\rho$ should hold.
In the case of an anisotropic material, current density and electric field are no longer parallel and the above relationships take the forms $\boldsymbol{J} = \boldsymbol{\sigma} \boldsymbol{E}$ or $\boldsymbol{E} = \boldsymbol{\rho} \boldsymbol{J}$, where now $\boldsymbol{\sigma}$ and $\boldsymbol{\rho}$ are matrices related by $\boldsymbol{\sigma} = \boldsymbol{\rho}^{-1}$.
Therefore, you cannot choose an arbitrary relationship between $\sigma$ and $\rho$, for otherwise you would lose one of the two equivalent relationships between the fields.

A: Ohm's law can be written as $I = V*\frac 1 R$. Given that we're multiplying $V$ by $\frac 1 R$, what is mysterious about the fact that people find it useful to define a quantity equal to this expression $\frac 1 R$ that can be multiplied with voltage to get current?
If there's anything mysterious, it's why conductivity is defined in terms of resistance, rather than resistance in terms of conductivity. Current is driven by voltage drop. Conductivity is a measure of the extent to which this occurs.
The reason that conductivity is the multiplicative inverse of resistance is because current, voltage, and resistance are related through multiplication.

It indeed makes sense to define a number called conductivity such that, when the resistivity of the material decreases, the conductivity increases.

...
Does it?
It makes sense to define conductivity, and as a result of defining conductivity, we end up with something that has the property of decreasing as resistance increases, but I don't see any reason to have something that decreases as resistance increases, as a goal in and of itself.

A: You cannot simply pick any decreasing function; it has to be one that works both for the number and the units. For example $-\log{ρ}$ is for sure a decreasing function, but $-\log{(1\text{Ωm})}$ makes no sense. There are quantities defined using logarithms on ratios, but for that you have to pick a base level, and each is as good as any other, so such a function isn't so simple and independent anymore.
$-ρ$ won't work for another similar reason – it has the same dimension (and hence unit) as $ρ$. This means that an expression like $ρ+σ$ would be well defined, and in this case equal to 0, which again makes no sense. This is what people tried to avoid with units.
The way units work leaves us with nothing but powers, and $ρ^{-1}$ is the simplest there. Plus it is an inverse, so it works both ways.

A: What's the resistance of a 10 ohm and a 20 ohm resistor in series? Easy: 10+20 = 30 ohms.
What if the same resistors are in parallel? That's erm...let me get calculator...
$$ \left({1\over 10} + {1 \over 20}\right)^{-1} = 6.67\:\Omega $$
Now what's the conductance of 0.05 siemens in parallel with 0.1 siemens? No calculator required: 0.05+0.1 = 0.15 siemens.
Thus, conductance is convenient whenever dealing with parallel circuits, among other things.
This isn't the only example: you'll find many electrical terms come in duals for the same reasons. For example when applying Thévenin's theorem you'll find it most convenient to think about voltage sources and resistance, but for Norton's theorem you'll want current sources and conductance. When analyzing nontrivial circuits you'll probably convert between the two several times, as that's easier than wrangling an equation that disappears into microscopic text as in:
$$ 1\over...{1\over...{1\over...{1\over ...}}}$$
Another consideration: an ohm is dimensionally equivalent to volt per ampere, whereas siemens is ampere per volt. The physical utility of these units should be pretty obvious when you have some material that obeys Ohm's law. I'm not sure the same could be said of the other possible definitions you propose.


text:
Q: How to deploy a java applet for today's browsers (applet, embed, object)? How do i deploy a java applet for modern browsers?
I know there are somehow 3 possibilities but nobody tells me which one to prefer and how to use them.
Does somebody have any resources on that? i cant find any :(

A: Use deployJava.js -- even if you AREN'T targeting only 1.6 and above.
I've been using it for more than a year, with applets that still support even the MSJVM (Java 1.1).
There are plenty of features that aren't available in the script for older JREs, but it's still quite useful!

A: Well, be aware that deployJava.js is designed to be called at document load time. So if you insert applet dynamically, upon an event, after DOM has been constructed, you're kinda out of luck with this new standard approach.
We had to use the object/embed/noembed construct.
Edit: Oh, someone found a better way for this, but this required manual altering of SUN's original deployJava.js, please see the link below:
Java Plug-In - Important addition to deployJava.js

A: If you can target Java 6 update 10 or better, you can simplify your life:
<script src="http://java.com/js/deployJava.js"></script>
<script>
    var attributes = {codebase:'http://java.sun.com/products/plugin/1.5.0/demos/jfc/Java2D',
                      code:'java2d.Java2DemoApplet.class',
                      archive:'Java2Demo.jar',
                      width:710, height:540} ;
    var parameters = {fontSize:16} ;
    var version = '1.6' ;
    deployJava.runApplet(attributes, parameters, version);
</script>

A: There is a section in The Java Tutorials titled Using applet, object and embed Tags which addresses the issue.
From the General Considerations:

Deploying Applets on the Internet Versus an Intranet
When deploying applets:

*

*Use the applet tag if the Web
  page is accessed through the Internet.

*Use the object or embed tag if the Web page is accessed through an
  Intranet.

  Deploying Applets for Specific
  Browsers
When deploying applets:

*

*For Internet Explorer only, use the
  object tag.

*For the Mozilla
  family of browsers only, use the
  embed tag.

  If you must deploy an applet in a mixed-browser environment, follow the guidelines in the section Deploying Applets in a Mixed-Browser Environment.

It should be noted that the applet tag has been deprecated, so it's probably not desirable to use that tag. (More information on the applet tag from the W3C)
(Note: Links have been updated from the previous edit to link to The Java Tutorials.)

A: You might consider using Java Web Start instead of an applet if you are making an application. Applets are used only if are creating something that has to be shown in a browser.

A: deployJava.js has many serious lacks.
Read my write-up on deployJava.js on Oracles Java-forum.
I would love to start an open source project on this, but I have no experience on starting or doing anything open source.   Anybody care to help me get one started?
(Preferrably on BitBucket using Mercurial.)
If so, comment on this, and contact me directly.

A: The below should work cross browser:-
<p>
<object type="application/x-java-applet"
    name="accessName" width="300" height="200">
    <param name="code" value="className" />
    <param name="archive" value="jarName.jar" />
    <param name="scriptable" value="true" />
    <param name="mayscript" value="true" />
</object>
</p>

In my tests both IE8 and FF5 required the "type" attribute. Any object classid attribute caused Firefox to fail. The mayscript param will be ignored by Java plugins after 1.6.0.10. The scriptable param is still required according to javadocs 1.6.0.21. In a test with 1.6.0.24 for a signed applet, IE8 called it OK from JS without scriptable being set true.


text:
Q: How can I find all number entries in a file I have file with a section that looks like this:
report from:PCAT1.DB   created at:2019-06-27 14:32:24   generated at:2019-06-27 14:35:10

number of campaigns:466

unique assets:950   downloaded assets:920   deleted assets:0   total assets: 922

What I am attempting to do is identify the numbers alongside certain headings. I.E. I want the unique assets and the total assets and then put them into a dictionary or list.
below is some code I have been using but it is picking up all numbers that have at least 3 digits so I am also getting the time/date values as well which I don't want.

assets = []

with open("C://AdSmart Results//Rack_54//cdb_report2.html") as adsmart:
    for line in adsmart.readlines():
        if re.search(r'assets:\d{3}', line):
            assets.append(line)

print(assets)

The assets dictionary should end up populated with the type of asset and the corresponding values:
assets = { "Unique Assets": "950", "Total Assets": "922"}

As ever, all help and guidance is greatly appreciated. Apologies if this is a duplicate of a question that I have managed to miss in my searches.

A: My guess is that you might want to design an expression with two capturing groups, maybe similar to:
(?i)\b([a-z][a-z\s]+\bassets?)\s*:\s*(\d+)

and you can likely add more boundaries.
Test
import re

regex = r"(?i)\b([a-z][a-z\s]+\bassets?)\s*:\s*(\d+)"

test_str = """
report from:PCAT1.DB   created at:2019-06-27 14:32:24   generated at:2019-06-27 14:35:10

number of campaigns:466

unique assets:950   downloaded assets:920   deleted assets:0   total assets: 922

report from:PCAT1.DB   created at:2019-06-27 14:32:24   generated at:2019-06-27 14:35:10

number of campaigns:466

unique assets:950   downloaded assets:920   deleted assets:0   total assets: 922

"""

print(dict(re.findall(regex, test_str)))

Output
{'unique assets': '950', 'downloaded assets': '920', 'deleted assets': '0', 'total assets': '922'}

If you wish to explore/simplify/modify the expression, it's been
  explained on the top right panel of
  regex101.com. If you'd like, you
  can also watch in this
  link, how it would match
  against some sample inputs.

RegEx Circuit
jex.im visualizes regular expressions:

A: Here is a variant of the code that works as I think you wanted:
import re

assets = {}

with open("C://AdSmart Results//Rack_54//cdb_report2.html") as adsmart:
    for line in adsmart.readlines():
        for match in re.finditer(r'(\w+ assets):\s*(\d+)', line):
            assets[match.group(1)] = int(match.group(2))

print(assets)

What changed:

*

*You have more than one figure per line, so you need to iterate over the matches in each line. So I changed the if re.search(...) to for match in re.finditer(...). Whereas re.search returns a Match object for the first match found (if any), re.finditer returns every match object. Then we can loop over that.

*The regular expression (\w+ assets) matches a word, then a space, then the word "assets"

*I didn't understand whether you only want 3-digit numbers, but that's what \d{3} is. It's the same as \d\d\d. I changed it to \d+, meaning "one or more digits".

*The parentheses in the regular expression are capturing groups. So for each Match object, match.group(1) is the text that matched the regex inside the first pair of parentheses, match.group(2) is the second, etc.

*I changed assets from a list to a dict, since that's what you show in your desired output. Then we can map the asset type (match.group(1)) to the count (int(match.group(2))).
This is the output I get:
{'unique assets': 950, 'downloaded assets': 920, 'deleted assets': 0, 'total assets': 922}


text:
Q: Convert php regex to javascript exclude first 150 characters I don't want to capture the first 150 characters and then capture everything else.
/(?<=\A.{150})(.*)/g

this is the expression I wrote in PHP but I need to do it in JavaScript and I cant work around not having lookbehind
this is javascript regex that I wrote
/(?:.*)(?!.{150})/g

A: You're overthinking it.
The pattern you want is /^.{150}(.*)/, and then you pull out the contents of capture group 1. And, for added fun, this pattern will work equally well in just about every engine under the sun, because it uses only basic token types and quantifiers.
Demo on Regex101

A: You don't need lookarounds for this
^.{150}(.+)

is all you need. https://regex101.com/r/P7keW9/1


text:
Q: Java Thread - Make a clock and own clock So I'm starting to get really interested about Threads and how it works, Kinda amazing how it works but I just learned about it today and trying to make a program to work. So im trying to make a clock that gives me in a Jlabel a current clock which is right now and a Textfield where I enter the time by myself. so what I want to do is it should start by showing me the time, when pressing the button "Set time" it should change the time as I entered and go from there as a clock.
So my problem right now is that whenever I press the Set time now it changes for a second and then turn back to the current clock again. and I don't really know how to stop the first thread when pressing Set time (Which starts the second Thread)
However I think this is kinda simple but fun to work with,
EDIT: I Also found out that I will have a problem by counting when entering a own "clock". My code:
 public Clock() {
            initialize();
            Thread1();

        }

    .......

JButton btnSetTime = new JButton("Set time");
            btnSetTime.setBounds(474, 262, 89, 23);
            frame.getContentPane().add(btnSetTime);
            btnSetTime.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    if(e.getSource() == btnSetTime) {
                        Thread2();

                    }

                }
            });
        }

        public void Thread2() {
            Thread t2 = new Thread() {
                public void run() {
                    try {
                        for(;;) {
                            int hour = Integer.parseInt(tfhour.getText());
                            int minute = Integer.parseInt(tfminute.getText());
                            int second = Integer.parseInt(tfsecond.getText());

                            lblKlockan.setText(hour + ":" + minute + ":" + second);
                            sleep(1000);
                        }
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            };t2.start();
        }

        public void Thread1() {
            Thread t1 = new Thread() {
                public void run() {
                    try {
                        for(;;) {
                            Calendar cal = Calendar.getInstance();
                            int hour = cal.get(Calendar.HOUR_OF_DAY);
                            int minute = cal.get(Calendar.MINUTE);
                            int second = cal.get(Calendar.SECOND);

                            lblKlockan.setText(hour + ":" + minute + ":" + second);
                            sleep(1000);
                        }
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            };t1.start();
        }
    }

So as I can see, the int hour = Integer.parseInt(tfhour.getText()); will probably not count as a Clock if I change to my own clock later on if i'm right? In that case, How can I fix it?
I hope I have all my problems out here in the post and I hope anyone here is willing to help me aswell :)
EDIT:
To make it easier to see:
EDIT PART 3:0

A: You have to define a global variable to stop the thread 1, when the thread 2 starts. Here is an example,
//define a variable that controls the thread 1
static boolean clockSet = false;

Now thread 1 is written such as it runs only when the clockSet is false, that is clock not set by a click.
  Thread t1 = new Thread(){
        public void run(){
           while(!clockSet){
            Calendar cal = Calendar.getInstance();
                int hour = cal.get(Calendar.HOUR_OF_DAY);
                int minute = cal.get(Calendar.MINUTE);
                int second = cal.get(Calendar.SECOND);
               lblKlockan.setText(hour + ":" + minute + ":" + second);
               try {
              sleep(1000);
            } catch (InterruptedException e) {
                    e.printStackTrace();
            }
        }
    }
   };

In your thread 2, set the clockSet to true, so the thread 1 will stop. I see you are just displaying the value entered, but not setting those on a Calendar object. So create a Calendar object in thread 2, set the user defined values, and increment the time after every second of sleep.
Thread t2 = new Thread(){
    public void run(){
        clockSet = true;
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(tfhour.getText()));
        cal.set(Calendar.MINUTE, Integer.parseInt(tfminute.getText()));
        cal.set(Calendar.SECOND, Integer.parseInt(tfsecond.getText()));
        while(true){
                int hour = cal.get(Calendar.HOUR_OF_DAY);
                int minute = cal.get(Calendar.MINUTE);
                int second = cal.get(Calendar.SECOND);
               lblKlockan.setText(hour + ":" + minute + ":" + second);
               try {
            sleep(1000);
            cal.add(Calendar.SECOND, 1);
        } catch (InterruptedException e) {
            e.printStackTrace();}
      }
     }
   };

Have fun..!

A: Sure, you see the code
try {
                        for(;;) {
                            int hour = Integer.parseInt(tfhour.getText());//this one
                            int minute = Integer.parseInt(tfminute.getText());//and this one
                            int second = Integer.parseInt(tfsecond.getText());//and this too

                            lblKlockan.setText(hour + ":" + minute + ":" + second);
                            sleep(1000);
                        }

you are setting hour, minute & second each and every time inside the for loop. So the clock is reseting.
Make them to get initialize only once, i.e. take them out of the loop.

Further this code
for(;;) {
                            Calendar cal = Calendar.getInstance();
                            int hour = cal.get(Calendar.HOUR_OF_DAY);
                            int minute = cal.get(Calendar.MINUTE);
                            int second = cal.get(Calendar.SECOND);

                            lblKlockan.setText(hour + ":" + minute + ":" + second);
                            sleep(1000);
                        }

is making your timer work as clock and not a timer because after 1 sec. the hour, minute & second are set to the values according to the time you get from Calendar.
Due to this your code will work as a clock that show the current time.

A: In my opinion you don't need the second thread at all. What I would do in this case is create three Int fields, hour-, minute- and second-offset, which you change when the button is pressed to, for example, hourOffset =  Calendar.HOUR_OF_DAY - Integer.parseInt(tfhour.getText())%24; (example for the hours). Than you just need to add the offset to the time in thread1, which allways works since you start with 0 as offset.


text:
Q: css: show div when another div is hover I've got 2 divs. Div A and Div B. If Div A is hovered, then I need show Div B. Can this be achieved with pure css only? Or if I do it in query, how do i go about with this base on the assumption that we cannot use id for these 2 divs.
Thanks

A: Please note that I've used element ids in these examples to identify which, specific, elements are used. In place of ids you could use almost any other CSS-selector, the important thing is the relationships between the selected elements; in the first example I've used the adjacent-sibling selector, and in the latter the descendant selector.
If you post your mark-up, and notify me with a comment, I'll try and revise the selectors to match what you're working with. Otherwise this is just a generic best-guess. And they're not always that useful...
That said, the answers appear below:
If you've got super-simple mark-up then this can be accomplished via CSS:
#divB {
    display: none;
}

#divA:hover + #divB {
    display:  block;
}

    Some content in 'divA'

    Some content in 'divB'

JS Fiddle demo. Or:
#divB {
    display: none;
}

#divA:hover #divB {
    display:  block;
}

    Some content in 'divA'

        Some content in 'divB'

JS Fiddle demo.

A: Assuming the two divs are contained in a div:
http://jsfiddle.net/4p8CM/1/
#container > div {
    display: none
}
#container > div:first-child {
    display: block
}
#container > div:hover + div {
    display: block
}

A

B

The :first-child stuff is to work around this limitation that you set:

base on the assumption that we cannot
  use id for these 2 divs

If you want the second div to stay visible when you hover over it, try this:
http://jsfiddle.net/4p8CM/3/
#container > div {
    display: none
}
#container > div:first-child {
    display: block
}
#container:hover > div {
    display: block
}

A: If you add a container to div A and div B you can do it very easy in this way:

A

B

http://jsfiddle.net/royshoa/bzhz8pou/