text:
Q: Bash shell: how to reconcile portable configuration files and GUI terminal start-up types (login or interactive)? In an attempt to "properly" implement a standard configuration of my preferred shell, bash, for use across multiple platforms, I've come across some confusion when dealing with terminals that are inconsistent with their choice of shell start-up types (login or interactive).
Bash Start-Up Files
From the bash manual, I've determined the difference between the start-up files and order/cases in which they are sourced (/etc/profile, ~/.bash_profile, ~/.bash_login, and ~/.profile for login shells, and ~/.bashrc for interactive non-login shells). The documentation suggested that you store your bash-specfic login configuration in ~/.bash_profile and your bash-specific interactive ones in your ~/.bashrc. The manual itself even suggested adding if [ -f ~/.bashrc ]; then source ~/.bashrc; fi to the ~/.bash_profile file so login shells inherit your interactive shell settings.
From what I've read in the manual and in various online forums/docs, it also seemed prudent to abstract your non-bash specific login configuration to ~/.profile since other shells can source this file. This may be an edge-case for people who may use Bourne shell in addition to bash (which is not really likely in my case), but it seems like a good habit to form.
So far this all seems pretty straight forward and logical, especially in an environment where the distinction between the various shell start-up types are apparent: on systems or terminals where the command-line is the primary interface, login shells are your primary session shells, interactive shells are subsequent shells launched in that session, and your non-interactive shells are script-running shells.
The real confusion is what constitutes a login shell when your shell is started from a terminal within a GUI environment where you are already authenticated to the system? It seems to me that the default behavior in Mac OSX Terminal.app is for the shell running in each window to start a login shell, whereas in xterm, each new window is an interactive shell.

It is possible that I am seeing a problem where one does not exist, however consider the following: the terminal situation suggests that I put the vast majority of my configuration in ~/.bashrc to avoid losing functionality should I be working on a terminal that starts bash as an interactive shell. Being unfamiliar with the intricacies of when bash might be spawned as interactive shells, I have to rely on this statement that abusing ~/.bashrc like this will eventually cause problems where login shell configuration being misplaced is detrimental to normal shell functioning. It isn't hard to imagine that problems might arise when you ignore the manual's advice and use configuration files inappropriately.
Since you can't really rely on using ~/.bashrc as your catch-all, it seems like you might need to treat your ~/.bash_profile and ~/.bashrc files differently depending on the terminal you are using. This seems like it would result in a lot of headaches and is counter to the purpose of having these distinct start-up files in the first place!
So finally my questions are as follows:

*

*How do current Bash shell users address the issue of GUI terminal inconsistencies between starting login and interactive shells?

*How do you create a single-set of bash start-up files for cross-platform (and cross-terminal) use, without running into problems?
Thank you for your assistance and advice.

A: The most common problem caused by misuse of shell startup files is that if you define environment variables in .bashrc as opposed to .profile, they are not defined in applications that are not launched from a shell in a terminal but rather from a GUI menu.
Defining environment variables from .bashrc is generally not a good idea, but that's primarily because it's generally useless as the variables should already have been set at login time. It can cause a problem in practice if you (or an application) have deliberately changed the value of a variable (e.g. PATH) in a program and you launch a shell from that program and expect the setting to have remained the same.
You can avoid the problem of environment variables being reset by defining a "sentinel" value, and not defining anything if the sentinel value is set:
if [ -z "$JMLANE_PROFILE_READ" ]; then
  export ...
  export JMLANE_PROFILE_READ=1
fi

Another problem caused by terminals starting login shells is that there are things that should only be done once when you log in, for example starting a password agent (e.g. ssh-agent), or initiating a session (e.g. running startx in certain circumstances). The sentinel variable avoids these issues.
A shell inside a terminal is always interactive. As long as you source .bashrc from .bash_profile when the shell is interactive, you don't need to worry about the terminal starting a login shell.
An additional wart of bash's startup file handling is that .bashrc is read by non-interactive shells invoked by rshd or sshd. For example, when you do rsync somefile host.example.com:, if your login shell on host.example.com is bash, you can use .bashrc there to set the path to include rsync. You can tell you're in this situation because .bashrc is read from a non-interactive shell.
## .bashrc
if [[ $- != *i* ]]; then
  # either .bashrc was executed explicitly or this is a noninteractive rsh/ssh session
fi


text:
Q: return a value out of an eventListener that is inside of a forof loop How can I pass the returned coin object from the displayCurrencies function to the getCoinId function to use it as a parameter in the API call for retrieving the specific coin data?
this is the function i created to return the value:
let returnID = (value) => {
  return value;
};

this is the function that i want to return coin from:
let displayCurrencies = async () => {
  let coinsContainer = document.querySelector(`.coins`);
  try {
    let coins = await getData();
    let coinsArray = [];
    let coinElement;
    for (const coin of coins) {
      coinElement = coin;

      if (coinsArray.length > 20) {
        break;
      }
      coinsArray.push(coin);
      // create Nodes
      let coinDisplay = createElement(`li`, `coin`);
      let coinSymbolElement = createElement(`p`, `coinSymbol`);
      let coinIDElement = createElement(`p`, `coinID`);
      // set Values
      coinSymbolElement.innerHTML = coin.symbol;
      coinIDElement.innerHTML = coin.id;

      // append
      coinDisplay.append(coinSymbolElement, coinIDElement);
      coinsContainer.appendChild(coinDisplay);

      coinDisplay.addEventListener(`click`, () => {
        openModal();
        returnID(coin);
      });
    }
    let returnCoin = returnID
    coinDisplay.addEventListener(`click`, () => {
    console.log(returnCoin);
    });

    console.log(returnCoin);

  } catch (error) {
    console.log(error);
  }
};

and last, this is the function that i want to use the returned value at:
displayCurrencies();
let getCoinId = async () => {
  let coinID = await displayCurrencies();
  let currencyData = `https://api.coingecko.com/api/v3/coins/${coinID}`;
  let responseData = await fetch(currencyData);
  let dataOfCoins = await responseData.json();
  console.log(dataOfCoins);
};

A: You can simply add an onclick event for each element, and when the call-back is called you invoke the getCoinID function passing the coinID as a parameter.
A simple example:

<ul class="coins">
</ul>

<script>
    function addOnClick() {
        let coinsContainer = document.querySelector('.coins');
        let coins = [
            { id: 1, symbol: 'bitcoin' },
            { id: 3, symbol: 'brazil-fan-token' },
            { id: 4, symbol: 'celo-euro' },
        ]

        for (const coin of coins) {
            let coinDisplay = document.createElement('li')
            let coinSymbolElement = document.createElement('p')
            let coinIDElement = document.createElement('p')

            coinSymbolElement.innerHTML = coin.symbol
            coinIDElement.innerHTML = coin.id

            coinDisplay.appendChild(coinIDElement)
            coinDisplay.appendChild(coinSymbolElement)

            coinsContainer.appendChild(coinDisplay)

            coinDisplay.addEventListener('click', () => {
                getCoinID(coin.symbol)
            })
        }
    }

    async function getCoinID(coinID) {
        let currencyData = `https://api.coingecko.com/api/v3/coins/${coinID}`
        let responseData = await fetch(currencyData)
        let dataOfCoins = await responseData.json()
        console.log(dataOfCoins)
    }

    addOnClick()
</script>

redpajama_set_name: RedPajamaStackExchange


text:
Q: Manage logins on a certain page Is it some way that you could manage your logins on a certain page via some other page?
For ex:
You have an account on site A and you would like to track the amount of times you login to that page via site B.
Thanx in advance.
//Richie

A: What I'd do is:
1. I'll create a database variable for site A that increments each time the
   site is visited.
   You can do this by creating a MySQL database and accessing it with PHP
   from the site.
2. This database can then be accessed from the other site, namely B, which
   will have the count as a field.
3. For security reasons you can create username and password fields and ask for
   them each time you try to access the count variable.

Does this answer your question?
You can find the basics of creating a database here.

EDIT :
You have to create a database with count variable.
 This database can be accessed from both the sites.
You can use php for this.
 From what you say, I think, you can use one site to increment the count variable and the other to access and show it on the page.
 Also, you can create 2 more fields, username and password along with count.
 If you have 200 users, create a record for each of them.
Do you get it?


text:
Q: Convert HEX to RGB in Excel I have a column "HEX" and three columns "R", "G", and "B".
How can I convert a HEX to RGB, e.g. ff0000 to R=255, G=0, and B=0?
I know that the first 2 characters ff belongs to "R", the next 2 00 belongs to "G", and the final 2 00 belongs to "B". So I will have to use =LEFT(A1, 2) for "R", =RIGHT(LEFT(A1, 4), 2), and =RIGHT(A1, 2) for the last.
But how can I convert ff to 255 and 00 to 0, etc.? I guess I will have to do something to parse from hexadecimal (base 16) to decimal (base 10)?
I would like to do it without VBA.

A: You can convert from hex to decimal using the HEX2DEC() function. For instance:
=HEX2DEC(A1)

Where cell A1 contains the string FF, this will return 255.
More details here.

A: I have managed to create a excel spreadsheet that converts Hex to RGB in three columns; Red, Green and Blue.  Below is the code for it:
Red: =HEX2DEC(LEFT([Cell],2))
Green: =HEX2DEC(MID([Cell],3,2))
Blue: =HEX2DEC(RIGHT([Cell],2))
So far, I have not found any restrictions to this code.
I also made code for RGB to hex:
=DEC2HEX(([Red]*65536)+([Green]*256)+[Blue],6)
I hope this answers your question.

A: You can try with the =Hex2Dec(A1) indeed, but you should split its input into 3 parts:
One for R, one for G and one for B, considering that you would always get them in a format like this ff0000.
=HEX2DEC(LEFT(B1,2))&"-"&HEX2DEC(MID(B1,3,2))&"-"&HEX2DEC(RIGHT(B1,2))

This is the result from the formula:

A: Some pages make that (w3SCHOOL PICKER), but in excel you can make this
vba rgb to hex and inverse
If you try without vba, you'll only can use 56 colors.
(in case use the colors from a cell)


text:
Q: Sheafification of constant real sheaf on smooth manifold and sheaf of smooth functions I have a question that has been motivated by this one.
Since $H^k_{dR}(M)\cong \hat{H}^k(M;\mathbb{R}_M)$ I was wondering if the constant sheaf $\mathbb{R}_M$ was isomorphic to the sheaf of $C^{\infty}$ functions $f:M\to \mathbb{R}$. From the definition of the constant sheaf I think it's clear that it "contains" the sheaf of $C^{\infty}$ functions since the stalks determine germs of these functions, but it looks like there can be many more functions, since one can consider just $C^1$ functions with those germs for example.
If they are not isomorphic, is $H^k_{dR}(M)\cong \hat{H}(M;C^{\infty})$?


text:
Q: Find the volume of the solid obtained by rotating the region bounded by the curves $y=x^2$, $x=4$ and $y=0$ about the $x$-axis I do not understand how they want the volume between $y=x^2$ and $y=0$? I don't understand how to do the problem. Please help. I have other similar homework problems and would like to LEARN how to do them properly.

