text:
Q: What does opening/closing curly braces without any keyword mean in PHP? I just saw this little piece of code and now I'm a bit curious about the meaning of that... is it just used for code indentation?
form_buffer('start');
{
  form_validation();
}
form_buffer('end');

A: I agree, it could be just personal notation from the developer.


text:
Q: How to Use Background Image in BootStrap .carousel-control Can you please let me know how I can update the .carousel-control CSS to use a background image like This Arrows image?
I tried to update this CSS code by adding the
position:absolute;
display:none;
top:50%;
margin-top:-28px;
z-index:60;
height: 50px;
width: 51px;
background-image: url(http://www.promap.ca/img/arrows.png);
/*max-height:20%;
max-width:12%;
background-size:200% 200%;*/

To following code but it didn't go through!
.carousel-control {
    position: absolute;
    top: 40%;
    left: 15px;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    font-size: 60px;
    font-weight: 100;
    line-height: 30px;
    color: #ffffff;
    text-align: center;
    background: #222222;
    border: 3px solid #ffffff;
    -webkit-border-radius: 23px;
    -moz-border-radius: 23px;
     border-radius: 23px;
     opacity: 0.5;
     filter: alpha(opacity=50);
 }

.carousel-control.right {
    right: 15px;
    left: auto;
}

.carousel-control:hover,
.carousel-control:focus {
    color: #ffffff;
    text-decoration: none;
    opacity: 0.9;
    filter: alpha(opacity=90);
}

A: Bootstrap Carousel Orientation
I'm also not sure where you want this image to go.  Where it gets put is very important
Look at this Bootply to see where each of the css background colors gets applied - that's where your image will go:
.carousel .container {
  background-color: red;
}

.carousel-control {
  background-color: green;
}

.carousel .item {
  background-color: black;
}

.carousel-caption h1,
.carousel-caption .lead {
    background-color: yellow;
}

Customize Carousel Arrows
I'm guessing that you're trying to customize the arrows specifically since that's the name of your image file.
By Default the arrow image is just a < or > character by using glyphs to specify the content of the anchor tag with the before selector as seen in the bootstrap.css file here:
.carousel-control .icon-prev:before { content: '\2039'; }
.carousel-control .icon-next:before { content: '\203a'; }

You can add whatever content you'd like for left and right arrows by specifying it in the innerHtml of the arrow anchor tags

...

If you have a different image for the next arrow, you can use that, or you can apply a css class to it and flip it horizontally with the following css:
.flipped {
    -webkit-transform: scale(-1, 1);
     -khtml-transform: scale(-1, 1);
       -moz-transform: scale(-1, 1);
        -ms-transform: scale(-1, 1);
         -o-transform: scale(-1, 1);
            transform: scale(-1, 1);
}

Also, add some css so the carousel image defaults don't apply to your arrows:
#myCarousel a img {
    width:  20px !important;
    height: 40px !important;
}

Demo in jsFiddle

A: If you want to use background image and hide default icons
.carousel-control .icon-prev:before { content: ''; }
.carousel-control .icon-next:before { content: ''; }

A: In your code there is broken link and there is no quotes in address.
background-image: url('http://www.promap.ca/img/arrows.png');

A: .carousel-control {
width: 54px;
height: 54px;
background: url(images/arrow_slide_sprite.png) -10px 0 no-repeat;
display: block;
position: absolute;
top: 50%;
margin-top: -27px;
z-index: 10;
cursor: pointer;

}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Создание пагинации для таблицы на Bootstrap Использую Bootstrap для верстки. Есть необходимость создать pagginator для моих таблиц. Нашел решение, которое меня заинтересовало. Только не могу понять, как его внедрить на свою страницу, так как немного новичок в вебе.
Буду рад, если кто поможет с кодом. Возможно, кто-то подскажет другие варианты. Спасибо.
Вот пример моей страницы:
<!DOCTYPE html>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

    <title>

    </title>
    <link rel="icon" href="../../../resources/images/logoGM_.ico" type="image/x-icon">
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

    <link href="/resources/html/css/mystyle.css" rel="stylesheet">


text:
Q: Computing and simulating average marginal effect standard error using Delta Method with reproducible codes I am trying to simulate calculating Average Marginal Effects on a basic linear regression with interaction on a binary variable and compare the empirical standard deviation I get from simulations and the analytic standard error of the Average Marginal Effect I calculate using the Delta Method. But I keep getting a standard error that is way too small.
Below is my attempt with detailed explanation of each step:

*

*Data Generation codes:

I am simulating data of the form:
$y = \beta_0 + \beta_1 x_1 + \beta_2 x_1 x_2 + \epsilon$
# import packages
import numpy as np
import pandas as pd
import statsmodels.formula.api as smf

def make_data():

    # preset beta values
    beta0 = 1
    beta1 = 2
    beta2 = 3
    betas = np.asarray([beta0, beta1, beta2])

    n = 500
    x1 = np.random.choice(2, size=[n, 1])  # x1 is binary!
    x2 = np.random.normal(1, 1, size=[n, 1])
    x1x2 = x1*x2
    X = np.hstack([x1, x2, x1x2])
    epsilon = np.random.normal(0, 0.1, size=[n, 1])
    y = beta0 + x1*beta1 + x1x2*beta2 + epsilon

    data = np.hstack([y, X])
    df = pd.DataFrame(data=data, columns=['y', 'x1', 'x2', 'x1x2'])

    return df, x1, x2, x1x2

df, x1, x2, x1x2 = make_data()

*Calculate AME (average marginal effect)

I calculate the AME by difference formula for binary variables taken from the official doc of STATA here:
$\frac{1}{n} \sum_{i=1}^n (\hat{\beta}_0 + \hat{\beta}_1 (1) + \hat{\beta}_2 (1) x_2) - (\hat{\beta}_0 + \hat{\beta}_1 (0) + \hat{\beta}_2 (0) x_2)  $
def compute_ame(df, x1, x2, x1x2):

    formula = "y ~ x1 + x1x2"
    model = smf.ols(formula, data=df).fit()

    return np.mean( model.predict(df.assign(**{"x1":1, "x1x2":x2})) - model.predict(df.assign(**{"x1":0, "x1x2":0})) )

compute_ame(df, x1, x2, x1x2)

The output value is around 5, which makes sense since $\beta_1 = 2, \beta_2 = 3$, and $x_2 $ has a mean value of $1$. So from the equation, $y = \beta_0 + \beta_1 x_1 + \beta_2 x_1 x_2 + \epsilon$, turning $x_1$ on increases $y$ by 5.

*Get the covariance matrix of the model

formula = "y ~ x1 + x1x2"
model = smf.ols(formula, data=df).fit()

vcov = model.cov_params().values

*Get the gradient of AME with respect to each $\beta$'s

$\frac{\partial}{\partial \beta} \frac{1}{n} \sum_{i=1}^n (\hat{\beta}_0 + \hat{\beta}_1 (1) + \hat{\beta}_2 (1) x_2) - (\hat{\beta}_0 + \hat{\beta}_1 (0) + \hat{\beta}_2 (0) x_2)  $
$= \big[ (1-1) \enspace\enspace 1  \enspace\enspace \frac{1}{n} \sum_{i=1}^n x_2   \big]$
We have one row matrix here because we are getting AME for one variable, namely the binary variable $x_1$
grad = np.asarray([0, 1, np.mean(x2)]).reshape([-1, 1])

*Calculate the standard error:

$(grad)^T (vcov) (grad)$
result = grad.T @ vcov @ grad

*Run some simulations to get many AME values so we can calculate their standard deviations:

ames = []
for i in range(1000):

    df, x1, x2, x1x2 = make_data()
    ame = compute_ame(df, x1, x2, x1x2)

    ames.append(ame)

np.std(ames)

*Compare the results:

print(np.std(ames))  # 0.13759581829
print(np.sqrt(result[0][0]))  # 0.0091748250468 from step 5

The analytic standard error is REALLY small.
What am I doing wrong here?
UPDATES (for answer by user4422):
I separate out variable generation from adding Gaussian noise to re-do the simulation as was advised:
def make_data():

    # preset beta values
    beta0 = 1
    beta1 = 2
    beta2 = 3
    betas = np.asarray([beta0, beta1, beta2])

    n = 500
    x1 = np.random.choice(2, size=[n, 1])  # x1 is binary!
    x2 = np.random.normal(1, 1, size=[n, 1])
    x1x2 = x1*x2
    X = np.hstack([x1, x2, x1x2])
    # COMMENTED OUT NOISING CODES
    # epsilon = np.random.normal(0, 0.1, size=[n, 1])
    y = beta0 + x1*beta1 + x1x2*beta2 # + epsilon

    data = np.hstack([y, X])
    df = pd.DataFrame(data=data, columns=['y', 'x1', 'x2', 'x1x2'])

    return df, x1, x2, x1x2

def add_noise(df):

    n = 500
    epsilon = np.random.normal(0, 0.1, size=n)
    df_noised = df.copy()
    df_noised['y'] += epsilon

    return df_noised

The for loop now changes to first generate dataframe and then add new noise in each loop:
ames = []

df, x1, x2, x1x2 = make_data()  # generate variables here first

for i in range(1000):

    df_noised = add_noise(df)  # only change the noise component
    ame = compute_ame(df_noised, x1, x2, x1x2)
    ames.append(ame)

np.std(ames)

The standard deviations are similar now
print(np.std(ames))  # 0.0091397150909881
print(np.sqrt(result[0][0]))  # 0.0091748250468 from step 5

A: One thing you are doing wrong is that you do not take the square root of result: you are comparing a variance with a standard deviation.
The second thing, if I understood your code, is that in the computation of result the variance is generated only by the parameter estimation error, while in the computation of np.std(ames) the variance is generated not only by estimation error but also by sampling variability in the variables x1 and x2 (variability in the latter has a double effect in your model, as it contributes also to the average effect). To make a proper comparison you need to re-generate only the error terms epsilon (not the variables) in each simulation.
Let me provide a little more context: the standard errors computed with result are valid in a "fixed regressor" setting (either you have a small sample and the design matrix is fixed, or you have a large sample in which the statistics that depend on the design matrix converge in probability to a constant). If you run a bootstrap (which is what you call a simulation) to reproduce the standard errors of a "fixed regressor" setting, then you only need to randomly draw the errors (the regressors remain fixed). Instead, by randomly drawing also the regressors, you compute the standard errors for a "random regressor" setting. See, for example, this paper (p.254). This is not wrong, but since you want to reproduce the same result with two different methods, you need to keep the "fixed regressor" hypothesis in place.
Also note that, in your setting, not only "random regressors" inflate the variance of the OLS estimates, but they also inflate the variability of the average effect, which depends on the average value of one regressor.


text:
Q: Canceling Threads I have an application that uses 20 threads. It's an email client that uses threads to mail from.
Currently the threads are created in the main thread. But I am wondering, what if I want to cancel the whole operation? The only way I can see of doing it is killing the main thread ... thus ending the program.
Would I have to create a thread that encapsulates the threads for mailing so I can kill the encapsulating thread?
I am currently using BackgroundWorker by the way and it's a WF application.

A: If you are using a BackgroundWorker then you already have all of the infrastructure you need to cancel the operation.  Simply set WorkerSupportsCancellation to true on the BackgroundWorker, and invoke the worker's CancelAsync method when you want to cancel.
Obviously you have to write the worker code to honour the cancellation.  You do this by checking the CancellationPending property of the BackgroundWorker.
MSDN has an example of using this property.

