text:
Q: Spring boot + Thymeleaf + webjars Bootstrap 4 I'm trying to add bootstrap to my Spring Boot project using Thymeleaf.
index.html
<!DOCTYPE html >

footer.html

header.html

    <meta charset="UTF-8">
    <title>Модуль планирования ПД</title>
    <link th:rel="stylesheet"  th:href="@{webjars/bootstrap/4.0.0-1/css/bootstrap.min.css} "/>

MvcConfig.java
    @Configuration
public class MvcConfig implements WebMvcConfigurer {

   @Override
   public void addResourceHandlers(ResourceHandlerRegistry registry) {
      registry
              .addResourceHandler("/webjars/**")
              .addResourceLocations("/webjars/")
              .resourceChain(false);
   }
}

Styles doesn't applied to page and throwing error:
 in jquery, bootstrap, popper.
How I can solve this problem?
Thanks.

A: If you are using the org.webjars dependency in your pom.xml, then probably you should add slash / before webjars/... and leave the attribute rel="stylesheet" in your header.html:
<link rel="stylesheet" th:href="@{/webjars/bootstrap/4.0.0-1/css/bootstrap.min.css} "/>

Also try to run it without MvcConfig configuration class.

A: To make more easy I got webjars-locator:
 <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>bootstrap</artifactId>
        <version>4.0.0-2</version>
    </dependency>
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>webjars-locator</artifactId>
        <version>0.30</version>
    </dependency>

And at my page, at the end, I put:

And need to setup this WebMvcConfigure class:
@Configuration
public class SpringMVCConfiguration implements WebMvcConfigurer {
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
  "classpath:/META-INF/resources/",
  "classpath:/resources/",
  "classpath:/static/",
  "classpath:/public/"};

  @Override
 public void addResourceHandlers(ResourceHandlerRegistry registry) {
 registry.addResourceHandler("/**")
 .addResourceLocations(CLASSPATH_RESOURCE_LOCATIONS);
 registry.addResourceHandler("/webjars/**")
 .addResourceLocations("/webjars/").resourceChain(false);
   }
 }

I did not use any other setup in Spring boot to work with.

A: With Spring Boot, WebJars are auto-configured. There is no need to add any handlers or other configurations. When you run your application (without any configs), you can see a log like this:
... Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]

So deleting your MvcConfig class may resolve the problem.
In fact my Spring Boot application was similar to yours (but without that configuration file) and worked perfectly. When I added your configuration to my application, WebJars didn't work anymore!

A: Also you can fix that by adding webjars dependencies in following way
   <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>bootstrap</artifactId>
        <version>4.3.1</version>
    </dependency>
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>jquery</artifactId>
        <version>3.4.0</version>
    </dependency>

And by adding them in to your templates header
<link rel="stylesheet" th:href="@{/webjars/bootstrap/4.3.1/css/bootstrap.min.css}"/>

Then if you run your Spring-Boot application and view page source you will get the access to this files, by clicking on the link at the runtime.


