text:
Q: How to count active users base using window functions? I have a database clients with users' activities and I need to calculate the 30-day active users base. For any day 30-day active users base is a number of unique clients for the previous 30 days ago. For instance, for the 1st of Jan 30-day active users base is the number of clients for the previous 30 days including the 1st of Jan. For the 2nd of Jan this is the same including the 2nd of Jan and so on.
The structure of the database is the following:
cityname: character, the name of the city
date: datetime, the date
orderid: int, the id of the order
clientid: int, the id of the client
sales: float, the sum of sales in conventional units

So I need to calculate daily dynamics of 30-days active users base for each city from 2014-01-01 to 2014-06-30.
What I do is creating the CTE and then pulling the data using window function. But this approach is wrong as the last it does not count the number of users from the last day of a month with the number of users of the 1st day of the consecutive month.
WITH new_tbl as (
  SELECT cityname, date, COUNT(DISTINCT clientid) as client_ids
  FROM clients
  GROUP BY cityname, date
)

SELECT cityname, date,
       SUM(client_ids) OVER(PARTITION BY cityname ORDER BY cityname, date) as active_base
FROM new_tbl

Really do struggle with this task but cannot find the right solution. Also tried something like this:
SELECT ...
       COUNT(DISTINCT clientid) OVER(PARTITION BY ... ORDER BY ... UNBOUNDED ... PRECEEDING ...) as active_base
FROM clients

But count + distinct do not work with window functions, so I get the error. What solution fits me better to get the desirable result?
cityname     date       active_base

 city1    2014-02-01        234
   …          …              …
 city1    2014-06-30        876
 city2    2014-02-01       1950
   …          …              …
 city2    2014-06-30       5910

A: You may try a self join as the following:
select T.cityname, T.sdate,
       COUNT(distinct D.clientid) active_base
from clients T join clients D
on T.sdate between D.sdate and date(D.sdate, '+29 day')
and T.cityname=D.cityname
where T.sdate between '2014-01-01' and '2014-06-30'
group by T.cityname, T.sdate
order by T.cityname, T.sdate

See a demo, the demo uses 3 days interval because of the small number of rows in the sample date.


text:
Q: Difference between variable types for the same computation in Fortran I am new to Fortran and I was experimenting with int and double variables. I saw that
when you divide for example
integer:: a = 5
integer:: b = 2

the outcome is 2
However I was wondering when we use different types is there a difference of speed? Are they calculated the same way?
For example
double  :: a = 2.0
integer :: b = 2

1) a**b
2) a**a
3) b**a

Of course the outcome for all these will be the same since they turn to double. However are they calculated the same way? Is there a difference in the speed they calculated?
EDIT : I must admit I did not know that the compiler plays a role. So far I know about 3 compilers : gfortran, nagfor and ifort. Personally I have experience in just gfortran and I tried and I got the same results in all the 3 calculations. However are they calculated the same way?

A: Normally, when optimizations are enabled, a**2 with a literal 2 will be changed to a*a. It is less likely, but not impossible, for the compiler to do such a thing for a variable integer exponent.
A completely generic exponentiation to a real exponent is implemented using logarithms. You just need the exp(x) function and then you can exponentiate any other number to the power of x if you know the logarithm of your number.
You can test the gfortran optimizations online  https://godbolt.org/z/MvGEnn
You get a call to __powidf2() in the first case, and calls to pow() in the other cases.
Those are functions from the C runtime library.
 double __powidf2 (double a, int b)

https://gcc.gnu.org/onlinedocs/gccint/Soft-float-library-routines.html
 double pow(double x, double y);

https://linux.die.net/man/3/pow
The former one is a specialized function to exponentiate to an integer and is much faster, the other is for two doubles.
You can play with the optimization level and you can also make on of the numbers known.
Like this one, where the optimizer can treat it as a constant even when it is a variable:
https://godbolt.org/z/YT3KP8
However, the compiler will not do that, if the value is only known outside the subroutine.
But when you use -fwhole-program, the compiler is actually able the pre-compute the result from the subroutine https://godbolt.org/z/zs43jv
I hope it illustrates that the problem is actually quite complex and cannot be answered in all generality.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Borel sigma-algebra for compacts How can we show that the borel sigma-algebra on the interval (0, 1] is the smallest sigma-algebra that contains compact sets ?

A: The $\sigma$-algebra generated by the compacts contains every open subinterval, so it contains every open subset.  Therefore, it contains the Borel sets.

A: Since $(0,1]$ is a subset of $\Bbb R$, we know compactness is equivalent to being closed and bounded.  Since every subset of $(0,1]$ is bounded, this implies subsets of $(0,1]$ are compact if and only if they are closed.
Let $\mathcal{C}$ be the collection of closed (i.e., compact) subsets of $(0,1]$.  Suppose by contradiction that there is a smaller $\sigma$-algebra $\mathcal{B}'$ than the Borel $\sigma$-algebra which contains $\mathcal{C}$.
Since $\mathcal{B}'$ contains $\mathcal{C}$ and it is also closed under set complements, $\mathcal{B}'$ contains all open sets in $(0,1]$.  But then this is a $\sigma$-algebra that's smaller than the Borel $\sigma$-algebra which contains the open sets, and this is a clear contradiction.  So $\mathcal{B}'$ doesn't exist, and thus the Borel $\sigma$-algebra is the smallest $\sigma$-algebra containing the closed subsets of $(0,1]$, and thus the compact subsets of $(0,1]$.


text:
Q: circle buffer for serial port in c# I want to creating circle buffer in c#.
i have Arduino board that sending a lot of data
when discard buffer in serial port command some of data will be lost.
at this situation I need circle buffer for my data to ricived  them .
InputData = ComPort.ReadByte();
object firstByte = InputData;

if (ComPort.IsOpen==true)
{
    s = Convert.ToString(Convert.ToChar(firstByte));
    temp1 += s;
    lock (firstByte) {
    if (Convert.ToInt32( firstByte)== 13)
    {
        temp = temp1;
        temp1 = "";
        LstGetInfo.BeginInvoke(new Action(()=>
        {
            if (temp !=null)
            {
                LstGetInfo.Items.Add(temp);

                if (LstGetInfo.Items.Count >= 100)
                {
                     LstGetInfo.Items.Clear();
                     // ComPort.DiscardInBuffer();
                     //ComPort.DiscardOutBuffer();
                }
                FileStream fs = new FileStream(filename, FileMode.Append);
                var data = System.Text.Encoding.UTF8.GetBytes(String.Format("{0} {1}", temp, DateTime.Now.ToString("hh mm ss")) +"\r\n");
                fs.Write(data, 0, data.Length);
                fs.Close();
            }
        }));
        LstGetInfo.BeginInvoke(new Action(() =>
        {
            LstGetInfo.TopIndex = LstGetInfo.Items.Count - 1;
        }));
    }
}

any solution for this problem ?

A: Try following :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication72
{
    class Program
    {

        static string buffer = "";

        static void Main(string[] args)
        {

        }

        static void AddToBuffer(byte[] rxData)
        {
            buffer += Encoding.UTF8.GetString(rxData);
        }
        static string ReadLine()
        {
            int returnIndex = buffer.IndexOf("\n");
            if (returnIndex >= 0)
            {
                string line = buffer.Substring(0, returnIndex);
                buffer = buffer.Remove(0, returnIndex + 1);
                return line;
            }
            else
            {
                return "";
            }
        }
    }
}


text:
Q: How to make a top wrapper(?) with a background color First off, I'm really new to this so sorry if I sound dumb ;_;. Now, I'm trying to make a background color on my list items. Like this site has, black bar with the logo, search bar etc.. I tried wrapping divs everywhere but nothing seems to work.
HTML

About Us

Staff

Schedule

Home

CSS
.nav-menu ul {
margin-right: 50px;
}
.nav-menu li {
list-style: none;
display: inline;
margin-left: 30px;
float: right;
color: red;
}
.container {
color: black;
}

http://jsfiddle.net/Hm4KJ/

A: Set overflow to auto to display everything in the .content div (now everything is hidden because you use float property)
.container {
   background: black;
   overflow:auto;
}

I guess it is a typo, anyway , you should set background property instead of color to set background color.
Example

A: if you only want a background color in each list item you can use this one:
.nav-menu li {
    list-style: none;
    display: inline;
    margin-left: 30px;
    float: right;
    color: red;
    background:#000000;
    display:inline-block;
    padding:5px 10px;
}

http://jsfiddle.net/Hm4KJ/2/

A: You could add a clearfix after your floating element.
html:
put a

after your

related css:
.clear {
    clear: both;
}

and you would need to change color: black; to background-color: black; ;-)
see: http://jsfiddle.net/Hm4KJ/4/


text:
Q: Stack Overflow showing different messages in different browsers at same time Today I observed one peculiar behaviour regarding the Stack Overflow home page message.
See the images for Internet Explorer and chrome.
In IE

In Chrome

Why this message difference? I have cleared y cache and checked but is it not surprising?

A: This is an A/B test  we are running, comparing two variations of the hero unit shown on Stack Overflow to anonymous users.
You're seeing two different pages because your browsers were placed in different groups (obviously, we do not track you across browsers!).

You should see different messages on the question page hero unit too, by the way.


text:
Q: Is there any alternative for MPNS in Windows Phone? I want to support push notification for my Windows Phone app. Is there any alternative for Microsoft Push Notification Service? Something like MQTT etc. I have a similar app in Android where MQTT is used to send push notifications. I need the same service to be implemented for Windows Phone. Is it possible?

A: WP does not allow your app to keep a socket connections alive while you are in background.
So this is not possible.

Your only option would be to have a background agent that contacts your server each time it runs (approximately every half hour) and checks for new messages.  If there are messages, use a local toast notification to alert the user.  If the user taps on the toast, it will launch your app.
If it is only new data that you need to pull down, then push
  notifications were never going to work because all they can do is
  display a toast and the user has to tap the toast to launch the app
  for it to do anything.  The background agent is still your best bet
  here and poll for new data every time it runs.  If the data will take
  a while to pull down, use background file transfer to pull the data
  down to isolated storage, then process it when the agent or the app
  runs next.


text:
Q: How can i autopost to my Twitter account? I have a Twitter account. I have some data i receive from a third party. When new data arrives (these are football lineups) I want to post this to my Twitter. The data arrives approximately 60-30 minutes before matches start.
I've tried using twitterfeed but it checks only every 30 minutes - and this can result in tweets with data for matches that already started.
How can i post my data automatically...and almost instantly upon reception?
-Rasmus

A: I found the solution here:
https://github.com/J7mbo/twitter-api-php
Great code for posting to twitter:
require_once('includes/TwitterAPIExchange.php');

$settings = array(
    'oauth_access_token' => "OWN",
    'oauth_access_token_secret' => "OWN",
    'consumer_key' => "OWN",
    'consumer_secret' => "OWN"
);

$url = 'https://api.twitter.com/1.1/statuses/update.json';
$requestMethod = 'POST';

$postfields = array(
    'status' => 'Testing'
);

