text:
Q: JProfiler identifying "Unclosed Collected" connections when using JDBCTemplate from spring-jdbc-4.1.6.RELEASE We are testing vendor code, and to help with performance we installed JProfiler 9.1.1.  JProfiler has been helpful identifying performance issues.
One thing that JProfiler identified was "Unclosed Collected" connections.
JProfiler defines "Unclosed Collected" connections as:

a virtual connection where the connection object that has been handed out by the
  database pool has been garbage collected, but close() has not been called on it. This is a definite connection leak.

Per JProfiler, the method that is triggering "Unclosed Collected" connection is:
org.springframework.jdbc.core.JdbcTemplate.query(
      java.lang.String, java.lang.Object[ ],
      org.springframework.jdbc.core.RowMapper)

We are using SQL Server 2012, and JBoss EAP 6.3.3.
Data source configuration
<datasource jta="false" jndi-name="java:/jdbc/abcclmicdds" pool-name="clmDataSource" enabled="true" use-ccm="false">
    <connection-url>jdbc:IP_GOES_HERE</connection-url>
    <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
    <driver>sqlserver2012</driver>
    <pool>
        <min-pool-size>10</min-pool-size>
        <max-pool-size>60</max-pool-size>
    </pool>
    <security>
        <user-name>USERNAME_GOES_HERE</user-name>
        <password>PASSWORD_GOES_HERE</password>
    </security>
    <validation>
        <validate-on-match>false</validate-on-match>
        <background-validation>false</background-validation>
    </validation>
    <timeout>
        <idle-timeout-minutes>0</idle-timeout-minutes>
    </timeout>
    <statement>
        <share-prepared-statements>false</share-prepared-statements>
    </statement>
</datasource>

The vendor came back and claims that JProfiler is misidentifying this as "Unclosed Collected".
JdbcTemplate is designed to automatically close connections for you. Has anyone came across something like this before?  Could JProfiler be misidentifying these connections?


text:
Q: Login failed for user during update-database I have a big problem. I tried to use another solution but didn't help me.
I try to make initial migration (code-first workflow) to database which is on my computer.
I used commands in PM like enable-migrations, then add-migration NameMigration, then update-database and at this moment I have an error like:
Error Number:4060,State:1,Class:11
Cannot open database "CodeFirstDemo.Program+BlogDbContext" requested by the login. The login failed.
Login failed for user 'SZYMON\Szymon'.

My config:
<entityFramework>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
  <connectionStrings>
    <add name="BlogDbContext" connectionString="Data Source=SZYMON\BASE; Initial Catalog=CodeFirstDemo; Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
  </connectionStrings>

Database is not exist yet. My object explorer in MS SQL Server looks
enter image description here
Server properties looks
enter image description here
I don't know what is wrong. Please help me to solve problem.

A: It does not seem that you have access to the database server. Try to login using SQL Management Studio to SZYMON\BASE db server using windows authentication.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Connecting multiple MySQL tables with Foreign Keys I have 3 different tables on MySQL:

*

*Clients

*Flights

*Bookings

On Clients I have

*

*Name

*Last Name

*ID

*Flight Number (from Flights table)

*Booking Number (from Bookings table)

On Flights I have

*

*ID (from Clients)

*Flight Number

*Company

*Date

On Bookings I have

*

*ID (from Clients)

*Booking Number

*Hotel

*Check-in date

*Check-out date

I want, after creating a Client, to make what I create on Flights and Bookings tables link on the Clients.
So, each Client has an ID that is also inserted into Flights and Bookings tables. And I need to link that Clients.ID row to it's row on Flights and Bookings.
Is this possible with Foreign Keys?
I tried making Clients.ID a Primary Key and Flights.ID and Booking.ID a Foreign Key, but then when I use INSERT INTO I get :

#1452 - Cannot add or update a child row: a foreign key constraint fails

The SQL query was:
INSERT INTO clients (name, lastname, id) VALUES ('Jane', 'DOE', 123123123);

The SQL query to create the Foreign Keys was:
ALTER TABLE clients ADD CONSTRAINT fk_flightid FOREIGN KEY (id) REFERENCES flights(id);` and

ALTER TABLE clients ADD CONSTRAINT fk_bookingid FOREIGN KEY (id) REFERENCES bookings(id);`

This is my first time coding MySQL, sorry if my explanation is messy.

A: You  have created constraints that make client a child table of flights and bookings. As a consequence, you cannot create new clients (you would need to create parent records in the two other tables first).
In your database design, client should be the parent table, with flights and bookings as children tables.
Consider:
ALTER TABLE flights
    ADD CONSTRAINT fk_flights_client_id
    FOREIGN KEY (id) REFERENCES client(id);

ALTER TABLE bookings
    ADD CONSTRAINT fk_bookings_client_id
    FOREIGN KEY (id) REFERENCES client(id);

Other remarks:

*

*columns Flight Number (from Flights table) and Booking Number (from Bookings table) do not make sense in the Client table. These information belong to the children table, and can be accessed through JOINs

*I would recommend renaming columns ID to ClientID in all 3 tables; using a name that makes sense functionaly is better than a generic name.


text:
Q: Java - Storing Several string inputs using a loop and input.nextline(); I'm trying to get a set of string statements (which can include spaces) into a string array. The number of statements will be decided by the input of the user.
So I thought of looping the input.nextline(); function.
But I think as soon as enter is hit it is taken as \n to all the loops..
Is there any better way to do this?
    Scanner input = new Scanner(System.in);
    System.out.println("How many Inputs??");
    numOfInputs = input.nextInt();
    String[] dataStore = new String[numOfInputs];
    System.out.println("Input Strings");

    for(i=0;i<numOfInputs;i++){
        System.out.print("Input "+(i+1)+ " = ");

        dataStore[i] =  input.next();

    }

A: Add this to the bottom after the for loop, your code is working fine:
for(String str : dataStore) {
    System.out.println(str);
}

A: public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    System.out.println("How many Inputs??");
    int numOfInputs = input.nextInt();
    String[] dataStore = new String[numOfInputs];
    System.out.println("Input Strings");

    for (int i = 0; i < numOfInputs; i++) {
        dataStore[i] = input.next();
        System.out.println("Input " + (i + 1) + " = " + dataStore[i]);

    }
}

Try this . I corrected the mistakes.


text:
Q: Как правильно расставить отношения OneToMany - ManyToOne? Есть две сущности новости и категории. Создаю отношение в сущности news к category:
@ManyToOne(fetch = FetchType.EAGER, targetEntity = Category.class)
    @JoinColumn(name = "category")
    private int category;

Многое к одному, то есть многим записям может соответствовать 1 категория.
К примеру мне нужно чтобы было именно отношение News.category-> Category.id.
То есть я проставил в базе цифру 1 что соответствует 1 категории, ниже скрины:

Сущность Category
@Entity
@Table(name = "Category")
public class Category {

    @Id
    @GeneratedValue(generator = "increment")
    @GenericGenerator(name = "increment", strategy = "increment")
    private long id;

    @Column(name = "category")
    private String category;

    public String getCategory() {
        return category;
    }
    public void setCategory(String category) {
        this.category = category;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

Проект собирается, но при запросе на сервер вылетает ошибка -
HTTP Status [500] – [Internal Server Error].

Message Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: Could not set field value [com.reweu.server.entity.Category@2e9827b7] value by reflection : [class com.reweu.server.entity.News.category] setter of com.reweu.server.entity.News.category; nested exception is org.hibernate.PropertyAccessException: Could not set field value [com.reweu.server.entity.Category@2e9827b7] value by reflection : [class com.reweu.server.entity.News.category] setter of com.reweu.server.entity.News.category

Подскажите пожалуйста в чем может быть причина.

A: Может кому пригодиться.
Разобрался, у меня ошибка в private int category;
Надо так:
@ManyToOne(fetch = FetchType.EAGER, targetEntity = Category.class)
    @JoinColumn(name = "category")
    private Сategory category;


text:
Q: Placing two div's, of unequal width, with margin, paddding and border, side by side I want to place two divs side by side. However, I don't want them to be equal in width; I want the first div to take up 70% of the space and the second one to fill the rest of the space.
So far I have this code (or see this JSFiddle):
HTML

    div 1

    div 2

CSS
body {
    text-align: center;
}
.bodyRect {
    border: 1px solid black;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    /*behavior: url(/PIE.htc); /* CSS PIE - for IE 6-8 */
    padding: 10px;
    margin: 10px;
}
#d1 {
    width: 70%; float: left
}
#d2 {
    width: 30%; float: right
}
.clearfix {
    display: block;
    clear: both;
    visibility: hidden;
    line-height: 0;
    height: 0;
}

However, that results in this:

Only after removing the margin, padding, and border do the divs align correctly.
How can I make this work while still keeping the margin, padding, and border?
It needs to support IE8.

A: Separate the padding and margin from the parent
 by placing a child within. It will fill the width of parent, but the margin and padding are subtracted from the width of the parent (instead of added to it). This results in a true 70% and 29%
s, with padding and margin inside.
Here is a link to the working fiddle: http://jsfiddle.net/wkpxj/5/
Here is the HTML:

    div 1

    div 2

The CSS:
body {
    text-align: center;
}
.bodyRect { /* move all stylings to the child */
}

.bodyRect > div { /* apply padding and margin to the direct descendent */
    border: 1px solid black; /* apply border here to respect margin */
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    /*behavior: url(/PIE.htc); /* CSS PIE - for IE 6-8 */

    padding: 10px;
    margin: 10px;
}

#d1 {
    width: 70%; float: left
}
#d2 {
    width: 29%; float: right /* <100% to allow for border */
}
.clearfix {
    display: block;
    clear: both;
    visibility: hidden;
    line-height: 0;
    height: 0;
}

A: The most semantic solution to this problem, which I'll describe here, is only supported in IE9+. For deeper IE support, refer to Set Sail's answer. I know the asker needs IE8+ support, but I just thought that I'd put this answer here in case other programmers find this question who have less stringent requirements.
I like this answer because it doesn't require any additional markup; it keeps the styling completely contained in the Css.
View the solution on JSFiddle
We do two things here:
1. box-sizing: border-box;
What this does is calculate the width of the divs to include the border and padding, but not the margin.
2. width: calc();
And what this does is allow us to write equations to calculate widths. In this case, we subtract 20px from the width of both of our divs, as they both have a left and right margin of 10px each.
The Css
.bodyRect {
  ...
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
#d1 {
  width: -webkit-calc(70% - 20px);
  width: -moz-calc(70% - 20px);
  width: calc(70% - 20px);
  float: left
}
#d2 {
  width: -webkit-calc(30% - 20px);
  width: -moz-calc(30% - 20px);
  width: calc(30% - 20px);
  float: right
}

A: How can I make this work while still keeping the margin, padding, and border?
The margin, padding, and border take up some of the space. If you set your widths to something lower, you'll see that the divs are side-by-side: JSFiddle