A: The first step is to find the area between the given curves. I like to draw a picture. Here we have a parabola $y=x^2$ and two lines $x=4$, which is a vertical line, and $y=0$, which actually is just the x axis. Think now of rotating this area around the x axis. You get a sort of bell or horn shaped thing. What if we cut this horn into really thin disks that are circles with radius $x^2$ going perpendicular to the x axis? We could find their volume, add it up, and get the total volume.
This should make you think of an integral.
The volume of each thin disk I mentioned is $\pi r^2$ times the disk thickness "dx", which we could also write as $\Delta x$. The radius r of each disk is $x^2$. So, en total we can form an integral $\int_0^4 \pi (x^2)^2 dx=\int_0^4 \pi (x^4)dx$.
Maybe consult a good calculus text to see more methods.


text:
Q: i want to change the values of html div using javascript Is it possible to change the values of HTML through a JavaScript-function?
Here's an example:
div class="fb-page" data-href="https://www.facebook.com/ConnectCommunications?fref=ts"
  data-width="450" data-hide-cover="false" data-show-facepile="true" data-small-header="false"
  data-show-posts="true"></div

Now I want to change data-show-facepile from true to false through a JavaScript onclick-event.
Thanks in advance!

A: With clean JavaScript in the browser:
document.getElementByClassName('fb-page').setAttribute('data-show-facepile', false), see here for more information on that. It can be smart to give the element an id, and then use document.getElementById() instead.
Now, if you have a button <button id="clickme"> Click me! </button> you can add a handler:
document.getElementById('clickme').addEventListener('click', function(){
    document.getElementByClassName('fb-page')[0].setAttribute('data-show-facepile', false)
});

Note that if there are more than one element of the fb-page-class, the element you want to change may not be the first element of the returned list.

With jQuery: $('.fb-page').attr('data-show-facepile', false). Docs. If you give the element an id, you use $('#id') instead.
So if you have a button: <button id="fb-show-button">Click me! </button> you add a handler:
$('#fb-show-button').click(function(){
    $('.fb-page')[0].attr('data-show-facepile', false)
})

The note from above also affects this example.

Why do I mention the use of id instead of class? Because when there's a specific element you want to handle, the ID will identify it uniquely, as only one element can have a specific id. More than one element can have the class fb-page. That's why the methods getting elements of a class returns an array.

A: Assuming you want to click on the div, like this:
 $('.fb-page').on('click', function(){
     $(this).data('show-facepile', false);
 });

A: Very simple:
1) Give your Div an ID
2)
function YourEvent() {
   $('IdOfYourDiv').prop('data-show-facepile', true)
 }

A: Use jquery.data()
<button>Go</button>

Test

jQuery:
alert(jQuery('.fb-page').data('show-facepile'));
jQuery('button').on('click', function(){
    jQuery('div').data('show-facepile', false);
    alert(jQuery('.fb-page').data('show-facepile'));
});

http://jsfiddle.net/2taxxnwn/


text:
Q: How would I insert a word into a string? I have a string https://www.exampleurl.com/
How would I insert a word in the middle of a string so it could look like this: https://www.subdomain.exampleulr.com/
I know I can insert the word if I did this:
url = 'https://www.exampleurl.com/'
url[:12] + 'subdomain'

It prints me https://www.subdomain, but I can't figure out how to print the rest of the string dynamically so it would adjust to the subdomain that is being appended to the string.
My goal is for the end result to look like the following https://www.subdomain.exampleurl.com/

A: url = 'https://www.exampleurl.com/'
content = url.split("www.")

url = content[0] + "www." + "subdomain." + content[1]

A: url = 'https://www.exampleurl.com/'
text = url.split(".")

url =  text[0] + '.subdomain.' + text[1] + '.' + text[2]

Final output : https://www.subdomain.exampleurl.com/

A: Better split on the first .:
l = url.split('.', 1)
l[0] + '.subdomain.' + l[1]

## OR if subdomain is a variable:
f'{l[0]}.{subdomain}.{l[1]}'

output: 'https://www.subdomain.exampleurl.com/'

A: Using replace (once)
url = 'https://www.exampleurl.com/'
url = url.replace(".", ".subdomain.", 1)   # only replaces first "." to
                                           # get desured result


text:
Q: QGIS 3.44 heatmap to contour file I am trying to convert a point file, currently displayed into a contour file. The methods that I have tried, all expect a raster file as an input, but my source file is a vector file points, i.e.
I have tried the gdal colour plugin with the following results
Not what I was expecting, I was hoping for a blob that represented the deep red in the first image and perhaps some other bands. There must be a better way of doing this unless I have missed something important! Any sugggestions?


text:
Q: Datatables table tool design change? I am using datatables table tool plugin for exporting to csv file..the button usually shown on the top of the datatables...but i want to show below the table how to do that?

A: post your code
you need to edit the "sDom" parameter to position it.
check out this example where it is added to top and bottom http://datatables.net/release-datatables/extras/TableTools/multi_instance.html


text:
Q: Is there a convention for brunch.io style 'skeletons' - for Ember / CLI? I'm getting to a point with Ember CLI where I need to follow a long list of things at the beginning of every project. (I'm making many projects a week)
add stylus, add fastclick -- copy and paste in the content security policy into the environment ---- partial out the head ... drag over some styles from bower... - most of this is extremely easy and fast - it's not that I'm lazy - with the package.json - or bower.json I could just save them - and paste them into new projects and install/update --- but I imagine there to be a better way.
I am thinking about a branch of a base install... with a git ignore or something... but I'm just wondering if there is a convention and I'm just missing it... like, instead of 'skeleton' it's called 'hampster-wheel' or something.
Any help to keep the refactoring down would be greatly appreciated.  : )

A: OK, the answer is... that there might be, but as of this date - no one on stack overflow knows of anything like it.


text:
Q: Form validation with alerts and out that displays all checked items I've finally been able to validate my radio button and check box. However, I still have some minor issues.
Issues 1:
When I submit my form after filling all the required information, the form outputs all the selected information and yet I notice that when I select multiple check boxes it only displays one in the output summary. Any tips on how to get the other selected check box item to appear for example If I check 2 Items I should see two checked items in the output summary page
Issue 2: The form validation
For each text field, radio box, and check box that is not selected, meaning if I were to fill all but one of the text and submit the form without selecting a radio box and check box, I should receive an alert stating what is missing. However, the alerts ends after step 1 one after the email. it doesn't even alert if no radio box and check box is selected unless I hit submit to validate the form again.
How do I force the from to check for validation from step 1 to 3?
My main concern is to be able to validate the check box and be able to select multiple and have my selection appear in the out put.

<title>Hello and JavaScript</title>


text:
Q: Xamarin gets Permission Denial when setting badge number on Galaxy 8 & 9 I have an app that shows the notification number in the little red dot on the app icon. This works fine on all models except the Samsung Galaxy S9. I have tried many solutions but always get the error

Permission Denial: writing com.sec.android.provider.badge.BadgeProvider uri content://com.sec.badge/apps from pid=32464, uid=10233 requires com.sec.android.provider.badge.permission.WRITE, or grantUriPermission()

The project is a Xamarin Android project in Visual Studio 2017, below is the code that works with all models except S9
In the manifest
<uses-permission android:name="com.sec.android.provider.badge.permission.READ" />
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE" />

The C#
        try
        {
            var context = Android.App.Application.Context;

            // This is the content uri for the BadgeProvider
            var uriPath = "content://com.sec.badge/apps"; //"com.sec.android.app.launcher";
            Android.Net.Uri uri = Android.Net.Uri.Parse(uriPath); //new Uri("content://com.sec.badge/apps");

            ICursor cursor = context.ContentResolver.Query(uri, new string[] { "_id" }, "package=?", new string[] { context.PackageName }, null);

            if (cursor == null || !cursor.MoveToFirst())
            {
                ContentValues cv = new ContentValues();
                cv.Put("package", context.PackageName);
                cv.Put("class", context.PackageManager.GetLaunchIntentForPackage(context.PackageName).Component.ClassName);
                cv.Put("badgecount", count);
                context.ContentResolver.Insert(uri, cv); //Errors here
            }
            else
            {
                int idColumnIndex = cursor.GetColumnIndex("_id");

                ContentValues cv = new ContentValues();
                cv.Put("badgecount", count);
                context.ContentResolver.Update(uri, cv, "_id=?", new string[] { cursor.GetInt(idColumnIndex).ToString() });
            }

        }
        catch (System.Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex.Message);
        }

Like I said, this all works fine with earlier models but errors with the newer models. Is there something that needs to be added to permissions or am I missing something else?

A: I have a fix to my problem. You now need to use a NotificationChannel with your NotificationManager. I have created a small test app with one button. In the button click, I call the code below. I haven't moved this to my live apps yet but it is working good in this test app.
First, add a const to use for the id parameter for the NotificationChannel
public const string CLICKS_CHANNEL = "com.yourcompany.SamsungBadgeTest.clicks";

Now:

*

*Move the declaration of the NotificationManager to be above the NotificationBuilder

*Create the NotificationChannel

*Call the manager's CreateNotificationChannel passing the channel as a parameter

*Make your Notification.Builder

*Build()
    try
    {
        //This is declared at the class level and initially set to 0
        //Incrementing with each button click
        clickCount++;

        int defaults = 0;
        defaults |= (int)NotificationDefaults.Sound;
        defaults |= (int)NotificationDefaults.Lights;
        defaults |= (int)NotificationDefaults.Vibrate;

        var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);

        var chan = new NotificationChannel(CLICKS_CHANNEL, "Button Click", NotificationImportance.Default)
        {
            LockscreenVisibility = NotificationVisibility.Private
        };

        notificationManager.CreateNotificationChannel(chan);

        var notificationBuilder = new NotificationCompat.Builder(this, CLICKS_CHANNEL)
            .SetAutoCancel(true)
            .SetContentText("You've received new messages.")
            .SetContentTitle("A New Message")
            .SetNumber(clickCount)
            //You need to add a icon to your project and get it here
            .SetSmallIcon(Resource.Drawable.ic_stat_button_click)
            .SetBadgeIconType(NotificationCompat.BadgeIconSmall)
            .SetDefaults(defaults); //.Build();

        notificationManager.Notify(0, notificationBuilder.Build());
    }
    catch(System.Exception ex)
    {
        System.Diagnostics.Debug.WriteLine(ex.Message);
    }

Don't forget to add this to your Manifest
<uses-permission android:name="com.sec.android.provider.badge.permission.READ" />
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE" />


text:
Q: Changing all phone numbers SQL I'm building a sample database in SQL Server 2008 R2 for a class and have filled it with dummy data I can create stored procedures and such with.
One of the sprocs I want to create is to change all the phone numbers (all American, 10 digit format) to look like (XXX)XXX-XXXX.
I've purposely entered a group of phone numbers in different fashions and want to have the sproc format them all into a standard format listed above so no matter what style the numbers are entered in the database, they get formatted properly.
I don't even know how to start this. I'm really still new to SQL. ALSO...I'm pulling all the phone numbers on the database, not from just one table.
    CREATE PROC spPhoneNumberFormat
AS

Select Employees.Phone, Vendors.Phone, Vendors.AltPhone
From Employees join Vendors on employees.ID = vendors.ID

Hope you all can help?

A: Since I've no idea which format American phone numbers appear in, I can only provide you with basic instructions on how to parse and handle strings.
You can use REPLACE(1,2,3) to parse the field into its basic form XXXXXXXXXX.
In the replace, 1 is the full string you're handling, 2 is the part of which you want to replace, 3 the part you'll replace it with. So you can for example use REPLACE(PHONENUM,'+','') to remove plus signs. You can combine REPLACE functions or even use REGEX to some extent to parse multiple different characters, strings etc at the same time. Google will provide you with instructions on how.
When you have the phone number in format XXXXXXXXXX, you can use functions such as substring to reformat it. IE:
SELECT '('+SUBSTRING(PHONENUM,1,3)+')'+SUBSTRING(PHONENUM,4,6)+'-'+SUBSTRING(PHONENUM,7,LEN(PHONENUM))

