text:
Q: Fail to 'git pull' using LibGit2Sharp I have the following piece of code, that is meant to pull changes from the current branch:
    public static void Main(string[] args)
    {
        var repo = new Repository(args[0]);
        var signaure = repo.Config.BuildSignature(DateTimeOffset.Now);
        var pullResult = Commands.Pull(repo, signaure, new PullOptions());
    }

I get this exception when I run this:
 public static void Main(string[] args)
Exception occured: LibGit2Sharp.LibGit2SharpException: request failed with status code: 401
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
   at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
   at LibGit2Sharp.Core.Proxy.git_remote_fetch(RemoteHandle remote, IEnumerable`1 refSpecs, GitFetchOptions fetchOptions, String logMessage)
   at LibGit2Sharp.Commands.Fetch(Repository repository, String remote, IEnumerable`1 refspecs, FetchOptions options, String logMessage)
   at LibGit2Sharp.Commands.Pull(Repository repository, Signature merger, PullOptions options)

I tried to search online, couldn't figure out how to solve this (most of the results used an outdated API). If I simple type "git pull" in cmd (from the repo folder) it works. Any help?


text:
Q: Changing color components in Java Is there a way to change the individual color components in Java graphics programming (apart from the brighter() and darker() methods? For example, if I create a Color object with r,g,b color components and then wish to modify one of them is there a way to do so?
Color x = new Color(255,0,0);

Is there a way to quickly change one of the individual color components?

A: You can't actually change an existent Color object. To have a different one, you have to create a another Color object because the object is always defined by the constructor values. This is also how darker() and brighter() are internally implemented. Take a look
public Color brighter() {
    int r = getRed();
    int g = getGreen();
    int b = getBlue();
    int alpha = getAlpha();

    /* From 2D group:
     * 1. black.brighter() should return grey
     * 2. applying brighter to blue will always return blue, brighter
     * 3. non pure color (non zero rgb) will eventually return white
     */
    int i = (int)(1.0/(1.0-FACTOR));
    if ( r == 0 && g == 0 && b == 0) {
        return new Color(i, i, i, alpha);
    }
    if ( r > 0 && r < i ) r = i;
    if ( g > 0 && g < i ) g = i;
    if ( b > 0 && b < i ) b = i;

    return new Color(Math.min((int)(r/FACTOR), 255),
                     Math.min((int)(g/FACTOR), 255),
                     Math.min((int)(b/FACTOR), 255),
                     alpha);
}

and
public Color darker() {
    return new Color(Math.max((int)(getRed()  *FACTOR), 0),
                     Math.max((int)(getGreen()*FACTOR), 0),
                     Math.max((int)(getBlue() *FACTOR), 0),
                     getAlpha());
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Test OpenStreetMap with selenium webdriver (java) How to Test OpenStreetMap with selenium webdriver (java)
for example :
test buttons as routes, distance calculation and zoom.
i have try this code but any why, it impossible to click on the button iténaires.
tnks for your help !!
code :
WebDriver driver = new ChromeDriver();
driver.get("https://www.openstreetmap.org/#map=5/46.483/4.468");
Thread.sleep(3000);

WebElement button = driver.findElement(By.xpath("//img[@class='button']"));
button.click();


text:
Q: How long an Azure' web role can stay active? My cloud application (web role) uploads over 5000 records into SQL Azure.
The total time for this process takes about 15-19 minutes on my development machine.
Once, I deploy to the Cloud and try again, it fails after 10 - 12 minutes without any error message.
My guess is that the web role times out after certain period of time. Is there a setting for this?

A: Your webrole doesn't time out.
SQL Azure can time out and also your connection can be killed.
Some reasons for Connection Termination:

*

*Sessions consuming greater than one million locks are terminated.

*Transactions with a log file size > 1 GB are terminated.

*The distance from the first or oldest active transaction log sequence number (LSN) to the tail of the log (current LSN) cannot exceed 20% of the size of the log file.

*If a transaction locks a resource required by an underlying system operation for more than 20 seconds, it is terminated.

*When a session uses more than 5 GB of tempdb space (= 655,360 pages), the session is terminated.

*When there is memory contention, sessions consuming greater than 16-megabyte (MB) for more than 20 seconds are terminated in the descending order of time the resource has been held, such as the oldest session is terminated first.

*A database will be read-only when it reaches its maximum database size. Transactions attempting to updates or inserts will be terminated when this happens.

http://social.technet.microsoft.com/wiki/contents/articles/sql-azure-connection-management-in-sql-azure.aspx#Reasons

A: May I suggest you page your upload? Even if it's just to build the record set in memory (cache/queue/table/blob store rather) and then execute against SQL.
At the very least it'll allow you to isolate where the issue is.


text:
Q: react-native splash screen setup I tried many different plugins and instruction to do splash screen but I get error when I change or try to setup android-manifest or my splash screen style, can anyone help me with step by step exactly to setup a splash screen or a video as tutorial please?
I tried such the below links but   I got errors when I run-android
https://android.jlelse.eu/change-splash-screen-in-react-native-android-app-d3f99ac1ebd1#.saf96u3bp
Note: I want over android

A: 1> use the module react-native-smart-splash-screen install it on your project
2>In the file MainActivity.java update the code as
import com.reactnativecomponent.splashscreen.RCTSplashScreen;
import android.os.Bundle;
import android.content.Intent;
in the onCreate method delete the method and copy the code below

@Override
protected void onCreate(Bundle savedInstanceState) {
RCTSplashScreen.openSplashScreen(this);
super.onCreate(savedInstanceState);
}

in the MainApplication.java file
import com.reactnativecomponent.splashscreen.RCTSplashScreenPackage;

replace the getPackages() method with the following

     @Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
        new VectorIconsPackage(),
        new MapsPackage(),
        new RCTSplashScreenPackage()
  );
}

now In your landing page in react native app
 import SplashScreen from 'react-native-smart-splash-screen'

in the lifecycle method componentWillMount() add the following as:

  componentDidMount(){
   SplashScreen.close(SplashScreen.animationType.scale, 2000, 800)
 }

if there is some problem visit this repo
https://github.com/UjjwalNepal/Dental
https://github.com/react-native-component/react-native-smart-splash-screen
add the dependencies as mentioned in the link above in gradle settings as well and add the dependency in android/app/build.gradle
as mentioned in the link above


text:
Q: How to get the text from a control type : client using coded UI I have a Windows Application, which has a control type: Client and
class name =WindowsForms10.WIndows.8.app.0.3ce0bb8_r11_ad1
It is like a sub title bar. It has a text which displays the number of records in the table below. I want to extract that number of records. How ever when I spy using UIMap-CodedUI Test Builder, it highlight the entire title bar and does not only highlight the number of records. Is there any way I can handle this.
I want to extract 495 from the title bar. How can I do that?

A: Thank you all for your reply.
I could figure out an answer.
1) 495 is not shown as a UI control.
2) I found a work around , I can calculate the rows in the table below using UISyncDataGridTable.Rows.Count
and it serves my purpose.

A: You could use AutoHotkey. This or this function should be able to complete the task you want. The installer also comes with windows spy, which might help you pinpoint the control class you want to extract the string from.


text:
Q: WPF C# Image MouseDown to switch pages I have 3 Images with Mouse Down event like this :
        private void button12_MouseDown(object sender, MouseButtonEventArgs e) // Back to choose story menu page.
    {

       //if button 2 is pressed then show FoodKing
      // if button 1 is pressed then show Grasshopper
        stackPanelHome.Visibility = System.Windows.Visibility.Hidden;
        pageTransition1.Visibility = System.Windows.Visibility.Visible;
        pageTransition1.ShowPage(What to put in here?);

    }

    private void button2_MouseDown(object sender, MouseButtonEventArgs e) // Food fit for a king.
    {
        FoodKing controlpage = new FoodKing(); // Calling user control page
        stackPanelHome.Visibility = System.Windows.Visibility.Hidden;
        pageTransition1.Visibility = System.Windows.Visibility.Visible;
        pageTransition1.ShowPage(controlpage);

    }

private void button1_MouseDown(object sender, MouseButtonEventArgs e) // Grasshopper
{
    GrasshopperMenu controlpage = new GrasshopperMenu(); / Calling user control page
    stackPanelHome.Visibility = System.Windows.Visibility.Hidden;
    pageTransition1.Visibility = System.Windows.Visibility.Visible;
    pageTransition1.ShowPage(controlpage);
}

In the first page , there is 2 icon , 1 is FoodKing , 1 is Grasshopper then they choose which image to press on and each icon have many buttons and leads to else where , so i create a menu page to revert the user back to the page that they have selected in the beginning ( FoodKing or GrassHopper) . But how do i do this? See my code above.

A: Page currentPage;

private void button12_MouseDown(object sender, MouseButtonEventArgs e) // Back to choose story menu page.
{
    stackPanelHome.Visibility = System.Windows.Visibility.Hidden;
    pageTransition1.Visibility = System.Windows.Visibility.Visible;
    if(currentPage != null)
    {
        pageTransition1.ShowPage(currentPage);
    }
}

private void button2_MouseDown(object sender, MouseButtonEventArgs e) // Food fit for a king.
{
    FoodKing controlpage = new FoodKing(); // Calling user control page
    stackPanelHome.Visibility = System.Windows.Visibility.Hidden;
    pageTransition1.Visibility = System.Windows.Visibility.Visible;
    pageTransition1.ShowPage(controlpage);
    currentPage = controlpage;
}

private void button1_MouseDown(object sender, MouseButtonEventArgs e) // Grasshopper
{
    GrasshopperMenu controlpage = new GrasshopperMenu(); // Calling user control page
    stackPanelHome.Visibility = System.Windows.Visibility.Hidden;
    pageTransition1.Visibility = System.Windows.Visibility.Visible;
    pageTransition1.ShowPage(controlpage);
    currentPage = controlpage;
}


text:
Q: Check if several values have changed in reactive forms I have some fields in reactive forms that I have to check if values have changed. I know how to check if value have changed on one field like this
this.form.controls['phone'].valueChanges.subscribe(
  data => console.log('form changes', data)
  );

The problem I have is that I need to check two or more fields, e.g. phone and address.

A: You can merge observables, but it merges into a single observable, i.e.
import { merge } from 'rxjs';

merge(
  this.form.controls['phone'].valueChanges,
  this.form.controls['address'].valueChanges
).subscribe(console.log)

alternatively you can use combineLatest. Which will emit the latest value from each observable. I think this is what you need.
import { combineLatest } from 'rxjs';

combineLatest(
  this.form.controls['phone'].valueChanges,
  this.form.controls['address'].valueChanges
).subscribe((phone, address) => {
  // do something
})