Note - I am a bit confused by the combination of BackgroundWorker and 20 threads; a BackgroundWorker only uses one thread by itself.  Are you spinning off 20 BackgroundWorkers?  If so, how do you ensure that they're properly disposed?  If you need that much concurrency in a Winforms app then it's better to use asynchronous delegates or the Thread Pool.
If you are creating actual threads, one common way of implementing a cancellation flag is to use a ManualResetEvent.  If you wait on this event with zero timeout, it acts as a thread-safe status flag.  An example usage would be:
ManualResetEvent cancelEvent = new ManualResetEvent(false);
for (int i = 0; i < 20; i++)
{
    ThreadPool.QueueUserWorkItem(s =>
    {
        // Do some work
        if (cancelEvent.WaitOne(0, true))
            return;
        // Do some more work
        // etc.
    });
}

Then at some point later if you write cancelEvent.Set(), every worker will stop its work as soon as it hits the status check.


text:
Q: Blocking empty strings to be written into SQL database table I have a program that will update a production database on data point change. However, the embedded script in the program performs a blanket update of an entire row, but what I want it to do is just to partially update values in specified columns. I do not have the time to learn the script and make whatever changes I need, so I tried setting the other columns to Not Null in attempt to block the "" values written from the program.
ALTER TABLE `scheduling`
CHANGE COLUMN `Priority` `Priority` VARCHAR(5) NOT NULL ,
CHANGE COLUMN `PurchaseOrder` `PurchaseOrder` VARCHAR(45) NOT NULL ,
CHANGE COLUMN `PartID` `PartID` VARCHAR(45) NOT NULL ,
CHANGE COLUMN `OrderQty` `OrderQty` VARCHAR(20) NOT NULL ,
CHANGE COLUMN `DeliveryDate` `DeliveryDate` VARCHAR(20) NOT NULL ,
CHANGE COLUMN `ReadyToRun` `ReadyToRun` VARCHAR(10) NOT NULL ,
CHANGE COLUMN `LF5` `LF5` VARCHAR(45) NOT NULL ,
CHANGE COLUMN `CompletionTime` `CompletionTime` VARCHAR(45) NOT NULL ;

But this method did not work, the values in the database still got overwritten by "" from the script. Is there a way to prevent columns in the database to be overwritten by empty values?
Here is my database table after the blanket update:

The intention of the update is just to use work order as PK and update the associated completion time.
I've located the update query in the script:
method ODBCConnection.Update (row)
{
    local       query = "";
    local       n, len;
    local       value, retval, cols;

    if (!row.__primary_key || !row..(row.__primary_key))
    {
        error ("Update: Row is not identifiable - primary key not set");
    }
    else
    {
        query = string ("update ", row.__table, " set ");

        len = length(row.__columns);
        n = 0;
        with name in row.__columns do
        {
            if (name != row.__primary_key)
            {
                value = row..name;
                query = string (query,
                                n > 0 ? ", " : "",
                                name, " = ", ODBC_ValueString(value));
                n++;
            }
        }
        query = string (query, " where ", row.__primary_key, " = ",
                        ODBC_ValueString (row..(row.__primary_key)));

//      princ (query, "\n");

        .Statement().FreeStmt (SQL_CLOSE);
        retval = .Query (query);
        if (retval != -1)
            retval = .StoreResult();
        else
            error (.Error());
    }
    retval;
}

And I changed the query part to:
if (name != row.__primary_key)
        {
                            name = "CompletionTime";
            value = row..name;
            query = string (query, name, " = ", ODBC_ValueString(value));

        }

That did not work either.


text:
Q: my title and navigation won't line up on the same line enter image description hereI am trying to place my name and my navigation link on the same line when my screen hit 768px but it would not line up after setting their display to inline block. can anyone help please and thank. This is my repository.  https://github.com/corry010/mobile-first-reponsive-project
tried using just inline as display. but it wouldn't work also played around with the code but can't figure it out.

.container {
  width: 80%;
  margin: 0 auto;
  /* max-width: 1000px; will change it later */
}

.name {
  float: left;
}

.main-nav {
  float: right;
}

.main-nav li {
  float: left;
}

.name,
.main-nav,
.navigation,
.main-nav li {
  display: inline-block;
}

Cornelis Etta

home

portfolio

interest

contact

My name and navigation should be on the same line in a 768 screen.

A: You can use a flex layout to get items aligned side-by-side and the add align-items: center; to have items within a flexbox centred.
Please add the media query when you integrate with your site.

.container {
  width: 80%;
  margin: 0 auto;
  display: flex;
  align-items: center;
}

.name {
  flex-grow: 1;
  margin: 0;
}

ul {
  padding: 0;
  margin: 0;
}

.main-nav li {
  display: inline-block;
}

Cornelis Etta

home

portfolio

interest

contact


text:
Q: HQL inline query Specific to hibernate i am newbie. so please pardon me as if i am asking basic stuff. Though i can directly use SQL and make things complete I wants to convert the herewith mentioned complex inline query in HQL. Can anyone Quickly guide me how to do it. i.e which features do i need to use etc.
Select c.DOCUMENT_TITLE_EN, d.* From
(Select a.*, b.AOB_SUPPORTED_DOCUMENT_ID from
(Select act.*
from ACTIVITIES act inner join CATEGORIES cat
on act.CATEGORIES_ID=cat.CATEGORIES_ID
Where cat.AOB_CATEGORIES_ID in (1)
and act.USER_TYPE= '1') a left outer join ACTIVITY_ATTACHMENT b
on a.ACTIVITIES_ID = b.ACTIVITIES_ID) d
Left Outer Join SUPPORTED_DOCUMENT c
on d.SUPPORTED_DOCUMENT_ID = c.SUPPORTED_DOCUMENT_ID ;

A: You have to create hibernate entity for each table and java attributes for database columns.
Then in hql all you need is to replace table names with entity names and column names with attributes names.

A: use this method ...
session.createQuery();


text:
Q: Spring data mongodb, how to set SSL? I have so far failed to find a good explanation/doc on the topic.
I am using
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-mongodb</artifactId>
    <version>1.9.5.RELEASE</version>
</dependency>

and my code looks like this:
   @Bean
   public MongoClientFactoryBean mongo() {
      MongoClientFactoryBean mongo = new MongoClientFactoryBean();
      mongo.setHost(host);
      mongo.setPort(port);
      mongo.setCredentials(new MongoCredential[]{MongoCredential.createCredential(username, database, password.toCharArray())});
      return mongo;
   }

   @Bean
   public MongoTemplate mongoTemplate(Mongo mongo) throws Exception {
      return new MongoTemplate(mongo, database);
   }

Do you know how I should configure SSL for this?  And can I allow invalid certificate?
The equivalent mongo command line would be
mongo --ssl --sslAllowInvalidCertificates --host <host> --port <port>

A: If you just want to connect your spring boot app with mongodb, you can use the keyStore and trustStore with java code. So you dont have to add your certificate via command line. If you are using cloud foundry you can connect your app with mongodbServices and then you have all the credentials you need in System.getEnv("VCAP_SERVICES").
@Configuration
public class MongoConfiguration extends AbstractMongoConfiguration {
    private static Log logger = LogFactory.getLog(MongoConfiguration.class);
    @Value("${spring.data.mongodb.database}")
    private String defaultDatabase; //database you want to connect
    private String host;
    private int port;
    private String authenticationDb; //usually admin
    private String username;
    private char[] password;
    private String certificateDecoded; //your CA Certifcate decoded (starts with BEGIN CERTIFICATE)

    public MongoConfiguration() {
        //method for credentials initialization
    }

    //you can't set replicaset=replset in mongooptions so if you want set replicaset, you have to use
    // customEditorConfigurer in combintaion with class that implementsPropertyEditorRegistrar
    @Bean
    public static CustomEditorConfigurer customEditorConfigurer(){
        CustomEditorConfigurer configurer = new CustomEditorConfigurer();
        configurer.setPropertyEditorRegistrars(
                new PropertyEditorRegistrar[]{new ServerAddressPropertyEditorRegistrar()});
        return configurer;
    }

    @Override
    protected String getDatabaseName() {
        return authenticationDb;
    }

    @Override
    @Bean
    public MongoClient mongoClient() {
        MongoClient mongoClient = new MongoClient(Arrays.asList(new ServerAddress(host, port)), mongoCredentials(), mongoClientOptions());
        return mongoClient;
    }

    @Bean
    public MongoClientOptions mongoClientOptions() {
        MongoClientOptions.Builder mongoClientOptions = MongoClientOptions.builder().sslInvalidHostNameAllowed(true).sslEnabled(true);
        try {
            InputStream inputStream = new ByteArrayInputStream(certificateDecoded.getBytes(StandardCharsets.UTF_8));
            CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
            X509Certificate caCert = (X509Certificate) certificateFactory.generateCertificate(inputStream);

            TrustManagerFactory trustManagerFactory = TrustManagerFactory
                    .getInstance(TrustManagerFactory.getDefaultAlgorithm());
            KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
            keyStore.load(null); // You don't need the KeyStore instance to come from a file.
            keyStore.setCertificateEntry("caCert", caCert);

            trustManagerFactory.init(keyStore);

            SSLContext sslContext = SSLContext.getInstance("TLS");
            sslContext.init(null, trustManagerFactory.getTrustManagers(), null);
            mongoClientOptions.sslContext(sslContext);
            mongoClientOptions.sslInvalidHostNameAllowed(true);
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }

        return mongoClientOptions.build();
    }

    private MongoCredential mongoCredentials() {
        return MongoCredential.createCredential(username, authenticationDb, password);
    }

//With MongoTemplate you have access to db.
    @Bean
    public MongoTemplate mongoTemplate() {
        SimpleMongoDbFactory factory = new SimpleMongoDbFactory(mongoClient(), defaultDatabase);
        return new MongoClient(factory);

    }
}

public final class ServerAddressPropertyEditorRegistrar implements PropertyEditorRegistrar {
    @Override
    public void registerCustomEditors(PropertyEditorRegistry registry) {
        registry.registerCustomEditor(ServerAddress[].class, new ServerAddressPropertyEditor());
    }
}

A: Spring Boot 2.3.4 and Reactive Mongo in Eclipse:
pfx goes into src/test/resources
  @Bean @Profile("dev")
  public MongoClientSettings mongoClientSettingsDev() throws NoSuchAlgorithmException {
    System.setProperty ("javax.net.ssl.keyStore","target/test-classes/xxx.pfx");
    System.setProperty ("javax.net.ssl.keyStorePassword","xxx");
    SSLContext sslContext = SSLContext.getDefault();
    MongoClientSettings settings = MongoClientSettings.builder()
                                                      .applyToSslSettings(builder -> {
                                                        builder.enabled(true);
                                                        builder.context(sslContext);
                                                      })
                                                      .build();
    return settings;
  }

bootstrap.yml for connection with x.509:
spring:
  data:
    mongodb:
      database: database_name
      uri: mongodb://CN=xxx.xxx.com@cloud.xxx.com:62017/?authMechanism=MONGODB-X509&tls=true&authSource=$external

Update for Spring Boot 2.4.5
  @Bean @Profile("dev")
  public MongoClientSettings mongoClientSettingsDev(
    MongoProperties properties,
    Environment environment
  ) throws NoSuchAlgorithmException {
    System.setProperty ("javax.net.ssl.keyStore","target/test-classes/xxx.pfx");
    System.setProperty ("javax.net.ssl.keyStorePassword","xxx");
    SSLContext sslContext = SSLContext.getDefault();
    MongoClientSettings.Builder builder = MongoClientSettings.builder();
    builder.applyToSslSettings(b -> {
      b.enabled(true);
      b.context(sslContext);
    });
    new MongoPropertiesClientSettingsBuilderCustomizer(properties, environment).customize(builder);
    return builder.build();
  }

Another way of setting the SSLContext:
Resource resource = new ClassPathResource("xxx.pfx");
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(resource.getInputStream(), "xxx".toCharArray());
SSLContext sslContext = SSLContexts.custom().loadKeyMaterial(ks, "xxx".toCharArray()).build();