Which would change XXXXXXXXXX into (XXX)XXX-XXXX.
Try and test those and you should get it working in no time at all. :)

A: In the version of SQL Server 2008 I have (r2) it seems the parameters of the substring function are actually (stringname, start location, length). Therefore the appropriate query to change 'XXXXXXXXXX' to '(XXX)XXX-XXXX' is:
update [TableName]

set [phone] = '('+substring([phone],1,3)+')'+substring([phone],4,3)+'-'+substring([phone],7,4)

where len([phone]) = 10

The qualifier (where len([phone]) = 10) will prevent altering any record with more than ten characters - which ensures your phone numbers won't be contaminated if you accidentally run the query twice in a row.

A: Please try it
http://www.codeproject.com/Articles/20596/Telephone-Numbers-in-SQL-Server-2005-Part-2-Format
http://bytes.com/topic/sql-server/answers/705833-phone-number-conversion-xxxxxxxxx
http://www.sqlservercurry.com/2010/11/format-phone-numbers-in-sql-server.html
http://www.sqlservercentral.com/Forums/Topic698934-338-2.aspx
http://forums.devshed.com/ms-sql-development-95/format-phone-number-253468.html
http://www.katieandemil.com/t-sql-yyyymmdd
i hope
It is
helpful to you


text:
Q: 'The good of the people' & 'follow in everything the general will'
The first and most important rule of legitimate or popular government, that is to say, of government whose object is the good of the people, is therefore, as I have observed, to follow in everything the general will
Source: a sample passage for interpretation

Would you tell me what the following mean?

The good of the people
follow in everything the general will

In addition, what does will mean here?

A: "For the good of the people" means "in the best interests of the citizens". It's an important distinction that the line does not mean that the government should always make the most popular decision. It's saying that the government should always consider what will most benefit the people that they represent or rule.
The second line (follow in everything the general will) does suggest that the government should make the popular choice.
As a whole and without further context, the author is suggesting (wrongly, in my opinion) that the best interests of the people are served by always making the most popular choice.
"Will" in this context means that which the people want and desire. So the government should do what the people want.
It is every parent's "will" that their child be healthy. As children, it is our "will" that our parents always treat us fairly.
EDIT: I addressed the quotes you listed, please do not assume that the answers address the essay in its entirety.

A: This is a passage from [a translation of] an essay by the 18th-century philosopher Jean-Jacques Rousseau, and it deals in 18th-century style with Very Large Abstractions.

*

*The good of the people means that The People—all members of the society, taken as a whole—enjoy The Good—all good things, such as prosperity, security, liberty, happiness, and so forth, taken (again) as a whole.
A "legitimate or popular government", says Rousseau, is one which takes achieving this Good as its primary "object" or purpose.

*Follow means "be led by", as opposed to "lead": such a government must obey the "general will".

*In everything means with respect to all matters: there are no matters which the government can decide on its own, without consulting the "general will".

*The general will is what everybody-taken-together—The People, again—desires, what it requires the government to do. Will is the noun form of the verb to will, which is not the ordinary modal auxiliary but the active verb meaning "desire, wish".


text:
Q: Cygwin: readline lib loaded in different locations Within cygwin, almost each unix command I type prints a warning message, takes time and eventually gives a correct result:
-bash-4.1$ ls
0 [main] bash 7468 child_info_fork::abort: cygreadline7.dll: Loaded to different address:
parent(0x320000) != child(0x3B0000)
-bash: fork: retry: Resource temporarily unavailable

What is the meaning of this warning?

A: Windows loads each dynamic library at the same address in every process. This interacts badly with Cygwin's emulation of fork when there are different versions of a DLL in the parent and child process (i.e. when you upgraded a DLL between the time the parent started and the time the child started). Restart all your Cygwin processes after upgrading a library.

A: The Cygwin FAQ mentions "resource temporarily unavailable" as one of the error messages that can occur because of the way Windows handles process creation. The potential solutions it lists are:

*

*Restart the process

*Remove all applications known to conflict with Cygwin

*Follow the instructions in /usr/share/doc/rebase/README to run rebaseall


text:
Q: How to configure Jest added to an app via Vue cli 3? I'm trying to introduce testing with Jest into an app build with Vue. I've run
vue add unit-jest

and similarly to what testing single file components with Jest guide suggests, created the following simple test file (Paginator.spec.js in the same folder as Paginator.vue, that is /src/components):
import { mount } from '@vue/test-utils'
import Paginator from "./Paginator.vue";

describe('Paginator', () => {
    it('is a Vue instance', () => {
        const wrapper = mount(Paginator);
        // const a = 2;
        expect(wrapper.isVueInstance()).toBeTruthy();
        // expect(a).toBe(2);
    })
});

Initially I had some issue with Jest itself not finding the file. Later I've changed in jest.config.js
testMatch: [
  '**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
],

to
testMatch: [
  '**/*.spec.(js|ts)|**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
],

and after some weird glitches I got it finding the file (did git stash, made sure that the app is working, then git stash pop and it started to find the files).
But I still has the issue of Jest not recognizing import. I get the following errors regardless I run jest or npm test (which is vue-cli-service test:unit). A simple test like this works normally:
describe('tests of components', () => {
    it('work', () => {
        const a = 2;
        expect(a).toBe(2);
    })
});

but the test shown in the beginning of the question brings

Test suite failed to run
  [...]
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { mount } from '@vue/test-utils'
                                                                                ^
SyntaxError: Unexpected token {
  at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)

and if I switch the import order to
import Paginator from "./Paginator.vue";
import { mount } from '@vue/test-utils'

I get
● Test suite failed to run

  C:\NNTC\medkiosk\src\components\Paginator.spec.js:1
  ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import Paginator from "./Paginator.vue";
                                                                                ^^^^^^^^^

  SyntaxError: Unexpected identifier

    at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)

(I haven't changed jest.config.js in any fashion other than extending the regexp as shown above)
What's the problem here? Looks like Jest doesn't recognize import as a language feature.. is this a webpack misconfiguration issue? Some loader is missing?

*

*There's no webpack config file in the project because it was started with vue cli. One guy claims that the actual config is in node_modules/@vue/cli-service/webpack.config.js it's not that helpful:
// this file is for cases where we need to access the
// webpack config as a file when using CLI commands.

let service = process.VUE_CLI_SERVICE

if (!service || process.env.VUE_CLI_API_MODE) {
  const Service = require('./lib/Service')
  service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd())
  service.init(process.env.VUE_CLI_MODE || process.env.NODE_ENV)
}

module.exports = service.resolveWebpackConfig()

(resolveWebpackConfig seems to be this one)

*As I understand this, tweaking internal webpack config is done inside vue.config.js, but I don't know that is the initial config to start modifying and also what is actually should be tweaked

*I've tried npm i babel-jest (not sure if it's installed already by vue cli), adding .babelrc with { "presets": ["latest"] } similarly to what a person with a similar problem did, tried adding to vue.config.js the part the other guy from that thread suggested:
configureWebpack: {
    module: {
        rules: [
            {
                loader: "babel-loader",
                options: {
                    presets: ["latest"]
                }
            }
        ]
    }
},

and also some suggestions from here and for now I'm out of ideas

*below you can see all the config files

*a bonus: if I rename the Paginator.spec.js into Paginator.spec.ts makes Jest show this instead:
● Test suite failed to run

  Passing cached plugin instances is not supported in babel.loadPartialConfig()

    at forEach.item (node_modules/@babel/core/lib/config/partial.js:120:13)
        at Array.forEach (<anonymous>)
    at loadPartialConfig (node_modules/@babel/core/lib/config/partial.js:118:27)
    at TsJestTransformer.process (node_modules/ts-jest/dist/ts-jest-transformer.js:110:32)

Can anyone suggest how to fix the config? Or how to debug it? From what I've read so far it seems that probably Jest should get a file piped through babel-loader which doesn't seem to be the case, but I'm not sure. I know, I probably don't know enough about how Webpack works exactly, so hints what to learn are welcome as well, I'll post the solution when I find one.
jest.config.js:
module.exports = {
  moduleFileExtensions: [
    'js',
    'jsx',
    'json',
    'vue',
    'ts',
    'tsx'
  ],
  transform: {
    '^.+\\.vue$': 'vue-jest',
    '.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
    '^.+\\.tsx?$': 'ts-jest'
  },
  transformIgnorePatterns: [
    '/node_modules/'
  ],
  moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/src/$1'
  },
  snapshotSerializers: [
    'jest-serializer-vue'
  ],
  testMatch: [
    '**/*.spec.(js|ts)|**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
  ],
  testURL: 'http://localhost/',
  watchPlugins: [
    'jest-watch-typeahead/filename',
    'jest-watch-typeahead/testname'
  ],
  globals: {
    'ts-jest': {
      babelConfig: true
    }
  }
};

babel.config.js:
module.exports = {
  presets: [
    '@vue/app'
  ]
}

vue.config.js:
module.exports = {
    // the default value is '/', which may be ok for production but is not suitable for local build/deploy
    publicPath: ''
};

part of package.json:
  "scripts": {
    "lint": "vue-cli-service lint",
    "serve": "vue-cli-service serve",
    "test:unit": "vue-cli-service test:unit",
    "build": "vue-cli-service build"
  },
  "dependencies": {
    "core-js": "^2.6.5",
    "vue": "^2.6.10",
    "vuex": "^3.1.1",
    "vue-class-component": "^7.0.2",
    "vue-property-decorator": "^8.2.2",
    "axios": "^0.19.0",
    // more packages
  },
  "devDependencies": {
    "@types/jest": "^23.1.4",
    "@vue/cli-plugin-babel": "^3.11.0",
    "@vue/cli-plugin-eslint": "^3.11.0",
    "@vue/cli-plugin-typescript": "^3.11.0",
    "@vue/cli-plugin-unit-jest": "^3.11.0",
    "@vue/cli-service": "^3.11.0",
    "@vue/eslint-config-typescript": "^4.0.0",
    "@vue/test-utils": "1.0.0-beta.29",
    "babel-core": "7.0.0-bridge.0",
    "babel-eslint": "^10.0.1",
    "eslint": "^5.16.0",
    "eslint-plugin-vue": "^5.0.0",
    "ts-jest": "^23.0.0",
    "typescript": "^3.4.3",
    "vue-template-compiler": "^2.6.10"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended",
      "@vue/typescript"
    ],
    "rules": {},
    "parserOptions": {
      "parser": "@typescript-eslint/parser"
    },
    "overrides": [
      {
        "files": [
          "**/__tests__/*.{j,t}s?(x)"
        ],
        "env": {
          "jest": true
        }
      }
    ]
  },
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions"
  ]
}

tsconfig.json:
{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "allowJs": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": [
      "webpack-env",
      "jest"
    ],
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "tests/**/*.ts",
    "tests/**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}