text:
Q: Is it true that $\{x\in \mathbb{R}: |1-f(x)|\leq 1-a\} = \{x\in \mathbb{R}: |f(x)|\geq a\}?$ Suppose that $f:\mathbb{R}\to\mathbb{R}$ is a continuous function on $\mathbb{R}.$
Let $a$ be a positive constant.

Question: Is it true that
  $$\{x\in \mathbb{R}: |1-f(x)|\leq 1-a\} = \{x\in \mathbb{R}: |f(x)|\geq a\}?$$

Observe that $1-f$ is the reflection of $f$ about the line $y=\frac{1}{2}.$
I use desmos to check the two sets and it seems that they coincide.
I tried to prove the equality.
Let $x$ be a real number such that
$$|1-f(x)|\leq 1-a.$$
By reverse triangle inequality,
$$1-|f(x)|\leq |1-f(x)|\leq 1-a.$$
So we have
$$|f(x)|\ge a.$$
However, if $x$ is such that $|f(x)|\geq a,$ then I am not able to obtain
$$|1-f(x)|\leq 1-a.$$
It seems that I need
$$|1-f(x)|\leq 1-|f(x)|$$
but the inequality above may not be true.

A: Let's look at a simple case:
$f(x) = x$. And let's take $a = 0$.
Then you're asking if the set
$$
\{ x \in R : |1-x| \le 1\}
$$
is the same as the set
$$
\{x : |x| \ge 0\}
$$
Well...$x = 3$ is in the second set, but not the first, so the conjecture is false.


text:
Q: Verification of my authentication page I have created a jsp page named Login.jsp, here's the followings code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link type="text/css" rel="stylesheet" href="inc/style.css"  >
<title>login</title>

<form method=post action="j_security_check">

 Authentication

                    Login:
                    <input type="text" name="j_username">

                    Password:
                     <input type="password"
                            name="j_password">

        <input style="width: 85px" type="submit" value="Confirm" class="login">

</form>

i create a new folder below WebContent in my project, named "authentication" and i placed below home.jsp.
This page will display, if the login and password is correct.
Also, i change some thing in web.xml of project :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>authentication</display-name>
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>secured</web-resource-name>
      <url-pattern>/authentication/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>user</role-name>
    </auth-constraint>
  </security-constraint>
  <security-role>
    <role-name>user</role-name>
  </security-role>
  <login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
      <form-login-page>/login.jsp</form-login-page>
      <form-error-page>/login_failure.jsp</form-error-page>
    </form-login-config>
  </login-config>
</web-app>

When i enter "/Gestion_de_stock/authentication/home.jsp" as a url many problem appears :
Firstly, the login page doesn't display with the style that i made in a css file "style.css"
Also, when i enter a correct login and password an error page display and a url i don't know where it comes from "/Gestion_de_stock/authentication/image/top_logo.png"
I use eclipse java EE and tomcat7 as a server.
Would you please help me to find out my problem, and thank you in advance :)


text:
Q: Controlling Firefox through terminal I am writing a script which involves showing the user a webpage on the basis of his requirements (which I take as inputs) and opening it in firefox. For instance, a crude version of this is :
#!/bin/bash
read -p "What do you want to search" search_term
link=$(echo "http://www.mywebsite_whatever.com/search?q="$search_term)
firefox $link

The major problem is I cannot wget/urllib this website since I don't have permission.
Now what I want to do is :
Have the user look over only certain keywords on the webpage. So for that I want to either:

*

*Open firefox with the find box (Ctrl + F) ON with the keyword in it (without changing the source code of firefox)

*Somehow have firefox open the website, save it as html and quit. (I can't wget) Then I can grep out keywords as desired. [Please don't start off on how this is unethical and all. I am doing this merely as an exercise]
I am working on Linux.

A: To control a browser in your program, try Selenium. It supports Java, Python, etc.
See example source code from: http://seleniumhq.org/docs/03_webdriver.html
package org.openqa.selenium.example;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

public class Selenium2Example  {
    public static void main(String[] args) {
    // Create a new instance of the Firefox driver
    // Notice that the remainder of the code relies on the interface,
    // not the implementation.
    WebDriver driver = new FirefoxDriver();

    // And now use this to visit Google
    driver.get("http://www.google.com");
    // Alternatively the same thing can be done like this
    // driver.navigate().to("http://www.google.com");

    // Find the text input element by its name
    WebElement element = driver.findElement(By.name("q"));

    // Enter something to search for
    element.sendKeys("Cheese!");

    // Now submit the form. WebDriver will find the form for us from the element
    element.submit();

    // Check the title of the page
    System.out.println("Page title is: " + driver.getTitle());

    // Google's search is rendered dynamically with JavaScript.
    // Wait for the page to load, timeout after 10 seconds
        (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
           public Boolean apply(WebDriver d) {
               return d.getTitle().toLowerCase().startsWith("cheese!");
           }
        });

        // Should see: "cheese! - Google Search"
        System.out.println("Page title is: " + driver.getTitle());

        //Close the browser
        driver.quit();
    }
}

A: Use Wget with the --user-agent switch so that the website thinks you're using Firefox, for example
wget --user-agent="Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0"

Of course, for a permanent script you should instead use --user-agent="MyScript/1.0 (http://mywebsite/)" or similar so that if it goes haywire they know who to contact.


text:
Q: Setting and retrieving objects in an array I'm trying to store an array of simple objects and then retrieve them.  For some reason the pName element in my object always comes back as "default".  I'm not sure what I'm doing wrong.  personID comes back with the expected value.
var phys = {pName:"default",
            personID:0};

var aGroupPhys = [];  // Clear the array
for (var i = 0; i < data.MD_LIST.Q.length; i++) {
    //phys.pNname = data.MD_LIST.Q[i].PHYS_NAME;
    phys.pNname = "STEVE"
    phys.personID = data.MD_LIST.Q[i].PERSON_ID;
    aGroupPhys.push(phys);
    alert(i + " Name: " + aGroupPhys[i].pName + "  personID: " + aGroupPhys[i].personID);
}

Output:

A: This is resolved.  Below is the correct code.
var phys = {}
var aGroupPhys = [];  // Clear the array

for (var i = 0; i < data.MD_LIST.Q.length; i++) {
    phys = new Object();

    phys.pName = data.MD_LIST.Q[i].PHYS_NAME;
    //phys.pName = "STEVE"
    phys.personID = data.MD_LIST.Q[i].PERSON_ID;
    aGroupPhys.push(phys);
    //alert(i + " Name: " + aGroupPhys[i].pName + "  personID: " + aGroupPhys[i].personID);
}

for (var i = 0; i < aGroupPhys.length; i++) {
    alert(aGroupPhys[i].pName);
}


text:
Q: React-native-Firebase: "auth/network-request-failed" Describe your issue here
My Application is in production and the verification works well, but I have a problem with the verification of phone numbers on phones Samsung and other with run Android 5.X , 4.X.
The execution of this code:
firebase
         .auth ()
         .verifyPhoneNumber (phoneFullNumber)

generate the error: [auth / network-request-failed] A network error
NB: Our application in production on google play
NB: this problem is encountered by some android phones any version included
NB: The telephones which encounter this problem have internet which works well and Google Play


text:
Q: Injecting jQuery to webpage from Safari extension I just want to inject jQuery into a webpage from a safari extension. But only to some pages because adding jQuery as a start-/endscript would inject it to all pages and this makes browsing slow.
I tried it by creating a script tag using its onload function:
var node = document.createElement('script');
node.onload = function(){
    initjquerycheck(function($) {
        dosomethingusingjQuery($);
    });
};
node.async = "async";
node.type = "text/javascript";
node.src = "https://code.jquery.com/jquery-2.0.3.min.js";
document.getElementsByTagName('head')[0].appendChild(node);

to check if jquery is loaded i use:
initjquerycheck: function(callback) {
    if(typeof(jQuery) != 'undefined'){
        callback(jQuery);
    }else {
        window.setTimeout(function() { initjquerycheck(callback); }, 100);
    }
}

But typeof(jQuery) remains undefined. (checked that using console.log()).
Only if I call console.log(typeof(jQuery)) from the debugging console it returns 'function'. Any ideas how to fix that? Thanks in advance!

A: Extension injected scripts cannot access the web page's JavaScript namespace. Your injected script creates a <script> element and adds it to the page's DOM, but then the jQuery object instantiated by the script belongs to the page's namespace, not to your injected script's.
There are at least two potential solutions. One, inject jQuery into the page the normal way, using the extension API. This method is only viable if the web pages that you are targeting can be categorized using URL patterns.
Two, use Window.postMessage to communicate between your injected script and the web page's namespace. You will need to add another <script> to the page, and in this script, have a listener for the message event. The listener will be able to use jQuery as if it were "native" to the page itself.
Here's some code to get you started, if needed.
In the extension injected script:
var s0 = document.createElement('script');
s0.type = 'text/javascript';
s0.src = 'https://code.jquery.com/jquery-2.0.3.min.js';
document.head.appendChild(s0);

var s1 = document.createElement('script');
s1.type = 'text/javascript';
s1.src = safari.extension.baseURI + 'bridge.js';
document.head.appendChild(s1);

window.addEventListener('message', function (e) {
    if (e.origin != window.location.origin)
        return;
    console.log(e.data);
}, false);

window.postMessage('What jQuery version?', window.location.origin);

In bridge.js:
window.addEventListener('message', function (e) {
    if (e.origin != window.location.origin)
        return;
    if (e.data == 'What jQuery version?') {
        e.source.postMessage('Version ' + $.fn.jquery, window.location.origin);
    }
}, false);


text:
Q: Copy records from a table on one SQL instance to an identical table on a different SQL instance We had an intern who was given written instructions for deleting old data from a database based on dates (from within our ERP system). They were fascinated by the results and just kept deleting instead of stopping at the required date. There are now 4 years of missing records in the production database. I have these records in my development database, which is in a different instance on a different server. Is there a way to transfer just those 4 years worth of data from my development database to my production database, checking, of course, to make sure there are no duplicates (unique index on transaction number).
I haven't tried anything yet because I'm not sure where to start. I do have a test database on the same instance as the production database that I could use to test the transfer with.

A: A basic insert will work just fine.
Insert ProdDB.schema.YourTable
([Columns])
select ([Columns])
from TestDB.schema.YourTable
where YourDateRange predicates here

A: There are several ways to do this. Assuming that this is on a different machine, you will want to create a Linked Server on your dev machine to link to the target server (Or, technically, a link from the production server to your dev machine could be used as well). Then, perform an insert of the selected records from the source to the target.
More efficiently, you can use the Export Data functionality. Right click on the database (Not the server / instance, but the database) and select Tasks / Export Data from the popup menu. This will pop up the SQL Server Import and Export Wizard. Use your query above to select the data for export.
If security considerations interfere with this, create a duplicate of the table(s) with alternate names (e.g. MyInvRecords) in a new database, and export the data into those tables. Back up that DB, transfer it to someplace accessible from the target server, restore that DB, then transfer the rows back into the original DB.
I haven't had to use anything but these methods before, so one of them should work for you.


