text:
Q: What does the third wire on this speaker do? I salvaged two large speakers from an old iPod player/alarm clock device. Each of the speakers have three wires tied to it. There is a positive and negative and a third which I assume is ground since it is tied to the thick metal casing.

I understand how a two-wire speaker works and is used but I haven't encountered a three-wire speaker before. I don't see the point to the third wire besides it being a ground.

A: The size difference and rough casing on the center wire indicate that it's probably shielded cable. This takes the form of a braided wrap on the two speaker wires, and prevents the speaker from receiving interference, for instance from 60Hz mains wiring or transformers in the iPod player device.
The speaker itself is basically an electromagnet, or, more simply, a coil of wire.  Current goes in one end, and out the other, and that's about it.  This coil should be isolated from the speaker casing.  The speaker is driven with AC, and probably capacitively isolated from ground.  Shorting to ground could damage the amplifier, depending on the configuration, so shielding is not generally used on speaker wire.
However, in an alarm clock (plugged into mains), which is also used to play audio and charge iPod batteries (which are significant power draws), there's probably a sizeable transformer in the enclosure, which is probably pretty close to this speaker and the speaker wire.  This could produce a hum, so the designers of the device decided that the speaker needed to be shielded.  The risk of the speaker wire shorting out and damaging the amplifier is minimal, because the speaker wire never needs to flex within the alarm clock.
If you do connect these speakers to something else, you can probably ignore the third connection.  If you reuse the cable, simply leave the shield at the other end floating.

A: It is likely for shielding purposes.  Speaker leads in genernal are notorious for picking up RF, including being an antenna from which it can couple back into the driving amplifier.
You mentioned that this was out of something intended for use with an ipod; if it is also intended to work with an iphone GSM radios tend to be very good at causing thumping/pulsing sounds in cheap amplified speakers during certain network operations. With my previous phone, I'd hear this unintended "notification" of an incoming call in my PC's speakers as the nearby phone acknowledged itself to the network, a second or two before the actual ringtone began.
Note also that the speakers are magnetically shielded, probably to limit scan distortion if they are placed near a CRT monitor - wonder how long they will continue bothering with that!

A: Ha ha ha!  That is so funny!  The speaker is a standard speaker.  Nothing special.  What is funny is that someone soldered a wire to the rivet that holds the speaker terminals to the frame!  I'm an EE in the pro-audio industry and I've never seen this done.
The only conceivable use for that third wire is as a shield-- although I doubt that it is very effective at that.  You could certainly disconnect or ignore that wire with no bad effects.


text:
Q: Как с помощью mockito подменить вызов метода который ни чего не возвращает Пытаюсь с помощью mockito подменить вызов метода, который возвращает void. Код сильно упростил, чтобы уменьшить его. Имеется сервис
@Service
public class CalService {
  public void createTable(DataAtributes attr) {
    ...
  }
  public Integer addAttr(DataAtributes attr) {
    return 0;
  }
}

и еще один класс, который вызывает метод из CalService
@Component
public class GetCalcService {
  @Autowired
  private CalService calService ;
  DataAtributes dataAtributes;
  public Integer setCalc() {
    dataAtributes = new DataAtributes(1,"test");
    Integer val = calService.addAttr(dataAtributes);
    calService.createTable(dataAtributes);
    return val;
  }
}

и сам класс тестирования
@SpringBootTest
public class CaclServisTest {
  @Mock
  CalService calcService;
  @InjectMocks
  GetCalcService getCalcService ;
  @Test
  void add() {
    DataAtributes dataAtributes = new DataAtributes(1,"test");
    when(calcService.addAttr(dataAtributes)).thenReturn(57);
    Integer calc = getCalcService.setCalc();
    log.info("calc = " + calc);
  }
}

С методом addAttr все получилось.
А вот как мне подменить вызов метода calService.createTable(dataAtributes) или сделать, так чтобы он не вызывался в тесте?
Просто подменить метод setCalc нельзя, на самом деле в нем идет вызов нескольких методов и только один из них (createTable) необходимо подменить или проигногрировать.

A: В Mockito есть несколько методов для работы с методами, которые возвращают void. В этом случае используйте Mockito.doNothing так:
Mockito.doNothing().when(calServiceMock).createTable(dataAttributes);

redpajama_set_name: RedPajamaStackExchange


text:
Q: regex for access log in Hive RegexSerDe I'm very new in developing regular expressions. Can any one help me to build a common regular expression for the following two strings.

*

*offset=0&fileGuid=1014fc48-6eb3-4fff-8242-96f5a496b0ee

*file=Arnold+P+Gleit+Contract+Information.pdf&param=CommandType=1.1.2.1~ProjectID=13979~FolderID=1344972~UserID=13395&fileGuid=51c01e15-ac3c-4d2d-bdc9-4e63251a0364&location=CommandType=1.1.2.1~ProjectID=13979~FolderID=1344972~UserID=13395&size=28357151&title=&desc=&searchtags=&OnDuplicateAction=2&offset=1703936&first=True&last=False

My intention is to get the value of "offset" and "fileGuid" and load the data into a Hive table.
I tried with the regular expression --
"input.regex" = "offset=([0-9]+).*\\&fileGuid=([a-zA-Z0-9]+\\-[a-zA-Z0-9]+\\-[a-zA-Z0-9]+\\-[a-zA-Z0-9]+\\-[a-zA-Z0-9]+)"

This will work for the first string but will fail for the 2nd string.
Thanks in Advance.

A: This should do the trick: /offset=([^&$]+)|fileGuid=([^&$]+)/
Basically it matches offset=<string to next & or end of line> or fileGuid=<string to next & or end of line>
Example: http://regexr.com?34t57
It might also be convenient to add the offset/fileGuid strings to your matches so its easier to see which is which, to do that make it like (offset)=([^&$]+)|(fileGuid)=([^&$]+).


text:
Q: Pasting emoji in QT QTextEdit I'm trying to paste emoji's in the QT QTextEdit box but it's not getting recognized and it's showing as ??? or [][]
I'm not talking about smiley, I'm talking about emoji.
How can I go about making sure that QT's QTextEdit accepts emoji and displays them correctly?
Thank you.
Got it based on the helpful answer below:
SOLUTION:
    QFontDatabase fontDB;
    fontDB.addApplicationFont(":/Resources/fonts/seguisym.ttf");

    QApplication::setFont(QFont(QStringLiteral("Segoe UI Symbol")));

A: A considerable number of emoji characters are in the Unicode Standard.
If you're, for example, developing with Qt 5.3 in Mac OS X 10.9, pasting emoji characters in text edits should work as it does when pasting any other character.
The reason why your application is showing ?'s and/or []'s is because the current font (perhaps the default system font) doesn't provide representations for emoji "characters".
You can find a proper font out there in the web. Check this for reference.
Then you can add the font to your Qt application
QFontDatabase fontDB;
fontDB.addApplicationFont(":/A Font Supporting Emoji.ttf");

and set it as the font for your application or only your QTextEdit if you prefer
setFont(QFont(QStringLiteral("A Font Supporting Emoji")));

With this your app should be able to display emoji.

A: The Qt documentation of QTextEdit::paste() says: To change the behavior of this function, i.e. to modify what QTextEdit can paste and how it is being pasted, reimplement the virtual canInsertFromMimeData() and insertFromMimeData() functions.
There you should be able to convert the pasted data e.g. to an HTML img element pointing to a file that is embedded into the application by ressource compiler (or to image file on disk).


text:
Q: Despite set.seed - I get different results than others in R When doing
set.seed(123)
smaple(1:100,3)

in R, I get 29 79 41 which is not what others are getting.
Why is this? And how can I change it?
When typing sessionInfo() I get a line which says
Random number generation:
 RNG:     Mersenne-Twister
 Normal:  Inversion
 Sample:  Rounding

Is that perhaps a problem?

A: We can change the default values in RNGkind
-default settings in R 4.1.0 - MacOS (which could vary based on R version - see below)
RNGkind()
#[1] "Mersenne-Twister" "Inversion"        "Rejection"

-testing
set.seed(123)
sample(1:100, 3)
#[1] 31 79 51

-Change the values in RNGkind to match with the OP's
RNGkind(kind = "Mersenne-Twister",
        normal.kind = "Inversion",
        sample.kind = "Rounding")

-test again
set.seed(123)
sample(1:100, 3)
[1] 29 79 41

According to ?RNGkind

sample.kind can be "Rounding" or "Rejection", or partial matches to these. The former was the default in versions prior to 3.6.0: it made sample noticeably non-uniform on large populations, and should only be used for reproduction of old results. See PR#17494 for a discussion.


text:
Q: Pygame - Trying to Toggle a BOOL when a key is pressed, not while pressed I'm trying to make BOOL toggle when a key is pressed not while since that just makes it toggle off and on (true and false) each frame if the key is held down.
Here's my little toggle code
if key[pygame.K_z] and robsHouse.pressed == False:
        robsHouse.pressed = True
    elif key[pygame.K_z] and robsHouse.pressed == True:
        robsHouse.pressed = False

Any ideas would be helpful, thanks.

A: So, this Boolean will change when ever a button is pressed, correct?
Just use the KEYUP event and reverse the variable:
if event == KEYUP:
    if event.key == DESIRED_KEY:
        boolVar = not boolVar

A: You need to toggle on KEYDOWN and KEYUP events.

A: The reason your code is toggling robsHouse.pressed every frame while you hold the key down is because the key[pygame.K_z] condition will be satisfied on each loop iteration while the key is held down, and then the secondary conditions will cause each other to be satisfied on alternating frames.
Without changing the way you are retrieving key data, you could do something like this:
if key[pygame.K_z]:
    robsHouse.pressed = True
else:
    robsHouse.pressed = False

Another way is to find KEYUP and KEYDOWN events from pygame's event module, rather than getting key data from the key module.  That could be done like this:
for event in pygame.event.get():
    if event.type == pygame.KEYDOWN:
        if event.key == pygame.K_z:
            robsHouse.pressed = True
    elif event.type == pygame.KEYUP:
        if event.key == pygame.K_z:
            robsHouse.pressed = False

Personally, I prefer the second approach in most cases.  You are going to need to process events from pygame's event module anyway, otherwise the queue will fill up and your program will become unresponsive (this is mentioned in the pygame event module documentation).


text:
Q: Three.js post-processing: How to keep depth texture for multiple passes? I am rendering a scene using three.js that needs multiple post-processing passes. Most of those steps need the depth buffer. My plan was to first render all visible objects to obtain the color and depth and then render all post-processing passes using 2 framebuffers which are alternating read and write framebuffers. The passes are just examples:

*

*Render Objects -> FB0

*DistortionPass, taking FB0 as input -> FB1

*GodrayPass, taking FB1 as input -> FB0

*SSAOPass, taking FB0 as input -> screen

The GodrayPass needs to read the depth of the first render pass, therefore I need to bind the depth texture and it should not be the one bound to FB0, otherwise it would lead to a feedback loop, since that shader is writing to FB0.
I think it would make sense to copy the depth into a separate texture after rendering the objects, so I can bind this texture whenever needed in a pass without worrying about a feedback loop.
However,

*

*copyTexImage2D seem to not support copying from the depth buffer.

*using a shader to pack the depth buffer after the first pass into an RGBA8 texture would require every pass to "unpack" the float again

*render all objects again using a shader that output the depth to the color buffer? Would require packing or precision loss again.

What is the best practice here? Am I on the right path?
I can make use of WebGL 2.0 (OpenGL ES 3.0), but would like to avoid using unpopular extensions.