A: It is explained in the docs : please refer below :
http://mongodb.github.io/mongo-java-driver/3.0/driver/reference/connecting/ssl/?_ga=1.122423051.1001600813.1475930911
Also following configuration can be used to enable it
    @Bean
    public  MongoClientOptions mongoClientOptions(){
        System.setProperty ("javax.net.ssl.keyStore","<<PATH TO KEYSTOR >>");
        System.setProperty ("javax.net.ssl.keyStorePassword","PASSWORD");
        MongoClientOptions.Builder builder = MongoClientOptions.builder();
        MongoClientOptions options=builder.sslEnabled(true).build();
        return options;
    }

pass the mongo client options to MongoClient instance as an argument
public MongoClient(ServerAddress addr, MongoClientOptions options) {
        super(addr, options);
    }

Adding further, when mongo processs is started with
mongo
    --ssl --sslAllowInvalidCertificates --host  --port
clients connecting to the mongo process dont have to set any options to support this.

A: You can also build the ssl enabled mongo instance in the following way.
public @Bean MongoClient mongoClient() throws Exception {
    return new MongoClient(new MongoClientURI("mongodb://username:password@host:port/db?ssl=true"));
}

If you using spring boot then it can be configurable in application.properties or application.yml in the following way
spring.data.mongodb.uri=mongodb://username:password@host:port/db?ssl=true

A: Create a Bean as below and use where ever needed.
@Configuration
@ComponentScan(basePackages = "XXXXX")
@EnableMongoRepositories({ "XXXXXX" })
public class ApplicationConfig {
System.setProperty ("javax.net.ssl.keyStore", "<CERT>.keystore");
System.setProperty ("javax.net.ssl.keyStorePassword","<password>");

MongoCredential credential = MongoCredential.createMongoX509Credential(
            "C=US,ST=XXXXXXX,O=XXXXXX... "
            );
MongoClientSettings.Builder settings = MongoClientSettings.builder();
settings.credential(credential);

SSLContext sslContext = SSLContext.getDefault();
MongoClientSettings settings = MongoClientSettings.builder()
.applyToSslSettings(builder -> {
                builder.enabled(true);
                builder.context(sslContext);}).credential(credential).applyConnectionString(new     ConnectionString("mongodb://<host>:<port>/?authMechanism=MONGODB-X509&ssl=true"))
                                                      .build();
com.mongodb.client.MongoClient client = MongoClients.create(settings);
SimpleMongoClientDatabaseFactory factory = new     SimpleMongoClientDatabaseFactory(client, <database>);
MongoTemplate mongoTemplate = new MongoTemplate(factory);
return mongoTemplate;
    }
}


text:
Q: Capture screen of Windows store App Is it possible to capture the contents of running Windows store app? I need to capture the entire screen or a user defined rectangular area.

*

*The application will provide share option

*When the application is running and share option is selected, I want to get the screen shot periodically say 4 times in a second

*This screen shot image will be posted to server, which will store the same

A: It's now possible in Windows 8.1 to capture the screen of a Store App. You need to use the RenderTargetBitmap class.
You can find an example here:
http://mariusbancila.ro/blog/2013/11/05/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1/
Hope it helps.

A: You can't capture screen programatically. See the below threads from MSDN.
Programmatically take snap shot Windows RT.
How to capture screen in Metro app?

A: There is no built-in mechanism to render Windows 8 XAML UI to a bitmap in Windows 8.0. Depending on how complicated your UI is you could implement your own composition engine to render your UI to a bitmap using Direct2D or use the WinRT XAML Toolkit WriteableBitmap.Render() method implementation which has a limited support for doing what you ask (it doesn't render all types of controls, doesn't support RenderTransform, etc.). You could update it though to add support for the missing features.
Windows 8.1 APIs include the new 'RenderTargetBitmap' class that allows to render to a bitmap with its RenderAsync methods.


text:
Q: cv2.addWeighted except some color I want overlay two images except specified color(it is black color in my case). I already wrote some code for this.
def overlay_two_image(image, overlay):
    result = image.copy()
    mask = np.full(image.shape, False)
    for i in range(image.shape[0]):
        for j in range(image.shape[1]):
            if not np.array_equal(overlay[i, j], [0, 0, 0]):
                mask[i, j] = True
    result[mask] = image[mask] * 0.5 + overlay[mask] * 0.5
    return result

OK it works. But I don't think this is a good solution. This is terribly slow and it seems not pythonic. This takes about 5 seconds with (1024, 1024, 3) image.
Are there more efficient way? Are there along-the-axis version of array_equal in numpy? Are there internal functions exactly do this in OpenCV? Or are there more efficient algorithm?
EDIT: Above code doesn't work when color to ignore is other than black.

A: Approach #1
Here's a generalized one to take care of generic ignore-color parameter -
def overlay_two_image(image, overlay, ignore_color=[0,0,0]):
    ignore_color = np.asarray(ignore_color)
    mask = ~(overlay==ignore_color).all(-1)
    # Or mask = (overlay!=ignore_color).any(-1)
    out = image.copy()
    out[mask] = image[mask] * 0.5 + overlay[mask] * 0.5
    return out

Approach #2
Use np.where to make it more pythonic -
def overlay_two_image_v2(image, overlay, ignore_color=[0,0,0]):
    ignore_color = np.asarray(ignore_color)
    mask = (overlay==ignore_color).all(-1,keepdims=True)
    out = np.where(mask,image,(image * 0.5 + overlay * 0.5).astype(image.dtype))
    return out

Approach #3
Use views for memory and hence performance efficiency -
# https://stackoverflow.com/a/45313353/ @Divakar
def view1D(a, b): # a, b are arrays
    a = np.ascontiguousarray(a)
    b = np.ascontiguousarray(b)
    void_dt = np.dtype((np.void, a.dtype.itemsize * a.shape[1]))
    return a.view(void_dt).ravel(),  b.view(void_dt).ravel()

def overlay_two_image_v3(image, overlay, ignore_color=[0,0,0]):
    ignore_color = np.asarray(ignore_color)
    O,I = view1D(overlay.reshape(-1,overlay.shape[-1]),ignore_color)
    mask = (O==I).reshape(overlay.shape[:2])[...,None]
    out = np.where(mask,image,(image * 0.5 + overlay * 0.5).astype(image.dtype))
    return out

Make use of numexpr module for further boost -
import numexpr as ne

def overlay_two_image_v3_numexpr(image, overlay, ignore_color=[0,0,0]):
    ignore_color = np.asarray(ignore_color)
    O,I = view1D(overlay.reshape(-1,overlay.shape[-1]),ignore_color)
    mask = (O==I).reshape(overlay.shape[:2])[...,None]
    scaled_vals = ne.evaluate('image * 0.5 + overlay * 0.5').astype(image.dtype)
    out = np.where(mask,image,scaled_vals)
    return out

Timings on a large image dataset -
In [250]: np.random.seed(0)
     ...: image = np.random.randint(0,256,(4000,5000,3))
     ...: overlay = np.random.randint(0,256,(4000,5000,3))

In [251]: ignore_color = [56,23,90]