$twitter = new TwitterAPIExchange($settings);
echo  $twitter->buildOauth($url, $requestMethod)
      ->setPostfields($postfields)
      ->performRequest();

Only thing i needed to change in the library was to add "CURLOPT_SSL_VERIFYPEER => false" to the cURL made, as I did not get any return values or see any tweets.


text:
Q: How to read the scale of the munin monitoring system, tomcat accesses by day graph The tomcat accesses by day graph in munin has a y axis that shows "accesses / second", and currently shows "66 m".  It can't be 66 million accesses per second, a single server couldn't return that quickly.  Also, tomcat is configured to sit behind apache with ajp and apache is only receiving about 25 queries per second.
What does the "m" mean here?

A: This can best be answered by quoting Wikipedia

Milli (symbol m) is a prefix in the metric system denoting a factor of one thousandth

Munin (by default) reads a counter every 5 minutes, and calculates the average between the two last reads.  66m means 66*300 = 19.8 accesses within a five minute period (but the 66 is probably 66.6666, so you'll end up with 20 accesses that interval).

A: I found a couple other posts asking similar questions.  Responders came to similar conclusions:
what does the 'm' unit in munin mean?
I'm using version 1.4.5 of munin (vs. 1.4.4), and I saw a max of 400 m accesses/second, which makes little sense.  It definitely isn't 400 million accesses per second.  400 x 10**-3 makes sense for what I'm running (a very lightly used web service in our engineering group).
When the value to be graphed is less than 1 unit-per-time-interval, showing it this way is very misleading.  If the max value in the graph is less than one, then change the units to accesses per minute, or even accesses per hour if necessary.  Or make the max y be "1 access per second" and let the data rumble around in the lower region of the graph.
If no reasonably compact, clearer method of displaying the data can be figured out, I'd suggest a note or tooltip or something that helps the user understand the variable and its units.  When one drills down (click through to the 4 graphs day/week/month/year), the variable is explained as: "The number of accesses (pages and other items served) globaly on the Apache server".  Add a discussion of units (and spell globally correctly).
Note - I have not checked this on a newer version of munin.  Perhaps it has been improved.  However, I was not able to find mention of the topic on the http://munin-monitoring.org/ site.  Apologies for not going and filing a feature request on munin.


text:
Q: AWS Cognito iOS: How to replace / upgrade from AWS MobileHubHelper generated code? I am developing an iOS application with user authentication via a AWS Cognito user pool (with email/password authentication).
The initial Xcode project and source code was generated by the AWS MobileHub code generator (that is no longer available).
It contained the AWSMobileHubHelper framework, an AWSMobileClient, and a few view controllers and storyboards related to authentication (like SignInViewController, UserPoolForgotPasswordViewController etc.)
(Since then, I moved to using the Serverless framework, so I no longer rely on the MobileHub "managing" my AWS resources - but the code structure of the Xcode project for the authentication parts is still the same.)
Now, it seems that MobileHubHelper is no longer maintained (the Podfile referencing older AWS SDK versions - although "deprecated" is not explicitly mentioned).
Also, the code generator has been removed from the MobileHub console.
Now, there are multiple "auth"-related repositories / SDKs, like

*

*AWSCognitoAuth

*AWSAuthCore

*AWSAuthUI

*AWSUserPoolsSignIn

I'm lost.
I want to be able to modify the UI, and keep the option to add Facebook or Google authentication at a later date.
The steps described in the Cognito User Pools tutorial differs significantly from the ones in the "Mobile App Development" tutorial - and both don't really match the structure of my (generated) code.
The CognitoYourUserPoolsSample and CognitoAuthSample are different again.
What do I need to do to upgrade my authentication code and UI from the AWSMobileHubHelper-generated code  to the latest AWS SDKs?
Second issue: I used AWSUserFileManager from MobileHubHelper to upload user files - what do I use now?


text:
Q: Replace whole element rather than innerHTML? I can do this:
$('my-panel').innerHTML = '
 New content
';

But if there any way of doing something like
$('my-panel').wholeHTML = "

 New Content

";

I can't find any way. If I can't do something like this, I'll have to refactor a whole bunch of stuff, which would be time consuming.

A: What about outerHTML, which includes the 'whole' tag:
$('my-panel').outerHTML = '
 New content
';

http://jsfiddle.net/pimvdb/Sah2U/1/

A: You use mootools, right? you could easily replace the element, i.e.:
Elements.from("

 New Content

").replaces($("my-panel"));

A: you can always get the tags parentNode and replace his innerHTML
         $('my-panel').parentNode.innerHTML = '
 New Content
'


text:
Q: CKEditor filebrowser plugin Can anyone explain with examples for everyone how to integrate CKEditor and external file browser? Where to put this code:
    CKEDITOR.replace( 'editor1', {
    filebrowserBrowseUrl: '/browser/browse.php',
    filebrowserUploadUrl: '/uploader/upload.php'
});

And what shoud return these:
browse.php
upload.php

I think the answer for this question should be here. So many peeople asked this question, but there is no definitive guide to this plugin. SO members, maybe some of you can?

A: filebrowserBrowseUrl will be the url of a page that allows a user to choose a file on the server. This page will be opened in a new window.
These arguments will be added to the url CKEditor=editor&CKEditorFuncNum=2&langCode=en-gb

*

*CKEditor is the current editor

*CKEditorFuncNum is the function to call(pass this value to callFunction)

*langCode is the language

in the popup window call
window.opener.CKEDITOR.tools.callFunction(CKEditorFuncNum, 'img_url');

to set the selected image and optionally window.close(); to close the window.
e.g.
<?php
$files = glob('/images/directory/*.{jpg,png,gif,bmp}', GLOB_BRACE);
if (count($files) > 0){
    echo 'Select a file
';
    foreach ($files as $file) {
        echo '
<button onclick="select(this)" data-name="'.$file.'">.basename($file).</button>
';
    }
    echo '
';
}
?>

filebrowserUploadUrl will be the url that handles the image upload.
Its just a standard file upload handler except you run some js on the page.
and same arguments are added to the url as with filebrowserBrowseUrl.
<?php
... handle the upload
?>
";

Simple Demo http://jsfiddle.net/mowglisanu/f2ztp/show/ (upload doesn't actually work though)
http://jsfiddle.net/mowglisanu/f2ztp/
http://jsfiddle.net/mowglisanu/GuA6s/show/
http://phpfiddle.org/api/run/dv4-e70


text:
Q: Scrape only hyperlinks that end .ece from an html page using beautifulsoup I wrote a code to scrape only hyperlinks that end with .ecm, here is my code
_URL='http://www.thehindu.com/archive/web/2017/08/08/'
r = requests.get(_URL)
soup = BeautifulSoup(r.text)
urls = []
names = []
newpath=r'D:\fyp\data set'
os.chdir(newpath)
name='testecmlinks'
for i, link in enumerate(soup.findAll('a')):
    _FULLURL = _URL + link.get('href')
    if _FULLURL.endswith('.ece'):
        urls.append(_FULLURL)
        names.append(soup.select('a')[i].attrs['href'])

names_urls = zip(names, urls)

for name, url in names_urls:
    print url
    rq = urllib2.Request(url)
    res = urllib2.urlopen(rq)
    pdf = open(name+'.txt', 'wb')
    pdf.write(res.read())
    pdf.close()

But I get the following error
Traceback (most recent call last):
  File "D:/fyp/scripts/test.py", line 18, in <module>
    _FULLURL = _URL + link.get('href')
TypeError: cannot concatenate 'str' and 'NoneType' objects

Can you help me get hyperlinks ending with .ece?

A: Try this instead. I hope you will get all the hyperlinks ending with .ece from  that page.
import requests
from bs4 import BeautifulSoup

response = requests.get("http://www.thehindu.com/archive/web/2017/08/08/").text
soup = BeautifulSoup(response,"lxml")
for link in soup.select("a[href$='.ece']"):
    print(link.get('href'))

A: The error indicates that the result of link.get('href') is None. The filtering of links can better be done using Beautiful Soup directly in the for loop. Change your original code
...
for i, link in enumerate(soup.findAll('a')):
    _FULLURL = _URL + link.get('href')
    if _FULLURL.endswith('.ecm'):
        urls.append(_FULLURL)
        names.append(soup.select('a')[i].attrs['href'])
...

to this:
...
for i, link in enumerate(soup.find_all('a', href=re.compile(r'\.ece$'))):
...

A: You get better solutions but with current code you have to check if link.get('href') is not None before you can add to _URL
for link in soup.findAll('a'):
    url = link.get('href')  # get `href` or `None`
    if url and url.endswith('.ece'): # check `None` and `.ece'
        names_urls.append( _URL + url, url )
        # ... or directly download file ...
        # rq = urllib2.Request(_URL + url)
        # res = urllib2.urlopen(rq)
        # pdf = open(url+'.txt', 'wb')
        # pdf.write(res.read())
        # pdf.close()


text:
Q: selecting mysql rows for a special circumstance Is it possible to select a new row from mysql database whenever I call a php script? For example, I need to fetch a new email address from a mysql database everytime I call the following php script. I am aware of mysqls' ORDER BY RAND () function; here I need to fetch every row according to their date of entry (i.e. ORDER BY created_on DESC).
// Add recepients from a datasoutce iteratively
$emails = mysql_query('SELECT email from recepients ORDER BY created_on DESC LIMIT 1') or die;
while($row = mysql_fetch_assoc($emails))
{
    message->addTo($row['email']);
}

EDIT: I will use cron job (scheduled task in windows) to run my php script, where I need a solution to select rows one by one (not randomly) as my php is called.

A: Add column to table, if you are allowed to:
alter table recepients add column uts_sent BIGINT NOT NULL;

Update the table after sending the email:
$limit= 1; //fetch $limit rows per page

$now = mktime(); //current unix time stamp

// Add recepients from a datasource iteratively
$emails = mysql_query("SELECT email from recepients WHERE uts_sent<$now ORDER BY created_on DESC LIMIT $limit") or die;
while($row = mysql_fetch_assoc($emails))
{
    $message->addTo($row['email']);
    $message->send();
    $email_escaped = mysql_real_escape_string($row['email']);
    mysql_query("update recepients set uts_sent = $now where email ='$email_escaped'") or die;
}


text:
Q: How to get content of a single text or a single json file inside a .tar.gz file in PHP? I have a i.tar.gz file of a folder with 1,000,000 unique .json files. I tried to use the $a=file_get_contents('phar://path/to/i.tar.gz/filename.json'); and echo $a; takes forever to load on browser. Any help is appreciated.

A: A .tar.gz file cannot be accessed randomly. All of the files up to the one you want must be decompressed.
You can try using a .zip file instead, which will permit rapid random access. However the compression of many small files could be much worse, since zip entries are compressed independently and not able to use repeated information in the previous files to aid in the compression of subsequent files.


text:
Q: Check if html element exists with iMacros and javascript I want to check if an HTML element exist with iMacros. If it does, I want to go to a URL. If not, I want to go to other URL.
Because iMacros doesn't have statements, I used javascript with the iMacros' EVAL.
Here is the line that handles the javascript execution:
SET !VAR3 EVAL("var element = window.content.document.getElementById(\"some_element\");
if (typeof(element) != 'undefined' && element != null) {
var redirect = 'http://192.168.178.22/sc/report.php';
} else {
var redirect = 'http://192.168.178.22/sc/index.php?action=connect';
}
redirect;
")

*It's all in one line, but I formatted it for here.
Then, I will redirect with
URL GOTO={{!VAR3}}

The problem is in both of the cases, the !VAR3 is set to 'undefined.'
I tried almost the same JS code on Firefox only, and it seems to be working.
Windows 8 with the latest Firefox and the latest iMacros version.
Thank you.

A: var macro;

macro ="CODE:";
macro +="TAG POS=1 TYPE=DIV ATTR=CLASS:some_class CONTENT=EVENT:MOUSEOVER ";

var ret=null;

ret=iimPlay(macro);

if(ret>0)
{
//do something
}
else
{
//do something else
}

This would be the basic model of the script you want. You just have to insert the proper imacros code.


text:
Q: How to debug "could not receive data from client: Connection reset by peer" I'm running a django-celery application on Ubuntu-12.04.
When I run a celery task from my web interface, I get the following error, taken form postgresql-9.3 logfile (maximum level of log):
2013-11-12 13:57:01 GMT tss_usr 8113 LOG:  could not receive data from client: Connection reset by peer

tss_usr is the postgresql user of the django application database and (in this example) 8113 is the pid of the process who killed the connection, I guess.
Have you got any idea on why this happens or at least how to debug this issue?
To make things work again I need to restart postgresql which is extremely uncomfortable.

A: I know this is an older post, but I just found it because I had the same error today in my postgres logs.  I narrowed it down to a PDO select statement.  I'm using Zend Framework 1.10.3 on Ubuntu Precise.
The following pdo statement generated an error if $opinion is a long text string.  The column opinion is type Text in my postgres table.  The query succeeds if $opinion is under a certain number of characters.  1000 characters works fine. 2000 characters fails with "could not receive data from client: Connection reset by peer".
  $select = $this->db->select()
           ->from( 'datauserstopics' )
           ->where("opinion = ?",trim($opinion))
           ->where("datatopicsid = ?",trim($tid))
           ->where("datausersid= ?",$datausersid);

  $stmt = $this->db->query($select);

I circumvented the problem by using:
  ->where("substr(opinion,1,100) = ?",trim(substr($opinion,1,100)))
This is not a perfect solution, but for my purposes, the select statement using substr() suffices.
Note that I have no problem inserting long strings into the same table/column.  The disconnect problem only appears for me on the PDO select with relatively long text strings.

A: I'm getting it in 2017 with 9.4, I have no text fields, don't know what a PDO is.  My select statement is about 50 bytes long, I'm trying to fetch an int4 and a double precision.  I suspect the error message can mean multiple things.
I've since found https://dba.stackexchange.com/questions/142350/postgres-could-not-receive-data-from-client-connection-reset-by-peer which indicates it could be a problem with the client configuration.  My client is libpg and PQconnectdb() is giving me a CONNECTION_OK return.  It works at least partly.

A: For me, restarting the hypervisor where both the Postgres and the application using it helped. I've seen stack traces in dmesg before, though.


text:
Q: windows 98 installer inside a VirtualBox claims for 16 Mb RAM I am trying to install Windows 98 in a virtual box image. I have built it with a 512 Mb virtual hard drive, 32 Mb RAM, and 16 Mb video RAM. First, it is declared as a DOS virtual machine. FreeDOs installs well. I used this tuto.
I have burned an ISO of my Windows 98 install CD because I don't manage to connect my CD device to the virtual box. I boot on FreeDOS, switch to D:, and run "install /p j" or "install". The windows 98 install screen is displayed, and an error appear telling: windows 98 requires a computer with at least 16 Mb of memory.
As I gave it 32Mb, it should be happy. Any idea please ?

A: Booting from the Windows 98 install CD works, both when FreeDOS is first installed and when it is not, surprisingly. My Windows 98 install CD is a basic one, not the 98 SE one.

A: The official answer for FreeDos is "SETUP /NM /IS" as described here: http://wiki.freedos.org/wiki/index.php/Windows

A:
I boot on FreeDOS, switch to D:, and run "install /p j" or "install". The windows 98 install screen is displayed, and an error appear telling: windows 98 requires a computer with at least 16 Mb of memory.
  …
  Booting from the Windows 98 install CD works, both when FreeDOS is first installed and when it is not, surprisingly.

If it works from the CD but not from the install files, then the problem is because the CD is loading some kind of driver on boot (probably XMS via config.sys) whereas your default boot is not. You should be able to fix it by copying the contents of config.sys and autoexec.bat to your FreeDos boot-up environment. You should also check to see that FreeDos is not loading extraneous stuff.

I have burned an ISO of my Windows 98 install CD because I don't manage to connect my CD device to the virtual box.

The CD image you created was probably not a valid CD image or was not bootable. Try ImgBurn, VFD, BCD, or CDIMAGE. Just make sure to select the bootable option when creating the image.

My Windows 98 install CD is a basic one, not the 98 SE one.

I'm not familiar with all of the intricacise of Microsoft licensing, but I believe you should be able to download and use a 98SE image if you have a legitimate 98 key. If you have a copy of XP, you can download SP3 without having to buy a new copy; you should also be able to download an ISO of XP with SP3 pre-installed without it being considered piracy. The SE release of 98 was effectively just a service-pack for 98.

A: Probably because the Windows 98 included MS-DOS autoload extended memory support thanks to HIMEM.SYS, so it can detect correctly the amount of usable memory. FreeDOS may enable only the 1st MB of RAM. The equivalent of HIMEM.SYS from MS-DOS is HIMEM.EXE, which should be loaded if you add it in CONFIG.SYS. However, Windows 98 installer should load another driver called XMSMMGR.EXE if no other driver are loaded, but I'm not sure about that.
Still, you should not use FreeDOS to insall Windows 98 which owns already a bootable MS-DOS.

A: I ran into the same problem and discovered that passing /IT (ignore TSRs) to setup resolved the issue.


text:
Q: Adding an empty value to the enum class Below is the enum class available in my code but, I want to add an empty value to it. After adding empty value to this class I am getting an error.
public enum AgentLevel : int
{

        [System.Runtime.Serialization.EnumMemberAttribute()]
        Location = 1,

        [System.Runtime.Serialization.EnumMemberAttribute(Value="Head Quarter")]
        HeadQuarter = 2,
}

A: If you need to just initialize an empty string then you could:
public enum AgentLevel : int {

        [System.Runtime.Serialization.EnumMemberAttribute(Value = "")]
        Location = 1,

        [System.Runtime.Serialization.EnumMemberAttribute(Value="Head Quarter")]
        HeadQuarter = 2,
    }


text:
Q: Symfony 3 FosUserBundle non unique username login Things we want to achieve in our application are:

*

*Non-unique usernames [Done]

*Unique username and email combination

*FosUserBundle will fetch all users (on user login) with given username and checks if any of the users has the given password (hashed with bcrypt). When a user is found it logs the user in.

Making username non unique was quite simple by just overriding the username field in the user ORM. But we're kinda stuck with how to proceed in achieving the last two points. We've started creating a custom User Provider but it seems Symfony Security can only handle one user(name).
Is there anyone with experience that might be able to help us? If you need more information or code snippets, please ask. Thank you in advance!

A: So after looking through alot of the documentation for the Symfony Security module we figured it out.
We added an extra field (displayname) to the User model because Symfony is completely build around the fact that usernames are Unique. It always fetches the first user with the given username, this is not what we wanted.
So we started with writing our own Guard Authentication System, this was pretty straight forward although we had to make some adjustments.
This was all working well, but we ran into a problem with the built-in UsernamePasswordFormAuthenticationListener, this listener was still picking up the displayname from the login form. We actually want the unique username so that Symfony knows which user to use.
We created a custom listener that extended the standard listener and made sure the username was not fetched from the login form but from the user token.
So our flow is now like this: The user fills in his username (actually his displayname) and password, the system fetches all users with that displayname. Then we loop these users and check if someone has that password. If so, authenticate the user.
On user create the admin fills in the displayname and the system will autoincrement this as a username. (admin_1, admin_2, ...).
We have to monitor if what @kero said is true, but with Bcrypt it seems that even with simple passwords like "123", it results in a different hash for each user.
The only thing that is left is to have a UniqueConstraint on the unique combination of the displayname and email. If anyone knows how this can be achieved in our orm.xml and form, thank you.
http://symfony.com/doc/current/security/guard_authentication.html
Custom Guard Authenticator
class Authenticator extends AbstractGuardAuthenticator
{
    private $encoderFactory;
    private $userRepository;
    private $tokenStorage;
    private $router;

public function __construct(EncoderFactoryInterface $encoderFactory, UserRepositoryInterface $userRepository, TokenStorageInterface $tokenStorage, Router $router)
{
    $this->encoderFactory = $encoderFactory;
    $this->userRepository = $userRepository;
    $this->tokenStorage = $tokenStorage;
    $this->router = $router;
}

/**
 * Called on every request. Return whatever credentials you want,
 * or null to stop authentication.
 */
public function getCredentials(Request $request)
{
    $encoder = $this->encoderFactory->getEncoder(new User());
    $displayname = $request->request->get('_username');
    $password = $request->request->get('_password');

    $users = $this->userRepository->findByDisplayname($displayname);

    if ($users !== []) {
        foreach ($users as $user) {
            if ($encoder->isPasswordValid($user->getPassword(), $password, $user->getSalt())) {
                return ['username' => $user->getUsername(), 'password' => $user->getPassword()];
            }
        }
    } else {
        if ($this->tokenStorage->getToken() !== null) {
            $user = $this->tokenStorage->getToken()->getUser();

            return ['username' => $user->getUsername(), 'password' => $user->getPassword()];
        }
    }

    return null;
}

public function getUser($credentials, UserProviderInterface $userProvider)
{
    if ($credentials !== null) {
        return $userProvider->loadUserByUsername($credentials["username"]);
    }

    return null;
}

public function checkCredentials($credentials, UserInterface $user)
{
    if ($user !== null) {
        return true;
    } else {
        return false;
    }
}

public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
{
    return null;
}

public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
    $exclusions = ['/login'];

    if (!in_array($request->getPathInfo(), $exclusions)) {
        $request->getSession()->set(Security::AUTHENTICATION_ERROR, $exception);
        throw $exception;
    }
}

/**
 * Called when authentication is needed, but it's not sent
 */
public function start(Request $request, AuthenticationException $authException = null)
{
    $data = array(
        // you might translate this message
        'message' => 'Authentication Required'
    );

    return new JsonResponse($data, Response::HTTP_UNAUTHORIZED);
}

public function supportsRememberMe()
{
    return false;
}
}

Custom listener
class CustomAuthListener extends UsernamePasswordFormAuthenticationListener
{
    private $csrfTokenManager;
    private $tokenStorage;

public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, CsrfTokenManagerInterface $csrfTokenManager = null)
{
    parent::__construct($tokenStorage, $authenticationManager, $sessionStrategy, $httpUtils, $providerKey, $successHandler, $failureHandler, array_merge(array(
        'username_parameter' => '_username',
        'password_parameter' => '_password',
        'csrf_parameter' => '_csrf_token',
        'csrf_token_id' => 'authenticate',
        'post_only' => true,
    ), $options), $logger, $dispatcher);

    $this->csrfTokenManager = $csrfTokenManager;
    $this->tokenStorage = $tokenStorage;
}

/**
 * {@inheritdoc}
 */
protected function attemptAuthentication(Request $request)
{
    if ($user = $this->tokenStorage->getToken() !== null) {
        $user = $this->tokenStorage->getToken()->getUser();
        $username = $user->getUsername();

        if ($this->options['post_only']) {
            $password = ParameterBagUtils::getParameterBagValue($request->request, $this->options['password_parameter']);
        } else {
            $password = ParameterBagUtils::getRequestParameterValue($request, $this->options['password_parameter']);
        }

        if (strlen($username) > Security::MAX_USERNAME_LENGTH) {
            throw new BadCredentialsException('Invalid username.');
        }

        $request->getSession()->set(Security::LAST_USERNAME, $username);

        return $this->authenticationManager->authenticate(new UsernamePasswordToken($username, $password, $this->providerKey));
    } else {
        return null;
    }
}
}

Listener service
<service id="security.authentication.listener.form" class="Your\Path\To\CustomAuthListener" parent="security.authentication.listener.abstract" abstract="true" />


text:
Q: Can't change background of actionbar in Android Studio I want to change the background of actionbar but it doesn't work. The code is rather simple:
<style name="AppTheme" parent="@style/Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
    <item name="android:actionBarStyle">@style/ActionBarTheme</item>
</style>

<style name="ActionBarTheme"
parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:background">@drawable/green1</item>
    <item name="background">@drawable/green1</item>
</style>

<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">
</activity>

green1 is a picture in drawable. I run the program, the actionbar shows as the default theme instead of the picture I want. What is the problem? Really confused.

A: Because your AppTheme Use parent="@style/Theme.AppCompat.Light">, your ActionBarTheme should use:
<style name="ActionBarTheme"
       parent="@style/Widget.AppCompat.Light.ActionBar">
       ... ...
</style>

replace:
<style name="ActionBarTheme"
       parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
       ... ...
</style>

othewise if your AppTheme use DarkActionBar then your ActionBarTheme use Solid.Inverse is ok


text:
Q: How to call TWS Beans from another Java EE server How to call TWS beans from another Java EE server like JBoss or even WAS Liberty Profile?

A: I've no direct experience with JBoss or Liberty, but we have tried several times from Tomcat without success. Maybe it's possible with Liberty but as said I've never tried it.
This is one of the reason we are moving to REST APIs that makes interoperability much easier. REST APIs has been introduced on TWSd with 9.3 FP2, but are still not available on TWSz.
If you need them on TWSz, you can try to open an RFE to push this new feature.
If you don't have a product/release that natively support REST APIs, a possible pattern is to implement your own REST APIs based on J2EE APIs and deploy them as an additional WAR on the engine/connector WAS, and the call these REST APIs from your JBoss, Liberty.


text:
Q: dask histogram from zarr file (a big zarr file) So heres my question, I have a big 3dim array which is 100GB in size as a #zarr file (the array is more than twice the size). I have tried using the histogram from #Dask to calculate but I get an error saying that it cant do it because the file has tuples within tuples. Im guessing thats the zarr file formate rather than anything else?
any thoughts?
edit:
yes the bigger computer thing wouldnt actually work...
Im running a dask client on a single machine, it runsthe calculation but just gets stuck somewhere.
I just tried dask.map function across the file but when I plot it out I get something like this:
ValueError: setting an array element with a sequence.

heres a version of the script:
def histo(img):
    return da.histogram(img, bins=255, range=[0, 255])

histo_1 = da.map_blocks(histo, fimg)

I am actually going to try and use it out side of the map function. I wonder rather than the map funtion, does the windowing from map blocks, actually cause the issue. well, ill let you know if it is or now....
edit 2
So I tried to remove the map blocks function as suggested and this was my result:

[in] h, bins =da.histogram(fused_crop, bins=255, range=[0, 255])

[in] bins
[out] array([  0.,   1.,   2.,   3.,   4.,   5.,   6.,   7.,   8.,   9.,  10.,
        11.,  12.,  13.,  14.,  15.,  16.,  17.,  18.,  19.,  20.,  21.,
        22.,  23.,  24.,  25.,  26.,  27.,  28.,  29.,  30.,  31.,  32.,
        33.,  34.,  35.,  36.,  37.,  38.,  39.,  40.,  41.,  42.,  43.,
        44.,  45.,  46.,  47.,  48.,  49.,  50.,  51.,  52.,  53.,  54.,
        55.,  56.,  57.,  58.,  59.,  60.,  61.,  62.,  63.,  64.,  65.,
        66.,  67.,  68.,  69.,  70.,  71.,  72.,  73.,  74.,  75.,  76.,
        77.,  78.,  79.,  80.,  81.,  82.,  83.,  84.,  85.,  86.,  87.,
        88.,  89.,  90.,  91.,  92.,  93.,  94.,  95.,  96.,  97.,  98.,
        99., 100., 101., 102., 103., 104., 105., 106., 107., 108., 109.,
       110., 111., 112., 113., 114., 115., 116., 117., 118., 119., 120.,
       121., 122., 123., 124., 125., 126., 127., 128., 129., 130., 131.,
       132., 133., 134., 135., 136., 137., 138., 139., 140., 141., 142.,
       143., 144., 145., 146., 147., 148., 149., 150., 151., 152., 153.,
       154., 155., 156., 157., 158., 159., 160., 161., 162., 163., 164.,
       165., 166., 167., 168., 169., 170., 171., 172., 173., 174., 175.,
       176., 177., 178., 179., 180., 181., 182., 183., 184., 185., 186.,
       187., 188., 189., 190., 191., 192., 193., 194., 195., 196., 197.,
       198., 199., 200., 201., 202., 203., 204., 205., 206., 207., 208.,
       209., 210., 211., 212., 213., 214., 215., 216., 217., 218., 219.,
       220., 221., 222., 223., 224., 225., 226., 227., 228., 229., 230.,
       231., 232., 233., 234., 235., 236., 237., 238., 239., 240., 241.,
       242., 243., 244., 245., 246., 247., 248., 249., 250., 251., 252.,
       253., 254., 255.])

[in] h.compute
[out] <bound method DaskMethodsMixin.compute of dask.array<sum-aggregate, shape=(255,), dtype=int64, chunksize=(255,), chunktype=numpy.ndarray>>

im going to try in another notebook and see if it still occurs.
edit 3
its the stranges thing, but if I just declare the variable h, it comes out as one small element from the dask array?
edit
Strange, if i call the xarray.hist or the da.hist function, they both fall over. If I use the skimage.exposure.histogram it works but it appears that the zarr file is unpacked before the histogram is a calculated. Which is a bit of a problem...
Update 7th June 2020 (with a solution for not big but annoyingly medium data) see below for answer.

A: You probably want to use dask's function for this rather than map_blocks. For the latter, Dask expects the output of each call to be the same size as the input block, or a shape derived from the input block, instead of the one-dimensional fixed-size output of histogram.
h, bins =da.histogram(fused_crop, bins=255, range=[0, 255])
h.compute()

A: Update 7th June 2020 (with a solution for not big but annoyingly medium data):
So unfortunately I got a bit ill around this time and it took a while for me to feel a bit better. Then the pandemic happened and I was on full childcare duty. I tried lots of different option and what ultimately, this looked like was that the following:
1) if just using x.compute, the memory would very quickly fill up.
2) Using distributed would fill the hard drive with spill to disk and take hours but would hang and crash and not do anything because...it would compute (im guessing here but based on the graph and dask api) it would create a sub histogram array for every chunk... that would all need to be merged at some point.
3) The chunking of my data was sub optimal so the amount of tasks was massive but even then I couldn't compute a histogram when i improved the chunking.
In the end I looked for a dynamic way of updating the histogram data. So I used Zarr to do it, by computing to it. Since it allows conccurrent reads and writing functions. As a reminder : my data is a zarr array in 3 dims x,y,z and uncompressed 300GB but compressed it's about 100GB. On my 4 yr old laptop with 16GB of ram using the following worked (I should have said my data was 16 bit unsigned:
imgs = da.from_zarr(.....)