A: I wouldn't use the float in this case. You can achieve the placement next to each other by putting display: inline-block.
The reason the why you have trouble displaying them next to each other are the margins which are not part of the width.
.bodyRect {
    border: 1px solid black;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    /*behavior: url(/PIE.htc); /* CSS PIE - for IE 6-8 */
    padding: 10px;
    margin: 10px;
}
#d1 {
    width: 50%;
    display: inline-block;
}
#d2 {
    width: 29%;
    display: inline-block;
}


text:
Q: Convert C++Builder AnsiString to std::string via boost::lexical_cast For a school assignment I have to implement a project in C++ using Borland C++ Builder.
As the VCL uses AnsiString for all GUI Components I have to convert all of my std::strings to AnsiString for the sake of displaying.
std::string inp = "Hello world!";
AnsiString outp(inp.c_str());

works of course but is a bit tedious to write and code duplication I want to avoid. As we use Boost in other contexts I decided to provide some helper functions go get boost::lexical_cast to work with AnsiString. Here is my implementation so far:
std::istream& operator>>(std::istream& istr, AnsiString& str) {
    istr.exceptions(std::ios::badbit | std::ios::failbit | std::ios::eofbit);
    std::string s;
    std::getline(istr,s);
    str = AnsiString(s.c_str());
    return istr;
}

In the beginning I got Access Violation after Access Violation but since I added the .exceptions() stuff the picture gets clearer.
When the conversion is performed I get the following Exception:
ios_base::eofbit set [Runtime Error/std::ios_base::failure]

Does anyone have an idea how to fix it and can explain why the error occurs? My C++ experience is very limited.
The conversion routine the other way round would be:
std::ostream& operator<<(std::ostream& ostr,const AnsiString& str) {
    ostr << (str.c_str());
    return ostr;
}

