text:
Q: Android emulator status bar rendering messed up after Mac crash I was adding a Google Pixel 3 XL emulator to the list of my Virtual Devices in Android Studio. During the boot my MacOS froze and I had to hard reset. After restarting I booted the emulators and all of them seem to have some rendering issues with the status bar. One also crashed on startup with some OpenGL error. I tried deleting and recreating them with no success.

On the left is a Nexus 5 device with a status bar that seems to have double height. On the right is the Google Pixel 3 XL with some weird transparency and some microchips visible on the right side of the notch.
I am looking for a way to fix this without getting into full Android Studio/SDK cleanup. Even if I did that I'm not sure that would help.

A: I solved it by updating Android Studio to 3.6.1 and not importing previous settings (this step may not be needed). I then re-created the AVD (this may not be needed either).

A: For anyone still looking for a fix:

*

*download this image

*Locate the image assets folder for the Pixel 3 XL emulator (.\Android\sdk\skins\pixel_3_xl)

*Replace round_corners.webp with the image you downloaded.

I found the solution and a short explanation of the issue HERE.


text:
Q: Understanding C++ std::shared_ptr I have a question, please go through the following simple C++ program,
int main( )
{
 shared_ptr<int> sptr1( new int );
 shared_ptr<int> sptr2 = sptr1;
 shared_ptr<int> sptr3;
 shared_ptr<int> sptr4;
 sptr3 = sptr2;

 cout<<sptr1.use_count()<<endl;
 cout<<sptr2.use_count()<<endl;
 cout<<sptr3.use_count()<<endl;

 sptr4 = sptr2;

 cout<<sptr1.use_count()<<endl;
 cout<<sptr2.use_count()<<endl;
 cout<<sptr3.use_count()<<endl;

 return 0;
}

Output:
3
3
3
4
4
4

How does sptr1 and sptr3 objects know reference count is incremented as it prints 4.
As far as I know reference count is a variable in each shared_ptr object.

A:
As far as i know reference count is a variable in each shared_ptr object.

No, the reference count is stored in a "control block" on the heap. Every shared_ptr instance points to the same "control block" and keeps it alive (until all instances and all weak_ptr instances that share ownership with them are dead).

A: A shared_ptr<T> is usually implemented as two pointers.  One to the object data, and one to a structure that looks like this:
[strong reference count]
[weak reference count]
[type-erased destroyer fptr]
[type-erased destroyer data]

where the [object ptr] points to the actual object.
When you copy a shared_ptr, it creates another pointer to the above data (and to the actual object) and increments the [strong reference count] part of it.  Weak pointers behave similarly, but instead increase the [weak reference count] (when strong is 0 and weak is non-zero- the type-erased destroyer is called but the control block remains).
As an aside, when you call make_shared it does:
[strong reference count]
[weak reference count]
[type-erased destroyer fptr]
[object data]

where the pointer-to-object now points to the to the [object data] at the end of the control block.  This reduces the number of allocations to one.
A separate data and control block pointer is needed because of features like the fact that a shared_ptr to derived can be changed to a shared_ptr to base; that requires an adjustment to the pointer value in many cases.  Similarly, the aliasing constructor of shared ptr allows the control block and the pointed to object to be completely unrelated.
Taken from @Estinox's answer-that-isn't-an-answer, here is a Channel9 talk on how shared ptr works.

redpajama_set_name: RedPajamaStackExchange


text:
Q: why opening a port is so difficult in ubuntu? I have searched around and I have run these commands
iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 5432 -j ACCEPT
iptables-save > /etc/iptables.rules

And I rebooted the box. I had no luck.
What am I missing? IS there a universal way to do this thing in ubuntu? I remember in fedora I just need to edit  a text file and make it happen.
Thanks
UPDATE
I have run
ufw allow 5432

and I ran
 ufw status

I got this result
Status: active

To                         Action      From
--                         ------      ----
5432/tcp                   ALLOW       Anywhere
80                         ALLOW       Anywhere
22                         ALLOW       Anywhere
5432                       ALLOW       Anywhere
5432/tcp                   ALLOW       Anywhere (v6)
80                         ALLOW       Anywhere (v6)
22                         ALLOW       Anywhere (v6)
5432                       ALLOW       Anywhere (v6)

I still cannot access 5432!

A: You'll want to read up on UFW - Uncomplicated Firewall