In [252]: m,n = image.shape[:2]
     ...: unq_idx = np.random.choice(m*n,m*n//2,replace=0)
     ...: overlay.reshape(-1,overlay.shape[-1])[unq_idx] = ignore_color

In [253]: %timeit overlay_two_image(image, overlay, [56,23,90])
     ...: %timeit overlay_two_image_v2(image, overlay, [56,23,90])
     ...: %timeit overlay_two_image_v3(image, overlay, [56,23,90])
     ...: %timeit overlay_two_image_v3_numexpr(image, overlay, [56,23,90])
1.91 s ± 8.57 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
1.43 s ± 8.55 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
1.3 s ± 2.21 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
869 ms ± 3.8 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

A: consider using numpy.ma. it does the jobs faster.
in your case, try replacing
mask = np.full(image.shape, False)
for i in range(image.shape[0]):
        for j in range(image.shape[1]):
            if not np.array_equal(overlay[i, j], [0, 0, 0]):
                mask[i, j] = True

with
mask = np.ma.masked_greater(overlay, 0).mask


text:
Q: How to save data into an image using OpenCV? I read an image(the original image) into an CvMat using cvLoadImage, and assign its data pointer to another CvMat by an intermediate data block, and then show this CvMat using cvShowImage, but only a small region of the original image was displayed, in a window with the same size as the original image.
char* filename = "image\\neuron.tif"; // an 8bits grayscale image
IplImage*  iplImage = cvLoadImage(filename);
int width = iplImage->width;
int height = iplImage->height;
cvNamedWindow("Original", CV_WINDOW_AUTOSIZE);
cvShowImage("Original", iplImage);  // showed properly
cvWaitKey();

CvMat* header = cvCreateMatHeader(height, width, CV_8UC1);
CvMat* img_mat = cvGetMat(iplImage, header);

unsigned char* img_host = (unsigned char*)malloc(height * width * sizeof(unsigned char));// the intermediate data block, on which I need to apply a cuda operation
img_host = img_mat->data.ptr;
CvMat* blur_mat = cvCreateMat(height, width, CV_8UC1);
blur_mat->data.ptr = img_host;
cvNamedWindow("Blurred", CV_WINDOW_AUTOSIZE);
cvShowImage("Blurred", blur_mat);  // the problem described
cvWaitKey();

Actually the problem occured when I try "img_host = img_mat->data.ptr", but I have no idea what's wrong.

A: Your problem is that your input image is not really a single channel grayscale 8UC1 image. What you are seeing is the first third of the image where each BGR pixel is displayed as 3 grayscale pixels.
To fix this you can either read your input in grayscale, as @eyllanesc suggested in the comments: cvLoadImage(filename, CV_LOAD_IMAGE_GRAYSCALE);.
Alternatively, you need to declare your target as 8UC3.
In any case, your code is very messy and there are at least two memory leaks here:
unsigned char* img_host = (unsigned char*)malloc(height * width * sizeof(unsigned char));// the intermediate data block, on which I need to apply a cuda operation
img_host = img_mat->data.ptr; // LEAKS malloced buffer data

CvMat* blur_mat = cvCreateMat(height, width, CV_8UC1);
blur_mat->data.ptr = img_host; // LEAKS cvCreateMat() buffer data

I really really recommend that you use the higher level C++ API with cv::Mat instead.


text:
Q: Scrapy pull data from table rows I'm trying to pull data from this page using Scrapy: https://www.interpol.int/notice/search/woa/1192802
The spider will crawl multiple pages but I have excluded the pagination code here to keep things simple. The problem is that the number of table rows that I want to scrape on each page can change each time.
So I need a way of scraping all the table data from the page no matter how many table rows it has.
First, I extracted all the table rows on the page. Then, I created a blank dictionary. Next, I tried to loop through each row and put it's cell data into the dictionary.
But it does not work and it is returning a blank file.
Any idea what's wrong?
# -*- coding: utf-8 -*-
import scrapy

class Test1Spider(scrapy.Spider):
    name = 'test1'
    allowed_domains = ['interpol.int']
    start_urls = ['https://www.interpol.int/notice/search/woa/1192802']

    def parse(self, response):
        table_rows = response.xpath('//*[contains(@class,"col_gauche2_result_datasheet")]//tr').extract()
        data = {}
        for table_row in table_rows:
            data.update({response.xpath('//td[contains(@class, "col1")]/text()').extract(): response.css('//td[contains(@class, "col2")]/text()').extract()})
        yield data

A: What is this?
response.css('//td[contains(@class, "col2")]/text()').extract()

You are calling css() method but you are giving it a xpath
Anyways, here is the 100% working code, I have tested it.
table_rows = response.xpath('//*[contains(@class,"col_gauche2_result_datasheet")]//tr')
data = {}
for table_row in table_rows:
    data[table_row.xpath('td[@class="col1"]/text()').extract_first().strip()] = table_row.xpath('td[@class="col2 strong"]/text()').extract_first().strip()
yield data

EDIT:
To remove the characters like \t\n\r etc, use regex.
import re
your_string = re.sub('\\t|\\n|\\r', '', your_string)

A: Try this.
I Hope it will help you.
# -*- coding: utf-8 -*-
import scrapy

class Test(scrapy.Spider):
    name = 'test1'
    allowed_domains = ['interpol.int']
    start_urls = ['https://www.interpol.int/notice/search/woa/1192802']

    def parse(self, response):
        table_rows = response.xpath('//*[contains(@class,"col_gauche2_result_datasheet")]//tr')

        for table_row in table_rows:
            current_row = table_row.xpath('.//td/text()').extract()
            print(current_row[0] + current_row[1].strip())


text:
Q: How to remove mysql-server-core-5.5 even if it has dependencies? I am trying a clean install of mysql so I tried uninstalling mysql-client and mysql-server. I can't seem to uninstall mysql-server-core-5.5 using sudo dpkg --remove mysql-server-core-5.5 because of its dependency with akonadi.
dpkg: dependency problems prevent removal of mysql-server-core-5.5:
 akonadi-backend-mysql depends on mysql-server-core-5.5.

dpkg: error processing mysql-server-core-5.5 (--purge):
 dependency problems - not removing
Errors were encountered while processing:
 mysql-server-core-5.5

A: Try the following:
$ apt-get purge --auto-remove mysql-server-core
...<output from apt-get>...

In general, you should use apt-get instead of dpkg directly to install/remove software on a Debian/Ubuntu.
For mysql, you might also want to follow the above up with this:
$ rm -rf /var/lib/mysql

A: install aptitude
sudo apt-get install aptitude

then try remove with it
sudo aptitude remove mysql-server-core


text:
Q: Setting DOTNET_ROOT to directory of libhostfxr.so is insufficient If want to run dotnet-trace on Linux, against an application that ships with its own .NET Core runtime. When I run it, however, I get:
A fatal error occurred. The required library libhostfxr.so could not be found.
If this is a self-contained application, that library should exist in [/home/user/.net/dotnet-trace/RMBGJOBRwpkX5Kvpq_FShF5s1UmJMO8=/].
If this is a framework-dependent application, install the runtime in the global location [/usr/share/dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet/install_location].

I located the libhostfxr.so library at /home/user/app/libhostfxr.so, then executed DOTNET_ROOT=/home/user/app/ dotnet-trace, but got the same error.
How do I go from the path of this library to the correct setting for DOTNET_ROOT?
According to strace, it is looking for the file /home/user/app/host/fxr which does not exist.

A: I ended up installing the .NET version that matched the application I was trying to debug using the install script. (I found this by using strings libhostfxr.so; perhaps there's a better way.)
A little confusingly, the runtime version 3.1.28 is not the same as the corresponding SDK version 3.1.422, which I installed with:
$ wget -O - https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version 3.1.422

It can also be downloaded from versionsof.net which is not an official site, but it links to the files hosted by Microsoft.
This process installed /home/user/.dotnet/host/fxr/3.1.28/libhostfxr.so and I could then run DOTNET_ROOT=/home/user/.dotnet/ dotnet-trace.


text:
Q: New table view cell shows as a blank cell I've been working on an app, and ran into some problems, so I rebuilt it as simple as possible to find where the error happens at. My code uses CoreData, and my first example has the code for adding new items inside the plus button in the navigation bar. In other words, there is no change of view or segue. This version works as I would expect it to. See the following GIF.

But when I make a new view controller that adds the new item, I end up getting a blank cell instead. I have the exact same code behind the add button that I had in the plus button. And I just use a show segue to get from the tableview to a normal view controller. But if I quit the app and start it back up, it all shows correctly. See below.

If you are curious, I have the section it is adding to being a random number between 1 and 3. My guess is there is something I need to do with that segue but I don't have clue what it is. I'm very new at Swift so I have lots to learn.
Thank you in advance for any help you can give me. I think if I can solve this problem, I can finally move forward with developing my app. Thank you again. Below is my code for the case where it has a segue.
Table View Controller Code (Swift)
import UIKit
import CoreData

class ListItemsTVC: UITableViewController, NSFetchedResultsControllerDelegate {

// MARK: - Constants and Variables

let moc = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext
var frc: NSFetchedResultsController = NSFetchedResultsController()

// MARK: - App loading Functions

override func viewDidLoad() {
    super.viewDidLoad()

    frc = getFCR()
    frc.delegate = self

    do {
        try frc.performFetch()
    } catch {
        print("Failed to perform inital fetch")
    }
    self.tableView.rowHeight = 62

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

// MARK: - Outlets and Actions

/*@IBAction func addItem(sender: AnyObject) {

    let entityDesc = NSEntityDescription.entityForName("Items", inManagedObjectContext: moc)
    let item = Items(entity: entityDesc!, insertIntoManagedObjectContext: moc)

    if (NSUserDefaults.standardUserDefaults().objectForKey("nextItemID") == nil) {
        NSUserDefaults.standardUserDefaults().setObject(1, forKey: "nextItemID")
        NSUserDefaults.standardUserDefaults().synchronize()
    }

    let id = NSUserDefaults.standardUserDefaults().integerForKey("nextItemID")

    item.id = id
    switch id {
    case 1...9:
        item.name = "Item ID: 0\(id)"
    default:
        item.name = "Item ID: \(id)"
    }
    item.brand = "Brand \(id)"
    item.qty = 1
    item.price = 0
    item.size = "Size \(id)"
    let sec: Int = Int(arc4random_uniform(UInt32(4 - 1))) + 1
    item.section = "Section \(sec)"
    item.isChecked = false

    do {
        try moc.save()
        NSUserDefaults.standardUserDefaults().setObject(id + 1, forKey: "nextItemID")
        NSUserDefaults.standardUserDefaults().synchronize()
    } catch {
        fatalError("New item save failed")
    }

}*/

// MARK: - Table view data source

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {

    if let sections = frc.sections {
        return sections.count
    }

    return 0

}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

    if let sections = frc.sections {
        let currentSection = sections[section]
        return currentSection.numberOfObjects
    }

    return 0

}

override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {

    return 28

}

override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {

    if let sections = frc.sections {
        let currentSection = sections[section]
        return currentSection.name
    }

    return nil

}

func controllerWillChangeContent(controller: NSFetchedResultsController) {

    tableView.beginUpdates()

}

func controllerDidChangeContent(controller: NSFetchedResultsController) {

    tableView.endUpdates()

}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCellWithIdentifier("listContentCell", forIndexPath: indexPath) as! ListItemsTVCell
    let item = frc.objectAtIndexPath(indexPath) as! Items

    cell.separatorInset = UIEdgeInsets(top: 0, left: 78, bottom: 0, right: 0)
    cell.itemName.text = item.name
    cell.itemSection.text = item.section
    cell.itemQty.text = "Qty: \(item.qty!)"
    cell.itemSize.text = item.size
    cell.itemPrice.text = floatToCurrency(Float(item.price!))
    //cell.itemImage.image = UIImage(data: item.image!)
    cell.itemID.text = String(item.id!)

    return cell

}

override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {

    let delete = UITableViewRowAction(style: .Destructive, title: "Delete") { (action, indexPath) in

        let item = self.frc.objectAtIndexPath(indexPath) as! Items
        let id = item.id!
        let request = self.fetchRequest()
        let pred = NSPredicate(format: "%K == %@", "id",id)
        request.predicate = pred
        var fetchResults = [AnyObject]()

        do {
            fetchResults = try self.moc.executeFetchRequest(request)
        } catch {
            fatalError("Fetching Data to Delete Failed")
        }

        self.moc.deleteObject(fetchResults[0] as! NSManagedObject)
        fetchResults.removeAtIndex(0)

        do {
            try self.moc.save()
        } catch {
            fatalError("Failed to Save after Delete")
        }

    }

    return [delete]

}

func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) {

    switch type {
    case NSFetchedResultsChangeType.Delete:
        self.tableView.deleteSections(NSIndexSet(index: sectionIndex), withRowAnimation: UITableViewRowAnimation.Automatic)
    case NSFetchedResultsChangeType.Insert:
        self.tableView.insertSections(NSIndexSet(index: sectionIndex), withRowAnimation: UITableViewRowAnimation.Automatic)
        /*case NSFetchedResultsChangeType.Update:
         tableView.reloadSections(NSIndexSet(index: sectionIndex), withRowAnimation: UITableViewRowAnimation.Automatic)*/
    default:
        print("Default in didChangeSection was called")
        break
    }

}

internal func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {

    switch type {
    case NSFetchedResultsChangeType.Delete:
        self.tableView.deleteRowsAtIndexPaths([indexPath!], withRowAnimation: UITableViewRowAnimation.Automatic)
    case NSFetchedResultsChangeType.Insert:
        self.tableView.insertRowsAtIndexPaths([newIndexPath!], withRowAnimation: UITableViewRowAnimation.Fade)
    default:
        print("Default in didChangeObject was called")
        break
    }

}

/*
// Override to support conditional editing of the table view.
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    // Return false if you do not want the specified item to be editable.
    return true
}
*/

/*
// Override to support editing the table view.
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
    if editingStyle == .Delete {
        // Delete the row from the data source
        tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
    } else if editingStyle == .Insert {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }
}
*/

/*
// Override to support rearranging the table view.
override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {

}
*/

/*
// Override to support conditional rearranging of the table view.
override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    // Return false if you do not want the item to be re-orderable.
    return true
}
*/

/*

// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    // Get the new view controller using segue.destinationViewController.
    // Pass the selected object to the new view controller.
}
*/

// MARK: - Custom Functions

func fetchRequest() -> NSFetchRequest {

    let fetchRequest = NSFetchRequest(entityName: "Items")
    let sortDesc1 = NSSortDescriptor(key: "section", ascending: true)
    let sortDesc2 = NSSortDescriptor(key: "isChecked", ascending: true)
    let sortDesc3 = NSSortDescriptor(key: "name", ascending: true)
    fetchRequest.sortDescriptors = [sortDesc1, sortDesc2, sortDesc3]

    return fetchRequest

}

func getFCR() -> NSFetchedResultsController {

    frc = NSFetchedResultsController(fetchRequest: fetchRequest(), managedObjectContext: moc, sectionNameKeyPath: "section" , cacheName: nil)

    return frc

}

func floatToCurrency(flt: Float) -> String {

    let formatter = NSNumberFormatter()
    formatter.numberStyle = NSNumberFormatterStyle.CurrencyStyle
    return String(formatter.stringFromNumber(flt)!)

}

}

View Controller (Swift) [The segue view]
import UIKit
import CoreData

class AddItemListVC: UIViewController, NSFetchedResultsControllerDelegate {

// MARK: - Constants and Variables

let moc = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext
//var frc: NSFetchedResultsController = NSFetchedResultsController()

// MARK: - App loading Functions

override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

// MARK: - Outlets and Actions

@IBAction func addItem(sender: AnyObject) {

    let entityDesc = NSEntityDescription.entityForName("Items", inManagedObjectContext: moc)
    let item = Items(entity: entityDesc!, insertIntoManagedObjectContext: moc)

    if (NSUserDefaults.standardUserDefaults().objectForKey("nextItemID") == nil) {
        NSUserDefaults.standardUserDefaults().setObject(1, forKey: "nextItemID")
        NSUserDefaults.standardUserDefaults().synchronize()
    }

    let id = NSUserDefaults.standardUserDefaults().integerForKey("nextItemID")

    item.id = id
    switch id {
    case 1...9:
        item.name = "Item ID: 0\(id)"
    default:
        item.name = "Item ID: \(id)"
    }
    item.brand = "Brand \(id)"
    item.qty = 1
    item.price = 0
    item.size = "Size \(id)"
    let sec: Int = Int(arc4random_uniform(UInt32(4 - 1))) + 1
    item.section = "Section \(sec)"
    item.isChecked = false

    do {
        try moc.save()
        NSUserDefaults.standardUserDefaults().setObject(id + 1, forKey: "nextItemID")
        NSUserDefaults.standardUserDefaults().synchronize()
    } catch {
        fatalError("New item save failed")
    }

}

/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    // Get the new view controller using segue.destinationViewController.
    // Pass the selected object to the new view controller.
}
*/

}