imgs2 = imgs.rechunk((a,b,c)) ## individual chunk dim per dim

h, bins = da.histogram(imgs2, bins = 255, range=[0, 65535]) # binning to 256

h_out = da.to_zarr(h, "histogram.zarr")

I ran the progress bar alongside the process and to get a histogram from file took :
[########################################] | 100% Completed | 18min 47.3s

Which I dont think is too bad for a 300GB array. Hopefully this helps someone else as well, thanks for the help earlier in the year @mdurant.


text:
Q: Which NodeJS Frameworks support relational databases? I'm starting server-side development with NodeJS, I have found lots of promising frameworks, but can't tell which of them support relational databases (Namely Postgres).
Any ideas? Server-side MVC frameworks are preferred.

A: Express is universal framework ( and really popular one ), you can use it with any database you want. You just need a database driver. You can use one of these:
https://github.com/brianc/node-postgres ( low level )
https://github.com/grncdr/node-any-db
https://github.com/brianc/node-sql
There are probably many many more, just google it.

A: check out the modules list here
there are many db modules for mysql/SQLite/PostgreSQL etc...

A: I'd go with Sequelize.js. It's an ORM for Postgres and MySQL. It's recommended in some books about node.js. I gave it a try and it looked promising.
On the other hand I would ask myself a question: If I need to use relational database, is node.js still a good choice?

A: sails.js is built on express (see @freakish's answer) and supports MySQL, Postgres, and over a dozen other NoSQL and SQL databases.


text:
Q: Datatables - dataTables_length, dataTables_filter, dataTables_info & dataTables_paginate all display on separate lines problem I have the following script to wrap around datatables on my users_index table.
$(document).ready(function() {
    $('#users_index').DataTable( {
        "dom": '<lf<t>ip>'
    } );
} );

I expected dataTables_length, dataTables_filter to display on the same line.  Also, I expected dataTables_info & dataTables_paginate to display on the same line.  This is how it displays;

See above how each dataTables_length, dataTables_filter, dataTables_info & dataTables_paginate all display on a separate line.
I would like dataTables_length & dataTables_filter to be on one line and dataTables_info & dataTables_paginate to be on one line.
I tried removing the '<' and '>' but the display doesn't change at all.
Any suggestions appreciated.
Here is the html (reduced the table to just one user);

                        Name
                        Email
                        Is Active?
                         Admin?
                        Created At
                        Updated At

                            mainuser

                            me@example.com

                            yes

                            2021-04-16 21:08:18

                            2021-05-09 10:41:48


text:
Q: Dropping observations in SAS based on length I have a dataset that I'm trying to create tables from but I need to filter out the observations that don't belong in those tables. I'm still learning my way around SAS, so I don't know how to drop the observations using conditions.
Basically I want to drop the observations that have an ID value that is not four digits (in terms of length). Is this possible?
Thanks in advance.

A: Assuming your ID is character, and you don't consider blanks digits:
if lengthn(id) ~= 4 then delete;
If your ID is numeric:
if 1000 <= id <= 9999 then output;

A: If id is character:
where length(id) = 4;

If id is numeric:
where id between 1000 and 9999;


text:
Q: How to change naming scheme for network interfaces of an already installed Ubuntu 16.04? I want to change naming scheme for network interfaces for the classic one (eth0, eth1, etc). Is it possible to an already installed Ubuntu 16.04 machine?

A: It is possible, edit the following file with your favorite editor (vi for example)
vi /etc/udev/rules.d/70-persistent-net.rules


text:
Q: Command Timeout not working I am using Entity Framework to communicate with SQL Server. I set connection timeout = 36000 in connection string, then set command Timeout = 36000 for EF context object. I also set this line in web config.
<httpRuntime executionTimeout="36000" />

I also set timeout = 28800 like this.
<authentication mode="Forms">
            <forms loginUrl="~/view/login/Login.aspx" timeout="28800" defaultUrl="~/view/login/WellComePage.aspx"/>
        </authentication>

After setting this all, i fetch data from db. It works fine for small data, but for long queries i got following message after 44 seconds. Although i didn't set 44 anywhere.

'Execution Timeout Expired.  The timeout period elapsed prior to
  completion of the operation or the server is not responding.'

Any idea what i am doing wrong here.


text:
Q: How to fix 'Failed to Update dependency information of the project. Please restore the project and try again' I'm writing a new web API using .net core 2.2 and I connected an existing database using entity framework. but I keep getting an error saying above when I try to add a controller to the existing model using Scaffold new item.
here are the commands I used
Install-Package Microsoft.EntityFrameworkCore.SqlServer
Install-Package Microsoft.EntityFrameworkCore.Tools
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design

Scaffold-DbContext to reverse engineer and create the EF model based on my existing database.
but keeps getting below error
"There was an error running the selected code generator: ' Failed to update dependency information for the project. Please restore the project and try again.'
I tried everything I could think of and I even gets the same error when I tries to add an empty controller also

A: I met this issue and found nothing wrong in my project.
After deleting the bin and obj folder, this issue is gone.

A: It was due to a mismatch between .netCore version and EntityFrameworkCore version.
Edit
I uninstalled the EFCore and installed a parallel versiion for .net core
Ex
.netCore 2.0.9
EFCore 2.2.4

A: i had the same error
then i uninstalled all packages and reinstall them again throught nuget
i don't no why but it worked for me


text:
Q: converting a SQL statement to LINQ query on a DataTable I am studying that Linq to DataTable,Lambda.
Because is difficult want to change sql to linq,Lambda, is not doing.
Below the SQL code is member list that remove telephone number repetition.
I will thank if help.
SELECT A.no, B.name, B.userId, B.homeTel2
FROM

    (  SELECT homeTel2, min(no) NO
       FROM  OF_Member
       GROUP BY homeTel2
    ) A
    INNER JOIN OF_Member B
        ON A.NO = B.NO

Progressing work  ============
var objectName =from t in mMemberTable.AsEnumerable()
    group t by t.Field("homeTel2")

A: Try this link:
Linq to Entities simple group query
converting ms sql "group by" query to linq to sql
                var objectName =from t in mMemberTable.AsEnumerable()
                group t by t.Field<string>("homeTel2") into groups
                select groups;

Hope this helps,
Regards

A: Try using a tool called LINQ Pad. This is the best tool so far for writing and testing sql/LINQ queries and moreover it is free. It also allows you to convert your queries from LINQ to SQL and vice-versa.
http://www.linqpad.net


text:
Q: I can't enable MFA for Oracle Identity Cloud Service user I just sign-up an account of Oracle Cloud
After I logged in, It seem the system automatically created a tenancy for me and added me to an Identity Providers named oracleidentitycloudservice.
They also create one more user starts with oracleidentitycloudservice/username.
This is identity user page, both 2 of them is me. One of them is federated with oracleidentitycloudservice which is created automatically.

I can enable MFA for the second account.
But I can not enable MFA account for oracleidentitycloudservice/username:

When I want to login to Identity Console page, I need to use this SSO method:

It seem risky if Identity Console page doesn't provide MFA feature. That's what I worry about.
Question is:

*

*Is it safe if I delete oracleidentitycloudservice/username?

*How can I enable MFA for oracleidentitycloudservice/username from Oracle Infastructure page?

*If Oracle is providing a complicated way to enable MFA for oracleidentitycloudservice/username, could it be a security issue?

A: For those who are in the same situation, here is step to Enable MFA for Oracle Identity cloud service user:

*

*Sign in by this SSO method at this screen:

*Go to Service User Console on top-right screen

*Go to Admin Console of Identity

*Go to My profile on top-right screen

*Go to Security tab, our goal is to give the account permissions so that MFA item shows on this screen. At this moment MFA is not yet enabled, move to next step

*Go to Admin console at top-right screen

*Go to Security -> MFA at left side panel, check the box Mobile App Passcode

*Go to Security -> Sign-On Policies, edit the Default Policy

*Edit Default Sign-on Rule

*Select the option that you prefer. It's upto you.

*Go to Security tab and here you can enable MFA for your IDCS account

*Sign-out and Sign-in again. Now you can use MFA to login.

A: Here's how you enable MFA (TOTP Authenticator) for Free Tier accounts:

*

*Navigate to https://www.oracle.com/in/cloud/sign-in.html

*Enter your Cloud Account Name and click Next

*Select oracleidentitycloudservice as your Identity Provider and click Continue

*Enter your username and password

*Click on hamburger menu and select Identity & Security > Federation

*Click on OracleIdentityCloudService

*Click on the link next to Oracle Identity Cloud Service Console

*You should be logged into the Oracle Identity Cloud Service console. Click on the hamburger menu and select Security > MFA

*I don't see a way to enable Duo Security or FIDO Authenticator at this screen. Probably because the license type is Foundation but if you found a way to enable either of those, please edit this answer. If not, enable Mobile App Passcode and Mobile App Notification and click Save

*Click on the top right corner of the screen with your initials and select My Profile

*Click on the Security tab and you should see a 2-Step Verification section with an Enable button.

*Click on Enable and select Mobile App

*Check Offline Mode or Use Another Autenticator App

*Scan the QR code with your favorite TOTP app (I used Authy) and enter a code and click Verify

*You'll now have a 2SV factor enabled

*Go back to the console by clicking on your initials at the top right corner and selecting Admin Console

*Click on the hamburger menu and navigate to Security > Sign-On Policies

*Edit the Default Sign-On Policy by clicking on  and selecting Edit

*Click on the Sign-On Rules tab and edit the Default Sign-On Rule by clicking on  and selecting Edit

*Scroll down to Actions section and enable Prompt for an additional factor and leave the rest at defaults and click Save

*Log out and log back in again (alternatively open the Oracle Identity Cloud Service Console URL from step 7 in a private/incognito tab) and verify that you're prompted for the TOTP code after entering your username and password.

A: I have the same issue.
I was following an official training from Oracle and found that the option did not appear because I was using the federated user.
You may manage all the users from the the lines button at the top-left corner and from there 'Identity & Security'.
First menu Identity & Security
Once you click on that option, you will see:
Choose Users
And this is the main user's options with the MFA and password reset if required:
User's options including MFA
Dani.

A: This is already old information, OCI is constantly changing it's dashboard. If you can't find the correct screens anymore, see this Oracle Documentation page, with which I set the policy after I enabled 2FA on my profile via Security:
https://docs.oracle.com/en-us/iaas/Content/Identity/mfa/understand-multi-factor-authentication.htm?Highlight=mfa
After that 2FA is asked after you login with your credentials.


text:
Q: Representing an Integer in bits : Error I am trying to declare an integer in bytes.
What i mean is : i am trying to declare int a = 4 as  int a = 0100(i have shortened it here to 4 bits for simplicity. )
Following is the code which i have used and is giving me unexpected output.
public class class4A_d {
public static void main(String[] args) {
    System.out.println("Hello world,this is the main function ");
    int q1=  00000100;  //8 bits
    int q2 = 00000000000000000000000000000100; //32 bits
    System.out.println("q1 and q2 are respectively "+ q1 + ":" + q2); //q1= 64,q2 =64
                                       }
                       }

I know java stores integers as 32 bits number in 2,s complement in the back end with weight of each bit progressing in the following manner:
2(^0),2(^1),2(^2).....etc.
But here it seems that the weights are in the following manner :
8(^0),8(^1),8(^2).....etc.
Can anyone  explain this ?

A: When you declare an int, you have the possibility to do it decimal, octal, hexadecimal and binary.
Binary:
Binary int constants begin with 0b, e.g.
int binary = 0b00000100; //decimal: 4

Octal:
Octal int constants begin with 0, so be careful because it can happen, that you use them accidentally, e.g.
int octal = 0127; //decimal 87

Hexadecimal:
Hexadecimal int constants begin with 0x, e.g.
int hex = 0xFF; //decimal 255


text:
Q: How to implement INotifyPropertyChanged with nameof rather than magic strings? I was reading about the new nameof keyword in C# 6.
I want to know how can I implement INotifyPropertyChanged using this keyword, what are the prerequisites (of course other than C# 6) and how it will effect the performance of my MVVM application?

A: It's just a matter of using nameof() instead of the magic string. The example below is from my blog article on the subject:
private string currentTime;

public string CurrentTime
{
    get
    {
        return this.currentTime;
    }
    set
    {
        this.currentTime = value;
        this.OnPropertyChanged(nameof(CurrentTime));
    }
}

Since it is evaluated at compile-time, it is more performant than any of the current alternatives (which are also mentioned in the blog article).

A: Here's a complete code sample of a class using the new C# 6.0 sugar:
public class ServerViewModel : INotifyPropertyChanged {
    private string _server;
    public string Server {
        get { return _server; }
        set {
            _server = value;
            OnPropertyChanged(nameof(Server));
        }
    }

    private int _port;
    public int Port {
        get { return _port; }
        set {
            _port = value;
            OnPropertyChanged(nameof(Port));
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;
    protected void OnPropertyChanged(string propertyName) =>
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

With this, you get the nameof() operator, the null-conditional operator ?., and an expression-bodied function (the OnPropertyChanged definition).

A: I've found it's a lot easier to use PropertyChanged.Fody as you end up with less mistakes and a hell of a lot cleaner code, see - https://github.com/Fody/PropertyChanged
All you have to do is label up your class with ImplementPropertyChanged attribute:
[ImplementPropertyChanged]
public class Person
{
    public string GivenNames { get; set; }
    public string FamilyName { get; set; }

    public string FullName
    {
        get
        {
            return string.Format("{0} {1}", GivenNames, FamilyName);
        }
    }
}

And after build it gets transformed in to:
public class Person : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    string givenNames;
    public string GivenNames
    {
        get { return givenNames; }
        set
        {
            if (value != givenNames)
            {
                givenNames = value;
                OnPropertyChanged("GivenNames");
                OnPropertyChanged("FullName");
            }
        }
    }

    string familyName;
    public string FamilyName
    {
        get { return familyName; }
        set
        {
            if (value != familyName)
            {
                familyName = value;
                OnPropertyChanged("FamilyName");
                OnPropertyChanged("FullName");
            }
        }
    }

    public string FullName
    {
        get
        {
            return string.Format("{0} {1}", GivenNames, FamilyName);
        }
    }

    public virtual void OnPropertyChanged(string propertyName)
    {
        var propertyChanged = PropertyChanged;
        if (propertyChanged != null)
        {
            propertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

A: It would look like this:
public string Foo
{
   get
   {
      return this.foo;
   }
   set
   {
       if (value != this.foo)
       {
          this.foo = value;
          OnPropertyChanged(nameof(Foo));
       }
   }
}

The nameof(Foo) will be substituted with the "Foo" string at compile time, so it should be very performant. This is not reflection.

A: See the documentation for INotifyPropertyChanged.PropertyChanged Event
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }


text:
Q: How to convert $(A \vee B) \wedge (C \vee D)$ to CNF? Wikipedia states that all propositional logic statements can be transformed into CNF.
However, I'm not so sure how we can further simplify $(A \vee B) \wedge (C \vee D)$?
Or if this is CNF, why is it in CNF? To quote wikipedia:

... it is a conjunction of one or more clauses, where a clause is a disjunction of literals; otherwise put, it is a product of sums or an AND of ORs ...

A: $(A \vee B) \wedge (C \vee D)$ is an AND of two OR's: $A \vee B$ and $ C \vee D$
Moreover, both OR's are disjunctions of literals: $A, B, C,$ and $D$ are all atomic statements, which are all literals.
So, this statement is in CNF


text:
Q: The correct design: Including module in ActiveRecord or helper method I have a Sinatra application using ActiveRecord and I wish to add a feature where I can generate a fingerprint (SHA1) for a set of records.
The way I've implemented this is by defining a module and including it within ActiveRecord::Relation as follows:
module Fingerprints
  def sha1
    Digest::SHA1.hexdigest map{ |record| record.attributes.values.join }.join
  end
end

ActiveRecord::Relation.send :include, Fingerprints

I can now call 'sha1' on a ActiveRecord::Relation and get the value I need.
My question is whether this is the "preferred" way to be doing this (extending ActiveRecord with additional functionality)?
The final line that uses send feels unclean to me and the simple fact that I'm bolting features onto a class that isn't my own also feels like a hack. I know this is a standard pattern in Ruby but reaching into ActiveRecords guts and patching it in this way is unfamiliar to me.
The alternative is to create a Sinatra helper that takes a ActiveRecord::Relation and returns the fingerprint. While this feels cleaner, I can't help feeling that the sha1 method should really belong to the ActiveRecord::Relation class to better describe it's intent.
This might be simply down to personal preference but I'd be interested how others do this and whether there is a feeling of the "right" way this is done.
Thanks

A: In all honesty I can't see any real problem with what you've done. Perhaps call the method fingerprint_sha to prevent clobbering, maybe add an custom exception so that if any problems occur you know that it started in your code and not AR's.
Personally, I'd probably have made this a helper and passed in the relation, it could well be more obvious where the method was defined for others if it's in the helpers, but like I say I don't see a problem with what you've done and think it's a good solution.
Maybe someone else will come along and say different and we'll both learn something here :)


text:
Q: Render text in center of line in d3.js I am new to d3.js I want to how to render the text in the center of line in d3.js. I have attached the image how it should be rendered.

A: renderTextInCenterOfLine will put a text with background in the center of a line:

const renderTextInCenterOfLine = (line, text) => {
  const from = parseInt(line.attr('x1'));
  const to = parseInt(line.attr('x2'));
  const y = parseInt(line.attr('y1'));
  const svg = d3.select('svg');
  const textBackground = svg.append('rect')
  const textElement = svg.append('text')
    .text(text)
    .attr('x', (from + to) / 2)
    .attr('y', y)
    .attr('text-anchor', 'middle')
    .attr('alignment-baseline', 'central');

  const box = textElement.node().getBBox();
  const width = box.width + 50; //
  const height = box.height + 20;
  textBackground
    .attr('x', (from + to - width) / 2)
    .attr('y', y - height / 2)
    .attr('width', width)
    .attr('height', height)
    .style('fill', 'white')

}

renderTextInCenterOfLine(d3.select('#my-line'), '2020');
text {
  font-size: 32px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>
<svg width="500" height="100">
  <line id="my-line" x1="20" x2="480" y1="40" y2="40" stroke="#000" />
  <line x1="20" x2="20" y1="30" y2="50" stroke="#000" />
  <line x1="480" x2="480" y1="30" y2="50" stroke="#000" />
</svg>


text:
Q: Stop intellisense from changing my table Alias Using DBeaverEE as i type i get intellisense for table names but if I want to alias that table (I for example) if i type I then space intellisense is kicking in and changing it to some keyword. This is pretty frustrating but i don't want to completely turn off intellisense, anyone else have this problem and figure out a solution?

A: I think the easiest way would be to turn off the auto-activate on typing option.
Go to Window > Preferences > General > Editors > SQL Editor > SQL Completion
Toward the top of the SQL Completion page there should be an option named "Activate on typing". Uncheck this box and the editor won't activate intellisense until you hit ctrl + space.
SQL Completion Page


text:
Q: CSS reference to phone's Emoji font? I want to use this specific emoji in my web page 🔍 - 🔍
On Android, the browser recognises the Unicode glyph as an Emoji, and displays.

On the desktop it renders as a Unicode fallback character - a little square with numbers in.
So, using Symbola, Quivira, or any other font with the right symbols, I can fix that.
@font-face {
    font-family: 'quiviraregular';
    src: url('fonts/quivira.woff2') format('woff2');
}

body{
 font-family:sans-serif,quiviraregular;
}

However, now Android displays the symbol from the font, not the Emoji.
Is there any way to set the font-family declaration so that Android (and iPhone) will use their in-built colour Emoji and all other browsers will use the provided symbol font?

A: Modernizr has a (non core) feature detection for emoji support. If you create your own build of Modernizr with cssclasses and emoji you can use the .no-emoji class that's added to the html tag to have a different font-family.
body {
    font-family: sans-serif;
}

.no-emoji body {
    font-family: sans-serif, emojisymbols;
}

I've created a jsFiddle that shows a green background if you have emoji support, and a red background and Kenichi Kaneko's EmojiSymbols font if haven't got emoji support. Unfortunately I could only see the EmojiSymbols font work on Windows 7 + Firefox, but this might give you a start.
Update based on comment
To see that it is possible to detect a specific character is supported lets take a look at Modernizr's feature detection source code for emoji support:
define(['Modernizr', 'createElement', 'test/canvastext'], function( Modernizr, createElement ) {
  Modernizr.addTest('emoji', function() {
    if (!Modernizr.canvastext) return false;
    var node = createElement('canvas'),
    ctx = node.getContext('2d');
    ctx.fillStyle = '#f00';
    ctx.textBaseline = 'top';
    ctx.font = '32px Arial';
    ctx.fillText('\ud83d\udc28', 0, 0); // U+1F428 KOALA
    return ctx.getImageData(16, 16, 1, 1).data[0] !== 0;
  });
});

it works by creating a canvas element, rendering the  koala emoji and checking the red color channel value of a specific pixel, which I'm assuming exists in every rendition of this emoji.
You can extend this function to check if all emoji in a parameter list are supported, and if not use the emoji font fallback. I think that the best solution would be to render every emoji in the same canvas and to check if there is at least one pixel colored inside the bounding box of each emoji. I'm not sure how a unsupported emoji is rendered, it might be needed to detect this.
P.S. As I would assume that specifying the default font from which the emoji come before the fallback emoji font should be enough to solve this, am I correct in assuming that these emoji don't exist in a default font?

A: One approach would be to use media-queries to target devices with no native support (such as desktop PCs), and apply the custom font-family, e.g. (very broadly speaking, you will want to refine the below)
// target devices with 'larger than mobile' screen size...and apply the emoji 'polyfill'
@media only screen and (min-device-width: 768px){
   body{
      font-family:quiviraregular;
   }
}

A: I took @ckuijjer's answer and ran with it. I found that position 16,16 was not reliable in IE11. Position 14,16 had problems in FireFox. But so far Position 12,16 has worked everywhere I tried it (IE11, Edge, FF42+, Chrome; Windows7, Windows10, OSX10.11).
export default class EmojiUtils {
  static checkEmoji(char) {
    var node = document.createElement('canvas');
    var ctx = node.getContext('2d');
    ctx.fillStyle = '#f00';
    ctx.textBaseline = 'top';
    ctx.font = '32px Arial';
    ctx.fillText(char, 0, 0);
    return ctx.getImageData(12, 16, 1, 1).data[0] !== 0;
  }

  static checkColor() {
    var node = document.createElement('canvas');
    var ctx = node.getContext('2d');
    ctx.fillStyle = '#000';
    ctx.textBaseline = 'top';
    ctx.font = '32px Arial';
    ctx.fillText('\uD83D\uDD34', 0, 0);
    var data = ctx.getImageData(16, 16, 1, 1).data;
    return data[0] > data[1];
  }

  static polyfillEmoji() {
    if (!EmojiUtils.checkColor()) {
      require('emojione/font.css');
    } else {
      if (!EmojiUtils.checkEmoji('\uD83D\uDD7A')) { //Dancing man Unicode 9.0
        require('emojione/font-versioned.css');
      }
    }
  }
}

I then simply have to call EmojiUtils.polyfillEmoji() when the page loads.
I added to my body font-family: "EmojiOneColor", "EmojiOneColor-9", sans-serif;
font.css:
@font-face {
  font-family: 'EmojiOneColor';
  font-style: normal;
  font-weight: 400;
  src: local('EmojiOneColor'), local('EmojiOne Color'), url(emojione-svg.woff);
  unicode-range: U+0020, U+0023, U+002A, U+0030-0039, U+00A9, U+00AE, U+200D, U+203C, U+2049, U+20E3, U+2122, U+2139, U+2194-2199, U+21A9-21AA, U+231A-231B, U+2328, U+23CF, U+23E9-23F3, U+23F8-23FA, U+24C2, U+25AA-25AB, U+25B6, U+25C0, U+25FB-25FE, U+2600-2604, U+260E, U+2611, U+2614-2615, U+2618, U+261D, U+2620, U+2622-2623, U+2626, U+262A, U+262E-262F, U+2638-263A, U+2648-2653, U+2660, U+2663, U+2665-2666, U+2668, U+267B, U+267F, U+2692-2694, U+2696-2697, U+2699, U+269B-269C, U+26A0-26A1, U+26AA-26AB, U+26B0-26B1, U+26BD-26BE, U+26C4-26C5, U+26C8, U+26CE-26CF, U+26D1, U+26D3-26D4, U+26E9-26EA, U+26F0-26F5, U+26F7-26FA, U+26FD, U+2702, U+2705, U+2708-270D, U+270F, U+2712, U+2714, U+2716, U+271D, U+2721, U+2728, U+2733-2734, U+2744, U+2747, U+274C, U+274E, U+2753-2755, U+2757, U+2763-2764, U+2795-2797, U+27A1, U+27B0, U+27BF, U+2934-2935, U+2B05-2B07, U+2B1B-2B1C, U+2B50, U+2B55, U+3030, U+303D, U+3297, U+3299, U+FE0F, U+1F004, U+1F0CF, U+1F170-1F171, U+1F17E-1F17F, U+1F18E, U+1F191-1F19A, U+1F1E6-1F1FF, U+1F201-1F202, U+1F21A, U+1F22F, U+1F232-1F23A, U+1F250-1F251, U+1F300-1F321, U+1F324-1F393, U+1F396-1F397, U+1F399-1F39B, U+1F39E-1F3F0, U+1F3F3-1F3F5, U+1F3F7-1F4FD, U+1F4FF-1F53D, U+1F549-1F54E, U+1F550-1F567, U+1F56F-1F570, U+1F573-1F57A, U+1F587, U+1F58A-1F58D, U+1F590, U+1F595-1F596, U+1F5A4-1F5A5, U+1F5A8, U+1F5B1-1F5B2, U+1F5BC, U+1F5C2-1F5C4, U+1F5D1-1F5D3, U+1F5DC-1F5DE, U+1F5E1, U+1F5E3, U+1F5E8, U+1F5EF, U+1F5F3, U+1F5FA-1F64F, U+1F680-1F6C5, U+1F6CB-1F6D2, U+1F6E0-1F6E5, U+1F6E9, U+1F6EB-1F6EC, U+1F6F0, U+1F6F3-1F6F6, U+1F910-1F91E, U+1F920-1F927, U+1F930, U+1F933-1F93A, U+1F93C-1F93E, U+1F940-1F945, U+1F947-1F94B, U+1F950-1F95E, U+1F980-1F991, U+1F9C0;
}

font-versioned.css:
@font-face {
  font-family: 'EmojiOneColor-9';
  font-style: normal;
  font-weight: 400;
  src: local('EmojiOneColor'), local('EmojiOne Color'), url(emojione-svg.woff);
  unicode-range: U+1F57A, U+1F5A4, U+1F6D1-1F6D2, U+1F6F4-1F6F6, U+1F919-1F91E, U+1F920-1F927, U+1F930, U+1F933-1F93A, U+1F93C-1F93E, U+1F940-1F945, U+1F947-1F94B, U+1F950-1F95E, U+1F985-1F991, U+1F57A, U+1F5A4, U+1F6D1-1F6D2, U+1F6F4-1F6F6, U+1F919-1F91E, U+1F920-1F927, U+1F930, U+1F933-1F93A, U+1F93C-1F93E, U+1F940-1F945, U+1F947-1F94B, U+1F950-1F95E, U+1F985-1F991, U+1F57A, U+1F919-1F91C, U+1F91E, U+1F926, U+1F930, U+1F933-1F939, U+1F93D-1F93E;
}

This has the benefit that if chrome natively has color emojis, it will only load the Unicode 9 characters. The loaded ones will be black and white because of limitations in chrome. On other systems with black and white native emoji it loads the whole emoji font. unicode-range on that version still makes sure the font is only loaded if emoji exist on the page (Brief tofu is possible on first load).


text:
Q: In Excel ,When some text entered in Cell B1 then =ROW() function should fire in A1 I want the function =row() to fire automatically in cell A1 when some text is entered in cell B1.
Can this be achieved using IF statement in excel cell.
I want this to be done without using vba script.
please help.

A: In cell A1
=IF(B1<>"",ROW(),"")


text:
Q: Regex for index of string match spanning across several XML tags I'm trying to insert a link in TLF. Normally you would simply simply use
var linkElement:LinkElement = textArea.textFlow.interactionManager.applyLink( ... );

The problem is that, if I create a link which spans across differently formatted text (bold, italic, etc), or heaven forbid across paragraphs and list items, it completely and utterly crashes and burns. Link formatting is completely lost, and list structures collapse.
Simply adding a LinkElement via addChild() doesn't work either, if we're going to keep both the formatting and the structure within the selected text.
Ripping out the textFlow for the selection with interactionManager.cutTextScrap(...), wrapping it in a LinkElement with interactionManager.applyLink( ... ), and then "pasting" back in... also creates a mess.
So I have to create my own link insertion routine.
What I've resolved to do is to:
1) convert the textflow tags to a string
2) find the start and end indexes of the selection within the textflow string
3) insert the following string at the start index:

4) insert the following string at the end index:

5) reconvert the textflow string into a textflow object for the TextArea
And voila! Instant RTF link!
The only problem is... I have no idea how to write a regex parsing equation which can find the start and ending indexes for a string match inside XML markup where the result may be spread across several tags.
For instance, if the TextFlow is (abbreviated):
<TextFlow>
Lorem Ipsum do
lor sit amet, consectetur adipiscing elit.

</TextFlow>

Say, for instance, the user has selected "Ipsum dolor sit amet" to be converted into a link. I need to find the first and last indexes of "Ipsum dolor sit amet" within that RTF markup, and then insert the strings indicated in 3) & 4) above, so that the end result looks like this:
<TextFlow>
Lorem
Ipsum dolor sit am
et, consectetur adipiscing elit.

</TextFlow>

You might lose some style formatting, but I can fix that later parsing through the textflow formatting.
What I need is the regex to do step 2).
I know the regex to ignore tags and strip out the text between tags, and how to find a string match of the selected text in the stripped textflow text... but not how to find the match indexes within the original (unstripped) textflow string.
Anyone?