Maybe someone will spot an error here too :)
With best regards!
Edit:
At the moment I'm using the edited version of Jem, it works in the beginning. After a while of using the programm the Borland Codeguard mentions some pointer arithmetic in already freed regions. Any ideas how this could be related?
The Codeguard log (I'm using the german version, translations marked with stars):
------------------------------------------
Fehler 00080. 0x104230 (r) (Thread 0x07A4):
Zeigerarithmetik in freigegebenem Speicher: 0x0241A238-0x0241A258. **(pointer arithmetic in freed region)**
| d:\program files\borland\bds\4.0\include\dinkumware\sstream Zeile 126:
|               {   // not first growth, adjust pointers
|               _Seekhigh = _Seekhigh - _Mysb::eback() + _Ptr;
|>              _Mysb::setp(_Mysb::pbase() - _Mysb::eback() + _Ptr,
|                   _Mysb::pptr() - _Mysb::eback() + _Ptr, _Ptr + _Newsize);
|               if (_Mystate & _Noread)
Aufrufhierarchie: **(stack-trace)**
   0x00411731(=FOSChampion.exe:0x01:010731) d:\program files\borland\bds\4.0\include\dinkumware\sstream#126
   0x00411183(=FOSChampion.exe:0x01:010183) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#465
   0x0040933D(=FOSChampion.exe:0x01:00833D) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#151
   0x00405988(=FOSChampion.exe:0x01:004988) d:\program files\borland\bds\4.0\include\dinkumware\ostream#679
   0x00405759(=FOSChampion.exe:0x01:004759) D:\Projekte\Schule\foschamp\src\Server\Ansistringkonverter.h#31
   0x004080C9(=FOSChampion.exe:0x01:0070C9) D:\Projekte\Schule\foschamp\lib\boost_1_34_1\boost/lexical_cast.hpp#151

Objekt (0x0241A238) [Größe: 32 Byte] war erstellt mit new **(Object was created with new)**
| d:\program files\borland\bds\4.0\include\dinkumware\xmemory Zeile 28:
|   _Ty _FARQ *_Allocate(_SIZT _Count, _Ty _FARQ *)
|   {   // allocate storage for _Count elements of type _Ty
|>  return ((_Ty _FARQ *)::operator new(_Count * sizeof (_Ty)));
|   }
|
Aufrufhierarchie: **(stack-trace)**
   0x0040ED90(=FOSChampion.exe:0x01:00DD90) d:\program files\borland\bds\4.0\include\dinkumware\xmemory#28
   0x0040E194(=FOSChampion.exe:0x01:00D194) d:\program files\borland\bds\4.0\include\dinkumware\xmemory#143
   0x004115CF(=FOSChampion.exe:0x01:0105CF) d:\program files\borland\bds\4.0\include\dinkumware\sstream#105
   0x00411183(=FOSChampion.exe:0x01:010183) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#465
   0x0040933D(=FOSChampion.exe:0x01:00833D) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#151
   0x00405988(=FOSChampion.exe:0x01:004988) d:\program files\borland\bds\4.0\include\dinkumware\ostream#679

Objekt (0x0241A238) war Gelöscht mit delete **(Object was deleted with delete)**
| d:\program files\borland\bds\4.0\include\dinkumware\xmemory Zeile 138:
|   void deallocate(pointer _Ptr, size_type)
|       {   // deallocate object at _Ptr, ignore size
|>      ::operator delete(_Ptr);
|       }
|
Aufrufhierarchie: **(stack-trace)**
   0x004044C6(=FOSChampion.exe:0x01:0034C6) d:\program files\borland\bds\4.0\include\dinkumware\xmemory#138
   0x00411628(=FOSChampion.exe:0x01:010628) d:\program files\borland\bds\4.0\include\dinkumware\sstream#111
   0x00411183(=FOSChampion.exe:0x01:010183) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#465
   0x0040933D(=FOSChampion.exe:0x01:00833D) d:\program files\borland\bds\4.0\include\dinkumware\streambuf#151
   0x00405988(=FOSChampion.exe:0x01:004988) d:\program files\borland\bds\4.0\include\dinkumware\ostream#679
   0x00405759(=FOSChampion.exe:0x01:004759) D:\Projekte\Schule\foschamp\src\Server\Ansistringkonverter.h#31

------------------------------------------

Ansistringkonverter.h is the file with the posted operators and line 31 is:
std::ostream& operator<<(std::ostream& ostr,const AnsiString& str) {
    ostr << (str.c_str()); **(31)**
    return ostr;
}

Thanks for your help :)

A: Still not using boost, but may be a first step to solve your current problem. You may try this:
std::istream& operator>>(std::istream& istr, AnsiString& str) {
    istr.exceptions(std::ios::badbit | std::ios::failbit | std::ios::eofbit);
    std::string s;
    istr >> s;
    str = AnsiString(s.c_str());
    return istr;
}

EDIT: more complete solution, taking op's comments into account:
std::istream& operator>> (std::istream& istr, AnsiString& str)
{
    std::string tmp;

    std::istreambuf_iterator<char> it(istr), end;
    std::copy(it, end, std::inserter(tmp, tmp.begin()));

    str = AnsiString(tmp.c_str());

    return istr;
}

However, having different operator >> behavior for std::string and AnsiString is probably ok for your needs, but not very nice in general. You can still give it an explicit name.

A: Your conversion converts one line of the input. That's a serious problem if there are two lines, and a rather fatal bug if there are none. The best solution in this case is not a new operator>>, but a template specialization. Top of my head:
template< > AnsiString lexical_cast<AnsiString, std::string>(std::string const& s)
{
    return AnsiString(s.c_str());
}

(You're not supposed to overload other peoples templates. In std::, it's illegal, elsewhere just bad practice)

A: You may also try this! I had also that kind of problem working with hashlib++.
String toAnsiString(const std::string& myString)
{
  return String(myString.c_str());
}

A: In addition to MSalters comments, It would be more efficient to pass the std::string's actual length to AnsiString as well, so that it does not need waste CPU cycles to calculating the length manually:
template<> System::AnsiString lexical_cast<System::AnsiString, std::string>(std::string const& s)
{
    return System::AnsiString(s.c_str(), s.length());
}


text:
Q: How to insert into realm database with specific position and how to retrieve the data with that position in android? I am using retrofit to parse youtube api json data and used tablayout and viewpager.titles are coming correctly and the data is only coming for the first youtube playlist and the same repeating for the other fragments.saved data to realm like this
private void setAdapterVideos(final List<YoutubeVideoDetails> items, final List<YoutubePlayListVideos> videosList) {
                        realm.executeTransaction(new Realm.Transaction() {
                            @Override
                            public void execute(Realm realm) {
                                realm.copyToRealmOrUpdate(items);
                                realm.copyToRealmOrUpdate(videosList);
                            }
                        });
                    }`

and retrieved the data like this
realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                videosList = realm.where(YoutubePlayListVideos.class).findAll();
                videoDetails = realm.where(YoutubeVideoDetails.class).findAll();
            }
        });
        if (videosList.size() > 0) {
            new LogUtil("aaaaaaaaaaa",posi+": "+videosList.get(0).getSnippet().getTitle());

            VideoAdapter vAdapter = new VideoAdapter(getActivity(), videosList, videoDetails);
            recyclerView.setAdapter(vAdapter);
            progressBar.setVisibility(View.GONE);
        }

I am new to realm database used only SQ Lite and any help would be appreciated...!


text:
Q: Static initialization with private constructor In a class I have a static member that represents the singleton instance of that class:
class A {
public:
  static const std::shared_ptr<A> INSTANCE;
private:
  A();
};

In order to prevent more instances I made the constructor private. Now I have trouble to initialize the static var, because the initializer cannot access a private member. Here's the code I use in the .cpp file:
const std::shared_ptr<A> A::INSTANCE = std::make_shared<A>();

A factory method wouldn't help either, as it would have to be public as well. What else can I do to make this work? Note: I'd like to avoid the typical static get() method if possible.

A: You can't use make_shared, but you can just create the instance directly:
const std::shared_ptr<A> A::INSTANCE { new A };

A: The initialization of a static member is unrelated to the constructor, so the global statement is indeed the right way to go. Is it not working for you?
EDIT: I just realized you're trying to avoid using a singleton access method for some reason. Sounds suspiciously like the Borg pattern. :) Unrelated to you r specific question but I'd advise you to reconsider.


text:
Q: Unable to use an Array as environment variable I don't know why I can't use env array variable inside a script ?
In my ~/.bashrc or ~/.profile
export HELLO="ee"
export HELLOO=(aaa bbbb ccc)

in a shell :
> echo $HELLO
ee
> echo $HELLOO
aaa
> echo ${HELLOO[@]}
aaa bbbb ccc

in a script :
#!/usr/bin/env bash
echo $HELLO
echo $HELLOO
echo ${HELLOO[@]}
---
# Return
ee

Why ?

A: Arrays are bash specific.  Environment variables are name-value pairs.
Read the specifications on environment variables, which says, in part:

The value of an environment variable is a string of characters. For a C-language program, an array of strings called the environment shall be made available when a process begins. The array is pointed to by the external variable environ, which is defined as:
extern char **environ;

These strings have the form name=value; names shall not contain the character '='.

A: A bash array can not be an environment variable as environment variables may only be key-value string pairs.
You may do as the shell does with its $PATH variable, which essentially is an array of paths; turn the array into a string, delimited with some particular character not otherwise present in the values of the array:
$ arr=( aa bb cc "some string" )
$ arr=$( printf '%s:' "${arr[@]}" )
$ printf '%s\n' "$arr"
aa:bb:cc:some string:

Or neater,
arr=( aa bb cc "some string" )
arr=$( IFS=:; printf '%s' "${arr[*]}" )
export arr

The expansion of ${arr[*]} will be the elements of the arr array separated by the first character of IFS, here set to :.  Note that if doing it this way, the elements of the string will be separated (not delimited) by :, which means that you would not be able to distinguish an empty element at the end, if there was one.

An alternative to passing values to a script using environment variables is (obviously?) to use the command line arguments:
arr=( aa bb cc )

./some_script "${arr[@]}"

The script would then access the passed arguments either one by one by using the positional parameters $1, $2, $3 etc, or by the use of $@:
printf 'First I got "%s"\n' "$1"
printf 'Then  I got "%s"\n' "$2"
printf 'Lastly there was "%s"\n' "$3"

for opt in "$@"; do
    printf 'I have "%s"\n' "$opt"
done

A: Current Array Export Situation 10/2021
Array export is not fully implemented yet. You can clone the source code with command git clone https://git.savannah.gnu.org/git/bash.git ~/bash-src. Look into the bash source ~/bash-src/config-top.h for the commented line 154:
/* Define to 1 if you want to be able to export indexed arrays to processes
   using the foo=([0]=one [1]=two) and so on */
/* #define ARRAY_EXPORT 1 */

and furthermore the code section in ~/bash-src/variables.c at line 429 which says
#if defined (ARRAY_VARS)
#  if ARRAY_EXPORT
      /* Array variables may not yet be exported. */
      if (*string == '(' && string[1] == '[' && string[strlen (string) - 1] == ')')
    {
      string_length = 1;
      temp_string = extract_array_assignment_list (string, &string_length);
      temp_var = assign_array_from_string (name, temp_string, 0);
      FREE (temp_string);
      VSETATTR (temp_var, (att_exported | att_imported));
      array_needs_making = 1;
    }
      else
#  endif /* ARRAY_EXPORT */
#endif

so basically some more work has to be put into this issue.
Workaround
Meanwhile you can export the BASH_ENV variable which can point to an environment script. I put mine into /etc/bash.environment and declare system-wide arrays there. Your ~/.bashrc could contain something like export BASH_ENV="~/.bash.environment", now every bash process executed by the current user will source this file.
As @they mentioned below an according ~/.bashrc configuration to take effect on interactive AND noninteractive shells is needed:
[ -r "~/.bash.environment" ] \
&& source "~/.bash.environment" \
&& export BASH_ENV="~/.bash.environment"

And finally your environment:
# ~/.bash.environment
export HELLO="ee"
export HELLOO=(aaa bbbb ccc)

Non-persistent Workaround
A non-persistent solution for passing arrays quick and dirty could look like so, that you assign the named pipe created by process substitution <() to BASH_ENV environment variable:
BASH_ENV=<(declare -p HELLO HELLOO) your_script.sh

Best wishes


text:
Q: ElasticSearch - searching different doc_types with the same field name but different analyzers Let's say I make a simple ElasticSearch index:
curl -XPUT 'http://localhost:9200/test/' -d '{
    "settings": {
        "analysis": {
            "char_filter": {
                "de_acronym": {
                    "type": "mapping",
                    "mappings": [".=>"]
                }
            },
            "analyzer": {
                "analyzer1": {
                    "type":      "custom",
                    "tokenizer": "keyword",
                    "char_filter": ["de_acronym"]
                }
            }
        }
    }
}'

And I make two doc_types that have the same property name but they are analyzed slightly differently from one another:
curl -XPUT 'http://localhost:9200/test/_mapping/docA' -d '{
    "docA": {
        "properties": {
            "name": {
                "type": "string",
                "analyzer": "simple"
            }
        }
    }
}'
curl -XPUT 'http://localhost:9200/test/_mapping/docB' -d '{
    "docB": {
        "properties": {
            "name": {
                "type": "string",
                "analyzer": "analyzer1"
            }
        }
    }
}'

Next, let's say I put a document in each doc_type with the same name:
curl -XPUT 'http://localhost:9200/test/docA/1' -d '{ "name" : "U.S. Army" }'
curl -XPUT 'http://localhost:9200/test/docB/1' -d '{ "name" : "U.S. Army" }'

Let's try to search for "U.S. Army" in both doc types at the same time:
curl -XGET 'http://localhost:9200/test/_search?pretty' -d '{
    "query": {
        "match_phrase": {
            "name": {
                "query": "U.S. Army"
            }
        }
    }
}'
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.5,
    "hits" : [ {
      "_index" : "test",
      "_type" : "docA",
      "_id" : "1",
      "_score" : 1.5,
      "_source":{ "name" : "U.S. Army" }
    } ]
  }
}

I only get one result! I get the other result when I specify docB's analyzer:
curl -XGET 'http://localhost:9200/test/_search?pretty' -d '
{
    "query": {
        "match_phrase": {
            "name": {
                "query": "U.S. Army",
                "analyzer": "analyzer1"
            }
        }
    }
}'
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "test",
      "_type" : "docB",
      "_id" : "1",
      "_score" : 1.0,
      "_source":{ "name" : "U.S. Army" }
    } ]
  }
}

I was under the impression that ES would search each doc_type with the appropriate analyzer. Is there a way to do this?
The ElasticSearch docs say that precedence for search analyzer goes:
1) The analyzer defined in the query itself, else
2) The analyzer defined in the field mapping, else
...
In this case, is ElasticSearch arbitrarily choosing which field mapping to use?

A: Take a look at this issue in github, which seems to have started from this post in ES google groups. I believe it answers your question:

if its in a filtered query, we can't infer it, so we simply pick one of those and use its analysis settings


text:
Q: Google Drive - Trash/Bin Won't Empty with 200,000 files Google Drive has told me I have 200,000 files in my trash/bin, taking up 19GB. I've repeatedly tried clicking the "Empty Bin" option in browser, but that doesn't seem to do anything.
I called Google Drive Support, and the guy said that when you click Empty Bin, it only gets rid of what your browser has loaded... He recommended scrolling and then clicking empty bin occasionally. What kind of a suggestion is that? I said I have 200,000 files in my bin, which he already knew, and apologised, saying it was the only way.

A: I'm experiencing the very same thing right now:

*

*I accidentally synced a huge folder containing > 300GB worth of stuff,
so I quickly reached the 15GB limit without realising the issue

*I moved this folder to the bin, clicked empty bin, but it struggles to
load, and when it does it loads and displays more folders, suggesting
that emptying bin contents only deletes what is displayed in the bin

However...
I believe it is deleting the bin contents, just very slowly
The 'Storage' level at the bottom of the left panel goes down by 0.1GB every few minutes. I believe it's iterating through every bin item and removing it permanently, hence why it's taking so long.
Hope that info helps someone else too!


text:
Q: Experimental design for discrete choice response I'm designing a survey where people need to choose one of three transportation alternatives. Here are the alternatives, their specific factors/attributes and the levels I intend to use for each:
Regular car:
    Fixed cost: 3 levels: $10.00, $15.00, $20.00
Variable cost: 3 levels: $0.25, $0.50, $0.75
    No waiting time
Electric car:
    Fixed cost: 3 levels: $05.00, $15.00, $30.00
Variable cost: 3 levels: $0.25, $0.50, $0.75
    No waiting time
Taxi:
    No fixed cost
    Variable cost: 3 levels: $2.00, $3.00, $4.00
    Waiting time: 3 levels: 2min, 5min, 8min

Besides all of this, there is another factor/attribute that should be taken into account in the design which doesn't "belong" to any of the alternatives - it's a factor that affects people's choices "externally". It would be something like this:
Weather condition: 3 levels: sunny, rainy and overcast

Notice how I would have ONE weather condition per choice occasion, not one weather condition per alternative.
I've created designs with about 40 or 50 runs, but I can't possibly ask every person in my survey to answer 50 versions of a very similar question. In my case, I would like each respondent to receive only 2 choice occasions (i.e. 2 "repetitions" per survey).
So, for example, one survey would look something like this:

Question 1
  When the weather is sunny, which one of these modes would you use?
  Regular car:  FC=\$10.00, VC=\$0.75, WT=0min
  Electric car: FC=\$30.00, VC=\$0.50, WT=0min
  Taxi:         FC=\$00.00, VC=\$3.00, WT=5min
Question 2
  When the weather is rainy, which one of these modes would you use?
  Regular car:  FC=\$15.00, VC=\$0.50, WT=0min
  Electric car: FC=\$05.00, VC=\$0.75, WT=0min
  Taxi:         FC=\$00.00, VC=\$4.00, WT=2min
(FC = Fixed cost, VC = Variable cost, WT = Waiting time)

Since this will be a paper-based survey (yes, old school printing, mail-out and all that), it would make logistics MUCH easier if I only have around 10 versions of the survey.
Does anyone know what software to use for this kind of design?
I have found how to generate orthogonal designs and fractional factorial designs in R and SPSS. However, I haven't found how to split those designs into groups of 2 questions and still guarantee a small number of overall versions of the survey.
I also found that some design of experiment tools (such as JMP's "Choice DoE" module) were made considering that all of the alternatives share exactly the same attributes and levels. In other words, the alternatives themselves are almost identical to each other, and the only thing that sets them apart from one another are the attribute levels, making the alternatives almost perfect substitutes (e.g. hard drives with different capacities, write speeds and costs; or potato chips with different flavors, textures and costs).
I can clearly recognize that the situation I'm dealing with is different: even if costs and travel times are the same, there is still some fundamental difference between regular cars, electric cars and taxis that might make people choose one over the other. Since this is the case, I'm not sure the default tools I found are appropriate for developing a DoE for this problem.
Does anyone know any resources I could look at to help with this? I've already taken a look at Hensher, Rose & Greene's "Applied Choice Analysis" and Louviere, Hensher & Swait's "Stated Choice Methods", but the language seems incredibly cryptic and dense.
TL;DR
What tools would you use to design an experiment where you have the following particularities:
 - The outcome to be analyzed is a discrete-choice outcome
 - Not all alternatives share the same attributes and/or attribute levels
 - Some attributes analyzed affect all alternatives simultaneously
 - You want to ensure a reasonable amount of repetitions/choice occasions per respondent (around 2 or 3) such that you don't fatigue the respondent
 - All versions of the survey have to be created beforehand (i.e. cannot randomly choose from a full design for each respondent) due to printing and other logistical constraints


text:
Q: App crashes when switching from main activity to a new activiy My app crashes when I use use a menu button to switch to a new page and call a new Activity. I have followed the tutorial from the android developer site which shows how to link button clicks to a new activity but when I click a button object the app crashes without changing to the new activity.
I have six different activities linking from the main activity.
My log cat is as follows:
03-05 20:12:10.185: W/ActivityManager(288): Activity pause timeout for ActivityRecord{40d31ab0 u0 com.example.g00290342bvarley/.MainActivity}
03-05 20:12:10.394: E/SurfaceFlinger(36): ro.sf.lcd_density must be defined as a build property
03-05 20:12:10.954: E/SurfaceFlinger(36): ro.sf.lcd_density must be defined as a build property
03-05 20:12:11.065: W/EGL_emulation(863): eglSurfaceAttrib not implemented
03-05 20:12:11.474: I/QSB.SuggestionsProviderImpl(863): chars:0,corpora:[web, apps, com.android.contacts/.activities.PeopleActivity]
03-05 20:12:11.604: E/SurfaceFlinger(36): ro.sf.lcd_density must be defined as a build property
03-05 20:12:11.744: W/EGL_emulation(449): eglSurfaceAttrib not implemented
03-05 20:12:12.815: I/Choreographer(288): Skipped 32 frames!  The application may be doing too much work on its main thread.
03-05 20:12:13.114: D/dalvikvm(863): GC_CONCURRENT freed 398K, 13% free 3825K/4348K, paused 11ms+154ms, total 867ms
03-05 20:12:15.115: I/Process(1467): Sending signal. PID: 1467 SIG: 9
03-05 20:12:15.285: I/WindowState(288): WIN DEATH: Window{40dbdb70 u0 com.example.g00290342bvarley/com.example.g00290342bvarley.MainActivity}
03-05 20:12:15.297: I/ActivityManager(288): Process com.example.g00290342bvarley (pid 1467) has died.
03-05 20:12:15.455: W/InputMethodManagerService(288): Got RemoteException sending setActive(false) notification to pid 1467 uid 10048
03-05 20:12:36.119: D/ExchangeService(688): Received deviceId from Email app: null
03-05 20:12:36.119: D/ExchangeService(688): !!! deviceId unknown; stopping self and retrying
03-05 20:12:41.254: D/ExchangeService(688): !!! EAS ExchangeService, onCreate
03-05 20:12:41.264: D/ExchangeService(688): !!! EAS ExchangeService, onStartCommand, startingUp = false, running = false
03-05 20:12:41.284: W/ActivityManager(288): Unable to start service Intent { act=com.android.email.ACCOUNT_INTENT } U=0: not found
03-05 20:12:41.294: D/ExchangeService(688): !!! Email application not found; stopping self
03-05 20:12:41.304: D/ExchangeService(688): !!! EAS ExchangeService, onStartCommand, startingUp = true, running = false
03-05 20:12:41.334: W/ActivityManager(288): Unable to start service Intent { act=com.android.email.ACCOUNT_INTENT } U=0: not found
03-05 20:12:41.354: E/ActivityThread(688): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d06b20 that was originally bound here

MainActivity where button methods located:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends Activity {

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

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

    //methods for button clicks

    public void aboutMeth(View view) {
        // Do something in response to button
        Intent intent = new Intent(this, AboutGmit.class);
        EditText editText = (EditText) findViewById(R.id.about);
        startActivity(intent);

    }

    public void mapMeth(View view) {
        // Do something in response to button
        Intent intent = new Intent(this, MapGmit.class);
        EditText editText = (EditText) findViewById(R.id.map);
        startActivity(intent);
    }

    public void courseMeth(View view) {
        // Do something in response to button
        Intent intent = new Intent(this, CourseInfo.class);
        EditText editText = (EditText) findViewById(R.id.courseInfo);
        startActivity(intent);
    }

    public void lifeMeth(View view) {
        // Do something in response to button
        Intent intent = new Intent(this, StudentLife.class);
        EditText editText = (EditText) findViewById(R.id.studLife);
        startActivity(intent);
    }

    public void portalMeth(View view) {
        // Do something in response to button
        Intent intent = new Intent(this, StudentPortal.class);
        EditText editText = (EditText) findViewById(R.id.studPortal);
        startActivity(intent);
    }

    public void contactMeth(View view) {
        // Do something in response to button
        Intent intent = new Intent(this, ContactInfo.class);
        EditText editText = (EditText) findViewById(R.id.contact);
        startActivity(intent);
    }

}

The new activity called ContactInfo.java
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class ContactInfo extends Activity {

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

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

}

The manifest file where I have added the activity element.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.g00290342bvarley"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.g00290342bvarley.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.example.g00290342bvarley.AboutGmit"
            android:label="@string/title_activity_about_gmit"
             android:parentActivityName="com.example.g00290342bvarley.MainActivity"
            >
        </activity>
        <activity
            android:name="com.example.g00290342bvarley.MapGmit"
            android:label="@string/title_activity_map_gmit"
             android:parentActivityName="com.example.g00290342bvarley.MainActivity"
            >
        </activity>
        <activity
            android:name="com.example.g00290342bvarley.CourseInfo"
            android:label="@string/title_activity_course_info"
             android:parentActivityName="com.example.g00290342bvarley.MainActivity"
            >
        </activity>
        <activity
            android:name="com.example.g00290342bvarley.StudentLife"
            android:label="@string/title_activity_student_life"
             android:parentActivityName="com.example.g00290342bvarley.MainActivity"
            >
        </activity>
        <activity
            android:name="com.example.g00290342bvarley.StudentPortal"
            android:label="@string/title_activity_student_portal"
            android:parentActivityName="com.example.g00290342bvarley.MainActivity"
            >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.g00290342bvarley.MainActivity" />
        </activity>
        <activity
            android:name="com.example.g00290342bvarley.ContactInfo"
            android:label="@string/title_activity_contact_info"
             android:parentActivityName="com.example.g00290342bvarley.MainActivity"
            >
        </activity>
    </application>

</manifest>

Button layout in activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <Button
        android:id="@+id/about"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:onClick="aboutMeth"
        android:hint="Details about GMIT"
        android:text="@string/about" />

    <Button
        android:id="@+id/map"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="95dp"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:onClick="mapMeth"
        android:hint="Location of GMIT on google maps"
        android:text="@string/map" />

    <Button
        android:id="@+id/courseInfo"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:onClick="courseMeth"
        android:hint="Info about courses offered by GMIT"
        android:text="@string/courseInfo" />

    <Button
        android:id="@+id/studLife"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="98dp"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:hint="Gallery"
        android:onClick="lifeMeth"
        android:text="@string/studLife" />

    <Button
        android:id="@+id/studPortal"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="93dp"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:onClick="portalMeth"
        android:hint="The Student Portal!"
        android:text="@string/studPortal" />

    <Button
        android:id="@+id/contact"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:onClick="contactMeth"
        android:hint="GMIT contact info"
        android:text="@string/contact" />

</LinearLayout>

A: The <activity> element belongs in your AndroidManifest.xml file, not in your layout files.
You need to add all 6 activities to your AndroidManifest.xml file.

A: this
 <activity
    android:name="com.example.g00290342bvarley.ContactInfo"
    android:label="@string/title_activity_contact_info"
    android:parentActivityName="com.example.g00290342bvarley.MainActivity" >
    <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value="com.example.g00290342bvarley.MainActivity" />
</activity>

goes in the Manifest, not in the XML of your activity!

A: I might be missing something but I give a try .
In each of your onClick methods you 're trying to get an editText.
EditText editText = (EditText) findViewById(R.id.contact);

But there is no editText declared in your layout, so it turns into NullPointerException.
Try to remove this line .
Hope it ll help


text:
Q: How to change the name of Lists generated by JAXB I have an xsd that I'm using to generate an object model in Java using JAXB and I want the Lists it generates to be renamed to xyzList instead of xyz. Is there a way to do this without having to add an entry in the bindings file for each list?
For example this xsd fragment:
<xs:element name="RegulatoryEL" minOccurs="0" maxOccurs="unbounded">

generates this:
protected List<RegulatoryEL> RegulatoryEL;

but I want something like:
protected List<RegulatoryEL> RegulatoryELList;

A: JAXB (JSR-222) does not provide a global setting to control how field/property names are generated for elements that can appear multiple times.  Using standard config you will need to do this on a per element basis using an external binding file.

*

*How do you customize how JAXB generates plural method names?

To do this in a more general way you could create your own XJC extension:

*

*http://ricston.com/blog/xjc-plugin/

A: For manipulate names you can use plugin and register you own name converter. For example look at xjcnormalize.
Detailed explanation from their author you may find in this answer: JAXB convert non-ASCII characters to ASCII characters


text:
Q: Deriving TypeScript interface from object literal Does TypeScript have the ability to infer an interface from an object literal? Like the following:
export const theme = {
  primaryColor: "#e9e9eb",
  secondaryColor: "blue"
};

The interface would be the following, which (AFAICT), TypeScript compels me to create a separate interface for, but I would like to automatically derive.
export interface IThemeInterface {
  primaryColor: string;
  secondaryColor: string;
}

A: type IThemeInterface = typeof theme; does the correct thing here.


text:
Q: How to query pandas data frame where field having dot in field name from pandas.io.json import json_normalize

record = {'a': {'b': 1, 'c': 2}}
df = json_normalize(record)
print(df.query("a.b == 1"))

Printing below error:
  File "C:\Python37\lib\site-packages\pandas\core\computation\scope.py", line 194, in resolve
    raise compu.ops.UndefinedVariableError(key, is_local)
pandas.core.computation.ops.UndefinedVariableError: name 'a' is not defined


text:
Q: Restricting users to access C drive in C#? i have a winform to merge few file and save the merge files in a Directory.
The directory in which it is saved ,it deletes the whole files and subdirectory in it .
Now i want that the user should not be able to save the file in My Computer,C,D Drives.
User can choose the directory through FolderBrowserDialog.
How can i restrict the user in doing so?
Can u plz help out?

A: The simplest way of doing it would be use the access rights in Windows NTFS file system.

A: Perhaps you mean that the user chooses the directory using the FolderBrowserDialog ? In any case, neither the FolderBrowserDialog nor the SaveFileDialog offer any in-built means of restricting the user selection.
Your most straightforward option therefore is to validate the user's selection and check if it is not one of directories you have chosen to restrict access to. You could also set code permissions and disallow permission for your code to save files into the restricted folders.


text:
Q: PieChart for ios-charts broken in Swift 2.0? So I upgraded my project, and pods, to work with Swift 2.0 and Xcode 7. But now my PieChart isn't working as expected anymore. My Pies are all starting from the 0 degree angle, which means that they are all beginning in the same place, above each other.
The data is added the same way as before and if I highlight them I can see that they are all there, but not originating from their respective places.
Code for adding my pieChartData:
var dataEntries: [ChartDataEntry] = []
var dataPoints: [String] = []

for var i = 0; i < expensesHistory.count; i++ {
    let dataEntry = ChartDataEntry(value: expensesHistory[i].amount, xIndex: i)
    dataEntries.append(dataEntry)
    dataPoints.append(expensesHistory[i].category.rawValue)
}

let pieChartDataSet = PieChartDataSet(yVals: dataEntries)
let pieChartData = PieChartData(xVals: dataPoints, dataSet: pieChartDataSet)
pieChartView.data = pieChartData
var colors = [UIColor]()
colors.append(Colors.blueColor())
pieChartDataSet.colors = colors
pieChartDataSet.drawValuesEnabled = false
pieChartDataSet.sliceSpace = 4.0

The data gets loaded and added correctly, into different entries (there are 7) but all 7 pies are starting in the same place...so they don't result in a circle at all. Any ideas?
UPDATE #1
I translated the ChartsDemo to Swift as best I could and I end up with the same issue, but further debugging tells me that I'm probably only getting the last Entry pushed into the DataSet. If I set PieChartDataSet.drawValuesEnabled = true and PieChartView.legend.enabled = true I only see 1 value in the legend and 1 value for the DataSet. But I checked and my xVals and yVals contain more than 1 value, but it only displays one, and randomly chosen which one as well. I tried to find a pattern in which entry it chooses, but it just picks one at random.
I have added functionality to my PieChartView which allows me to press a button to highlight the entry associated with it, so that's why I thought that all the pies are placed above each other, but now I'm thinking it might be that the PieChartView is only showing 1 value, since I only get 1 value in the legend displayed, and not all of them on top of one another.
Here is my translation code from the ChartsDemo to Swift, keep in mind that I use Swift 2.0 (which is where this issue first presented itself).
private func setPieChartData() {

    let mult = UInt32(100)
    let count = Int(4)

    let parties = [
    "Party A", "Party B", "Party C", "Party D", "Party E", "Party F",
    "Party G", "Party H", "Party I", "Party J", "Party K", "Party L",
    "Party M", "Party N", "Party O", "Party P", "Party Q", "Party R",
    "Party S", "Party T", "Party U", "Party V", "Party W", "Party X",
    "Party Y", "Party Z"
    ]

    var yVals1 = [ChartDataEntry]()

    // IMPORTANT: In a PieChart, no values (Entry) should have the same xIndex (even if from different DataSets), since no values can be drawn above each other.
    for var i = 0; i < count; i++
    {
        let chartDataEntry = ChartDataEntry(value: Double((arc4random_uniform(mult) + mult/5)), xIndex: i)
        yVals1.append(chartDataEntry)
    }

    var xVals = [String?]()

    for var i = 0; i < count; i++
    {
        xVals.append(parties[i % parties.count])
        //[xVals addObject:parties[i % parties.count]]
    }

    let dataSet = PieChartDataSet(yVals: yVals1, label: "Election Results")
    dataSet.sliceSpace = 3.0

    // add a lot of colors

    var testColors = [UIColor]()
    testColors.append(Colors.blueColor())
    let data = PieChartData(xVals: xVals, dataSet: dataSet)

    pieChartView.data = data

    dataSet.colors = testColors
    dataSet.drawValuesEnabled = true

    dataSet.sliceSpace = 4.0
}

Since this issue started when I updated to the Swift 2.0 compatible version of ios-charts I still think that this issue is connected to that update. I haven't touched this code in months prior to the update, and it works fine with the previous version. And as far as I can tell from a debugging point of view all my values are pushed correctly, but seems to not be handled correctly by the PieChartView.
UPDATE #2
Here is a sample project where I show you the issue I'm having. I did not include functionality for highlighting with buttons since it will take a bit more effort to get it working.
Link to sample project
How to:

*

*You need Xcode 7 to run this.

*You need CocoaPods installed.

*Once you have installed CocoaPods use the terminal to go to the project folder and type "pod install" in root to install the Charts framework.

*Use the ChartsIssue.xcworkspace to launch the project, NOT ChartsIssue.xcproj

A: I tried to simulate what your code do in ChartsDemo's pie chart view controller like below, but it does not have problem.
I looked at your code, it is also fine to me. I guess there might be something wrong with your data value, like class type? Anyway, based on current info, I cannot say what's wrong with it, but it seems like it's your project's problem.
There are two ways to move forward:
1.You double check the data value and try debug on your own, to figure out why;
2.Try to reproduce with ChartsDemo code, and post your data sample code, so I can reproduce it on my side; a screenshot is even better.
- (void)setDataCount:(int)count range:(double)range
{
    double mult = range;

    NSMutableArray *yVals1 = [[NSMutableArray alloc] init];

    // IMPORTANT: In a PieChart, no values (Entry) should have the same xIndex (even if from different DataSets), since no values can be drawn above each other.
    for (int i = 0; i < count; i++)
    {
        [yVals1 addObject:[[ChartDataEntry alloc] initWithValue:(arc4random_uniform(mult) + mult / 5) xIndex:i]];
    }

    NSMutableArray *xVals = [[NSMutableArray alloc] init];

    for (int i = 0; i < count; i++)
    {
        [xVals addObject:parties[i % parties.count]];
    }

    PieChartDataSet *dataSet = [[PieChartDataSet alloc] initWithYVals:yVals1 label:@"Election Results"];
    dataSet.sliceSpace = 3.0;

    // add a lot of colors

    NSMutableArray *colors = [[NSMutableArray alloc] init];
    [colors addObject:[UIColor blueColor]];

    PieChartData *data = [[PieChartData alloc] initWithXVals:xVals dataSet:dataSet];
    _chartView.data = data;

    dataSet.colors = colors;
    dataSet.drawValuesEnabled = NO;
    dataSet.sliceSpace = 4.0;
}

Update for question update 1&2:
I have download your demo project and manage to get it work on my side, I do see what you are saying, only one arc stripe while you should have 4 values;
I think you have hit an animation bug here or you mis-use it:
pieChartView.animate(xAxisDuration: 1.5, easingOption: ChartEasingOption.EaseOutBack)
pieChartView.animate(yAxisDuration: 1.5, easingOption: ChartEasingOption.EaseOutBack)

Simply comment one of them out and it will display correctly (not sure if the animation is fine), comment both will display correctly without animation too.
If you want animate both x and y axis, use below func also give you correct chart and animation:
pieChartView.animate(xAxisDuration: 1.5, yAxisDuration: 1.5, easingOption: ChartEasingOption.EaseOutBack)

I will post an issue to ask if using separate methods simultaneously is valid or not.


text:
Q: How to Preventing Host Header Attack in Ubuntu Server 14.04 If we send a request from any host like example.com our server gives back a HTTP 1.1 200 OK response status.
In correct condition it should show either 302, 400 or 404 error message (not found response) status. At current condition it is showing 200 OK response message, when its send through our host like xx.xxx.xx.xx.
For example, if we sent this request:

GET /web/ HTTP/1.1 Host: example.com User-Agent: Mozilla/5.0 (Windows
  NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0 Accept:
  text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
  Accept-Language: en-US,en;q=0.5 Connection: close
  Upgrade-Insecure-Requests: 1

We get this response:

HTTP/1.1 200 OK Date: Thu, 02 Mar 2017 15:23:20 GMT Server:
  figi_Server X-Frame-Options: deny Strict-Transport-Security: 1 Vary:
  Accept-Encoding X-Content-Type-Options: nosniff X-Frame-Options:
  sameorigin X-XSS-Protection: 1; mode=block

Using
OS: Ubuntu 14.04.
Web server: Apache 2.2.
Virtual machine running both.

Please go through Screen Shot Of Issue for better Understanding of Issue:


text:
Q: the faithful normal conditional expectation is uniquely determined

I was puzzled by the proof of $(i)\rightarrow (ii)$.
How to check that $E:M\rightarrow N$ is uniquely determined by the condition $\varphi\circ E=\varphi$?
To my mind, we need to verify the following statement: If $E':M\rightarrow N$ is another conditional expectation such that $\varphi\circ E'=\varphi$, then $E= E'$.
But how to conclude the above conclusion according to the equality $\varphi(E(bx^*b))=\varphi(bx^*b)$?

A: The equality in 10.3, which is longer than what you wrote, says that
$$
\langle \pi_\psi(E'(x))b_\psi,b_\psi\rangle=\langle \pi_\psi(E(x))b_\psi,b_\psi\rangle
$$
for all $b$, and hence $\pi_\psi(E'(x))=\pi_\psi(E(x))$; as $\pi_\psi$ is faithful, $E'(x)=E(x)$.


text:
Q: Error while creating a table in mysql cluster I'm trying to create a table in MySQL Cluster . but getting a error while executing below query.
CREATE TABLE `tbl_anal_results` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tbl_bill_bill_id` int(10) unsigned NOT NULL,
  `item` varchar(256) NOT NULL,
  `bill_value` decimal(10,2) NOT NULL,
  `calc_value` decimal(10,2) NOT NULL,
  `err` tinyint(1) NOT NULL,
  `error_code` varchar(256) DEFAULT NULL,
  `tbl_bill_info_id` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_tbl_anal_results_tbl_bill1_idx` (`tbl_bill_bill_id`),
  CONSTRAINT `fk_tbl_anal_results_tbl_bill1` FOREIGN KEY (`tbl_bill_bill_id`) REFERENCES `tbl_bill` (`bill_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=ndbcluster AUTO_INCREMENT=16570225 DEFAULT CHARSET=latin1;

ERROR 1215 (HY000): Cannot add foreign key constraint

I have used same query which I used to create same table in old mysql setup.
and I have changed ENGINE as ENGINE=ndbcluster instead of ENGINE=InnoDB
also noticed UPDATE CASCADE not working in mysql cluster.

A: Cut from docs:
ON UPDATE CASCADE is not supported when the reference is to the parent table's primary key.
This is because an update of a primary key is implemented as a delete of the old row (containing the old primary key) plus an insert of the new row (with a new primary key). This is not visible to the NDB kernel, which views these two rows as being the same, and thus has no way of knowing that this update should be cascaded.


text:
Q: PDFKit rendering all the pages to pdf in rails 3 app after user successfully generates 1 page in pdf I want to generate some pages in pdf and so I started with PDFKit gem.
Everything works fine, however, when the user downloads a page in pdf, after that point on any link that the user clicks is getting downloaded to pdf!!.  I wish to have the pdf generation turned on only one page.
My configurations are:
application.html.erb
 <%= stylesheet_link_tag "application", :media => 'all'%>

application.rb
config.middleware.use  "PDFKit::Middleware", :print_media_type => true

show.html.erb
<%= link_to "PDF", medicalhistory_path(medicalhistory, :format => "pdf")%>

A: rolled back to 0.4.6
https://github.com/jdpace/PDFKit/issues/66

A: I was also getting the same problem with pdfkit gem version 0.5.0, if I remove the config.middleware.use PDFKit::Middleware it is working fine.


text:
Q: How to mongo aggregate with lookup and geoIntersects I want to lookup which users are in a specific area, so, if i have these objects on users collection:
{
    "_id" : ObjectId("6197a78308591026b742cbc7"),
    "longitude" : -8.88180350512795,
    "latitude" : 38.5628716186268
}

/* 2 */
{
    "_id" : ObjectId("6199798916317b0c2dcab874"),
    "longitude" : -9.15904389999993,
    "latitude" : 38.7235087
}

/* 3 */
{
    "_id" : ObjectId("6199798916317b0c2dcab874"),
    "longitude" : -8.6923178,
    "latitude" : 41.1846394
}

And i have other collection deliveryareas with this object:
{
   "_id" : ObjectId("6197ebf6fdbd8f6b06c97c57"),
    "area" : {
        "type" : "Polygon",
        "coordinates" : [
            [
                [
                    -9.0556241,
                    38.4989521
                ],
                [
                    -9.0551516,
                    38.4964531
                ],
                [
                    -9.0522346,
                    38.4950589
                ],
                [
                    -9.0526648,
                    38.4940872
                ]
            ]
        ],
        "_id" : ObjectId("6197ebf6fdbd8f6b06c97c58")
    }
}

Making this query:
db.getCollection('users').aggregate([
{
    $lookup: {
        from: 'deliveryareas',
        let: { longitude: '$longitude', latitude: '$latitude' },
        pipeline: [
            { $match: {
                area: {
                    $geoIntersects: {
                        $geometry: {
                            type: 'Point',
                            coordinates: [ '$$longitude', '$$latitude' ],
                        },
                    },
                }
            } },
        ],
        as: 'inRegion',
    },
},
])

if i run the query directly in the deliveryareas collection it works, but over the pipeline on lookup don't work and it's giving the error "Point must only contain numeric elements", can anyone tell me why?

A: Just one more thing, if i run first this:
db.getCollection('users').aggregate([
{ $unwind: '$addresses' },
{ $project: { coordinates: [ '$addresses.region.longitude', '$addresses.region.latitude' ] } },
])

I have this results:
/* 1 */
{
    "_id" : ObjectId("6197a78308591026b742cbc7"),
    "coordinates" : [
        -8.88180350512795,
        38.5628716186268
    ]
}

/* 2 */
{
    "_id" : ObjectId("6199798916317b0c2dcab874"),
    "coordinates" : [
        -9.15904389999993,
        38.7235087
    ]
}

/* 3 */
{
    "_id" : ObjectId("6199798916317b0c2dcab874"),
    "coordinates" : [
        -8.6923178,
        41.1846394
    ]
}

Then if i add the lookup:
db.getCollection('users').aggregate([
{ $unwind: '$addresses' },
{ $project: { coordinates: [ '$addresses.region.longitude', '$addresses.region.latitude' ] } },
{
    $lookup: {
        from: 'deliveryareas',
        let: { userCoordinates: '$coordinates' },
        pipeline: [
            { $match: {
                area: {
                    $geoIntersects: {
                        $geometry: {
                            type: 'Point',
                            coordinates: '$$userCoordinates',
                        },
                    },
                }
            } },
        ],
        as: 'inRegion',
    },
},
])

i have the error: Point must be an array or object
but if i replace the variable $$userCoordinates by a fixed value, for example [ -8.88180350512795, 38.5628716186268 ] (that i have on the users) the query run with success.


text:
Q: nodejs conversion from buffer data to byte array I want to convert buffer data to byte array. Here's what I've tried
import * as fs from 'fs';
[...]
event:(data) => {
   fs.readFile(data, function(err, data) {
      var arrByte= new Uint8Array(data)
      var binaryData= new Blob([arrByte])
      console.log(binaryData)
   }
 }

I'm yet to have this work hence my post. I'd very much like to know what I'm doing that's not right.

A:   import * as fs from 'fs';
  [...]
  event:(data) => {
    fs.readFile(data, function(err, data) {
      var arrByte= new Uint8Array.from(Buffer.from(data))
      var binaryData= new Blob([arrByte])
      if (err) throw err;
      console.log(binaryData)
    }
 }

A: The Buffer docs are very enlightening:

Prior to the introduction of TypedArray, the JavaScript language had no mechanism for reading or manipulating streams of binary data. The Buffer class was introduced as part of the Node.js API to enable interaction with octet streams in TCP streams, file system operations, and other contexts.
With TypedArray now available, the Buffer class implements the Uint8Array API in a manner that is more optimized and suitable for Node.js.
…
Buffer instances are also Uint8Array instances. However, there are subtle incompatibilities with TypedArray. For example, while ArrayBuffer#slice() creates a copy of the slice, the implementation of Buffer#slice() creates a view over the existing Buffer without copying, making Buffer#slice() far more efficient.
It is also possible to create new TypedArray instances from a Buffer with the following caveats:

*

*The Buffer object's memory is copied to the TypedArray, not shared.

*The Buffer object's memory is interpreted as an array of distinct elements, and not as a byte array of the target type. That is, new Uint32Array(Buffer.from([1, 2, 3, 4])) creates a 4-element Uint32Array with elements [1, 2, 3, 4], not a Uint32Array with a single element [0x1020304] or [0x4030201].

They go on to mention TypedArray.from, which in node accepts Buffers, so the 'correct' way is:
var arrByte = Uint8Array.from(data)

...however, this shouldn't be necessary at all since a Buffer is a Uint8Array and new UintArray(someBuffer) does work just fine.
There's also no context in your question, but Blob doesn't exist in node, and you shouldn't need it anyway, since Buffer already gives you raw access to binary data and the other fs methods let you read and write files.


text:
Q: Flexbox justify-content not working properly with transform scale I have a regular unordered list of items with display: flex and justify-content: space-between applied to it (as a result, .first_item touches the left edge of .list and .last_item touches the right edge of .list):

Item

Item

Item

However, if I shrink the items using transform: scale(0.5), there is now a space at these two locations, as if justify-content: space-between was "unaware" that the items have been reduced.
This isn't right: even when shrinking the items, the first and last item should still touch the left and right edges of the container.
What's going on and how to fix that problem?

A: Once you scale down the element with the transform, it is automatically centered within its box.
This is because the initial value of the transform-origin property is 50%, 50% (i.e., centered horizontally and vertically).
As a result, the items are offset from the edges of the container.

.list {
  display: flex;
  justify-content: space-between;
  border: 1px dashed black;
  padding: 0;
  list-style: none;
}

li {
  transform: scale(0.5);
  border: 1px solid red;
}

Item

Item

Item

You can adjust the position of the transformed element with left and right on transform-origin.

.list {
  display: flex;
  justify-content: space-between;
  border: 1px dashed black;
  padding: 0;
  list-style: none;
}

.first_item {
  transform: scale(0.5);
  transform-origin: left;
}

.last_item {
  transform: scale(0.5);
  transform-origin: right;
}

li {
  transform: scale(0.5);
  border: 1px solid red;
}

Item

Item

Item

More details in the spec: https://drafts.csswg.org/css-transforms/#transform-origin-property


text:
Q: I want to make a query based on the current logged in user id in Angular using firebase as my back-end I've created a bookmarking feature which if the users clicks at the bookmark button the user's id will be save to that documents bookmark array in firebase which is working fine.
But i want to show all bookmarks by a user in the bookmark page/tab (it's a news site btw the documents have title, picture, article, bookmarks and so on kind of data).
I've got it to work manually
bookmarks$: Observable<lajmiId[]>;
bookmarksBehaviorSubject : BehaviorSubject<string|null>;

constructor(
    private afs: AngularFirestore,
    public authService: AuthService,
    private ls: LoginService) {

this.bookmarksBehaviorSubject = new BehaviorSubject(null);
    this.bookmarks$ = this.bookmarksBehaviorSubject.pipe(
      switchMap(string => this.afs.collection<lajmiId>('lajmet', ref =>
        ref.where('bookmarks', 'array-contains', 'manually_written_uid')).valueChanges())
    );
}

Which works however when i try to pas in the uid dynamically based on the current logged in user it's not working,
var uid = this.authService.userData.uid;

this.bookmarksBehaviorSubject = new BehaviorSubject(null);
    this.bookmarks$ = this.bookmarksBehaviorSubject.pipe(
      switchMap(string => this.afs.collection<lajmiId>('lajmet', ref =>
        ref.where('bookmarks', 'array-contains', uid)).valueChanges())
    );

This gives me an error of undefined since it's trying to read the uid before the data is ready to be used since the data is asynchronous.
I've tried putting the code in the ngOnInit() block same result.
I've tried creating an observable with the uid data still same result.
i just can't seem to figure this out.
My authServise looks something like this:
import { User } from '../core/user';

export class AuthService {
    userData: Observable<any>;

    constructor(
    public afs: AngularFirestore,   // Inject Firestore service
    public afAuth: AngularFireAuth, // Inject Firebase auth service
    public router: Router,
    public ngZone: NgZone, //ngZone service to move outside scope warning
    private dialogRef: MatDialog
    ) {
       this.afAuth.authState.subscribe(user => {
            if (user) {
                this.userData = user;
                localStorage.setItem('user', JSON.stringify(this.userData));
                JSON.parse(localStorage.getItem('user'));
            }
        })
    }
}

My User.ts contains the User interfase.
Any help is much appreciated.

A: In your auth service you need to make the user as an Observable and then you can easily subsribe it on ngOnInit.
Suppose your auth.service.ts
export class AuthService{
   user$:Observable<any>;
 constructor(private router: Router,
          private afAuth: AngularFireAuth,
          private db:AngularFirestore,
          ) {
            this.user$ = this.afAuth.authState.pipe(
              switchMap(user => {
                if (user) {
//here you get the logged in user cred like uid
//you can use uid to refer in your collection
                  return this.afs.collection<lajmiId>(`lajmet/${user.uid}`).valueChanges()
                } else {
                  return of(null)
                }
              })
            )
          }
}

This will always give you the current logged in user and then you can easily subscribe after importing your authservice in the component you are trying to fetch.
this.authService.user$.take(1).subscribe(data=>{
//data of the user logged in
})


text:
Q: Automatically close dropdown when a new dropdown is selected/opened (React) I have a dropdown component and I'd like to be able to automatically close the previous dropdown when you click on a different dropdown menu item. I have the dropdown component working but I can't get them to close after selecting a new item. Additionally I'd like to close the items if you click anywhere on the page. Any help would be greatly appreciated, thanks in advance!
export const Dropdown: FC<Props> = ({ passedBindings }) => {
  let [isDropdownOpen, setDropdownOpen] = useState(false);
  const [ firstMediaBindings, ...restMediaBindings ] = bindings.mediaFlagBindings||[{}];

  const toggleDropdown = () => {
    setDropdownOpen(!isDropdownOpen)
  };

  return (
    <div { ...optionalAttributes }>
        <Container>
          {
            firstMoleculeMediaFlag()
          }
          {isDropdownOpen && restMediaBindings.length > 0 &&
            <Container passedBindings={({
              padding: {
                direction: "all",
                size: "size2"
              }
            })}>
              {
                restMediaBindings.map((mediaFlagBindings: IMoleculeMediaFlag, index: number) => {
                  return (
                    <Container
                      key={index}
                      passedBindings={({
                        padding: {
                          direction: "all",
                          size: "size1"
                        }
                    })}>
                      <MediaFlag key={index} passedBindings={mediaFlagBindings} />
                    </Container>
                  )
                })
              }
            </Container>
          }
        </Container>

      </Container>
    </div>
  )

``

A: You need a backdrop DIV to allow click and exit anywhere on the page.
It's like a 3-layer system.

*

*1st : your page content

*2nd : the backdrop goes on top

*3rd : your dropdown goes on top of the backdrop

An example (using styled-components for style, but you can style as you wish):
Backdrop.js
This renders a div on top of your page content.
const Backdrop = styled.div`
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.2);
  z-index: 100;
`;

Use it like that: conditionally with isDropdownOpen
Dropdown.js
But remember to style your dropdown with a z-index with something higher than the z-index you used on the backdrop. In this example, I used 100 for the backdrop so you can use 200.
export const Dropdown() {
  ...
  return(
    isDropdownOpen ?
      <Backdrop onClick={toggleDropdown}/>
      // Here goes the rest of your return for your dropdown
  );
}

If you need one dropdown to close the previous when they are clicked you need something in your state that tells you which one is opened.
Something like:
const [indexDropdownOpened, setIndexDropdownOpened] = useState(false);
You can set it to false (initial value) when no dropdown is opened, and you can set it with an index (or key) to tell your component which one is openend.
On each dropdown, when you render them:
...
return(
  <Container
    key={index}
    onClick={()=>setIndexDropdownOpened(index)}
  />
);

Then, on the backdrop, you could do:
<Backdrop onClick={()=>setIndexDropdownOpnened(false)}/> // So it closes the dropdown


text:
Q: How to animate background image with jQuery Hi I'm trying to animate a background image using jQuery, I tried following this tutorial here, however I've had no luck with my test page, I see the blue Facebook icon, but on mouse over it does not animate upwards to reveal the gray logo. Please help! Thanks, I'm a jQuery noob.
My test page:
http://leongaban.com/_stack/bg_animation/
The Facebook icon should animation upwards, the full image below:

My CSS

HTML

Javascript

UPDATE: WORKING CSS 3 Solution
CSS 3
#facebook_icon li {
        padding: 0;
        width: 120px;
        height: 119px;
        list-style: none;
        background: red;
        background:url('img/fb_120x238.png') repeat 0 0;

        -moz-transition: background-position 1s;
        -webkit-transition: background-position 1s;
        -o-transition: background-position 1s;
        transition: background-position 1s;
        background-position: 0 0;
    }

    #facebook_icon li:hover{
        background-position: 0 -119px;
    }

    .box {
        width: 120px;
        height: 119px;
    }

HTML (Added empty div box to have something to click on)

A: A simple solution should be using the css3 transition.
You can do something like this:
In Your CSS
#facebook_icon li{
    -moz-transition: background-position 1s;
    -webkit-transition: background-position 1s;
    -o-transition: background-position 1s;
    transition: background-position 1s;
    background-position: 0 0;
}

#facebook_icon li:hover{
     background-position: 0 -119px;
}

A: This one is thankfully pretty simple. You are animating background-position on the anchor, but the actual image is on the li.
Just change your selector in your JavaScript:
 $('#facebook_icon li')

However, I'd recommend changing your markup (and accompanying CSS) so the a is inside the li instead of a child of the ul. That way your markup is valid.
Update:
Hey, so I totally agree with using CSS3. Its exactly how I would implement that. But just to close out the question: To get the bgpos plugin working with jQuery 1.8.2, change the first two lines of the backgroundPosition method to this:
 if (fx.start === 0 && typeof fx.end == 'string') {
    var start = $.css(fx.elem,'backgroundPosition');


text:
Q: How can I configure XCode to generate warnings for methods without prototypes? I'd like Xcode to warn me if I define a method but don't declare it in the class's @interface  block.  Is this possible?
Thanks.

A: Useful request, but I don't believe there's a way with the current version of gcc. I would open a radar (bugreporter.apple.com) if no one else has a solution. Note that what is needed is slightly more complicated than how you asked it. What you generally really want is a warning if a method implementation does not match any applicable prototype. That would include your @interface of course, but also your formal protocols, superclass @interfaces, and applicable categories (including all superclass categories, particularly NSObject). Even so, the warning would be useful in many cases, especially when you misspell the signature for an informal protocol such as for NSWindow.
For reference, the documentation most useful for this is the ObjC/ObjC++ option page for gcc. Xcode doesn't generate warnings itself.


text:
Q: Word String matching i have a dataframe with two columns which are names of people. Generate the table with code below :
names.1=c('Ron ven goh','Phil Mick' , 'Rohan Aggarwal','John Deo Lin')
names.2=c('Rob ven goh','kitty Mol','Tejas Aggarwal','Jorge Mol Lin')
df=data.table(names.1,names.2)

My task is to add another variable which is binary ( Yes , No ) - if any word in the whole character string in column 1 matches any word in whole string of column 2 then "Yes" , else "No" - As long as a match is found it can give a yes.
i have this code below :
for(i in 1:nrow(df)){
  var_customername <- strsplit(as.character(df$names.1[i]),"\\s+")
  var_relationshipname <- strsplit(as.character(df$names.2[i]),"\\s+")
  df$NAMEMATCH[i] <- ifelse(any(unlist(var_customername) %in% unlist(var_relationshipname)),'YES','NO')
  rm(var_customername,var_relationshipname)
}

My overall data frame is 7 million rows and hence it by my calculations will take 405 hours due to the if any loop - any suggestions on how this can be made faster or optimized ?

A: I have shown a faster approach here using 'apply':
Your Approach:
> start.time <- Sys.time()
> for(i in 1:nrow(df)){
+   var_customername <- strsplit(as.character(df$names.1[i]),"\\s+")
+   var_relationshipname <- strsplit(as.character(df$names.2[i]),"\\s+")

+   df$NAMEMATCH[i] <- ifelse(any(unlist(var_customername) %in%
unlist(var_relationshipname)),'YES','NO')
+   rm(var_customername,var_relationshipname)
+ }
> end.time <- Sys.time()
> time.taken <- end.time - start.time
> time.taken
Time difference of 0.03119993 secs

My Approach:
> start.time <- Sys.time()
> apply(df, 1, function(x)
ifelse(any(unlist(strsplit(as.character(x[1]),"\\s+")) %in%
unlist(strsplit(as.character(x[2]),"\\s+"))),'YES','NO'))
[1] "YES" "NO"  "YES" "YES"
> end.time <- Sys.time()
> time.taken <- end.time - start.time
> time.taken
Time difference of 0 secs


text:
Q: split a dataframe into equal parts and store the results I'm relatively new to R.
I have a large dataframe which I would like to split into multiple dataframes around different values.
structure(list(country = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), .Label = c("Bangladesh", "Barbados", "Benin", "Burundi",
"Cameroon", "Chile", "Cyprus", "Ecuador", "Equatorial Guinea",
"Gabon", "Ghana", "Guatemala", "Guinea", "Guyana", "Haiti", "India",
"Jordan", "Lebanon", "Liberia", "Madagascar", "Mali", "Mexico",
"Morocco", "Mozambique", "Nepal", "Nicaragua", "Niger", "Oman",
"Pakistan", "Panama", "Peru", "Rwanda", "Senegal", "Seychelles",
"Sierra Leone", "Singapore", "Sri Lanka", "Sudan", "Togo", "Tunisia",
"Turkey", "Uganda", "Zambia"), class = c("pseries", "factor")),
    date = structure(12:36, .Label = c("1965", "1966", "1967",
    "1968", "1969", "1970", "1971", "1972", "1973", "1974", "1975",
    "1976", "1977", "1978", "1979", "1980", "1981", "1982", "1983",
    "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991",
    "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999",
    "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007",
    "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015",
    "2016", "2017", "2018"), class = c("pseries", "factor")),
    oda_gdp = c(0.15080885502447, 0.1744123099839, 0.199176897551553,
    0.193616875061556, 0.186942991013889, 0.164744452026834,
    0.192609744294439, 0.13752013069625, 0.156186721262664, 0.137192335225767,
    0.131167382827501, 0.139945790928319, 0.112553104508006,
    0.1172188903714, 0.120991133274215, 0.0940867931618562, 0.0857724612850372,
    0.0653099752359248, 0.0714189688493898, 0.0470115150264598,
    0.0446068588203229, 0.0414522297087586, 0.0450866627292532,
    0.0435203084091358, 0.0404623996092304), entry = c(0, 0,
    1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0)), row.names = c(NA, 25L), class = "data.frame")