A: Three.js doesn't call them FB's, it calls them RenderTargets. For webgl they are WebGLRenderTarget
https://threejs.org/docs/#api/en/renderers/WebGLRenderTarget
This example show setting up a depth texture with a render target
target = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight );
target.texture.format = THREE.RGBFormat;
target.texture.minFilter = THREE.NearestFilter;
target.texture.magFilter = THREE.NearestFilter;
target.texture.generateMipmaps = false;
target.stencilBuffer = false;
target.depthBuffer = true;
target.depthTexture = new THREE.DepthTexture();
target.depthTexture.format = THREE.DepthFormat;
target.depthTexture.type = THREE.UnsignedShortType;

And this article shows rendering to render targets. And this article shows rendering to render targets for the purposes of post processing using EffectComposer and Pass three.js objects.
So, just make 3 render targets
RT0 = color + depth
RT1 = color
RT2 = color

Then setup Pass objects such that
Render Objects -> RT0(color+depth)
DistortionPass, taking RT0(color) as input -> RT1(color)
GodrayPass, taking RT1(color) + RT0(depth) as input -> RT2(color)
SSAOPass, taking RT2(color as input -> screen


text:
Q: Alert is not displayed My test checks whether the user can log in to the site.
I wrote a code to alert that works but showing parts in catch.
I tried to write alert without try and catch but displays an error.
How to write alert without try and catch and alert to be displayed(test to pass).
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for alert to be present (tried for 5 second(s) with 500 MILLISECONDS interval)

This is my code:
public void getMessage() {
        //Verify that is message preview
        try {
        WebDriverWait wait = new WebDriverWait(driver, 5);
        wait.until(ExpectedConditions.alertIsPresent());
        Alert alert = driver.switchTo().alert();
        System.out.println(alert.getText());
        alert.accept();
        Assert.assertTrue(alert.getText().contains("ERROR: Invalid login credentials."));
        } catch (Exception e) {
        System.out.println("Alert is not displayed");
        }

A: Since you have confirmed that the dialog is not truly a JS alert dialog, you won't be able to use Alert. The good news is that it's HTML just like any other part of the page so you can just scrape the element that contains the error text.


text:
Q: Loading JSON into timemap I want to load a JSON into a timemap, and my code seems to be missing something to configure the JSON correctly. JSON format below

{"results": [{"Lat": "34.0453113", "text": "Historic Core DTLA",
  "Lon": "-118.2501836", "bicyclistCount": "26", "date": "2014-10-15"},
  {"Lat": "34.0444899", "text": "Spring @ 7", "Lon": "-118.2523059",
  "bicyclistCount": "16", "date": "2014-10-26"}]}

This link contains the html file based mainly on a timemap example. It opens up the timeline and map, but the data does not load. Also the map won't zoom in and out, though I want to solve the JSON load issue first. Do you have a suggestion on what I can change? Adding the JavaScript code below. Thanks, Patty
The JavaScript code:
var tm;
var errFn = function(jqXHR, textStatus, errorThrown){
  alert(textStatus);
  }

$(function() {

tm = TimeMap.init({
    mapId: "map",               // Id of map div element (required)
    timelineId: "timeline",     // Id of timeline div element (required)
    options: {
        eventIconPath: "../images/"
    },
    datasets: [
        {
            title: "JSON String Dataset",
            type: "json",

            options: {
                // json file
                url: "output.json", <!--this file sits in the same folder as the HTML-->
                error: errFn,
            }
        }
    ],

  bandIntervals: [
         Timeline.DateTime.DAY,
         Timeline.DateTime.WEEK
     ]
  });

    <!--start loading data-->
        function transformData(data) {
      var text, Lat, Lon, bicyclistCount, date; <!--is this how the data is called?-->

    var newData = {
    "title" : text,
    "start" : date,

    "options" : {
        "description" : bicyclistCount
    }
};
newData["point"] = {
   "lat" : Lat,
    "lon" : Lon,
};
}
});
<!--end loading data-->

A: I see a javascript error on your page: Uncaught TypeError: undefined is not a function on this line: data.forEach(function(item)
data is an Object, not an Array
Object
results: Array[10]

Change your JSON from:
{"results": [{"Lat": "34.0453113", "text": "Historic Core DTLA", "Lon": "-118.2501836", "bicyclistCount": "26", "date": "2014-10-15"}, {"Lat": "34.0444899", "text": "Spring @ 7", "Lon": "-118.2523059", "bicyclistCount": "16", "date": "2014-10-26"}]}

To:
[{"Lat": "34.0453113", "text": "Historic Core DTLA", "Lon": "-118.2501836", "bicyclistCount": "26", "date": "2014-10-15"}, {"Lat": "34.0444899", "text": "Spring @ 7", "Lon": "-118.2523059", "bicyclistCount": "16", "date": "2014-10-26"}]

(make it an array not an object with an array as its "results" property)

A: If you don't want to change json then define custom loader and configure Timemap to use it.
$(function() {

TimeMap.loaders.custom = function(options) {
    var loader = new TimeMap.loaders.remote(options);
    loader.parse = JSON.parse;
    loader.preload = function(data) {
        return data["results"]
    }
    loader.transform = function(data) {
        return {
            "title" : data.text,
             "start" : data.date,
            "options" : {
            "description" : data.bicyclistCount
        },
        "point": {
            "lat" : data.Lat,
            "lon" : data.Lon,
            }
        };
    };
    return loader;
};

tm = TimeMap.init({
    mapId: "map",               // Id of map div element (required)
    timelineId: "timeline",     // Id of timeline div element (required)
    options: {
        eventIconPath: "../images/"
    },
    datasets: [
        {
            title: "JSON String Dataset",
            type: "custom",

            options: {
                // json file
                url: "output.json"
            }
        }
    ],

 bandIntervals: [
        Timeline.DateTime.DAY,
        Timeline.DateTime.WEEK
    ]
});
});

A: Change your JSON Format to:
[
  {
    "title":"example",
    "start":"1968-10-12",
    "end": "1968-11-12",
  }

]


text:
Q: .htaccess rewrite, how do I do it for this scenario? I would like to have
eg.
www.domain.com/api/json/implode/abc/and/a/b/c...
equal to
www.domain.com/api/jason/?method=implode&key=abc&param1=and&param2=a&param3=b&param4=c...

A: You could do something like this:
RewriteRule ^/api/json/([/]*)/([/]*)$ /api/jason/method=$1&key=$2
RewriteRule ^/api/json/([/]*)/([/]*)/([/]*)$ /api/jason/method=$1&key=$2&param1=$3
RewriteRule ^/api/json/([/]*)/([/]*)/([/]*)/([/]*)$ /api/jason/method=$1&key=$2&param1=$3&param2=$4
RewriteRule ^/api/json/([/]*)/([/]*)/([/]*)/([/]*)/([/]*)$ /api/jason/method=$1&key=$2&param1=$3&param2=$4&param3=$5
RewriteRule ^/api/json/([/]*)/([/]*)/([/]*)/([/]*)/([/]*)/([/]*)$ /api/jason/method=$1&key=$2&param1=$3&param2=$4&param3=$5&param4=$6
# keep expanding this pattern out for however many paramas you need to be
# able to handle...

But cleaner would be something like this:
RewriteRule ^/api/json/([/]*)/([/]*)$ /api/jason/method=$1&key=$2
RewriteRule ^/api/json/([/]*)/([/]*)/(.*)$ /api/jason/method=$1&key=$2&params=$3

ie: stuff all trailing optional params into a single parameter.

A: I don't think it's possible to dynamically figure out the number of params, but you can do something close:
RewriteRule ^/api/json/([^/]+)/([^/]+)/(.*) /api/jason/?method=$1&key=$2&params=$3

This will extract method and key individually but put all the additional parameters into params, which you can split later within your script.


text:
Q: How to change a DB2 JDBC connection property after its creation? I'm setting the ClientAccountingInformation property of a DB2 connection before its creation for logging purposes.
    this.properties.put("ClientAccountingInformation", "test");
    lDbConection = DriverManager.getConnection(this.connectionString, this.properties);

But I need to set a different value everytime this connection is used, because it comes from a connection pool and it is reused by different transactions.
In fact, what I need is:

*

*Create a connection

*Set the property with value A

*Use the connection

*Give it back to the connection pool

*Get it again for another transaction

*Set the property with value B

*Use the connection

*Give it back to the connection pool

And so on...

A: That is possible:
    properties.put("ClientAccountingInformation", "test 2");
    lDbConnection.setClientInfo(properties);


text:
Q: ASP.NET Image Listbox I want to display a list of images (instead of text) for the user to choose from. The control is databound (the URLs come from the database) Instead of the typical vertical scroll bar in a listbox, I want this box to be horizontal. I'm looking for an ASP.NET server control similar to this: http://www.infragistics.com/dotnet/netadvantage/aspnet/webimageviewer.aspx#Overview
I considered all the answers and finally decided to use the ComboBox from obout.com which can also display the images.
thanks
Shankar

A: if you are experienced with ajax and/or jQuery you can have a look at the jQuery SliderGallery control.
http://ui.jquery.com/repository/real-world/product-slider/

A: I'd just put them in a div (asp:panel?) that's styled to have a particular height and width and overflow horizontally.

A: Unless I'm missing something, this seems like a pretty simple problem to me.  Just create a scrollable DIV that will host all the images.


text:
Q: Use Lagrange method to solve the constrained OP $\max_{x_{1}, x_{2}} 2x_{1} + 3 x_{2}$ subject to $\sqrt{x_{1}} + \sqrt{x_{2}} = 5$.
I set up the Lagrangian first $\wedge (x_{1},x_{2}, \lambda) = 2 x_{1} + 3 x_{2} + \lambda\left ( 5 - \sqrt{x_{1}} - \sqrt{x_{2}} \right )$.
Then obtain the following first-order conditions:
$$\frac{\partial \wedge }{\partial x_{1}} = 2 - \frac{\lambda}{2\sqrt{x_{1}}} = 0$$
$$\frac{\partial \wedge }{\partial x_{2}} = 3 - \frac{\lambda}{2\sqrt{x_{2}}} = 0$$
$$\frac{\partial \wedge }{\partial \lambda} = 5 - \sqrt{x_{1}} - \sqrt{x_{2}}  = 0$$
Then I solve the above equations and find that $x_{1}=9$, $x_{2} = 4$, and $\lambda = 12$.
However the answer says that for the optimal solution $x_{1}=0$ and $x_{2}=25$.
I am not sure how they find this. Also, how do I check the constraint qualification the proper way?
For CQ, how do I show that the constraint is full rank?
I have $$ J = \begin{bmatrix}
\frac{1}{2 \sqrt{x_{1}}} & \frac{1}{2 \sqrt{x_{2}}}
\end{bmatrix}$$
Then I am not sure how to infer that the Jacobian matrix is full rank.

A: If $x_1=0$ and $x_2=25$ we get a value $75$.
We'll prove that it's a maximal value.
Indeed, we need to prove that
$$2x_1+3x_2\leq75$$ or
$$2x_1+3x_2\leq3(\sqrt{x_1}+\sqrt{x_2})^2$$ or
$$2x_1+3x_2\leq3x_1+6\sqrt{x_1x_2}+3x_2,$$
which is obvious.
Done!

A: one can do the following
from $$\sqrt{x_2}=5-\sqrt{x_1}$$ we get by squaring
$$x_2=25-10\sqrt{x_1}+x_1$$ and the objective function is now
$$f(x_1)=2x_1+3(25-10\sqrt{x_1}+x_1)$$
simplifying
$$f(x_1)=5x_1-30\sqrt{x_1}+75$$
$$f'(x_1)=5-15x_1^{-1/2}$$
and $$f''(x_1)=\frac{15}{2}x_1^{-3/2}>0$$ gives a minimum


text:
Q: Differentiate between blank form and 0 using php for html5 form handling if(isset($_POST['n']) ){
    $n  = $_POST['n'];
    if(!empty($n) || $n==0){
        echo "n is any number including 0 but not blank";
    }
}

How do I check if the form values are blank but can be 0 ? isset($_POST['$var']) is returning true even if the html form is blank. I tried doing the above code but it still isnt working. I can't seem to find a way to separate a blank form and 0.

A: Text inputs are considered successfull even if they are empty so don't use isset(). An empty string and 0 are both empty() so don't use it here.  Try checking for an empty string:
($_POST['n'] != '')

Or since you are expecting numbers look at is_numeric() or ctype_digit().


text:
Q: How can I recursively change the permissions of files and directories? I have ubuntu installed on my local computer with apache / php / mysql.
I now have a directory at /var/www - inside which I have several of my ongoing projects. I also work with opensource ( drupal, magento, sugarcrm ).
The problem I am facing is changing file permission with terminal. Sometime I need to change the permission of entire folder and its subsequent sub-folders and files. I have to individually change using
sudo chmod 777 foldername

How can I do this recursively.
Also why do I have to always do it 777, I tried 755 for folders and 644 for files, but that won't work.

A: You can change the subfolders and files on Nautilus. As you can see on the image below. In order to have the permissons on buttons, you can enable the option on Ubuntu Tweak.

A: You should not need 777 for anything. Worst case, you'll need to change the owner of certain files and directories to the "www-data" user.
sudo find /var/www -type d -print0 | xargs -0 chmod 755
sudo find /var/www -type f -print0 | xargs -0 chmod 644
sudo find /var/www/some/subset -print0 | xargs -0 chown www-data:www-data

If you're using Lekensteyn's group membership method, change 755 to 775 and 644 to 664 respectively above, and then force the group stickiness:
sudo find /var/www/some/subset -type d -print0 | xargs -0 chmod g+s

A: bruteforce:
sudo find foldername -exec chmod a+rwx {} ";"

What does not work? Be more specific!
sudo find foldername -type d -exec chmod 755 {} ";"
sudo find foldername -type f -exec chmod 644 {} ";"

A: Just add the -R option to recursively change the permissions of files. An example, recursively add read and write permissions for the owner and group on foldername:
chmod -R ug+rw foldername

Permissions will be like 664 or 775.
Setting the permissions to 777 is highly discouraged. You get errors in either Apache or your editor regarding permissions because apache runs under a different user (www-data) than you.
If you want to write to /var/www, add yourself to the www-data group and set umask+permissions accordingly.

*

*Add yourself to the www-data group: sudo adduser $USER www-data

*Change the ownership of the files in /var/www: sudo chown -R www-data:www-data /var/www

*Change the umask, so newly created files by Apache grants write permissions to the group too. Add umask 007 to /etc/apache2/envvars.

*Grant yourself (technically, the group www-data) write permissions: sudo chmod -R g+w /var/www.

A: If you want to have all of your files be readable to the world (ie. it's just a static set of HTML files/images), then use this command:
chmod -R a+r <base directory>

That will recursively go through all of the files & subdirectories and add read permission to them.
WARNING: Don't do this for files that are executable!  Only files that should be visible by everybody.


text:
Q: What is #syntax=docker/dockerfile:experimental? I have been working with dockerfiles for a while now but today I was working on a small project and somehow on my VScode I typed # then CTRL+SPACE on the first line I got this syntax=docker/dockerfile:experimental.
I don't understand what this does and can't find documentation about it can somebody explain what's with that weird comment.

PS I found some people using this so it's not just some random comment generated by vscode I guess.

A: It's a way to enable new syntax in Dockerfiles when building with BuildKit. It's mentioned in the documentation:

Overriding default frontends
The new syntax features in Dockerfile are available if you override the default frontend. To override the default frontend, set the first line of the Dockerfile as a comment with a specific frontend image:
# syntax=<frontend image>, e.g. # syntax=docker/dockerfile:1.2

The examples on this page use features that are available in docker/dockerfile version 1.2.0 and up. We recommend using docker/dockerfile:1, which always points to the latest release of the version 1 syntax. BuildKit automatically checks for updates of the syntax before building, making sure you are using the most current version. Learn more about the syntax directive in the Dockerfile reference.

I have used it to enable SSH Auth Sock forwarding.


text:
Q: Running specific test class inside a package first in TestNG I want to run a specific test class before running other tests in the same package using testng xml.
test_package
-------------
testclass1
testclass2
testclass3

I want testclass3 to run first.
Selenium grid is being used. Currently the longer test runs at last and other nodes are idle making the test duration longer. How can i give first priority to longer test classes.
<test name="Tests">
    <packages>
        <package name="tests.*"/>
    </packages>
</test>-->

There are multiple classes inside the package but i want selected test class to run ahead of all.

A: If you want to run the classes in order, you can specify the order in the xml as given below, By default testng, run the classes in order mentioned in xml.
<test name="Tests" preserve-order="true">
  <classes>
     <class name="tests.testclass3"/>
     <class name="tests.testclass1"/>
     <class name="tests.testclass2" />
   </classes>
</test>

A: If you include
 <package name="tests.*"/>

Then looks there is no way to say order of classes to execute.
You can try by providing classes with preserve order is testng.xml file or you can create xml file by coding like here.


text:
Q: Defining ethernet port's auto-negotiation property through linux device-tree Is there a way to define ethernet port's auto-negotiation property through linux's device-tree?

A: I think drivers are auto-negotiating by default. Of course HW must support it (PHY must be connected through MDIO to SOC).
If your question was hot to get rid of auto-negotiation then use fixed link as shown here device tree, change fixed link ethernet phy speed runtime


text:
Q: create a new page in odoo -11 theme I am following the odoo-11 documentation - https://www.odoo.com/documentation/11.0/howtos/themes.html#create-a-specific-page-layout
  and trying to create a page layout. But It shows error. I have no idea  why this error pop out. I am newbie.
> Error:
Odoo Server Error

Traceback (most recent call last):
  File "/opt/odoo/odoo/odoo/http.py", line 646, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/odoo/odoo/http.py", line 307, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "/opt/odoo/odoo/odoo/tools/pycompat.py", line 87, in reraise
    raise value
  File "/opt/odoo/odoo/odoo/http.py", line 683, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/odoo/odoo/http.py", line 339, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/odoo/odoo/service/model.py", line 97, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/odoo/odoo/http.py", line 332, in checked_call
    result = self.endpoint(*a, **kw)
  File "/opt/odoo/odoo/odoo/http.py", line 927, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/odoo/odoo/http.py", line 512, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/odoo/addons/web/controllers/main.py", line 928, in call_button
    action = self._call_kw(model, method, args, {})
  File "/opt/odoo/odoo/addons/web/controllers/main.py", line 916, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/opt/odoo/odoo/odoo/api.py", line 689, in call_kw
    return call_kw_multi(method, model, args, kwargs)
  File "/opt/odoo/odoo/odoo/api.py", line 680, in call_kw_multi
    result = method(recs, *args, **kwargs)
  File "<decorator-gen-45>", line 2, in button_immediate_upgrade
  File "/opt/odoo/odoo/odoo/addons/base/module/module.py", line 71, in check_and_log
    return method(self, *args, **kwargs)
  File "/opt/odoo/odoo/odoo/addons/base/module/module.py", line 600, in button_immediate_upgrade
    return self._button_immediate_function(type(self).button_upgrade)
  File "/opt/odoo/odoo/odoo/addons/base/module/module.py", line 539, in _button_immediate_function
    modules.registry.Registry.new(self._cr.dbname, update_module=True)
  File "/opt/odoo/odoo/odoo/modules/registry.py", line 85, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/opt/odoo/odoo/odoo/modules/loading.py", line 339, in load_modules
    force, status, report, loaded_modules, update_module)
  File "/opt/odoo/odoo/odoo/modules/loading.py", line 242, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/opt/odoo/odoo/odoo/modules/loading.py", line 156, in load_module_graph
    _load_data(cr, module_name, idref, mode, kind='data')
  File "/opt/odoo/odoo/odoo/modules/loading.py", line 94, in _load_data
    tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
  File "/opt/odoo/odoo/odoo/tools/convert.py", line 788, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
  File "/opt/odoo/odoo/odoo/tools/convert.py", line 836, in convert_xml_import
    relaxng.assert_(doc)
  File "src/lxml/etree.pyx", line 3560, in lxml.etree._Validator.assert_ (src/lxml/etree.c:194584)
AssertionError: Element odoo has extra content: template, line 5

A: Clear indicates you traceback
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
  File "/opt/odoo/odoo/odoo/tools/convert.py", line 836, in convert_xml_import
    relaxng.assert_(doc)
  File "src/lxml/etree.pyx", line 3560, in lxml.etree._Validator.assert_ (src/lxml/etree.c:194584)
AssertionError: Element odoo has extra content: template, line 5

Your created new template had bugs not properly coded html tempalte


text:
Q: Short (horror) story about about a guy with an implant that lets him turn off his conscious mind I'm trying to find a short story about a guy with a sort of p-zombie implant that lets him like, turn off his consciousness or something like that, which he uses to be more productive at work. Except that one day it breaks and he finds out his workplace is some sort of fucked up rich person's sex dungeon.
At the end he runs off and goes home and finds out his wife has been using the implant, because I guess being married to him is so intolerable that she'd rather be unconscious for it or something like that.


text:
Q: jQM Difference between $.post and $.ajax and I get error with $.post In my hybrid app (using jQM as framework), I try to retrieve data from server.
I tried both $.post and $.ajax method.
With $.ajax, I can access the return data with "data[0].name".
With $.post and exact same return data, when I try access the data with "data[0].name" I get "undefined".
My code that works ($.ajax) and show me correct data:
$(document).on('pagebeforeshow', '#restaurantList', function() {
    $.ajax({
    url: "http://mydomain.com/api/restaurant/allstate/allcuisine",
    type: "POST",
    dataType: "json",
    success: function (data) {
        alert(data[0].restaurant_id);
    }
    });
    });

My code that does not work ($.post) and give me "undefined":
$(document).on('pagebeforeshow', '#restaurantList', function() {
    $.post("http://mydomain.com/api/restaurant/allstate/allcuisine",
    function(data){
        alert(data[0].restaurant_id);
    });
    });

Why is that? There is a reason I need to use $.post but I just unable to access the data. I have check the return JSON, both method return the exact same data.
Please point me the difference between these two and why I get "undefined" from $.post method. Thank you.

A: For $.post to work properly with JSON return data. dataType have to be specified.
According to jQM document:

dataType Type: String The type of data expected from the server.
  Default: Intelligent Guess (xml, json, script, text, html).

But it's Intelligent Guess doesn't seem to be intelligent enough.
For this to work, add in "json", example below:
$(document).on('pagebeforeshow', '#restaurantList', function() {
    $.post("http://mydomain.com/api/restaurant/allstate/allcuisine",
    function(data){
        alert(data[0].restaurant_id);
    }, "json");
    });


text:
Q: How can I set up a code review process to my remote peers before checking in to TFS? My development environment is set up behind a corporate proxy through remote VMs. We uses Visual Studio as the main platform for our code developement , so we had no issue with code review process as Team Foundation Server have this feature.
However recently, we switch to eclipse while still maintaining the projects in TFS. Eclipse have TFS plugin which is good as we can continue on from our previous track without much effort. The only thing missing is the code review.
So, is there anyone who worked using TFS and eclipse in offline mode behind a corporate proxy, have an alternative way to do code review just like visual studio + TFS.

A: It's based on which version control system your team  are using.
If you are using GIT as source control.
For now, the Team Foundation Server plug-in for Eclipse (Team Explorer Everywhere) supports pull requests to review code and collaborate with members of your team.

Collaborate
Work and code together
Use pull requests to review code and collaborate with members of your
  team. Triage and track comments at each stage of the work to ensure no
  feedback gets lost. Finally, configure merge, build, and review
  policies for your Git branches and stay up-to-date with alerts.
Source: Team Explorer Everywhere

If you are using TFVC as source control.
There is no this function in the plug-in directly. You may need to use 3-party code-review plugins to achieve it. Such as SonarLint, Checkstyle Plug-in...
If you want to enforce Code review before any checkin in TFS server. You may need to use check-in policies which can evaluate whether the pending changes meet the validation requirements before they can be checked in to the server. So, if the code review through Sonar can be called programmatically, then you can build a custom check-in policy that calls Sonar inside the Evaluate method.


text:
Q: Overwrite CSS of Instaemail Popup I am using instaemail on my website for sending a post by email and I am trying to customize popup window, but seems that I can not overwrite class or I don't know how to do it. Same popup you can find on link above if you click on email (try it)
I had success with changing wraper color and ID by putting in style.css
div#pf-email-wrapper {
    background-color: rgba(09, 85, 3, 0.50);
}

but how to change (overwrite URL)
.email-sprite{
  background: url('/images/email/email-app-sprite.png') no-repeat;
}

or change color of
.pf-email label {
  color:#356da9; }

So the CSS in style.css would overwrite default CSS of Instamail script

A: Look at the !important from css.
http://css-tricks.com/when-using-important-is-the-right-choice/
.email-sprite {
     backgroun: url('your url') no-repeat !important;
}


text:
Q: Ошибка при сборке dll в visual studio Использую Visual Studio 2017. Есть проект по созданию внешней компоненты для 1с. На выходе должна быть готовая dll компонента. Пытаюсь сделать build. Но все время появляется ошибка
1>------ Build started: Project: Rabbit, Configuration: Debug Win32 ------
1>Writing file 'C:\Users\503053244\git\rabbit\MANIFEST.h'.
1>XSD : error : There was an error processing 'include\MANIFEST.xsd'.
1>
1>If you would like more help, please type "xsd /?".
1>  - Error generating code for DataSet ''.
1>  - Unable to convert input xml file content to a DataSet. The 'http://www.w3.org/2001/XMLSchema:enumeration' element is not supported in this context.
1>  - The 'http://www.w3.org/2001/XMLSchema:enumeration' element is not supported in this context.
1>Done building project "Rabbit.vcxproj" -- FAILED.

Файл MANIFEST выглядит так -
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://v8.1c.ru/8.2/addin/bundle" targetNamespace="http://v8.1c.ru/8.2/addin/bundle" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:complexType name="Bundle">
        <xs:annotation>
            <xs:documentation>Bundle description</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="component" type="Component" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="name" type="xs:string">
            <xs:annotation>
                <xs:documentation>Name component</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>
    <xs:complexType name="Component">
        <xs:attribute name="os" type="OSType" use="required">
            <xs:annotation>
                <xs:documentation>Platform type</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="path" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>File name</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="type" type="ComponentType" use="required">
            <xs:annotation>
                <xs:documentation>Component type</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="object" type="xs:string" >
            <xs:annotation>
                <xs:documentation>Object name</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="arch" type="ArchType" use="required">
            <xs:annotation>
                <xs:documentation>Architecture</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="client" type="ClientType" >
            <xs:annotation>
                <xs:documentation>Client type</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="clientVersion" type="xs:string" >
            <xs:annotation>
                <xs:documentation>Client version</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="buildType" type="buildTypeEnum" >
            <xs:annotation>
                <xs:documentation>Build type</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="codeType" type="codeTypeEnum" >
            <xs:annotation>
                <xs:documentation>Code type</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>
    <xs:simpleType name="OSType">
        <xs:enumeration value="Windows"/>
        <xs:enumeration value="Linux"/>
        <xs:enumeration value="MacOS"/>
        <xs:enumeration value="iOS"/>
        <xs:enumeration value="Android"/>
        <xs:enumeration value="WindowsRuntimePhone"/>
        <xs:enumeration value="WindowsRuntime"/>
    </xs:simpleType>
    <xs:simpleType name="ComponentType">
        <xs:enumeration value="native"/>
        <xs:enumeration value="com"/>
        <xs:enumeration value="plugin"/>
    </xs:simpleType>
    <xs:simpleType name="ArchType">
        <xs:enumeration value="i386"/>
        <xs:enumeration value="x86_64"/>
        <xs:enumeration value="ARM"/>
        <xs:enumeration value="Universal"/>
    </xs:simpleType>
    <xs:simpleType name="ClientType">
        <xs:enumeration value="1C:Enterprise"/>
        <xs:enumeration value="Firefox"/>
        <xs:enumeration value="MSIE"/>
        <xs:enumeration value="Safari"/>
        <xs:enumeration value="Chrome"/>
    </xs:simpleType>
    <xs:simpleType name="buildTypeEnum">
        <xs:enumeration value="developer"/>
        <xs:enumeration value="release"/>
    </xs:simpleType>
    <xs:simpleType name="codeTypeEnum">
        <xs:enumeration value="c++"/>
        <xs:enumeration value="java"/>
    </xs:simpleType>
</xs:schema>

С чем она может быть связана?


text:
Q: How Do You Boost Longer Documents In lucene I have an index of short phrases containing 1-10 sentences. The longer phrases are more relevant results, but because the term frequency is lower they score below all the 1 liners. What I would like to do is boost on the inverse of term frequency, or just give a boost to documents that are longer.
I'm using C#, NEST, and ElasticSearch, but I'm not sure how to go about this with even raw Lucene so anything would help.
example
If I search for "written article" short documents like doc 2 are consitently at the top, while the good results like doc 1 are at the bottom.  How can I reverse this?
Doc 2

cats can't write articles

Doc 1

this is a well written and thought out article.Lorem ipsum dolor sit
  amet, consectetur adipiscing elit. Quisque ornare sem ac arcu posuere
  viverra. Integer egestas pharetra nunc nec cursus. Nam rhoncus sem nec
  sem laoreet tincidunt.

A: Maybe add file length field and boost it?
or
Have you tried removing norms using omitNorms=true, and thus removing length normalization so shorter documents are not boosted?


text:
Q: Passing Pointers to Classes in C++ I am trying to pass a pointer into my classes function, have it incremented, and have the variable retain it's value using pointers. Heres my code, it doesnt increment.
#include "stdafx.h"
#include <iostream>

using namespace std;

class test
{
public:

    int addTo();
    test(int * currentY);
private:

    int y;
};

test::test(int * currentY):
y(*currentY)
{
}

int test::addTo()
{
    y++;
    return 0;
}

int main ()
{
    for (;;)
    {
        int pointedAt = 1;
        int * number = &pointedAt;
        test t(number);
        t.addTo();
        cout <<*number;

        char f;
        cin >>f;
    }
}

A: This should do it:
#include "stdafx.h"
#include <iostream>

using namespace std;

class test
{
public:
    int addTo();
    test(int * currentY);

private:
    int *y;
};

test::test(int *currentY):
    y(currentY)
{}

int test::addTo()
{
    ++*y;
    return 0;
}

int main ()
{
    for (;;)
    {
        int pointedAt = 1;
        test t(&pointedAt);
        t.addTo();
        cout << pointedAt;
    }
}

You have to store a pointer to the integer, so it refers to the same address as the original variable.


text:
Q: How to reformat text ignoring explicit line breaks in OpenOffice? Quite often I find myself inserting text files in OpenOffice Writer documents, then spending inordinate amounts of time reformatting the result. The problem is that those text files contain newlines, which OOWriter then uses to force a line break. Therefore, I get this:
aa bb cc dd ee
ff
gg hh ii jj kk
ll mm

when I'd rather have the whole paragraph properly formatted:
aa bb cc dd ee ff gg
hh ii jj kk ll mm

Is there a (preferably easy) way to reformat the text to achieve this result?
EDIT:
Here's a reproducible example:
123 121 21 23232 2323 232 23232 2332 23 22332 3 22 2 323 23232 23232 23 323 23232  sds sfsdfs sdfs sfsdfs
3232 232 223 23232 22323 23 23232 2323 23232 2 2 sdsd sdad asdasas adsada adasda adassda fsdfs sfsdf sfsdfs
adsaa dasa addasadaa adasads adas das adas as d a das ad a dsa da sd ad sad asasasd asds sfdfds sfsfsd
hfghfg fghfhg fhfgh fhgfh fhfgf fhghf fh fgh fg hfg hfg hfghrttyhfg  fhfh hf h f hg f hffg dfs sdfsfwet ytyt

Since there are no empty lines, I consider this text to be single paragraph. But if I insert or paste this content into a new empty document in OOWriter-3.3, I get this:
123 121 21 23232 2323 232 23232 2332 23 22332 3 22 2 323 23232 23232 23 323 23232  sds sfsdfs
sdfs sfsdfs
3232 232 223 23232 22323 23 23232 2323 23232 2 2 sdsd sdad asdasas adsada adasda adassda fsdfs
sfsdf sfsdfs
adsaa dasa addasadaa adasads adas das adas as d a das ad a dsa da sd ad sad asasasd asds sfdfds sfsfsd
hfghfg fghfhg fhfgh fhgfh fhfgf fhghf fh fgh fg hfg hfg hfghrttyhfg  fhfh hf h f hg f hffg dfs sdfsfwet
ytyt

Is there an automatic way to restructure the flow of text so that all lines are filled properly?

A: I found a partial solution:

*

*Mark the text

*Select Find & Replace

*Enable regular expressions from the More Options menu

*In Search for: enter a single $

*Leave Replace with: empty

*Press Replace All
This will remove all explicit newlines - not exactly what I want but very close.


text:
Q: Cannot open Anaconda Navigator in Ubuntu 16.04. Import error? I cannot open Anaconda Navigator.
I installed it following the instructions here: https://conda.io/docs/user-guide/install/linux.html#install-linux-silent.
I get this output when I run the comand conda list
# packages in environment at /home/luismario/anaconda3:
#
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0            py36he11e457_0
alabaster                 0.7.10           py36h306e16b_0
anaconda                  5.1.0                    py36_2
anaconda-clean            1.1.0                    py36_0
anaconda-client           1.6.9                    py36_0
anaconda-navigator        1.8.4                    py36_0    anaconda
anaconda-project          0.8.2            py36h44fb852_0
asn1crypto                0.24.0                   py36_0
astroid                   1.6.1                    py36_0
astropy                   2.0.3            py36h14c3975_0
attrs                     17.4.0                   py36_0
babel                     2.5.3                    py36_0
backports                 1.0              py36hfa02d7e_1
backports.shutil_get_terminal_size 1.0.0            py36hfea85ff_2
beautifulsoup4            4.6.0            py36h49b8c8c_1
bitarray                  0.8.1            py36h14c3975_1
bkcharts                  0.2              py36h735825a_0
blaze                     0.11.3           py36h4e06776_0
bleach                    2.1.2                    py36_0
bokeh                     0.12.13          py36h2f9c1c0_0
boto                      2.48.0           py36h6e4cd66_1
bottleneck                1.2.1            py36haac1ea0_0
bzip2                     1.0.6                h9a117a8_4
ca-certificates           2017.08.26           h1d4fec5_0
cairo                     1.14.12              h77bcde2_0
certifi                   2018.1.18                py36_0
cffi                      1.11.4           py36h9745a5d_0
chardet                   3.0.4            py36h0f667ec_1
click                     6.7              py36h5253387_0
cloudpickle               0.5.2                    py36_1
clyent                    1.2.2            py36h7e57e65_1
colorama                  0.3.9            py36h489cec4_0
conda                     4.4.10                   py36_0
conda-build               3.4.1                    py36_0
conda-env                 2.6.0                h36134e3_1
conda-verify              2.0.0            py36h98955d8_0
contextlib2               0.5.5            py36h6c84a62_0
cryptography              2.1.4            py36hd09be54_0
curl                      7.58.0               h84994c4_0
cycler                    0.10.0           py36h93f1223_0
cython                    0.27.3           py36h1860423_0
cytoolz                   0.9.0            py36h14c3975_0
dask                      0.16.1                   py36_0
dask-core                 0.16.1                   py36_0
datashape                 0.5.4            py36h3ad6b5c_0
dbus                      1.12.2               hc3f9b76_1
decorator                 4.2.1                    py36_0
distributed               1.20.2                   py36_0
docutils                  0.14             py36hb0f60f5_0
entrypoints               0.2.3            py36h1aec115_2
et_xmlfile                1.0.1            py36hd6bccc3_0
expat                     2.2.5                he0dffb1_0
fastcache                 1.0.2            py36h14c3975_2
filelock                  2.0.13           py36h646ffb5_0
flask                     0.12.2           py36hb24657c_0
flask-cors                3.0.3            py36h2d857d3_0
fontconfig                2.12.4               h88586e7_1
freetype                  2.8                  hab7d2ae_1
get_terminal_size         1.0.0                haa9412d_0
gevent                    1.2.2            py36h2fe25dc_0
glib                      2.53.6               h5d9569c_2
glob2                     0.6              py36he249c77_0
gmp                       6.1.2                h6c8ec71_1
gmpy2                     2.0.8            py36hc8893dd_2
graphite2                 1.3.10               hf63cedd_1
greenlet                  0.4.12           py36h2d503a6_0
gst-plugins-base          1.12.4               h33fb286_0
gstreamer                 1.12.4               hb53b477_0
h5py                      2.7.1            py36h3585f63_0
harfbuzz                  1.7.4                hc5b324e_0
hdf5                      1.10.1               h9caa474_1
heapdict                  1.0.0                    py36_2
html5lib                  1.0.1            py36h2f9c1c0_0
icu                       58.2                 h9c2bf20_1
idna                      2.6              py36h82fb2a8_1
imageio                   2.2.0            py36he555465_0
imagesize                 0.7.1            py36h52d8127_0
intel-openmp              2018.0.0             hc7b2577_8
ipykernel                 4.8.0                    py36_0
ipython                   6.2.1            py36h88c514a_1
ipython_genutils          0.2.0            py36hb52b0d5_0
ipywidgets                7.1.1                    py36_0
isort                     4.2.15           py36had401c0_0
itsdangerous              0.24             py36h93cc618_1
jbig                      2.1                  hdba287a_0
jdcal                     1.3              py36h4c697fb_0
jedi                      0.11.1                   py36_0
jinja2                    2.10             py36ha16c418_0
jpeg                      9b                   h024ee3a_2
jsonschema                2.6.0            py36h006f8b5_0
jupyter                   1.0.0                    py36_4
jupyter_client            5.2.2                    py36_0
jupyter_console           5.2.0            py36he59e554_1
jupyter_core              4.4.0            py36h7c827e3_0
jupyterlab                0.31.5                   py36_0
jupyterlab_launcher       0.10.2                   py36_0
lazy-object-proxy         1.3.1            py36h10fcdad_0
libcurl                   7.58.0               h1ad7b7a_0
libedit                   3.1                  heed3624_0
libffi                    3.2.1                hd88cf55_4
libgcc-ng                 7.2.0                h7cc24e2_2
libgfortran-ng            7.2.0                h9f7466a_2
libpng                    1.6.34               hb9fc6fc_0
libsodium                 1.0.15               hf101ebd_0
libssh2                   1.8.0                h9cfc8f7_4
libstdcxx-ng              7.2.0                h7a57d05_2
libtiff                   4.0.9                h28f6b97_0
libtool                   2.4.6                h544aabb_3
libxcb                    1.12                 hcd93eb1_4
libxml2                   2.9.7                h26e45fe_0
libxslt                   1.1.32               h1312cb7_0
llvmlite                  0.21.0           py36ha241eea_0
locket                    0.2.0            py36h787c0ad_1
lxml                      4.1.1            py36hf71bdeb_1
lzo                       2.10                 h49e0be7_2
markupsafe                1.0              py36hd9260cd_1
matplotlib                2.1.2            py36h0e671d2_0
mccabe                    0.6.1            py36h5ad9710_1
mistune                   0.8.3                    py36_0
mkl                       2018.0.1             h19d6760_4
mkl-service               1.1.2            py36h17a0993_4
mpc                       1.0.3                hec55b23_5
mpfr                      3.1.5                h11a74b3_2
mpmath                    1.0.0            py36hfeacd6b_2
msgpack-python            0.5.1            py36h6bb024c_0
multipledispatch          0.4.9            py36h41da3fb_0
navigator-updater         0.1.0            py36h14770f7_0
nbconvert                 5.3.1            py36hb41ffb7_0
nbformat                  4.4.0            py36h31c9010_0
ncurses                   6.0                  h9df7e31_2
networkx                  2.1                      py36_0
nltk                      3.2.5            py36h7532b22_0
nose                      1.3.7            py36hcdf7029_2
notebook                  5.4.0                    py36_0
numba                     0.36.2          np114py36hc6662d5_0
numexpr                   2.6.4            py36hc4a3f9a_0
numpy                     1.14.0           py36h3dfced4_1
numpydoc                  0.7.0            py36h18f165f_0
odo                       0.5.1            py36h90ed295_0
olefile                   0.45.1                   py36_0
openpyxl                  2.4.10                   py36_0
openssl                   1.0.2n               hb7f436b_0
packaging                 16.8             py36ha668100_1
pandas                    0.22.0           py36hf484d3e_0
pandoc                    1.19.2.1             hea2e7c5_1
pandocfilters             1.4.2            py36ha6701b7_1
pango                     1.41.0               hd475d92_0
parso                     0.1.1            py36h35f843b_0
partd                     0.3.8            py36h36fd896_0
patchelf                  0.9                  hf79760b_2
path.py                   10.5             py36h55ceabb_0
pathlib2                  2.3.0            py36h49efa8e_0
patsy                     0.5.0                    py36_0
pcre                      8.41                 hc27e229_1
pep8                      1.7.1                    py36_0
pexpect                   4.3.1                    py36_0
pickleshare               0.7.4            py36h63277f8_0
pillow                    5.0.0            py36h3deb7b8_0
pip                       9.0.1            py36h6c6f9ce_4
pixman                    0.34.0               hceecf20_3
pkginfo                   1.4.1            py36h215d178_1
pluggy                    0.6.0            py36hb689045_0
ply                       3.10             py36hed35086_0
prompt_toolkit            1.0.15           py36h17d85b1_0
psutil                    5.4.3            py36h14c3975_0
ptyprocess                0.5.2            py36h69acd42_0
py                        1.5.2            py36h29bf505_0
pycodestyle               2.3.1            py36hf609f19_0
pycosat                   0.6.3            py36h0a5515d_0
pycparser                 2.18             py36hf9f622e_1
pycrypto                  2.6.1            py36h14c3975_7
pycurl                    7.43.0.1         py36hb7f436b_0
pyflakes                  1.6.0            py36h7bd6a15_0
pygments                  2.2.0            py36h0d3125c_0
pylint                    1.8.2                    py36_0
pyodbc                    4.0.22           py36hf484d3e_0
pyopenssl                 17.5.0           py36h20ba746_0
pyparsing                 2.2.0            py36hee85983_1
pyqt                      5.6.0            py36h0386399_5
pysocks                   1.6.7            py36hd97a5b1_1
pytables                  3.4.2            py36h3b5282a_2
pytest                    3.3.2                    py36_0
python                    3.6.4                hc3d631a_1
python-dateutil           2.6.1            py36h88d3b88_1
pytz                      2017.3           py36h63b9c63_0
pywavelets                0.5.2            py36he602eb0_0
pyyaml                    3.12             py36hafb9ca4_1
pyzmq                     16.0.3           py36he2533c7_0
qt                        5.6.2               h974d657_12
qtawesome                 0.4.4            py36h609ed8c_0
qtconsole                 4.3.1            py36h8f73b5b_0
qtpy                      1.3.1            py36h3691cc8_0
readline                  7.0                  ha6073c6_4
requests                  2.18.4           py36he2e5f8d_1
rope                      0.10.7           py36h147e2ec_0
ruamel_yaml               0.15.35          py36h14c3975_1
scikit-image              0.13.1           py36h14c3975_1
scikit-learn              0.19.1           py36h7aa7ec6_0
scipy                     1.0.0            py36hbf646e7_0
seaborn                   0.8.1            py36hfad7ec4_0
send2trash                1.4.2                    py36_0
setuptools                38.4.0                   py36_0
simplegeneric             0.8.1                    py36_2
singledispatch            3.4.0.3          py36h7a266c3_0
sip                       4.18.1           py36h51ed4ed_2
six                       1.11.0           py36h372c433_1
snowballstemmer           1.2.1            py36h6febd40_0
sortedcollections         0.5.3            py36h3c761f9_0
sortedcontainers          1.5.9                    py36_0
sphinx                    1.6.6                    py36_0
sphinxcontrib             1.0              py36h6d0f590_1
sphinxcontrib-websupport  1.0.1            py36hb5cb234_1
spyder                    3.2.6                    py36_0
sqlalchemy                1.2.1            py36h14c3975_0
sqlite                    3.22.0               h1bed415_0
statsmodels               0.8.0            py36h8533d0b_0
sympy                     1.1.1            py36hc6d1c1c_0
tblib                     1.3.2            py36h34cf8b6_0
terminado                 0.8.1                    py36_1
testpath                  0.3.1            py36h8cadb63_0
tk                        8.6.7                hc745277_3
toolz                     0.9.0                    py36_0
tornado                   4.5.3                    py36_0
traitlets                 4.3.2            py36h674d592_0
typing                    3.6.2            py36h7da032a_0
unicodecsv                0.14.1           py36ha668878_0
unixodbc                  2.3.4                hc36303a_1
urllib3                   1.22             py36hbe7ace6_0
wcwidth                   0.1.7            py36hdf4376a_0
webencodings              0.5.1            py36h800622e_1
werkzeug                  0.14.1                   py36_0
wheel                     0.30.0           py36hfd4bba0_1
widgetsnbextension        3.1.0                    py36_0
wrapt                     1.10.11          py36h28b7045_0
xlrd                      1.1.0            py36h1db9f0c_1
xlsxwriter                1.0.2            py36h3de1aca_0
xlwt                      1.3.0            py36h7b00a1f_0
xz                        5.2.3                h55aa19d_2
yaml                      0.1.7                had09818_2
zeromq                    4.2.2                hbedb6e5_2
zict                      0.1.3            py36h3a3bf81_0
zlib                      1.2.11               ha838bed_2

And when I run anaconda-navigator I get
Traceback (most recent call last):
  File "/home/luismario/anaconda3/bin/anaconda-navigator", line 7, in <module>
    from anaconda_navigator.app.main import main
  File "/home/luismario/anaconda3/lib/python3.6/site-packages/anaconda_navigator/app/main.py", line 22, in <module>
    from anaconda_navigator.utils.conda import is_conda_available
  File "/home/luismario/anaconda3/lib/python3.6/site-packages/anaconda_navigator/utils/__init__.py", line 15, in <module>
    from qtpy.QtGui import QIcon
  File "/home/luismario/anaconda3/lib/python3.6/site-packages/qtpy/QtGui.py", line 20, in <module>
    from PyQt5.QtGui import *
ImportError: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1: undefined symbol: xcb_dri3_get_supported_modifiers

I also looked for an answer in Ask Ubunutu and here https://github.com/ContinuumIO/anaconda-issues/issues, but I found questions about another kind of errors. Anyway I tried updating navigator and instaling anaconda-clean but nothing worked.
I will appreciate all comments. Thanks in advance.

A: It worked for me:
export PATH=/home/yourUserName/anaconda3/bin:$PATH

A: Fine, it is done. Just for the record.
First of all, run conda update -n base conda if your conda version is not the newest.
Then conda update --all (it will take some time).
After that anaconda-navigator works.
P.D: I don't really know what the line ImportError: /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1: undefined symbol: xcb_dri3_get_supported_modifiers means, but the file libGL.so.1 still not possible to open.
Anyway, if someone have the same error I hope it would be useful. You just need to update everything.

A: I run conda update -n base conda and, then, conda update --all. It started my Anaconda Navigator, showing that green logo on the center of my screen, but after six (yes, 6) hours, it never loaded the Navigator.
So I run conda install anaconda-clean and, then, anaconda-clean. It removed Anaconda from my computer.
After that, I run again conda update -n base conda  and, finally, conda update --all, but these commands were not necessary because all my Conda files were already updated.
I finally run conda install -c anaconda python, which reinstalled Anaconda, and it could finally load.

A: Please Check if your virtual environment is active or not.
To activate your Virtual Env :
source ~/anaconda3/bin/activate root

This command will activate your virtual environment.
After this you can try running your anaconda by using the below command:
anaconda-navigator

Cheers!
happy coding!
I learned an another way from the comments and It worked too.
You can try :
~/anaconda3/bin/anaconda-navigator


text:
Q: How do I select all text within a div and a href I have HTML such as:

  Country 1

  Capital 1

  Population

I would like to know how to use Javascript (not jquery) to create an array:
[Country 1,Captial 1,Population]
I know the class of the DIV above each href will be set to "mt brn" - so I'd like it to ignore any a href text that isn't contained within the
Thanks in advance,
Mark

A: Use document.querySelectorAll('.mt.brn a'); to get anchor tag inside the class .mt.brn.Then loop throught the elements and  use inneHTML to get the content.Or use textContent to get the text

var elemts = document.querySelectorAll('.mt.brn a');
var textArray=[];
for(var i= 0;i< elemts.length;i++){

  textArray.push(elemts[i].innerHTML )
}
console.log(textArray)

  Country 1

  Capital 1

  Population

Example using text Content:

var elemts = document.querySelectorAll('.mt.brn a');
var textArray=[];
for(var i= 0;i< elemts.length;i++){

  textArray.push(elemts[i].textContent )
}
console.log(textArray)

  Country 1

  Capital 1

  Population

A: Use document.querySelectorAll:

var anchorElements = document.querySelectorAll('.mt.brn > a');
var contents = [];
for (var i = 0; i < anchorElements.length; i++) {
  contents.push(anchorElements[i].textContent);
}

console.log(contents);

  Country 1

  Capital 1

  Population

A: You can try the following javascript code :
var divList = document.getElementsByClassName("brn");
var tab=[];
for (index = 0; index < divList.length; ++index)  {
    var text =divList[index].getElementsByTagName('a')[0].innerHTML;
    tab.push(text);
}


text:
Q: What do these error messages mean when numerically solving differential equations? I am using Mathematica to numercially solve the following equations:
2 D[f0[r], r]/r + D[f0[r], r, r] == -2 A f1[r]/r^4 +  2 A D[f1[r],
r]/r^3 -2 f1[r]/r^2 + 2 D[f1[r], r]/r + D[f1[r], r, r] == 2 A D[f0[r], r]/r^3

And my boundary condition is
f0[10] == 0.01, f1[10] == 0.01,
(D[f0[r], r] /. r -> 1) == 10^-3 A,
(D[f1[r], r] /. r -> 1) == 0

When I take A to be small, say 1, everything is fine. However, if I take A
to be large, e.g. 100, Mathematica complains and gives me crazy results.
Here are the error message I get:

NDSolve::bvluc: The equations derived from the boundary conditions are
  numerically ill-conditioned. The boundary conditions may not be sufficient
  to uniquely define a solution. The computed solution may match the boundary
  conditions poorly. >>
NDSolve::berr: There are significant errors {-5.55116*10^6,-7.26312*10^6,0.,
  0.} in the boundary value residuals. Returning the best solution found. >>

Can anyone help me to deal with this issue?  I appreciate your help!

A: You may solve this by increasing the WorkingPrecision like so:
eqn = {2 D[f0[r], r]/r + D[f0[r], r, r] == -2 A f1[r]/r^4 +
     2 A D[f1[r], r]/r^3,
   -2 f1[r]/r^2 + 2 D[f1[r], r]/r + D[f1[r], r, r] ==
    2 A D[f0[r], r]/r^3};
bc = {f0[10] == 1/100,
   f1[10] == 1/100, (D[f0[r], r] /. r -> 1) ==
    10^-3 A, (D[f1[r], r] /. r -> 1) == 0};

A = 80
NDSolve[{eqn, bc}, {f0, f1}, {r, 1, 10}, WorkingPrecision -> 60,
 MaxSteps -> Infinity]
A =.;


text:
Q: sorting pandas data frame based on multiple values in a single cell i have a data frame that contain multiple data in one column
    ID                                            classes
4   5792.0  Mechanics (any of the two sessions), Analysis ...
6   5915.0  Mechanics (any of the two sessions), Perspecti...
8   5931.0                        CS, Chemistry, Perspecti...
9   5991.0                                    Perspective, CS
10  5841.0  Mechanics (any of the two sessions), Perspecti...

the "classes" column can have values such as "Perspective, Chemistry, CS" and so on
i want to sort the above data frame based on values in the classes string
for example one output might be
        ID  classes
4   5792.0       CS
6   5915.0       CS
8   5931.0       CS
9   5991.0       CS
10  5841.0       CS

thus sorted based on classes attended,
I searched google, but all results were sorting data frame based on single value (single value per cell)
thanks in advance

A: Data
df=pd.DataFrame({'ID':[5792.0,5915.0,5931.0,5991.0,5841.0 ],'classes':['Mechanics (any of the two sessions), Perspecti,CS, Chemistry','Mechanics (any of the two sessions), Perspecti,CS, Chemistry','Mechanics (any of the two sessions), Perspecti,CS, Chemistry','Mechanics (any of the two sessions), Perspecti,CS, Chemistry','Mechanics (any of the two sessions), Perspecti,CS, Chemistry']})
df

Use df.str.split to convert string in classes to list
df['classes']=df.classes.str.split(",")

Explode and sort by classes
df.explode('classes').sort_values(by='classes')

Outcome

A: I'm assuming you want to sort each string in the classes column split by commas, you can try this:
df['string'] = df['classes'].apply(lambda x: ' '.join(sorted(x.split(', '))))
print(df)

A: I'm sure there's a more "pandas" way of doing this, but here's one possible solution:
cs_df = df[df['classes'].apply(lambda x: 'CS' in x)]
cs_df['classes'] = 'CS'

In the above example, cs_df should contain all of the rows from the original dataframe where 'CS' is in classes.  You can do this manually or in a loop to get all your dataframes.
Explanation:
When we use df['classes'], pandas returns a numpy.Series instance. numpy.Series.apply takes a function as an argument and applies it to every item in the series. For example:
# square each item in the series
s1 = numpy.Series([1,2,3]).apply(lambda x: x*x)
#[1,4,9]
# root each item in the series
s2 = s1.apply(sqrt)
#[1,2,3]

Pandas also has special indexing logic. If you use a Series of bools as an index on a Dataframe, pandas will return a Dataframe where the items in the index series was True.
So in this example
s = numpy.Series([True, False, True])
df2 = df[s]

df2 will only contain the rows 0 and 2 from the original df.
Finally, pandas also has special logic for assignment by index as well. You can set entire columns to a single scalar value without needing an explit loop:
df['best_column'] = "best value"

In the above example, the dataframe will have a new column filled with values "best value".


text:
Q: Bash script processing snmp text to only print desired ID I am trying to create a bash script handling snmp responses the same way whether or not the OID is installed on the client.
Clients can get the following responses:
SNMPv2-SMI::mib-2.47.1.1.1.1.13.1062 STRING: "GLC-SX-MMD          "

iso.3.6.1.2.1.47.1.1.1.1.13.1062 STRING: "GLC-SX-MMD          "

I want to get the last part, 1062, which is the id number. What these responses share is 47.1.1.1.1.13.(id number).
How can I process the text to print id number only regardless of how the client reponse looks in the beginning?

A: For example, you can remove everything except a number following digits and dots:
sed -e 's/.*[0-9.]*\.\([0-9]*\).*/\1/'

Explanation:
.*         anything
[0-9.]*    digits and dots in any order
\.         dot
\(         start a matching group
  [0-9]*   digits
\)         end the matching group
.*         anything

All the matching string is replaced with the matching group, i.e. the last number after digits and dots.

A: If the only thing you can be sure of is that you want a string of digits that comes after 47.1.1.1.1.13., you could use one of:
grep -Po '47\.1\.1\.1\.1\.13.\K\d+'
sed -n 's/.*47\.1\.1\.1\.1\.13\.\([0-9]\+\).*/\1/p'
perl -lne '/47\.1\.1\.1\.1\.13\.(\d+)/ && print $1'

If, as in your example, the target string is always before STRING, you could use:
grep -Po '\d+(?= STRING)'
sed -n 's/.*\.\([0-9]\+\) STRING.*/\1/p'
perl -lne '/(\d+)(?= STRING)/ && print $1'

Alternatively, if the target string is always the first occurrence of a dot, a string of numbers and a space, which is what you show in your question, you can do:
grep -Po '^\S+\.\K\d+'
sed -n 's/^[^ \t]*\.\([0-9]\+\).*/\1/p'
perl -lne '/^\S+\.(\d+)/ && print $1' file

A: Based on Remove two substrings from a string:
$ shopt -s extglob
$ resp1='SNMPv2-SMI::mib-2.47.1.1.1.1.13.1062 STRING: "GLC-SX-MMD          "'
$ resp2='iso.3.6.1.2.1.47.1.1.1.1.13.1062 STRING: "GLC-SX-MMD          "'
$ echo ${resp1//@(*47.1.1.1.1.13.| STRING*)}
1062
$ echo ${resp2//@(*47.1.1.1.1.13.| STRING*)}
1062


text:
Q: Simulate external page request in php in my local server I have written code in a php file that gets called from Paypal when a charge is processed (also called as PIN/API etc.). Paypal sends some parameters, may be many get and post variables etc. too along with the page call using which I send email to customer based of the user details, amount etc. from the parameters. Is it possible that I can save all the call info by any line of code in the php file so that I can simulate same call again, because Paypal sandbox is very time consuming and if I can debug by code locally instead of writing a log code on each step and transferring the php file on server for testing after each code change, then it will save many hrs.
I hope I am clear in my question. I just want to simulate a page request which third-party server is calling and I don't know their parameters. So, I was thinking may be there is a way to do an exact page request by any mean on my local computer.

A: You know which parameters Paypal will be sending you, it's in their documentation. But I can understand you might want this for debugging or error reporting.
How to capture input
To capture a request it's usually sufficient to capture $_GET and $_POST. In some cases you will want to read from file_get_contents("php://input") as well but I don't believe PayPal uses that.
How to make a request
If your request is simple you can just do a file_get_contents("mypage.php"). If you want to send POST parameters as well: make a stream context with stream_context_create. Or chicken out and use curl :P


text:
Q: Check if dropout rates are independent for an interaction of two independent variables (one with a large amount of levels) I am trying to analyse dropout rates in an experiment, but there are multiple issues which collide, and I don't know how to deal with them as a whole. First, find a list of those issues. Below, see a more elaborate description and a fictional example for illustration (which involves cakes!). I am using R for my analysis, but appreciate any theoretical input.
Issues

*

*A combination of two independent variables (stimulus $\times$ condition).

*

*... where one of the variables has a large number of levels (100 stimuli).

*... where there might be (?) dependencies: The same stimuli are used in both conditions, even though there are no repeated measures.

*In some cells, the count is zero.

*I have less participants (i.e. maximum dropout rates/cell counts) than stimuli.

What I thought of so far

*

*A $\chi^2$ test, as I am dealing with frequencies - but that doesn't cover the interaction between the two idependent variables.

*I found this tutorial using the Titanic dataset in R which seems to cover my problem and uses a log-linear model to solve it.

*

*However: The large amount of levels, zero counts and possibly (?) dependencies would still be an issue?

*I also found another tutorial heading in the same direction. Here, the loglm() function (MASS package) and the glm() function are used in R.

*

*However, I am unsure if a generalised linear model (glm() using family = poisson(link = "log") is the same as loglm() and if those are fit for my case.

*The nature of the stimuli (many of them; used in both conditions) made me think of including them as a random effect, but that seems wrong because it is my main interest to find out if the dropout rate differs across stimuli - which seems more like a fixed effect to me, but I might be on the wrong track here. In later analyses (e.g. for reaction times), my goal is to include the stimuli as random effects, but the dropout question seems to have a different nature.

I thought I'd go with a fully saturated log-linear model and then remove the interactions one by one to figure out if the dropout is independent of stimulus, condition or the interaction of those. But it appears to me that some assumptions are violated in my case.
Toy example (with code)
I created a toy data set which you can find on GitHub. Let's assume a cake experiment, where 40 participants taste 20 different cakes (stimuli) in two conditions: blindfolded or not. The experiment is between subjects: Participants each get to try 10 cakes blindfolded and 10 without a blindfold. To that end, cakes are divided into two sets (A and B) with 10 cakes each. It's always the same cakes in the same set. Each participant gets to try set A blindfolded and set B without a blindfold - or vice versa (pseudo-randomised across participants).
What I want to know
Does the number of dropouts (i.e. people who get sick and break up the experiment) differ?
a) Most importantly: Across cakes? I.e. are some cakes more likely to cause participants to quit?
b) Also: Is there an interaction between cake and condition, i.e. does the red velvet cause people to get sick in the blindfolded condition, but not without a blindfold - while it is the other way around for the chocolate cake?
Quick overview with three of the 20 cakes selected:
cakes[cakes$cake %in% c("chocolate", "banoffee", "carrot"), ]

        cake set blindfold dropout nodrop
3  chocolate   A       yes       7     33
6     carrot   A       yes       4     36
17  banoffee   B       yes      23     17
23 chocolate   A        no       1     39
26    carrot   A        no       9     31
37  banoffee   B        no      23     17

set is included in case that should play a role for my analysis. dropout is the number of participants who quit, nodrop the number of participants who did not quit, i.e. the two columns always total to 40 participants. Note that in real life, I do not only have 20 cakes, but 100 stimuli (50 in each set).
Thanks and a virtual piece of cake to everyone pointing me in the right direction!
Solution
As suggested in the answers, restructuring the dataset to single trials and doing a logistic regression was the key. I used the package brms to do it the Bayesian way. With the single-trial structure, I was not only able to include the cakes as random slope and intercept, but also the participants, which I found to explain much more variance than the ckaes - which makes sense. In the end, my model looked like this:
dropout ~ blindfold + (1 + blindfold | participant) + (1 + blindfold | cake)

Thanks for the help!

A: My initial reaction is to use a logistic regression.
First, you would need to restructure your data. In the cake example, you'd create a new dataset with three variables: (1) dropout indicator, (2) cake, and (3) blindfold indicator.  Each row represents a unique person x cake x blindfold combination.
A) Do dropout rates differ by cakes?
You can just compare the residual deviance between the null model and a model with the cake variable.  If the results are significant it means that there is at least one cake with differing dropout rates.
mod <- glm(dropout ~ 1, data=cakes)
mod1 <- glm(dropout ~ factor(cake), data=cakes)

anova(mod, mod1, type="Chisq")

B) Differences based on interaction
Here, you could do something similar by comparing a model with just the main effects and a model with the interaction terms.
mod2 <- glm(dropout ~ factor(cake) + blindfold, data=cakes)
mod3 <- glm(dropout ~ factor(cake)*blindfold, data=cakes)

anova(mod2, mod3, type="Chisq")

If you're interested in comparing specific combinations of cake and blindfold status, you could use the multcomp package in R.  UCLA has a great tutorial.


text:
Q: django humanize timesince do not printing My django view is passing this inside my template:
context={'material':material_id,'inventory_list':inventory,'now_time':datetime.now()

Inside my material object I have this field that is update each new save:
last_update = models.DateTimeField()

And I'm trying to print an humanized time ago in the screen so I'm doing this:
{{now_time | timesince:material.last_update }}

It's not printing anything, despite separately both variables are appearing correctly:
{{now_time}} {{material.last_update}}
OUTPUT:
May 18, 2018, 11:10 a.m. May 18, 2018, 10:45 a.m.

Here is my complete view:
def material_page(request,pk):
try:
    material_id=Material.objects.get(id=pk)
    inventory = InventoryMove.objects.filter(material=material_id).order_by("-date")
    i=0
    for movement in inventory:
        print (inventory[i].date)
        i+=1
except Material.DoesNotExist:
    raise Http404("Material does not exist")
return render(
     request,
    'material_detail.html',
    context={'material':material_id,'inventory_list':inventory,'now_time':datetime.now()}
    )


text:
Q: Syntax error in NMaximize despite following official documentation This is the code I'm trying to run:
NMaximize[ {k, (a + b + c + d + e + f + g + h + i + j + k ==
     1) && (b + 2*c + 3*d + 4*e + 5*f + 6*g + 7*h + 8*i + 9*j + 10*k ==
      6) &&  (b + 4*c + 9*d + 16*e + 25*f + 36*g + 49*h + 64*i +
      81*j + 100*k == 42)}, {a , b, c, d, e, f, g, h, i, j,
   k} \[Element] NonNegativeReals ]

This is the error I'm getting:
NMaximize::ivar: (a|b|c|d|e|f|g|h|i|j|k)\[Element]\[DoubleStruckCapitalR]&&a>=0&&b>=0&&c>=0&&d>=0&&e>=0&&f>=0&&g>=0&&h>=0&&i>=0&&j>=0&&k>=0 is not a valid variable.

The syntax I'm using is NMaximize[{f,cons},x∈reg], which is suggested on the official website.
The f (function) part is just k, the "x∈reg" (region restriction) part is
{a , b, c, d, e, f, g, h, i, j,
       k} \[Element] NonNegativeReals

and the cons (constraints) part is
(a + b + c + d + e + f + g + h + i + j + k ==
         1) && (b + 2*c + 3*d + 4*e + 5*f + 6*g + 7*h + 8*i + 9*j + 10*k ==
          6) &&  (b + 4*c + 9*d + 16*e + 25*f + 36*g + 49*h + 64*i +
          81*j + 100*k == 42)

So where's the issue?

A: Try this
NMaximize[{k, (a + b + c + d + e + f + g + h + i + j + k ==
     1) && (b + 2*c + 3*d + 4*e + 5*f + 6*g + 7*h + 8*i + 9*j +
      10*k == 6) && (b + 4*c + 9*d + 16*e + 25*f + 36*g + 49*h +
      64*i + 81*j + 100*k == 42),
  ## & @@ Thread[{a, b, c, d, e, f, g, h, i, j, k} >= 0]}, {a, b, c, d,
   e, f, g, h, i, j, k}, Reals]

{0.266667, {a -> 0., b -> 0., c -> 0., d -> 0., e -> 0.333333,
  f -> 0.4, g -> 0., h -> 0., i -> 0., j -> 0., k -> 0.266667}}

And you can directly use Maximize, get
{4/15, {a -> 0, b -> 0, c -> 0, d -> 0, e -> 1/3, f -> 2/5, g -> 0, h -> 0, i -> 0, j -> 0, k -> 4/15}}

A: NonNegativeIntegers is not a region,it is just a algebra field.
You can use
NMaximize[{k, a + b + c + d + e + f + g + h + i + j + k == 1,
  b + 2*c + 3*d + 4*e + 5*f + 6*g + 7*h + 8*i + 9*j + 10*k == 6,
  b + 4*c + 9*d + 16*e + 25*f + 36*g + 49*h + 64*i + 81*j + 100*k ==
   42}, {a, b, c, d, e, f, g, h, i, j, k} ∈
  ImplicitRegion[
   Thread[{a, b, c, d, e, f, g, h, i, j, k} >= 0], {a, b, c, d, e, f,
    g, h, i, j, k}]]

Or simpely
NMaximize[{k, a + b + c + d + e + f + g + h + i + j + k == 1,
  b + 2*c + 3*d + 4*e + 5*f + 6*g + 7*h + 8*i + 9*j + 10*k == 6,
  b + 4*c + 9*d + 16*e + 25*f + 36*g + 49*h + 64*i + 81*j + 100*k ==
   42, {a, b, c, d, e, f, g, h, i, j, k} >= 0}, {a, b, c, d, e, f, g,
  h, i, j, k}]

Or
NMaximize[{k, a + b + c + d + e + f + g + h + i + j + k == 1,
  b + 2*c + 3*d + 4*e + 5*f + 6*g + 7*h + 8*i + 9*j + 10*k == 6,
  b + 4*c + 9*d + 16*e + 25*f + 36*g + 49*h + 64*i + 81*j + 100*k ==
   42, {a, b, c, d, e, f, g, h, i, j, k} ∈
   NonNegativeReals}, {a, b, c, d, e, f, g, h, i, j, k}]

etc.


text:
Q: How to use Phone Data service if WiFi is not available? I am making an app and I want it to be allowed to use 3G or any data network when WiFi is not available. How would I implement this? I am using HTTPClients to make calls everytime an SMS is received. It works, but it would be perfect if it could run when WiFi is not available, of course this option would be user defined (Check if you wish to use data network if WiFi is unavailable) so the user has full control.

A: After further research I figured out that it automatically uses 3G resources if you have the correct permission to use 3G or any data network available.


text:
Q: Howto get currentTime inside timeupdate event (apply & bind) How to get curentTime from Html5 Audio.I did not place audio html tag . I just want to do it in typescript.i get TypeError: Cannot read property 'currentTime' of undefined. I think there is something wrong with current context ? how can i fix it with apply & bind or any other technique ?
//player.ts

 audio = new Audio();
btnPlay(){
    this.audio.src = "media/Audio_1.mp3";
    this.audio.load();
    this.audio.play();
    this.audio.addEventListener('timeupdate',this.timeupdate)
 }
timeupdate(e){
  console.log(this.audio.currentTime);
}

A: Make timeupdate an arrow function:
timeupdate = (e) => {
  console.log(this.audio.currentTime);
}

See https://www.typescriptlang.org/docs/handbook/functions.html#this-and-arrow-functions for more information.


text:
Q: How can I limit the filling range in a list plot? This is an example from ListPlot in the Mathematica documentation.
ListPlot[Table[{k,PDF[BinomialDistribution[50, p], k]}, {p, {0.3, 0.5}}, {k, 0, 50}],
  Filling -> Axis, PlotLegends -> {0.3, 0.5}, Joined -> True]

In this example, I want to limit the filling range from 10.5 to 20.8 on x-axis of the blue one and the filling range from 15.2 to 27.4 on x-axis of the yellow one.
Edit
Actually, my lists are:
list1 =
  {{-2.,0.}, {-1.9,0.}, {-1.8,0.}, {-1.7,0.}, {-1.6,0.}, {-1.5,0.}, {-1.4,0.},
   {-1.3,0.}, {-1.2,0.}, {-1.1,0.}, {-1.,0.}, {-0.9,0.}, {-0.8,0.}, {-0.7,0.},
   {-0.6,0.}, {-0.5,0.}, {-0.4,0.}, {-0.3,0.}, {-0.2,0.}, {-0.1, 0.0000270029},
   {0.,0.573}, {0.1, 0.944375}, {0.2, 0.905604}, {0.3, 0.876333}, {0.4,0.856429},
   {0.5,0.842903}, {0.6,0.833816}, {0.7,0.823825}, {0.8,0.82225}, {0.9,0.820646},
   {1.,0.824455}, {1.1,0.820966}, {1.2,0.82971}, {1.3,0.838609}, {1.4,0.833386},
   {1.5,0.847014}, {1.6,0.845375}, {1.7,0.831121}, {1.8,0.858744}, {1.9,0.878679},
   {2.,0.883768}, {2.1,0.895884}, {2.2,0.916524}, {2.3,0.883408}, {2.4,0.820855},
   {2.5,0.812862}, {2.6,0.850007}, {2.7,0.85677}, {2.8,0.917854}, {2.9,0.860092},
   {3.,0.826174}};

list2 =
  {{-2., Indeterminate}, {-1.9, Indeterminate}, {-1.8, Indeterminate},
   {-1.7, Indeterminate}, {-1.6, Indeterminate}, {-1.5, Indeterminate},
   {-1.4, Indeterminate}, {-1.3, Indeterminate}, {-1.2, Indeterminate},
   {-1.1, Indeterminate}, {-1., Indeterminate}, {-0.9, Indeterminate},
   {-0.8, Indeterminate}, {-0.7, Indeterminate}, {-0.6, Indeterminate},
   {-0.5, Indeterminate}, {-0.4, Indeterminate}, {-0.3, Indeterminate},
   {-0.2, Indeterminate}, {-0.1, 0.000978548}, {0., 0.0216139},
   {0.1, 0.0159094}, {0.2, 0.0246127}, {0.3, 0.0432556}, {0.4, .0698127},
   {0.5, 0.100648}, {0.6, 0.13547}, {0.7, 0.171693}, {0.8, 0.210745},
   {0.9, 0.251159}, {1., 0.294236}, {1.1, 0.32755}, {1.2, 0.367015},
   {1.3, 0.398382}, {1.4, 0.402279}, {1.5, 0.405745}, {1.6, 0.370707},
   {1.7, 0.343634}, {1.8, 0.325424}, {1.9, 0.325361}, {2., 0.28044},
   {2.1, 0.330616}, {2.2, 0.272563}, {2.3, 0.281717}, {2.4, 0.37461},
   {2.5, 0.433955}, {2.6, 0.210232}, {2.7, 0.276848}, {2.8, 0.39585},
   {2.9, 0.55642}, {3., 1.53635}};

When the lists are like this, how can I limit the filling ranges along the x-axis from 0.23 to 1.67 in list1 and from 1.23 to 2.34 in list2?

A: Using Plot
Plot[{PDF[BinomialDistribution[50, .3], x],
  PDF[BinomialDistribution[50, .5], x],
  ConditionalExpression[0, .5 <= x <= 20.8],
  ConditionalExpression[0, 15.2 <= x <= 27.4]}, {x, 0, 50},
 Filling -> {1 -> {3}, 2 -> {4}}, PlotLegends -> {0.3, 0.5},
 Evaluated -> True, PlotRange -> All]

Using ListPlot
table1 = Table[{k, PDF[BinomialDistribution[50, p], k]}, {p, {0.3, 0.5}}, {k, 0, 50}];
lim[p_] := Switch[p, .3, {.5, 20.8}, .5, {15.2, 27.4}];
table2 = Table[{k, 0}, {p, {.3, .5}}, {k, lim[p][[1]], lim[p][[2]]}];

ListPlot[Join @@ {table1, table2}, Filling -> {1 -> {3}, 2 -> {4}},
 PlotLegends -> {.3, .5}, Joined -> True, PlotRange -> All]

Update: for "the real question", you can do
table1 = {list1, list2};
l = {{.23, 1.67}, {1.23, 2, 34}};
table2 = Table[{k, 0}, {p, 2}, {k,l[[p,1]],l[[p,2]], (l[[p,2]] - l[[p,1]])/10}];

ListPlot[Join @@ {table1, table2}, Filling -> {1 -> {3}, 2 -> {4}},
 PlotLegends -> {"list1", "list2"}, Joined -> True, PlotRange -> All]

A: You can split your data (not a good way, but it does the job)
data = Table[{k, PDF[BinomialDistribution[50, 0.3], k]}, {k, 0, 30}];
d1 = Select[data, #[[1]] <= 15 &];
d2 = Select[data, #[[1]] >= 15 &];
Show[ListLinePlot[d1], ListLinePlot[d2, Filling -> Axis],
PlotRange -> All]

For any set of data and a range x1,x2
filling[list__, x1_, x2_, col_] := Show[ListLinePlot[list, PlotStyle -> col],
          ListLinePlot[Select[list, x1 <= #[[1]] <= x2 &], PlotStyle -> None, Filling -> 0,
          FillingStyle -> Directive[Opacity[0.5], col]], PlotRange -> All]

Show[filling[list1, 0.23, 1.67, Blue],filling[list2, 1.23, 2.34, Red], Frame -> True]


text:
Q: The following code giving java.lang.NoSuchMethodError: main Exception in thread "main" in Eclipse package Demo;

public class CurrentDirectoryExample {

    public static void main(String args[]) {

        String current = System.getProperty("user.dir");
        System.out.println("Current working directory in Java : " + current);

    }
}

A: This is bit strange exception as the actual problem differs with the displayed error. You should check whether the project(the program is running in) having any build errors. If any such error exists like refered lib is not available etc, the program will not run.
Concentrate on project for any build errors.


text:
Q: how to validate same form id in javascript? I am trying to validate two forms with same id. for first its working fine. but for second its not validating why?
Here, i have given the example code:
function cc(id){
    if(document.getElementById(id).value.toUpperCase()==(id)){
        document.getElementById(id).style.backgroundColor = "green";
    }else{
       document.getElementById(id).style.backgroundColor = "red";
    }
}

<form id="save"  method="post">
<input type="text" name="A"  id="C" class="textbox" onKeyUp="cc(id,this, 'H')"  maxlength="1"  />
<input type="text" name="A"  id="C" class="textbox" onKeyUp="cc(id,this, 'H')"  maxlength="1"  />
</form>

http://jsbin.com/viraqixicigi/6/edit

A: Use the this argument to operate on the target of the event:
function cc(element, goodValue){
    if(element.value.toUpperCase() == goodValue){
        element.style.backgroundColor = "green";
    }else{
        element.style.backgroundColor = "red";
    }
}

<form id="save"  method="post">
<input type="text" name="A"  id="C" class="textbox" onKeyUp="cc(this, 'H')"  maxlength="1"  />
<input type="text" name="A"  id="C" class="textbox" onKeyUp="cc(this, 'H')"  maxlength="1"  />
</form>

DEMO


text:
Q: Creating an interactive choropleth map using Plotly (R) I've scoured the internet for my first attempt at creating an interactive map and I've hit a wall. I'm in no way married to this way of creating an interactive map, so if anyone has any other tried and true method that doesn't use plotly, I would love to hear it.
I'm trying to take my panel data and create a "heat map" of how counties change over time. I've simplified for my reproducible example to 3 counties, 3 years, and one variable. I believe the problem is that the thing that I am trying to change over time is the fill for the polygon layer. The outcome of this code is entertaining but obviously not what I'm looking for. Any help, resources, or guidance would be appreciated. Thanks!
library(tidyverse)
wy<-map_data("state", region="wyoming")
county<- map_data("county", region = "wyoming")

#create reprex df
subregion <- rep(c("albany", "big horn", "converse"), each=3)

Year <- rep(c(2004, 2005, 2006), times =3)

Emp<- runif(9)

panel <- data.frame(subregion, Year, Emp)

#Combine this with map data
combined <- merge(panel, county, by= "subregion")

#Create map
x <-ggplot()+
  geom_polygon(data=wy, aes(x=long, y=lat, group=group), fill=NA, color="royalblue")+
  geom_polygon(data=county, aes(x=long, y=lat, group=group),fill=NA, color="dodgerblue1")+
  geom_polygon(data=combined, aes(x=long, y=lat, group=group,fill=Emp, frame = Year))+
  theme_void()

ggplotly(x)


text:
Q: forcing cursor be automatically placed at left end of username field in registration form Hello
in the registration form of my WordPress based website, i need when user clicks on any field (for example username field), the cursor be automatically placed at left end in that field & the keyboard be automatically on ENG-US.
 I need this because some of my users have right to left language and perhaps their keyboard is set to right-to-left language when they open registration page & so when they click on any field, the cursor would be placed on the right end in the field (which is undesirable & the user must manually press Ctrl+shift to make cursor be located at the left of the field.)
 I want to know whether the above is possible (forcing cursor to be automatically placed at the left end of the field and language be set to ENG-US)? I don't know what code should I use and in which file on my WordPress site.

A: You can use the dir="rtl" on the input.
<input dir="rtl" id="foo"/>

or
by css
#foo{
  direction: rtl;  /* Right to Left */
}

but if you want to do for some countries , you need to check by location with the help of GEO location or google location.


text:
Q: Are there Fourier Eigenfunctions "Outside" an Interval? 1) It is known that no function vanishing outside an interval $-a < x < a  $ has a Fourier transform with compact support.  $(x,a \in \mathbb{R})$ However, are there Fourier transform pairs which both vanish inside the interval $-a < x < a$, and are Fourier transform eigenfunctions with this property?
In other words, for all $f(x)$:
$$  \int_{-\infty}^{\infty} f(x) \Pi (\frac{x}{a})e^{-i2 \pi xy} \, dx \neq  \lambda f(x) \Pi (\frac{x}{a})$$
However, are there functions, $g(x)$, solving this?:
$$  \int_{-\infty}^{\infty} g(x) (1-\Pi (\frac{x}{a}))e^{-i2 \pi xy} \, dx =  \lambda g(x) (1-\Pi (\frac{x}{a}))$$
$N.B.$ - $\Pi (\frac{x}{a})$ is the $rect(x)$ function scaled to a width of $a$.
2) Are there keywords or names for this topic, that I might do more research?  $i.e.$ Is there a specific name for this domain "outside an interval?"


text:
Q: Copy Webpack Plugin pattern for maintaining folder structure I am using thge copy-webpack-plugin for webapck to copy files from my src folder to the dist folder.  I want the process to maintain the folder structure when doing so.
My folder structure is as follows:
|- src
|-components
|- my-component
|-view.html
I would like the plugin to copy only html files in the component folder to the dist folder maintaining the folder structure above.
I have accomplished the following so far:
const path = require('path');
const CopyPlugin = require("copy-webpack-plugin");

module.exports = {
    ...
    plugins: [
        new CopyPlugin({
            patterns: [
                { from: "./src/components/*/*.html", to: "[name].html" },
            ],
        }),
    ],
};

The above simply copies the html files to the dist folder, the original folder structure is lost.
I would need to get the folder name where the html resides in and use that in the "to" patrtern.
Can this be done?

A: Please see this example from the CopyWebpackPlugin Documentation.
module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        {
          from: "**/*",
          to: "[path][name].[ext]",
          context: "src/"
        },
      ],
    }),
  ],
};

src/ is the relative path here. To use an absolute path start with a slash (/src/).
UPDATE: I changed the code example to fit your circumstances.