A: Reload TableView Data is viewWillAppear method as :
override func viewWillAppear() {
    super.viewWillAppear()
    do {
        try frc.performFetch()
    } catch {
        print("Failed to perform inital fetch")
    }
}

As when you are navigating back from viewController you are not telling the TableViewController to update tableView so do it in viewWillAppear as it will fire when you are popping navController to come back.

A: Here is the code that fixed the problem for me. I only changed the Table View Controller Code:
import UIKit
import CoreData

class ListItemsTVC: UITableViewController, NSFetchedResultsControllerDelegate {

// MARK: - Constants and Variables

let moc = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext
var frc: NSFetchedResultsController = NSFetchedResultsController()

// MARK: - App loading Functions

override func viewDidLoad() {
    super.viewDidLoad()

    frc = getFCR()
    frc.delegate = self

    do {
        try frc.performFetch()
    } catch {
        print("Failed to perform inital fetch")
    }
    self.tableView.rowHeight = 62

}

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)

    self.tableView.reloadData()

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

// MARK: - Outlets and Actions

/*@IBAction func addItem(sender: AnyObject) {

    let entityDesc = NSEntityDescription.entityForName("Items", inManagedObjectContext: moc)
    let item = Items(entity: entityDesc!, insertIntoManagedObjectContext: moc)

    if (NSUserDefaults.standardUserDefaults().objectForKey("nextItemID") == nil) {
        NSUserDefaults.standardUserDefaults().setObject(1, forKey: "nextItemID")
        NSUserDefaults.standardUserDefaults().synchronize()
    }

    let id = NSUserDefaults.standardUserDefaults().integerForKey("nextItemID")

    item.id = id
    switch id {
    case 1...9:
        item.name = "Item ID: 0\(id)"
    default:
        item.name = "Item ID: \(id)"
    }
    item.brand = "Brand \(id)"
    item.qty = 1
    item.price = 0
    item.size = "Size \(id)"
    let sec: Int = Int(arc4random_uniform(UInt32(4 - 1))) + 1
    item.section = "Section \(sec)"
    item.isChecked = false

    do {
        try moc.save()
        NSUserDefaults.standardUserDefaults().setObject(id + 1, forKey: "nextItemID")
        NSUserDefaults.standardUserDefaults().synchronize()
    } catch {
        fatalError("New item save failed")
    }

}*/

// MARK: - Table view data source

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {

    if let sections = frc.sections {
        return sections.count
    }

    return 0

}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

    if let sections = frc.sections {
        let currentSection = sections[section]
        return currentSection.numberOfObjects
    }

    return 0

}

override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {

    return 28

}

override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {

    if let sections = frc.sections {
        let currentSection = sections[section]
        return currentSection.name
    }

    return nil

}

func controllerWillChangeContent(controller: NSFetchedResultsController) {

    tableView.beginUpdates()

}

func controllerDidChangeContent(controller: NSFetchedResultsController) {

    tableView.endUpdates()

}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCellWithIdentifier("listContentCell", forIndexPath: indexPath) as! ListItemsTVCell
    let item = frc.objectAtIndexPath(indexPath) as! Items

    cell.separatorInset = UIEdgeInsets(top: 0, left: 78, bottom: 0, right: 0)
    cell.itemName.text = item.name
    cell.itemSection.text = item.section
    cell.itemQty.text = "Qty: \(item.qty!)"
    cell.itemSize.text = item.size
    cell.itemPrice.text = floatToCurrency(Float(item.price!))
    //cell.itemImage.image = UIImage(data: item.image!)
    cell.itemID.text = String(item.id!)

    return cell

}

override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {

    let delete = UITableViewRowAction(style: .Destructive, title: "Delete") { (action, indexPath) in

        let item = self.frc.objectAtIndexPath(indexPath) as! Items
        let id = item.id!
        let request = self.fetchRequest()
        let pred = NSPredicate(format: "%K == %@", "id",id)
        request.predicate = pred
        var fetchResults = [AnyObject]()

        do {
            fetchResults = try self.moc.executeFetchRequest(request)
        } catch {
            fatalError("Fetching Data to Delete Failed")
        }

        self.moc.deleteObject(fetchResults[0] as! NSManagedObject)
        fetchResults.removeAtIndex(0)

        do {
            try self.moc.save()
        } catch {
            fatalError("Failed to Save after Delete")
        }

    }

    return [delete]

}

func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) {

    switch type {
    case NSFetchedResultsChangeType.Delete:
        self.tableView.deleteSections(NSIndexSet(index: sectionIndex), withRowAnimation: UITableViewRowAnimation.Automatic)
    case NSFetchedResultsChangeType.Insert:
        self.tableView.insertSections(NSIndexSet(index: sectionIndex), withRowAnimation: UITableViewRowAnimation.Automatic)
        /*case NSFetchedResultsChangeType.Update:
         tableView.reloadSections(NSIndexSet(index: sectionIndex), withRowAnimation: UITableViewRowAnimation.Automatic)*/
    default:
        print("Default in didChangeSection was called")
        break
    }

}

internal func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {

    switch type {
    case NSFetchedResultsChangeType.Delete:
        self.tableView.deleteRowsAtIndexPaths([indexPath!], withRowAnimation: UITableViewRowAnimation.Automatic)
    case NSFetchedResultsChangeType.Insert:
        self.tableView.insertRowsAtIndexPaths([newIndexPath!], withRowAnimation: UITableViewRowAnimation.Fade)
    default:
        print("Default in didChangeObject was called")
        break
    }

}

/*
// Override to support conditional editing of the table view.
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    // Return false if you do not want the specified item to be editable.
    return true
}
*/

/*
// Override to support editing the table view.
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
    if editingStyle == .Delete {
        // Delete the row from the data source
        tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
    } else if editingStyle == .Insert {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }
}
*/

/*
// Override to support rearranging the table view.
override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {

}
*/

/*
// Override to support conditional rearranging of the table view.
override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    // Return false if you do not want the item to be re-orderable.
    return true
}
*/

/*

// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    // Get the new view controller using segue.destinationViewController.
    // Pass the selected object to the new view controller.
}
*/

// MARK: - Custom Functions

func fetchRequest() -> NSFetchRequest {

    let fetchRequest = NSFetchRequest(entityName: "Items")
    let sortDesc1 = NSSortDescriptor(key: "section", ascending: true)
    let sortDesc2 = NSSortDescriptor(key: "isChecked", ascending: true)
    let sortDesc3 = NSSortDescriptor(key: "name", ascending: true)
    fetchRequest.sortDescriptors = [sortDesc1, sortDesc2, sortDesc3]

    return fetchRequest

}

func getFCR() -> NSFetchedResultsController {

    frc = NSFetchedResultsController(fetchRequest: fetchRequest(), managedObjectContext: moc, sectionNameKeyPath: "section" , cacheName: nil)

    return frc

}

func floatToCurrency(flt: Float) -> String {

    let formatter = NSNumberFormatter()
    formatter.numberStyle = NSNumberFormatterStyle.CurrencyStyle
    return String(formatter.stringFromNumber(flt)!)

}

}

A: Muhammad's answer will surely solve the problem as it will trigger the reload of the table view every time viewWillAppear will call. But the problem is that is not a very good way of doing this.
You see, viewWillAppear gets called a lot of times. It is a UIViewController life cycle method. If you are going to the second view controller and coming back without pressing the add button, it will still reload the UITableView. Now, the point is not whether it is an expensive operation or not, the point is that viewWillAppear is not the place to do that kind of a stuff. What if you had to do something else before reloading the cell, you may not want to put it all there and risk creating bugs.
A good way of achieving this is through delegates (call backs). Read up more on this and you will see that it gives you a much needed flexibility.


text:
Q: What is the syntax to pass a list to ack? I have installed strawberry-perl on my windows 7 laptop.
I want to search for a list of words using grep or ack on windows.
I have been able to perform basic searches using ack, but I just don't know how to pass a list of words to ack So I want to pass a list of words to ack and find out the line numbers where these words occur. Both words do not have to occur on the same line.
For example, if I am searching for "doll" and "house", I could have doll on line 12 and house on line 244.
I tried something like this ack "doll"|"house" but it throws the following error.
Expressions are only allowed as the first element of a pipeline.
At line:1 char:22
+ ack "doll" | "house" <<<<
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : ExpressionsMustBeFirstInPipeline

A: So you're saying you want to find all the files where "doll" appears and where "house" appears.  So here's what you do.
First, find all the files that contain "doll", and print a list of them.
ack -l doll

Then search that list of files for the word "house".
ack house $(ack -l doll)

Or, if you're not running a shell that lets you do that (i.e. Windows), you can do:
ack -l doll | ack -x house

ack -x says "Take the list of files to search from STDIN".


text:
Q: Can i use the Google places API in an edittext? Is it possible to use the Google places API in this layout:

I highlighted the EditText field where i want to use the API in.
I've already searched for numerous guides on how to do this but it seems all of them use deprecated code. I'm also fairly new to Fragments but i would like to get to know more of this topic.

A: This is possible if you use the Web API, but will require a lot of work.
However, it looks like someone has done it before: https://github.com/mukeshsolanki/Google-Places-AutoComplete-EditText
Alternatively, you can use the Places SDK for Android, which provides the AutoCompleteSupportFragment and AutoCompleteActivity.

A: set onclicklistener on that edittext and in onclick method call below function
private void searchPlace() {
if (!Places.isInitialized(){ Places.initialize(this, getApplication().getString(R.string.google_maps_key)); }
// Set the fields to specify which types of place data to
// return after the user has made a selection.
List<Place.Field> fields = Arrays.asList(Place.Field.LAT_LNG, Place.Field.ADDRESS);
 // Start the autocomplete intent.
Intent intent = new Autocomplete.IntentBuilder( AutocompleteActivityMode.FULLSCREEN, fields) .build(this);
 startActivityForResult(intent, AUTOCOMPLETE_REQUEST_CODE); }

And get selected result in onresult method
Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == AUTOCOMPLETE_REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
                Place place = Autocomplete.getPlaceFromIntent(data);
                destinationAddress = place.getAddress();
                lblDestinationAddress.setText(destinationAddress);

            } else if (resultCode == AutocompleteActivity.RESULT_ERROR) {
                // TODO: Handle the error.
                Status status = Autocomplete.getStatusFromIntent(data);
                Toast.makeText(this, "Some went wrong. Search again", Toast.LENGTH_SHORT).show();
                Log.i(TAG, status.getStatusMessage());
            }

Dependency
//search places implementation
 'com.google.android.libraries.places:places:2.0.0'


text:
Q: Discuss strong and weak convergence of a sequence in $W^{1,p}$ Sobolev space
Discuss the strong and weak convergence of the sequence of functions
$$u_n(x)=\frac{1}{n}\sin nx+2\sqrt{x}$$
in the $W^{1,p}(0,1)$ Sobolev space.