text:
Q: split file to specific sizes with tar command There is an iso file with 5.5 GB in size. I want to split that with tar command each part should be 500M. What is the command for that?

A: It's not the job of tar to split files. Use split to split the tar file.

A: You can use split:
tar [your params] |split -b 500m - output_prefix

...Or use zip (or any other compressor):
tar [your params] | zip  -s 500m output.zip  -


text:
Q: 'Unable to resolved identifier cudaMalloc' in NetBeans IDE 7.1 I'm trying to configure NetBeans Code Assistance to recognize CUDA functions in C++ so the red sqwiggly lines don't show up. However, the code builds and runs successfully. Are there any includes that I'm missing for Code Assistance to recognize CUDA function calls like cudaMalloc and cudaFree? What about cuBLAS function calls?
Here are the cuda includes I have at the top of my .cpp file:
#include <cuda.h>
#include <cuda_runtime_api.h>
#include <cuda_runtime.h>

And here is the output from NetBeans after cleaning and building the project.
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory `/home/estest/NetBeansProjects/GPU-NN'
"/usr/bin/gmake"  -f nbproject/Makefile-Debug.mk dist/Debug/CUDA-Linux-x86/gpu-nn
gmake[2]: Entering directory `/home/estest/NetBeansProjects/GPU-NN'
mkdir -p build/Debug/CUDA-Linux-x86
nvcc    -c -g -I/usr/local/cuda/include -I/usr/include -o build/Debug/CUDA-Linux-   x86/main.o main.cpp
mkdir -p build/Debug/CUDA-Linux-x86
nvcc    -c -g -I/usr/local/cuda/include -I/usr/include -o build/Debug/CUDA-Linux-    x86/data_preprocess.o data_preprocess.cpp
mkdir -p dist/Debug/CUDA-Linux-x86
nvcc     -o dist/Debug/CUDA-Linux-x86/gpu-nn build/Debug/CUDA-Linux-x86/main.o   build/Debug/CUDA-Linux-x86/data_preprocess.o -L/usr/local/cuda/lib -L/usr/local/cuda/lib64
/usr/bin/ld: warning: skipping incompatible /usr/local/cuda/lib/libcudart.so while searching for cudart
gmake[2]: Leaving directory `/home/estest/NetBeansProjects/GPU-NN'
gmake[1]: Leaving directory `/home/estest/NetBeansProjects/GPU-NN'

And here are the CUDA related includes I have included via Code Assistance.
/usr/local/cuda/include/


text:
Q: Can you use LetsEncrypt with Nginx and localhost? I didn't think you could use SSL with localhost but I came across this Q&A which says you can.
I'm looking for similar instructions to do this nginx instead of apache.
I'm running:
sudo letsencrypt certonly -d localhost

Which returns Requested domain localhost is not a FQDN
Is what I want to do possible and if so how?

A: No, this is not possible with LE. Think through it for a bit: LE needs to verify domain ownership before they issue a signed certificate. How are they going to verify that you have control of "localhost"? Every single computer on the planet has a "localhost", so they cannot issue a certificate for this CN.

A: No, using letsencrypt with localhost is not possible and actually doesn't make any sense, as localhost is by definition only reachable by yourself, in which case a self-signed cert is absolutely sufficient.


text:
Q: Xamarin IOS: BLE I am trying to connect to my Bluetooth Low Energy Device. After finding the device and getting the peripheral object. I cannot connect to the Bluetooth Device from my iPhone and it does not call  central.ConnectedPeripheral method.
Another issue is that i cannot register the event central.ConnectedPeripheral += ConnectedPeripheral in the method.
Error: System.InvalidOperationException: Event registration is overwriting existing delegate. Either just use events or your own delegate:
class IOSBluetooth : IBluetooth
{
    private readonly CBCentralManager central;
    private CBPeripheral activePeripheral;
    SimpleCBCentralManagerDelegate myCentralDelegate;

    public bool IsScanning { get; private set; }

    List<CBPeripheral> connectedDevices = new List<CBPeripheral>();

    //List<CBPeripheral> discoveredDevices = new List<CBPeripheral>();
    /// <summary>
    /// Gets the current Bluetooth instance
    /// </summary>
    /// <value>The Bluetooth Adapter instance</value>

    public IOSBluetooth(SimpleCBCentralManagerDelegate myCenDel)
    {
        myCentralDelegate = myCenDel;
        central = new CBCentralManager(myCentralDelegate, DispatchQueue.CurrentQueue);
        InitializeEvents();

        //   central.DiscoveredPeripheral += DiscoveredPeripheral; // Called when peripheral is discovered (Working)
        //   central.UpdatedState += UpdatedState; // Method Implemented - Tells us about the bluetooth powered state (On or Off). (Working)
        //   central.ConnectedPeripheral += ConnectedPeripheral; // Devices that are connected to Iphone -> Services and Characteristics discovery start from here
        //   central.DisconnectedPeripheral += DisconnectedPeripheral; // Disconnect the device from the iphone
        //   central.FailedToConnectPeripheral += FailedToConnectPeripheral;  // Failed to connect to Bluetooth Device
    }

    void InitializeEvents()
    {
        try
        {
           // central.ConnectedPeripheral += ConnectedPeripheral;
            central.FailedToConnectPeripheral += FailedToConnectPeripheral;
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message, "Intialization Failes");
            Console.WriteLine("Bluetooth.Connect " + ex.Message);
        }
    }

    public void FailedToConnectPeripheral(object sender, CBPeripheralErrorEventArgs e)
    {
        Console.WriteLine("Failed to Connect to Peripheral");
    }

    private void DisconnectedPeripheral(object sender, CBPeripheralErrorEventArgs e)
    {
        // when a peripheral disconnects, remove it from our running list.
        if (connectedDevices.Contains(e.Peripheral))
        {
            connectedDevices.Remove(e.Peripheral);

        }
    }

    public void ConnectToPeripheral(CBPeripheral peripheral)
    {
        central.ConnectPeripheral(peripheral, new PeripheralConnectionOptions { NotifyOnConnection = true, NotifyOnDisconnection = true, NotifyOnNotification = true  });
    }

    private void UpdatedState(object sender, EventArgs e)
    {
        throw new NotImplementedException();
    }

    //public override void DiscoveredPeripheral(object sender, CBDiscoveredPeripheralEventArgs e)
    //{
    //    Console.WriteLine("DiscoveredPeripheral: {0}", e.Peripheral.Name);
    //    discoveredDevices.Add(e.Peripheral);

    //}

    public void ConnectedPeripheral(object sender, CBPeripheralEventArgs e)
    {

        if (!connectedDevices.Contains(e.Peripheral))
        {
            connectedDevices.Add(e.Peripheral);

        }

        activePeripheral = e.Peripheral;
        Console.WriteLine("Connected to " + activePeripheral.Name);

        if (activePeripheral.Delegate == null)
        {
            activePeripheral.Delegate = new SimplePeripheralDelegate();
            //Begins asynchronous discovery of services
            activePeripheral.DiscoverServices();
        }

    }

    public async void BeginScanningForDevices()
    {
        Console.WriteLine("BluetoothLEManager: Starting a scan for devices.");

        // start scanning
        IsScanning = true;
        central.ScanForPeripherals((CBUUID[])null); // Discover all the devices and Initiates async calls of DiscoveredPeripheral

        // in 10 seconds, stop the scan
        await Task.Delay(10000);

        // if we're still scanning
        if (IsScanning)
        {
            Console.WriteLine("BluetoothLEManager: Scan timeout has elapsed.");
            StopScanningForDevices();

        }
    }

    /// <summary>
    /// Stops the Central Bluetooth Manager from scanning for more devices. Automatically
    /// called after 10 seconds to prevent battery drain.
    /// </summary>
    public void StopScanningForDevices()
    {
        Console.WriteLine("BluetoothLEManager: Stopping the scan for devices.");
        IsScanning = false;
        central.StopScan();
    }

    public IEnumerable<string> ListDevices()
    {
        return myCentralDelegate.DiscoveredDevices.Keys;

    }

    public bool Connect(string DeviceName)
    {
        StopScanningForDevices();

        if (!myCentralDelegate.DiscoveredDevices.ContainsKey(DeviceName))
            return false;

        var device = myCentralDelegate.DiscoveredDevices[DeviceName];

        // central.ConnectPeripheral(device, new PeripheralConnectionOptions { NotifyOnConnection = true, NotifyOnDisconnection = true, NotifyOnNotification = true });
        central.ConnectPeripheral(device);
        return true;
    }

    public void StartScanning()
    {
        if(central.State == (CBCentralManagerState.PoweredOn))
            BeginScanningForDevices();
    }

    public void StopScanning()
    {
        StopScanningForDevices();
    }
}