I would like to split this into multiple dataframes around the points where entry==1. More concretely, I would like each new dataframe to contain 2 rows before entry==1 and 7 rows after entry==1.
Output should look like this
df1=structure(list(country = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L), .Label = c("Bangladesh", "Barbados", "Benin",
"Burundi", "Cameroon", "Chile", "Cyprus", "Ecuador", "Equatorial Guinea",
"Gabon", "Ghana", "Guatemala", "Guinea", "Guyana", "Haiti", "India",
"Jordan", "Lebanon", "Liberia", "Madagascar", "Mali", "Mexico",
"Morocco", "Mozambique", "Nepal", "Nicaragua", "Niger", "Oman",
"Pakistan", "Panama", "Peru", "Rwanda", "Senegal", "Seychelles",
"Sierra Leone", "Singapore", "Sri Lanka", "Sudan", "Togo", "Tunisia",
"Turkey", "Uganda", "Zambia"), class = c("pseries", "factor")),
    date = structure(12:21, .Label = c("1965", "1966", "1967",
    "1968", "1969", "1970", "1971", "1972", "1973", "1974", "1975",
    "1976", "1977", "1978", "1979", "1980", "1981", "1982", "1983",
    "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991",
    "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999",
    "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007",
    "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015",
    "2016", "2017", "2018"), class = c("pseries", "factor")),
    oda_gdp = c(0.15080885502447, 0.1744123099839, 0.199176897551553,
    0.193616875061556, 0.186942991013889, 0.164744452026834,
    0.192609744294439, 0.13752013069625, 0.156186721262664, 0.137192335225767
    ), entry = c(0, 0, 1, 0, 0, 0, 1, 0, 0, 0)), row.names = c(NA,
10L), class = "data.frame")