A: IMHO better way is to go through out the string instead of trying to go with regex.
Here is an idea for quick dirty way, this code need to be improved, but anyway it might give directions.
So main goal might be just "throw out" tags and match text, but counting gow many chars passed within the process.
//This code might need revision for not to get < and > symbols as fake tags starting and finishing points, also reseting searchwhen text not completly done.

var sourceStr:String = '<TextFlow>
Lorem Ipsum dolor sit amet, consectetur adipiscing elit.
</TextFlow>';
var searchStr:String = "Lorem Ipsum d";
var indexes:Object = firstLast(sourceStr, searchStr);

trace(indexes.startIndex,indexes.finishIndex);

function firstLast(sourceStr:String, searchStr:String):Object
{
    var indexCounter:int = -1;

    var searchFlag:Boolean = true;
    var searchPos:int = 0;

    var searchChar:String;
    var sourceChar:String;

    var startIndex:int;
    var finishIndex:int;

    for (var i:int = 0; i < sourceStr.length; i++ )
    {
        indexCounter++;

        sourceChar = sourceStr.substr(i, 1);
        if (sourceChar == "<")
        {
            searchFlag = false;

        }
        else if (sourceChar == ">")
        {
            searchFlag = true;
        }

        if (!searchFlag)
        {
            continue;
        }

        searchChar = searchStr.substr(searchPos, 1);
        if (sourceChar == searchChar)
        {
            if (searchPos == 0)
            {
                startIndex = indexCounter;
            }
            if (searchPos == searchStr.length - 1)
            {
                finishIndex = indexCounter;
            }
            searchPos++;
        }

    }

    return { startIndex:startIndex, finishIndex:finishIndex };

}