text:
Q: Where should the files go in a SharePoint solution? Our SharePoint solution has recently been upgraded to SharePoint 2010, and we are taking a look at how we package and deploy the site to see if there are better ways to do things.
We currently package all files needed for our site (dll's, images, svc files, xap files, js files, css files, masterpages, html files, aspx files) and deploy them to 14/template/features/OurFeature/
I've been doing a lot of reading about SharePoint Developer Tools in Microsoft Visual Studio 2010, and I would like to use this to package/deploy our solution.  It seems Visual Studio allows for mapped folders to SharePoint's images and layouts directories, and also allows other mapped folders.  I'm wondering if there are standard locations for any of the other file types that I have mentioned above, or is our current method of storing things in the template/features folder a good idea?  We currently map things to this folder in IIS, so ~/images/ points to our site's images and so forth.
Can someone point me to best practices for SharePoint site file organization?  Are there benefits to doing things one way versus another?

A: *

*Images should go in 14\TEMPLATE\IMAGES or an Image Library (I usually use an image library so images can be changed without forcing a deployment).

*Client Libraries (.xap files, .js files, etc.) should go in 14\TEMPLATE\LAYOUTS\ClientBin

*.dll files should get sent to the GAC or the BIN directory for the web application running the assembly

*.css files can live in a document library, ClientBin, a custom folder under 14\TEMPLATE\Layouts, or 14\TEMPLATE\LAYOUTS\STYLES  (I usually put these in a style library so they can be changed if needed without having to re-deploy the whole solution.)

*.svc files should go in 14\ISAPI.  These are accessed under the /_vti_bin/ path.

*Features go in 14\TEMPLATE\FEATURES

A: In addition to what Kyle said, if you put files in the hive (14), say in Images, Layouts, Styles, it is normally good practice to add a directory (shortened namespace) to avoid name clashes.


text:
Q: MSAcpi_ThermalZoneTemperature class not showing actual temperature i want to fetch CPU Performance data in real time including temperature. i used the following code to get CPU Temperature:
try
        {
            ManagementObjectSearcher searcher =
                new ManagementObjectSearcher("root\\WMI",
                "SELECT * FROM MSAcpi_ThermalZoneTemperature");

            foreach (ManagementObject queryObj in searcher.Get())
            {
                double temp = Convert.ToDouble(queryObj["CurrentTemperature"].ToString());
                double temp_critical = Convert.ToDouble(queryObj["CriticalTripPoint"].ToString());
                double temp_cel = (temp/10 - 273.15);
                double temp_critical_cel = temp_critical / 10 - 273.15;
                lblCurrentTemp.Text = temp_cel.ToString();
                lblCriticalTemp.Text = temp_critical_cel.ToString();
            }
        }
        catch (ManagementException e)
        {
            MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
        }

but this code shows the temperature that is not the correct temperature. It ususally shows 49.5-50.5 degrees centigrade. But I used "OpenHardwareMonitor" that report CPU temperature over 71 degree centigrade and changing fractions along with time fractions. is there anything I am missing in the code?
I used the above code in    timer_click event for every 500ms interval to refresh the temperature reading but it's always showing the same temperature from the beginning of execution. That implies if you run this application and if it shows 49 degree then after 1 hour session, it'll constantly show 49 degree. Where is the problem?

A: In https://web.archive.org/web/20150911113852/http://www.scriptinternals.com/new/us/support/Internal/WMI_MSAcpi_ThermalZoneTemperature.htm I've found that CurrentTemperature returns temperature at some thermal zone which is somewhere on motherboard. That means it returns not CPU temperature.
It would be the same as temperature in the kitchen is 30C but stove is 200C or so...
This way cannot show exact temperature of CPU. To get the exact temperature of CPU (and every core) you need to write kernel drivers, what is much more complicated.
All-in-all your code does that it should do, for taking temperature you need to use some other way.


text:
Q: equivariant Steenrod algebra From Hu-Kriz "Real-oriented homotopy theory and an analogue of the Adams-Novikov spectral sequence" we know about calculation of $C_2$ - equivariant Steenrod algebra.
Where can I find (if it exists) information about $(C_2)^k$-equivariant version, $k\ge 2$? I guess $k=2$ would be good enough.


text:
Q: PHP: I have a string that has a mathematical operation in it. How do I run it? (Please note, it's been user entered, so I cannot hard code it). Anyways, the user enters math.php?do=2+2 and the script will kick back 4 as a result. Another thing is that the input is rigorously verified, so, there is no malicious possibility. My testing method is this
function testMath($char){
    $array['math'] = Array("+", "-", "/", "*", "(", ")", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
    foreach($char as $chr){
        if(!in_array($chr, $array['math'){
            return false;
        }
    }
    return true;
}

Would it be safe to eval() something checked by this? or should I forget about doing math from user-entered input?
Side note, PHP throws
Parse error: parse error in C:\Users\Josh\Desktop\App\html\new.php(24) : eval()'d code on line 1

When I try to eval() something. What's wrong?

A: I'm not sure how you used the eval() since you didn't post that part of your code. But if you are going to eval the code, you need to specify the variable it will be saved to:
Revised testMath:
function testMath($char){
    if(strlen($char) > 10) return false;
    $array['math'] = Array("+", "-", "/", "*", "(", ")", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
    foreach($char as $chr){
        if(!in_array($chr, $array['math'){
            return false;
        }
    }
    return true;
}

$math = $_GET['do'];
if(testMath($math)) eval("$result = " . $math . ";");

echo $math, ' = ', $result;


text:
Q: Is there a single variable I can use in mod_rewrite that is equivalent to %{DOCUMENT_ROOT}%{REQUEST_FILENAME}? I am using mod_rewrite in the httpd.conf file (not in a .htaccess file) and I was wondering if there was a variable I could use that represents the entire request; ie DOCUMENT_ROOT represents the "path/to/htdocs" and REQUEST_FILENAME represents the "/path/to/file.php". Is there a single Apache variable that represents both of these together, like "path/to/htdocs/path/to/file.php" ?
The reason I'm asking is that in my rewrite directives, this doesn't work:
RewriteCond %{REQUEST_FILENAME} -f

but this does:
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -f

the weird thing is, all of the tutorials I've seen use the first format, but that didn't work for me and I came up with the second format on my own-- and I've never seen the second format being used in any tutorials. Does it have to do with the fact that I'm writing in httpd.conf instead of a .htaccess document?
When I output the %{REQUEST_FILENAME} variable, it does not include the document root.

A: %{DOCUMENT_ROOT} is not website.com, it's the local path on the filesystem that is associated with the site's DocumentRoot directive. For example: /var/www/localhost/htdocs
If you want website.com, then you either want %{SERVER_NAME} (defined by the UserCanonicalName directive) or %{HTTP_HOST} which is defined by the Host: request header.
Additionally, %{REQUEST_FILENAME} includes the document root, it's more or less the equivalent of: %{DOCUMENT_ROOT}%{REQUEST_URI}. So given the above example of the document root, and a request URI of /images/title.png, then the %{REQUEST_FILENAME} would be /var/www/localhost/htdocs/images/title.png
If what you're looking for is: website.com/path/to/file.php, then, no. There's not a single variable that puts this together for you. You either want:
%{HTTP_HOST}%{REQUEST_URI}

or
%{SERVERNAME}%{REQUEST_URI}

A:
Does it have to do with the fact that I'm writing in httpd.conf instead of a .htaccess document?

Yes. From the Apache docs:

REQUEST_FILENAME
  The full local filesystem path to the file or script matching the request, if this has already been determined by the server at the time REQUEST_FILENAME is referenced. Otherwise, such as when used in virtual host context, the same value as REQUEST_URI.

And REQUEST_URI is the "path component of the requested URI, such as /index.html".

the weird thing is, all of the tutorials I've seen use the first format

Because most of the tutorials are written with respect to a .htaccess (or <Directory>) context.

If used in per-server context (i.e., before the request is mapped to the filesystem) SCRIPT_FILENAME and REQUEST_FILENAME cannot contain the full local filesystem path since the path is unknown at this stage of processing. Both variables will initially contain the value of REQUEST_URI in that case. In order to obtain the full local filesystem path of the request in per-server context, use an URL-based look-ahead %{LA-U:REQUEST_FILENAME} to determine the final value of REQUEST_FILENAME.


text:
Q: How do I compare attribute to a lower case value in dynamodb table -> Item -> attribute in query runtime I want to search text string in attribute like we do in mysql  LOWER(fieldName) = LIKE% strtolower(search_text)% . I did some r n d but not found any solution.
{
    "TableName": "DEV_postTbl",
    "ProjectionExpression": "postId, postType, postStatus",
    "ScanIndexForward": false,
    "Limit": 6,
    "KeyConditionExpression": "postStatus =:postStatusPublished",
    "IndexName": "postStatus-createdOn-index",
    "FilterExpression": " (  contains( postTitle, :searchText)  OR  contains(postDescription, :searchText) OR contains(postLocation.addressLine, :searchText) ) ",
    "ExpressionAttributeValues": {
        ":searchText": "hello",
        ":postStatusPublished": "published"
    }
}

This is my code.. but this search only  "hello"  instead of "Hello", "heLLO" like this

A:
DynamoDB is case sensitive. If your data is case insensitive, one solution is to lower case or upper case the data before storing it in DynamoDB. Then you can get around this by querying for all lower case or all upper case.

Example :
Store postTitle with lowerCase items.
When You search just lowerCase the :searchTex (str.toLowerCase()) and then query.


text:
Q: Showing image(coming from database) dynamically in crystal report using ImagePath C# I store image path in database like this: UploadedImage/FabricImage/11115.JPG.
I want to show them dynamically in a crystal report. Can anyone help me?

A: Use a conditional formula to dynamically change the location of a report's image.

*

*Add an image to the report: -> Insert -> PictureThis image will act as a placeholder.Ensure that the placeholder is the same size as the one that will be dynamically loaded, otherwise the image will be scaled.

*Change the image's Graphic Location:

*

*right click image

*select Format Graphic…

*select Picture tab

*click the conditional-formula button (looks like x+2)

*set the formula's text to the name of the formula or parameter field that will contain the image's URL

*save the formula and click the OK button

*Save the report

Source: cogniza.com


text:
Q: Cannot connect to local postgres database via pgAdmin4 (Mac) I have two databases running locally, I am able to connect to both via the psql command line, but when I attempt to connect to the second database, my unit test db, it throws a "Connection to server has been lost" error. I have no issues connecting to the development database via pgAdmin4.
Here is the console output:
$ psql
  psql (9.6.4)
  Type "help" for help.

admin=# \c development
You are now connected to database "development" as user "admin".
development=# \c test
You are now connected to database "test" as user "admin".
test=#


text:
Q: SSL Connection problem to web service from Java bean I have written an application that connects to a SSL web service (including client certificate) through jaxws. For this to work I have a wstrust.jks that contains trusted root certificate for ws, and client.p12 that is the client certificate to use when connecting to ws. I have then created a custom SSLSocketFactory to be able to use my wstrust.jks and client.12 during the connection to ws. I tell jaxws to use my implementation by:
[javax.xml.ws.BindingProvider].getRequestContext().put(JAXWSProperties.SSL_SOCKET_FACTORY, customSSLSocketFactory);
Everything works like a charm if i run it as a standalone java-application. However when i use the same technique inside a Java bean (JSF) deployed as a war-file running under Tomcat,
i get a "PKIX path building failed"-error.
BUT If i configure SSL through JAVA_OPTS when i start my Tomcat (through the -Djavax.net.ssl.* parameters) I get it to work.
So my question:
How do i (or is it possible) to get my custom-SSLSocketFactory-technique to work inside the Java bean?
I guess as tomcat wraps itself around my application, when running as a bean, it is working differently and my wish to use a custom SSLSocketFactory isnt respected...
Thanks for any input on this!
/Tobbe

A: Solved it. If anyone have the same issue here is how. Instead of setting my custom factory through:
[javax.xml.ws.BindingProvider].getRequestContext().put(JAXWSProperties.SSL_SOCKET_FACTORY, customSSLSocketFactory);
I had to set it through:
HttpsURLConnection.setDefaultSSLSocketFactory(customSSLSocketFactory);
otherwise it seems to get ignored.
/Tobbe


text:
Q: Vagrant provision order I try to install kubernetes with istio. Here is snippet from Vagrantfile(copied from github)
    config.vm.define "k8s-master" do |master|
        master.vm.box = IMAGE_NAME
        master.vm.network "private_network", ip: "192.168.50.10"
        master.vm.hostname = "k8s-master"
        master.vm.provision "ansible" do |ansible|
            ansible.playbook = "kubernetes-setup/master-playbook.yml"
        end
    end

    (1..N).each do |i|
      config.vm.define "node-#{i}" do |node|
        node.vm.box = IMAGE_NAME
        node.vm.network "private_network", ip: "192.168.50.#{i + 10}"
        node.vm.hostname = "node-#{i}"
        node.vm.provision "ansible" do |ansible|
          ansible.playbook = "kubernetes-setup/node-playbook.yml"
        end
      end
    end

If I put installation of istio into k8s-master playbook, it fails. I assume this happens because worker nodes are not installed yet, and istio can't provision its infrastructure. I need to run second playbook on k8s-master after provisioning workers. What is solution?


text:
Q: Recursive Coin Change Function Prints Correct Answer but Doesn't Return It With my function below, it prints the correct answer to the problem in the base case conditional, but it won't return it. My output prints from the base case in the function on the 1st line, then prints the returned value from the function on the second line.
If I return the value of the recursive call, then the base case isn't reached.

I see this output:

[1, 0, 0, 0, 1]
None

But I expect this output:

[1, 0, 0, 0, 1]
[1, 0, 0, 0, 1]
def changeslow(amounts, goal, coins = [], highest = 0, sum = 0, results = []):
    # Base case
    if sum == goal:
        result = []
        if highest == amounts[(len(amounts)-1)]:
            result = []
            for amount in amounts:
                count = coins.count(amount)
                result.append(count)
                count = count + 1
            print result
        return result

    # Recursive case
    for value in amounts:
        if value >= highest:
            copy = coins[:]
            copy.append(value)
            if sum + value <= goal:
                changeslow(amounts, goal, copy, value, sum + value, results)

amounts = [1, 5, 10, 25, 50]

print(changeslow(amounts, 51))


text:
Q: How to get vue-js-toggle-button change value I tried to get change status with Vue-js-toggle-button package:
<toggle-button
  @change="onToggleChange(slider.id)"
  :labels="{checked: 'Active', unchecked: 'Deactive'}"
  :width="70"
  :sync="true"
  :value="Boolean(slider.status)"/>

And I used a method to pass current slider.id:
 onToggleChange(id) {
     let value = event.target.value;
     console.log(value);
 },

I tried to get event with value but it's not working correctly.
I want to get both toggle button table row slider id and toggle button value using vue js. Any one can help?

A: Pass the event as argument (notice the addition of $event):
<toggle-button
  @change="onToggleChange(slider.id, $event)"

And use it like:
onToggleChange(id, event) {                // added event as second arg
  let value = event.value;                 // changed from event.target.value to event.value
  console.log(value);
},

Notice that event does not have target.
Demo:

Vue.use(window['vue-js-toggle-button'].default)

new Vue({
  el: '#app',
  data: {
    slider: {
      status: true
    }
  },
  methods: {
    onToggleChange(id, event) { // added event as second arg
      let value = event.value;  // changed from event.target.value to event.value
      console.log(value);
    },
  }
})
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/vue-js-toggle-button"></script>

<div id="app">
  <toggle-button
    @change="onToggleChange(slider.id, $event)"
    :labels="{checked: 'Active', unchecked: 'Deactive'}"
    :width="70"
    :sync="true"
    :value="Boolean(slider.status)"/>
</div>


text:
Q: Could use some help in probability question Two distinct numbers are selected simultaneously and at random from the set {1, 2, 3, 4, 5}. What is the probability that the smaller one divides the larger one? Express your answer as a common fraction.

A: There are $\binom{5}{2}=10$ choices of this pair. The ones that qualify are the four of the form $(1,\,n)$ and $(2,\,4)$, and the answer is $\frac12$.


text:
Q: Need a different module name when using Python's Sphinx automodule directive I have a file layout that looks like:
/my_module
    __init__.py
    submodule1.py
    submodule2.py

I use Sphinx's automodule directive like:
.. automodule:: my_module.submodule1

It produces documents that say my command name is something like: my_module.submodule1.my_function. But my __init__ pulls submodule1 into the my_module namespace. So what I really want is for the documentation to say my_module.my_function instead. Leave out the submodule1, since that's not what users are going to use.
Is there a way to do this?

A: Not exactly, but you can get close.  There is the ~ (tilde) in standard cross-referencing syntax.

If you prefix the content with ~, the link text will only be the last component of the target. For example,
:py:meth:`~Queue.Queue.get`

will refer to Queue.Queue.get but only display get as the link text. This does not work with all cross-reference roles, but is domain specific.

You might be able to use substitutions or the raw directive, but that would bypass the advantage of using autodoc and its directives.


text:
Q: That's a lot of 'pizza'! I've heard this expression on TV suggesting 'a lot/(too)big amount of something'.
It was from an experienced financial analyst (Bloomberg TV) who was referring to the big assets of a company. "There is a lot of pizza there". The guy who said that on TV was about 60. The part of the expression that I want to learn more about is the use of 'pizza' to refer to a big amount of something else.
Is it just an extension of the expression that's a lot?
Is it a common expression (AmE or BrE) or just a one-off saying I happened to hear?

A: Early Google Books sightings of 'that's a lot of pizza'
It is certainly possible that, as Hot Licks suggests in a comment above, the initial occasion for the expression "That's a lot of pizza!" was an advertising campaign by a U.S. pizza outlet. But in a Google Books search, the earliest instance of the expression is an advertisement for Data General's UNIX-based AViiON7000 computer system that appeared in various issues of CIO and Computerworld magazines from April through October of 1991. The headline of the advertisement reads as follows:

For the price of one AViiON7000 you can save $4,000,000 (now that's a lot of pizza!)

The ad may be playing on an earlier advertisement or tagline from a pizza parlor, but it probably also reflects the supposed centrality of pizza in the diets of early computer engineers and programmers: if you think of meals in terms of pizzas, it isn't a very big jump to thinking of cost savings in terms of pizza equivalents.
That pizza was widely (and semi-seriously) proclaimed to be the staff of life for computer professionals helps explain why pizza-box might have become a standard term for any piece of equipment used to raise the level of a computer monitor on a desk. For example, Eric Raymond, The New Hacker's Dictionary, third edition (1996) has these pizza-related terms:

pizza, ANSI standard {CMU} Pepperoni and mushroom pizza. Coined allegedly because most pizzas ordered by CMU hackers during some period leading up to mid-1990 were of that flavor.
...
rotary debugger n. {Commodore} Essential equipment for those late-night or early-morning debugging sessions. Mainly used as sustenance for the hacker. Comes in many decorator colors, such as Sausage, Pepperoni, and Garbage.

And from The Oxford Dictionary of Computing, sixth edition (2008):

pizza-box (2008) A piece of equipment, such as a computer system box, whose dimensions are roughly in the same proportions and size as the cardboard boxes used to transport pizzas, ... Such an enclosure can be conveniently placed beneath a monitor on a desk.

Instances of 'that's a lot of X' intended literally
Of course, the expression "that's a lot of X [or Xs]," where X is a mass noun (or Xs is  plural noun), goes back very far indeed in English. Here are a few newspaper examples. From "Caribbean Twelve Percents," in the [Chicago, Illinois] Farmer's Review (June 22, 1882):

"Will you lend me a hundred pounds?"
"Name of St. Iago, that is a lot of money," I answered.

And from "Louis Hanitch Talks of West Superior as a Wheat Shipping Point," in the Bismarck [North Dakota] Weekly Tribune (November 20, 1891):

But the wheat question is the foremost just now. A week ago last Monday 1,600 cars of wheat were received, the next day 1,200 cars, and it is averaging about 1,200 a day. That is a lot of wheat. North Dakota wheat is the best, and we want it, and it is only a question of time when we will get about all there is to get.

And likewise, from an advertisement for Emery, Bird & Thayer in the Kansas City [Missouri] Daily Journal (January 14, 1897):

A Mammoth Shirt Sale! 8,880 Shirts to Make Your Selection From.
Yes, that IS a lot of Shirts. But the makers of them wanted to clean up stock and made prices to us A HALF for part and part for about ONE-THIRD their market value.

Instances of 'that's a lot of X' intended figuratively
The big change introduced by expressions along the lines of "that's a lot of pizza" is that the expression is intended figuratively. Saved money isn't literally lots of pizza—but people understand it as being in some sense equivalent to lots of pizza. Thus, the implicit meaning of "that's a lot of pizza" in these instances is "that's the equivalent of a lot of pizza."
Figurative expressions of this type begin to show up in newspaper articles from the 1920s. For example, from "Dixon Bowlers Win Tilt from DeKalb Teams" in the DeKalb [Illinois] Daily Chronicle (January 13, 1927):

Peters was the star wood crasher [that is, bowler] of the Dixon outfit getting three games well over the 200 mark, and that is a lot of wood to crash in each game.

In other words, a score above 200 in a single game is equivalent to a lot of fallen bowling pins.
And from "Motordom Marches On!" in the [Des Moines, Iowa] Wallaces' Farmer & Iowa Homestead (November 21, 1936):

Total payrolls in automotive and allied plants rose from $216,000,000 for the 12 months ending August, 1933, to $627,000,000 for the corresponding period of 1936. Translated into farm language that is a lot of potatoes.

We can hardly doubt that a lot of potatoes in 1936 farm language is a lot of pizza (or a lot of double lattes, or a lot of Big Macs, or a lot of rides on the Cyclone) today.

A: I've never heard it in the UK. It might have been influenced by an advertising campaign such as this.


text:
Q: Separate a column in R data.df
colA

2 AD
3 KF
4 GH

I want to split this column into two columns
 colA  ColB
  2     AD
  3     KF
  4     GH

Here's my code:
library(dplyr)

X1 <- data.df

ca <- as.data.frame(X1) %>% separate(X1,col=colA, into = paste("colA","colB"))

Error: Values not split into 1 pieces at 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
What's wrong with my code?

A: When you pipe commands the first argument to each function will the data.frame, so try
library(tidyr)
dat %>% separate(colA, c("colA", "colB"))
#   colA colB
# 1    2   AD
# 2    3   KF
# 3    4   GH

Data
dat <- structure(list(colA = structure(1:3, .Label = c("2 AD", "3 KF",
"4 GH"), class = "factor")), .Names = "colA", row.names = c(NA,
-3L), class = "data.frame")

A: We could do this using read.table from base R.  If the 'colA' in the initial dataset is factor class, convert to character, and use read.table.  We can specify the column names with col.names argument.
read.table(text=as.character(dat$colA), sep='',
                      col.names=paste0('col', c('A', 'B')) )
#   colA colB
#1    2   AD
#2    3   KF
#3    4   GH

Another option is cSplit from splitstackshape.  We specify the column to be split in the splitCols and the sep.  The direction is 'wide' by default.
 library(splitstackshape)
 cSplit(dat, 'colA', ' ')

NOTE: "dat" from @nongkrong's post


text:
Q: How are gestures handled in C4Shape objects? I'm trying to extend C4 a bit, and am trying to figure out how gestures and animations work on C4Shape objects. I've looked through the source, and it looks like they are all based on CAShapeLayers, to which gesture recognizers cannot be directly attached. Could someone explain how this works in C4?

A: Right, all visible objects in C4 are based on a subclass CALayer. For instance, C4Shapes subclass C4ShapeLayers, whereas C4Movies subclass C4PlayerLayer (a subclass of AVPlayerLayer which is already a subclass of CALayer), and images are drawn as the content of a basic CALayer.
However, each one of these layers is contained within a subclass of UIControl (UIView) so that they can all individually register touches and to which they can all have gesture recognizers attached.
As an example, the hierarchy for a C4Shape is:

UIView > UIControl > C4Control (with a C4ShapeLayer as its main
  layer).

For a movie:

UIView > UIControl > C4Control (with an C4PlayerLayer as its main
  layer).

etc.
So, all visible objects have the following:

UIView > UIControl > C4Control

... with custom layers for the C4Control object.


text: Q: Can I downgrade ASP.NET Core project from version 5.0 to 3.1 I finished my ASP.NET Core MVC project on .NET Core 5.0. Can I downgrade this project from version 5.0 to 3.1? Could someone explain? Because I need it in that version.


text:
Q: form_for fields disables all javascript elements I have a rails 3.2 application.
On one page I have some javascript to show hide divs.
That works fine and dandy.
However when I add some fields it seems all javascript events are disabled, for the code that worked before.
I can make the events work again, if I remove the fields, but leave the form_for tag.
If I only remove for instance the text area, the events are still gone.
If I move the fields up directly under the form_for tag, it works again
One more hint I found, I have three RWD states, Desktop, Tablet and Phone.
On phone it works! But on the two other states, its does not work.
The form_for tag looks like this:
= form_for(@new_note, url: write_new_page_path) do |f|
and I add fields like this:
 = f.label :text, 'how are things today?', :class => 'module-helper'
 = f.text_area :text, placeholder: 'Please write a note here', rows: 5, class: 'required'

I did not expect the events to be gone, and I am sure its a rookie mistake.
You can find the entire code here:
https://gist.github.com/khebbie/a29917357552b809a1fe

A: Ok, so I finally found the answer:
It turned out that the elements were hiding under other elements.
That is why it worked in phone layout.


text:
Q: How can I make multiple div elements in another div element horizontally center? I want to make my div elements be centered in the same line. I want it to be done without using a fixed margin because that doesn't work as soon as you resize it or change screen resolution.
I've tried using "margin: 0 auto" but that didn't seem to work. I've also trid a couple of different things but they were honestly all just me kicking in the dark.
The HTML:

The CSS:
.box{
  text-align: center;
  width: 20%;
  border: 2px solid blue;
  margin: 1pt;
  float: left;}

.div3{
  text-align: center;}

.sredina{
  display: inline-block;
  margin: auto;
  border: 2px solid red;}

.container{
  width: 80%;
  margin: auto;
  overflow: hidden;
}

How it looks now:
An image of how it looks now
How I want it to look:
An image of how it should look

A: Try to use flex for your .sredina
https://codepen.io/anon/pen/zXbxym
.sredina{
  display: flex;
  justify-content: center;
  align-items: strentch;
  margin: auto;
  border: 2px solid red;
}

A: Use display: flex and justify-content: center on the the .sredina div within your container:
https://codepen.io/HappyHands31/pen/qwvEez

A: Try this,
<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

hello

hello

hello

it works well in all screen sizes. You must use
display: inline-block;

in the inner div class
then use
margin-left: auto;
margin-right: auto;
position: relative;
text-align:center;

in the outer div.
A similar answer is here


text:
Q: CSS order section I have this html:

Section 1 content

Section 2 content

Now, I want to make those sections into 2 columns but the last section should be shown on the left side and the first section should be shown on the right side.
Here is my css
@media only screen and (max-width: 767px) {

    .footer-address {
        display : flex;
    }

    .footer-address section {
        column-count : 2;
    }

    .footer-address section p {
        margin-bottom : 0;
    }
}

Now, it's on 2 columns but I want the last section should show on the left side instead of the right side.

A: you can set the flex-direction to row-reverse
.footer-address {
    display : flex;
    flex-direction: row-reverse;
}

A: Use flex-direction: row-reverse in .footer-address
Also keep in mind this is complete no sense in your case
.footer-address section {
   column-count : 2;
}

because column-count applies for every section, but you are willing to make each section inside .footer-address a separate column, not two separate section in each section

A: You can also use CSS grid to make your life a bit easier. Use display: grid; on your parent element and then you can give a grid template of two columns with grid-template-columns: repeat(2, 1fr);. Next, use grid-column: 2; on the second one to display it in the 2nd column

A: Using order, no need to explain that to work you need to have parent with display: flex :

 .footer-address section:first-child{
      order: 1;
    }
    .footer-address section:last-child{
      order: 2;
    }

@media only screen and (max-width: 767px) {

    .footer-address {
        display : flex;
    }

    .footer-address section {
        column-count : 2;
    }

    .footer-address section p {
        margin-bottom : 0;
    }
    .footer-address section:first-child{
      order: 2;
    }
    .footer-address section:last-child{
      order: 1;
    }

}

Section 1 content

Section 2 content


text:
Q: Python Debian Docker image can't update anymore Since yesterday evening (14NOV2020), I'm no longer able to update my container (python:3.9-buster)
$ winpty docker run -it python:3.9-buster //bin/bash
root@3a7825a70263:/# apt-get update
Err:1 http://deb.debian.org/debian buster InRelease
  403  Forbidden [IP: 146.112.61.110 80]
Err:2 http://security.debian.org/debian-security buster/updates InRelease
  403  Forbidden [IP: 146.112.61.110 80]
Err:3 http://deb.debian.org/debian buster-updates InRelease
  403  Forbidden [IP: 146.112.61.110 80]
Reading package lists... Done
N: See apt-secure(8) manpage for repository creation and user configuration details.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
E: The repository 'http://deb.debian.org/debian buster InRelease' is not signed.
E: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease  403  Forbidden [IP: 146.112.61.110 80]
E: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease  403  Forbidden [IP: 146.112.61.110 80]
E: The repository 'http://security.debian.org/debian-security buster/updates InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease  403  Forbidden [IP: 146.112.61.110 80]
E: The repository 'http://deb.debian.org/debian buster-updates InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

This is the content of the /etc/apt/sources.list file
root@3a7825a70263:/# cat /etc/apt/sources.list
# deb http://snapshot.debian.org/archive/debian/20201012T070000Z buster main
deb http://deb.debian.org/debian buster main
# deb http://snapshot.debian.org/archive/debian-security/20201012T070000Z buster/updates main
deb http://security.debian.org/debian-security buster/updates main
# deb http://snapshot.debian.org/archive/debian/20201012T070000Z buster-updates main
deb http://deb.debian.org/debian buster-updates main

Is there anything known about this issue?
EDIT 1:
As per @madzohan comment, I've tried to add [trusted=yes] in the /etc/apt/sources.list, but after that change I still can't update.
root@3a7825a70263:/# echo deb [trusted=yes] http://deb.debian.org/debian buster main | tee /etc/apt/sources.list
deb [trusted=yes] http://deb.debian.org/debian buster main
root@3a7825a70263:/# echo deb [trusted=yes] http://security.debian.org/debian-security buster/updates main | tee -a /etc/apt/sources.list
deb [trusted=yes] http://security.debian.org/debian-security buster/updates main
root@3a7825a70263:/# echo deb [trusted=yes] http://deb.debian.org/debian buster-updates main | tee -a /etc/apt/sources.list
deb [trusted=yes] http://deb.debian.org/debian buster-updates main

root@3a7825a70263:/# cat /etc/apt/sources.list
deb [trusted=yes] http://deb.debian.org/debian buster main
deb [trusted=yes] http://security.debian.org/debian-security buster/updates main
deb [trusted=yes] http://deb.debian.org/debian buster-updates main

root@3a7825a70263:/# apt-get update
Ign:1 http://security.debian.org/debian-security buster/updates InRelease
Ign:2 http://deb.debian.org/debian buster InRelease
Ign:3 http://deb.debian.org/debian buster-updates InRelease
Ign:4 http://security.debian.org/debian-security buster/updates Release
Ign:5 http://deb.debian.org/debian buster Release
Ign:6 http://security.debian.org/debian-security buster/updates/main amd64 Packages
Ign:7 http://deb.debian.org/debian buster-updates Release
Ign:8 http://security.debian.org/debian-security buster/updates/main all Packages
Ign:9 http://deb.debian.org/debian buster/main amd64 Packages
Ign:6 http://security.debian.org/debian-security buster/updates/main amd64 Packages
Ign:8 http://security.debian.org/debian-security buster/updates/main all Packages
Ign:10 http://deb.debian.org/debian buster/main all Packages
Ign:11 http://deb.debian.org/debian buster-updates/main amd64 Packages
Ign:6 http://security.debian.org/debian-security buster/updates/main amd64 Packages
Ign:12 http://deb.debian.org/debian buster-updates/main all Packages
Ign:8 http://security.debian.org/debian-security buster/updates/main all Packages
Ign:9 http://deb.debian.org/debian buster/main amd64 Packages
Ign:6 http://security.debian.org/debian-security buster/updates/main amd64 Packages
Ign:10 http://deb.debian.org/debian buster/main all Packages
Ign:8 http://security.debian.org/debian-security buster/updates/main all Packages
Ign:6 http://security.debian.org/debian-security buster/updates/main amd64 Packages
Ign:11 http://deb.debian.org/debian buster-updates/main amd64 Packages
Ign:12 http://deb.debian.org/debian buster-updates/main all Packages
Ign:8 http://security.debian.org/debian-security buster/updates/main all Packages
Ign:9 http://deb.debian.org/debian buster/main amd64 Packages
Ign:6 http://security.debian.org/debian-security buster/updates/main amd64 Packages
Ign:10 http://deb.debian.org/debian buster/main all Packages
Ign:8 http://security.debian.org/debian-security buster/updates/main all Packages
Ign:11 http://deb.debian.org/debian buster-updates/main amd64 Packages
Err:6 http://security.debian.org/debian-security buster/updates/main amd64 Packages
  403  Forbidden [IP: 146.112.61.110 80]
Ign:8 http://security.debian.org/debian-security buster/updates/main all Packages
Ign:12 http://deb.debian.org/debian buster-updates/main all Packages
Ign:9 http://deb.debian.org/debian buster/main amd64 Packages
Ign:10 http://deb.debian.org/debian buster/main all Packages
Ign:11 http://deb.debian.org/debian buster-updates/main amd64 Packages
Ign:12 http://deb.debian.org/debian buster-updates/main all Packages
Ign:9 http://deb.debian.org/debian buster/main amd64 Packages
Ign:10 http://deb.debian.org/debian buster/main all Packages
Ign:11 http://deb.debian.org/debian buster-updates/main amd64 Packages
Ign:12 http://deb.debian.org/debian buster-updates/main all Packages
Ign:9 http://deb.debian.org/debian buster/main amd64 Packages
Ign:10 http://deb.debian.org/debian buster/main all Packages
Ign:11 http://deb.debian.org/debian buster-updates/main amd64 Packages
Ign:12 http://deb.debian.org/debian buster-updates/main all Packages
Err:9 http://deb.debian.org/debian buster/main amd64 Packages
  403  Forbidden [IP: 146.112.61.110 80]
Ign:10 http://deb.debian.org/debian buster/main all Packages
Err:11 http://deb.debian.org/debian buster-updates/main amd64 Packages
  403  Forbidden [IP: 146.112.61.110 80]
Ign:12 http://deb.debian.org/debian buster-updates/main all Packages
Reading package lists... Done
E: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/main/binary-amd64/Packages  403  Forbidden [IP: 146.112.61.110 80]
E: Failed to fetch http://deb.debian.org/debian/dists/buster/main/binary-amd64/Packages  403  Forbidden [IP: 146.112.61.110 80]
E: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/main/binary-amd64/Packages  403  Forbidden [IP: 146.112.61.110 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.

EDIT 2:
As per some resources found on internet, I've tried to perform some pruning on docker, but after that change I still can't update:
docker image prune -f
docker system prune -f
docker container prune -f

EDIT 3:
The resolution was to wait ... :-/
Now if if try to update it, it works.
I guess someone at Debian forgot to push some files on http://deb.debian.org/debian and fixed it this afternoon (since some files seems to have been updated after 15NOV2020 14:00:00)
$ winpty docker run -it python:3.9-buster //bin/bash
root@6c0a161ec04b:/# apt-get update
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://deb.debian.org/debian buster InRelease [121 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [248 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7906 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [7856 B]
Fetched 8401 kB in 4s (2021 kB/s)
Reading package lists... Done
root@6c0a161ec04b:/#

A: This worked for me!
docker image prune -f
docker system prune -f
docker container prune -f


text:
Q: Stripe Checkout with React and Express Js I am trying to solve the following problem. On the Frontend I use React and installed the React-Stripe-Checkout package. I created a Checkout.js file which I am importing then into a FromContainer-
Here is the logic for Checkout.js
onToken(token) {
    fetch('/postajob', {
        method: 'POST',
        body: JSON.stringify(token),
    }).then(response => {
        response.json().then(data => {
            alert(`We are in business, ${data.email}`);
        });
    });
}
render() {
    return (
        <StripeCheckout
            name="Teacherjobs.io"
            description="Job Post on Teacherjobs.io"
            ComponentClass="div"
            panelLabel="Post Job"
            amount={1000}
            currency="USD"
            stripeKey="pk_test_vfjVQjaiduhHGt9OY3lUB1yz"
            locale="auto"
            email="contact@teacherjobs.io"
            zipCode={false}
            alipay={true}
            allowRememberMe
            token={this.onToken}
            reconfigureOnUpdate={false}
            triggerEvent="onClick">

            <button
                className="submitbtn"
                onClick={this.handleFormSubmit}
                type="submit"
                value="Submit">Submit
            </button>

        </StripeCheckout>
    )
}

In my FormContainer I import Checkout.js which is a submit button to save data. So by clicking the button you can save the information giving in the form (const formPayload).
handleFormSubmit(e) {
    e.preventDefault();

    const formPayload = {
        jobTitle: this.state.jobTitle,
        country: this.state.location,
        city: this.state.city,
        apply: this.state.apply,
        categories: this.state.categories,
        description: this.state.description

    };
    // post a job - logic coming from services
    jobsService.postJob(formPayload, (err, result) => {
        if(result) {
            console.log('job posted');
            console.log('here');
        } else {
            alert('Could not post a job');
        }
    });

Furthermore I have an Api based on Express router to handle the post requests
 router.route('/postajob')
    .post((req, res) => {
        console.log(req.body);
        JobList.insertOne(req.body, (err,  stat) => {
            if(err) {
                res.status(500).send({ msg: 'Job upload failed' });
            } else  {
                res.status(202).send({ msg: 'Job posted successfully' });
            }
        });
    });

And a Services folder for the postJob functionality in the FormContainer.
function postJob(jobInfo, callback) {
console.log(jobInfo);
fetch('/api/postajob', {
    method: 'POST',
    headers: {
        Accept: 'application/json',
        'Content-Type': 'application/json',
    },
    body: JSON.stringify(jobInfo)
})
    .then((response) => {
        response.json().then((data) => {
            console.log(data);
            if (response.ok) {
                callback(null, data);
            } else {
                callback({});
            }
        });
    })
    .catch((error) => {
        console.log(error);
    });

}
What do I have to change in this logic to let the customer save data, but only if fulfilled stripe checkout and paid for the service?

A: Your frontend only generates the token and all the necessary information for the payment. When the request reaches your backend, you would have to use your Stripe Secret Key (while you would use the Stripe Public Key in the frontend) to make another request to the Stripe API. If you need further guidance on this topic, this article describes the minimum steps it takes to setup React with Express and Stripe. It comes with an open source boilerplate project too.

A: It's important to know that Stripe Checkout does not create charges, it only creates card tokens. Your backend code at /postajob needs to read the token sent from the frontend and then attempt to create a charge, something like:
router.route('/postajob')
    .post((req, res) => {
        stripe.charges.create({
            amount: 2000,
            currency: "usd",
            source: req.token,
            description: "Charge for jenny.rosen@example.com"
        }, function(err, charge) {
            // asynchronously called, check if charge was created successfully
            // ...
            // Insert job, or return error to frontend
        });
    });

More on this here:
https://stripe.com/docs/api/node#create_charge
There's a full example of using Express + Checkout here:
https://stripe.com/docs/checkout/express

A: router.post('/stripe', requireAuth, async (req, res) => {
    const { token } = req.body
    const charge = await stripe.charges.create({
        amount: 10000,//100€
        currency: 'EUR',
        source: token.id, // obtained with Stripe.js in the frontend
    })

    console.log("charge", charge)
    //Aqui el cargo ya esta realizado con exito.
    //We return a confirmation so that the process continues in the frontend.
    res.send(charge)
})


text:
Q: Configure Serial port for ethernet I have an unmarked cable that adapts an rs232 serial port to an Ethernet jack. How do I configure my ubuntu 18.04 machine to work with it?

A:
I have an unmarked cable that adapts an rs232 serial port to an
  Ethernet jack.

Just use a proper Ethernet Cable to connect the Ethernet Jack to your Ubuntu Machine.
Ethernet is multiple twisted pairs and the capacitance between pairs matters. So Ethernet does not work over a Serial Cable.

A: I'm not sure I understand the description correctly, but what I guess is following.
The small cable is intended to be plugged into a serial port interface.
Its purpose is probably to allow using standard ethernet cables as a serial interface cable.
This allows you for example in an office where network cables are already placed in the floor to go have a serial cable go across a huge office without having to add new specific serial cables.
You cannot use a serial cable reliably for an ethernet connection.


text:
Q: Customizing WSO2 IS login I've implemented a working environment with Spring SAML (2 service providers) and WSO2 IS v5.2.  This question do not pertain to visual styling of the login page as I have completed this.  The login page is hosted from the WSO2 server and is delivered with the following redirect url:
https://server/authenticationendpoint/login.do?commonAuthCallerPath=
%2Fsamlsso&forceAuth=false&passiveAuth=false&tenantDomain=carbon.super
&sessionDataKey=e779c512-fdf6-4787-ae40-d6ccccc052ec&
relyingParty=urn%foo%bar%3Atampa&type=samlsso&
sp=mysp&isSaaSApp=false&authenticators=BasicAuthenticator:LOCAL

I would like to know if the framework on the wso2 side allows for adding additional query-string params to the above URL.  I would like to add additional params to cause a certain behavior.  For example: an addition query-string argument could be username and I could pre-populate this value in the login page.

A: Yes, It's possible to pass any additional parameters as long as they don't share the same parameter names used by IS.
You may write an authenticator by extending "BasicAuthenticator" and overriding the initiateAuthenticationRequest().There you'll have to copy the method content from "BasicAuthenticator" class and append the redirect url built inside with your parameters. Then use this authenticator as the default one. You can still hack the BasicAuthenticator code itself too, but it's not recommended.


text:
Q: High availability for ceph storage? Do ceph have high availability, I config 2 node like this
  cluster:

    id:     07df97db-f315-4c78-9d2a-ab85007a1856
    health: HEALTH_WARN
            Reduced data availability: 32 pgs inactive
            Degraded data redundancy: 374/590 objects degraded (63.390%), 18 pgs degraded, 32 pgs undersized

  services:
    mon: 2 daemons, quorum ceph1,ceph2
    mgr: ceph1(active), standbys: ceph2
    mds: mycephfs-1/1/1 up  {0=ceph1=up:active}, 1 up:standby
    osd: 2 osds: 1 up, 1 in

  data:
    pools:   6 pools, 96 pgs
    objects: 216  objects, 12 MiB
    usage:   75 MiB used, 945 MiB / 1020 MiB avail
    pgs:     33.333% pgs not active
             374/590 objects degraded (63.390%)
             64 active+clean
             18 undersized+degraded+peered
             14 undersized+peered

As you can see i set up 2 mon call ceph1 and ceph2, but when i stop ceph1, the ceph2 is unable to write file into cephfs -mounted storage on VM
So how to make ceph high availability ?
Does is require more node or somethings like that ?

A: You need at least 3 MON to achieve HA because of the quorum. With only 2 nodes your storage will be stopped by an problem on one node.
"When a Ceph Storage Cluster runs multiple Ceph Monitors for high availability, Ceph Monitors use Paxos to establish consensus about the master cluster map. A consensus requires a majority of monitors running to establish a quorum for consensus about the cluster map (e.g., 1; 2 out of 3; 3 out of 5; 4 out of 6; etc.)." link
If you need HA storage with 2 nodes take a look at solutions which has been designed for this. I can recommend StarWind VSAN free with active-active replication and no quorum requirement.


text:
Q: Sass. Compilation Error Error: expected ":" What i do wrong?
I want to install an embedded font from ../fonts/bsb in sass file, my code:
@font-face
    font-weight: normal
    font-style: normal
    font-family: 'birthstone'
    src: url('//fonts/bsb/bsb-r.woff2') format('woff2')
         url('//fonts/bsb/bsb-r.eot')
         url('//fonts/bsb/bsb-r.eot?#iefix') format('embedded-opentype')
         url('//fonts/bsb/bsb-r.woff') format('woff')
         url('//fonts/bsb/bsb-r.ttf') format('truetype')
         url('//fonts/bsb/bsb-r.svg#birthstone') format('svg')

When compiling it throws this error:
Compilation Error
Error: expected ":".
  ╷
6 │         url('//fonts/bsb/bsb-r.eot')
  │            ^

Questions:

*

*Why does the compiler expect ":" there?

*How can I correctly put the font through sass so that it compiles
correctly into fonts.css?


text:
Q: How to use Playwright Sharp in F# for Browser Automation I guess this is a classic C# to F# conversion I haven't quite got my head around.
I am trying to automate a browser using the quick start
https://playwright.dev/dotnet/docs/intro
The C# code is
using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();
await page.GotoAsync("http://www.bing.com");
await page.ScreenshotAsync(path: outputFile);

I've made a start but getting a bit lost already.
let playwright: Playwright = PlaywrightSharp.Playwright.CreateAsync() |> Async.AwaitTask

Incorrect type. What am I doing wrong here?
Error   FS0001  This expression was expected to have type
    'Playwright'
but here has type
    'Async<IPlaywright>'

A: You can use the TaskBuilder framework https://github.com/rspeele/TaskBuilder.fs
dotnet add package Taskbuilder.fs
and write
task {
    use! playwright =  Playwright.CreateAsync()
    let! browser =  playwright.Chromium.LaunchAsync()
    let! page = browser.NewPageAsync()

    let! response = page.GoToAsync("http://www.bing.com")
    let! title =  page.GetTitleAsync()

    printfn "%s" title

}
|> Task.WaitAll

A: As of F# 6, tasks are now natively supported through the task computation expression. The syntax will be almost identical to the async computation expression from Brian Berns's answer, except that you no longer need to call Async.AwaitTask on each let!, use!, or do! binding.
let screenshotTask =
  task {
    use! playwright = Playwright.CreateAsync ()
    use! browser = playwright.Chromium.LaunchAsync ()
    let! page = browser.NewPageAsync ()
    let! _ = page.GotoAsync "https://www.bing.com"
    let! _ = page.ScreenshotAsync (PageScreenshotOptions(Path = "screenshot.png"))
    return ()
  }
screenshotTask.Wait ()

A: One way to do this is with a F#'s built-in support for async computation expressions. The translation would look something like this:
let (~~) = Async.AwaitTask

async {
    use! playwright = ~~Playwright.CreateAsync()
    let! browser = ~~playwright.Chromium.LaunchAsync()
    let! page = ~~browser.NewPageAsync()
    do! ~~page.GoToAsync("http://www.slashdot.com") |> Async.Ignore
    do! ~~page.ScreenshotAsync(outputFile) |> Async.Ignore
} |> Async.RunSynchronously

There are a few subtleties here that you'll need to know about:

*

*F# has its own async type, called Async<'T>. I've used Async.AwaitTask to convert from C#-style tasks, and defined a prefix operator, ~~, to make this look a bit cleaner.

*F# doesn't support DisposeAsync in async computation expressions yet, so the browser doesn't get disposed of properly. If you want, you can add do! browser.DisposeAsync().AsTask() |> Async.AwaitTask at the end of the block to do this manually.

*F# requires us to explicitly ignore unwanted return values, which I've done via Async.Ignore.


text:
Q: I want to send a json value as a parameter to php page I create a json value as follows:
[
 {
  idx: "261",
  token: "12931"
 }
]

I want to send the value in this way.
send.php?index={"ids":["261"]}& token={"ids":["12931"]}

I do not know what to do to put a parameter in the page that way.


text:
Q: Getting error when using axios POST My url, headers and body data are defined as:
var headers = {
    'Authorization': 'Bearer 12345',
    'Content-Type': 'application/x-www-form-urlencoded'
  }

var data = {
  'password': '123456',
  'ver': '1',
  'time': '1534494857045'
}

I am calling axios by:
axios.post(url, data, headers)
.then(response => {
  console.log(response);
})
.catch(error => {
  if (error.response) {
    console.log(error.response.data);
    console.log(error.response.status);
    console.log(error.response.headers);
  } else if (error.request) {
    console.log(error.request);
  } else {
    console.log('Error', error.message);
  }
  console.log(error.config);
});

I am getting a 500 error from the server. Other apps calling the same server works fine. I even tried this out in Postman and it works. What am I doing wrong in axios?

A: This is, sadly, an educated guess because a MCVE was not provided.
See the documentation for axios:

By default, axios serializes JavaScript objects to JSON. To send data in the application/x-www-form-urlencoded format instead, you can use one of the following options.

You are setting a Content-Type header which claims you are sending application/x-www-form-urlencoded data, but you haven't done any of the things that the documentation suggests to generate data in that format.


text:
Q: using primefaces in liferay 6.1 I have created a sample portlet using primefaces bridge in lifeary. The main functionality is create/edit/delete in some tables. How is it possible to split code of on page to more.
To be more specific I want when I click on a record to go to another xthml page in which I will load the data from selected record

A: You can use the following code to get portlet context and the for example user information
System.out.println("Getting user info");
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
User user = PortalUtil.getUser(portletRequest);

A: Much concise way of doing this is
PortalRequest request = LiferayFacesContext.getPortalRequest();
User user = PoralUtil.getUser(portletRequest);

or to get the currently logged in user, use the following code
LiferayFacesContext.getInstance().getUser();

should give you the Liferay user object for the currently logged in user.


text:
Q: Most suitable message-oriented middleware for cross-language client/server card game? I am going to write a client/server card game for learning/practice purposes, and intend to use Java for both the client and server to begin with. In the future I will be looking to continue to use this project for learning, and thus will want write additional clients in other languages such as C and C++.
The main detail I am unsure about is whether I need to use a MOM with a message broker, or if I can get away without using one.
My initial thought was I could handle the failure to send/receive a message on both sides, prompting an attempt to re-send the message resulting into the game being ended if the amount of attempts reaches a maximum.
However, instead of just having the game client and game server I was thinking about having a client, lobby server and game server. This way I would need the message broker to route the correct messages to the correct server, however I am unsure whether apart from that if I have any need for message broker, as I'm not sure if I really need to have any facility for message persistency.
I am leaning towards going for a MOM with a message broker, but I would welcome anymore lightweight solutions if I am doing so unnecessarilly. That said, if I did what would be a suitable cross-language MOM to use? I have seen quite a few suggested on SO before, but I'm not sure what would best meet my needs.

A: For cross language MOM - I suggest you use Apache ActiveMQ. It complies to the JMS spec and also has a robust C++ client library. It is open source (Apache license)
Yes the other lightweight option you could explore is HTTP. esp. for the client to server communication. (Since clients may need to connect to the server across firewalls etc - HTTP port is easiest to access etc).
For lobby server - game server communication - I like your idea of MOM.


text:
Q: Sonata admin createQuery ignores table alias in sort expression I have two entities: "OriginNews" and "FollowUpNews". They are related one to many, so one OriginNews can have multiple FollowUpNews.
In my OriginNewsAdmin i only want to display the OriginNews in listview, but also ordered (if connected) by FollowUpNews ... so i decided to manipulate my listView-data by altering the  createQueryMethod like this.
 /**
 * @param string $context
 * @return ProxyQueryInterface
 */
public function createQuery($context = 'list')
{
    $query = parent::createQuery($context);

    $query->leftJoin('o.followUpNews', 'fun')
        ->addSelect('COALESCE(fun.importDate, o.importDate) AS HIDDEN sortDate')
        ->addOrderBy('sortDate');

    return $query;
}

This should join the followUpNews to the originNews and sort by importdate ... when i run this, ill get the error.

An exception has been thrown during the rendering of a template
  ("[Semantical Error] line 0, col 94 near 'sortDate ASC,': Error:
  'sortDate' is not defined.").

Is sonata admin kidding me? I defined the sortDate field one line above ... even if i remove the "HIDDEN" keyword ... no change!
Where is the problem?
My goal is, to have always the OriginNews on top which has the most recent FollowUpNews ... is that possible in another way?
Thanks

A: Hours of searching for my problem i found out, that this is simple a doctrine bug existing since several years ...
I ran into the same problem as described here
Doctrine Querybuilder ORDER BY clause is not in SELECT list
I also did the workaround with setting the sql mode to null. I installed also doctrine extensions to use IFNULL-function in order by clause.
My sql looks now like following
$query->leftJoin('o.followUpNews', 'fun')
    ->addOrderBy(IFNULL('fun.importDate', 'o.importDate'), 'DESC');

That works for me.


text:
Q: using sed and grep to search and replace (skipping .svn or .git) I'm using sed and grep to search and replace boost::shared_ptr with std::shared_ptr. How do I keep egrep out of .svn. Its leading to local corruptions:
Transmitting file data .svn: E155017: Commit failed (details follow):
svn: E155017: Working copy text base is corrupt
svn: E200014: Checksum mismatch for text base of '/home/jeffrey/owasp-esapi-cplusplus/doc/html/_codec_8cpp_source.html':
   expected:  09ead67f10a06a392ec41455179da560
     actual:  310ceca1a9c721b40db494f62854d2df

Jeff

A: I recommend you to use ack instead of grep to search files. It takes the same basic options as grep.
It will skip .svn, .git... dirs & binaries by default.
Example :
ack -rl --print0 "pattern" . | xargs -0 -l sed -i 's/pattern/other_pattern/g'

So finally :
ack -rl --print0 "boost::shared_ptr" . |
    xargs -0 -l sed -i 's/boost::shared_ptr/std::shared_ptr/g'

A: Try find with xargs
find /path/to/basedir -name .svn -prune -o -iname '*.h' -print0 , -iname '*.cpp' -print0 | xargs -0 sed -i 's/boost::shared_ptr/std::shared_ptr/g'


text:
Q: meteor react material-ui Steppers So I'm using Meteor with React for a short while and i've seen, that there are steppers for material-ui on googles material-ui specification site, but i found absolutely nothing about how to use it with Meteor! The interesting thing is, that i found some code in the node_modules/material-ui folder for those steppers.... Can someone tell me s.th. about this?
I'm using Meteor 1.3.1 with react@0.14.8 and material-ui@0.15.0-alpha.2..
other npm packages i have installed:
  -http
  -react-dom
  -react-mounter


text:
Q: Nginx React App - Allowing only one location to be accessible I have a server on DigitalOcean that hosts my web app.
The server hosts the API (using Flask) and my web app (React).
I managed to set up the Nginx to serve the app and the API using 2 different domains.
Now I'm facing a problem.
I'm, trying to add another domain that I need to be able to access only one page in the react app.
I can't find a way to set up the configuration to allow that.
server {
server_name www.domain domain;
root /var/www/path/html;
index index.html index.htm index.nginx-debian.html;

location / { deny all; }
location = / { }
location /test {
   try_files $uri /index.html;
}
location /favicon.ico {
   try_files $uri /index.html;
}
location /static/ {
try_files $uri /index.html;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domain/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot }

In my other config files I just use try_files $uri /index.html; and it works perfectly.
I need this domain to be able to accept requests for one path only (domain.com/confirm/token)


text:
Q: What is the meaning of this code in asp.net mvc? [assembly: PreApplicationStartMethod(typeof(Mvc.Bootstrap.Datatables.Example.App_Start.RegisterDatatablesModelBinder), "Start")]

namespace Mvc.Bootstrap.Datatables.Example.App_Start
{
    public static class RegisterDatatablesModelBinder {
        public static void Start() {
            ModelBinders.Binders.Add(typeof(DataTablesParam), new NullableDataTablesModelBinder());
        }
    }
}

I found this in one of GitHub project can anyone tell me what this line does
[assembly: PreApplicationStartMethod(typeof(Mvc.Bootstrap.Datatables.Example.App_Start.RegisterDatatablesModelBinder), "Start")]

A: It instructs the ASP.NET pipeline to call a specific method on a specific type, presumably (judging by its name) before application startup.


text:
Q: How to segue a JSON file in swift? I am building an app where people need to fill out a form and then it creates an HTTP post where the API will return a Json file to the app with data I need. Everything is working fine with accessing the API however I want to parse the data in another view controller. How can I access the JSON file from another view controller?
let task = session.dataTask(with: request as URLRequest, completionHandler: { data, response, error in

        guard error == nil else {
            return
        }

        guard let data = data else {
            return
        }

        do {
            //create json object from data
            if let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: Any] {

                print(json)

 ^^^^^^^
 How do I take this JSON file to the next view controller so I dont have to do the parsing below?

                let jsonData = json

                let ratesJson = jsonData["rates"]!

                let rates = ratesJson as! NSArray

                print("Rates: \(rates)")

                print("*************")
                print(rates.count)
                print("*************")

                for item in 0..<rates.count {
                    let specificRate = rates[item]
                    let price = (specificRate as AnyObject)["amount_local"]!
                    let provider = (specificRate as AnyObject)["provider"]!

                    print("--\(item)--")
                    print("Price: \(price!)")
                    print("Provider: \(provider!)")

                }

            }

        } catch let error {
            print(error.localizedDescription)
        }
    })

A: I assume by your comment, your intention is to actually pass a JSON object, not a JSON file to the next view controller.
Therefore, you just need to pass the JSON object to your segue and assign it as a property to the next view controller.
Since the question was very open ended, here is one possible solution and interpretation.
Example:
//Sample snippet from code from question
if let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: Any] {
    performSegue(withIdentifier: "MySegue", sender: json);
}

override func prepare(for segue: UIStoryboardSegue!, sender: Any?) {
    if (segue.identifier == "MySegue") {
       let vc = segue.destinationViewController as! RandomViewController
       vc.json = sender as! [String:Any];
    }
}

A: One of the things that usually cause bugs in programs is state. What you are asking here in my opinion is state.
What I would do is i would write a generic function ( Swift encourages functional programming in a lot of cases, have a look at: swift map, filter etc. that deals with the HTTP request and returning the data in a closure.
This closure will then live within the view controller you want your json object in, thus solving your problem of accessing said data.
Now I don't believe that is the right approach either. I would create an object for your specific data returned, like say a "struct Person" or whatever your needs are.
This has 2 advantages:

*

*In swift 3.1 you can have a custom init() method that parses the JSON safely ( remember, optionals! ) and populates the structs data accordingly

*In swift 4.0 and Xcode9.0 You will be able to morph the struct you just created to conform to the Codable and Decodable protocols with wich json parsing will be greatly simplified, as explained here: ultimate swift json guide
Hope this was of any help.


text:
Q: Is this a higher kinded type in Scala? Having following definition
type MyMap = Map[String, List[Map[Int, String]]]

Can Map be defined as a higher kinded type ?

A: What you have is not a higher-kinded type, but it could be quite easily modified to be such.
type MyMap2[A,B,C] = Map[A, List[Map[B, C]]]

Now, we can create MyMap again by providing type parameters.
type MyMap = MyMap2[String, Int, String]

"Higher-kinded" just means that it is a type that is uninhabited, and needs to be provided with other types in order to create an inhabitable type.

A: It should not.
You can make an analogy with values and functions. You have basic values, which are not functions, such as 5 and "foo". You have then simple functions, which takes simple values as arguments and return simple values, such as + or length. Higher order functions are functions which have other functions as parameters or result. For instance takeWhile, map, or foldLeft are higher order functions.
If you consider types, there are simple types, which are the actual types of values , such as Int, String, or even Int => String and List[Double] (now I consider every values, simple or not, including functions). Then there are parameteric types, which may also be called type constructors (calling them type functions would make the analogy clearer). List (without instanciating the generic parameter) is not really a type for values, you cannot declare a val to be just of type List, it has to be List[Something]. So List may be considered as a function that given a simple type (say Int) returns another simple type (List[Int]).  Int, String, and Double and Int => String are said to have kind *, while List has kind * -> *. Parametric types such as List or Map are the analogous of simple functions.
Just as a higher order function is a function with function (instead of simple value) parameter, a Higher order type (or sometimes higher kinded) is a type that has a type constructor parameter, rather than just simple type parameters. It has kind (* -> *) -> *, or something more complex. They are declared with HigherOrder[C[_]], or HigherOrder[C[X]], to tell that the type parameter, C, is itself a parametric type, or type constructor. Note that this has to appear in the type declaration, not the type instantiation. List is declared trait List[A], so it is parametric, but not higher order. If you instanciate one with List[Seq[Map[Int, Set[Double]]], that won't make List's order any higher. A higher order type would accept List (rather than List[Int]) as its parameter, one could declare val x : HigherOrder[List] = ....
Higher order types are not too common in the library, you can spot a few in the gory details of the collection library, such as GenericCompanion. You can find a lot of them in scalaz.


text:
Q: Android Javascript Interface empty object in webview I am trying to set up a simple Android app that displays a webview and has some extra functionality available via the Javascript Interface.
I am testing on a HTC One S running Kitkat (via Cyanogenmod). When I inspect the webview the object inserted (Android) is empty "Object {}". I cannot use the functions in the interface via the loaded page.
I had built a more complicated activity but could not get the interface working, so I've created this new app for testing which contains the only the code from the webview guides. Still not inserting the methods into the exposed object.
MyActivity
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;

public class MyActivity extends Activity {

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

        WebView myWebView = (WebView) findViewById(R.id.webview);
        myWebView.addJavascriptInterface(new WebAppInterface(this), "Android");
        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        myWebView.loadUrl("http://47e148ba.ngrok.com");
    }

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

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

WebAppInterface
import android.content.Context;
import android.webkit.JavascriptInterface;
import android.widget.Toast;

/**
 * Created by graeme on 28/08/2014.
 */
public class WebAppInterface {
    Context mContext;

    /** Instantiate the interface and set the context */
    WebAppInterface(Context c) {
        mContext = c;
    }

    /** Show a toast from the web page */
    @JavascriptInterface
    public void showToast(String toast) {
        Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
    }
}

Layout
<?xml version="1.0" encoding="utf-8"?>
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />

build.gradle
apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.mydomain.jswebview"
        minSdkVersion 17
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

You can see I'm using the decorator required for the methods, which most questions seem to have as the solution. I'm developing in Android Studio if any of the presets in there might be interfering?
Edit:
In The JS file, or via the console if I'm inspecting the webview via chrome if I call Android or window.Android i get an empty objected returned "Object {}". Or if I try to use the methods defined in the interface above I'll receive a method undefined error.

A: I was having the same problem. Turned out to be a Proguard problem. Try adding the following to your Proguard rules:
-keepclassmembers class ** {
    @android.webkit.JavascriptInterface <methods>;
}

A: I don't know how are you trying to call to your Java methods from inside of your WebView. I think that the correct way is:
javascript:window.Android.showToast('Hi!');

you could also test your JS interface from your Java code using:
myWebView.loadUrl("javascript:window.Android.showToast('Hi!');");

I hope this help you!


text:
Q: Recursive Function Name Error def a(j):

    lines=in_file.readlines()
    linex=[]
    for line in lines:
        line=line.strip("\n").split(" ")
        linex.append(line)
    print(linex)
    for i in linex:
        for j in i:
            if j=="":
                return 0
            elif j=="X" or j=="Y":
                return 0
            else:
                return a(j[:-1])

in_file=open("ncl.txt","r")
a(j)

Here is my code and I'm having a NameError with this code.

NameError: name 'i' is not defined

So that I can't run the code.. Can you help me about it..
 linex = [['CATTCG', 'ACT'], ['GGTAC', 'GCATTA']] after file operations..

the small code that explains i what i'm trying to do :
def a(j):

   if j=="":
     return 0
   elif j=="X" or j=="Y":
     return 0
   else:
     return a(j[:-1])

a("GUGUUG")

I just want to generalize the code for every j in list.

A: The error is occuring because there is no variable named j.
Replace the j in a(j) with in_file.

Change this:
a(j)

To this:
a(in_file)

If you prefer to use j instead, then you would need to create/define the j variable like this:
j = open("ncl.txt", "r")

It is best practice to give a meaningful name to variables, exactly as you did with in_file.

A: Then you post a code which uses some file, post a file too, really. Or at least add a content of that file in the code itself. You can do it by adding something like this at the beginning:
my_strings = """line 1
line 2
line 3"""

This is the same as doing this:
with open("somefile.txt","r") as my_file:
    my_string = my_file.read()

for a file containing this:
line 1
line 2
line 3

About you doing readlines() in the body of that function, and then doing recursion. Get this outside, it doesn't belong there, and it will probably everything on the second call, because readlines() will return nothing if file is already has been read.
I'd recommend to use for loops instead of recursions, they are just safer and simplier. I didn't really understood what you are trying to do, so it's just a recommendation.
lines and linex are dangerous names, you'll mistake one for another one day and will search for a mistake for hours. Maybe call it like all_lines and lines_list?


text:
Q: Iptable l7-filter installation guide and block p2p I would install l7-filter to block P2P torrent,
First of all , I have a linux debian. I installed by the below command
apt-get install l7-filter-userspace

And then run command
iptables -I FORWARD -m layer7 --l7proto bittorrent -j DROP

but face with the error:

iptables v1.4.14: Couldn't load match `layer7':No such file or
  directory
Try `iptables -h' or 'iptables --help' for more information.

I really don't know what extra should I do ?

A: To use L7, read the 2 links below:
Option 1 - you will still need to load some kernel modules
http://kuscsik.blogspot.com/2008/02/how-to-userspace-l7-filter-on-ubuntu.html
Option 2 - you will need to recompile the the kernel
http://www.ph-lwug.org/index.php?option=com_content&view=article&id=71:turn-your-linux-into-layer-7-filtering-appliance-l7-filter


text:
Q: Explaination of Orthogonal Partial Least Squares (OPLS) I am rather familiar with PLS and understand that it is composed of 3 iterated steps:

*

*finding directions $\vec{v}$, $\vec{w}$ such that the correlation E[($\vec{x}$$\vec{v}$)($\vec{y}$$\vec{w}$)] is maximal

*perform regression on input scores z=$\vec{x}$$\vec{v}$ to find direction $\vec{\beta}$ such that $\hat{\vec{y}}=\vec{\beta} z$

*deflate $\vec{x} \to \vec{x}-\vec{p}z$ and $\vec{y}\to \vec{y}-\hat{\vec{y}}$
Now OPLS performs the deflation in step 3 differently if I understand the paper "Orthogonal projections to latent structures (O-PLS)
Johan Trygg,Svante Wold" https://analyticalsciencejournals.onlinelibrary.wiley.com/doi/10.1002/cem.695 correctly
However, I have to admit I do not yet follow all 20 steps in the original paper. E.g., according to step 13 there is a PCA involved in finding the "orthogonal variation".
Could somebody please explain OPLS and its deflation step in a didactic way? Or is there some good resources out there which do this?


text:
Q: Implementing UML Sequence and Class Diagram I've recently came across this question and I'm just curious if my work is correct, and if not, where I made a mistake.
My Task:
a) Officials are appointed on a temporary or permanent basis. Professors are civil servants who may be appointed for a fixed term or for life.
Professors are also either teaching professors or heads of study. Employees of a scientific institute are civil servants or employees.
Professors are subordinate to the Minister of Science, employees of the scientific institute are subordinate to the professors.
Both professors and employees of the scientific institute work at the scientific institute. The institute can call meetings with professors and staff.
Create the appropriate  UML Class Diagram.
My answer:

b) A professor can inform the secretariat that he or she would like to have an appointment with staff of the scientific institute. The secretariat will then send a list of proposed appointments to all the staff concerned. As soon as the secretariat has received feedback from all staff members, it will send the final appointment to each of them.
Create the corresponding UML Sequence Diagram.
My answer:

c) Implement the process from (b) in Java (method bodies are sufficient!). In doing so, adhere to the classes, abstract classes, and interfaces defined in (a).
My answer:
I tried to solve this problem, but I didn't get any further, especially that it is about solving the task with abstract classes and interfaces. I think this subtask can be solved without abstract classes and interfaces, right?
should the scientific institute be implemented as an abstract class?
Can someone please explain it to me?
Thanks so much :)

A: Class diagram
There is a mistake since professor are civil-servant who are co-worker who are subordinate to professor:  in your narrative a professor is subordinate of the ministry and not of another professor.
What I understand from the narrative is that employees who work in a scientific institute and are subordinate to a professor can only be employee.
In your diagram, a part of the narrative disappeared :

*

*there are only fulltime_employee.  It's not clear how these relate to temporary and permanent employee.

*there is no meeting which would relate to staff and professors.

*where is the staff ?

In your diagram there is also a rigidity that does not exist in the real world: a professor may start career and one day be promoted to director of studies.  It's still the same professor.  It's just the role that changed.  Here I suggest to think about preferring composition over inheritance.
Sequence
Seems reasonable to me, except that:

*

*you should really show separate execution activity as separate: the secretariat send activity then it's over.  Aoother activity starts when the feedback is received.  And in some cases (last feed back received), it's followed by another distinct activity to send the final confirmation.

*you should take care about the arrows.  Most of the requests are asynchronous and have an open arrow head.

*The send final is a normal asynchronous message when sent to the staff (plain line, open head),  but it's an answer to the professor (here you can keep the dotted line.

Implementation
This is a complex question on its own. Better ask this as a separate question.  But you need to be more specific.
Hint: an abstract class, is a class that cannot be instantiated: classes inheriting from it must implement its abstract methods so that objects can be instantiated.


text:
Q: Scala Ordering, Ordered, and View Bound I am writing the following code to illustrate the problem:
def max[T <% Ordered[T]](a: T, b: T) = {
  val c = a.compare(b)
  if (c > 0) a else b
}

def min[T <% Ordering[T]](a: T, b: T) = {
    val ord = implicitly[Ordering[T]]
    val c = ord.compare(a, b)
    if (c > 0) b else a
}

println(s"max is ${max(10, 20)}")
implicit val intOrdering = new Ordering[Int] {
  override def compare(x: Int, y: Int): Int = x - y
}
println(s"min is ${min(10, 20)}")

The max method works well, while the min method doesn't, complaining  No implicit Ordering defined for T even though I defined the intOrdering, it still complains.
I would ask why Ordered works, but Ordering doesn't here, even if I have provided the implicit definition for the Ordering[Int]

A: Ordered and Ordering are semantically different. An Ordered[T] is an object that supports comparisons against other Ordered[T]s, while an Ordering[T] is a single object that is a collection of functions able to compare ordinary Ts.
This difference is reflected in the two types of bounds you need to use here. The view bound [T <% Ordered[T]] means that there needs to be an implicit function T => Ordered[T] somewhere in scope. This function is the implicit conversion intWrapper(Int): RichInt. These RichInts directly support comparisons between themselves via the comparison methods.
However, def min[T <% Ordering[T]]... can't work. This requires a T => Ordering[T], or a function from values of a type to orderings on that type. For some types this might exist, but for most, like Int, it won't.
The other kind of bound is the context bound, T: Ordering, which is what you must use in min. A context bound of this form requests an implicit Ordering[T],  that is, def min[T: Ordering](a: T, b: T) takes two Ts as arguments, and also one implicit Ordering[T] that defines how they are ordered.
In mathier language: A view bound is of the form Left <% Right for some types Left and Right of kind *, leading to the creation of an implicit parameter of type Left => Right. A context bound is of the form Left: Right for some type Left of some kind k and some type Right of kind k -> *, leading to the creation of an implicit parameter of type Right[Left].

A: The view bound used in your max method is really just a short-cut for:
def max[T](a: T, b: T)(implicit ord: T => Ordered[T]) = {
  val c = a.compare(b)
  if (c > 0) a else b
}

Ordering requires an implicit value (as opposed to an implict function for Ordered) for your min method as follows, thus view bound isn't applicable:
def min[T](a: T, b: T)(implicit ord: Ordering[T]) = {
  val c = ord.compare(a, b)
  if (c > 0) b else a
}

Expressing the above in the form of context bound yields the following:
def min[T: Ordering](a: T, b: T) = {
  val ord = implicitly[Ordering[T]]
  val c = ord.compare(a, b)
  if (c > 0) b else a
}


text:
Q: In react router is onEnter is same as onLeave In react router documentation for onEnter hook they specified how to handle but for onLeave there is no example. My question is how to confirm that user want to leave page properly.
According to code given below in both cases whether user click on cancel or ok it leaves the page. However onEnter hook working fine as per logic.
const checkEnterAbout = (nextState, replace, callback) => {
    if(!confirm('do you want to enter really!!!')){
        replace(`/`);
    }else{
        callback();
    }

}

const checkLeaveAbout = (prevState) => {
    console.log(prevState);
    return confirm("Are you sure you want to leave this page");
}

<Route path="/about"  component={About} onEnter={checkEnterAbout} onLeave={checkLeaveAbout} />

Also when I tried withRouter confirming guide.  its giving me an error of
Failed prop type: Invalid prop `component` supplied to `Route`.
    in Route

A: There's a hook called routerWillLeave, here's an example:
https://github.com/ReactTraining/react-router/blob/master/docs/guides/ConfirmingNavigation.md


text:
Q: SharePoint solution for spreadsheet daily planners Does anybody have a good idea for using SharePoint (probably calendars) instead of creating what I call 'daily planner' spreadsheets like in the screenshot I've attached below. Personally I've never been able to present a solution to an end user that they actually prefer. Typically these spreadsheets will include one worbook for each month and show what each team member is doing on a particular day. It's colour coded into categories and also allows notes. The attraction to these spreadsheets is the data input simplicity, which is normally a copy and paste once an entry of a given category exists which is first entered by selecting some cells, select a background colour and type into the (and/or) first cell / notes column. Also these spreadsheets provide end users an easy visual cue as to who is doing what on a given day.
I have tried using a SharePoint calendar, creating some columns, setting up views and enabling colour-coding based on a category column but end users prefer these spreadsheets because it gives them an easier view of what is happening on a given day and the data input takes longer.
I would like to utilise SharePoint functionality to deliver benefits such as Outlook calendar integration and concurrent editing abilities, but so far these benefits aren't enough to tempt my end users into new ways of working.
Has anybody had any success in using SharePoint for this type of 'daily planner' functionality?
Regards,

A: Sure it can be done; One advice (actually it is a Steve Jobs quote):

start with the End User Interface and built back towards technology.

Your challenge will be how to replicate the (fancy) Excel day/duration calculations in SP.
If you are on 2013 you might want to dig through the Apps in the Store to see what has been built (and how) by others.
If you don't master them yet you might need to learn SP technologies:

*

*Workflows

*CSR - Client Side Rendering (for fancy colors and better UX)
My advice: don't try to built an end-product, built a POC (Proof of Concept) exploring the UI/UX and technologies needed.
Then start over, and do it right


text:
Q: Scala - Iterate Over Two Arrays How do you iterate over two arrays of the same size, accessing the same index each iteration The Scala Way™?
      for ((aListItem, bListItem) <- (aList, bList)) {
         // do something with items
      }

The Java way applied to Scala:
     for(i <- 0 until aList.length ) {
          aList(i)
          bList(i)
      }

Assume both lists are the same size.

A: Something like:
for ((aListItem, bListItem) <- (aList zip bList)) {
     // do something with items
}

Or with map like:
(aList zip bList).map{ case (alistItem, blistItem) => // do something }

Updated:
For iterating without creating an intermediates, you can try:
for (i <- 0 until xs.length) ... //xs(i) & ys(i) to access element

or simply
for (i <- xs.indices) ...

A: tl;dr: There are trade-offs between speed and convenience; you need to know your use case to pick appropriately.

If you know both arrays are the same length and you don't need to worry how fast it is, the easiest and most canonical is to use zip inside a for-comprehension:
for ((a,b) <- aList zip bList) { ??? }

The zip method creates a new single array, however.  To avoid that overhead you can use zipped on a tuple which will present the elements in pairs to methods like foreach and map:
(aList, bList).zipped.foreach{ (a,b) => ??? }

Faster still is to index into the arrays, especially if the arrays contain primitives like Int, since the generic code above has to box them.  There is a handy method indices that you can use:
for (i <- aList.indices) { ??? }

Finally, if you need to go as fast as you possibly can, you can fall back to manual while loops or recursion, like so:
// While loop
var i = 0
while (i < aList.length) {
  ???
  i += 1
}

// Recursion
def loop(i: Int) {
  if (i < aList.length) {
    ???
    loop(i+1)
  }
}
loop(0)

If you are computing some value, rather than having it be a side effect, it's sometimes faster with recursion if you pass it along:
// Recursion with explicit result
def loop(i: Int, acc: Int = 0): Int =
  if (i < aList.length) {
    val nextAcc = ???
    loop(i+1, nextAcc)
  }
  else acc

Since you can drop a method definition in anywhere, you can use recursion without restriction.  You can add an @annotation.tailrec annotation to make sure it can be compiled down to a fast loop with jumps instead of actual recursion that eats stack space.
Taking all these different approaches to calculate a dot product on length 1024 vectors, we can compare these to a reference implementation in Java:
public class DotProd {
  public static int dot(int[] a, int[] b) {
    int s = 0;
    for (int i = 0; i < a.length; i++) s += a[i]*b[i];
    return s;
  }
}

plus an equivalent version where we take the dot product of the lengths of strings (so we can assess objects vs. primitives)
normalized time
-----------------
primitive  object  method
---------  ------  ---------------------------------
 100%       100%   Java indexed for loop (reference)
 100%       100%   Scala while loop
 100%       100%   Scala recursion (either way)
 185%       135%   Scala for comprehension on indices
2100%       130%   Scala zipped
3700%       800%   Scala zip

This is particularly bad, of course, with primitives!  (You get similarly huge jumps in time taken if you try to use ArrayLists of Integer instead of Array of int in Java.)  Note in particular that zipped is quite a reasonable choice if you have objects stored.
Do beware of premature optimization, though!  There are advantages to in clarity and safety to functional forms like zip.  If you always write while loops because you think "every little bit helps", you're probably making a mistake because it takes more time to write and debug, and you could be using that time optimizing some more important part of your program.

But, assuming your arrays are the same length is dangerous.  Are you sure?  How much effort will you make to be sure?  Maybe you shouldn't make that assumption?
If you don't need it to be fast, just correct, then you have to choose what to do if the two arrays are not the same length.
If you want to do something with all the elements up to the length of the shorter, then zip is still what you use:
// The second is just shorthand for the first
(aList zip bList).foreach{ case (a,b) => ??? }
for ((a,b) <- (aList zip bList)) { ??? }

// This avoids an intermediate array
(aList, bList).zipped.foreach{ (a,b) => ??? }

If you instead want to pad the shorter one with a default value, you would
aList.zipAll(bList, aDefault, bDefault).foreach{ case (a,b) => ??? }
for ((a,b) <- aList.zipAll(bList, aDefault, bDefault)) { ??? }

In any of these cases, you can use yield with for or map instead of foreach to generate a collection.
If you need the index for a calculation or it really is an array and you really need it to be fast, you will have to do the calculation manually.  Padding missing elements is awkward (I leave that as an exercise to the reader), but the basic form would be:
for (i <- 0 until math.min(aList.length, bList.length)) { ??? }

where you then use i to index into aList and bList.
If you really need maximum speed you would again use (tail) recursion or while loops:
val n = math.min(aList.length, bList.length)
var i = 0
while (i < n) {
  ???
  i += 1
}

def loop(i: Int) {
  if (i < aList.length && i < bList.length) {
    ???
    loop(i+1)
  }
}
loop(0)

A: for {
    i <- 0 until Math.min(list1.size, list2.size)
 } yield list1(i) + list2(i)

Or something like that which checks bounds etc.

A: I would do something like this:
aList.indices foreach { i =>
   val (aListItem, bListItem) = (aList(i), bList(i))
   // do something with items
}


text:
Q: Descargar archivo Angular Mi servicio me retorna un b64 de imagenes. Alguna forma de decodificar el b64, convertir a archivo y descargar el archivo en angular. Algun ejemplo que me puedan proporcionar.

A: Puedes crear un elemento  con el atributo download en la vista y luego simular el clic, o puedes hacer un binding al atributo que sea igual al href en base 64.

Descargar Imagen

Copia el base64, Ejemplo: data:image/jpeg;base64,11

<input ng-model="value" />

Descargar Imagen {{value}}