For the first case where entry=1
df2=structure(list(country = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L), .Label = c("Bangladesh", "Barbados", "Benin",
"Burundi", "Cameroon", "Chile", "Cyprus", "Ecuador", "Equatorial Guinea",
"Gabon", "Ghana", "Guatemala", "Guinea", "Guyana", "Haiti", "India",
"Jordan", "Lebanon", "Liberia", "Madagascar", "Mali", "Mexico",
"Morocco", "Mozambique", "Nepal", "Nicaragua", "Niger", "Oman",
"Pakistan", "Panama", "Peru", "Rwanda", "Senegal", "Seychelles",
"Sierra Leone", "Singapore", "Sri Lanka", "Sudan", "Togo", "Tunisia",
"Turkey", "Uganda", "Zambia"), class = c("pseries", "factor")),
    date = structure(16:25, .Label = c("1965", "1966", "1967",
    "1968", "1969", "1970", "1971", "1972", "1973", "1974", "1975",
    "1976", "1977", "1978", "1979", "1980", "1981", "1982", "1983",
    "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991",
    "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999",
    "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007",
    "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015",
    "2016", "2017", "2018"), class = c("pseries", "factor")),
    oda_gdp = c(0.186942991013889, 0.164744452026834, 0.192609744294439,
    0.13752013069625, 0.156186721262664, 0.137192335225767, 0.131167382827501,
    0.139945790928319, 0.112553104508006, 0.1172188903714), entry = c(0,
    0, 1, 0, 0, 0, 0, 0, 0, 0)), row.names = 5:14, class = "data.frame")