text:
Q: How to debug sqlplus thin client connection I have installed SQLPLUS thin client on a CentOS. Via the client I am trying to establish a TCPS connection with the Oracle 12c. but when I use the following command I get "ORA-28759: failure to open file" exception. However, when I use the TCP connection it works fine.
This does not work:
sudo sqlplus -s 'user/pwd002@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(PORT=1522)(HOST=test.co.uk))(CONNECT_DATA=(SERVICE_NAME=service101))(SECURITY=(ssl_server_cert_dn=CN=test.co.uk)))'
This Works:
sudo sqlplus -s 'user/pwd002@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(PORT=1521)(HOST=test.co.uk))(CONNECT_DATA=(SERVICE_NAME=service101))(SECURITY=(ssl_server_cert_dn=CN=test.co.uk)))'
Now, I googled and found that above reason can be because the client is unable to locate the wallet location which I checked and is correct as well
in sqlnet.ora
SSL_CLIENT_AUTHENTICATION = FALSE
wallet_location = (SOURCE=(METHOD= File)(METHOD_DATA=(DIRECTORY=/home/test/wallet)))
Now, I am not sure if my client is able to locate sqlnet.ora file or not and if not how can I debug it? Any help will be appreciated.

A: Ensure you are setting the TNS_ADMIN to your wallet path before executing the sqlplus
export TNS_ADMIN=/home/test/wallet
If your Oracle client is 19c+, you can set the wallet path in the connection string through variable 'my_wallet_location'
(SECURITY=(SSL_SERVER_DN_MATCH=TRUE)(SSL_SERVER_CERT_DN=cn=sales,cn=OracleContext,dc=us,dc=example,dc=com)(MY_WALLET_LOCATION=/home/test/wallet)))
https://docs.oracle.com/en/database/oracle/oracle-database/19/netag/configuring-naming-methods.html#GUID-36F3A17D-843C-490A-8A23-FB0FE005F8E8


text:
Q: how to filter specific payload bytes in tcpdump? I use command tcpdump -x -r input.pcap and have the following tcp packet:
18:05:08.139615 IP 192.168.5.117.12336 > 192.168.5.2.58542: Flags [P.], seq 4484:4604, ack 91, win 5792, options [nop,nop,TS val 3008071469 ecr 2239920620], length 120
    0x0000:  4500 00ac a172 4000 4006 0d12 c0a8 0575  E....r@.@......u
    0x0010:  c0a8 0502 3030 e4ae 1f09 8634 bb24 e0aa  ....00.....4.$..
    0x0020:  8018 16a0 1372 0000 0101 080a b34b 872d  .....r.......K.-
    0x0030:  8582 79ec d580 0008 7d08 0000 0000 0000  ..y.....}.......
    0x0040:  0000 fd0a ff6f 7308 1200 0a1c 0d0a 0901  .....os.........
    0x0050:  1112 0003 1e1f 0c10 010f 0000 0000 0000  ................
    0x0060:  0000 0000 0000 0000 0000 0000 0000 0000  ................
    0x0070:  0000 0000 0000 0000 0000 0000 0000 0000  ................
    0x0080:  0000 0000 0000 0000 0000 0000 0000 0000  ................
    0x0090:  0000 0000 0000 0000 0000 0000 0000 0000  ................
    0x00a0:  0000 0000 0000 0000 0000 0000

How can I filter byte 8582 at 0x0031? and pipe it to some other command. Does tcpdump has any option to specify bytes to filter from the payload?
I need to filter 2 bytes starting from 0x0030.

A: tcpdump -lx -r input.pcap | grep 0x0030 | awk '{print $2}'

I was looking to do something similar and settle on using grep to get the line for 0x0030, and then awk to split it by whitespace and print the 2nd field i.e. 8582.
The -l option to tcpdump ensures that output to stdout is immediate.


text:
Q: Should a nugget ever shift the variogram away from zero at distance zero? I had frequently seen the definition for a "rigorous" spatial isotropic semivariogram being defined as:
$$
\gamma(h) = K(0) - K(h)
$$
Where $K$ is a positive definite covariance matrix. If the nugget $\sigma$ is applied to the covariance function $K$, then it seems to me that it would always be that $\gamma(0) = 0$, but that $\gamma(0+\delta)>\sigma$ for all distances greater than zero.
However, often in practice a linear function is used to determine $\gamma$:
$$
\gamma(h) = \sigma + \frac{h}{\beta}
$$
Should I really define the nugget in terms of the covariance matrix, or should I make it a separate term:
$$
\gamma(h) = \sigma + K(0) - K(h)
$$
Am I making a mountain out of mole hill here? Are there any reasons to prefer one form or the other?
To visualize, is it more "correct" to pick one form over the other:

Based on the idea of nugget as allowing a non-zero offset at zero, I could see the former should be preferred: but this seems to imply that the nugget is no really part of the assumed covariance matrix.


text:
Q: WPF - Path Geometry on Canvas scaling differently than Thumb control This is a WPF question.
I am trying to track / drag the vertices of a PathGeometry on a Canvas using Thumb Controls to drag the vertices.
It seems that the PathGeometry is scaled differently than the Thumb positions relative to the Canvas.
How can I compute the scaling ratio? Once I have that, I can use a ScaleTransform to correct it.
Thanks in advance.
Here is my XAML. I have a scale value of 3 hard coded, but it doesn't work if my window size changes:
MyControl.XAML

<UserControl x:Class="WPF_Discovery_Client.ColorOpacityControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:WPF_Discovery_Client"
             DataContext="{Binding RelativeSource={RelativeSource Self}}"
             mc:Ignorable="d"
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <Style TargetType="{x:Type Thumb}" x:Key="RoundThumb">
            <Style.Resources>
                <Style TargetType="Border">
                    <Setter Property="CornerRadius" Value="10" />
                    <Setter Property="BorderThickness" Value="1" />
                </Style>
            </Style.Resources>
        </Style>
    </UserControl.Resources>
    <Grid>
        <Canvas Background="aqua" x:Name="MyCanvas" SizeChanged="MyCanvas_SizeChanged" Loaded="MyCanvas_Loaded" >
            <Path Stroke="Black" StrokeThickness="1" Height="450" Stretch="Fill" Width="800" >
                <Path.Fill>
                    <LinearGradientBrush ColorInterpolationMode="ScRgbLinearInterpolation" StartPoint="0,0" EndPoint="1,0">
                        <GradientStop Offset="0" Color="Red"/>
                        <GradientStop Offset="0.17" Color="Orange"/>
                        <GradientStop Offset="0.34" Color="Yellow"/>
                        <GradientStop Offset="0.51" Color="Green"/>
                        <GradientStop Offset="0.68" Color="Blue"/>
                        <GradientStop Offset="0.85" Color="Indigo"/>
                        <GradientStop Offset="1.0" Color="Violet"/>
                    </LinearGradientBrush>
                </Path.Fill>
                <Path.Data>
                    <PathGeometry>
                        <PathGeometry.Figures>
                            <PathFigureCollection>
                                <PathFigure x:Name="MyPath" IsClosed="True" StartPoint="{Binding BottomLeftCorner, Mode=TwoWay}">
                                    <PathFigure.Segments>
                                        <PathSegmentCollection>
                                            <LineSegment Point="{Binding LeftVertex, Mode=TwoWay}"/>
                                            <LineSegment Point="{Binding MiddleVertex, Mode=TwoWay}" />
                                            <LineSegment Point="{Binding RightVertex, Mode=TwoWay}" />
                                            <LineSegment Point="{Binding BottomRightCorner, Mode=TwoWay}" />
                                        </PathSegmentCollection>
                                    </PathFigure.Segments>
                                </PathFigure>
                            </PathFigureCollection>
                        </PathGeometry.Figures>
                    </PathGeometry>
                </Path.Data>
                <Path.RenderTransform>
                    <ScaleTransform ScaleX="2.0" ScaleY="2.0"/>
                </Path.RenderTransform>
            </Path>

            <Thumb Name="LeftThumb" Style="{DynamicResource RoundThumb}" Background="White"
                Width="20" Height="20" DragDelta="LeftThumb_DragDelta"
                DragStarted="LeftThumb_DragStarted"  DragCompleted="LeftThumb_DragCompleted"/>

            <Thumb Name="MiddleThumb" Style="{DynamicResource RoundThumb}" Background="White"
                Width="20" Height="20" DragDelta="MiddleThumb_DragDelta"
                DragStarted="MiddleThumb_DragStarted"  DragCompleted="MiddleThumb_DragCompleted"/>

            <Thumb Name="RightThumb" Style="{DynamicResource RoundThumb}" Background="White"
                Width="20" Height="20" DragDelta="RightThumb_DragDelta"
                DragStarted="RightThumb_DragStarted"  DragCompleted="RightThumb_DragCompleted"/>

        </Canvas>
    </Grid>
</UserControl>

And here is the code behind for the control:
MyControl.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Globalization;
using System.Windows.Controls.Primitives;
using System.ComponentModel;

namespace WPF_Discovery_Client
{
    /// <summary>
    /// Interaction logic for ColorOpacityControl.xaml
    /// </summary>
    public partial class ColorOpacityControl : UserControl, INotifyPropertyChanged
    {
        const int ThumbRadius = 10;

        // Bottom corners
        public Point BottomRightCorner
        {
            get { return (Point)GetValue(BottomRightCornerProperty); }
            set { SetValue(BottomRightCornerProperty, value); }
        }

        // Using a DependencyProperty as the backing store for BottomRightCorner.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty BottomRightCornerProperty =
            DependencyProperty.Register("BottomRightCorner", typeof(Point), typeof(ColorOpacityControl), new PropertyMetadata(new Point(0, 100)));

        public Point BottomLeftCorner
        {
            get { return (Point)GetValue(BottomLeftCornerProperty); }
            set { SetValue(BottomLeftCornerProperty, value); }
        }

        // Using a DependencyProperty as the backing store for BottomLeftCorner.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty BottomLeftCornerProperty =
            DependencyProperty.Register("BottomLeftCorner", typeof(Point), typeof(ColorOpacityControl), new PropertyMetadata(new Point(0, 200)));

        // Thumb center locations
        public Point LeftVertex
        {
            get { return (Point)GetValue(LeftVertexProperty); }
            set { SetValue(LeftVertexProperty, value); }
        }

        // Using a DependencyProperty as the backing store for LeftVertex.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty LeftVertexProperty =
            DependencyProperty.Register("LeftVertex", typeof(Point), typeof(ColorOpacityControl), new PropertyMetadata(new Point(0,266)));

        public Point MiddleVertex
        {
            get { return (Point)GetValue(MiddleVertexProperty); }
            set { SetValue(MiddleVertexProperty, value); }
        }

        // Using a DependencyProperty as the backing store for MiddleVertex.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty MiddleVertexProperty =
            DependencyProperty.Register("MiddleVertex", typeof(Point), typeof(ColorOpacityControl), new PropertyMetadata(new Point(100, 100)));

        public Point RightVertex
        {
            get { return (Point)GetValue(RightVertexProperty); }
            set { SetValue(RightVertexProperty, value); }
        }

        // Using a DependencyProperty as the backing store for RightVertex.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty RightVertexProperty =
            DependencyProperty.Register("RightVertex", typeof(Point), typeof(ColorOpacityControl), new PropertyMetadata(new Point(100, 50)));

        public ColorOpacityControl()
        {
            InitializeComponent();

            DataContext = this;
        }

        private void LeftThumb_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
        {
            LeftThumb.Background = Brushes.Red;
        }

        private void LeftThumb_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
        {
            LeftThumb.Background = Brushes.White;
        }