Pointwise limit is $u(x)=2\sqrt{x}$ and can be easily shown that the sequence converge strongly in $L^p(0,1)\ \forall\ 1\le p \le +\infty$.
The derivative of the sequence is $u'_n(x)=\cos nx +\frac{1}{\sqrt{x}}$ and the pointwise limit $u'(x)=\frac{1}{\sqrt{x}}$ (right?).
For $p=1$ I would say that
$$\int_0^1 \cos nx\ dx = \frac{\sin nx}{n}\to 0\text{ as }n\to+\infty$$
so the sequence would converge strongly in $W^{1,1}$, but actually
$$||u'_n(x)-u'(x)||_{L^1} = \int_0^1 |\cos nx|\ dx$$
and $\cos nx$ does not have a fixed sign for $x\in[0,1]$ since $n$ is going to infinity so how to solve it?
For $p=+\infty$
$$||u'_n(x)-u'(x)||_{L^{\infty}} = \max|\cos nx|=1\nrightarrow 0$$
so the sequence doesn't converge strongly in $W^{1,+\infty}$.
For $1<p<+\infty$, since $\max(\cos nx)=1$
$$||u'_n(x)-u'(x)||_{L^p}^p \le 1$$
so we don't have strong convergence, but since $L^p$ is reflexive for $1<p<+\infty$, by Banach-Alaoglu we can extract a subsequence of $u'_n$ converging weakly (but where?). In particular in $L^2$ $\cos nx$ is a subsequence of the trigonometric basis, which converges weakly to $0$ in $L^2$. But for others $p$ where does the subsequence extracted from $u'_n$ weakly converge?

A: First notice that $u_n$ only belong to some of the $W^{1,p}$ spaces, as we have $u_n'=\cos (nx)+\frac{1}{\sqrt{x}}$ and
$$\cos(nx)+\frac{1}{\sqrt{x}}\in L^p(0,1)\iff \frac{1}{\sqrt{x}}\in L^p(0,1)\iff |x|^{-p/2}\in L^1(0,1)\iff p<2 $$
Therefore it is only meaningful to discuss convergence in $W^{1,p}(0,1)$ for $p\in [1,2)$.
There is no pointwise limit for $u_n'(x)=\cos (nx)+\frac{1}{\sqrt{x}}$ because there is no pointwise limit for $\cos(nx)$ except for $x=0$. The sequence keeps on oscillating around $\frac{1}{\sqrt{x}}$.
Your Banach-Alaoglu + reflexivity argument works to prove the existence of a weakly converging subsequence if $p\in (1,\infty)$. The issue is that it says nothing about the weak limit aside from existence.
To understand the weak limit, there is a general result (see my answer here) - if $g:\mathbb{R}\to \mathbb{R}$ is a bounded periodic function such that its mean over a period is $\alpha$, then if $v_n(x):=g(nx)$ we have $v_n\rightharpoonup \alpha$ weakly-star in $L^{\infty}(\mathbb{R})$ for $p<\infty$. In this case, we have $g(x)=\cos x$ whose mean over a period is $\alpha=\int_0^{2\pi}\cos x\, dx = 0$. Therefore, $\cos (nx)\rightharpoonup 0$ weakly-star in $L^{\infty}(\mathbb{R})$, hence $\cos (nx)\rightharpoonup 0$ weakly-star in $L^{\infty}(0,1)$ and thus (since $L^{\infty}(0,1)\hookrightarrow L^p(0,1)$ for $p\in [1,\infty]$) we also have $\cos (nx)\rightharpoonup 0$ weakly-star (and hence weakly, since they are reflexive) in $L^p(0,1)$ for all $p\in (1,\infty)$. Finally, we can include $p=1$ as weak convergence in $L^p(0,1)$ for $p>1$ implies weak convergence in $L^1(0,1)$.
In conclusion, the above argument shows that the sequence $u_n$ is weakly convergent to $2\sqrt{x}$ in $W^{1,p}(0,1)$ for all $p\in [1,2)$.
To study strong convergence, notice that as we have proved, the weak limit of $\cos (nx)$ is $0$. Therefore, since the strong limit must agree with the weak limit when it exists, by contradiction if $u_n'\to u$ strongly in $L^p(0,1)$, then we would have $\cos (nx)\to 0$ strongly in $L^p(0,1)$ and in particular in $L^1(0,1)$, but if $2(k+1)\pi\geq n\geq 2k\pi$, then
\begin{align*}\int_0^1|\cos (n x)|\,dx&= \frac{1}{n}\int_0^n|\cos (y)|\,dy\geq \frac{1}{2(k+1)\pi}\int_0^{2k\pi}|\cos y|\,dy\geq \\
&\geq \frac{k}{2(k+1)\pi}\int_0^{2\pi}|\cos y|\,dy=\frac{2}{(1+1/k)\pi}\not \to 0
\end{align*}
 a contradiction.


text:
Q: Attach WYSIWYG to custom Drupal form I have a custom module implementing a system settings form, and I would like to attach WYSIWYG to the text area field. However, nothing I am doing is having much affect. I am using the latest WYSIWYG module with CKEditor. There are no JS errors. All I get on the screen is a plain text area.
Code:
$form['mymodule'] = array(
            '#type' => 'fieldset',
            '#title' => t('Settings'),
        );

    $form['mymodule']['email_content'] = array(
        '#title' => 'Email Content',
        '#type' => 'textarea',
        '#description' => t('The content of the message that is emailed to the user when a license key is assigned. You can use [user_fullname] and [user_license_key] to substitute for the user name and license key, respectively.'),
        '#default_value' => variable_get('mymodule_email_content', ''),
    );

    $form['mymodule']['format'] = filter_form(2);

All this seems to do is provide a filter selection. Got that from this page: http://drupal.org/node/358316. Even when you pick a format, the WYSIWYG does not load.
What I want to do is simply have the form present the WYSIWYG without having to make a format selection. How can I trigger it to load on the textarea in the Form API?