For the second case where entry=1
I'm guessing split might be the way to go, but I can't figure out a way to include the conditions.
Notice that all newly created dataframes should be the same size.
Any help is much appreciated!

A: I don't think split is the right tool here. Instead, you can do:
lapply(which(df$entry == 1), function(i) df[(i-2):(i+7),])
#> [[1]]
#>       country date   oda_gdp entry
#> 1  Bangladesh 1976 0.1508089     0
#> 2  Bangladesh 1977 0.1744123     0
#> 3  Bangladesh 1978 0.1991769     1
#> 4  Bangladesh 1979 0.1936169     0
#> 5  Bangladesh 1980 0.1869430     0
#> 6  Bangladesh 1981 0.1647445     0
#> 7  Bangladesh 1982 0.1926097     1
#> 8  Bangladesh 1983 0.1375201     0
#> 9  Bangladesh 1984 0.1561867     0
#> 10 Bangladesh 1985 0.1371923     0
#>
#> [[2]]
#>       country date   oda_gdp entry
#> 5  Bangladesh 1980 0.1869430     0
#> 6  Bangladesh 1981 0.1647445     0
#> 7  Bangladesh 1982 0.1926097     1
#> 8  Bangladesh 1983 0.1375201     0
#> 9  Bangladesh 1984 0.1561867     0
#> 10 Bangladesh 1985 0.1371923     0
#> 11 Bangladesh 1986 0.1311674     0
#> 12 Bangladesh 1987 0.1399458     0
#> 13 Bangladesh 1988 0.1125531     0
#> 14 Bangladesh 1989 0.1172189     0
#>
#> [[3]]
#>       country date    oda_gdp entry
#> 13 Bangladesh 1988 0.11255310     0
#> 14 Bangladesh 1989 0.11721889     0
#> 15 Bangladesh 1990 0.12099113     1
#> 16 Bangladesh 1991 0.09408679     0
#> 17 Bangladesh 1992 0.08577246     0
#> 18 Bangladesh 1993 0.06530998     0
#> 19 Bangladesh 1994 0.07141897     0
#> 20 Bangladesh 1995 0.04701152     0
#> 21 Bangladesh 1996 0.04460686     0
#> 22 Bangladesh 1997 0.04145223     0