text:
Q: Lagrange Multipliers- Two constraints (Minimum) I am given the following: extermum $f(x,y,z)=xyz$ s.t $x+y=z$ , $x+y=1-z$ .
I found that the only possible point is $(\frac{1}{4},\frac{1}{4}, \frac{1}{2} ) $ and its value is $\frac{1}{32}$ .
I guess this value is a minimum , but can't find a rigorous proof for this (the two constraints don't bound a compact set , so I can't deduce anything).
Will you please help me find a formal proof for the fact that this point is a minimum?
Thanks in advance

A: This value ($\frac{1}{32})$ is actually the global maximum. There is no global minimum. Try some other values that satisfy the constraints to see that they all correspond to f values less than $\frac{1}{32}$. For example, try $(x,y,z)=(\frac{1}{8},\frac{3}{8},\frac{1}{2})$.
Note: My response assumes you've done the work to show that $(\frac{1}{4},\frac{1}{4},\frac{1}{2})$ is either a global max or min as I gathered you had done based on the statement of the problem.

A: Do you need Langrange multipliers?
From the two constraints it's easy to show $z = \frac{1}{2}$, and $y = \frac{1}{2} - x$.
Substituting into $f$ we get, $$\frac{1}{32}(1 - (4x - 1)^2).$$
This is clearly $\textbf{maximized}$ at $x = \frac{1}{4}$, which
corresponds to $\left(\frac{1}{4},\frac{1}{4},\frac{1}{2}\right)$.