A: You need to add a subarray for the wysiwyg thing
    $form['mymodule']['foo']['email_content'] = array(
        '#title' => 'Email Content',
    .
    .
    .
    $form['mymodule']['foo']['format'] = filter_form(2);
Maybe you can hide the filter selection box using css?


text:
Q: Yaml code fails while running msg: "{{ job_info[0][\"JOB_NAME\"] }}" Here is my Yaml code.
---
- hosts: as053a
  gather_facts: false
  collections:
    - ibm.power_ibmi
  vars:
    job_info: ""
  tasks:
    - name: Submit a batch job and run CALL QGPL/PGM1
      ibm.power_ibmi.ibmi_submit_job:
        cmd: DSPPTF OUTPUT(*PRINT)
    - name: Get status of a list of jobs
      ibm.power_ibmi.ibmi_job:
        user: MSRXS
        type: "*BATCH"
      register: job_info
    - name: Debug job info
      debug:
        var: job_info
    - name: Print the job name or names
      debug:
         msg: "{{ job_info[0][\"JOB_NAME\"] }}"

Basically I'm trying to run a command & get the process ID & other details from a IBMi system.
Out of the four tasks, 3 tasks run successfully, but the fourth task fails with below error message:

fatal: [as053a]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: dict object has no element 0\n\nThe error appears to be in '/tmp/bwrap_7266694_r5nf2p16/awx_7266694_2sgugv1b/project/as053a.dspptf.yaml': line 20, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n        var: job_info\n    - name: Print the job name or names\n      ^ here\n"}

Please let me what needs to be done
The output of third task looks like below:
"job_info": {
        "end": "2023-02-18 05:03:14.796003",
        "job_log": [],
        "failed": false,
        "changed": false,
        "job_info": [
            {
                "JOB_STATUS": "OUTQ",
                "JOB_QUEUE_NAME": "IBMSAJOBQ",
                "JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
                "JOB_TYPE": "BCH",
                "JOB_ACCOUNTING_CODE": "IBM 123385 897",
                "CCSID": 37,
                "JOB_END_TIME": "2023-02-17 23:02:23",
                "SUBMITTER_JOB_NAME": "927415/MSRXS/QPADEV000C",
                "JOB_ENTERED_SYSTEM_TIME": "2023-02-17 23:02:23",
                "JOB_DESCRIPTION": "ISYSJOBD",
                "JOB_INFORMATION": "YES",
                "JOB_NAME": "927529/MSRXS/ISYSJOBD",
                "JOB_TYPE_ENHANCED": "BATCH",
                "COMPLETION_STATUS": "ABNORMAL",
                "JOB_DATE": "",
                "JOB_ACTIVE_TIME": "2023-02-17 23:02:23",
                "JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
                "JOB_QUEUE_STATUS": "RELEASED",
                "SUBMITTER_MESSAGE_QUEUE": "MSRXS",
                "JOB_SUBSYSTEM": "",
                "SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
                "JOB_SCHEDULED_TIME": "",
                "JOB_END_REASON": "JOB ENDED DUE TO THE MESSAGE SEVERITY LEVEL BEING EXCEEDED",
                "JOB_QUEUE_PRIORITY": "",
                "JOB_END_SEVERITY": 30
            },
            {
                "JOB_STATUS": "OUTQ",
                "JOB_QUEUE_NAME": "",
                "JOB_DESCRIPTION_LIBRARY": "",
                "JOB_TYPE": "BCH",
                "JOB_ACCOUNTING_CODE": "IBM 123385 897",
                "CCSID": "",
                "JOB_END_TIME": "2023-02-17 23:55:28",
                "SUBMITTER_JOB_NAME": "",
                "JOB_ENTERED_SYSTEM_TIME": "2023-02-17 23:55:28",
                "JOB_DESCRIPTION": "",
                "JOB_INFORMATION": "YES",
                "JOB_NAME": "928197/MSRXS/QPRTJOB",
                "JOB_TYPE_ENHANCED": "ALTERNATE_SPOOL_USER",
                "COMPLETION_STATUS": "ABNORMAL",
                "JOB_DATE": "",
                "JOB_ACTIVE_TIME": "",
                "JOB_QUEUE_LIBRARY": "",
                "JOB_QUEUE_STATUS": "",
                "SUBMITTER_MESSAGE_QUEUE": "",
                "JOB_SUBSYSTEM": "",
                "SUBMITTER_MESSAGE_QUEUE_LIBRARY": "",
                "JOB_SCHEDULED_TIME": "",
                "JOB_END_REASON": "",
                "JOB_QUEUE_PRIORITY": "",
                "JOB_END_SEVERITY": 10
            },
            {
                "JOB_STATUS": "OUTQ",
                "JOB_QUEUE_NAME": "IBMSAJOBQ",
                "JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
                "JOB_TYPE": "BCH",
                "JOB_ACCOUNTING_CODE": "IBM 123385 897",
                "CCSID": 37,
                "JOB_END_TIME": "2023-02-18 00:40:00",
                "SUBMITTER_JOB_NAME": "928201/QUSER/QSQSRVR",
                "JOB_ENTERED_SYSTEM_TIME": "2023-02-18 00:39:59",
                "JOB_DESCRIPTION": "ISYSJOBD",
                "JOB_INFORMATION": "YES",
                "JOB_NAME": "928748/MSRXS/ISYSJOBD",
                "JOB_TYPE_ENHANCED": "BATCH",
                "COMPLETION_STATUS": "NORMAL",
                "JOB_DATE": "",
                "JOB_ACTIVE_TIME": "2023-02-18 00:40:00",
                "JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
                "JOB_QUEUE_STATUS": "RELEASED",
                "SUBMITTER_MESSAGE_QUEUE": "MSRXS",
                "JOB_SUBSYSTEM": "",
                "SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
                "JOB_SCHEDULED_TIME": "",
                "JOB_END_REASON": "JOB ENDING IN NORMAL MANNER",
                "JOB_QUEUE_PRIORITY": "",
                "JOB_END_SEVERITY": 30
            },
            {
                "JOB_STATUS": "OUTQ",
                "JOB_QUEUE_NAME": "IBMSAJOBQ",
                "JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
                "JOB_TYPE": "BCH",
                "JOB_ACCOUNTING_CODE": "IBM 123385 897",
                "CCSID": 37,
                "JOB_END_TIME": "2023-02-18 04:05:01",
                "SUBMITTER_JOB_NAME": "915387/QUSER/QSQSRVR",
                "JOB_ENTERED_SYSTEM_TIME": "2023-02-18 04:05:00",
                "JOB_DESCRIPTION": "ISYSJOBD",
                "JOB_INFORMATION": "YES",
                "JOB_NAME": "931583/MSRXS/ISYSJOBD",
                "JOB_TYPE_ENHANCED": "BATCH",
                "COMPLETION_STATUS": "NORMAL",
                "JOB_DATE": "",
                "JOB_ACTIVE_TIME": "2023-02-18 04:05:00",
                "JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
                "JOB_QUEUE_STATUS": "RELEASED",
                "SUBMITTER_MESSAGE_QUEUE": "MSRXS",
                "JOB_SUBSYSTEM": "",
                "SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
                "JOB_SCHEDULED_TIME": "",
                "JOB_END_REASON": "JOB ENDING IN NORMAL MANNER",
                "JOB_QUEUE_PRIORITY": "",
                "JOB_END_SEVERITY": 30
            },
            {
                "JOB_STATUS": "OUTQ",
                "JOB_QUEUE_NAME": "IBMSAJOBQ",
                "JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
                "JOB_TYPE": "BCH",
                "JOB_ACCOUNTING_CODE": "IBM 123385 897",
                "CCSID": 37,
                "JOB_END_TIME": "2023-02-18 04:29:54",
                "SUBMITTER_JOB_NAME": "915387/QUSER/QSQSRVR",
                "JOB_ENTERED_SYSTEM_TIME": "2023-02-18 04:29:53",
                "JOB_DESCRIPTION": "ISYSJOBD",
                "JOB_INFORMATION": "YES",
                "JOB_NAME": "932009/MSRXS/ISYSJOBD",
                "JOB_TYPE_ENHANCED": "BATCH",
                "COMPLETION_STATUS": "NORMAL",
                "JOB_DATE": "",
                "JOB_ACTIVE_TIME": "2023-02-18 04:29:53",
                "JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
                "JOB_QUEUE_STATUS": "RELEASED",
                "SUBMITTER_MESSAGE_QUEUE": "MSRXS",
                "JOB_SUBSYSTEM": "",
                "SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
                "JOB_SCHEDULED_TIME": "",
                "JOB_END_REASON": "JOB ENDING IN NORMAL MANNER",
                "JOB_QUEUE_PRIORITY": "",
                "JOB_END_SEVERITY": 30
            },
            {
                "JOB_STATUS": "OUTQ",
                "JOB_QUEUE_NAME": "IBMSAJOBQ",
                "JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
                "JOB_TYPE": "BCH",
                "JOB_ACCOUNTING_CODE": "IBM 123385 897",
                "CCSID": 37,
                "JOB_END_TIME": "2023-02-18 04:36:25",
                "SUBMITTER_JOB_NAME": "915387/QUSER/QSQSRVR",
                "JOB_ENTERED_SYSTEM_TIME": "2023-02-18 04:36:24",
                "JOB_DESCRIPTION": "ISYSJOBD",
                "JOB_INFORMATION": "YES",
                "JOB_NAME": "932122/MSRXS/ISYSJOBD",
                "JOB_TYPE_ENHANCED": "BATCH",
                "COMPLETION_STATUS": "NORMAL",
                "JOB_DATE": "",
                "JOB_ACTIVE_TIME": "2023-02-18 04:36:24",
                "JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
                "JOB_QUEUE_STATUS": "RELEASED",
                "SUBMITTER_MESSAGE_QUEUE": "MSRXS",
                "JOB_SUBSYSTEM": "",
                "SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
                "JOB_SCHEDULED_TIME": "",
                "JOB_END_REASON": "JOB ENDING IN NORMAL MANNER",
                "JOB_QUEUE_PRIORITY": "",
                "JOB_END_SEVERITY": 30
            },
            {
                "JOB_STATUS": "OUTQ",
                "JOB_QUEUE_NAME": "IBMSAJOBQ",
                "JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
                "JOB_TYPE": "BCH",
                "JOB_ACCOUNTING_CODE": "IBM 123385 897",
                "CCSID": 37,
                "JOB_END_TIME": "2023-02-18 04:41:44",
                "SUBMITTER_JOB_NAME": "915387/QUSER/QSQSRVR",
                "JOB_ENTERED_SYSTEM_TIME": "2023-02-18 04:41:44",
                "JOB_DESCRIPTION": "ISYSJOBD",
                "JOB_INFORMATION": "YES",
                "JOB_NAME": "932232/MSRXS/ISYSJOBD",
                "JOB_TYPE_ENHANCED": "BATCH",
                "COMPLETION_STATUS": "NORMAL",
                "JOB_DATE": "",
                "JOB_ACTIVE_TIME": "2023-02-18 04:41:44",
                "JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
                "JOB_QUEUE_STATUS": "RELEASED",
                "SUBMITTER_MESSAGE_QUEUE": "MSRXS",
                "JOB_SUBSYSTEM": "",
                "SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
                "JOB_SCHEDULED_TIME": "",
                "JOB_END_REASON": "JOB ENDING IN NORMAL MANNER",
                "JOB_QUEUE_PRIORITY": "",
                "JOB_END_SEVERITY": 30
            },
            {
                "JOB_STATUS": "OUTQ",
                "JOB_QUEUE_NAME": "IBMSAJOBQ",
                "JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
                "JOB_TYPE": "BCH",
                "JOB_ACCOUNTING_CODE": "IBM 123385 897",
                "CCSID": 37,
                "JOB_END_TIME": "2023-02-18 04:59:55",
                "SUBMITTER_JOB_NAME": "915387/QUSER/QSQSRVR",
                "JOB_ENTERED_SYSTEM_TIME": "2023-02-18 04:59:55",
                "JOB_DESCRIPTION": "ISYSJOBD",
                "JOB_INFORMATION": "YES",
                "JOB_NAME": "932541/MSRXS/ISYSJOBD",
                "JOB_TYPE_ENHANCED": "BATCH",
                "COMPLETION_STATUS": "NORMAL",
                "JOB_DATE": "",
                "JOB_ACTIVE_TIME": "2023-02-18 04:59:55",
                "JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
                "JOB_QUEUE_STATUS": "RELEASED",
                "SUBMITTER_MESSAGE_QUEUE": "MSRXS",
                "JOB_SUBSYSTEM": "",
                "SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
                "JOB_SCHEDULED_TIME": "",
                "JOB_END_REASON": "JOB ENDING IN NORMAL MANNER",
                "JOB_QUEUE_PRIORITY": "",
                "JOB_END_SEVERITY": 30
            },
            {
                "JOB_STATUS": "OUTQ",
                "JOB_QUEUE_NAME": "IBMSAJOBQ",
                "JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
                "JOB_TYPE": "BCH",
                "JOB_ACCOUNTING_CODE": "IBM 123385 897",
                "CCSID": 37,
                "JOB_END_TIME": "2023-02-18 05:01:32",
                "SUBMITTER_JOB_NAME": "915387/QUSER/QSQSRVR",
                "JOB_ENTERED_SYSTEM_TIME": "2023-02-18 05:00:28",
                "JOB_DESCRIPTION": "ISYSJOBD",
                "JOB_INFORMATION": "YES",
                "JOB_NAME": "932558/MSRXS/ISYSJOBD",
                "JOB_TYPE_ENHANCED": "BATCH",
                "COMPLETION_STATUS": "NORMAL",
                "JOB_DATE": "",
                "JOB_ACTIVE_TIME": "2023-02-18 05:01:32",
                "JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
                "JOB_QUEUE_STATUS": "RELEASED",
                "SUBMITTER_MESSAGE_QUEUE": "MSRXS",
                "JOB_SUBSYSTEM": "",
                "SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
                "JOB_SCHEDULED_TIME": "",
                "JOB_END_REASON": "JOB ENDING IN NORMAL MANNER",
                "JOB_QUEUE_PRIORITY": "",
                "JOB_END_SEVERITY": 30
            },
            {
                "JOB_STATUS": "OUTQ",
                "JOB_QUEUE_NAME": "IBMSAJOBQ",
                "JOB_DESCRIPTION_LIBRARY": "ISYSMODOBJ",
                "JOB_TYPE": "BCH",
                "JOB_ACCOUNTING_CODE": "IBM 123385 897",
                "CCSID": 37,
                "JOB_END_TIME": "2023-02-18 05:03:13",
                "SUBMITTER_JOB_NAME": "915387/QUSER/QSQSRVR",
                "JOB_ENTERED_SYSTEM_TIME": "2023-02-18 05:03:12",
                "JOB_DESCRIPTION": "ISYSJOBD",
                "JOB_INFORMATION": "YES",
                "JOB_NAME": "932641/MSRXS/ISYSJOBD",
                "JOB_TYPE_ENHANCED": "BATCH",
                "COMPLETION_STATUS": "NORMAL",
                "JOB_DATE": "",
                "JOB_ACTIVE_TIME": "2023-02-18 05:03:12",
                "JOB_QUEUE_LIBRARY": "ISYSMODOBJ",
                "JOB_QUEUE_STATUS": "RELEASED",
                "SUBMITTER_MESSAGE_QUEUE": "MSRXS",
                "JOB_SUBSYSTEM": "",
                "SUBMITTER_MESSAGE_QUEUE_LIBRARY": "QUSRSYS",
                "JOB_SCHEDULED_TIME": "",
                "JOB_END_REASON": "JOB ENDING IN NORMAL MANNER",
                "JOB_QUEUE_PRIORITY": "",
                "JOB_END_SEVERITY": 30
            }
        ],
        "start": "2023-02-18 05:03:14.707204",
        "delta": "0:00:00.088799",
        "rc": 0
    },
    "changed": false,
    "_ansible_verbose_always": true,
    "_ansible_no_log": false
}

I tried changing the syntax of fourth tasks in various ways. But it keeps failing.

A: Your choice of variable names makes this look more confusing. the ibm.power_ibmi.ibmi_job documents these return values. As you see it will retrun you a dict of which there will be an attribute job_info which is a list. Since your register your task output also as job_info you would need to access it as
    - name: Print the job name or names
      debug:
         msg: "{{ job_info.[\"job_info\"][0][\"JOB_NAME\"] }}"

since the first job_info is the name of your var, then the second job info is an attribute of the dict which is your var. then you will be able to access the list using index [0] then lastly lookup then job name from the first index


text:
Q: Use the Android app's new commenting interface for editing comments too Recently, the Android app introduced a new way to submit comments while still being able to view the answers etc. (i.e., not in a new activity).
It'd be great to be able to edit comments with this interface, too.
Refer: https://meta.stackexchange.com/a/196914/168660

A: Done as of version 0.1.34, coming out later today!


text:
Q: I have a the following message "'collapse' argument should be a formula" while using mixture function (drc package) While using drc package for mixture prediction on microalgae growth inhibition data, specifically the mixture function, I receive an error message "'collapse' argument should be a formula" , which I don't really understand.
I'm using almost exactly the same script present in the drc package pdf available online with the data "glymet" which also concerns growth inhibition data, with just a few changes to fit my own data. The drm function manages well to estimate the parameters of the dose-response curves concerning my data.
Being not that proficient with Rstudio as a whole, I am stuck with the error message ""'collapse' argument should be a formula" "  which blocks me from doing further analysis.
Does someone has any idea of what could cause this error ? I didn't find anyone raising the same issue online, and this problem doesn't happens with glymet data.
my data :
> dbp
     dose   rgr pct