A: To get rid of the "Error: System.InvalidOperationException: Event registration is overwriting existing delegate. Either just use events or your own delegate" error, implement the ConnectedPeripheral method in the SimpleCBCentralManagerDelegate class. That class is being used as the iOS delegate (not to be confused with a C# delegate)  so all of the events from CBCentralManager central are being handled in the relevant methods in the SimpleCBCentralManagerDelegate class.
The idea here is that you can either use the iOS style delegate/protocol pattern, where a delegate class that implements an Obj-C/iOS protocol is assigned as the iOS/Obj-C delegate for the class that will call those protocol methods, or you can use C# style event subscriptions, but you can't use both on the same object.
More info on this is discussed on this document: https://learn.microsoft.com/en-us/xamarin/ios/app-fundamentals/delegates-protocols-and-events
It's a long read but well worth it if you are developing using Xamarin.iOS.


text:
Q: Index of vector iterator So I have a basic vector iterator, which looks like:
for (std::vector<string>::iterator i = vec.begin(); i != vec.end(); ++i)
{
    // Need the index here
}

I've tried using &i but that just returns true. I need to return the index. Would I need to create my own integer?

A: If by 'ID' you mean index, use
i - vec.begin()


text:
Q: Last Bar overlap with Right YAxis d3js I follow https://bl.ocks.org/nanu146/f48ffc5ec10270f55c9e1fb3da8b38f0 and http://bl.ocks.org/Caged/6476579 and make a Bar Graph with line an tooltip
<!DOCTYPE html>
<meta charset="utf-8">

        <svg id="graph"></svg>

If you run above code you will see a barchart like bellow image

the problem is last bar overlap with right axis .which I unable to fix .
any body have any suggestion to fix .please help .

A: You are not correctly positioning your bars regarding the x coordinate.
Since your groups are already translated...
.attr("transform", function (d) {
    return "translate(" + x0(d.Date) + ",0)";
});

... this line:
.attr("x", function (d) { return x1(d.Name); })

Should be simply:
.attr("x", 0)

Here is a fiddle with that change only: https://jsfiddle.net/6gpwmups/


text:
Q: how to get the value of select element via inline javascript when clicking this select element, the inline call "onchange" should call a javascript function:
<select onchange="if (this.selectedIndex) do_something();">
  <option value=1>1</option>
  <option value=2>2</option>
</select>

basically how do i submit the option selected to 'do_something()' function?  or in the function how can I obtain the option value selected?

A: you may try this :

function do_something(e) {
  alert(e);
}
<select onchange="if (this.selectedIndex) do_something(this.value);">
  <option value=1>1</option>
  <option value=2>2</option>
  <option value=3>3</option>
  <option value=4>4</option>
</select>

You may notice that i won't work for 1 because of selectedIndex which is equal to 0 for the first index (the value 1)
so more generic it can be :

function do_something(e) {
  //we make do test on the element e
  alert(e.value);
}
<select onchange="do_something(this);">
  <option value=1>1</option>
  <option value=2>2</option>
  <option value=3>3</option>
  <option value=4>4</option>
</select>

A:

function do_something(i){
  console.log(i);
}
<select onchange="do_something(this.selectedIndex);">
  <option value=1>1</option>
  <option value=2>2</option>
</select>

Try adding it as a parameter in the do_something function.


text:
Q: Conditionally allowing for null in LINQ WHERE clause Working:
I am trying to perform a LEFT OUTER JOIN between my Contacts table and my Permissions table. I have the basis of this working correctly, and get back a list of contacts regardless of whether they have a corresponding permission.
// Query for Contacts
from contact in Contacts
join permission in Permissions on contact.Id equals permission.ObjectId into permissionGrp
from p in permissionGrp.DefaultIfEmpty()
where p==null || (p!=null && /* ... condition based on the existence of a permission */)
select new { contact, permission = p };

Generated WHERE SQL:
WHERE
(t1.PermissionId IS NULL OR
    ((t1.PermissionId IS NOT NULL AND ... other conditions ... )))

Problem:
I want to adapt the above to introduce 'fallback' check; Not working as expected.
Requirement:

*

*When there is no Permission corresponding to the Contact (i.e. p==null) then only include the row based on the predetermined bool value of allowed.

Attempt:
I thought I could do where (p==null && allowed) || ... like this:
// Fallback permission
bool allowed = false;

// Query for Contacts
from contact in Contacts
join permission in Permissions on contact.Id equals permission.ObjectId into permissionGrp
from p in permissionGrp.DefaultIfEmpty()

/* Added bool condition 'allowed' to control inclusion when 'p' is null */
where (p==null && allowed) || (p!=null && /* ... condition based on the existence of a permission */)
select new { contact, permission = p };

Expected:
When allowed = false (don't accept null permission)
WHERE
    ((t1.PermissionId IS NOT NULL AND ... other conditions ... ))

When allowed = true  (accept null permission)
WHERE
(t1.PermissionId IS NULL OR
    ((t1.PermissionId IS NOT NULL AND ... other conditions ... )))

Actual Result:
Always outputs as if allowed=false even when true?
WHERE
    ((t1.PermissionId IS NOT NULL AND ... other conditions ... ))

Summary:
I hope I am just doing something silly that's easily fixed.
How can I filter my null value records based on a given bool value?

A: You are performing a GroupJoin here. So the result of the first part, permissionGrp, is an anonymous type IGrouping<Permission>. This already is the eqivalent of an OUTER JOIN.
You can achieve what you want by conditionally testing whether or not the IGrouping<Permission> contains elements:
from contact in Contacts
join permission in Permissions on contact.Id equals permission.ObjectId
    into permissionGrp
where allowed || g.Any()
from p in permissionGrp.DefaultIfEmpty()
select new { contact, permission = p };

Note that from p in permissionGrp flattens the grouping again, so .DefaultIfEmpty() is still necessary for the case where allowed == true.

A: I suspect there is a bug in the ORM (LightSpeed) I am using, which I will bring to their attention.
Workaround
I have found a suitable work around, using the let clause.
// Fallback permission
bool allowed = false;

// Query for Contacts
from contact in Contacts
join permission in Permissions on contact.Id equals permission.ObjectId into permissionGrp
from p in permissionGrp.DefaultIfEmpty()

/* Work around for 'allowed' not being honoured properly, using 'let' */
let isAllowed = allowed

/* Added bool condition 'isAllowed' to control inclusion when 'p' is null */
where (p==null && isAllowed) || (p!=null && /* ... condition based on the existence of a permission */)
select new { contact, permission = p };

Result
It is now using comparison of a known value with itself as a boolean check. In this case t0.ContactId.
SQL When allowed=true ... t0.ContactId = t0.ContactId
WHERE
    ((t1.PermissionId IS NULL AND t0.ContactId = t0.ContactId) OR
     (t1.PermissionId IS NOT NULL AND ... other conditions ...))

SQL When allowed=false ... t0.ContactId <> t0.ContactId
WHERE
    ((t1.PermissionId IS NULL AND t0.ContactId <> t0.ContactId) OR
     (t1.PermissionId IS NOT NULL AND ... other conditions ...))


text:
Q: redirect user after writing data to their account I was wondering how I can redirect my users to their dashboard after their account is added to the real time database. Currently, it redirects them before the function can be completed.
function signUp()
{
    var email = document.getElementById("usernameS").value;
    var password = document.getElementById("passwordS").value;
    console.log(email);
    console.log(password);
    firebase.auth().createUserWithEmailAndPassword(email, password)
    .then((userCredential) =>
    {
        var user = userCredential.user;
        firebase.database().ref('users/' + user.uid).set
        ({
            email: email
        });
        redirect();
    })
    .catch((error) =>
    {
        var errorCode = error.code;
        var errorMessage = error.message;
        console.log(errorMessage);
    });
}

function redirect()
{
    window.location.replace('dashboard.html');
}

A: Set is a promise so try moving the redirect to inside a then callback which would help ensure set has completed before attempting to redirect:
return firebase.database().ref('users/' + user.uid).set({ existing stuff }).then(() => redirect());

Hopefully that helps!


text:
Q: Variance of estimate variances Assuming the observed values $Y_i$ are Normal with mean $\beta_0 + \beta_1 X_i$ and variance $1$, what are the
variances of the estimates
$${\sigma_1}^2 = \frac{1}{n-1}[(Y_{21} − Y_2)^2 + (Y_{22} − Y_2)^2]$$ and $\sigma^2=\sum({Z_i}^2/6)$?
n=2 which is why 1/(n-1) was not included.
I am not really sure what is being asked.  The variance is $E(x^2) - [E(x)]^2$
so is it the $E(\sigma^2) - [E(\sigma)]^2$?  that seems to easy but it is the only thing I have thought of.
does it have to do with the distributions?  normal vs Chi^2
$\sigma^2 =
(\sigma_1^2+
\sigma_2^2+
\sigma_3^2$)/3
I am not sure of anything else.  Thank you for any and all help.


text:
Q: C# Attributes Order - Serializable - D Does the order of attributes matter?
Is this:
[Serializable]
[DataContract(Name = "GuUser")]
[TSF.Attributes.Entity(
    ConnectionKey = "usergroup",
    TableName = "gu_user",
    InsertCommand = "usp_gu_addguuser",
    UpdateCommand = "usp_gu_updateguuser",
    DeleteCommand = "usp_gu_deleteguuser",
    SelectCommand = "usp_gu_getguuser")]
public class User : TSF.Base.BaseEntity

the same as this:
[DataContract(Name = "GuUser")]
[TSF.Attributes.Entity(
    ConnectionKey = "usergroup",
    TableName = "gu_user",
    InsertCommand = "usp_gu_addguuser",
    UpdateCommand = "usp_gu_updateguuser",
    DeleteCommand = "usp_gu_deleteguuser",
    SelectCommand = "usp_gu_getguuser")]
[Serializable]
public class User : TSF.Base.BaseEntity

The second way says "not serializable". I can't try the first way. Perhaps the error is not related. But, does the order matter?

A: The order in which attributes are specified in such a list, and the order in which sections attached to the same program entity are arranged, is not significant.
For instance, the attribute specifications [A][B], [B][A], [A, B], and [B, A] are equivalent.
Source: http://msdn.microsoft.com/en-us/library/aa664616(v=vs.71).aspx


text:
Q: Systemctl: Failed to start Node.js Application I've seen one other post about this problem and it didn't seem to work so I'm posting my issue that might be a little different. The code for my service is file is below:
[Unit]
Description=Node.js Application
After=syslog.target network.target

[Service]
Type=simple
User=root
WorkingDirectory=/root
Enviroment=NODE_ENV=production
ExecStart=/usr/bin/node helloworld.js

Restart=always

[Install]
WantedBy=multi-user.target

This is the tutorial I am using:
https://blog.eduonix.com/web-programming-tutorials/deploy-node-js-application-linux-server/
I am using a Raspberry Pi if that makes a difference
The error says:
helloworld.service: Start request repeated too quickly.
helloworld.service: Failed with result 'exit-code'.
Failed to start Node.js Application


text:
Q: Tune FFmpeg H.264 Decoder I'm using the FFmpeg avcodec to decode live video - the avcodec_decode_video2 function from libx264 to be exact. How can I decrease the decoding time for each frame? At the moment it takes 20 ms for each frame (frame size about 1.5 KB).

A: Ok, may be it will be helpful for someone. By the way, for decoding we use function avcodec_video_decode2 from FFMPEG. And we can make delay lesser by two ways. The first: turn on AVCodecContext *ctx->thread_count=NBut in this case we get a stream with a delay however it is not good for real time video. The second way is use coder which will be code image in slice based mode e.g. libx264. In this case the delay is absent by definition. But it makes some limitation e.g. a count of threads is a count of slice.


text:
Q: Invalid prop `source` supplied to `Image`" React Native Can i get help in React Native?
Compiler throws always this error:
"Failed prop type: Invalid prop source supplied to Image"
dec is string coming from api.
Please help!
Im tired of this error.
 <Image
                resizeMode="stretch"
                style={styles.tempImg}
                source={
                  dec == "sunny"
                    ? require("./assets/sunny.png")
                    : dec == "Partly cloudy"
                    ? require("./assets/partlycloudy.png")
                    : dec == "Rain"
                    ? require("./assets/rain.png")
                    : dec == "Light Snow"
                    ? require("./assets/snowlight.png")
                    : dec == "Overcast"
                    ? require("./assets/overcast.png")
                    : dec == "Clear"
                    ? require("./assets/clear.png")
                    : dec == "Heavy snow"
                    ? require("./assets/heavysnow.png")
                    : dec == "Freezing Unknown Precipitation"
                    ? require("./assets/freezingrain.png")
                    : dec == "Cloudy"
                    ? require("./assets/cloudy.png")
                    : ""
                }
              />

A: Have a try with below code:
<Image
    resizeMode="stretch"
    style={styles.tempImg}
    source={
        dec == "sunny"
         ? require("./assets/sunny.png")
         : dec == "Partly cloudy"
           ? require("./assets/partlycloudy.png")
           : dec == "Rain"
             ? require("./assets/rain.png")
             : dec == "Light Snow"
                ? require("./assets/snowlight.png")
                : dec == "Overcast"
                  ? require("./assets/overcast.png")
                  : dec == "Clear"
                    ? require("./assets/clear.png")
                    : dec == "Heavy snow"
                       ? require("./assets/heavysnow.png")
                       : dec == "Freezing Unknown Precipitation"
                         ? require("./assets/freezingrain.png")
                         : dec == "Cloudy"
                           ? require("./assets/cloudy.png")
                           : { uri: "" }
            }
          />

add the default source at the last condition otherwise put { uri: "" }
as the black source might produce issue that's why you are getting error.


text:
Q: All windows reset their positions to the primary monitor after sleep I got a new secondary monitor a couple days ago, Acer B326HK. I had a multi-monitor setup before on the same W10 laptop and didn't experience any issues.
When the laptop and the monitor go to sleep, all the open windows move to the monitor that is selected as primary. I tried looking into the monitor settings but didn't find anything suspicious. What could be causing such behaviour? Is there any fix that would prevent it or any solution that would automatically put the windows back to them monitors they belong to?
System details:

*

*OS: Windows 10 Pro 22H2

*GPU: Intel Iris Xe (i5 1145G7)

*Monitor: Acer B326HK, connected via HDMI


text:
Q: What is the purpose of the tilde in this situation? What could be the purpose of the tilde in this code block?
public override int GetHashCode()
    {
      return ~this.DimensionId.Id ^ this.ElementId.Id;
    }

^ Operator (C# Reference)
Visual Studio 2010
Binary ^ operators are predefined for the integral types and bool. For integral types, ^ computes the bitwise exclusive-OR of its operands. For bool operands, ^ computes the logical exclusive-or of its operands; that is, the result is true if and only if exactly one of its operands is true.
~ Operator (C# Reference)
Visual Studio 2010
The ~ operator performs a bitwise complement operation on its operand, which has the effect of reversing each bit. Bitwise complement operators are predefined for int, uint, long, and ulong.
The ~ (tilde) operator performs a bitwise complement on its single integer operand. (The ~ operator is therefore a unary operator, like ! and the unary -, &, and * operators.) Complementing a number means to change all the 0 bits to 1 and all the 1s to 0s
What would be a reason why it would be used in this context (as opposed to simply excluding it)?

A: It's simply one way of generating a hash code. I'm not a huge fan of XORs in hash codes unless you want something that's order-independent, but it's a reasonable way of flipping bits in a reasonably arbitrary but repeatable way.
Basically you've got two 32-bit values here, which you need to combine in some form to create another 32-bit value. The code could have just XORed the values together without any bitwise complement:
return DimensionId.Id ^ ElementId.Id;

... but that would always give zero for cases where ElementId.Id == DimensionId.Id, which probably isn't ideal. On the other hand, we now always end up with -1 if the two IDs are the same, as noted in comments (doh!). On the other hand, it makes the pair {6, 4} have a different hash code to {4, 6} whereas a simple XOR doesn't... it makes the ordering important, in other words. Again, that could be important if your real identifiers are likely to be taken from a relatively small pool.
The XOR itself makes sure that a change to any bit in either ID makes a difference to the final hashcode.
Personally I normally follow Josh Bloch's pattern from effective Java, e.g.
unchecked
{
    int hash = 17;
    hash = hash * 31 + DimensionId.Id;
    hash = hash * 31 + ElementId.Id;
    return hash;
}

... but that's just because of some of the properties of hashing that way1, and it doesn't make the implementation you've shown "wrong" in any sense.

1 It seems to work pretty well at producing distinct values in a number of common scenarios. Obviously it can't prevent hash collisions, but if your IDs are actually generated from a sequence of 1, 2, 3... then this will do better at real-life collisions that an XOR. I did see a web page analyzing this approach and which numbers work well etc, but I can't remember where.


text:
Q: Service not available in the controller's container and cannot replace it from Listener I am porting a custom bundle that was created originally for symfony 2 to Symfony 5.
Inside the bundle there is a listener with this function:
public function onEarlyKernelRequest(RequestEvent $event)
{
    if (!$tenant = $this->tenantStrategy->getTenant()) {
        $this->dispatcher->dispatch($tEvent = new TenantEvent(null, $event), TenantEvents::TENANT_NOT_FOUND);
        if (!$tEvent->getTenant()) {
            return;
        }
    }
    $this->dispatcher->dispatch(new TenantEvent($tenant, $event), TenantEvents::TENANT_FOUND);

    //$this->container->set('synd_multitenant.tenant', $tenant);
}

When I remove the comment from the last line I get this error:
The "synd_multitenant.tenant" service is already initialized, you cannot replace it.
With that line commented out, When I try to get the service from the controller I get this message:
Service "synd_multitenant.tenant" not found: even though it exists in the app's container, the container inside "App\Controller\DefaultController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session" and "twig" services. Try using dependency injection instead.

And in case it is relevant, I had to change to RequestEvent from GetResponseEvent because GetResponseEvent is not supported anymore.
Here is the controller where I am trying to use the service:
<?php
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use App\Repository\ClientRepository;

class DefaultController extends AbstractController {

    function index() {
        //$entityManager = $this->getDoctrine()->getManager();
        //$clientRepository = $entityManager->getRepository('App\Entity\Client');
        //$client = $clientRepository->findOneBy(array('domain' => 'someclient.mysymfony.local'));

        $client = $this->get('synd_multitenant.tenant');

        return new Response(
            'Welcome to My Symfony 5 demo!'.
            '
Client: ' . $client->getDomain() .
            ''
            );
    }

}

Here is the output of console debug:
$ php bin/console debug:container synd_multitenant.tenant

Information for Service "synd_multitenant.tenant"
=================================================

 ---------------- -----------------------------------------------
  Option           Value
 ---------------- -----------------------------------------------
  Service ID       synd_multitenant.tenant
  Class            Synd\MultiTenantBundle\Entity\TenantInterface
  Tags             -
  Public           yes
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        yes
  Autoconfigured   yes
 ---------------- -----------------------------------------------

The complete code is available at this github repository: https://github.com/karimmtl/Mysymfony5
Thanks

A: found out that the tentant service class name is

\Synd\MultiTenantBundle\Entity\TenantInterface

in the bundles service.yaml file.
Try to change your controller so that you inject the service:
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use App\Repository\ClientRepository;
use Synd\MultiTenantBundle\Entity\TenantInterface;

class DefaultController extends AbstractController
{

    function index(TenantInterface $client)
    {
        return new Response(
            'Welcome to My Symfony 5 demo!'.
            '
Client: ' . $client->getDomain() .
            ''
            );
    }

}


text:
Q: Checking if two diagrams have isomorphic colimits Consider the infinite diagrams:
$$
C_1\to C_2 \to \cdots \to C_n \to \cdots
$$
$$
D_1\to D_2 \to \cdots \to D_n \to \cdots
$$
in some category, and suppose both colimits exist.
How do I check if the colimits are isomorphic? Is there a standard way, or even a definition?

A: To prove two (co-)limits are isomorphic, we usually show that one (co-)limit satisfies the universal property of the other one and vice versa.


text:
Q: Spring MVC form:radiobuttons tag not setting value attribute Here is relevant code from my controller:
@ModelAttribute("store_location_types")
public StoreLocationType[] getStoreLocationTypes() {
    return StoreLocationType.values();
}

Here is the definition of StoreLocationType, defined in the same controller:
private enum StoreLocationType {
    PHYSICAL("Physical"),
    ONLINE("Online");

    private String displayName;
    private String value;

    private StoreLocationType(String displayName) {
        this.displayName = displayName;
        this.value = this.name();
    }

    public String getDisplayName() {
        return this.displayName;
    }

    public String getValue() {
        return this.value;
    }
}

Here is the the relevant JSP code:

            Location Type:
            <form:radiobuttons path="StoreLocationType" items="${store_location_types}" itemLabel="displayName" itemValue="value"/>

Here is what gets generated when the page is rendered:

        Location Type:

            <input id="StoreLocationType1" name="StoreLocationType" type="radio" value="">
            Physical

            <input id="StoreLocationType2" name="StoreLocationType" type="radio" value="">
            Online

The value attributes are not being populated with the "value" field of my enum.  What am I doing wrong here?  What I would expect to see is this:

            <input id="StoreLocationType1" name="StoreLocationType" type="radio" value="PHYSICAL">
            Physical

            <input id="StoreLocationType2" name="StoreLocationType" type="radio" value="ONLINE">
            Online

The value attribute of the input tag should be the value of StorLocationType.ONLINE.getValue()

A: I cannot find any problem in your code. When I tested it works well.
But in the case you can do it in a simpler way. You don't need to add the value field in the enum. If you omit the itemValue attribute of <form:radiobuttons> Spring will put the name of instances of enum for the value of itemValue attribute.
So you can do like this.
Enum
private enum StoreLocationType {
    PHYSICAL("Physical"),
    ONLINE("Online");

    private String displayName;

    private StoreLocationType(String displayName) {
        this.displayName = displayName;
    }

    public String getDisplayName() {
        return this.displayName;
    }
}

JSP
Location Type:
<form:radiobuttons path="StoreLocationType"
    items="${store_location_types}" itemLabel="displayName" />

A: I solved it using multiple radiobutton tags instead of a single radiobuttons tag.
Here is the code of the JSP:
<c:forEach var="item" items="${store_location_types}">
    <form:radiobutton path="StoreLocationType" value="${item.value}"/>${item.displayName}
</c:forEach>

I used plain objects from database, so in my case value was the Id and the displayed string was the description. But this should work with enum too.


text:
Q: Gray box around image, bootstrap I've tried setting "outline: none", messed with the border, and I can't seem to fix it. You can view the page at: https://spring-resonance-4984.bss.design/. The reason I'm linking is because I don't know what part of the page is incorrect or needs to be added. I will update this with additional information if someone can help me.

A: Based on your markup, it's because you are technically using an  tag, which expects a valid src attribute to be set per the HTML spec.

If you are using CSS to set the image, which in your case you are via the background-url property, then you should likely use a
 element instead:

Otherwise, if you still want to explicitly use an  tag, you should either:

*

*Set the src attribute to your specified image.

*Ignore the src attribute, but explicitly set an alt property (of something like alt=' ') to hide the surrounding border (this is not recommended, but it should get rid of your border issue)

A: It's an img tag without a src, hence it looks a bit funky.
Either change the tag to div or set the src attribute of the img tag (instead of styling the background).

A: You are setting a background-image property on an  tag.
Just set the src of your img tag to the URL that you are linking to on your background-image property


text:
Q: GNU Parallel - Can these nested parallels be a single parallel call? I have a folder with a file for every 5 minute interval. Assuming the filename is 'Test-HHMM.png' for every file, I want to check for the existence of each file. So far here's what I have.
parallel "[ -f {1} ] || echo '{1} - Nope'" ::: $(parallel printf %s-%02d%02d.png\\\\n {1} {2} {3} ::: 'Test' ::: $(seq 0 23) ::: $(seq 0 5 55))

So there's a first call to parallel which uses printf to create a series of filenames, using 2 calls seq to generate hours and minutes. Then a second call to parallel does the -f test on each filename.
This seems like it could just be one call to parallel, where the command is a -f test on the result of a $(printf) of all the arguments. But I can't seem to get the syntax right. I also can't seem to break the command down into subcommands and then concatenate, to make things easier to read.
Any thoughts? Using parallel wrong seems dicey; it feels like I'd be better off using loops.
Update
Here's a stripped down version of my problem - looks Addtrivial but I can build up from this to what I need. I currently have this:
parallel echo $(printf %02d {1}) ::: $(seq 1 10)
I expect this to print

01
02
...
10

Instead I get

./foo.sh: line 7: printf: {1}: invalid number
00 1
00 2
...
00 10

No idea why. Tried many combinations of ' and " with no efefect.
Thanks!

A: First: Are you sure this is not an XY problem?
If you are monitoring a dir to see if new files are made then this is better:
inotifywait -q -m -r -e MOVED_TO -e CLOSE_WRITE --format %w%f my_dir | parallel -u echo

But if you really are looking to see if the file exists, then a single loop in Perl will be way faster: GNU Parallel excels at tasks that take longer than a few ms to run.
perl -e 'print map {$_."\n"} grep { ! -e $_ } map { $a=$_*5; map { sprintf "Test-%02d%02d.png", $_,$a } "00"..23 } 0..11' |
  parallel echo {} - Nope

Here I assume you really want to do some thing more serious than echo. Otherwise you should simply put it in with the map after print.
Edit:
If the run time is not an issue then this is a fairly compact way to do the same:
parallel [ -f Test-{1}{2} ] "||" echo Test-{1}{2} - Nope ::: {00..23} ::: {00..55..5}

If what you want to run is more complex make a function:
mytest() {
  file="$1"
  if [ -f "$file" ] ; then
    true
  else
    echo "$file" - Nope
  fi
}
export -f mytest
parallel mytest Test-{1}{2} ::: {00..23} ::: {00..55..5}

A: Referring to my simplified example in my edit ... this doesn't work
parallel echo $(printf %02d {1}) ::: $(seq 1 10)
... but this does
parallel echo "\$(printf %02d {1})" ::: $(seq 1 10)
The problem was I needed to escape that $ so the expression would get evaluated by parallel, not by bash.
So the solution to my original question becomes
parallel "file=\$(printf %s-%02d%02d.kml {1} {2} {3}) && [ -f \$file ] || echo \$file - Nope" ::: 'Foo' ::: $(seq 0 23) ::: $(seq 0 5 55)
which additionally assigns the result of the $(printf) to a variable, so I don't have to call printf more than once. Even got it working when I assigned the printf command to a variable, in case I wanted to reuse it. So I think I'm good.
Thanks for the answer & comments guys.


text:
Q: What mobile network types allow http traffic during phone calls? Would this Android code be a correct way to test for http network availability during a phone call, or does it exclude networks that should be included or vice versa:
public boolean isOnline() {
    TelephonyManager tm = (TelephonyManager)
              getSystemService(Context.TELEPHONY_SERVICE);

    if (tm.getNetworkType() > TelephonyManager.NETWORK_TYPE_EDGE)
        return true;
    return false;
}

A: Any GSM network allows network access while using the phone network. CDMA networks do not allow this. But if memory serves me correctly, when Verizon moves to LTE you should be able to network access even while on the phone. This is because they will probably use CDMA for the voice network and use LTE for data. Sprint uses WiMax for their 4G, but I do not know if they are using CDMA still for voice and using WiMax for data.
The reason GSM networks can use the data network while on the phone is because they use 2 different "networks" for both. GSM is actually the voice data and UMTS/HSPA is for web data. HSPA+ for t-mobiles "4G", which is just basically upgrades to their HSPA network.
Also any of the carriers will have access to a data network if they are connected to WiFi while on the phone.
So to really answer your question, you first need to know the voice/data network type, then you need to account for wifi, but also if they are connected to LTE, WiMax, UMTS/HSPA, or CDMA.
If they are connected to CDMA only, then there is no data network available while on the phone. But if they are on CDMA + LTE, CDMA + WiMax, CDMA + WiFi then yes they have data. If it is a GSM voice network, then they have data network.
Even after you determine that, you should also keep in mind that the data network may not be available at all for one reason or another.


text:
Q: Why the audio play only when clicking on image and not while clicking on textVIew? I'm following some online tutorial and it is about how to play an audio in the listview with onItemCLickLIstener, but the problem is i have done the exact work but it is not working properly.
The audio plays when i'm clicking on image but it doesn't do anything when clicking  on rest of the screen.
     public class NmbersActivity extends AppCompatActivity{

private MediaPlayer mediaPlayer;

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

    final ArrayList<Word> word = new ArrayList<Word>();

    word.add(new Word("One", "Lutti",R.drawable.number_one,R.raw.number_one));
    word.add(new Word("Two", "Otlika",R.drawable.number_two,R.raw.number_two));
    word.add(new Word("Three", "Tolookosu",R.drawable.number_three,R.raw.number_three));
    word.add(new Word("Four", "Oyyisa",R.drawable.number_four,R.raw.number_four));
    word.add(new Word("Five", "Massokka",R.drawable.number_five,R.raw.number_five));
    word.add(new Word("Six", "Temmoka",R.drawable.number_six,R.raw.number_six));
    word.add(new Word("Seven", "Kenekaku",R.drawable.number_seven,R.raw.number_seven));
    word.add(new Word("Eight", "Kawinta",R.drawable.number_eight,R.raw.number_eight));
    word.add(new Word("Nine", "Wo'e",R.drawable.number_nine,R.raw.number_nine));
    word.add(new Word("Ten", "Na'aacha",R.drawable.number_ten,R.raw.number_ten));

    WordAdapter Adapter = new WordAdapter(this,word,R.color.category_number);

    ListView activityText = findViewById(R.id.commanIntent);

    activityText.setAdapter(Adapter);

    activityText.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Word words = word.get(position);

            mediaPlayer = MediaPlayer.create(NmbersActivity.this,words.getmAudioResource());

            mediaPlayer.start();

        }
    });

}

}
Here is the LIstView File
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" />