Created on 2022-02-08 by the reprex package (v2.0.1)


text:
Q: Custom keys in Crashlytics seems to be lost between activities I wanted to add custom keys in Crashlytics reports so I done something like this:
Activity 1:
Crashlytics.start(this);

Activity 2:
Crashlytics.setString(Constants.MY_KEY, "my value");

...
    Crashlytics.setString(Constants.MY_KEY, "my overwritten value");
Activity 3:
Crashlytics.getInstance().crash();

The problem is that there is no MY_KEY displayed in the crash info. ONLY if I set it in Activity 1 but is not getting overwritten on Activity 2.
Is there any workaround to make this work ?

A: I don't see anything wrong with this approach. Just make sure your custom key in Activity 2 is read before crash happens. You can put a break point or log it to make sure the setString method is called.


text:
Q: JSON body response find index for value Given this JSON response:
[{"brukergruppeSperret":false,"virksomhetsnavn":"HELFO","brukerGruppe":"Brukerstøtte"},{"brukergruppeSperret":false,"virksomhetsnavn":"Klubbgaten Legesenter","brukerGruppe":"Lege"},{"brukergruppeSperret":false,"virksomhetsnavn":"Sjøsiden Legesenter","brukerGruppe":"Lege"},{"brukergruppeSperret":false,"virksomhetsnavn":"Athene legekontor Helsedirektoratet","brukerGruppe":"Lege"},{"brukergruppeSperret":false,"virksomhetsnavn":"Xeon Legekontor","brukerGruppe":"Lege"},{"brukergruppeSperret":false,"virksomhetsnavn":"Østmarka legekontor","brukerGruppe":"Lege"},{"brukergruppeSperret":false,"virksomhetsnavn":"Hultemyra shamansamling","brukerGruppe":"Lege"},{"brukergruppeSperret":false,"virksomhetsnavn":"AMIS Testsenter","brukerGruppe":"Lege"},{"brukergruppeSperret":false,"virksomhetsnavn":"GLØSHAUGEN LEGESENTER DA","brukerGruppe":"Lege"},{"brukergruppeSperret":false,"virksomhetsnavn":"Helse Møre og Romsdal HF","brukerGruppe":"Lege"},{"brukergruppeSperret":false,"virksomhetsnavn":"St. Olavs hospital HF","brukerGruppe":"Saksbehandler"},{"brukergruppeSperret":false,"virksomhetsnavn":"HELSEDIREKTORATET","brukerGruppe":"Saksbehandler"},{"brukergruppeSperret":false,"virksomhetsnavn":"Østmarka legekontor","brukerGruppe":"Saksbehandler"}]