1    0.00 1.502 100
2    0.00 1.449 100
3    0.00 1.611 100
4    0.00 1.468 100
5    0.00 1.506 100
6    0.00 1.495 100
7    1.81 1.249 100
8    1.81 1.303 100
9    1.81 1.316 100
10   3.19 0.968 100
11   3.19 1.057 100
12   3.19 1.083 100
13   5.43 1.003 100
14   5.43 0.964 100
15   5.43 0.943 100
16   8.25 0.849 100
17   8.25 0.781 100
18   8.25 0.697 100
19  15.67 0.587 100
20  15.67 0.660 100
21  15.67 0.591 100
22  26.65 0.485 100
23  26.65 0.497 100
24  26.65 0.532 100
25  45.50 0.286 100
26  45.50 0.370 100
27  45.50 0.326 100
28   0.00 1.686  75
29   0.00 1.580  75
30   0.00 1.499  75
31   0.00 1.528  75
32   0.00 1.540  75
33   0.00 1.653  75
34   1.32 1.380  75
35   1.32 1.421  75
36   1.32 1.468  75
37   2.65 1.174  75
38   2.65 1.137  75
39   2.65 1.167  75
40   5.30 0.726  75
41   5.30 0.810  75
42   5.30 0.797  75
43  10.59 0.626  75
44  10.59 0.471  75
45  10.59 0.416  75
46  21.18 0.468  75
47  21.18 0.415  75
48  21.18 0.487  75
49  42.36 0.252  75
50  42.36 0.303  75
51  42.36 0.320  75
52   0.00 1.620  50
53   0.00 1.713  50
54   0.00 1.659  50
55   0.00 1.678  50
56   0.00 1.700  50
57   0.00 1.581  50
58   1.58 1.298  50
59   1.58 1.226  50
60   1.58 1.189  50
61   3.16 1.021  50
62   3.16 1.062  50
63   3.16 0.925  50
64   6.33 0.863  50
65   6.33 0.823  50
66   6.33 0.711  50
67  12.65 0.548  50
68  12.65 0.611  50
69  12.65 0.597  50
70  25.30 0.394  50
71  25.30 0.363  50
72  25.30 0.319  50
73  50.60 0.255  50
74  50.60 0.241  50
75  50.60 0.219  50
76   0.00 1.500  25
77   0.00 1.541  25
78   0.00 1.527  25
79   0.00 1.491  25
80   0.00 1.468  25
81   0.00 1.353  25
82   1.80 1.512  25
83   1.80 1.313  25
84   1.80 1.442  25
85   3.60 1.437  25
86   3.60 1.364  25
87   3.60 1.291  25
88   7.20 1.231  25
89   7.20 1.389  25
90   7.20 1.286  25
91  14.40 0.802  25
92  14.40 1.069  25
93  14.40 0.865  25
94  28.80 0.474  25
95  28.80 0.597  25
96  28.80 0.411  25
97  57.61 0.321  25
98  57.61 0.216  25
99  57.61 0.239  25
100  0.00 1.512   0
101  0.00 1.390   0
102  0.00 1.388   0
103  0.00 1.391   0
104  0.00 1.328   0
105  0.00 1.390   0
106  1.56 1.467   0
107  1.56 1.422   0
108  1.56 1.371   0
109  2.92 1.255   0
110  2.92 1.359   0
111  2.92 1.354   0
112  5.25 1.211   0
113  5.25 1.232   0
114  5.25 1.353   0
115  7.66 1.271   0
116  7.66 1.168   0
117  7.66 0.970   0
118 17.03 0.927   0
119 17.03 0.689   0
120 17.03 1.034   0
121 31.22 0.611   0
122 31.22 0.758   0
123 31.22 0.752   0
124 55.19 0.449   0
125 55.19 0.303   0
126 55.19 0.434   0

dose is corresponding to the concentration of exposure, rgr to the growth rate and pct to the percentage of the 1st substance in the mixture.
I'm using the following script for this data:
> library(drc)
>
> dbp<-read.table("dbp.txt",header=TRUE, sep="")
>
 ### data glymet
> ## Fitting the model with freely varying ED50 values
> dbp.free <- drm(rgr~dose, pct, data = dbp,
+                    fct = LL.3())
>
> ## Lack-of-fit test
> modelFit(dbp.free) # acceptable
Lack-of-fit test

          ModelDf     RSS Df F value p value
ANOVA          89 0.46595
DRC model     111 0.68575 22  1.9083  0.0181
> summary(dbp.free)

Model fitted: Log-logistic (ED50 as parameter) with lower limit at 0 (3 parms)

Parameter estimates:

       Estimate Std. Error t-value   p-value
b:100  0.836148   0.060986  13.710 < 2.2e-16 ***
b:75   0.990562   0.067962  14.575 < 2.2e-16 ***
b:50   0.819426   0.057170  14.333 < 2.2e-16 ***
b:25   1.651083   0.147962  11.159 < 2.2e-16 ***
b:0    1.217393   0.112309  10.840 < 2.2e-16 ***
d:100  1.511861   0.031439  48.089 < 2.2e-16 ***
d:75   1.605332   0.030678  52.329 < 2.2e-16 ***
d:50   1.658598   0.031896  52.001 < 2.2e-16 ***
d:25   1.472612   0.026126  56.365 < 2.2e-16 ***
d:0    1.414731   0.027300  51.822 < 2.2e-16 ***
e:100 10.070587   0.871177  11.560 < 2.2e-16 ***
e:75   6.293939   0.474130  13.275 < 2.2e-16 ***
e:50   5.670343   0.491531  11.536 < 2.2e-16 ***
e:25  20.022984   1.153494  17.359 < 2.2e-16 ***
e:0   27.492564   2.023952  13.584 < 2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error:

 0.07859961 (111 degrees of freedom)
> ## Plotting isobole structure
> isobole(dbp.free)
>
> ## Fitting the concentration addition model
> dbp.ca <- mixture(dbp.free, model = "CA")
Error in mixture(dbp.free, model = "CA") :
  'collapse' argument should be a formula

Thank you in advance! It's my first post so don't hesitate to tell me if an information is missing.


text:
Q: how to write csv file using python i have a python script that read from csv file and store the values in a list,
where the values are Dates row[0], float row[10] , Boolean row[11].
the script work perfectly in reading part  but when i try to write the selected values to a second CSV file the system create a file with just the headers, and the system crash  with displaying this error:

line 62, in
  fwriter.writerow("{}:{}:{}".format(row[0],row[10],row[11]))
builtins.IndexError: string index out of range

where is the error in the code?
code:
          import csv

            mydelimeter = csv.excel()
            mydelimeter.delimiter=";"
            myfile = open("C:/Users/test/Documents/R_projects/homework/rdu-weather-history.csv")

            # read the first line in the opened file ==> Header
            myfile.readline()

            myreader=csv.reader(myfile,mydelimeter)

            result=[]

            '''
            create a variable that handle values of the 3 fields
 ==> Date - fastest5secwindspeed - fog
             and display the result where
                 fog ==> Yes    and highest speed  more than 10.
            '''

            for index ,row in enumerate(myreader):
                try:
                    '''
                    check if the values in the fog colums is == Yes
                    if ok
                    check if the column of the "fastwindspeed"
is  empty ==>  raise Exception
                    check if the value in column of the "fastwindspeed"
 is < 10.0 ==>  raise Exception

                    else  print the results
                    '''
                    if row[11] =="Yes":
                        if row[10] in (None, ""):
                            raise Exception( "this Record has empty value" )
                        if float(row[10]) < 10.0:
                            raise Exception( 'the wind speed  is below 10 mph in ' + row[0] )
                        print(row[0],row[10],row[11])
                        '''
                        append the result into a list
 in order to use it in the writing of the new csv file
                        '''
                        result.append(row[0])
                        result.append(row[10])
                        result.append(row[11])
                except Exception as e:
                    print("{}:{}".format(index ,e))
          myfile.close()
             '''
    create a second csv file and append the selected result from the  1st csv file
    '''
            with open("C:/Users/test/Documents/Python_Projects/rduSpeedFog.csv", "w") as f:
                headers = ["Date","WindSpeed","Fog"]

                fwriter=csv.writer(f,mydelimeter)

                fwriter.writerow(headers)

                for row in result:

                    fwriter.writerow("{}:{}:{}".format(row[0],row[10],row[11]))

                print("Writing Complete")
            f.close()

after using the answer of @Bamar
i got this result
csv file as result

A: In the first loop, each string is put into a separate element of the result list, so it's not a list of rows.
You should change that loop to use:
result.append([row[0], row[10], row[11]])

to append those fields as a list for each row.
In the second loop you're using a csv.writer, so it will add the delimiters, and you shouldn't use format. Just write:
fwriter.writerow(row)

And if you want the field delimiter to be : in the output file, use:
fwriter=csv.writer(f,":")

A: writerow takes a sequence as a parameter, but you are passing a string. Try to pass your values as a list.


text:
Q: Reusable editor template with DropDownList for business objects I'm using MVC3 with Razor views and would like to build reusable DropDownLists for several of my classes, but after much searching I have not found an example that performs exactly how I need it...
For this example I have two classes like this:-
public class Person
{
  public int ID { get; set; }
  public string Name { get; set; }
  public Group Group { get; set; }
}

public class Group
{
  public int ID { get; set; }
  public string Name { get; set; }
}

I have a working Controller/View for Person. The view has a DropDownListFor control:
@model Person

...

@Html.DropDownListFor(o => o.Group.ID, (ViewData["groups"] as SelectList))

The view uses the Person class directly, not an intermediary model, as I haven't found a compelling reason to abstract one from the other at this stage.
The above works fine... in the controller I grab the value from Group.ID in the Person returned from the view, look it up, and set Person.Group to the result. Works, but not ideal.
I've found a binder here: MVC DropDownList values posted to model aren't bound that will work this out for me, but I haven't got that working yet... as it only really seems useful if I can reuse.
What I'd like to do is have something like this in a template:-
@model Group

@Html.DropDownListFor(o => o.Group.ID, (ViewData["groups"] as SelectList))

And use it in a view like this:-
@Html.EditorFor(o => o.Group)

However the above doesn't seem to work... the above EditorFor line inserts editors for the whole class (e.g. a textbox for Group.Description as well)... instead of inserting a DropDownList with my groups listed
I have the above template in a file called Group.cshtml under Views/Shared/EditorTemplates
If this worked, then whenever a class has a property of type Group, this DropDownList editor would be used by default (or at least if specified by some attribute)
Thanks in advance for any advice provided...

A: You can create a drop down list user control to handle this.  Under your Shared folder create a folder called EditorTemplates and place your user control there.  MVC, by convention, looks in the Shared/EditorTemplates for any editor templates.  You can override where it looks for the editor templates but I won't go in to that here.
Once you have your user control created, you'll need to decorate the appropriate property with the "UIHint" attribute to tell the engine what editor it should use for that property.
Following would be a sample implementation.
In the Shared/EditorTemplates folder your user control (_GroupsDropDown.cshtml in this case) would look like:
@model Group

@Html.DropDownListFor(o => o.ID, (ViewData["groups"] as SelectList))

Modify the Group property in the Person to add the UIHint attribute as follows:
**[UIHint("_GroupsDropDown")]**
public Group Group { get; set; }

In your controller you would need
ViewData["groups"] = new SelectList(<YourGroupList>, "ID", "Name");

Once you have the above code you can use the EditorFor syntax like you desire.
Hope this helps.


text:
Q: flash_ask not fond all overthe python i use this code install flask
pip install flask
pip3 install flask

i import flask like this
from flask import Flask
from flask_ask import Ask, statement, question, session

when i try to run
python test.py
python3 test.py

both are give this error
from flask_ask import Ask, statement, question, session
ImportError: No module named flask_ask

try all this code
python3.6 -m pip install flask_openid
sudo apt-get install python-flask

its not solve my problem
pip --version : pip 18.1  from /home/ghost/.local/lib/python2.7/site-packages/pip (python 2.7)
pip3 --version    :  pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

*

*i try this answers as well
2.flask installed, but ModuleNotFoundError: No module named 'Flask'

*from Flask import Flask ImportError: No module named Flask

A: You've installed flask but not flask-ask which is a separate module.
pip install flask-ask

A: Use this command to download flask-ask
pip install git+https://github.com/johnwheeler/flask-ask.git@v0.8.8