Here is the custom layout for single list item .
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/tan_background"
android:minHeight="@dimen/list_item_height"
android:orientation="horizontal">

<ImageView
    android:id="@+id/image"
    android:layout_width="@dimen/list_item_height"
    android:layout_height="@dimen/list_item_height" />

<LinearLayout
    android:id="@+id/text_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingLeft="16dp">

    <TextView
        android:id="@+id/miwok_text_view"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="bottom"
        android:textAppearance="?android:textAppearanceMedium"
        android:textColor="@android:color/white"
        android:textStyle="bold"
        tools:text="lutti" />

    <TextView
        android:id="@+id/default_text_view"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="top"
        android:textAppearance="?android:textAppearanceMedium"
        android:textColor="@android:color/white"
        tools:text="one" />
</LinearLayout>

Here is the wordAdapter file.
public class WordAdapter extends ArrayAdapter<Word> {

private int mColorPrimary;

public WordAdapter(Context ActivityName, ArrayList<Word> word, int
background) {
    super(ActivityName,0,word);
    mColorPrimary = background;
 }
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {

    View listItemView = convertView;
    if (listItemView == null)

    {
        listItemView = LayoutInflater.from(getContext()).inflate
                (R.layout.list_item, parent, false);
    }

    Word defaultView = getItem(position);

    final TextView miwokTextView =
listItemView.findViewById(R.id.mivokTrans);

    miwokTextView.setText(defaultView.getMovik());

    final TextView defaultTextView =
listItemView.findViewById(R.id.defaultTrans);

    defaultTextView.setText(defaultView.getDefault());

    ImageView imageView = listItemView.findViewById(R.id.image);
   if(defaultView.hasImage()) {
       imageView.setImageResource(defaultView.getmImageResourseId());
   }

   else{
       imageView.setVisibility(View.GONE);
   }

   View colorView = listItemView.findViewById(R.id.linear_item);

   colorView.setBackgroundResource(mColorPrimary);

    return listItemView;

 }

Here is the Word class.
public class Word{