        private void LeftThumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
        {
            //Move the Thumb to the mouse position during the drag operation
            var yadjust = MyCanvas.ActualHeight + e.VerticalChange;
            var xadjust = MyCanvas.ActualWidth + e.HorizontalChange;
            if ((xadjust >= 0) && (yadjust >= 0))
            {
                // Compute new thumb location
                double X = Canvas.GetLeft(LeftThumb) + e.HorizontalChange;
                double Y = Canvas.GetTop(LeftThumb) + e.VerticalChange;

                // Move thumb
                Canvas.SetLeft(LeftThumb, X);
                Canvas.SetTop(LeftThumb, Y);

                // Compute center of thumb as vertex location
                LeftVertex = new Point(X + LeftThumb.Width, Y + LeftThumb.Height);
                NotifyPropertyChanged("LeftVertex");
            }
        }

        private void MiddleThumb_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
        {
            MiddleThumb.Background = Brushes.Green;
        }

        private void MiddleThumb_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
        {
            MiddleThumb.Background = Brushes.White;
        }

        private void MiddleThumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
        {
            //Move the Thumb to the mouse position during the drag operation
            var yadjust = MyCanvas.ActualHeight + e.VerticalChange;
            var xadjust = MyCanvas.ActualWidth + e.HorizontalChange;
            if ((xadjust >= 0) && (yadjust >= 0))
            {
                // Compute new thumb location
                double X = Canvas.GetLeft(MiddleThumb) + e.HorizontalChange;
                double Y = Canvas.GetTop(MiddleThumb) + e.VerticalChange;

                // Move thumb
                Canvas.SetLeft(MiddleThumb, X);
                Canvas.SetTop(MiddleThumb, Y);

                // Compute center of thumb as vertex location
                MiddleVertex = new Point(X + MiddleThumb.Width, Y + MiddleThumb.Height);
                NotifyPropertyChanged("MiddleVertex");
            }
        }

        private void RightThumb_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
        {
            RightThumb.Background = Brushes.Yellow;
        }

        private void RightThumb_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
        {
            RightThumb.Background = Brushes.White;
        }

        private void RightThumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
        {
            //Move the Thumb to the mouse position during the drag operation
            var yadjust = MyCanvas.ActualHeight + e.VerticalChange;
            var xadjust = MyCanvas.ActualWidth + e.HorizontalChange;
            if ((xadjust >= 0) && (yadjust >= 0))
            {
                // Compute new thumb location
                double X = Canvas.GetLeft(RightThumb) + e.HorizontalChange;
                double Y = Canvas.GetTop(RightThumb) + e.VerticalChange;

                // Move thumb
                Canvas.SetLeft(RightThumb, X);
                Canvas.SetTop(RightThumb, Y);

                // Compute center of thumb as vertex location
                RightVertex = new Point(X + ThumbRadius, Y + ThumbRadius);
                NotifyPropertyChanged("RightVertex");
            }
        }

        private void MyCanvas_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            // Adjust bottom left corners
            BottomLeftCorner = new Point(0, MyCanvas.ActualHeight);
            NotifyPropertyChanged("BottomLeftCorner");

            // Adjust botton right corner
            BottomRightCorner = new Point(MyCanvas.ActualWidth, MyCanvas.ActualHeight);
            NotifyPropertyChanged("BottomRightCorner");
        }

        private void InitializeVertices()
        {
            // Initialize bottom left corner
            BottomLeftCorner = new Point(ThumbRadius, MyCanvas.ActualHeight - ThumbRadius);
            NotifyPropertyChanged("BottomLeftCorner");

            // Initialize bottom right corner
            BottomRightCorner = new Point(MyCanvas.ActualWidth - ThumbRadius, MyCanvas.ActualHeight - ThumbRadius);
            NotifyPropertyChanged("BottomRightCorner");

            // Initialize right vertex
            RightVertex = new Point(MyCanvas.ActualWidth - ThumbRadius, ThumbRadius);
            NotifyPropertyChanged("RightVertex");

            // Initialize left vertex
            LeftVertex = BottomLeftCorner;
            NotifyPropertyChanged("LeftVertex");

            // Initialize middle vertex
            MiddleVertex = new Point(MyCanvas.ActualWidth * 0.5, MyCanvas.ActualHeight * 0.5);
            NotifyPropertyChanged("MiddleVertex");

            // Initialize Left Thumb
            Canvas.SetLeft(LeftThumb, LeftVertex.X - ThumbRadius);
            Canvas.SetTop(LeftThumb, LeftVertex.Y - ThumbRadius);

            // Initialize Right Thumb
            Canvas.SetLeft(RightThumb, RightVertex.X - ThumbRadius);
            Canvas.SetTop(RightThumb, RightVertex.Y - ThumbRadius);

            // Initialize Middle Thumb
            Canvas.SetLeft(MiddleThumb, MiddleVertex.X - ThumbRadius);
            Canvas.SetTop(MiddleThumb, MiddleVertex.Y - ThumbRadius);
        }

        #region INotifyPropertyChanged Members
        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }

        #endregion

        private void MyCanvas_Loaded(object sender, RoutedEventArgs e)
        {
            InitializeVertices();
        }

    }
}

As you can see, I am setting both the vertices and the thumbs to the same position relative to the canvas. However, if you run the code, you can see that the initial triangle with the gradient fill is much smaller than it needs to be. I want the 3 thumbs to coincide with the 2 vertices and the midpoint.
Moreover, I notice that I have a Height and Width specified for the Path, which I am not sure if I need. If I make it larger to match the size of the canvas, the triangle will grow. Should I set Height and with to *?
I am new to WPF graphics, so any help would be appreciated.

A: Well.. after banging my head on the wall for a couple days, I finally figured out how to fix this issue. Hopefully this will save someone a lot of time and hassle down the road.
The problem was that I had the Path width/height set to the size of the parent window, and the Stretch property set to Fill.
Once I made the following change, the scaling came out correct.

    <Canvas Background="Black" x:Name="MyCanvas" SizeChanged="MyCanvas_SizeChanged" Loaded="MyCanvas_Loaded">
        <Path x:Name="MyPath" Stroke="Black" StrokeThickness="1" Height="{Binding MyCanvas.ActualHeight}" Width="{Binding MyCanvas.ActualWidth}" Stretch="None"  HorizontalAlignment="Left" VerticalAlignment="Top">


text:
Q: Database comparison Which industry-class database has the most unique features? (with "unique" meaning that no other RDBMS has them)
I think my choice here is Oracle 11g:

*

*Flashback query (you can estract data as it was a moment in the past)

*ASM - automatic storage management

*Native code compilation of stored procedures

*Audit features (tracing everything, from logins to statements)

and many others.

A: Funny, I rate vendors by their conformance with the ANSI/ISO SQL Standards e.g. for SQL Server my shopping list is deferrable CHECK constraints that support subqueries and proper support for DOMAINs and ASSERTIONs -- and these date from as long ago as SQL-92. For me, vendors should put in proprietary features only after they've implemented the Standard ones :)

A: http://en.wikipedia.org/wiki/Comparison_of_relational_database_management_systems && http://en.wikipedia.org/wiki/Comparison_of_object-relational_database_management_systems would be where I'd start.
As to truly "unique" features? I've seen things I thought were unique that turned out to be common once I did more digging :)


text:
Q: wp_enqueue_script and php scripts I have some javascript in my footer that are only being dropped in if they pass a php check. Due to some page optimisations I would like to enqueue these scripts. I tried to enqueue the php scripts like so:
function add_base_scripts() {
    wp_enqueue_script(get_template_directory_uri() . '/base-scripts.php');
}
add_action('wp_footer', 'add_base_scripts');

But I'm not seeing any of the scripts from base-scripts.php being put into the page. It's definately the correct directory which makes me think its a problem with the scripts being in a php file. I haven't found anything online as to if you can use a php file or not. Can someone confirm/debunk this?

A: function add_base_scripts() {
   wp_enqueue_script('script-handle',get_template_directory_uri() . '/base-scripts.php');
}
add_action('wp_enqueue_scripts', 'add_base_scripts');

You got to add a handle to the enqueue_scripts more info

A: After fiddling with this, we came to the conclusion that you cannot enqueue a php script. We had to use a workaround to solve our problem.