A: Doing Lagrange's Multipliers
Define:
$$H(x,y,z,\lambda,\mu):=xyz-\lambda(x+y-z)-\mu(x+y+z-1)$$
and now, as we know, the partial derivatives:
$$\begin{align*}H'_x&=yz-\lambda-\mu=0&\iff& \lambda+\mu&=yz\\
H_y'&=xz-\lambda-\mu=0&\iff&\lambda+\mu&=xz\\
H_z'&=xy+\lambda-\mu=0&\iff& -\lambda+\mu&=xy\\
H_\lambda'&=-(x+y-z)=0&\iff&x+y&=z\\
H_\mu'&=-(x+y+z-1)=0&\iff&x+y+z&=1\end{align*}$$
As it is clear that $\;xyz\neq 0\;$ ,from the first two equations above we get $\;x=y\;$ , and then the fourth and the fifth give us
$$z=2x=1-2x\implies x=\frac14$$
and from here we get the point you got


text:
Q: Replace all instances of one value with NAs in a numeric vector I have a numeric vector of values between 1 and 7 (called in the hypothetical example below "Numeric").
How would I create a new variable ("Numericnomid" which contains the same numeric information but where all values of 4 in "Numeric" are now valued as NA? I know this might seem like silly code (I'm learning!) But I tried:
Numericnommid<-[Numeric==4] <- NA

But this just makes my new vector one with just one value - NA!

A: This should work

Numericnomid <- Numeric
Numericnomid[Numericnomid==4] <- NA

A: Here is one liner
Numericnomid <- ifelse(Numeric==4, NA, Numeric)


text:
Q: Webservice SOAPUI Peticion XML Tengo un soapUI de ejemplo con la peticiónxml CDATA:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:webservice">
   <soapenv:Header/>
      <soapenv:Body>
        <urn:Notificacion>
         <as_xml_peticion><![CDATA[<PETICION> </<PETICION>]]<cabecera></cabecera>
         </as_xml_peticion> [...]

He creado a partir del wsdl, un cliente webservice de axis2-1.7.9 ADB, generado manualmente con lo s comandos  y he generado el cliente webservice en JAVA, y al llamar al webservice STUB, creando los objetos el parametro as_xml_peticion me lo genera como un string, ya que es un parametro de texto, pero cuando genero un xml igual que la peticion, y lo agrego en el string, el servidor me pone Connection has been shutdown: javax.net.ssl.SSLException: java.net.SocketException: Connection reset, parece que no coge bien la peticion
Alguien me puede ayudar?

He probado de agergar al string de xml el CDATA y tampoco


text:
Q: Fixing: "There are no devices registered in your account" without a Lightning cable Xcode 11.0 Using Xcode, when I try to sign my app, I get an error that says:
Failed to create provision profile
There are no devices registered in your account on the developer website. Plug in and select a device
to have Xcode register it

However, I do have my Mac registered on the website, which isn't showing up for some reason in Xcode. I don't have a USB-C lightning cable with me, which seems to be a direct requirement to connect my iPhone to my Mac.
Is there any way to solve this issue?
Edit: There is a secondary error that says that no profile was found for my bundle ID, but I'm pretty sure this stems from the previously mentioned one.

A:
I don't have a USB-C lightning cable with me, which seems to be a direct requirement to connect my iPhone to my Mac.
Is there any way to solve this issue?

You'd need to connect and pair your iPhone to your Mac at least once before you can perform wireless debugging.
If you do not have a USB-C to Lightning Cable cable, you'd need to either get one or use a USB-C to USB Adapter (like this) or a similar hub.
The iPhone (or any iOS device) needs to be connected physically to the Mac and you'd have to manually Trust the iOS device before it could be paired with Xcode. This security reason is why you'd need a cable to connect the iPhone in the first place, and there is no way to work around it wirelessly.

There is a secondary error that says that no profile was found for my bundle ID, but I'm pretty sure this stems from the previously mentioned one.

You can resolve this by going to Xcode Preferences → Accounts and add your Apple ID. If it is already added, you can try by removing and adding it again.


text:
Q: How to disable warnings about anonymous struct in clang? I want to use anonymous struct in my C++ program without this warning but keep -pedantic flag because I want to know if I'm using any other compiler-extension from Microsoft/GCC on clang. I know that  -Wno-gnu but it turn off more than I'm looking for, every gcc's extension supported. Is it possible?

A: -Wno-gnu-anonymous-struct should do the job.


text:
Q: How to update a large table from AJAX response? How can I update every cell of the following large table (10 rows X 30 columns) using AJAX?

    puts @table[0][0]
    puts @table[0][1]
    ... 27 columns go here
    puts @table[0][29]

  ... 8 rows go here

    puts @table[9][0]
    puts @table[9][1]
    ... 27 columns go here
    puts @table[9][29]

I was able to update the cell at row 0 and column 0 by giving it a specific id, as follows
    puts @table[0][0]

and using the following javascript, which is working fine
document.getElementById("r0c0").innerHTML = '<%= @new_r0c0_value %>'

but since the table is very large (300 cells) I'm looking for an idea how to update the 300 cells from an array of values without identifying each table's cell with a specific id.
Anyone has a smart idea how to pass an array in the AJAX response and how to update this large table using that AJAX response?

A: If you put an id on the table tag itself, you can get all cells in the table into an array like this:
document.getElementById('myTable').getElementsByTagName('td');

You will then have an array of all the td elements in the table which you can loop through and update.
In some browsers, it may perform better to just remove the entire table and construct a new one with the new data in it rather than individually changing all the cells.  The issue is that since tables can have dynamic layout, the browser may not be very efficient about relaying out the table each time you change a cell.

A: Try this..
If you can construct an array like this
[[1,2,..27],[1,2,..27],..[1,2,..27]]
then it is easy to load the data into that table without using ID or anything else.

        <% arr.each do |inner_arr| %>

                <% inner_arr.each do |val| %>
                        <%= val %>
                <% end %>

        <% end %>

A: You can use the :nth-child selector if using JQuery. I am doing it this way to highlight the currently updated record in the table listing with Ajax.
I have @assets which is the collection of all the objects, and @asset is the current record which is updated. The _assets.html.erb partial with the table looks like this:
<% @assets.each_with_index do |asset, index| %>

     <%= link_to index + 1, asset, :remote => true, :onclick => "$('#spinner').show()" %>

      <%= link_to asset.try(:patient).try(:display_name), asset, :remote => true,
        :onclick => "$('#spinner').show()" %>

    ...

<% end %>

and do this in update.js.erb:
...
$("#assets").html("<%= escape_javascript( render "assets" ) %>");

$("table.listing > tbody tr:nth-child(<%= @assets.index(@asset) + 1 %>)").effect("highlight", {}, 3000);
...

Selecting the nth-child with the index and highlight.


text:
Q: How to change some part of address with javascript and navigate to that address? For example, if I what to change -
www.site.com/img-small-1.jpg

to
www.site.com/img-large-1.jpg

How can i do this using javascript?

A: You can use replace to change the address,
var currentAddress = "www.site.com/img-small-1.jpg";
var newAddress = currentAddress.replace("img-small-1.jpg", "img-large-1.jpg");
window.location.href = newAddress; // this will redirect to new address


text:
Q: Spring Boot Security: security.basic.path What is the purpose of having
security.basic.path=/any-secured-path/**

this setting in application.properties?
It seems that Basic Auth is not kicking in automatically accessing this url (or suburls).

A: The security.basic.path starts after context path. So no matter what the context path is, just set the protected path after that. For example, the full url is /mycontextpath/pathA/pathB, if you want to have /pathB to be protected, just set security.basic.path=/pathA/pathB. If context path is / only, you should still set security.basic.path=/pathA/pathB.


text:
Q: How can I assign a multiple-field-function result on PostgreSQL updates I'm looking for an optimized method in PostgreSQL to do that:
update table1
set (a,b)=(somecomplexfunction(table1.something),2*somecomplexfunction(table1.something))
where ...

this calculates somecomplexfunction(table1.something) twice, I'd like to do something like that:
update table1 set (a,b)=somecomplexvectorfunction(table1.something) where ...

but update syntax does not support multiple field functions. Any ideas?

A: update table1
set
    a = somecomplexfunction(table1.something),
    b = a * 2
where ...


text:
Q: Weird response when clicking the upper left corner of the Search Highlights button next to the Search box When clicking on the upper left corner of the Search Highlights button next to the Search box, it behaves differently than when I click the rest of the button. When clicking the rest of the button, nothing happens, because I have disabled Search highlights. When I click on the upper left clouds, the desktop dims/blurs and a round circle (the loading sign) appears and it goes round and round, but nothing is happening. After pressing Esc or Alt+F4, it returns to normal.
Anybody knows what this is?


text:
Q: Argument for electric field inside spherical shell If I have a conducting spherical shell of outer radius $R$ and inner radius $r$, the electric field inside is $0$. The argument commonly given is:
Pick a point $P$ inside the shell (i.e. radius < $r$) and draw a sphere such that $P$ lies on its boundary. Then the charge contained by this sphere is $0$, so the electric through it is $0$ by Gauss' Law, and so the electric field at this point must be $0$.
Isn't this argument faulty? By this logic, I can pick any point anywhere in space (even outside the charged spherical shell), and draw SOME sphere which passes through it but doesn't intersect with the charged shell, and argue that since the flux through this other sphere is $0$, the electric field at this point (which is outside our charged shell) is $0$, which isn't the case? What am I missing?

A: For Gauss' law to be applied straightforwardly, your point of interest must lie on an equipotential surface with some symmetry. For the case of the point inside the sphere, it is easy to visualize a Gaussian sphere with radius $r<R$ with said point on its boundary. The charge contained inside the Gaussian sphere would be zero -- the flux through the Gaussian sphere would be zero. You can then argue that, since the field lines should be normal to this Gaussian sphere, the flux $\phi_E = 4 \pi r^2 \textbf{E} \cdot \hat{r} = 0$ implies $\textbf{E} = 0$ inside.
It's quite different outside the charged sphere, however. If you try to hypothesize a similar Gaussian surface, you'll fail, because the electric field due to the charged sphere varies with position, and no Gaussian sphere would be normal to the field lines, unless you envelop the charged sphere completely (which would amount to computing the field at $r>R$.) The summary is that you cannot equate the flux to zero and infer the field is zero as well, like in the previous case. The net flux would be zero, sure, but that would involve a complicated mess of integrals and dot products with the radial vector and the normal vectors of our Gaussian surface.
Perhaps it is more illuminating to look at what is actually happening to the spherical shell, which we'll assume is perfectly conducting. In the absence of an external electric field, the free charges in the shell will align themselves such that the net electric field in the shell is zero; otherwise, they will simply move around until that occurs. On the other hand, if the shell is placed in an external field $\textbf{E}_\text{ext},$ this will prompt the free charges in the shell to reorient themselves such that the induced field $\textbf{E}_\text{ind}$ cancels out the external field perfectly everywhere inside the shell: $$\textbf{E}_\text{ext} + \textbf{E}_\text{ind} = 0$$
I hope this clears your doubt.

A: If the shell is charged and your gausian surface enclosed that shell hence electric field at this point is not 0.

A: Gauss law can help you find the field only when the surface is symmetrical about the point charge.
Taking a sphere around that point in the cavity with the centre of the sphere being the centre of the shell, you get a sphere that is symmetric wrt every charge in the spherical shell.
Hence you can use gauss law here to find field.
Taking any random outer sphere,flux through it is 0, yes.
However writing it directly as E×surface area of sphere is faulty, as E is variable with every point. So it involves more complex math and obviously would not come out to be 0.


text:
Q: launchd plist with large StartInterval never runs I'm trying to run a command once per day like so:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>local.borgmatic</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/borgmatic</string>
        <string>--syslog-verbosity</string>
        <string>1</string>
    </array>
    <key>EnvironmentVariables</key>
    <dict>
        <key>HOME</key>
        <string>/Users/mike</string>
    </dict>
    <key>StartInterval</key>
    <integer>86400</integer>
</dict>
</plist>

The problem is this job never seems to run on its own. If it was just failing, I'd expect to see an error message from launchd in system.log, but I don't see anything, even after leaving my computer running for several days with hibernation disabled. The job shows up in launchctl list and runs fine when I start it manually via launchctl start. It also runs automatically when I reduce StartInterval to something smaller, like 10. Does StartInterval have some undocumented maximum?
Incidentally, this looks like the same problem reported at OS X launchd.plist.

A: Can you try placing the following in your launchd file.
<key>RunAtLoad</key>
<true/>

See how that works after you start up as well.