    private String mDeafaultLanguage;

    private String mMovikLanguage;

    private int mImageResourseId = NO_IMAGE;

    public static final int NO_IMAGE = -1;

    public Word(String defaultLanguage,String movikLanguage){

        mDeafaultLanguage = defaultLanguage;
        mMovikLanguage = movikLanguage;

    }

    public Word(String defaultLanguage,String movikLanguage, int
 imageResource){

    mDeafaultLanguage = defaultLanguage;
    mMovikLanguage = movikLanguage;
    mImageResourseId = imageResource;

    }

    public String getDefault(){
        return mDeafaultLanguage;
    }

    public String getMovik() {
        return mMovikLanguage;
    }

public int getmImageResourseId() {
    return mImageResourseId;
}

public boolean hasImage(){
        return NO_IMAGE != mImageResourseId;
}

}

If you want to know more details there is the link of the exact app
 https://github.com/udacity/ud839_Miwok/tree/43a1596a48521beee160f937988a5c564519dbb5

A: Please, try to set clickable true for the textview.
android:clickable="true"


text:
Q: How do the arc and the straight line have equal length in this figure? I have the following derivation in one of my physics problem related to range of a transmitting antenna:

How is the distance QT equal to the length of arc PT? Can someone provide a quick explanation or proof of somekind?

A: In reality, they are not equal. However, QT is at least as long as the arc PT, and the most QT could be is the length of the arc plus the height of the tower:
$PT < QT < PT + h_T$
But since the height of the tower is at most tens of meters, and the distance of PT likely in kilometers, $PT \approx PT + h_T$.
And thus, for all intents and purposes, $PT \approx QT$.


text:
Q: Trying to get number of days in specific month using Calendar object I'm trying to write a Calendar in java that outputs an html web page with a Calendar inside of a table, but I've run into a problem when trying to get the number of days in a specific month during a specific year.
This is the bit of code I'm using:
    //accept input from command prompt in form of MONTH, DAY, YEAR
    String date = args[0];
    SimpleDateFormat df = new SimpleDateFormat("MMMM dd, yyyy");
    Date convertedDate = new Date();
    try
    {
        convertedDate = df.parse(date);
    }
    catch(Exception e)
    {
        System.out.print(e);
    }
    Calendar cal = Calendar.getInstance();
    cal.setTime(convertedDate);
    year = cal.get(Calendar.YEAR);
    month = cal.get(Calendar.MONTH);
    day = cal.get(Calendar.DAY_OF_MONTH);