text:
Q: Can't install SQL Server after Visual Studio Express I'm trying to re-install SQL Server Express from http://www.microsoft.com/express/Database/.
Visual Studio Web was installed previously, so I removed the SQL Server under add programs before installation, since I didn't get a server administration tool with the bundle.
Now, Microsoft (hello, haven't meet in five years), presents an interface to me (SQL Server Installation Center), with endless popups, progress bars, and eula checkboxes, but nothing more than "Setup Support Files" are being installed.
Are they pulling my leg? (Delicate humor if so, the loop is quite annoying, and finally ends with a crash).
Any way to fix this or should I fallback to a FOSS-db?
regards,
//t

A: Get the Web Platform Installer.  Best case scenario is it will help you get what you need installed (inc. SQL EXPRESS) on top of what you have.  Worst case it'll make the process a lot easier if you decide to do a clean build.


text:
Q: advanced customization of legend markers in matlab It is relatively simple to add basic modifications to markers in matlab legends. The legend produced by the following code snippet ():
hold on
h = plot(inf,inf,'ob',inf,inf,'r+');
legend(h,'Data1','Data2');
Can be easily modified to:  using the following code:
[~,~,icons,~] = legend(h,'Data1','Data2');
set(icons(1),'LineStyle','-')
set(icons(2),'LineStyle','-')
However things become fairly complicated if I want to correctly legend objects such as  (circle is not in the middle of a line) or  (several colors for one line with '+' markers on it). I have not found any property or workaround that allows to modify the position of the markers in the legend box, or add several markers in one legend group.
Does anyone know of a document that contains advanced information for legend customization? Or how to better use the numerous properties of graphic objects provided by matlab to achieve what is described above?

A: In the MatLab version up to R2014a  the legend box is actually an axes so it is relatively easy to modify its content through its handle.
From version R2014b the legend is a graphics object and seems there is no way to access to the axes handle (ref. to this post on undocumentedmatlab).
Up to R2014a
Given the legend for two lines in a plot:
h = plot((0:.1:2*pi),sin((0:.1:2*pi)),'ob',(0:.1:2*pi),cos((0:.1:2*pi)),'r+');
[a,b,icons,c] = legend(h,'Data1','Data2');

*

*a is the handle of the legend axex

*b is an array of handels:

*

*b(1): handle of the first string

*b(2): handle of the second string

*b(3): handle of the first line

*b(4): handle of the marker of the first line

*b(5): handle of the second line

*b(6): handle of the marker of the second line

if you want to move the marker on the first line to, for example, the end of the line, you can:

*

*get the XData of the line (stored in b(3)): it is an (1x2) array

*set the XData of the marker (stored in b(4)) to the last value of the array obtained on the above step

If you want to add more marker and have the second line made of more segments with different colours, you can:

*

*get the XData and YData of the line (stored in b(5))

*generate the x coord by splitting the XData array

*plot the the segments in a for loop using the YData value as y coord
This approach has been implemented in the following code in which, the legend box has been also enlarged to make in more "readable".
The comments in the code should explain the different steps.
% Plot something
h = plot((0:.1:2*pi),sin((0:.1:2*pi)),'ob',(0:.1:2*pi),cos((0:.1:2*pi)),'r+');
% Add trhe legend
[a,b,icons,c] = legend(h,'Data1','Data2');
%
% a ==> handle of the legend axes
% b(1) ==> handle of the first string
% b(2) ==> handle of the second string
% b(3) ==> handle of the first line
% b(4) ==> handle of the marker of the first line
% b(5) ==> handle of the second line
% b(6) ==> handle of the marker of the second line
%
% Get positin and size of the legend box
ax_p=get(a,'position')
% Enlarge the legend box
set(a,'position',[ax_p(1)-.2 ax_p(2) ax_p(3)+.2 ax_p(4)])
% Set the linestyle of the first element on the legend
set(b(3),'linestyle','-')
% Get the XData of the first line
xl_1=get(b(3),'xdata')
% Move the marker of the first line to the end of the line
set(b(4),'xdata',xl_1(2))
% Get the position of the first string
xs_1=get(b(1),'position')
% Move the first string
set(b(1),'position',[xs_1(1)+.2 xs_1(2) xs_1(3)])
% Get the position of the second string
xs_2=get(b(2),'position')
% Move the second string
set(b(2),'position',[xs_2(1)+.2 xs_2(2) xs_2(3)])
% Split the second line in multi-color segment and add more marker on the
% second line
%
% Define the number of segments
n=4;
% Get the XData of the first line
xl_2=get(b(5),'xdata')
% Get the YData of the first line
yl_2=get(b(5),'ydata')
% Define the segments
len=linspace(xl_2(1),xl_2(2),n+1);
% Plot the segments of the second line in different colours
for i=1:n
   plot(a,[len(i) len(i+1)],[yl_2(1) yl_2(2)], ...
      'marker',get(b(6),'marker'),'markeredgecolor', ...
      get(b(6),'markeredgecolor'),'markerfacecolor',get(b(6),'markerfacecolor'), ...
      'color',rand(1,3),'linewidth',2)
end

This is the result:

From R2014b
Since it seems not possible to access to the legend axex, a solution could be(as suggested in the above mentoined post to add an axes and superimpose it to the legend.
You could firt create the legend:
h = plot((0:.1:2*pi),sin((0:.1:2*pi)),'o-',(0:.1:2*pi),cos((0:.1:2*pi)),'r+-');
[a,b,icons,c] = legend(h,'Data1','Data2');

*

*a is an object of matlab.graphics.illustration.Legend (try class(a))

*b is an array of matlab.graphics.primitive.Data objects (try class(b))

in a similar way to the older versions, the b refers to:

*

*b(1): first string

*b(2): second string

*b(3): first line

*b(4): marker of the first line

*b(5): second line

*b(6): marker of the second line

You can get the position and size of the legend through the legend object a.
You can then apply the same approach described above in order to plot the "updated" legend.
This approach has been implemented in the following code (the comments should explains the different steps).
% Plot something
h = plot((0:.1:2*pi),sin((0:.1:2*pi)),'o-',(0:.1:2*pi),cos((0:.1:2*pi)),'r+-');
% Add the legend
[a,b,icons,c] = legend(h,'Data1','Data2');
% Add an axes to the figure
ax=axes;
% Enlarge the legend, then set the axes position and size equal to the
% legend box
%Get the legend's position and size
ax_p=a.Position;
a.Position=[ax_p(1)-.2 ax_p(2) ax_p(3)+.2 ax_p(4)];
ax.Position=a.Position;
ax.Units='normalized';
ax.Box='on';
% Plot the firt line in the axes
plot(ax,b(3).XData,b(3).YData,'color',b(3).Color);
hold on
% Add the marker of the first line at the end of the line
plot(ax,b(3).XData(end),b(3).YData(end), ...
             'marker',b(4).Marker, ...
             'markeredgecolor',b(4).Color, ...
             'markerfacecolor',b(3).MarkerFaceColor);
% Get second line XData and YData
x=b(5).XData;
y=b(5).YData;
% Define the number of line sections
n=5;
% Update the XData and YData by defning intermediate values
len=linspace(x(1),x(2),n);
% Plot the set of line with different colours
for i=1:n-1
   plot(ax,[len(i) len(i+1)],[y(2) y(2)], ...
      'marker',b(6).Marker,'markeredgecolor',b(6).Color, ...
      'markerfacecolor',b(6).MarkerFaceColor, ...
      'color',rand(1,3),'linewidth',1.5);
end
% Get the legend texts position
pt1=b(1).Position;
pt2=b(2).Position;
% Add the legend text
text(pt1(1)+.1,pt1(2),a.String{1});
text(pt2(1)+.1,pt2(2),a.String{2});
% Remove the axes ticks
ax.XTick=[];
ax.YTick=[];
% Set the axes limits
ax.XLim=[0 1];
ax.YLim=[0 1];

Hope this helps.
Qapla'


text:
Q: CodeIgntier 3 using native sessions instead of CI's drivers Would this be the best way to use the native php sessions instead of using their drivers? Since their drivers are just wrappers around session functions; I figured this would be the easiest way.
The reason behind this is I am having issues with locking with mysql database driver and redis driver. I want to use native php sessions and swap in a redis driver at the php level.
This seems to work well. Any thoughts?
<?php
class MY_Session extends CI_Session
{
    public function __construct(array $params = array())
    {
        $CI =& get_instance();

        // No sessions under CLI
        if (is_cli())
        {
            log_message('debug', 'Session: Initialization under CLI aborted.');
            return;
        }
        elseif ((bool) ini_get('session.auto_start'))
        {
            log_message('error', 'Session: session.auto_start is enabled in php.ini. Aborting.');
            return;
        }

        // Configuration ...
        $this->_configure($params);
        $this->_config['_sid_regexp'] = $this->_sid_regexp;

        // Sanitize the cookie, because apparently PHP doesn't do that for userspace handlers
        if (isset($_COOKIE[$this->_config['cookie_name']])
            && (
                ! is_string($_COOKIE[$this->_config['cookie_name']])
                OR ! preg_match('#\A'.$this->_sid_regexp.'\z#', $_COOKIE[$this->_config['cookie_name']])
            )
        )
        {
            unset($_COOKIE[$this->_config['cookie_name']]);
        }

        session_start();

        // Is session ID auto-regeneration configured? (ignoring ajax requests)
        if ((empty($_SERVER['HTTP_X_REQUESTED_WITH']) OR strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) !== 'xmlhttprequest')
            && ($regenerate_time = config_item('sess_time_to_update')) > 0
        )
        {
            if ( ! isset($_SESSION['__ci_last_regenerate']))
            {
                $_SESSION['__ci_last_regenerate'] = time();
            }
            elseif ($_SESSION['__ci_last_regenerate'] < (time() - $regenerate_time))
            {
                $this->sess_regenerate((bool) config_item('sess_regenerate_destroy'));
            }
        }
        // Another work-around ... PHP doesn't seem to send the session cookie
        // unless it is being currently created or regenerated
        elseif (isset($_COOKIE[$this->_config['cookie_name']]) && $_COOKIE[$this->_config['cookie_name']] === session_id())
        {
            setcookie(
                $this->_config['cookie_name'],
                session_id(),
                (empty($this->_config['cookie_lifetime']) ? 0 : time() + $this->_config['cookie_lifetime']),
                $this->_config['cookie_path'],
                $this->_config['cookie_domain'],
                $this->_config['cookie_secure'],
                TRUE
            );
        }
        $this->_ci_init_vars();
    }
}


text:
Q: alternative to `regs` attribute of `match` object in `re` in python3 Is there an alternative to Match.regs?  It is undocumented, and I see a proposal to remove it at http://bugs.python.org/issue18043, but it is useful to me.  Here's it's usage:
> m = re.match('(a) (b)', 'a b ')
> m
<_sre.SRE_Match object; span=(0, 3), match='a b'>
> m.regs
((0, 3), (0, 1), (2, 3))

Is there an alternative way to obtain the spans of those groups for non-trivial regex?

A: Alternatives:
>>> m.groups()
('a', 'b')
>>> m.span()
(0, 3)
>>> m.span(1)
(0, 1)
>>> m.span(2)
(2, 3)

I wouldn't worry too much about it, though, as at this point it still exists in 3.5.


text:
Q: Запретить одинаковые символы edit1, edit2 / Delphi XE Как запретить водить одинаковые символы edit1 + edit2. К примеру если символ + введен в edit1 то ввести его в edit2 нельзя.
Сделала вот так, работает:
if (Edit1.Text = '+') and (Edit2.Text = '+') then
Edit3.Clear;

Но я так понимаю это нужно прописывать для каждого символа. Может есть вариант по проще, в смысле что бы не писать для каждого символа код.

A: ...
Edit1.OnKeyPress := EditKeyPress;
Edit2.OnKeyPress := EditKeyPress;
...

procedure TSomeForm.EditKeyPress(Sender: TObject; var Key: Char);
begin
  if ((Sender = Edit1) and (Pos(Key, Edit2.Text) > 0)) or
     ((Sender = Edit2) and (Pos(Key, Edit1.Text) > 0)) then
    Key := #0;
end;

A: Вопрос решила вот таким образом:
if (Edit1.Text = Edit2.Text) then
Edit2.Clear;


text:
Q: Setting the header for response header in php How do i set the content-type to application/json from text/html in response header i already set the request header content type to application/json but the response header content-type shown in text/html
here is my code
      function check(c2) {
          document.title = 'Checking';
                    var xmlhttp;
                    xmlhttp=new XMLHttpRequest();
                    xmlhttp.onreadystatechange = function()
                    {
                        if (xmlhttp.readyState==4 && xmlhttp.status==200)
                        {
                            var xdata = xmlhttp.responseText;
                        if (xdata.match("GOOD")) {
                          $("#GOOD").append(xdata);
                          document.getElementById("goodcnt").innerHTML = (eval(document.getElementById("goodcnt").innerHTML) + 1);
                          $("#listcnt").html(parseInt($("#listcnt").html()) - 1),
                          line('#cs');
                          Check();

                      } else if (xdata.match("BAD")) {
                         $("#BAD").append(xdata);
                         document.getElementById("badcnt").innerHTML = (eval(document.getElementById("badcnt").innerHTML) + 1);
                         $("#listcnt").html(parseInt($("#listcnt").html()) - 1),
                         line('#cs');
                         Check();
                      }
 }
                      }
                    xmlhttp.open("POST","api?list=" + c2 ,true);
                    xmlhttp.setRequestHeader("Content-Type","application/json");
                    xmlhttp.send();
      }

i also tried to add this code in api
header("Content-Type: application/json");

A: When you're using this line:
xmlhttp.setRequestHeader("Content-Type","application/json");
You're saying to the server that the sent content contains a JSON. And then, when the server responds it needs to know that the client supports a JSON in reply.
For this reason, you need to add the line below after:
xmlhttp.setRequestHeader("Accept","application/json");
More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept


text:
Q: MySQL Error #1064 Okay. I have read through almost everything, except I cannot find the answer to my problem. I don't get what's wrong.. It keeps giving me #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 2
CREATE TABLE users (
);

A: You haven't defined any columns in your table.

A: I have just experienced that in create table query when you mention primary key then you don't get an error. Otherwise you are receiving error. This is a strange experience. well try this
CREATE TABLE User
(
    id INT NOT NULL AUTO_INCREMENT,
    PRIMARY KEY(id)
)

You must provide at least one column. And that would be your primary key.

A: Does the second error 1113 answer your query?
mysql> create table users();
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1

mysql> create table users;
ERROR 1113 (42000): A table must have at least 1 column

Further details can be found here http://dev.mysql.com/doc/refman/5.1/en/create-table.html

A: You also need to define a engine?
create table users (
    user_id tinyint unsigned primary key auto_increment,
    [.....]
)engine=innodb;

A: Another possible is that you did't choice database:
mysql> create table t(id int);
ERROR 1046 (3D000): No database selected
mysql> show warnings;
+-------+------+----------------------+
| Level | Code | Message              |
+-------+------+----------------------+
| Error | 1046 | No database selected |
+-------+------+----------------------+
1 row in set (0.00 sec)


text:
Q: Distorted line 2 in the sources list /etc/apt/sources.list.d/official-package-repositories.list When I tried to install Apache in Ubuntu 18.04 using the command sudo apt install apache2, I got:
E: Distorted line 2 in the sources list /etc/apt/sources.list.d  /official-package-repositories.list
E: The list of sources is not read.
E: Distorted line 2 in the sources list /etc/apt/sources.list.d/official-package-repositories.list

The second line contains the word universe. After I deleted it, I got:
The apache2 package is not available, but is listed in the dependency list of another package.
E: No installation candidate found for the "apache2" package.

A: Comment out line 2 in //etc/apt/sources.list.d/official-package-repositories.list by preceding that line with a # character. Open the terminal and type:
sudo nano /etc/apt/sources.list.d/official-package-repositories.list

Comment out line 2.
The instructions for using nano editor are always found at the bottom of every page. Press the keyboard combination Ctrl+O and after that press Enter to save the file being edited. Press the keyboard combination Ctrl+X to exit nano.
Add the main repository to /etc/apt/sources.list. Open /etc/apt/sources.list with nano text editor and add the following lines to it.
deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse

If you get a duplicate entry in sources.list error about any of the 4 new lines that you added, you can open /etc/apt/sources.list again in nano text editor, and comment out the duplicate lines by preceding them with a #.
Update the list of available software and try to install apache2 again.
sudo apt update
sudo apt install apache2


text:
Q: CEREAL failing to serialise - failed to read from input stream exception I found a particular 100MB bin file (CarveObj_k5_rgbThreshold10_triangleCameraMatches.bin in minimal example), where cereal fails to load throwing exception "Failed to read 368 bytes from input stream! Read 288"
The respective 900MB XML file (CarveObj_k5_rgbThreshold10_triangleCameraMatches.xml in minimal example), built from the same data, loads normally.
The XML file was produced by
    // {
        // std::ofstream outFile(base + "_triangleCameraMatches.xml");
        // cereal::XMLOutputArchive  oarchive(outFile);
        // oarchive(m_triangleCameraMatches);
    // }

and the binary version was produced by
    // {
        // std::ofstream outFile(base + "_triangleCameraMatches.bin");
        // cereal::BinaryOutputArchive  oarchive(outFile);
        // oarchive(m_triangleCameraMatches);
    // }

Minimal example: https://www.dropbox.com/sh/fu9e8km0mwbhxvu/AAAfrbqn_9Tnokj4BVXB8miea?dl=0
Version of Cereal used: 1.3.0
MSVS 2017
Windows 10
Is this a bug? Am I missing something obvious?
Created a bug report  in the meanwhile: https://github.com/USCiLab/cereal/issues/607

A: In this particular instance, the "failed to read from input stream exception" thrown from line 105 of binary.hpp arises because the ios::binary flag is missing from the ifstream constructor call. (This is needed, otherwise ifstream will attempt to interpret some of the file contents as carriage return and linefeed characters. See this question for more information.)
So the few lines of code in your minimal example that read from the .bin file should look like this:
vector<vector<float>> testInBinary;
{
    std::ifstream is("CarveObj_k5_rgbThreshold10_triangleCameraMatches.bin", ios::binary);
    cereal::BinaryInputArchive iarchive(is);
    iarchive(testInBinary);
}

However, even after this is fixed there does also seem to be another problem with the data in that particular .bin file, as when I try to read it I get a different exception thrown, seemingly arising from an incorrectly encoded size value. I don't know if this is an artefact of copying to/from Dropbox though.
There doesn't seem to be a fundamental 100MB limit on Cereal binary files. The following minimal example creates a binary file of around 256MB and reads it back fine:
#include <iostream>
#include <fstream>
#include <vector>

#include <cereal/types/vector.hpp>
#include <cereal/types/memory.hpp>
#include <cereal/archives/xml.hpp>
#include <cereal/archives/binary.hpp>

using namespace std;

int main(int argc, char* argv[])
{
    vector<vector<double>> test;
    test.resize(32768, vector<double>(1024, -1.2345));
    {
        std::ofstream outFile("test.bin");
        cereal::BinaryOutputArchive oarchive(outFile, ios::binary);
        oarchive(test);
    }

    vector<vector<double>> testInBinary;
    {
        std::ifstream is("test.bin", ios::binary);
        cereal::BinaryInputArchive iarchive(is);
        iarchive(testInBinary);
    }

    return 0;
}

It might be worth noting that in your example code on Dropbox, you're also missing the ios::binary flag on the ofstream constructor when you're writing the .bin file:
/// Produced by:
// {
    // std::ofstream outFile(base + "_triangleCameraMatches.bin");
    // cereal::BinaryOutputArchive  oarchive(outFile);
    // oarchive(m_triangleCameraMatches);
// }

It might be worth trying with the flag set. Hope some of this helps.


text:
Q: Group data by second? I have data that looks like:
No. Time    Source  Destination Protocol    Length
1   0   192.168.6.132   192.168.6.149   RTPS    110
2   0.000008    192.168.6.132   192.168.154.1   RTPS    110
3   0.000013    192.168.6.132   192.168.221.1   RTPS    110
4   0.000021    192.168.6.132   192.168.6.149   RTPS    110
5   0.000025    192.168.6.132   192.168.154.1   RTPS    110
6   0.00003 192.168.6.132   192.168.221.1   RTPS    110
7   0.000133    192.168.6.132   192.168.6.149   RTPS    110
8   0.000149    192.168.6.132   192.168.154.1   RTPS    110
9   0.000153    192.168.6.132   192.168.221.1   RTPS    110
10  0.000158    192.168.6.132   192.168.6.149   RTPS    110
11  0.000162    192.168.6.132   192.168.154.1   RTPS    110
12  0.000166    192.168.6.132   192.168.221.1   RTPS    110
13  0.000195    192.168.6.132   192.168.6.114   RTPS    106
14  0.155988    192.168.6.132   192.168.6.114   RTPS    210
15  0.156002    192.168.6.132   192.168.6.125   RTPS    210
16  0.156008    192.168.6.132   192.168.70.1    RTPS    210
17  0.156014    192.168.6.132   192.168.80.1    RTPS    210
18  0.190113    192.168.6.149   239.255.0.1 RTPS    146
19  0.191102    192.168.6.149   239.255.0.1 RTPS    146
20  0.21706 192.168.6.149   239.255.0.1 RTPS    146
21  0.26399 192.168.6.132   192.168.6.125   RTPS    210
22  0.264002    192.168.6.132   192.168.70.1    RTPS    210
23  0.264008    192.168.6.132   192.168.80.1    RTPS    210
24  0.264031    192.168.6.132   192.168.6.114   RTPS    210
25  0.323881    192.168.6.132   192.168.6.114   RTPS    106
26  0.408117    192.168.6.132   239.255.0.1 RTPS    146
27  0.418088    192.168.6.132   239.255.0.1 RTPS    146
28  0.426158    192.168.6.132   239.255.0.1 RTPS    146
29  0.435039    192.168.6.132   239.255.0.1 RTPS    146
30  0.453171    192.168.6.132   239.255.0.1 RTPS    146
31  0.455198    192.168.6.132   239.255.0.1 RTPS    146
32  0.459963    192.168.6.132   192.168.6.125   RTPS    210
33  0.459975    192.168.6.132   192.168.70.1    RTPS    210
34  0.459981    192.168.6.132   192.168.80.1    RTPS    210
35  0.459995    192.168.6.132   192.168.6.114   RTPS    210
36  0.470089    192.168.6.132   239.255.0.1 RTPS    146
37  0.569183    192.168.6.149   239.255.0.1 RTPS    146
38  0.718822    192.168.6.149   239.255.0.1 RTPS    146
39  0.736077    192.168.6.132   192.168.6.114   RTPS    202
40  0.736102    192.168.6.132   192.168.80.1    RTPS    202
41  0.73611 192.168.6.132   192.168.70.1    RTPS    202
42  0.73612 192.168.6.132   192.168.6.125   RTPS    202
43  0.765126    192.168.6.132   239.255.0.1 RTPS    146
44  0.837028    192.168.6.132   192.168.6.125   RTPS    210
45  0.837042    192.168.6.132   192.168.70.1    RTPS    210
46  0.837047    192.168.6.132   192.168.80.1    RTPS    210
47  0.837061    192.168.6.132   192.168.6.114   RTPS    210
48  0.895085    192.168.6.132   239.255.0.1 RTPS    146
49  0.919585    192.168.6.132   239.255.0.1 RTPS    146
50  0.95995 192.168.6.132   192.168.6.125   RTPS    202
51  0.959959    192.168.6.132   192.168.70.1    RTPS    202
52  0.959965    192.168.6.132   192.168.80.1    RTPS    202
53  0.959986    192.168.6.132   192.168.6.114   RTPS    202
54  0.985993    192.168.6.132   192.168.6.125   RTPS    202
55  0.98601 192.168.6.132   192.168.70.1    RTPS    202
56  0.986023    192.168.6.132   192.168.80.1    RTPS    202
57  0.986216    192.168.6.132   192.168.6.114   RTPS    202
58  0.991958    192.168.6.132   192.168.6.125   RTPS    202
59  0.991967    192.168.6.132   192.168.70.1    RTPS    202
60  0.991971    192.168.6.132   192.168.80.1    RTPS    202
61  0.991991    192.168.6.132   192.168.6.114   RTPS    202
62  1.069143    192.168.6.132   192.168.6.125   RTPS    202
63  1.069178    192.168.6.132   192.168.70.1    RTPS    202
64  1.069197    192.168.6.132   192.168.80.1    RTPS    202
65  1.069236    192.168.6.132   192.168.6.114   RTPS    202
66  1.1095  192.168.6.149   239.255.0.1 RTPS    146
67  1.109993    192.168.6.132   192.168.6.114   RTPS    202
68  1.110006    192.168.6.132   192.168.6.125   RTPS    202
69  1.110012    192.168.6.132   192.168.70.1    RTPS    202
70  1.110017    192.168.6.132   192.168.80.1    RTPS    202
71  1.176661    192.168.6.114   239.255.0.1 RTPS    822
72  1.186424    192.168.6.149   239.255.0.1 RTPS    146
73  1.24307 192.168.6.132   192.168.6.125   RTPS    110
74  1.2431  192.168.6.132   192.168.70.1    RTPS    110
75  1.24312 192.168.6.132   192.168.80.1    RTPS    110
76  1.243149    192.168.6.132   192.168.6.114   RTPS    110
77  1.307628    192.168.6.114   192.168.6.132   RTPS    106
78  1.314474    192.168.6.149   239.255.0.1 RTPS    146
79  1.344895    192.168.6.149   239.255.0.1 RTPS    146
80  1.372821    192.168.6.149   239.255.0.1 RTPS    146
81  1.395822    192.168.6.114   239.255.0.1 RTPS    146
82  1.425897    192.168.6.125   192.168.6.132   RTPS    106
83  1.802883    192.168.6.132   239.255.0.1 RTPS    890
84  1.851153    192.168.6.149   239.255.0.1 RTPS    146
85  1.878097    192.168.6.132   239.255.0.1 RTPS    890
86  1.903379    192.168.6.132   239.255.0.1 RTPS    890
87  1.998941    192.168.6.149   239.255.0.1 RTPS    146
88  1.999752    192.168.6.149   239.255.0.1 RTPS    146
89  2.010819    192.168.6.114   192.168.6.132   RTPS    218
90  2.012812    192.168.6.114   192.168.6.132   RTPS    218
91  2.029853    192.168.6.132   192.168.6.114   RTPS    110
92  2.02987 192.168.6.132   192.168.6.125   RTPS    110
93  2.029875    192.168.6.132   192.168.70.1    RTPS    110
94  2.02988 192.168.6.132   192.168.80.1    RTPS    110
95  2.048372    192.168.6.132   239.255.0.1 RTPS    146
96  2.082863    192.168.6.132   192.168.6.125   RTPS    110
97  2.082881    192.168.6.132   192.168.70.1    RTPS    110
98  2.082889    192.168.6.132   192.168.80.1    RTPS    110
99  2.082913    192.168.6.132   192.168.6.114   RTPS    110
100 2.087518    192.168.6.132   239.255.0.1 RTPS    910
101 2.102426    192.168.6.132   239.255.0.1 RTPS    146
102 2.108882    192.168.6.132   192.168.6.125   RTPS    110
103 2.108894    192.168.6.132   192.168.70.1    RTPS    110
104 2.108899    192.168.6.132   192.168.80.1    RTPS    110
105 2.108916    192.168.6.132   192.168.6.114   RTPS    110
106 2.141479    192.168.6.132   239.255.0.1 RTPS    146
107 2.163   192.168.6.132   192.168.6.125   RTPS    110
108 2.16304 192.168.6.132   192.168.70.1    RTPS    110
109 2.163061    192.168.6.132   192.168.80.1    RTPS    110
110 2.163144    192.168.6.132   192.168.6.114   RTPS    110
111 2.175276    192.168.6.114   192.168.6.132   RTPS    106
112 2.175668    192.168.6.114   192.168.6.132   RTPS    106
113 2.176194    192.168.6.114   192.168.6.132   RTPS    106
114 2.176196    192.168.6.114   192.168.6.132   RTPS    106
115 2.176724    192.168.6.132   239.255.0.1 RTPS    890
116 2.186826    192.168.6.149   239.255.0.1 RTPS    146
117 2.18683 192.168.6.149   239.255.0.1 RTPS    146
118 2.187821    192.168.6.149   239.255.0.1 RTPS    146
119 2.187825    192.168.6.149   239.255.0.1 RTPS    146
120 2.202925    192.168.6.132   192.168.6.125   RTPS    110
121 2.202936    192.168.6.132   192.168.70.1    RTPS    110
122 2.202942    192.168.6.132   192.168.80.1    RTPS    110
123 2.202958    192.168.6.132   192.168.6.114   RTPS    110
124 2.204504    192.168.6.114   192.168.6.132   RTPS    106
125 2.217402    192.168.6.132   239.255.0.1 RTPS    918
126 2.250785    192.168.6.132   239.255.0.1 RTPS    910
127 2.253399    192.168.6.132   239.255.0.1 RTPS    146
128 2.255321    192.168.6.132   239.255.0.1 RTPS    906
129 2.277901    192.168.6.132   192.168.6.125   RTPS    110
130 2.277914    192.168.6.132   192.168.70.1    RTPS    110
131 2.27792 192.168.6.132   192.168.80.1    RTPS    110
132 2.277946    192.168.6.132   192.168.6.114   RTPS    110
133 2.27952 192.168.6.114   192.168.6.132   RTPS    106
134 2.303003    192.168.6.132   192.168.6.125   RTPS    110
135 2.303043    192.168.6.132   192.168.70.1    RTPS    110
136 2.303064    192.168.6.132   192.168.80.1    RTPS    110
137 2.303147    192.168.6.132   192.168.6.114   RTPS    110
138 2.304437    192.168.6.114   192.168.6.132   RTPS    106
139 2.314884    192.168.6.125   192.168.6.132   RTPS    106
140 2.314886    192.168.6.125   192.168.6.132   RTPS    106
141 2.314965    192.168.6.125   192.168.6.132   RTPS    106
142 2.31512 192.168.6.125   192.168.6.132   RTPS    106
143 2.315121    192.168.6.125   192.168.6.132   RTPS    106
144 2.315205    192.168.6.125   192.168.6.132   RTPS    106
145 2.315206    192.168.6.125   192.168.6.132   RTPS    106
146 2.320935    192.168.6.132   192.168.6.125   RTPS    110
147 2.32096 192.168.6.132   192.168.70.1    RTPS    110
148 2.320976    192.168.6.132   192.168.80.1    RTPS    110
149 2.32103 192.168.6.132   192.168.6.114   RTPS    110
150 2.329616    192.168.6.132   239.255.0.1 RTPS    146
151 2.330565    192.168.6.114   192.168.6.132   RTPS    106
152 2.341503    192.168.6.132   239.255.0.1 RTPS    146
153 2.343022    192.168.6.149   239.255.0.1 RTPS    146
154 2.376308    192.168.6.132   239.255.0.1 RTPS    146
155 2.395825    192.168.6.149   239.255.0.1 RTPS    146
156 2.548168    192.168.6.132   239.255.0.1 RTPS    146
157 2.570517    192.168.6.132   239.255.0.1 RTPS    146
158 2.611479    192.168.6.125   192.168.6.132   RTPS    106
159 2.613891    192.168.6.132   239.255.0.1 RTPS    146
160 2.618985    192.168.6.149   239.255.0.1 RTPS    146
161 2.656532    192.168.6.132   239.255.0.1 RTPS    922
162 2.736513    192.168.6.125   239.255.0.1 RTPS    146
163 2.923952    192.168.6.114   192.168.6.132   RTPS    110
164 2.924452    192.168.6.114   192.168.6.132   RTPS    110
165 2.954357    192.168.6.132   239.255.0.1 RTPS    922
166 2.956826    192.168.6.149   239.255.0.1 RTPS    922
167 2.982879    192.168.6.149   239.255.0.1 RTPS    146

...
I need to group lengths by second. I need to know average length per second for each second.
For example:
if we have:
0.1 100
0.4 200
0.5 500
1.2 100
1.5 900
1.9 800
1.99 900
....

My output would be:
   Time  Length

    0    266.66
    1    675.00

My goal is to graph this resulting table to find out at which second did I have the most average bandwidth usage.
Thanks


text:
Q: String cannot be cast to java error MyButton4 does not work, output shows error,

Exception in thread "AWT-EventQueue-0"
  java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer at knapsacproject.Interface.getTableData(Interface.java:198)

It's showing this line error,

tableData[i] = (int) model.getValueAt (i,colIndex);

What is wrong ?
public int[] getTableData(DefaultTableModel model, Integer colIndex) {
    int nRow = model.getRowCount();
    int[] tableData = new int [nRow];

    for(int i = 0; i< nRow; i++) {
        tableData[i] = (int) model.getValueAt (i,colIndex);
    }
    return tableData;
}

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
    DefaultTableModel model = (DefaultTableModel)jTable1.getModel();
    int nRow = model.getRowCount();

    algorithm algo = new algorithm(getTableData(model, 1),getTableData(model, 2),
    Integer.parseInt(jTextField1.getText()),Integer.parseInt(jTextField2.getText()),Integer.parseInt(jTextField3.getText()));
    int[] result = algo.getResult();

    for(int i = 0; i < nRow; i++) {
        if(result[i]==1)
            model.setValueAt("take", i , 3);
        else
            model.setValueAt("leave", i, 3);
    }
}