I want to obtain the first index in the JSON response that has the value "Lege" as "brukerGruppe".
In the above example this corresponds to index 6.
How can I in session in Gatling do a check that implements this?
I guess the function "find" could be used somewhat like this:
.check(jsonPath("$.brukerGruppe").find("Lege").indexvalue ??

Thanks

A: JsonPath support condition and you can find like this:
jsonPath("$.[6][?(@.brukerGruppe=='Lege')]"

It's returned :
[
  {
    "brukergruppeSperret": false,
    "virksomhetsnavn": "Hultemyra shamansamling",
    "brukerGruppe": "Lege"
  }
]

You can also get all items where brukerGruppe equals Lege
$.[?(@.brukerGruppe=='Lege')]


text:
Q: How do I get rid of the UTA002/UTA005/UTA006 warnings for my generic base test class? I have a few test classes that do similar things, need similar initialization and cleanup and similar instance variables. Thus, I created a base class and defined the TestInitialize and TestCleanup attributes on them:
Public Class ImportTestBase(Of T As {ImportBase, New})
    ' ...Some instance variables and protected properties...

    <TestInitialize()>
    Public Sub Init()
        ' Connect to Test-DB, start a transaction, instantiate the import class T
    End Sub

    <TestCleanup()>
    Public Sub Cleanup()
        ' Rollback the transaction, do other cleanup stuff
    End Sub
End Class

This reduces boilerplate code in my actual test classes:
<TestClass()>
Public Class AddressImportTests
    Inherits ImportTestBase(Of MyAddresImportClass)

    <TestMethod()>
    Public Sub SomeTest()
        ' Test something here
    End Sub

    ' No boilerplate Init and Cleanup here. Yippie!
End Class

This works great! Unfortunately, the Visual Studio (2015) test runner outputs some ugly warnings:
UTA005: Illegal use of attributes on MyNamespace.ImportTestBase`1.Init.The TestInitializeAttribute can be defined only inside a class marked with the TestClass attribute.
UTA006: Illegal use of attributes on MyNamespace.ImportTestBase`1.Cleanup. The TestCleanupAttribute can be defined only inside a class marked with the TestClass attribute.

This bothers me, because I don't like to ignore warnings. Adding TestClass to the test base class does not help; on the contrary:
UTA002: TestClass attribute  cannot be defined on generic class MyNamespace.ImportTestBase`1.
UTA005: Illegal use of attributes on MyNamespace.ImportTestBase`1.Init.The TestInitializeAttribute can be defined only inside a class marked with the TestClass attribute.
UTA006: Illegal use of attributes on MyNamespace.ImportTestBase`1.Cleanup. The TestCleanupAttribute can be defined only inside a class marked with the TestClass attribute.

Any idea on how to get rid of them?

A: Make your base class abstract (C#) or MustInherit (VB).

A: Try using the vstest console instead.


text:
Q: Возможна ли в Unity в scrollbar прокрутка кнопкой? Возможна ли в Unity в scrollbar прокрутка кнопкой?
Создать кнопку и по нажатию она  будет немного прокручивать scrollbar?

A: Прокрутка кнопкой возможна, если использовать ScrollRect.horizontalNormalizedPosition или ScrollRect.verticalNormalizedPosition (в зависимости от того какой скролл горизонтальный или вертикальный). Внутри ScrollRect можно позиционировать содержимое через NormalizedPosition, который измеряется от 0.0f до 1.0f.
Вопрос тут будет заключаться только в том, как вы будет прикидывать размер содержимого. Например если у вас скролл в котором 10 одинаковых по размеру элементов, то каждый из них это 0.1f. Также если вас интересует просто небольшая прокрутка с помощью кнопок, то можете просто подобрать небольшой коэффициен на который будете перемещать содержимое.


text:
Q: Change of Variables for probability Let $X:(\Omega,\mathcal{F},P)\rightarrow(S,\mathcal{S})$
be a measurable map. Let $g:(S,\mathcal{S})\rightarrow(\mathbb{R},\mathcal{B}(\mathbb{R}))$
be a measurable real-valued function. Let $A\in\mathcal{F}$ (an event). I am trying to see how to properly represent the integral
$$\int_{A}g(X(\omega))\, dP(\omega)$$
as an integral over $S$ (Since $X$ maps from $A$ while $g$ maps from $S$. Of course, this is under the usual assumptions of these integrals (non-negativity or finite integral).Furthermore, how do you express the new transformed measure in terms of $P$,$A$ and$X$ exclusively?
thanks!

A: Hint: Let $\mu(B)=P(\{X\in B\}\cap A)$ for all $B\in \mathcal S$. Can you show that
$$\int_Ag(X(\omega))dP(\omega)=\int_Sg(y)\mu(dy)$$
using the three/four steps in the construction of the abstract integral?


text:
Q: JqGrid getGridParam dont work I working on a project where use a JqGrid plugin to list the results for users search, when I try get row data on a Grig like this sample
jQuery("#a1").click( function(){
    var id = jQuery("#list5").jqGrid('getGridParam','selrow');
    if (id) {
        var ret = jQuery("#list5").jqGrid('getRowData',id);
        alert("id="+ret.id+" invdate="+ret.invdate+"...");
    } else { alert("Please select row");}
});

got the  message "[object Object]". I try get the multiple parameters with getGridParam like rowNum , sortname and this method don't send any value. So I ask what the problem, probably miss load any jqGrid library. The list below represent library that I've included
  <script type="text/ecmascript"  src="<%= Url.Content("~/Scripts/jquery.jqGrid.js") %>" ></script>
    <script  src="<%= Url.Content("~/Scripts/js/jqModal.js") %>"  type="text/ecmascript"></script>
    <script  src="<%= Url.Content("~/Scripts/js/jqDnR.js") %>"  type="text/ecmascript"></script>

Thanks for help..
If anyone knows the solution to that issue please tell me.. I try several way to do this if I delete the row on my grid :
jQuery("#list").delRowta(id); - that is OK

but when try do this :
var selectedRow =  jQuery("#list").getGridParam('selrow'); //this work
var data =  jQuery("#list").getRowData(id);// this method doesn't work

I need the way to get data from row