    //get number of days in month
    int numDays, startMonth;
    numDays = cal.getActualMaximum(DAY_OF_MONTH);

and I'm getting an error from that last line that reads:
error: cannot find symbol and it points to the DAY_OF_MONTH variable.
How can I resolve this?

A: Use Calendar.DAY_OF_MONTH:
numDays = cal.getActualMaximum(Calendar.DAY_OF_MONTH);

It's a static field on the Calendar class.


text:
Q: Variable 'interface' might not have been initialized I am trying to build a Morphia and Spring application using a template from another project and I am getting the following error
Variable 'assetRepository' might not have been initialized

The AssetRepository is an interface
package code.nithin.repository;

import code.nithin.entity.Asset;
import org.mongodb.morphia.Key;

public interface AssetRepository {
    public Key<Asset> save(Asset asset);
}

and the AssetController is
package code.nithin.controllers;

import code.nithin.entity.Asset;
import code.nithin.repository.AssetRepository;
import org.mongodb.morphia.Key;

public class AssetController{

    public String saveAsset(String URL){
        AssetRepository assetRepository;
        Asset test = new Asset(1, System.currentTimeMillis(),"https://example.com");

        String returnString = assetRepository.save(test).getId();

    }
}

The entity is
package code.nithin.entity;

import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Entity("asset")
@NoArgsConstructor
public class Asset {

    @Id
    public ObjectId _id;

    public int version;
    public long timestamp;
    public String URL;

    public Asset(){}

    public Asset(int version, long timestamp, String URL) {
        this.version = version;
        this.timestamp = timestamp;
        this.URL = URL;
    }

    public ObjectId get_id() {
        return _id;
    }

    public void set_id(ObjectId _id) {
        this._id = _id;
    }

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public String getURL() {
        return URL;
    }

    public void setURL(String URL) {
        this.URL = URL;
    }
}

The project I am referring to implements the same as
@Bean
public CommandLineRunner init(AssetRepository assetRepository){
    return (args) -> {
        Asset test = new Asset(1, 123456789632541 ,"https://example.com");
        System.out.println(assetRepository.save(test).getId());
    };
}

The project I am referring to throws no error.
Stack trace
Error:(19, 28) java: variable assetRepository might not have been initialized
    Error:(21, 5) java: missing return statement
    /home/signzy/code/java/cubereum/boilerplate/src/main/java/code/cubereum/controllers/AssetController.java
    Information:javac 1.8.0_181 was used to compile java sources
    Information:1/9/18 2:58 PM - Compilation completed with 2 errors and 0 warnings in 1 s 730 ms
    Information:java: Errors occurred while compiling module 'boilerplate_main'

A: saveAsset() has a local assetRepository (never set) which hides the static global one.
Remove the local one and it should work.
After seeing the stack trace it is obviously as I said above:
public String saveAsset(String URL){
        AssetRepository assetRepository;
        Asset test = new Asset(1, System.currentTimeMillis(),"https://example.com");

        String returnString = assetRepository.save(test).getId();

    }

*

*You have a local AssetRepository that you never set and so you get "variable assetRepository might not have been initialized"

*The function returns a string but you have no return statement so you get "missing return statement"
public String saveAsset(String URL){
    Asset test = new Asset(1,  System.currentTimeMillis(),"https://example.com");
    return assetRepository.save(test).getId();
 }

A: I think it comes from this code:
public String saveAsset(String URL){
    AssetRepository assetRepository;
    Asset test = new Asset(1, System.currentTimeMillis(),"https://example.com");

    String returnString = assetRepository.save(test).getId();

}

You have an assetRepository which is not initialized. And then you try to do
assetRepository.save(test).getID();

Since assetRepository is not initialized, this can be a problem.
EDIT:
AssetRepository is an Interface, so you can't initalize your assetRepository variable with it.
However, you should have somewhere an other class, which implements AssetRepository and defines the method save(Asset asset). It should looks like that:
public class Foo implements AssetRepository{
    public Foo(){
        //Constructor for this class
    }

    public Key<Asset> save(Asset asset){
        //some code here
        //this defines the method declared in the Interface
    }
}

Then, to initialize your variable, you do that:
AssetRepository assetRepository = new Foo();


text:
Q: Iterating through the elements returned by getElementsByClassName and changing the .className attribute produces weird behavior Suppose I call getElementsByClassName() and store the result in a variable like so:
var editButtons = document.getElementsByClassName("editButtonDisabled");

Then I iterate through that variable (which is a nodelist, so .item(i) is used and not [i]) and change the class name of each item:
for (var i = 0; i < editButtons.length; i++) {

    var editButton = editButtons.item(i);
    editButton.className = "editButtonEnabled";

}

For some reason the loop skips over all the odd-indexed members of editButtons and only applies the class name change to the even-numbered ones, as though the length of editButtons is being mutated by changing the properties of its members, which shouldn't be the expected behavior in my opinion.
I know I can get around this by just throwing all the elements into an array first and then looping through it again, but that requires writing two loops when only one should be necessary, and I'm curious as to why it's doing this in the first place.

A: Yes, because editButtons.length changes after each iteration, you should put the length in a variable:
for (var i = 0, length = editButtons.length; i < length; i++) {
    var editButton = editButtons.item(i);

    editButton.className = "editButtonEnabled";

}

EDIT:
I was wrong about my solution and about length.
In fact when the first button class is changes the button is popped out of the array and when the i is incremented the second button (witch now is at index 0) is skipped and so on.
The solution is to iterate in reverse:

function changeClassName() {
  var buttons = document.getElementsByClassName('editButtonDisabled');

  for (var i = buttons.length - 1; i >= 0; i--) {
    var button = buttons[i];

    button.className = 'editButtonEnabled';
  }
}
button {
  display: block;
  margin-bottom: .5em;
}
.editButtonDisabled {
  background: red;
}
.editButtonEnabled {
  background: green;
}
<button onclick="changeClassName()">changeClassName()</button>

<button class="editButtonDisabled">Button 01</button>
<button class="editButtonDisabled">Button 02</button>
<button class="editButtonEnabled">Button 03</button>
<button class="editButtonDisabled">Button 04</button>
<button class="editButtonDisabled">Button 05</button>
<button class="editButtonDisabled">Button 06</button>
<button class="editButtonEnabled">Button 07</button>
<button class="editButtonDisabled">Button 08</button>
<button class="editButtonDisabled">Button 09</button>
<button class="editButtonDisabled">Button 10</button>


text:
Q: Bounded Lipschitz function space is separable for uniform norm For another proof I want to understand why $BL(S,d)$ is separable for uniform norm if $(S,d)$ is totally bounded. Here is an explanation in this site that I dont understand: Ref. Requst: Space of bounded Lipschitz functions is separable if the domain is separable.
I know that $C(\tilde{S})$ is compact, where $\tilde{S}$ is the completion of S, hence separable for $\|\cdot\|_{\infty}$
If we construct an isometry $BL(S,d)\rightarrow C(\tilde{S})$, how can from this follow that $BL(S,d)$ is separable if this is not an isomorphism? I really don't know much about functional analysis, so thanks for any help.

A: $C(S)$ is never compact for any $S$! Indeed it is a normed vector space and no non-zero normed vector space is compact:
$$\bigcup_{n\in\mathbb N} B_n(0)=V$$
but $V$ definitely isn't $\bigcup_{m=1}^M B_{n_m}(0)=B_{n_M}(0)$, where $n_1<n_2<...<n_M$ is a finite subsequence of $\mathbb N$. (Here $B_\epsilon(x)$ is the epsilon ball around $x$.)
However, for a compact $X$ you have that $C(X)$ is separable, this is an application of Stone-Weierstrass, you can read about it here.
Our situation is the following:
$$BL(S)\cong BL(\tilde S) \hookrightarrow C(\tilde S)$$
where the inclusion into $C(\tilde S)$ is isometric. So basically you can identify $BL(S)$ with a subset of $C(\tilde S)$, which is separable. But any subset of a separable metric space is itself separable. The proof goes like this:
Let $\{x_n\mid n\in\mathbb N\}$ be a dense subset of $C(\tilde S)$. For each $n,m\in\mathbb N$ choose an element $y_{n,m}\in BL(S)$ so that
$$y_{n,m}\in\{y\in BL(S)\mid d(x_n,y)<\frac1m\}$$
provided that set is non-empty of course (if it is empty set $y_{n,m}=0$). The set
$$\{y_{n,m}\mid (n,m)\in\mathbb N^2\}$$
is a countable subset of $BL(S)$.
It is also dense, for if $y\in BL(S)\subset C(\tilde S)$ and $\epsilon>0$ you have an $x_n$ and an $m$ so that $\epsilon>\frac2m$ and $B_{1/{m}}(x_n)$ contains $y$ (since $\{x_n\}$ is dense). But then $y_{n,m}$ has distance $<\frac1m$ from $x_n$ and thus distance $<\frac2m<\epsilon$ from $y$. Thus every open set around $y$ contains an element from $y_{n,m}$.


text:
Q: How to reset the command window size? Has anyone figured out how to reset the command window size to its original? Somehow it's got itself mussed up and I'd like to get the default size back.
Here's where I'm at:

And here's where I'm trying to get back to:

This is an odd one. I've never seen it before. Google, the sum of human knowledge, isn't much help here I'm afraid.

A: If you've changed the defaults then simply change them back. Right click the title bar, select Defaults and set the Window Size:Height to 25.


text:
Q: How to get started on TDD with Ruby on Rails? I am familiar with the concepts (took testing classes in college), but I am not sure how to really use them yet since I never worked on a "real" TDD project.
I am about to start the development of a project using Ruby on Rails (most likely using 2.3). This application will be used to manage data, users and some files. It won't be too complicated at first but might scale a lot in the next 6 months so I feel this is the right time to get more into TDD.
I've got a basic idea on how to do it, but I still need some pointers and advices:

*

*What Ruby on Rails TDD 101 article
should I read?

*What do I need to test?

*What gem/plugin should I use?

*Should I use rspec? Something else?

*Once I've got all my testing classes, how do I go and deploy them? (e.g.: Continual Integration)

*How time consuming TDD really is?

*Do I need to read a book about this or can I get everything just by playing around with it and reading online tutorials? If I need to read a book, what book?

I like learning with examples so could someone tell me how I would go and take a TDD approach to solve this issue:

I have Companies. I have Contacts. A
  contact can be linked to 1 company. A
  company can have multiple contacts. I
  want to create ways to create
  contacts, companies and link contacts
  to companies.

You don't have to use this example in your answer but it would help :)

A: I recommend this book: Ruby on Rails Tutorial. I'm almost done with it. The book uses TDD the whole book. Give it a try!

A: I recommend this book: Agile Web Development with Rails

A: TDD is all about writing tests first. This basically forces you to write your own client before you write your application code. The cycle is generally write a test for an API that doesn't exist, run the test expecting it to fail, go write your API code, run your test again and make sure it passes. Then write your next test... and so on.
You might also be interested in this Rails guide.

A: I use :

*

*Shoulda and rspec for testing

*Mocha for mocking

*Factory_girl for factories

*parallel_specs for faster testing

*metric_fu for code analysis

A:
What gem/plugin should I use?

I've always enjoyed shoulda.

How time consuming TDD really is?

The reason I've always favored TDD development is that it focuses how I will implement a specific piece of code.  I have an anecdotal feeling that whenever I adhere more strongly to TDD principles I spend less time reworking later.  The amount of time spent is all in how well you write unit tests though.  If the unit tests don't capture the expected behavior, all the time spent on them is wasted.

A:
What Ruby on Rails TDD 101 article should I read?

I will start with a guide to testing rails applications.
Also Railscast has some excellent screencasts about how to use different testing tools.

What do I need to test?

I will start with models, since they are easy to test. The simple rule is that you need to cover every if statement in your test.
You should test the purpose of the method (to make sure it is functioning as expected) as well as all edge cases.
Also make sure you don't end up over testing.

What gem/plugin should I use? Should I use rspec? Something else?

When you start, just use Test Unit. You can use rspec or cucumber after you get familiar with the basics.
Autotest is a nice tool to have if you want to be truly test driven. But it is a 'nice have' not required.

Once I've got all my testing classes how do I go and deploy them?

Not sure about the question. You don't usually deploy the tests. Once you have all your testing classes simple type 'rake test' to run all your tests.

How time consuming TDD really is?

It saves time really. If you like labyrinth puzzle, you know it is almost always easier to solve it if you go from finish to start. Same with TDD. Without Test Driven you are consistently thinking 'what should i do next'. With Test Driven, the test will tell you what to do next (it breaks if the logic is not there so you just need to fix the broken part). Also you have less bugs which will save you a lot of time in the long run.

Do I need to read a book about this or
  can I get everything just by playing
  around with it and reading online
  tutorials? If I need to read a book,
  what book?

You do not need a book. The most efficient way of learning anything is: just do it. Go back to the book or online resources once you encounter a question or problem. This is agile too.
In your example, the things that need testing are: A contact can be linked to 1 company, A company can have multiple contacts, create ways to create contacts, and link contacts to companies.
class CompanyTest <Test::Unit
    def test_relationship # test associations/relationships
        c = companies(:some_company)
        assert_equal [a list of contacts], c.contacts # make sure a company can have multiple contacts
    end
end

class ContactTest<Test::Unit
   def  test_relationships
        c = contact(:some_contact)
        assert_equal some_company, c.company # make sure the contact link to 1 company
   end