A: You are getting this error as you are assigning string value into an int array.
You need to do Integer.parseInt() to convert string into int.
tableData[i] = Integer.parseInt(model.getValueAt (i,colIndex));

A: You need to parse String into Integer using below code.
tableData[i] = Integer.parseInt(model.getValueAt (i,colIndex));

A: You are trying to cast the String value returned by the method getValueAt (i,colIndex) to int (which is not possible), so basically it gave you a ClassCastException
What you need is to convert that String value to an Integer value using one of the methods mentioned in the answers:
tableData[i] = Integer.parseInt(model.getValueAt (i,colIndex));

or
tableData[i] = Integer.valueOf(model.getValueAt (i,colIndex));


text:
Q: Variable for While loop not being recognized as initialized I am trying to use a variable as the parameter for my while loop, like shown below.
int compChoice;
while (compChoice < 8){

        compChoice = rand() % 8 + 0;
        cout << compChoice;
    }

My goal is to have a random number generated until an 8 is the output. The issue is that my compiler (visual studio pro 2013) is telling me the variable is not initialized. I removed the while loop and left the variable there and retried, and the compiler then told me the variable compChoice is unreferenced. I also tried just using the last two lines and it worked perfectly. I think I'm doing something wrong with the argument, but I can't figure out what. Any help would be greatly appreciated.