text:
Q: AWK : Unzipping and printing File Name and first line I am trying to unzip files in folder and print first line LASTMODIFIEDDATE
But the below will print First line with '-'
for file in /export/home/xxxxxx/New_folder/*.gz;
do
gzip -dc "$file" |  awk 'NR=1 {print $0, FILENAME}' |  awk '/LASTMODIFIEDDATE/'
done

1.How can i modify the above code to print filename that is unzipped.
2.I am a beginner and suggestion to improve the above code are welcome

A: A few issues:
Your first awk should have double equals signs if you mean to address the first line:
awk 'NR==1{...}'

Your second awk will only ever see the output of the first awk, which only shows the first line, so you will not see any lines with LASTMODIFIED in them unless they are the first. So this will show you the first line and any lines containing LASTMODIFIED.
for ...
do
   echo $file
   gzip -dc  "$file" | awk 'NR==1 || /LASTMODIFIED/'
done

Or you may mean this:
for ...
do
   gzip -dc  "$file" | awk -v file="$file" 'NR==1{print $0 " " file} /LASTMODIFIED/'
done

which will print the first line followed by the filename and also any lines containing LASTMODIFIED.

A: Do this with an echo. Also you might want to use grep instead of awk in this case.
for file in /export/home/xxxxxx/New_folder/*.gz;
do
    echo $file
    gzip -dc "$file" | grep LASTMODIFIEDDATE
done

redpajama_set_name: RedPajamaStackExchange


text:
Q: nginx refuses connections after some time I have a problem with my nginx configuration, my server works fine but after 1 or 2 days it just hangs and stop responding. It's not possible to connect to the server anymore.
(7) Failed to connect to XX.XX.XX.XX port 80: Connection refused

The main job of this server is running heavy PHP tasks, I run cron jobs every 5 seconds for many tasks. Restart helps and again nginx works correctly for the next 1-2 days. I don't have any error logs, nginx dosn't report anything in /var/log/nginx/error.log. It simply fails all connections. Any ideas where to start looking for a problem?
I run nginx on Ubuntu 16.04, 2 CPUs, 4 GB ram with PHP 7.0.
nginx version: nginx/1.10.0 (Ubuntu)
here is config file:
 user www-data;
 worker_processes 2;
 pid /run/nginx.pid;

 events {
  worker_connections 4096;
  #multi_accept on;
 }

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 300;
types_hash_max_size 2048;
server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# SSL Settings
##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

here is default file:
server {
 large_client_header_buffers 4 128k;
 listen XX:XX:XX:XX:80;

 set $root_path '/var/www/web/public/';

 root $root_path;
 index index.php;

 server_name XX:XX:XX:XX;

 location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ /index.php?$query_string;
 }

 location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    fastcgi_read_timeout 14400;

    proxy_set_header   Connection "";
    proxy_http_version 1.1;
 }

 location /status {
        stub_status on;
        access_log  off;
        allow XX:XX:XX:XX;
        deny all;
 }

 location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
    root $root_path;
 }

 # deny access to .htaccess files, if Apache's document root
 # concurs with nginx's one
 location ~ /\.ht {
    deny all;
 }
}

And the main thing, my cron jobs I run, for example:
* * * * * sleep 5; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1
* * * * * sleep 10; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1
* * * * * sleep 15; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1
* * * * * sleep 20; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1
* * * * * sleep 25; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1
* * * * * sleep 30; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1
* * * * * sleep 35; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1
* * * * * sleep 40; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1
* * * * * sleep 45; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1
* * * * * sleep 50; curl --request GET http://XX:XX:XX:XX/queue/fire > /dev/null 2>&1

etc.
UPDATE:
PHP FPM Status
 * php7.0-fpm.service - The PHP 7.0 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.0-fpm.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2017-01-13 10:46:41 CET; 3 days ago
  Process: 1439 ExecStartPre=/usr/lib/php/php7.0-fpm-checkconf (code=exited, status=0/SUCCESS)
 Main PID: 1662 (php-fpm7.0)
   Status: "Processes active: 0, idle: 25, Requests: 164215, slow: 0, Traffic: 0req/sec"
    Tasks: 26
   Memory: 377.3M
      CPU: 5h 57min 32.279s
   CGroup: /system.slice/php7.0-fpm.service
           |- 1662 php-fpm: master process (/etc/php/7.0/fpm/php-fpm.conf)
           |- 1752 php-fpm: pool www
           |- 8751 php-fpm: pool www
           |-12078 php-fpm: pool www
           |-14053 php-fpm: pool www
           |-14338 php-fpm: pool www
           |-14639 php-fpm: pool www
           |-14763 php-fpm: pool www
           |-16188 php-fpm: pool www
           |-16212 php-fpm: pool www
           |-16900 php-fpm: pool www
           |-17620 php-fpm: pool www
           |-17621 php-fpm: pool www
           |-17766 php-fpm: pool www
           |-18802 php-fpm: pool www
           |-19084 php-fpm: pool www
           |-22064 php-fpm: pool www
           |-24245 php-fpm: pool www
           |-24690 php-fpm: pool www
           |-25120 php-fpm: pool www
           |-27714 php-fpm: pool www
           |-29415 php-fpm: pool www
           |-30182 php-fpm: pool www
           |-30391 php-fpm: pool www
           |-32053 php-fpm: pool www
           `-32358 php-fpm: pool www

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

A: I would check php fpm logs. Maybe running out of php fpm processes.


text:
Q: Ссылка на url в адресной строке javascript Возникла необходимость вставить ссылку в адресную строку веб-браузера и перейти, то есть не просто сделать переход по ссылке из javascript, а переход в браузере. Если что знаете на эту тему напишите пожалуйста.

A: Чтобы имитировать действия пользователя нужно использовать сторонние библиотеки например puppeteer


text:
Q: How to apply a filter on LINQtoSQL results? With the ListBox control it is possible to feed it a DataSource, name a DisplayMember and a ValueMember and through some magic it will display a field from the DataSource and return a selected ValueMember. It can work wit a linq-to-sql result without even knowing anyting specific about the table it is feed with.
Isn't Reflection and Attributes doing some magic? How does it work!
I have a need to do something similar but I do not know where to start. I'm a beginner for LINQtoSQL.
This is what I want to do.
I have a source table that I want to filter. The source table can be anything but will be originating from some DataContext.
var MySourceTable =
    from MyRecord in Context.GetTable<MySourceTable>()
    select new
    {
        Value = MyRecord.ID,
        Display = MyRecord.Name,
        FilterValue = MyRecord.Value
    };

In my control I want to be able to filter MySourceTable on some given value. The control does not know what table is used (MySourceTable in the example above) and the control does only know the three names, ID, Name and Value of the fields in the record it should use.
The filter query should look like the example below.
var MyTable
    from Record in MySourceTable
    where FilterValue == GivenValue
    select new
    {
        Value = Record.ID,
        Display = Record.Name,
    };

Can somebody advise me on where to start?

A: It looks like what you are missing is in the where condition on your query. It should look like this:
var MyTable =
    from Record in MySourceTable
    where Record.FilterValue == GivenValue
    select new
    {
        Value = Record.ID,
        Display = Record.Name,
    };

GivenValue is presumably a local variable or property containing whatever you want to compare FilterValue against. But FilterValue is a property of the anonymous type that you created in your first query that created MySourceTable. In your second query, Record is an instance of that anonymous type, and you have to use that reference to the instance in all other parts of the query to reference the instance that you are checking for the where clause or selecting for the select clause. If you just put FilterValue there, then it has no idea what you mean.

A: I found a way, it works but is not a completely satisfying method.
The 'problem' (compared to my original question) is that it does not use linq-to-sql for filtering the source. But it works and that is at the moment fine for me.
Recap:
At a high level module I prepare a LINQtoSQL statement which will result in some IQueriable<Object>, effectively an IQueriable object. This object is given to a lower level module together with three names, one for the ID, one for the Display and one for filtering.
When I need more control over the source, e.g. for unfiltered data that will result in huge results or for complex LINQtoSQL queries I will use a delegate function. That will give me all the control I want.
At a low level I have a IQueriable<Object> and no knowledge at all about the Object, except for wat Reflection can tell me. I generate a table of results that I want to use in a control-specific format. (the Record class). For anything more complex that my standard code cannot handle I offer a delegate that must result in some list of object in which the object must have at least a property named 'Display' and a property named 'Value'. Other properties are possible but will not be used.
This is the solution that I finaly got to work:
public partial class MySelector : UserControl
{
    class Record
    {
        public object Display { get; set; }
        public object Value { get; set; }
    }

    ....

    public string MyDisplayMember { get; set; }
    public string MyValueMember { get; set; }
    public string MyExternalMember { get; set; }

    ....

    static Object Filter(MySelector sender, Object criterium)
    {
        IQueryable source = sender.MySource as IQueryable;
        if (source == null) return null;

        List<Record> result = new List<Record>();

        // drawback: this foreach loop will trigger a unfiltered SQL command.
        foreach (var record in source)
        {
            MethodInfo DisplayGetter = null;
            MethodInfo ValueGetter = null;
            bool AddRecord = false;

            foreach (PropertyInfo property in record.GetType().GetProperties())
            {
                if (property.Name == sender.MyDisplayMember)
                {
                    DisplayGetter = property.GetGetMethod();
                }
                else if (property.Name == sender.MyValueMember)
                {
                    ValueGetter = property.GetGetMethod();
                }
                else if (property.Name == sender.MyExternalMember)
                {
                    MethodInfo ExternalGetter = property.GetGetMethod();
                    if (ExternalGetter == null)
                    {
                        break;
                    }
                    else
                    {
                        object external = ExternalGetter.Invoke(record, new object[] { });
                        AddRecord = external.Equals(criterium);
                        if (!AddRecord)
                        {
                            break;
                        }
                    }
                }
                if (AddRecord && (DisplayGetter != null) && (ValueGetter != null))
                {
                    break;
                }
            }
            if (AddRecord && (DisplayGetter != null) && (ValueGetter != null))
            {
                Record r = new Record();
                r.Display = (DisplayGetter == null)
                    ? null
                    : DisplayGetter.Invoke(record, new object[] { });
                r.Value = (ValueGetter == null)
                    ? null
                    : ValueGetter.Invoke(record, new object[] { });
                result.Add(r);
            }
        }
        return result;
    }
}

A: I wrote a filter engine that takes in a Property and Value as a string, and is able to use that as a where clause.
IQueryable<T> FilterFunction<T>(IQueryable<T> query)
{
    ParameterExpression p = Expression.Parameter(typeof(T), "notused");

    Expression<Func<T, bool>> wherePredicate =
      Expression.Lambda<Func<T, bool>>(
          Expression.Equal(
            Expression.Call(Expression.Property(p, FilterProperty), "ToString", new Type[0]),
            Expression.Constant(FilterValue)), p);

    return query.Where(wherePredicate);
}

You should be able to pass in an Expression<Func<T, TResult>> built in a similar way into query.Select()
If I am understanding your question correctly, I believe this will work:
string DisplayProperty = "Name";
string ValueProperty = "ID";

IQueryable<Record> SelectRecordProperties<T>(IQueryable<T> query)
{
    ParameterExpression p = Expression.Parameter(typeof(T), "notused");

    MethodInfo ctorMethod = typeof(Record).GetMethod("Create");

    Expression<Func<T, Record>> selectPredicate =
      Expression.Lambda<Func<T, Record>>(
        Expression.Call(ctorMethod,
            Expression.PropertyOrField(p, DisplayProperty),
            Expression.PropertyOrField(p, ValueProperty)), p);

    return query.Select(selectPredicate);
}
class Record
{
    public static Record Create(string display, string value)
    {
        return new Record() { Display = display, Value = value };
    }
    public object Display { get; set; }
    public object Value { get; set; }
}

So for your full function you'd need to combine these two ideas so that your filtering works.
By the way, there are many possible ways to build the expression tree for this, there was some tool I've found at one point which would show you the expression tree I think, so you could manually write the linq query and see how .Net builds the expression, then modify this code to build it based on that to possibly get a more efficient expression tree.


text:
Q: using @package. When and how to use it?
Possible Duplicate:
What does the @package directive do in Objective-C?

I have only seen @package twice since starting iOS programming (and I've been doing this a while now).
What is @package used for? I believe it specifies where you can access variables from but I'm not sure of the exact rules?

A: It's for cases when you write a portable library, the visibility level is then set to your library, but not for the other source code that will make use of it.


text:
Q: How to add a design time service reference to a console application in VS 2010? I'm trying to create a simple WCF application. My service interfaces and implementations are in class libraries. I have written a very simple console application that acts as a server host.
Now I have created a silverlight client, and I'm trying to add a service reference, using the App.config in the console application, but the configured services are not showing up in the Discover->Services In Solution.
They do show up if I create a WCF class library to contain my services, but not a normal class library with an app.config.
I can run the console application and add the service reference then, but that seems a bit clumsy.
What are the rules for adding design-time service references?
Edit
Visibility of a project to design-time discovery appears to be controlled by the following project types:
{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
(adding these to a csproj requires that it contains at least one service).
Another rule appears to be that the service types have to be in the same assembly as the app.config that references them.

A: I believe Visual Studio uses different project types in your solution (metadata stored either in the solution-/project file or both) to identify potential candidates. If you create a console application Visual Studio won't treat it as if it could contain service reference, though as I think you've already figured out, changing the target type after the project has been created doesn't seem to have this effect because it doesn't invalidate that metadata.
Create two new projects, one of each and compare the two files with a diff tool or just notepad. See if copy the change between the projects and reloading (or even restarting VS) changes this behavior.


text:
Q: new String(byte[]) gives different results when I put it in vs pull it out of the database Before I save a byte array to the database if I print the output of new String(data) it returns a readable string like "foobar" but after I pull it out of the database, new String(data) will read like a bunch of gibberish like "9238929384739427349327...".  There's so many parts here I'll just try to list them all.  I'm using eclipselink and my data column is defined:
@Lob
@Column(name = "data")
private byte[] data;

If I run this code:
public static void main(String[] args) {
    System.out.println(Charset.defaultCharset());
}

It outputs windows-1250.
My database is defined as:
CREATE DATABASE project_trunk
  WITH OWNER = project
       ENCODING = 'UTF8'
       TABLESPACE = pg_default
       LC_COLLATE = 'English_United States.1252'
       LC_CTYPE = 'English_United States.1252'
       CONNECTION LIMIT = -1;

I've also tried this on a DB defined like this:
CREATE DATABASE project_trunk
  WITH OWNER = project
       ENCODING = 'UTF8'
       TABLESPACE = pg_default
       LC_COLLATE = 'en_US.UTF-8'
       LC_CTYPE = 'en_US.UTF-8'
       CONNECTION LIMIT = -1;

And the problem still occurs.
I think what's happening is my database has a different encoding from my appserver.  When I put things into the database and pull it out again, it decodes it the wrong way so it looks like gibberish.  Am I on to something there?
Now when it comes to a solution to this problem, I'm a little confused.  I think what I should be doing is changing my appserver's file encoding to be the same as the database.  I'm using Glassfish 2.1.1.  When I go to application server -> advanced -> domain attributes and set the Locale to "UTF8" or "UTF-8" it tells me a restart is required.  After I restart glassfish, that field is still blank and I still get the error.  I think maybe it isn't saving the property.  I'd manually put it in the configuration file, but I don't know where or what to put.
Alternatively, I tried creating my database with an ENCODING = 'WIN1250' but when I do that it says my LC_CTYPE needs to be "WIN1252".  When I set LC_CTYPE to "WIN1252" it says that encoding doesn't exist.

I'm spending a lot of time on this, I'd like to know if I'm on to something here.  Does my theory of "out of sync encodings between appserver and db" sound correct, or am I chasing a red herring?  If anyone could help me figure out how to change this setting for glassfish 2.1.1 that'd also be very helpful.  Thanks
EDIT: People are asking why I'm storing Strings as raw bytes.  That's not exactly what I'm doing, sometimes the raw bytes represent an image or a pdf or a binary, sometimes it's text.  My test is inserting a plain text String and pulling it back out to make sure it got saved correctly.  This test passes on our CI server which is on linux.
EDIT2: I was asked to show the raw binary input vs raw binary output.

Expected :[116, 104, 105, 115, 32, 105, 115, 32, 109, 121, 32, 97, 116, 116, 97, 99, 104, 109, 101, 110, 116, 32, 97, 115, 32, 97, 32, 83, 116, 114, 105, 110, 103]
Actual   :[60, 54, 56, 54, 57, 55, 51, 50, 48, 54, 57, 55, 51, 50, 48, 54, 100, 55, 57, 50, 48, 54, 49, 55, 52, 55, 52, 54, 49, 54, 51, 54, 56, 54, 100, 54, 53, 54, 101, 55, 52, 50, 48, 54, 49, 55, 51, 50, 48, 54, 49, 50, 48, 53, 51, 55, 52, 55, 50, 54, 57, 54, 101, 54, 55]

I gave this same test that checks the bytes to my coworker who's on a mac, and it passes for him.

A:
sometimes the raw bytes represent an image or a pdf or a binary, sometimes it's text

Okay, then you shouldn't be storing them as text.
Regardless of what's currently going wrong, even if you can get this to work for data which is actually text, you've got problems coming later on.
If you must store arbitrary binary data as text, you should use base64 to encode it - that way you can get back to the original binary with no problems. (You've only got to be able to transport ASCII strings around, and that's usually reasonably easy.) There are lots of third-party libraries for Base64; I like this self-contained public domain one.
Alternatively, store the data as binary data in the database, e.g. using a field of the bytea data type. That way you shouldn't need to do any conversion work: you should just be able to put it into the database as a byte array, and get it out as a byte array.
EDIT: Okay, it looks like you're getting back the hex representation of the binary data, but in ASCII. That's distinctly odd.

A: Turns out this is caused by a way that PostgreSQL works in version 9 vs version 8.  Most of my coworkers were using version 8 but I recently got a new computer so I used the latest PostgreSQL.
You need to set the output_bytea to "escape".
Getting nearly double the length when reading byte[] from postgres with jpa
I didn't find the answer there sufficient though, but I found this on a mailing list and it fixed my issue:  http://www.postgresql.org/message-id/AANLkTikkE-jQ9srZ9VL1JuJ5h=UCutx8ZLim+OfQ1T4z@mail.gmail.com

Dear List ,
recent change of bytea_output format from escape to hex in 9.0 apparently breaks
  popular persistent session handling perl modules like Apache::Session::Postgres
  which stores pickled data structures in bytea columns of db table.
  It is difficult to guess the root cause from the exception thrown by
  the said module.
  The problem is fixed by adding
  bytea_output='escape'  in postgresql.conf
  and issuing a pg_ctl reload.
Eg in RT application the error is:
  error:  RT couldn't store your session.
  This may mean that that the directory /blah/blah/foo/bar isn't
  writable or a database table is missing or corrupt
Regds
  Rajesh Kumar Mallah.


text:
Q: Data not refreshing when using actionscript to assign dataprovider My problem is when I assign the dataprovider for a spark list using actionscript it does not automatically update the list. example:
I have a list:
< s:List id="fiterList" allowMultipleSelection="true" width="100%" height="100%"/>
and I use actionscript to assign the dataprovider:
filterList.dataProvider = model.ADEPTList; (where model.ADEPTList is an ArrayCollection)
When I use an event to update model.ADEPTList the data does not show up in the list.
HOWEVER,
if I instead declare the dataprovider in the MXML like this:
< s:List id="filterList" allowMultipleSelection="true" width="100%" height="100%" dataProvider="{model.ADEPTList}"/>
When the event updates model.ADEPTList it DOES show up in the list. Why is this and how can I get the list to update when assigning the dataprovider using actionscript? Thanks

A: That's because that's only an assignment, you're not binding your list's dataProvider to model.ADEPTList.
You have to read more about flex binding mechanisms. In AS3 you could use:
BindingUtils.bindProperty(filterList,"dataProvider",model,"ADEPTList");


text:
Q: How can I get a world's seed in Minecraft Beta 1.7.3? I have a world in Minecraft Beta 1.7.3 and I need it's seed. Please note that F3 or /seed doesn't work because these features are not in Beta 1.7.3. Are there any tricks or programs I could use?

A: You can upload the level.dat file to MineAtlas.com.
It allows you to see the seed.

A: use re-create button, then go to more options there you would see the seed of map you are playing. I am 100% sure that the button would be in 1.7.3, because I used to recreate maps in 1.7.2

A: In 1.3 and above you can type /seed into the console to view it.


text:
Q: Postgresql select from 2 tables. Joins? I have 2 tables that look like this:
    Table "public.phone_lists"
  Column  |       Type        |                             Modifiers
----------+-------------------+--------------------------------------------------------------------
 id       | integer           | not null default nextval(('"phone_lists_id_seq"'::text)::regclass)
 list_id  | integer           | not null
 sequence | integer           | not null
 phone    | character varying |
 name     | character varying |

and
Table "public.email_lists"
 Column  |       Type        |                             Modifiers
---------+-------------------+--------------------------------------------------------------------
 id      | integer           | not null default nextval(('"email_lists_id_seq"'::text)::regclass)
 list_id | integer           | not null
 email   | character varying |

I'm trying to get the list_id, phone, and emails out of the tables in one table. I'm looking for an output like:
list_id |    phone    |             email
---------+-------------+--------------------------------
       0 |             | jqeron@wqwerweper.com
       0 |             | qwerox@wqwekeeper.com
       0 |             | erreon@fdfdeper.com
       0 |             | sfar@weasdfer.com
       0 |             | rawq@gdfefdgheper.com
       1 | 15555555555 |
       1 | 15555551806 |
       1 | 15555555508 |
       1 | 15055555506 |
       1 | 15055555558 |
       1 |             | rfoasdfx@wefdaser.com
       1 |             | radfy@wfdfder.com

I've come up with
select pl.list_id, pl.phone, el.email from phone_lists as pl left join email_lists as el using (list_id);

but thats not quite right. Any suggestions?

A: SELECT  list_id, phone, email
FROM    (
        SELECT  list_id, NULL AS phone, email, 1 AS set_id
        FROM    email_lists
        UNION ALL
        SELECT  list_id, phone, NULL AS email, 2 AS set_id
        FROM    phone_lists
        ) q
ORDER BY
        list_id, set_id


text:
Q: How to avoid if/else when the if condition can be calculated in compile time For example:
if (sizeof(long) == 4)
{
    ...
}
else
{
    ...
}

I think there should be an elegant way to avoid this kind of if/else, maybe something like std::conditional, but I can't find. thanks :)

A: Are you perhaps referring to tag dispatching?
#include <iostream>
#include <type_traits>

void
process(std::true_type)
{
    std::cout << "sizeof(long) == 4\n";
}

void
process(std::false_type)
{
    std::cout << "sizeof(long) != 4\n";
}

int
main()
{
    process(std::integral_constant<bool, sizeof(long) == 4>{});
}


text:
Q: Dynamically creating a compressed Bitmap I'm writing a custom printing app in Android and I'm looking for ways to save on memory. I have three basic rectangles I need to print on a full page. Currently I'm creating a base Bitmap the size of the page:
_baseBitmap = Bitmap.createBitmap(width/_scale, height/_scale, Bitmap.Config.ARGB_8888);

The print process requests a Rect portion of that page. I cannot predetermine the dimensions of this Rect.
newBitmap = Bitmap.createBitmap(fullPageBitmap, rect.left/_scale, rect.top/_scale, rect.width()/_scale, rect.height()/_scale);
return Bitmap.createScaledBitmap(newBitmap, rect.width(), rect.height(), true);

Using bitmap config ARGB_8888 _baseBitmap is about 28MB (8.5"x11" @ 300dpi = 2250*3300*4bytes). Even at 50% scaling (used above), my image is over 7MB. Scaling any smaller than this and image quality is too poor.
I've attempted to create _baseBitmap using Bitmap.Config.RGB_565, which does greatly reduce the full image size, but then when I overlay an image (jpegs) I get funny results. The image is compressed in width, duplicated next to itself, and all the color is green.
BitmapFactory.Options options = new BitmapFactory.Options();
options.inDither = true;
options.inPreferredConfig = Bitmap.Config.RGB_565;
Bitmap myBitmap = BitmapFactory.decodeStream(input, null, options);
input.close();
return myBitmap;

....

private static Bitmap overlay(Bitmap bmp1, Bitmap bmp2, float left, float top) {
    Canvas canvas = new Canvas(bmp1);
    canvas.drawBitmap(bmp2, left, top, null);
    return bmp1;
}

I know I can compress an image of these dimensions down to a reasonable size. I've looked into Bitmap.compress, but for some reason beyond my understanding I'm getting the same size image back:
ByteArrayOutputStream os = new ByteArrayOutputStream();
_baseBitmap.compress(Bitmap.CompressFormat.JPEG, 3, os);

byte[] array = os.toByteArray();
Bitmap newBitmap = BitmapFactory.decodeByteArray(array, 0, array.length);

_baseBitmap.getAllocationByteCount() == newBitmap.getAllocationByteCount()
It would be better to create it compressed than to create a large one and then compress it. Is there any way to create a compressed Bitmap? Any advice is greatly appreciated.
note: Not an Android expert. I'm not necessarily familiar with the platform specific terms you may use to respond. Please be gentle.

A: Try something like this, if you have a target size in mind.
private static final int MAX_BYTES_IMAGE = 4194304; // 4MB

//...

ByteArrayOutputStream out;
int quality = 90;
do
{
    out = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, quality, out);
    quality -= 10;
} while (out.size() > MAX_BYTES_IMAGE_FILESIZE);

out.close();


text:
Q: View/test websites on new server, without changing domain's DNS I'm pretty sure it's possible, I just don't exactly know how to; but I was wondering how I could view/test my website(s) without changing the DNS?
I'm migrating my websites from provider X (server IP: 159.253.1.196) to provider Y (server IP: 95.85.38.205) and before changing the DNS and I would like to test everything.
I might have done this before, by changing my host file, but I'm not completely sure if that's the right way, or even how do, again.
Since I should be able to access the old server, too, there should be a rather easy way to check the website on the new and old location, in best case simultaneously, but switching from one to another wouldn't be much a problem. The best solution therefor would be to have the new server been shown in Firefox, and the old server is shown in Chrome, but I'm unsure if you can change browser dependently..
Thanks in advance!

A: You should be able to simply create a hostfile entry as you stated.
WINDOWS:
C:\Windows\System32\Drivers\Etc\hosts
95.85.38.205     www.siteurl.com
Once you save that, try to go to the URL in question, and it should be the new side.  If you use Chrome or Firefox, you can use an add-on called HTTP Headers, or Firebug respectively.  This is about the most basic way to do it.
EDIT:  To clarify, the add-on's mentioned above are to show the servers response headers to YOUR HTTP request.  They aren't to manipulate the initial request like you would using CURL in Linux.  I like to typically set my servers up with response headers that give at least a unique identifier like "PUBLIC-IDENTIFIER" where the value is something like "MY-SERVER-NAME" so that I know which one I'm hitting publicly behind a load balancer.  Even without the load balancer, the principal and idea is the same.  Ensure you have a way to identify the server you are hitting.  How you do this will be dictated by which Server OS and Web Server you are running.
Thanks!

A: these try to solve a similar problem
https://superuser.com/questions/184643/override-dns-in-firefox
https://stackoverflow.com/questions/857376/send-host-header-when-accessing-ip-address-in-firefox
but some of those addons work via the hosts file anyway. you might need the live-http-headers which allows upstream request modification.
I like the dns-via-socks approach, but that needs some setup and a ssh client+account.


text:
Q: ContainerRequestFilter method not being called on WAS liberty I have filter class on my WAS Liberty server:
// TestRequestFilter.java
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.PreMatching;
import javax.ws.rs.ext.Provider;

@Secured
@Provider
@PreMatching
public class TestRequestFilter implements ContainerRequestFilter
{
    private final static Logger log = Logger.getLogger(DemoRESTRequestFilter.class.getName());

    @Override
    public void filter(ContainerRequestContext requestCtx) throws IOException
    {
        System.out.println("FILTER-REQUEST");
    }
}

And custom annotation:
@NameBinding
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface Secured {

}

And a rest call:
@GET
    @Consumes({ MediaType.APPLICATION_JSON })
    @Produces({ MediaType.APPLICATION_JSON })
    @Secured
    public Response login(@HeaderParam("Authorization") String authorization) {
        return Response.ok("OK").build();
    }

Server.xml:
<!-- Enable features -->
<featureManager>
    <feature>javaee-7.0</feature>
    <feature>localConnector-1.0</feature>
    <feature>appSecurity-2.0</feature>
</featureManager>

How to make Filter work on a WAS ?

A: You need to register TestRequestFilter:
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import java.util.HashSet;
import java.util.Set;

@ApplicationPath("/")
public class RestApplication extends Application
{
    @Override
    public Set<Object> getSingletons()
    {
        Set<Object> singletons = new HashSet<>();
        singletons.add(new TestRequestFilter());
        // register others, if any
        return singletons;
    }
}


text:
Q: Why is shift faster than index access in this JavaScript example? // Shifting the array and accessing 0
let sum = 0;
while(matrix.length > 0) {
  sum += matrix[0][0];
  matrix.shift();
}

// direct access
let sum = 0;
for (let i = 0; i < matrix.length; i++) {
  sum += matrix[i][0];
}

https://jsperf.com/shift-vs-index-access
Shifting the array and accessing 0 is faster than
direct access in the given examples in the above jsPerf link.
Isn't shift() an O(n) operation?

A: No, it's not faster. It's just your benchmark being broken. The shift() operation empties the matrix array, and after the first iteration you are comparing your codes on an empty array.
When you are benchmarking code that mutates your data structure, you need to re-create the data structure on every test run. I've fixed your jsperf.com case and as expected shift is slower (notice that probably a large part of the execution time is spent on createMatrix, so in fact it's a lot slower).


text:
Q: Insert row with few values - PySpark I have a PySpark dataframe with say 10 columns and 15 rows.
Now I want to add a row with values provided to few columns(say 5) and insert nothing (NULL) in all other cells for this new row.
Example :-
Old_DF is my dataframe with 10 columns.
new_Row has to be added but i want to give values for 5 columns, for rest of the cells it can be Null.
lst = [['a', 'b', 'c', 'd','e']]   #only 5 values given

new_Row = spark.createDataFrame(lst, Old_DF.columns)  #creating a DF for new row

New_DF = Old_DF.union(new_Row)     #union to add the new row to Old DF

How can I achieve this ??
Any suggestions ?


text:
Q: Symfony console language changed I am trying to learn Symfony framework.
When I type bin/console doctrine:fixtures:load command my console language changes to Japanese (I think) and as a result I can not debug my error.  Can anyone please help make Symfony console to print the results in English?
The following is the error I am getting from running the above command.
J�│T␤␋⎽ ⎼␊⎽⎺┤⎼␌␊ °⎺⎼┐ ␋┼├␊┼├␋⎺┼▒┌┌≤ ┌␊°├ ␉┌▒┼┐   ��PHP P▒⎼⎽␊ ␊⎼⎼⎺⎼:  ⎽≤┼├▒│ ␊⎼⎼⎺⎼, ┤┼␊│⎻␊␌├␊␍ '␊│├␊┼␍' (T_STRING), ␊│⎻␊␌├␋┼± 'π' ␋┼ /⎻⎼⎺┘␊␌├⎽/└▒┴▒/⎽⎼␌/A⎻⎻B┤┼␍┌␊/D▒├▒F␋│├┤⎼␊⎽/ORM/L⎺▒␍P⎼⎺┘␊␌├⎽.⎻␤⎻ ⎺┼ ┌␋┼␊ 9
P▒⎼⎽␊ ␊⎼⎼⎺⎼: ⎽≤┼├▒│ ␊⎼⎼⎺⎼, ┤┼␊│⎻␊␌├␊␍ '␊│├␊┼␍' (T_STRING), ␊│⎻␊␌├␋┼± 'π' ␋┼ /⎻⎼⎺┘␊␌├⎽/└▒┴▒/⎽⎼␌/A⎻⎻B┤┼␍┌␊/D▒├▒F␋│├┤⎼␊⎽/ORM/L⎺▒␍P⎼⎺┘␊␌├⎽.⎻␤⎻ ⎺┼ ┌␋┼␊ 9
[S≤└°⎺┼≤\C⎺└⎻⎺┼␊┼├\D␊␉┤±\E│␌␊⎻├␋⎺┼\F▒├▒┌E⎼⎼⎺⎼E│␌␊⎻├␋⎺┼]
  P▒⎼⎽␊ E⎼⎼⎺⎼: ⎽≤┼├▒│ ␊⎼⎼⎺⎼, ┤┼␊│⎻␊␌├␊␍ '␊│├␊┼␍' (T_STRING), ␊│⎻␊␌├␋┼± 'π'
␍⎺␌├⎼␋┼␊:°␋│├┤⎼␊⎽:┌⎺▒␍ [--°␋│├┤⎼␊⎽ [FIXTURES]] [--▒⎻⎻␊┼␍] [--␊└ EM] [--⎽␤▒⎼␍ SHARD] [--⎻┤⎼±␊-┬␋├␤-├⎼┤┼␌▒├␊] [--└┤┌├␋⎻┌␊-├⎼▒┼⎽▒␌├␋⎺┼⎽] [-␤≠--␤␊┌⎻] [-─≠--─┤␋␊├] [-┴≠┴┴≠┴┴┴≠--┴␊⎼␉⎺⎽␊] [-V≠--┴␊⎼⎽␋⎺┼] [--▒┼⎽␋] [--┼⎺-▒┼⎽␋] [-┼≠--┼⎺-␋┼├␊⎼▒␌├␋⎺┼] [-␊≠--␊┼┴ ENV] [--┼⎺-␍␊␉┤±] [--] <␌⎺└└▒┼␍>
Here is framework related settings in my config.xml
imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: services.yml }
    - { resource: "@MyBundle/Resources/config/services.yml" }
Put parameters here that don't need to change on each machine where the app is deployed
http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
    locale: en
framework:
    #esi:             ~
    #translator:      { fallbacks: ["%locale%"] }
    secret:          "%secret%"
    router:
        resource: "%kernel.root_dir%/config/routing.yml"
        strict_requirements: ~
    form:            ~
    csrf_protection: ~
    validation:      { enable_annotations: true }
    #serializer:      { enable_annotations: true }
    templating:
        engines: ['twig']
    default_locale:  "%locale%"
    trusted_hosts:   ~
    trusted_proxies: ~
    session:
        # http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
        handler_id:  session.handler.native_file
        save_path:   "%kernel.root_dir%/../var/sessions/%kernel.environment%"
    fragments:       ~
    http_method_override: true
    assets: ~


text:
Q: simple graphics package in python 2 or 3 The following website from the official python tutorial seems to imply that a graphics package is automatically included with an install of Python 3. Beyond being highly skeptical of that, my python 2 does not have the package in question.
http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/graphics.html
Does anyone have any ideas or substitutions for performing simple windowed graphics in python, 2 or 3?

A: The default python "graphics" package is Tkinter
https://wiki.python.org/moin/TkInter
In Python 3, it's called "tkinter" - in python 2 it's called "Tkinter". It sometimes includes (depending on your distribution) ttk or tix, which are extensions. It makes direct calls to Tcl, so it's pretty fast at basic operations.
PIL/Pillow is a very standard dependency for any kind of image manipulation. Tkinter basically will only let you work with gif and postscript files
https://pypi.python.org/pypi/Pillow
Zelle graphics a beginners graphics program built on tkinter. It is not a serious graphics suite (it's super duper slow), though it can be extremely good for educational purposes. It's meant to accompany his Python book or for self-teaching. Try Turtle as an alternative for teaching purposes, there are a lt of tutorials out there. I don't know which distributions include it, but you can easily download it by googling for it
From your linked page:

You will just be a user of the graphics.py code, so you do not need to
  understand the inner workings! It uses all sorts of features of Python
  that are way beyond these tutorials.

Those features are called Tkinter. I like tk, and this it's pretty easy to use, but that's subjective - take a look and decide for yourself.
If you're looking for more advanced suites or any kind of 3D (tkinter is strictly 2D) (my guess is you aren't for now, but that's okay), try OpenGl for python, or pygame.


text:
Q: How to check if directory is mounted on disc X and mount it if it isn't I'm trying to write script to back my data up. I don't know much about it, so I might take a wrong approach, but what I'm trying to do is use rsync -avh several times for each directory I want to back up. However, I set destination as hard-coded value - ~/sbackup/. Now I want my script to check before running if the folder is mounted, and if not - try mount it. Therefore, script logic would look like this:
1)See if my USB disc is mounted under ~/sbackup/. (The disc - it would be good if there was a way to prevent other USB device from mounting there).
2)If it isn't try to mount it there. If you can't, write an error message and exit.
3) If it is mounted, run rest of the script.
Now I can write error messages and such, but I'm not sure about 1st step and 1st part of 2nd step.

A: if you have a mountpoint command:
mountpoint -q /local/mount/point || mount ...

A: When run with no arguments, mount returns a list of mounted partitions and some information about them, including their mountpoints. Therefore, you can just grep for the mountpoint in the output of mount and act accordingly:
if ! mount | grep -q sbackup; then
    mount /dev/sdb1 /home/matthew/sbackup || echo "Couldn't mount" && exit
fi

Change /dev/sdb to whatever your USB's partition is and matthew to your username. Run the script with sudo to be able to mount.


text:
Q: How Do I solve this further? Logic (Fitch) This is what I have done
2
This is edit 2

A: First, your set-up is excellent!
Second, note that if $Smaller(b,a)$ is true, then $Larger(a,b)$ should be true as well. However, this does not follow logically, but by the meaning of the predicates. So, you'll have to use Ana Con, which understands the meaning of the predicates.


text:
Q: How to set cookie object using CookieOptions(earlier CookieOptionsArgs) for setting cookie for other/parent domain? Is angular2-cookie already Depricated? if yes how to set cookie object using CookieOptions(earlier CookieOptionsArgs) for setting cookie for other/parent domain?

A: Yes As the angular version has upgraded the new ngx-cookie has replaced earlier angular 2 cookie.You can set the cookie for parent domain using CookieOptions in ngx-cookie by setting the domain param provided.Hope it helps.
Just make sure you are setting cookie of parent domain from subdomain.


text:
Q: Wrong numbering persists in LyX When I try to organise my notes using Section\Subsection\Subsubsection numeration, I keep getting the wrong numbers in the editor:

Previously, I've got help finding the solution to fix this problem in my PDF output.
Now I want to have a correct output in the editor as well. Is there a way to fix it from within LyX document\editor settings?


text:
Q: Click button cause multiple function calls I develop a python program. The following code is my program. The problem is when I click self.ui.Restart_Btn which call self.restartClicked() method and I click self.ui.B11, it call the method self.boardClicked() twice (which it should call only one time). Moreover, it will repeatedly call 3, 4, 5, ... times after I click self.ui.Restart_Btn 3rd, 4th, 5th, ... times and click self.ui.B11
I don't know what happen with my program.
 from MainWin import Ui_MainWindow
 from WelcomDialog import Ui_Dialog

 class iCheckers(QMainWindow):
     def __init__(self, parent = None):
         super(iCheckers, self).__init__(parent)
         self.ui = Ui_MainWindow()
         self.ui.setupUi(self)

         # Attribute
         self.buttonArr = [  [self.ui.B11, self.ui.B12, self.ui.B13, self.ui.B14, self.ui.B15, self.ui.B16, self.ui.B17, self.ui.B18],
                             [self.ui.B21, self.ui.B22, self.ui.B23, self.ui.B24, self.ui.B25, self.ui.B26, self.ui.B27, self.ui.B28],
                             [self.ui.B31, self.ui.B32, self.ui.B33, self.ui.B34, self.ui.B35, self.ui.B36, self.ui.B37, self.ui.B38],
                             [self.ui.B41, self.ui.B42, self.ui.B43, self.ui.B44, self.ui.B45, self.ui.B46, self.ui.B47, self.ui.B48],
                             [self.ui.B51, self.ui.B52, self.ui.B53, self.ui.B54, self.ui.B55, self.ui.B56, self.ui.B57, self.ui.B58],
                             [self.ui.B61, self.ui.B62, self.ui.B63, self.ui.B64, self.ui.B65, self.ui.B66, self.ui.B67, self.ui.B68],
                             [self.ui.B71, self.ui.B72, self.ui.B73, self.ui.B74, self.ui.B75, self.ui.B76, self.ui.B77, self.ui.B78],
                             [self.ui.B81, self.ui.B82, self.ui.B83, self.ui.B84, self.ui.B85, self.ui.B86, self.ui.B87, self.ui.B88] ]
         self.clicked_button = None
         self.turn = 0;  # 0 = Player, 1 = Computer
         self.computer_score = 0
         self.player_score = 0

         self.update_mainWin()
         self.init_board()
         self.init_dialog()
         self.show()

     def init_dialog(self):
         self.dialog = QDialog()
         self.dialog.ui = Ui_Dialog()
         self.dialog.ui.setupUi(self.dialog)
         #self.dialog.show()

         self.dialog.ui.Player_first_Btn.clicked.connect(partial(self.start, 0))
         self.dialog.ui.Computer_first_Btn.clicked.connect(partial(self.start, 1))

     def start(self, firstPlayer):
         # firstPlayer = 0 >> Player Starts
         # firstPlayer = 1 >> Player Starts

         if firstPlayer == 0:
             self.turn = 0;
             print("Player Start!!")
         elif firstPlayer == 1:
             self.turn = 1;
             print("Computer Start!!")
         self.init_board()
         self.boardClicked(True)
         self.update_mainWin()
         self.dialog.hide()

     def init_board(self):
         self.board = [[0 for x in range(8)] for x in range(8)]

         # Init Computer Piece
         for i in range(1,24,2):
             row = int(math.ceil( i/8 ))
             column = i%8
             if row % 2 == 1:
                 column -= 1
             self.board[row][column] = 2

         # Init Player Piece
         for i in range(41,64,2):
             row = int(math.ceil( i/8 ))
             column = i%8
             if row % 2 == 1:
                 column -= 1
             self.board[row][column] = 1

         # Init White Box
         for i in range(1,64,2):
            row = int(math.ceil( i/8 ))
            column = i%8
            if row % 2 == 0:
                column -= 1
            self.board[row][column] = -1

     def update_mainWin(self):
         # Update Turn
         self.updateTurn()

         # Initial Score Board
         self.updateScore()

         # Initial Restart Button
         self.ui.Restart_Btn.clicked.connect(self.restartClicked)

         # Initial Board Button
         self.initBoardBtn()

     def initBoardBtn(self):
         for i in range(0, 8):
             for j in range(0, 8):
                 self.buttonArr[i][j].clicked.connect(self.boardClicked)

     def boardClicked(self, reset = False):
         sender = self.sender()
         if self.clicked_button != None:
             button_name = self.clicked_button.objectName()
             button_nameArr = list(button_name)
             row = int(button_nameArr[1])-1;
             column = int(button_nameArr[2])-1;

             if self.board[row][column] == 0:
                 self.clicked_button.setStyleSheet("background-color: #383838;")
             elif self.board[row][column] == 1:
                 self.clicked_button.setStyleSheet("background-color: #383838;background-image: url(:/image/Red_Pieces.png);")
             elif self.board[row][column] == 2:
                 self.clicked_button.setStyleSheet("background-color: #383838;background-image: url(:/image/Black_Pieces.png);")
             elif self.board[row][column] == 3:
                 self.clicked_button.setStyleSheet("background-color: #383838;background-image: url(:/image/Red_King.png);")
             elif self.board[row][column] == 4:
                 self.clicked_button.setStyleSheet("background-color: #383838;background-image: url(:/image/Black_King.png);")

         if reset:
             self.clicked_button = None
             return

         self.clicked_button = sender
         button_name = self.clicked_button.objectName()
         button_nameArr = list(button_name)
         row = int(button_nameArr[1])-1;
         column = int(button_nameArr[2])-1;
         if self.board[row][column] == 0:
             self.clicked_button.setStyleSheet("background-color: #707070;")
         elif self.board[row][column] == 1:
             self.clicked_button.setStyleSheet("background-color: #707070;background-image: url(:/image/Red_Pieces.png);")
         elif self.board[row][column] == 2:
             self.clicked_button.setStyleSheet("background-color: #707070;background-image: url(:/image/Black_Pieces.png);")
         elif self.board[row][column] == 3:
             self.clicked_button.setStyleSheet("background-color: #707070;background-image: url(:/image/Red_King.png);")
         elif self.board[row][column] == 4:
             self.clicked_button.setStyleSheet("background-color: #707070;background-image: url(:/image/Black_King.png);")
         print("Board: " + sender.objectName());

     def restartClicked(self):
         print("Restart!")
         self.dialog.show()
         # self.init_dialog()

     def updateTurn(self):
         if self.turn == 0:
             self.ui.Turn_img.setStyleSheet("background-color: #909090;background-image: url(:/image/Red_Icon.png);")
         elif self.turn == 1:
             self.ui.Turn_img.setStyleSheet("background-color: #909090;background-image: url(:/image/Black_Icon.png);")

     def updateScore(self):
         self.ui.Computer_Score_label.setText(str(self.computer_score))
         self.ui.Player_Score_label.setText(str(self.player_score))

 if __name__ == '__main__':
     app = QApplication(sys.argv)
     window = iCheckers()
     sys.exit(app.exec_())

A: The reason is relatively straight-forward, you misunderstand how connect works in Qt.
You seem to be connecting signals to slots at each invocation of certain methods. That seems to be conflicting with what you (rightfully) want.
You have a workaround and a solution for this problem.
Workaround
Use unique connection (type=Qt.UniqueConnection).
Solution
Move these connect calls to the initialization phase or at least disconnect them before reconnecting. The former is the general practice, but your mileage may vary.


text:
Q: .NET Core adding/building .cs files to target project I am trying to setup a NuGet package for some c bindings.
I want some .cs files to be added/built into the target project.
I got this to work for .NET Framework using the content target but that is not supported in .NET Core.
Similar issue - How does NuGet contentFiles work?
I tried that solution but it fails to build in the target project. The two folders content and contentFiles in the package folder are there so I am not sure what I am doing wrong.
The nuspec file is in the same folder as the files I want to be copied. I want to specify it so they are put inside a folder in the target project.


text:
Q: Windows Security Options over RDP in Server 2012+ In Server 2008 R2 and below, there was a "Windows Security" option in the Start Menu to access the "Ctrl+Alt"Delete" options without pressing Ctrl+Alt+End. I always found that useful since I often RDP to Windows Servers from my Mac (since I don't have an "End" key on it). Now, with Server 2012 (and R2), I've looked and looked for this the equivalent and cannot find it. Is it still possible to launch the Windows Security Options screen from the Start Screen or a desktop shortcut?
EDIT: Never mind, I found the solution. See my comment.

A: I was looking for it too in order to change Windows Password.
Found an old VB to force the screen to show. See below:
Set objShell = CreateObject("Shell.Application")

objShell.WindowsSecurity

Save as .vbs and you are all set.


text:
Q: Passing a list of key-value pairs in Python requests I am trying to post some parameters to server using REST. I am trying to craft a request of what the following url achieves.
https://example.com/rest/server.php?var[0][a]=1&var[0][b]=23
what I am trying is the following, but it does not work.
params =  {"var": [{'a':1, 'b':23}]}
resp = requests.post("https://example.com/rest/server.php",
                    data = json.dumps(params))

I see that in the request.body, the parameters are passed like below
{"var": [{"a": 1, "b": 23}]}

A: Your code does exactly what you tell it to do, which is:

*

*Use POST parameters instead of GET,

*Format the parameter data as json.

Instead, you want to use GET parameters, formatted in a non-standard way.
Perhaps something like this might help you forther:
def encode_params(params, head = None):
    output = []
    if head is None:
        head = ''
    if isinstance(params, dict):
        for k,v in params.items():
            output.extend(encode_params(v, '%s[%s]' % (head,k)))
    elif isinstance(params, list) or isinstance(params, tuple):
        for k,v in enumerate(params):
            output.extend(encode_params(v, '%s[%s]' % (head,k)))
    else:
        return ['%s=%r' % (head, params)]

    return output

encoded_args = ','.join([','.join(encode_params(v, k)) for k,v in params.items()])

It can definitely be improved further, but this might give you a head start. You will need to add some sanity checks, like urllib.parse.quote_plus(...) or something that prevents args like '][' to be added directly.


text:
Q: How can I use Leaflet (in R) to smoothly pan/zoom from one point to another point? I am using flyTo() in leaflet (R), but I want to avoid how it zooms all the way out to world view before zooming in to the specified lat/lon. Is there a way to set the start point of the flyTo to certain bounds that have a higher zoom level than the world view?
For example, I want the start point of the flyTo() to be at the level of a small city.
This is my current use of the function with no bound set:
%>% flyTo(
  lng = -122.17014,
  lat = 37.42752,
  zoom = 15
)


text:
Q: Can not change folder location in overGrive - no syncing possible The folder location to store my Google Drive files at is invalid according to .overgrive.log,

[2016-01-26 22:58:16] [ERROR] Could not create Google Drive folder :
  /media/    martin/sklad/Google Drive

and there is no syncing.
The problem is I can not change it. If I click the  "Change..." button then nothing happens.

The invalid path is remembered even after uninstallation. I tried to remove all configuration by removing all files from command
sudo find / -name *grive*

but after reinstall, the incorrect path is remembered. Do you have any idea where it might be stored and how to delete it? I wonder if it is in the cloud. It is not probable, because after the reinstall it reappears before the account is verified.

A: Seems like overGrive needs to make sure the default path is available before allowing you to change it to somewhere else. Try to manually create a folder exactly as suggested, e.g. /media/martin/sklad/Google Drive, then open overGrive and change the folder location. At least that worked in my case.

A: Update to the latest version from our website.


text:
Q: If $R$ is a total order over set $A$, then all subsets of $A$ can be sorted I'm working on the proof of this theorem:

Let A be a set and let $\leq_A$ be a partial order over . We say that a sequence $x_1,...,x_n$ is sorted if $x_1 \leq_A x_2 \leq_A ... \leq_A x_n$. Prove that any subset of $n$ elements of $A$ can be sorted iff $A$ is a total order.

Since this is bidirectional, I need to prove both directions of implication. I've actually already proved the first direction (I asked a question about this) - if any subset of $A$ can be sorted, then $\leq_A$ is total. Now I'm trying to prove the second direction, namely if $\leq_A$ is total, then any subset of $A$ can be sorted.
I tried different techniques (direct, contradiction, contrapositive) and the best results I achieved was when I tried to prove by induction, but I can't complete the proof. Here is it:
Assume that $P(n)$ is true iff any set $S \subseteq A$ with $n$ elements can be sorted.

*

*Then $P(0)$ is true, since all empty sets are sorted.

*So assuming that for any $n \in \mathbb{N}$ if $P(n)$ is true, then we prove that $P(n + 1)$ is also true. Consider any set $S \subseteq A$ with exactly $n$ elements and consider element $y \in A$ which is also $y \not\in S$. Since $\leq_A$ is total order we have that $y$ is either the least element in $S \cup \{y\}$, or the greatest element in $S \cup \{y\}$, or there are some $x_l \in S$, where $x_l \leq_A y$, and there are some $x_g \in S$, where $y \leq_A x_g$. In the first and the second cases we are done, because $S \cup \{y\}$ is sorted...

I don't actually know how to prove that the set is also sorted in the third case. Moreover I'm not even sure that my assumptions about the first and the second cases are correct.
Could someone please provide any hints and suggestions for where to go next? Or if you know another way (simplier/without induction) to prove this, please give me a hint.

A: Hint: Try to prove a Lemma: If $\le_A$ is a total order, then for every nonempty finite subset $\{x_1,x_2,\ldots,x_n\}\subset A$ there exists a minimum, i.e. one $x_i$ such that $x_i\le_A x_1$,  $x_i\le_A x_2$,...,  $x_i\le_A x_n$. Use induction for that.
Then use the Lemma in the inductive step of your overall proof.


text:
Q: How to leave margin between pause command in CMD batch file? Any command to add margin or  space between pause command and the window borders?

A: You can suppress the text from Pause and place your own, before.
echo       ..Press a key to continue..
pause > nul

A: It is possible with set /P to output a text of your choice with leading and trailing spaces as wanted with waiting on same line for any key press using pause.
Here is the code:
@echo off
setlocal EnableExtensions DisableDelayedExpansion
set /P "MyDummyVar=*   Please press a key to continue ... " <nul & pause >nul & echo(
endlocal

ATTENTION: The prompt text cannot start with leading normal spaces (code value decimal 32, hexadecimal 20), horizontal tabs (code value decimal 9, hex. 09) or non-breaking spaces according to current code page (code value 255, hex. FF for OEM code pages like 437 or 850, code value 160, hex. A0 for ANSI code pages like Windows-1252). The command SET removes all leading whitespaces before printing the prompt text.
The posted solution uses a prompt text starting with an asterisk and the second character is a backspace control character with decimal code value 8. There can be used also a different non-whitespace character than the asterisk as first character.
Note: The browser used to view this page might not display the backspace control character after * at all, but the posted code has a backspace control character after *. It depends on the used browser if the backspace control character is copied also with the three normal spaces and all the other characters of third command line. It depends on the used text editor how the backspace character is pasted into the batch file on really copied as backspace by the browser and on the used font how the backspace control character is displayed in the text editor window if displayed at all.
This solution is inspired by Windows batch: echo without new line written by dbenham and the DosTips forum post Output text without linefeed, even with leading space or = written by jeb.
& echo( at end of the command line is necessary to have the next output on next line and not on same line as the prompt text because of the newline characters output by pause are redirected also to device NUL.

Another solution for Windows Vista and newer Windows versions and Windows Server 2003 and newer Windows Server versions is:
%SystemRoot%\System32\choice.exe /N /M "   Please press a key to continue ..." <nul 2>nul & pause >nul & echo(

Note: choice.exe is by default not available on Windows XP. choice.exe of Windows Server 2003 can be copied into the Windows system directory of Windows XP to make it available also on a computer running Windows XP. In other words this solution should not be used in batch files which should run also on Windows XP or Windows 2000.
There are used three non-breaking spaces in this example with OEM code value 255 (hexadecimal FF) at beginning of the prompt text which the command CHOICE does not remove in comparison to leading normal spaces and horizontal tabs which are removed by CHOICE.
CHOICE outputs the prompt text always with one trailing space appended after removing trailing normal spaces/horizontal tabs from prompt text. Trailing non-breaking spaces are not removed by CHOICE and can be appended at end of the prompt text for even more output trailing spaces.
The device NUL is used for the standard input stream which results in the error message:

ERROR: The file is either empty or does not contain the valid choices.

This error message is redirected with 2>nul to device NUL to suppress it.
The result is that choice.exe immediately terminates itself after printing the prompt text and so internal command pause is executed next by cmd.exe.
It would be best on using this solution to get the number of currently used code page as suggested by Compo in DosTips form post [Info] Saving current codepage, next set OEM code page 437 as used to encode the prompt text with the non-breaking spaces, output the prompt and restore the initial code page. This can be done with the following code:
@echo off
setlocal EnableExtensions DisableDelayedExpansion
for /F "tokens=*" %%G in ('%SystemRoot%\System32\chcp.com') do for %%H in (%%G) do set "CodePage=%%~nH"
%SystemRoot%\System32\chcp.com 437 >nul
%SystemRoot%\System32\choice.exe /N /M "   Please press a key to continue ..." <nul 2>nul & pause >nul & echo(
%SystemRoot%\System32\chcp.com %CodePage% >nul
endlocal

PS: I have never understood why command PAUSE does not support optionally an argument string which is interpreted as prompt text instead of the built-in prompt text. I wrote in year 2002 a very small 32-bit console application as replacement for pause which I called batpause.exe which is like PAUSE and supports optionally an argument string interpreted as prompt text output by the small application instead of built-in default prompt text.


text:
Q: How to set rowspan in itext using do while loop in android studio My datas in PDF consists of 20 rows. I'm using do while loop for getting this 20 values from database. I trying to set rowspan for the last set of datas, which am unable to do so, as the last values are getting broken. Below is my codings...
PdfPTable tablel = new PdfPTable(3);
tablel.setWidthPercentage(100);

//Header
PdfPCell cell1 = new PdfPCell(new Phrase("S No"));
PdfPCell cell2 = new PdfPCell(new Phrase("Parameter"));
PdfPCell cell3 = new PdfPCell(new Phrase("Unit"));

tablel.addCell(cell1);
tablel.addCell(cell2);
tablel.addCell(cell3);

//Datas
Cursor c= dbs.query("kiosk_trn_tsoilparameter", new String[]{"soilparam_gid","soilparam_soil_gid","soil_parameter","soil_uom","soil_results"
                }, "soilparam_soil_gid" + "=? COLLATE NOCASE",
                new String[]{id}, null, null, null, null);

                int i = 1;
                if (c.moveToFirst()) {
                do {
                //to get increment values of i
                String group = String.valueOf(i);
                cell1 = new PdfPCell(new Phrase(group));
                tablel.addCell(cell1);

                String selectQuery1 = "SELECT  * FROM core_mst_tmaster....";
                Cursor cursor1 = dbs.rawQuery(selectQuery1, null);
                if(cursor1.moveToNext())
                    {
                        String machine = cursor1.getString(0);
                        cell1 = new PdfPCell(new Phrase(machine));
                        tablel.addCell(cell1);
                    }

                    String selectQuery2 = "SELECT  * FROM core_mst_tmaster ....";
                Cursor cursor2 = dbs.rawQuery(selectQuery3, null);
                if(cursor2.moveToNext())
                    {
                        String machine = cursor2.getString(0);
                        cell2 = new PdfPCell(new Phrase(machine));
                        tablel.addCell(cell2);
                    }
                    String selectQuery3 = "SELECT  * FROM core_mst_tmaster.... ";
                Cursor cursor3 = dbs.rawQuery(selectQuery3, null);
                if(cursor3.moveToNext())
                    {
                        String machine = cursor3.getString(0);
                        cell3 = new PdfPCell(new Phrase(machine));
                        cell3.setRowspan(3);
                        tablel.addCell(cell3);
                    }
                i++;
                while (c.moveToNext());
                }
                document.add(tablel);

I have also tried to put if loop to get first set of values and for the remaining set of values I assigned empty values and tried to assigned rowspan for the remaining set of values, but still it is not working.
Below is the coding...
//to get first set of values
if(i==1){
                    String machine = cursor3.getString(0);
                        cell3 = new PdfPCell(new Phrase(machine));
                        tablel.addCell(cell3);
                }else{
// to get remaining values
                    String machine = cursor3.getString(0);
                        cell3 = new PdfPCell(new Phrase(machine));
                        cell3.setRowspan(3);
                        tablel.addCell(cell3);
                }

```
Any codings I missed out...please help me out...


text:
Q: Why SurfaceInkCanvas do not draw? I am trying to do a simple example to use the SurfaceInkCanvas but, it will not draw any thing when I try to use the touch over it, although EditingMode="Ink"
Here is the code:
<s:SurfaceWindow x:Class="SurfaceApplication1.SurfaceWindow1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="http://schemas.microsoft.com/surface/2008"
    Title="SurfaceApplication1"
    >
  <Grid>
        <s:SurfaceInkCanvas x:Name="PostcardCanvas"
                                EditingMode="Ink"
                                Background="Orange"
                                Height="320"
                                IsHitTestVisible="False"
                                UsesTouchShape="False"
                                Width="426" />
  </Grid>
</s:SurfaceWindow>

So, what's I am missing here ?

A: Change
IsHitTestVisible="False"

to
IsHitTestVisible="True"


text:
Q: How to get start/end point of a dm-script line annotation (Component)? I want to use:
Component NewLineAnnotation( Number top, Number left, Number bottom, Number right )
The problem is that the line always runs in the direction from the top-left to the bottom-right.
However, I need the line to go from bottom-right to top-left.
And I also need to be able to get the accurate direction from an existing one.
It seems silly that the command is not:
Component NewLineAnnotation( Number start_x, Number start_y, Number end_x, Number end_y )
but surely there is a way to get the direction of the line annotation?
void ComponentGetRect( Component comp, NumberVariable top, NumberVariable left, NumberVariable bottom, NumberVariable right )
does not have such a detail.

A: Given the details in earlier great answer I looked more and found this to be the situation - I am using GMS 3.
The command for creating a line as a component via:
NewLineAnnotation( Number top, Number left, Number bottom, Number right )

could be described better as:
NewLineAnnotation( Number sX, Number sY, Number eX, Number eY )

But there is another source of potential confusion.  When looking for the Get() command for the coordinates, these commands are listed:
void ComponentGetBoundingRect( Component comp, NumberVariable t, NumberVariable l, NumberVariable b, NumberVariable r )

void ComponentGetRect( Component comp, NumberVariable top, NumberVariable left, NumberVariable bottom, NumberVariable right )

void ComponentGetRectInView( Component comp, NumberVariable top, NumberVariable left, NumberVariable bottom, NumberVariable right )

All 3 commands claim the order: top, left, bottom, right, but only the first and the last commands do.  The second command could again be better described by
ComponentGetRect(Number sX, Number sY, Number eX, Number eY)

I had mixed up the command NewLineAnnotation() with ComponentGetBoundingRect() and that caused some real issues.  I feel a better description in the manual might help avoid such issues.
As a summary, here is some code I used to demonstrate the different functionalities to myself.
image front := CreateFloatImage("", 800, 800)
front.setZoom(.4)
front.ShowImage()
component frontComponent = front.ImageGetImageDisplay(0)

component solid_Line_orange = NewLineAnnotation(700, 10, 500, 200);
frontComponent.ComponentAddChildAtEnd(solid_Line_orange)
solid_Line_orange.ComponentSetForegroundColor(1,.66,0);
component solid_Line_white  = NewLineAnnotation(500, 10, 700, 200);
frontComponent.ComponentAddChildAtEnd(solid_Line_white)

number sx, sy, ex, ey
number l_top, l_left, l_buttom, l_right
solid_Line_orange.ComponentGetRect( l_top, l_left, l_buttom, l_right );

Result("\n\n")
Result("using:  ComponentGetRectangle();\t actual convention: (start_x, start_y, end_x, end_y)\n")
Result("orange line set at: \t(700, 10, 500, 200);\n")
Result("orange line found at: \t(" + l_top + ", " +  l_left + ", " + l_buttom + ", " + l_right + ")\n")
solid_Line_white.ComponentGetRect( l_top, l_left, l_buttom, l_right )
Result("white line set at: \t(500, 10, 700, 200); \n")
Result("white line found at: \t(" + l_top + ", " +  l_left + ", " + l_buttom + ", " + l_right + ")\n")

Result("using:  ComponentGetBoundingRectangle();\t actual convention: (top, left, bottom, right)\n")
solid_Line_orange.ComponentGetBoundingRect( l_top, l_left, l_buttom, l_right );
Result("orange line found at: \t(" + l_top + ", " +  l_left + ", " + l_buttom + ", " + l_right + ")\n")
solid_Line_white.ComponentGetBoundingRect( l_top, l_left, l_buttom, l_right );
Result("white line found at: \t(" + l_top + ", " +  l_left + ", " + l_buttom + ", " + l_right + ")\n")

Result("using:  ComponentGetBoundingRectInView();\t actual convention: (top, left, bottom, right)\n")
solid_Line_orange.ComponentGetBoundingRectInView( l_top, l_left, l_buttom, l_right );
Result("orange line found at: \t(" + l_top + ", " +  l_left + ", " + l_buttom + ", " + l_right + ")\n")
solid_Line_white.ComponentGetBoundingRectInView( l_top, l_left, l_buttom, l_right );
Result("white line found at: \t(" + l_top + ", " +  l_left + ", " + l_buttom + ", " + l_right + ")\n")

This solves the problem for me.  Hope this helps somebody else as well.  And maybe a better description in the manual could help as well.

A: This is an interestings question!
I think the behavior of ComponentGetRect() is doing correct thing but mislabeling the variables names in the documentation. While it says that it returns you a rectangle as top-left to bottom-right coordinates, it actually returns you the Y/X start coordinate and the Y/X end coordiante pair of the Annotation. (For other types of annoations, this then is [TLBR] ). Note that it is Y/X not X/Y! This is confusing, but to keep it in line with the more general "component" object.
Similarly, the signature variables names for NewLineAnnotation() are wrong, as they are obvisoulsy giving a start to end direction, as you can easily try out when using arrow-annotations instead. (See example script below.)

You can defenitly set the direction of a created line or arrow annotation using:
Component NewLineAnnotation( Number StartY, Number StartX, Number EndY, Number EndX )
Component NewArrowAnnotation( Number StartY, Number StartX, Number EndY, Number EndX )
Similarly, you should use for reading the postions:
ComponentGetRect( NumberVariable StartY, NumberVariable StartX, NumberVariable EndY, NumberVariable EndX )

Now, and alternative way of getting start and end coordinates would be the control point of the component, and the F1 help documention explicitly lists the control point ID values:

So, the presumably correct way would be to ask the componet of the coordinates of the specified control point using:
Boolean ComponentGetControlPoint( Component comp, Number loc, NumberVariable x, NumberVariable y )
However, giving this a test (see script below) it does not actually work for the control point ID values 1 and 2. It seems that the two control points for start/end of a line have not been implemented with the command.
But, you can use the "Top/Left" control point 4 for getting the start value and the "Bottom/Right" control point 7 for getting the end value. Again, this just matches the same somewhat irregular mapping of "line/arrow" annotations on the regular components.

Alternatvive way of getting a start point XY:
Boolean ComponentGetControlPoint( Component comp, 4, NumberVariable x, NumberVariable y )
Alternatvive way of getting a end point XY:
Boolean ComponentGetControlPoint( Component comp, 7, NumberVariable x, NumberVariable y )

Test script used
// Control Point constants. See F1 help documentaton ("Component Object" Overview)
number kLineStart   = 1 // = start point of line
number kLineEnd     = 2 // = end point of line
number kTopLeft     = 4 // = top-left for rect, or start point for line
number kBottomRight = 7 // = bottom-right for rect, or end point for line

number sx = 50
number sy = 30
number ex = 400
number ey = 200
number sizeX = 500
number sizeY = 500

void PrintAnnoInfo( component anno )
{
    if ( !anno.ComponentIsValid() ) return
    number t,l,b,r
    anno.ComponentGetRect( t, l, b, r )
    // note that it is return StartY, StartX, EndY, EndX into TLBR!

    number type = anno.ComponentGetType()
    Result( "\n\n Component of type " + type + ":" )
    Result( "\n\t Position rect: " + t + " / " + l + " / "+ b + " / "+ r )
    Result( "\n\t\t { TOP / LEFT / BOTTOM / RIGHT }" )

    number sx, sy, ex, ey
    if ( !anno.ComponentGetControlPoint( kLineStart, sx, sy ) )
        Result( "\n INVALID Control point for annotation type. ( " + kLineStart + " ) " )
    else
        Result( "\n\t Start point (X/Y): " + sx + " / " + sy )
    if ( !anno.ComponentGetControlPoint( kLineEnd, ex, ey ) )
        Result( "\n INVALID Control point for annotation type. ( " + kLineEnd + " ) " )
    else
        Result( "\n\t End point (X/Y)  : " + ex + " / " + ey )

    if ( !anno.ComponentGetControlPoint( kTopLeft, sx, sy ) )
        Result( "\n INVALID Control point for annotation type. ( " + kLineStart + " ) " )
    else
        Result( "\n\t Start point (X/Y): " + sx + " / " + sy )
    if ( !anno.ComponentGetControlPoint( kBottomRight, ex, ey ) )
        Result( "\n INVALID Control point for annotation type. ( " + kLineEnd + " ) " )
    else
        Result( "\n\t End point (X/Y)  : " + ex + " / " + ey )

Result( "\n\n" )

}

// clear workspace and created dummy
EGUPerformActionWithAllShownImages( "Delete" )
ClearResults()
Result( "Component direction test:\n\n" )
image img := Realimage( "Test", 4, sizeX, sizeY )
img.ShowImage()
imageDisplay disp = img.ImageGetImageDisplay(0)

// Creating and adding line-Annotation
number UseArrow
useArrow = TwoButtonDialog( "In this test use", "Arrows", "Lines" )
string msg
msg = "\nAdding " + (useArrow?"arrow":"line") + ":"
msg += "\n from (" + sx + " / " + sy + ") to (" + ex + " / " + ey + ")"
msg += "\n { from (Ex/Ey) to (Sx/Sy) }"
Result( msg )
OKdialog( msg )

Component anno
if ( useArrow )
    anno = NewArrowAnnotation( sy, sx, ey, ex ) // note that it is YX!
else
    anno = NewLineAnnotation( sy, sx, ey, ex )  // note that it is YX!

anno.ComponentSetForegroundcolor(1,0,0)
disp.ComponentAddChildAtEnd( anno )
anno.PrintAnnoInfo()

msg = "\nAdding " + (useArrow?"arrow":"line") + ":"
msg += "\n from (" + ex + " / " + ey + ") to (" + sx + " / " + sy + ")"
msg += "\n { from (Ex/Ey) to (Sx/Sy) }"
Result( msg )
OKdialog( msg )

if ( useArrow )
    anno = NewArrowAnnotation( ey, ex, sy, sx ) // note that it is YX!
else
    anno = NewLineAnnotation( ey, ex, sy, sx )  // note that it is YX!

anno.ComponentSetForegroundcolor(0,1,0)
disp.ComponentAddChildAtBeginning( anno )
anno.PrintAnnoInfo()


text:
Q: Concurrent QuickSort only partially sorting im trying to implement QuickSort concurrently. When I run it and look at the sorted array, there is a portion of elements near the start of the array that is unsorted but the majority of the array is.
Code Below
package main

import (
    "fmt"
    "math/rand"

    //"runtime"
    "sync"
    "time"
)

func main() {
    slice := generateSlice(1000000)
    var wg sync.WaitGroup
    start := time.Now()
    go Quicksort(slice, 0, len(slice)-1, &wg)
    wg.Wait()
    end := time.Since(start)
    fmt.Printf("Sort Time: %v, sorted: %v \n", end, slice)
}

func Quicksort(A []int, p int, r int, wg *sync.WaitGroup) {
    if p < r {
        q := Partition(A, p, r)
        wg.Add(2)
        go Quicksort(A, p, q-1, wg)
        go Quicksort(A, q+1, r, wg)
    }
}

func Partition(A []int, p int, r int) int {
    index := rand.Intn(r-p) + p
    pivot := A[index]
    A[index] = A[r]
    A[r] = pivot
    x := A[r]
    j := p - 1
    i := p
    for i < r {
        if A[i] <= x {
            j++
            tmp := A[j]
            A[j] = A[i]
            A[i] = tmp
        }
        i++
    }
    temp := A[j+1]
    A[j+1] = A[r]
    A[r] = temp
    return j + 1
}

func generateSlice(size int) []int {

    slice := make([]int, size)
    rand.Seed(time.Now().UnixNano())
    for i := 0; i < size; i++ {
        slice[i] = rand.Intn(999) - rand.Intn(999)
    }
    return slice
}

I can't seem to find the issue, any ideas?

A: Your implementation has multiple problems. Hymns For Disco has already mentioned a couple of them in the comments. Another change I would suggest is not to use the same waitGroup in all recursive function calls. It can be very difficult to keep track of counter increments and decrements and you might reach a deadlock.
I have made a few changes to your code. I think it's working fine. Note that 'Partition' and 'generateSlice' functions remain unchanged.
func main() {
    slice := generateSlice(1000)
    Quicksort(slice, 0, len(slice)-1)
    fmt.Printf("%v\n", slice)
}

func Quicksort(A []int, p int, r int) {
    if p < r {
        var wg sync.WaitGroup
        q := Partition(A, p, r)

        wg.Add(2)
        go func() {
            defer wg.Done()
            Quicksort(A, p, q-1)
        }()

        go func() {
            defer wg.Done()
            Quicksort(A, q+1, r)
        }()

        wg.Wait()
    }
}


text:
Q: How to ensure that my amplify request is completed before returning a value? In one of my files, I make a call as follows:
var jobsString = getDropdownJobs();

It calls this function :
function getDropdownJobs() {

    var jobsString = amplify.store("JobsList");

    if (typeof jobsString === 'undefined') {

        // Amplify sends a request for getJobs, if it exists in cache, it will return that value.
        // If it does not exist in cache, it will make the AJAX request.
        amplify.request("getJobs", function (data) {

            // Leave a blank option for the default of no selection.
            var jobsString = '<option value=""></option>';
            // Append each of the options to the jobsString.
            $.each(data.jobs, function () {
                jobsString += "<option " + "value=" + this.JobNo_ + ">" + this.JobNo_ + " : " + this.Description + this.Description2 + "</option>";
            });
            // Store the jobsString to be used later.
            amplify.store("JobsList", jobsString);

        });
    }
    return jobsString;

}

Where the amplify definition of "GetJobs" is :
amplify.request.define("getJobs", "ajax", {
    url: "../api/Job/Jobs",
    dataType: "json",
    type: "GET",
    cache: "persist"
});

Whenever it returns, it's undefined. I put "async: false" in the AJAX definition and it didn't change anything.
How can I make sure that the value is there before returning?

A: I'm not familiar with Amplify, but its API says

Requests made through amplify.request will always be resolved asynchronously

So, you'll have to pass a callback into getDropdownJobs, to be executed after jobsString is filled, and any code that relies on the value goes in it.
Alternatively you could use Amplify's pub/sub system to subscribe an event for when jobsString is filled and publish to it during getDropdownJobs.

A: Sorry if I'm misunderstanding your question, but every time you do something like this, an asynchronous requests, you need to wait for the answer. Before I suggest an alternative some quick tips I tend to follow:

*

*Usually methods like your getJobsDropdown don't return anything, or potentially they can return promises. Take a look at jquery promises or this article for more advanced material on chaining those same promises.

*The most trivial thing you can use is a callback, some method on the context on the invoker of getJobsDropdown where you want to process the data. This will allow you to resume your program when the data is ready.

Try this:
function getDropdownJobs(callback) {

    // some code (...)

    amplify.request("getJobs", function (data) {

       // your processing and when done
       callback();

    });
}

Potentially you can pass the data in the callback. A usual call of the getDropdownJobs would be:
function processResults() { // This is your callback }

function getData() {

    // This is where you call getDropDownJobs
    getDropDownJobs(processResults);
}

Was this helpful? I hope so.
Cheers.

A: If you are using jQuery and do not mind coupling amplify with the jQuery framework you can use this plugin, allowing you to utilise jQuery deferred objects:
amplify-request-deferred plugin
Here is an article with some background information and an overview of the plugin usage:
Adding jQuery Deferred Support to AmplifyJS Request


text:
Q: net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::5.0.1 object name already exists: ���� I'm trying to run this:
Properties prop = new Properties();
prop.put("user", "");
prop.put("password", "LX2008");
conn = DriverManager.getConnection(
        "jdbc:ucanaccess://C:/Users/lh/Desktop/all_num.mdb;jackcessOpener=com.zhangmingge.access.CryptCodecOpener", prop);

But got this:
17:52:47.879 [main] DEBUG com.healthmarketscience.jackcess.Index - unsupported collating sort order SortOrder[2052(0)] for text index (Db=all_num.mdb;Table=MSysObjects;Index=0), making read-only
17:52:47.902 [main] DEBUG com.healthmarketscience.jackcess.impl.DatabaseImpl - Could not find expected index on table MSysObjects (Db=all_num.mdb)
17:52:47.920 [main] DEBUG com.healthmarketscience.jackcess.impl.DatabaseImpl - Finished reading system catalog.  Tables: [num, num_tmp, ����] (Db=all_num.mdb)
net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::5.0.1 object name already exists: ����
    at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:231)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:208)
    at com.zhangmingge.access.TestAccessUcanaccess.test2(TestAccessUcanaccess.java:72)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at ...
Caused by: java.sql.SQLSyntaxErrorException: object name already exists: ����
    at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
    at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
    at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
    at org.hsqldb.jdbc.JDBCStatement.executeUpdate(Unknown Source)
    at net.ucanaccess.converters.LoadJet.exec(LoadJet.java:1510)
    at net.ucanaccess.converters.LoadJet.access$000(LoadJet.java:74)
    at net.ucanaccess.converters.LoadJet$TablesLoader.createSyncrTable(LoadJet.java:472)
    at net.ucanaccess.converters.LoadJet$TablesLoader.createSyncrTable(LoadJet.java:399)
    at net.ucanaccess.converters.LoadJet$TablesLoader.createTable(LoadJet.java:823)
    at net.ucanaccess.converters.LoadJet$TablesLoader.createTable(LoadJet.java:767)
    at net.ucanaccess.converters.LoadJet$TablesLoader.createTables(LoadJet.java:976)
    at net.ucanaccess.converters.LoadJet$TablesLoader.loadTables(LoadJet.java:1070)
    at net.ucanaccess.converters.LoadJet$TablesLoader.access$3200(LoadJet.java:264)
    at net.ucanaccess.converters.LoadJet.loadDB(LoadJet.java:1579)
    at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:218)
    ... 72 more
Caused by: org.hsqldb.HsqlException: object name already exists: ����
    at org.hsqldb.error.Error.error(Unknown Source)
    at org.hsqldb.error.Error.error(Unknown Source)
    at org.hsqldb.Table.addColumn(Unknown Source)
    at org.hsqldb.ParserTable.readTableContentsSource(Unknown Source)
    at org.hsqldb.ParserTable.compileCreateTableBody(Unknown Source)
    at org.hsqldb.ParserTable.compileCreateTable(Unknown Source)
    at org.hsqldb.ParserDDL.compileCreate(Unknown Source)
    at org.hsqldb.ParserCommand.compilePart(Unknown Source)
    at org.hsqldb.ParserCommand.compileStatements(Unknown Source)
    at org.hsqldb.Session.executeDirectStatement(Unknown Source)
    at org.hsqldb.Session.execute(Unknown Source)
    ... 85 more

Bacause there is a table with Chinese name in my database, I guess:

I read this post, but unfortunately, I can't rename the table because another system need it.
Tryed to google, and got this post, but is not the expected solution.


text:
Q: AEM wcm.io testing Sling MockProperty name encoding issue I am experiencing an issue with the MockProperty implementation. My tests are currently failing because for some reason the ':' gets encoded to '%3A'. Why is this happening and how can I make this work?
NOTE: In my running code (outside of testing) this works all fine.

Resource resource = resourceResolver.getResource("path_to_a_valid_resource_here");
Node node = resource.adaptTo(Node.class);
PropertyIterator properties = node.getProperties();
while (properties.hasNext()){
    Property property = properties.nextProperty();
    String name = property.getName();
}

A: The returned String is UTF-8 encoded. You can obtain the decoded value it by calling String name = URLDecoder.decode(property.getName(), "UTF-8");
Why this was encoded in the first place is unknown to me, but my guess would be that the property name is treated as a URL and subsequently encoded in the ASCII set, hence the transformation of : to %3A


text:
Q: function that returns a select with options, using React I have a JSON of courthouse that contains one id and one name. The JSON contains an unlimited number of courthouses. I need to create a <Select> full of <Option>. the <Option> value will be the id, and the <Option> content will be the name.
So i got this function
createSelectCourtHouse:function(){
    return (
    <Form.Field className='form-control' type='select' name='request.courthouse_id' id='accused_lastname' placeholder="Nom de l'accusé" id='accused_lastname' onChange={this.handleChange.bind(this, 'accused_lastname')}>
       this.state.courthouseData.forEach(function(courthouse) {
           return (
               <option value={courthouse.i}>{courthouse.name}</option>
           );
       })
    </Form.Field>)
},

but it seems like i can't do a forEach inside a return. So i tried this way :
var field = (
      <Form.Field className='form-control' type='select' name='request.courthouse_id' id='accused_lastname' placeholder="Nom de l'accusé" id='accused_lastname' onChange={this.handleChange.bind(this, 'accused_lastname')}>
         this.state.courthouseData.forEach(function(courthouse) {
              <option value={courthouse.id}>{courthouse.name}</option>
          });
      </Form.Field>
    )
return field;

But it doesnt work.  I feel like im close to getting the answer but simply cant get the hand on it. Any ideas ?
TL;DR : I need to create a select with option filled with value from a JSON.

A: You might want to read Why Select Value? in the docs
It's not clear to me why you've created Form.Field abstraction when the select element is perfectly find for expressing your needs
<select className="form-control" name="request.courthouse_id">
  {this.state.courthouseData.map((courthouse, i) => (
    <option key={i} value={courthouse.id}>{courthouse.name}</option>
  ))}
</select>

This has the added benefit of being able to pass a value prop to the select element that will properly display the default/chosen option.

A: Use map to create jsx elements. Try:
var options = this.state.courthouseData.map(function(courthouse) {
   return (
     <option value={courthouse.i}>{courthouse.name}</option>
   );
});

I'm not sure where this function is being called but, chances are you want to return the output in your render function:
render: function() {
  return (
    <SomeParentElement>
      {options}
    </SomeParentElement>
  );
}


text:
Q: Big Ω time complexity of this algorithm I have this code which signifies a greedy algorithm. It adds programs from nums[] until there is no space left on diskSize. It's assumed that nums[] is sorted in order of ascending value and that the total sum of nums[] is > diskSize.
public static int maxPrograms(int[] nums, int diskSize) {
        int numPrograms = 0;

        for(int i = 0; i < nums.length && nums[i] <= diskSize; i++) {
            diskSize -= nums[i];
            numPrograms++;
        }

        return numPrograms;
    }

I believe that the time complexity would be O(n), with a maximum of O(n - 1) iterations in the worst case. What I'm unsure of is the Ω time complexity, which I believe would be Ω(1).
I think it's Ω because in the best case scenario, all items in nums[] are larger than diskSize, and the loop is never triggered. Would this be correct, or am I misjudging this?

A: As long as nums[0] is less than or equal to diskSize, the loop will never be triggered, giving you Ω(1).
for example, heres the algorithm reimplemented in JavaScript:

function maxPrograms(nums, diskSize) {
  let numPrograms = 0;
  for(let i = 0; i < nums.length && nums[i] <= diskSize; i++) {
    console.log("Loop Trigerred")
    diskSize -= nums[i];
    numPrograms++;
  }

  return numPrograms;
}

console.log(maxPrograms(5, [4]))


text:
Q: creating an object with has_many association results in NoMethodError Controllers
class ExperiencesController < ApplicationController
  def create
    @resume = Resume.find(params[:resume])
    @experience = @resume.build_experience(params[:experience])
  end
end

class ResumesController < ApplicationController
  def create
    @resume = Resume.new(params[:resume])
    @resume.build_webconnection
    @resume.build_experience   # <<<<<<<<< Error occurs here

    if @resume.save
      #UserMailer.created_resume_email(@user).deliver
      redirect_to @resume
    else
      @title = "Create a new resume"
      render :action => "new"
    end
  end
end

Models
class Experience < ActiveRecord::Base
  belongs_to :resume
end

class Resume < ActiveRecord::Base
  has_one   :webconnection
  has_many  :experiences
end

Error Message when I try to create a Resume (which also creates an Experience associated with Resume)
NoMethodError in ResumesController#create
undefined method `build_experience' for #<Resume:0xbb428a4>

I feel like I have everything pretty much in place, but missing an 's' or something somewhere. Any idea why I'm getting this error?

A: You would normally use build_experience when using a has_one or a belongs_to association. It's working for webconnection because it is a has_one association.
There's a difference with has_many associations though: you must call the build method on the association, like this: resume.experiences.build. This indicates
Because this is a has_many association and not a has_one or a belongs_to, you should be using resume.experiences.build.

A: Henceforth if you got such error, there is simplest way to check methods like this-
e.g. @resume.methods you will get list of methods.