   def  test_create/add
        # test create contacts, here you need to make sure the contact is created correctly, and linked to company correctly
   end
end

A: I've produced a 6-episode video series which was taught as a public class in San Francisco in the summer of 2010. The material covers testing and developer efficiency in Rails 2.3 using RSpec 1.3.  Slightly dated, but the main concepts apply to Rails 3 with Rspec 2.x
http://www.rubyfocus.biz/class_video/2010/07/19/rails_tdd_class_1.html


text:
Q: Asymptotic Notation difference Is O(2n) same as 2O(n)? If yes, how can I claim it or it is obvious?

O represents Big O

A: No, it's not the same. If it were true, we would have for example 2^(2n) ∈ O(2^n). In other words, there exists a k such that k 2^n dominates 2^(2n).
But for every k, we have that
k 2^n < 2^(2n)

for all n > log2(k).
Therefore, 2^(2n) ∉ O(2^n).


text:
Q: Convert CharCode to Char? What I need
ok I googled this and there are many tutorials on how to get the charCode from the character but I cant seem to find out how to get the character from the charcode.
Basically I am I am listening for the KeyDown event on a TextInput.
I prevent the char from being typed via event.preventDefault();
Later I need to add the text-char to the TextInput.
I can get the charCode via event.charCode so if I can turn that into a string I can save it for later user.
Why I need it
Basically I am making a TextInput, that that I can set to display default text in it. When A user types into it, I want to remove the default text first then add the user typed text.
Currently I am either removing it all, or ending up with both.

A: It's simple:
var yourNewChar:String = String.fromCharCode(event.charCode);


text:
Q: DbgHelp.dll : calling SymGetModuleInfo64 from C# I have quite strange behaviour calling SymGetModuleInfo64 from C# code.I always get ERROR_INVALID_PARAMETER (87) with Marshal.GetLastWin32Error().I have already read a lot of posts regarding problems with frequent updates of IMAGEHLP_MODULE64 struct and I just downloaded latest Debugging Tools For Windows (x86) , loaded dbghelp.dll from that location and I was quite sure it would work.Nevertheless I am getting the same error.Can anyone point me what is wrong here?
IMAGEHLP_MODULE64 struct is defined in my code as follows :
[StructLayout(LayoutKind.Sequential)]
  public struct IMAGEHELP_MODULE64
  {
   //************************************************
   public int SizeOfStruct;
   public long BaseOfImage;
   public int ImageSize;
   public int TimeDateStamp;
   public int CheckSum;
   public int NumSyms;
   public SymType SymType;
   [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
   public string ModuleName;
   [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
   public string ImageName;
   [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
   public string LoadedImageName;
   //************************************************
   //new elements v2
   //*************************************************
   [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
   public string LoadedPdbName;
   public int CVSig;
   [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 780)]
   public string CVData;
   public int PdbSig;
   public GUID PdbSig70;
   public int PdbAge;
   public bool PdbUnmatched;
   public bool DbgUnmatched;
   public bool LineNumbers;
   public bool GlobalSymbols;
   public bool TypeInfo;
   //************************************************
   //new elements v3
   //************************************************
   public bool SourceIndexed;
   public bool Publics;
   //************************************************
   //new elements v4
   //************************************************
   public int MachineType;
   public int Reserved;
   //************************************************
  }

the piece of code that actually calls SymGetModuleInfo64 is like this :
public void GetSymbolInfo(IntPtr hProcess,long modBase64,out bool success)
  {
   success = false;
   DbgHelp.IMAGEHELP_MODULE64 moduleInfo = new DbgHelp.IMAGEHELP_MODULE64();
   moduleInfo.SizeOfStruct = Marshal.SizeOf(moduleInfo);

   try
   {
    success = DbgHelp.SymGetModuleInfo64(hProcess, modBase64, out moduleInfo);

    if (success)
    {
     //Do the stuff here
    }
   }
   catch (Exception exc)
   {
   }
  }

Im stuck here...always with error 87.Please someone points me to the right direction.
By the way modBase64 is value previously populated by :
modBase64 = DbgHelp.SymLoadModule64(_handle, IntPtr.Zero, fileName, null, baseAddress, size);

where _handle is process handle of process being debugged,fileName is path of current loaded module, baseAddress is address base of currently loaded module and size is of course the size of current loaded module.I call this code when I get LOAD_DLL_DEBUG_EVENT.
Edit :
Sorry, I forgot to mention that SymGetModuleInfo64 signature is like this :
[DllImport("dbghelp.dll", SetLastError = true)]
    public static extern bool SymGetModuleInfo64(IntPtr hProcess, long ModuleBase64, out IMAGEHELP_MODULE64 imgHelpModule);

First of all thank you for your answer.
1.Checked SymType and it's underlying type is really int.
2.Changed GUID struct to System.Guid
3.Added CharSet=CharSet.Auto in the definition of IMAGEHELP_MODULE64 struct.
4.Commented last two fields.
5.Checked the size of struct and it is 3264 bytes (Unicode) and 1672 bytes (Ansi) using Marshal.SizeOf(instance_of_the_struct).
dbghelp.dll is loaded from %windir%\system 32 folder, Im using windows server 2008 enterprise and still no success.Im still getting the same error - 87.
In second attempt I uncommented last two fields , and used dbghelp.dll from Debugging Tool For Windows (x86) directory since I downloaded newest version a couple of days ago and in SDK\inc there is dbghelp.h file which says that structure is using last two fields (v4) as like in this code snippet :
//
// module data structure
//

typedef struct _IMAGEHLP_MODULE64 {
    DWORD    SizeOfStruct;           // set to sizeof(IMAGEHLP_MODULE64)
    DWORD64  BaseOfImage;            // base load address of module
    DWORD    ImageSize;              // virtual size of the loaded module
    DWORD    TimeDateStamp;          // date/time stamp from pe header
    DWORD    CheckSum;               // checksum from the pe header
    DWORD    NumSyms;                // number of symbols in the symbol table
    SYM_TYPE SymType;                // type of symbols loaded
    CHAR     ModuleName[32];         // module name
    CHAR     ImageName[256];         // image name
    CHAR     LoadedImageName[256];   // symbol file name
    // new elements: 07-Jun-2002
    CHAR     LoadedPdbName[256];     // pdb file name
    DWORD    CVSig;                  // Signature of the CV record in the debug directories
    CHAR     CVData[MAX_PATH * 3];   // Contents of the CV record
    DWORD    PdbSig;                 // Signature of PDB
    GUID     PdbSig70;               // Signature of PDB (VC 7 and up)
    DWORD    PdbAge;                 // DBI age of pdb
    BOOL     PdbUnmatched;           // loaded an unmatched pdb
    BOOL     DbgUnmatched;           // loaded an unmatched dbg
    BOOL     LineNumbers;            // we have line number information
    BOOL     GlobalSymbols;          // we have internal symbol information
    BOOL     TypeInfo;               // we have type information
    // new elements: 17-Dec-2003
    BOOL     SourceIndexed;          // pdb supports source server
    BOOL     Publics;                // contains public symbols
    // new element: 15-Jul-2009
    DWORD    MachineType;            // IMAGE_FILE_MACHINE_XXX from ntimage.h and winnt.h
    DWORD    Reserved;               // Padding - don't remove.
} IMAGEHLP_MODULE64, *PIMAGEHLP_MODULE64;

I didnt have any success using both of these versions of struct and I have no more ideas.
As for address I am passing , Im pretty sure it is ok since I get it from SymLoadModule64 function as I stated before.
Hope someone will have idea what's going on here.

A: Try changing the last parameter (imgHelpModule) from out to ref. For an out parameter, the CLR will not marshal any data into the function, so the API will not see the value you  put into SizeOfStruct.