A: Your while condition is reading the contents of compChoice before you have assigned compChoice a value.  Consider using a do-while loop instead, which will execute the loop body once before checking the condition:
int compChoice;
do {
    compChoice = rand() % 8;
    cout << compChoice;
} while (compChoice < 8);

However, this won't even work as you desire it to because rand() % 8 is guaranteed to be less than 8 by the definition of the modulus operation.  As you have written your code, the loop will never terminate (unless the uninitialized value in compChoice is already less than 8 when it is first read).
Perhaps you meant rand() % 9 or rand() % 8 + 1?  But this doesn't even make sense, as it's just an expensive way to assign 8 to compChoice.  It seems like you need to take a step back and figure out what you are even trying to do here.

A: In your example, your program will never end.
 rand() % 8;

generates numbers between 0 and 7. So you need:
rand() % 8 + 1;

to generate numbers between 1 and 8.
Also, you will need to initialize rand with:
#include <ctime>

and:
srand(time(NULL));

before the random generation, and
int compChoice=0;

before the loop

A: You are not initializing compChoice before you use it in the loop. So, it has an undefined value.


text:
Q: MySQL order by column, equal spread of values I am looking to select a subset of data from a table but would like to ensure I get an equal mix of different 'types' from a column.
For example, if the table had a column called 'animal' that was populated with the following:
name, animal
'Bob', 'cat'
'Fred','cat'
'Jim','dog'
'Sam','dog'
'Andy','snake'
'Paul','snake'

I would like to select the rows in an order that has an even mix of animal types, so the result would be:
['Bob','cat'],
['Jim','dog'],
['Andy','snake'],
['Fred','cat'],
['Sam','dog'],
['Paul','snake']

Similar to randomising, but ensuring that all types are included equally. Is there a way to do this in mysql?

A: This gives every name in the table an index with reference to the animal they own and then selects each index-animal in turn:
SELECT name, animal
  FROM (
    SELECT CASE
             WHEN @animal = animal THEN @row := @row + 1
             ELSE @row := 0
           END row_num,
           name,
           @animal := animal animal
      FROM owner
      JOIN (SELECT @animal := null, @row := 0) init
  ORDER BY animal, name
        ) temp
 ORDER BY row_num, animal

See Fiddle
Note any spare animals will be appended to the end.. is this what you wanted?