text:
Q: row.names=NULL adds a column and shifts the rest When I read a txt file using
read.table("text.txt", row.names=NULL, fill=TRUE)

a new column named "row.names" is created that takes over the values for a pre-existing column. All the rest of the columns shift to the right.
Any idea what is going on?
I used row.names=NULL, because not adding it returned error that there are duplicate row names.
The data link: https://raw.githubusercontent.com/bcaffo/ds4bme/master/data/federalRegions.txt
UPDATE
So this is how my data looks after read.table above:

   row.names        Region     State
1          1   Connecticut
2          1         Maine
3          1 Massachusetts
4          1           New Hampshire
5          1         Rhode    Island
6          1       Vermont
7          2           New    Jersey
8          2           New      York
9          3      Delaware
10         3      Maryland
11         3  Pennsylvania
12         3      Virginia
13         3          West  Virginia
14         4       Alabama
15         4       Florida
16         4       Georgia
17         4      Kentucky
18         4   Mississippi
19         4         North  Carolina
20         4         South  Carolina
21         4     Tennessee
22         5      Illinois
23         5       Indiana
24         5      Michigan
25         5     Minnesota
26         5          Ohio
27         5     Wisconsin
28         6      Arkansas
29         6     Louisiana
30         6           New    Mexico
31         6      Oklahoma
32         6         Texas
33         7          Iowa
34         7        Kansas
35         7      Missouri
36         7      Nebraska
37         8      Colorado
38         8       Montana
39         8         North    Dakota
40         8         South    Dakota
41         8          Utah
42         8       Wyoming
43         9       Arizona
44         9    California
45         9        Hawaii
46         9        Nevada
47        10        Alaska
48        10         Idaho
49        10        Oregon
50        10    Washington

A new column "row.names" is created, overtaking "Region" values, and Region now has states as its values, and "State" now has second half of the names of the states that have two words.

A: This is a tab delimited file, but unfortunately the header row has a space instead of a tab. We can grab the file with readLines, change the space to a tab, and use read.delim to get it into a data frame:
url <- "https://raw.githubusercontent.com/bcaffo/ds4bme/master/data/federalRegions.txt"
text <- readLines(url)
text[1] <- gsub(" ", "\t", text[1])
df <- read.delim(text = text, header = TRUE, stringsAsFactors = FALSE)

df
#>    Region          State
#> 1       1    Connecticut
#> 2       1          Maine
#> 3       1  Massachusetts
#> 4       1  New Hampshire
#> 5       1   Rhode Island
#> 6       1        Vermont
#> 7       2     New Jersey
#> 8       2       New York
#> 9       3       Delaware
#> 10      3       Maryland
#> 11      3   Pennsylvania
#> 12      3       Virginia
#> 13      3  West Virginia
#> 14      4        Alabama
#> 15      4        Florida
#> 16      4        Georgia
#> 17      4       Kentucky
#> 18      4    Mississippi
#> 19      4 North Carolina
#> 20      4 South Carolina
#> 21      4      Tennessee
#> 22      5       Illinois
#> 23      5        Indiana
#> 24      5       Michigan
#> 25      5      Minnesota
#> 26      5           Ohio
#> 27      5      Wisconsin
#> 28      6       Arkansas
#> 29      6      Louisiana
#> 30      6     New Mexico
#> 31      6       Oklahoma
#> 32      6          Texas
#> 33      7           Iowa
#> 34      7         Kansas
#> 35      7       Missouri
#> 36      7       Nebraska
#> 37      8       Colorado
#> 38      8        Montana
#> 39      8   North Dakota
#> 40      8   South Dakota
#> 41      8           Utah
#> 42      8        Wyoming
#> 43      9        Arizona
#> 44      9     California
#> 45      9         Hawaii
#> 46      9         Nevada
#> 47     10         Alaska
#> 48     10          Idaho
#> 49     10         Oregon
#> 50     10     Washington

Created on 2020-02-20 by the reprex package (v0.3.0)

A: As @AllanCameron stated, you really have a tab-delimited file with an incorrect first row. An alternative is to continue using read.table but skipping the first row.
dat <- read.table("federalRegions.txt", sep="\t", skip=1)
head(dat)
#   V1            V2
# 1  1   Connecticut
# 2  1         Maine
# 3  1 Massachusetts
# 4  1 New Hampshire
# 5  1  Rhode Island
# 6  1       Vermont

You have to rename the columns, but that's not hard. You can do it manually/literally or somewhat programmatically (though this is subject to problems if there are mixed spaces/tabs).
# colnames(dat) <- c("Region", "State") # manually
colnames(dat) <- strsplit(readLines("federalRegions.txt", n=1), "\\s+")[[1]]
head(dat)
#   Region         State
# 1      1   Connecticut
# 2      1         Maine
# 3      1 Massachusetts
# 4      1 New Hampshire
# 5      1  Rhode Island
# 6      1       Vermont


text:
Q: Split single row xml path result into multiple rows I'm after a bit of guidance here. I have a table that has all the data I need all mixed together in a single column (attributes) like so:
Device Index     Attribute index     Attributes
      5               59              WS020121
      5               83              9C-B6-54-A0-41-40
      5               90              GROUP\darkwahm
      6               59              WS020122
      6               83              9D-B8-54-A0-50-40
      6               90              GROUP\darkperm

What I am trying to do is split out the data into multiple columns so it will display as:
   Device              Mac Address              User
   WS020121            9C-B6-54-A0-41-40        GROUP\darkwahm
   WS020122            9D-B8-54-A0-50-40        GROUP\darkperm

After some research I was advised to use the XML path to get these results so I created a query which is:
SELECT cast (av1.attributeValue as varchar(50)) + ','
   --cast( av1.attributeValue as varchar(50)) + ','
FROM [dbo].[DeviceAttributes] Av1
WHERE av1.AttributeIndex=59 or av1.AttributeIndex=83 or av1.AttributeIndex=90
FOR XML PATH ('')

This works in the sense of all my data is together but its in a single row all together like this:
WS022743,B0-5A-DA-B4-51-01;60-6D-C7-34-86-05,GROUP\darkwahm,WS022871,D0-27-  88-92-9B-8A,GROUP\securitypc,ABSE-PEARSOND,00-05-9A-3C-78-00;68-F7-28-92-0E-7A,GROUP\SlavinM

Just wondering how I need to tweak the query to get it split across multiple columns and rows like how I mentioned above.

A: So, according to your query, numbers: 59, 83 and  90 are constants for these rows, if yes, you can try this:
SELECT t1.Attributes as device,  t2.Attributes as  Mac_Address , t3.Attributes as "user"  from
(SELECT Device_Index, Attributes  FROM [dbo].[DeviceAttributes] WHERE Attribute_index= 59) t1
INNER JOIN
(SELECT Device_Index, Attributes  FROM [dbo].[DeviceAttributes] WHERE Attribute_index = 83) t2
ON t1.Device_Index = t2.Device_Index
INNER JOIN
(SELECT Device_Index, Attributes  FROM [dbo].[DeviceAttributes] WHERE Attribute_index = 90) t3
ON t1.Device_Index = t3.Device_Index

redpajama_set_name: RedPajamaStackExchange


text:
Q: CSS Gradient repeats I've just completed a Django tutorial where I built an ecommerce website, so I am pretty new to HTML and CSS, but I've done Python for quite some time now, so that isn't the problem. So I decided on the website to have a random background color. I could do that quite easily with some JavaScript (edit the CSS value), but that just looked horrible. So I decided to make a random backround with CSS gradient, because that actually looks cool and I want a random color style on my website. Here is the article: https://www.w3schools.com/css/css3_gradients.asp
I have a body tag after the panel in the top and in the end of the HTML file.
Here is my CSS:
body{
    background-image: linear-gradient(to top, rgba(255,0,0,0), rgba(255,0,0,1));
}

Here is an image of the website: https://i.stack.imgur.com/762Mb.png
For some reason it duplicates/repeates itself and I can't figure that out by myself. I have tried making a DIV and asign it the class: grad1 and copy it over from the body tag in the CSS file, but that just does the same thing.
Thanks in advance :)

A: You need to add background-repeat: no-repeat to stop the background from repeating.

body {
  background-image: linear-gradient(to top, rgba(255,0,0,0), rgba(255,0,0,1));
  background-repeat: no-repeat;
  height: 100vh; /* Added to display the gradient better */
}


text:
Q: How can I sort and map my SQL query in Ionic? I have a database running in the background, the aim of the whole thing should be that I have categories as buttons and that categories should be created under elements. I separated the whole thing in the database (i.e. in two tables), i.e. in categories and in the sub-elements. I get everything correctly selected but just don't know how to assign or build it. Does anyone have any ideas or examples to look at?
I've already tried Ionic's list system. Just like ion-record.


text:
Q: Problem reading a file with FileSystem Capacitor I want to download and read files, to achieve that I am using the Capacitor FileSystem plugin. At the time of downloading the files they are saved in the indexedDB, but when trying to read the file it says that it cannot find it even though the file does exist and I give it the correct path, any idea what could be the reason?
This is the code:
        Filesystem.writeFile({
          path:name,
          data:base64,
          directory:FilesystemDirectory.Data,
          encoding: FilesystemEncoding.UTF8,
          recursive:true
        }).then((resp:FileWriteResult)=>{
          Filesystem.readFile({
            path:resp.uri
          }).then(resp=>{
            console.log(resp);
          }).catch(err=>console.log(err));
        }).catch(err=>console.log(err));

This is the error:
Error: File does not exist.


text:
Q: Does PHP 5.2 still receive security patches? My server admin tells me PHP 5.2 has been EOLed and so receives no bug fixes. This is obviously the case. He also tells me that 5.2 receives no security patches, which suggests we should upgrade to 5.3 ASAP.
However, a programmer I respect tells me that while PHP 5.2 has been EOLed for bug fixes, it is still very much supported insofar as security exploits are concerned - at least till 2012.
I've searched stackoverflow and google high and low but have come up with no answers to this elementary question.
Anyone care to inform my ignorance?

A: This type of information is usually posted as news on the php.net site. This is what I found in PHP 5.3.6 Released! from 2011:

All PHP users should note that the PHP
  5.2 series is NOT supported anymore. All users are strongly encouraged to
  upgrade to PHP 5.3.6.

I also found this 2010 news: PHP 5.2.14 Released!

This release marks the end of the
  active support for PHP 5.2. Following
  this release the PHP 5.2 series will
  receive no further active bug
  maintenance. Security fixes for PHP
  5.2 might be published on a case by cases basis. All users of PHP 5.2 are
  encouraged to upgrade to PHP 5.3.

Maybe your programmer have a distribution with guaranteed support, such as an Ubuntu LTS release or paid Red Hat support?

A: From: http://www.php.net/archive/2010.php#id2010-07-22-1

This release marks the end of the
  active support for PHP 5.2. Following
  this release the PHP 5.2 series will
  receive no further active bug
  maintenance. Security fixes for PHP
  5.2 might be published on a case by cases basis.

Since then we've seen 3 more releases of 5.2 series focusing mostly on security patches. As far as I know there is no guarantee that such patches will be published until 2012.

A: on the PHP.net home page:

All PHP users should note that the PHP 5.2 series is NOT supported anymore. All users are strongly encouraged to upgrade to PHP 5.3.6.

I think that says everything you need to know.


text:
Q: Inconsistent situation after upgrade to 22.04 LTS from 20.04 LTS I just upgraded to Ubuntu 22.04 LTS from 20.04 LTS
The upgrade has not aborted and the differences with previous version are evident.
Yet, this is what I get
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS (fossa-cory-tgl X59)
Release:    20.04
Codename:   focal

I tried a  do-release-upgrade again and I get
Calculating the changes
No candidate ver:  crda
No candidate ver:  dell-eula
No candidate ver:  dell-linux-assistant
No candidate ver:  dike6
No candidate ver:  hddtemp
No candidate ver:  hibernate
No candidate ver:  ippusbxd
No candidate ver:  ksysguard-data
No candidate ver:  ksysguardd
No candidate ver:  libpython3.9-minimal
No candidate ver:  linux-image-5.10.0-1049-oem
No candidate ver:  linux-image-5.10.0-1050-oem
No candidate ver:  linux-image-5.10.0-1051-oem
No candidate ver:  linux-image-5.10.0-1052-oem
No candidate ver:  linux-image-5.10.0-1053-oem
No candidate ver:  linux-image-5.10.0-1055-oem
No candidate ver:  linux-image-5.10.0-1057-oem
No candidate ver:  linux-image-5.14.0-1024-oem
No candidate ver:  linux-image-5.14.0-1027-oem
No candidate ver:  linux-image-5.14.0-1029-oem
No candidate ver:  linux-image-5.14.0-1031-oem
No candidate ver:  linux-image-5.14.0-1032-oem
No candidate ver:  linux-image-5.14.0-1033-oem
No candidate ver:  linux-image-5.14.0-1034-oem
No candidate ver:  linux-image-5.14.0-1036-oem
No candidate ver:  linux-image-5.14.0-1038-oem
No candidate ver:  linux-image-5.14.0-1042-oem
No candidate ver:  linux-image-5.14.0-1044-oem
No candidate ver:  linux-image-5.14.0-1045-oem
No candidate ver:  linux-image-5.14.0-1046-oem
No candidate ver:  linux-image-5.14.0-1047-oem
No candidate ver:  linux-image-5.14.0-1050-oem
No candidate ver:  linux-image-5.6.0-1036-oem
No candidate ver:  linux-modules-5.10.0-1049-oem
No candidate ver:  linux-modules-5.10.0-1050-oem
No candidate ver:  linux-modules-5.10.0-1051-oem
No candidate ver:  linux-modules-5.10.0-1052-oem
No candidate ver:  linux-modules-5.10.0-1053-oem
No candidate ver:  linux-modules-5.10.0-1055-oem
No candidate ver:  linux-modules-5.10.0-1057-oem
No candidate ver:  linux-modules-5.14.0-1024-oem
No candidate ver:  linux-modules-5.14.0-1027-oem
No candidate ver:  linux-modules-5.14.0-1029-oem
No candidate ver:  linux-modules-5.14.0-1031-oem
No candidate ver:  linux-modules-5.14.0-1032-oem
No candidate ver:  linux-modules-5.14.0-1033-oem
No candidate ver:  linux-modules-5.14.0-1034-oem
No candidate ver:  linux-modules-5.14.0-1036-oem
No candidate ver:  linux-modules-5.14.0-1038-oem
No candidate ver:  linux-modules-5.14.0-1042-oem
No candidate ver:  linux-modules-5.14.0-1044-oem
No candidate ver:  linux-modules-5.14.0-1045-oem
No candidate ver:  linux-modules-5.14.0-1046-oem
No candidate ver:  linux-modules-5.14.0-1047-oem
No candidate ver:  linux-modules-5.14.0-1050-oem
No candidate ver:  linux-modules-5.6.0-1036-oem
No candidate ver:  php7.4-cgi
No candidate ver:  php7.4-cli
No candidate ver:  php7.4-common
No candidate ver:  php7.4-intl
No candidate ver:  php7.4-json
No candidate ver:  php7.4-opcache
No candidate ver:  php7.4-readline
No candidate ver:  php7.4-sqlite3
No candidate ver:  php7.4-xml
No candidate ver:  python3.9-minimal
No candidate ver:  slimbookbattery
No candidate ver:  user-manager
No candidate ver:  uswsusp

Restoring original system state

Aborting
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

Can someone please explain what might have happened and how to fix it ?

A: it was easier than I thought
I just uninstalled lsb_release
sudo apt remove lsb-release
sudo apt autoclean && sudo apt autoremove

and then installed it again
sudo apt install lsb-release

now 22.04 is correctly reported:
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:    22.04
Codename:   jammy


text:
Q: How important are lookup tables? A lot of the applications I write make use of lookup tables, since that was just the way I was taught (normalization and such). The problem is that the queries I make are often more complicated because of this. They often look like this
get all posts that are still open
"SELECT * FROM posts WHERE status_id = (SELECT id FROM statuses WHERE name = 'open')"

Often times, the lookup tables themselves are very short. For instance, there may only be 3 or so different statuses. In this case, would it be okay to search for a certain type by using a constant or so in the application? Something like
get all posts that are still open
"SELECT * FROM posts WHERE status_id = ".Status::OPEN

Or, what if instead of using a foreign id, I set it as an enum and queried off of that?
Thanks.

A: The answer depends a little if you are limited to freeware such as PostGreSQL (not fully SQL compliant), or if you are thinking about SQL (ie. SQL compliant) and large databases.
In SQL compliant, Open Architecture databases, where there are many apps using one database, and many users using different report tools (not just the apps) to access the data, standards, normalisation, and open architecture requirements are important.
Despite the people who attempt to change the definition of "normalisation", etc. to suit their ever-changing purpose, Normalisation (the science) has not changed.

*

*if you have data values such as {Open; Closed; etc} repeated in data tables, that is data duplication, a simple Normalisation error:  if you those values change, you may have to update millions of rows, which is very limited design.

*

*Such values should be Normalised into a Reference or Lookup table, with a short CHAR(2) PK:
O  Open
C  Closed
U  [NotKnown]

*The data values {Open;Closed;etc} are no longer duplicated in the millions of rows. It also saves space.

*the second point is ease of change, if Closed were changed to Expired, again, one row needs to be changed, and that is reflected in the entire database; whereas in the un-normalised files, millions of rows need to be changed.

*Adding new data values, eg. (H,HalfOpen) is then simply a matter of inserting one row.

*in Open Architecture terms, the Lookup table is an ordinary table. It exists in the [SQL compliant] catalogue; as long as the FOREIGN KEY relation has been defined, the report tool can find that as well.

*ENUM is a Non-SQL, do not use it. In SQL the "enum" is a Lookup table.

*The next point relates to the meaningfulness of the key.

*

*If the Key is meaningless to the user, fine, use an {INT;BIGINT;GUID;etc} or whatever is suitable; do not number them incrementally; allow "gaps".

*But if the Key is meaningful to the user, do not use a meaningless number, use a meaningful Relational Key.

*Now some people will get in to tangents regarding the permanence of PKs.  That is a separate point.  Yes, of course, always use a stable value for a PK (not "immutable", because no such thing exists, and a system-generated key does not provide row uniqueness).

*

*{M,F} are unlikely to change

*if you have used {0,1,2,4,6}, well don't change it, why would you want to.  Those values were supposed to be meaningless, remember, only a meaningful Key need to be changed.

*if you do use meaningful keys, use short alphabetic codes, that developers can readily understand (and infer the long description from).  You will appreciate this only when you code SELECT and realise you do not have to JOIN every Lookup table.  Power users too, appreciate it.

*Since PKs are stable, particularly in Lookup tables, you can safely code:
WHERE status_code = 'O'  -- Open
You do not have to JOIN the Lookup table and obtain the data value Open, as a developer, you are supposed to know what the Lookup PKs mean.
Last, if the database were large, and supported BI or DSS or OLAP functions in addition to OLTP (as properly Normalised databases can), then the Lookup table is actually a Dimension or Vector, in Dimension-Fact analyses.  If it was not there, then it would have to be added in, to satisfy the requirements of that software, before such analyses can be mounted.

*

*If you do that to your database from the outset, you will not have to upgrade it (and the code) later.

Your Example
SQL is a low-level language, thus it is cumbersome, especially when it comes to JOINs.  That is what we have, so we need to just accept the encumbrance and deal with it.  Your example code is fine. But simpler forms can do the same thing.
A report tool would generate:
SELECT p.*,
       s.name
    FROM posts  p,
         status s
    WHERE p.status_id = s.status_id
    AND   p.status_id = 'O'

Another Exaple
For banking systems, where we use short codes which are meaningful (since they are meaningful, we do not change them with the seasons, we just add to them), given a Lookup table such as (carefully chosen, similar to ISO Country Codes):
Eq   Equity
EqCS Equity/Common Share
OTC  OverTheCounter
OF   OTC/Future
Code such as this is common:
WHERE InstrumentTypeCode LIKE "Eq%"
And the users of the GUI would choose the value from a drop-down that displays
{Equity/Common Share;Over The Counter},
not {Eq;OTC;OF}, not {M;F;U}.
Without a lookup table, you can't do that, either in the apps, or in the report tool.

A: For look-up tables I use a sensible primary key -- usually just a CHAR(1) that makes sense in the domain with an additional Title (VARCHAR) field. This can maintain relationship enforcement while "keeping the SQL simple". The key to remember here is the look-up table does not "contain data". It contains identities. Some other identities might be time-zone names or assigned IOC country codes.
For instance gender:

ID Label
M  Male
F  Female
N  Neutral

select * from people where gender = 'M'

Alternatively, an ORM could be used and manual SQL generation might never have to be done -- in this case the standard "int" surrogate key approach is fine because something else deals with it :-)
Happy coding.

A: Create a function for each lookup.
There is no easy way. You want performance and query simplicity. Ensure the following is maintained. You could create a SP_TestAppEnums to compare existing lookup values against the function and look for out of sync/zero returned.
CREATE FUNCTION [Enum_Post](@postname varchar(10))
RETURNS int
AS
BEGIN
DECLARE @postId int
SET @postId =
CASE @postname
WHEN 'Open' THEN 1
WHEN 'Closed' THEN 2
END

RETURN @postId
END
GO

/* Calling the function */
SELECT dbo.Enum_Post('Open')
SELECT dbo.Enum_Post('Closed')

A: Question is: do you need to include the lookup tables (domain tables 'round my neck of the woods) in your queries? Presumably, these sorts of tables are usually

*

*pretty static in nature — the domain might get extended, but it probably won't get shortened.

*their primary key values are pretty unlikely to change as well (e.g., the status_id for a status of 'open' is unlikely to suddenly get changed to something other than what it was created as).

If the above assumptions are correct, there's no real need to add all those extra tables to your joins just so your where clause can use a friend name instead of an id value. Just filter on status_id directly where you need to. I'd suspect the non-key attribute in the where clause ('name' in your example above)  is more likely to get changes than the key attribute ('name' in your example above): you're more protected by referencing the desire key value(s) of the domain table in your join.
Domain tables serve

*

*to limit the domain of the variable via a foreign key relationship,

*to allow the domain to be expanded by adding data to the domain table,

*to populate UI controls and the like with user-friendly information,

Naturally, you'd need to suck domain tables into your queries where you you actually required the non-key attributes from the domain table (e.g., descriptive name of the value).
YMMV: a lot depends on context and the nature of the problem space.

A: The answer is "whatever makes sense".
lookup tables involve joins or subqueries which are not always efficient. I make use of enums a lot to do this job. its efficient and fast

A: The commenters have convinced me of the error of my ways. This answer and the discussion that went along with it, however, remain here for reference.
I think a constant is appropriate here, and a database table is not. As you design your application, you expect that table of statuses to never, ever change, since your application has hard-coded into it what those statuses mean, anyway. The point of a database is that the data within it will change. There are cases where the lines are fuzzy (e.g. "this data might change every few months or so…"), but this is not one of the fuzzy cases.
Statuses are a part of your application's logic; use constants to define them within the application. It's not only more strictly organized that way, but it will also allow your database interactions to be significantly speedier.

A: Where possible (and It is not always . . .), I use this rule of thumb: If I need to hard-code a value into my application (vs. let it remain a record in the database), and also store that vlue in my database, then something is amiss with my design. It's not ALWAYS true, but basically, whatever the value in question is, it either represents a piece of DATA, or a peice of PROGRAM LOGIC. It is a rare case that it is both.
NOT that you won't find yourself discovering which one it is halfway into the project. But as the others said above, there can be trade-offs either way. Just as we don't always acheive "perfect" normalization in a database design (for reason of performance, or simply because you CAN take thngs too far in pursuit of acedemic perfection . . .), we may make some concious choices about where we locate our "look-up" values.
Personally, though, I try to stand on my rule above. It is either DATA, or PROGRAM LOGIC, and rarely both. If it ends up as (or IN) a record in the databse, I try to keep it out of the Application code (except, of course, to retrieve it from the database . . .). If it is hardcoded in my application, I try to keep it out of my database.
In cases where I can't observe this rule, I DOCUMENT THE CODE with my reasoning, so three years later, some poor soul will be able to ficure out how it broke, if that happens.


text:
Q: Pandas, groupby absolute month Question: Given a data frame with several entries and a "date" column of the form %Y%m%d (i.e. yyyy-mm-dd; these entries come as strings) what is a computationally-fast way to way add a column to the data frame consisting of the lexicographic order on the months?
Why on StackOverflow: Given a specified year and month, the above ordering allows one to easily go up or down any number of months relative to the specified month. I have a working ad hoc solution, but imagine this problem has been solved elegantly before.
Context: By way of example, given the data frame df:
         date  user
0  2011-10-06     1
1  2011-09-01     2
2  2011-11-05     3
3  2012-01-01     1
4  2012-01-01     2
5  2012-01-02     3

the desired output is:
         date  user  absmonth
0  2011-10-06     1         2
1  2011-09-01     2         1
2  2011-11-05     3         3
3  2012-01-01     1         4
4  2012-01-01     2         4
5  2012-01-02     3         4

What I've tried:
1) I made an adhoc def that sets the value of 'absmonth' based on simple arithmetic; via df.loc[row, 'absmonth'] = ... for each row. This "works" but is computationally very slow.
2) Using groupby:
df['newdate']=pd.to_datetime(df['date'],format='%Y-%m-%d')
df = df.set_index('newdate')
monthsgroup = df.groupby(df.index.month, df.index.year)

which produces the error:
    axis = self._AXIS_ALIASES.get(axis, axis)
TypeError: unhashable type: 'numpy.ndarray'

and also:
months = df.gropuby(df.index.month)
len(months)
4

At this point, I should be able to use something like an "apply" function on df using months, but am a bit lost...
ps:
pd.__version__
'0.14.0'

Help is appreciated.

A: I think 'apply' is a good way to go.
I provide my current solution from start to finish. I think I've fixed the ranking by now applying the method 'min' in order to get the desired result.
import pandas as pd

x = [{'date':'2011-10-06', 'user':1}, {'date':'2011-09-01', 'user':2},{'date':'2011-11-05', 'user':3}, {'date':'2012-01-01', 'user':1},{'date':'2012-01-01', 'user':2}, {'date':'2012-01-02', 'user':3}]

dx = pd.DataFrame(x)

dx['date'] = pd.to_datetime(dx['date'], format='%Y-%m-%d')

def get_ym(s):
  s = str(s)
  s = s[:7]
  s = s.replace('-','')
  return int(s)

dx['absmonth'] = dx['date'].apply(get_ym)
dx['absmonth'] = dx['absmonth'].rank(method='min')

-----
dx =
        date  user  absmonth
0 2011-10-06     1  2
1 2011-09-01     2  1
2 2011-11-05     3  3
3 2012-01-01     1  4
4 2012-01-01     2  4
5 2012-01-02     3  4

If someone has a slicker solution, e.g. using groupby, I'm all ears.
UPDATE:
DSM kindly suggested the following solution, which is a compact version of my approach and ranks in increments of 1 by using 'dense':
dx['absmonth'] = dx['date'].str.split('-').str[:2].rank('dense')

A: What about this?
df['absmonth'] = df.date
dict = df.absmonth.unique()
dict.sort()
df.absmonth.replace(dict,range(1,len(dict)+1),inplace=True)

Edit If you prefer to work with dates instead to format at the end:
df['absmonth'] = df.date.apply(lambda x: np.datetime64(x, 'M'))
dict = df.absmonth.unique()
dict.sort()
df.absmonth.replace(dict,range(1,len(dict)+1),inplace=True)
df.absmonth=df.absmonth.astype(int)

I think a way should exist to avoid the use of apply but I didn't find it.
Pandas.to_datetime(df['date'],format='%Y-%m-%d',unit='M') doesn't work for me.
However, I hope it accomplishes what you want.


text:
Q: Set Relations and Equivalence relation.
I'm confused as the question mention from a to b but why does it mention including 0 flights? Can somebody answer the whole question and explain the solution?
Thanks.

A: An equivalence relation must be reflexive (i.e., $aRa$ for all $a\in V$), symmetric ($aRb$ implies $bRa$) and transitive ($aRb$ and $bRc$ implies $aRc$).
The relation is reflexive because you can travel from one city to the same city using 0 flights ($0$ is even), symmetric because if you can travel from $a$ to $b$ using an even number of flights, you can take the flights back to travel from $b$ to $a$ using an even number of flights. Finally, it is transitive because if $aRb$ and $bRc$, then the number of flights needed to go from $a$ to $c$ is the sum of the numbers of flights from $a$ to $b$ and from $b$ to $c$, respectively.
To describe the equivalence relations, simply take one element and look for the cities that can be reached from that city using an even number of flights (for instance, $y$ and $w$). There will be two equivalence classes.
Finally, if we ask for an odd number of flights instead of an even number of flights, would the new relation be reflexive? or transitive? (If we call $R'$ to this new relation, notice that $yR'x$ and $xR'w$, but $yR'w$ does not hold)

A: Recall that an equivalence relation is reflexive, symmetric, and transitive.
a) In this scenario, if you can travel from a city to another city in an even number of flights, they are $R$ related.   Zero is also an even number.   Of course, this means any city is $R$ related to itself.   What does that mean?   What else must we test?
b) In this scenario, if you can travel from a city to another city in an odd number of flights, they are $R$ related.   Zero is not an odd number.   Of course, this means any city is not $R$ related to itself.   What does that mean?   What else must we test?

A: One possible way is to define a relation $R_1$ on $V$, according to adjacency of vertices. Then using relation composition, one can get new relations, by composing $R_1$ to itself ($R=R_1.R_1$). Now, you need to notice that if $(a,b)\in R_1$, then so is $(b,a)\in R_1$ and by composing them, we get $(a,a),(b,b)\in R$. Going from $a$ to $a$ can be done using even flights, because of the structure of the graph (a cycle of length $4$ and a branch). So, when we say we have gone from $a$ to $a$, it can be any even number and for the sake of algebraic accurateness, we want to include $0$.


text:
Q: preposition+being+past particle Please explain me the meaning and usage of "being+past particle" when we use with "preposition" ?
I don't know what kind of meanings it would conveys
1)
She was afraid of being accused of a crime which she did not commit. (What does "being accused of" mean?)
2)
Members must have the ability to organize without being challenged by external government authorities.


text:
Q: ¿Como guardar información de Cookies o LocalStorage al estado global en la carga inicial? Redux Toolkit - NextJS ¡Hola!
Estoy creando una app con NextJS y Redux Toolkit.
Al intentar obtener datos de las cookies y guardarlos en el estado global, obtengo el siguiente error


text:
Q: ERROR: Expression doesn't produce a value in mongodb using vb.net     Imports MongoDB.Bson
    Imports MongoDB.Driver
    Imports MongoDB.Bson.IO

Code:
    Dim sQuery = Query.EQ("name", "abc")
    Dim sUpdate = Update.Set("title", "rocks")
    Dim sResult As SafeModeResult = tblBooksCustom.Update(sQuery , sUpdate )

It will not compile and it is failing on the Update.Set and gives the
following message:

Expression does not produce a value.

Can anybody help me in solving this error.
Cheers.

A: I test this code but no error
MongoClient mc = new MongoClient("mongodb://localhost:27017");

        MongoServer server = mc.GetServer();
        server.Connect();
        MongoDatabase db = server.GetDatabase("testdb");

        MongoCollection<BsonDocument> col = db.GetCollection("mycollection");
        BsonDocument mycollection = new BsonDocument {
            { "name", "abc"},
            { "title", "b"}};
        col.Insert(mycollection);

        var sQuery = Query.EQ("name", "abc");
        var sUpdate = MongoDB.Driver.Builders.Update.Set("title", "rocks");
        SafeModeResult sResult = col.Update(sQuery, sUpdate);

Can you test other new collection?

A: Finally i solved this problem, Here is the vb.net code and hope this helps someone looking for it:
 Dim server As MongoServer = MongoServer.Create("mongodb://localhost")
 Dim db As MongoDatabase = server("tutorial1")
 Dim books As MongoCollection(Of BsonDocument) = db.GetCollection(Of BsonDocument) ("bookdetails")

 Dim query = New QueryDocument() From {{"author", "Ernest Hemingway"}, {"title", "For Whom the Bell Tolls"}}
 Dim update = New UpdateDocument() From {{"$set", New BsonDocument("title", "Cat's Cradle")}}
 Dim updatedBook = books.Update(query, update)


text:
Q: a:hover above img doesnt work properly with display block under IE & Opera Had anyone got a problem with a:hover that has position: absolute and is above  under IE & Opera
a:hover has background, but  hasn't, both has display: block.
Thank you in advance for your help
...
To see the problem please check this webpage:
http://bckp.eu/test.html
or
use this code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<title>Test</title>

        <a> without background

Doesnt work under IE? Add background | This is not quirks mode #

        <a> with background

 <a> without background, without img

A: This is one seriously wacky bug. Now, if you really must organize your html the way you have, then IE needs to have the following placed inside the a tag to get it to register with the image.

But this would be better (have not tested completely across browsers). Organize the html like (no need for a wrapper div):

Make sure the a is not position: absolute (IE7 didn't work with it so), and then set the image to:
img {position: absolute; z-index: -1}

I hope these head you in a direction to solving your problem.

A: Scott, thank you for your answer. This is just example of the problem.
Of course my real code is bigger than that:
- 2  tags to navigate prev/next (so I cant put )
- both 's has  but with display: none (prev). display: block doesnt help
z-index doesnt help. position: absolute works, when  has background.
I cant have filter: alpha(opacity=0) or opacity=0 because not every browser supports that.
I found odd solution that solves the problem, but dont want to use it: a {background: url(filedoesnotexists);} or i can use for example transparent 1x1 gif file but i would like to find reason of my problem.
Solution with img{position: absolute; z-index: -1;} div{position: relative;} a{position: static;} works exactly the same - no hovering without background above img for ie & opera
I also met another odd thing with that in my main code - will try to reproduce it. (EDIT below)
This is another strange problem - IE works, but only when it has another "layer" and mouse is hovering above this layer. Opera works fine in every case:
http://bckp.eu/test2.html - click Exif info and move mouse over image/new "layer"


text:
Q: Load and use echarts.format in Angular 6 I am trying to adapt an echarts component to work in an angular 6 dashboard.  I have added echarts and ngx-echarts to the project via npm.
In that example they load a function formatUtil = echarts.format.  I can (attempt to) load the equivalent library by importing echarts like so:
import { format } from 'echarts';

In my main class I have
formatUtil: new format;

Later on in my code I have a call to the formatter function to build a tooltip:
  tooltip: {
        formatter: function (info) {
          var value = info.value;
          var treePathInfo = info.treePathInfo;
          var treePath = [];

          for (var i = 1; i < treePathInfo.length; i++) {
            treePath.push(treePathInfo[i].name);
          }

          return [
            '
' + this.formatUtil.encodeHTML(treePath.join('/')) + '
',
            'Revenue: $' + this.formatUtil.addCommas(value) ,
          ].join('');
        }
      },

When I mouseover the tooltip, I get the following error:
zone.js:195 Uncaught TypeError: Cannot read property 'formatUtil' of undefined
    at formatter (treemap.component.ts:98)
    at ExtendedClass._showTooltipContent (TooltipView.js:544)
    at ExtendedClass.<anonymous> (TooltipView.js:479)
    at util.js:424
    at ExtendedClass._showOrMove (TooltipView.js:356)
    at ExtendedClass._showSeriesItemTooltip (TooltipView.js:478)
    at ExtendedClass._tryShow (TooltipView.js:336)
    at ExtendedClass.<anonymous> (TooltipView.js:158)
    at Object.handler (util.js:424)
    at doEnter (globalListener.js:113)

The example in question is here:
https://ecomfe.github.io/echarts-examples/public/editor.html?c=treemap-show-parent
Can anyone advise the best way to adapt the echarts.format function so that I can call it in my angular component?

A: I had the same issue. I've managed to solve it by importing the echart namespace and cast it to any.
First I've imported the namespace:
import * as echarts from 'echarts'

Then I declared a variable:
formatUtil: any = (<any>echarts).format;

After that I was able to use it.


text:
Q: C++ / XCode - How to generate pdfs? I need to generate a pdf from a c++ application. I am using Xcode and I would like to stick to that. Possibly the solution needs to be opensource. I already tried a few, but ecountered issues:
I tried podofo but I had some issues when building it - it seems that does not work on OS X.
I wanted to use ClibPDF, but that is no more available for download.
When including PDFlib oder PDFlib Lite in my projects that does not work either, I get some strange memory errors on runtime.
Has anyone an idea what could be used with C++/XCode for pdfs? Thanks in advance!

A: To create a podfo Xcode project use the following in Terminal:
cmake -G "Xcode" -DWANT_FONTCONFIG:BOOL=YES -DCMAKE_INSTALL_PREFIX=/opt/podofo -DCMAKE_INCLUDE_PATH=/opt/local/include -DCMAKE_LIBRARY_PATH=/opt/local/lib ../podofoSrcDir

A: The Mac OS X drawing library, Quartz, supports PDF natively.


text:
Q: New TeXLive installation and default distribution folder I just installed TeXLive 2021 on a Windows 10 system where TL2020 was installed. The installation was slow but went well. Once it was done, I clicked too fast on the last dialog box that may have had some instructions to update the path.
Currently, running kpsewhich --var-value=TEXMFROOT still returns C:/texlive/2020, instead of C:/texlive/2021. The TL manager gui does show the 2021 folder but anything on command line points to 2020. One consequence is that when I tried adding the tlcontrib RSA key, the key was installed to the 2020 folder, and the only way to have it in the right folder was to input the full path to tlmgr.
I checked the Windows environment variables and there is no TeX-related variable. Where does one update that default folder so the right version is called?

A: In windows, the user path is appended to the system path, so the system path always gets priority!!! But the TL command-prompt menu item has a custom path, with the TL2021 path prepended.
As to file associations, if they matter to you: the 2021 user settings should override the 2020 system settings.
Uninstalling 2020 might solve your problems. Please note: a user installation is uninstalled from the start menu, and a system installation from the settings app or from the control panel.


text:
Q: gcc-arm-none-eabi 11.3 "is not implemented and will always fail" I'm working on a bare-metal STM32 project, compiling on a Linux x64 host.
After upgrading my toolchain from gcc-arm-none-eabi-11.2-2022.02 to arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi, I get the following linker warnings:
warning: _close is not implemented and will always fail
warning: _fstat is not implemented and will always fail
warning: _getpid is not implemented and will always fail
warning: _isatty is not implemented and will always fail
warning: _kill is not implemented and will always fail
warning: _lseek is not implemented and will always fail
warning: _open is not implemented and will always fail
warning: _read is not implemented and will always fail
warning: _write is not implemented and will always fail

More comprehensively, I get this:
~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard/libg.a(libc_a-closer.o): in function `_close_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/closer.c:47: warning: _close is not implemented and will always fail
~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard/libc.a(libc_a-fstatr.o): in function `_fstat_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/fstatr.c:55: warning: _fstat is not implemented and will always fail
~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard/libc.a(libc_a-signalr.o): in function `_getpid_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/signalr.c:83: warning: _getpid is not implemented and will always fail
~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard/libc.a(libc_a-isattyr.o): in function `_isatty_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/isattyr.c:52: warning: _isatty is not implemented and will always fail
~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard/libc.a(libc_a-signalr.o): in function `_kill_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/signalr.c:53: warning: _kill is not implemented and will always fail
~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard/libg.a(libc_a-lseekr.o): in function `_lseek_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/lseekr.c:49: warning: _lseek is not implemented and will always fail
~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard/libc.a(libc_a-openr.o): in function `_open_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/openr.c:50: warning: _open is not implemented and will always fail
~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard/libg.a(libc_a-readr.o): in function `_read_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/readr.c:49: warning: _read is not implemented and will always fail
~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ~/dev_tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard/libg.a(libc_a-writer.o): in function `_write_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/writer.c:49: warning: _write is not implemented and will always fail

Other than that, the project seems to compile fine.
Reading the release note (available here), I can't see what could cause this.

*

*What change caused this ?

*Can I disregard these warnings ? It looks like system calls, so I guess I can ?

*If so, can they be silenced ?

A: The library supplied with gcc-arm-none-eabi is called 'newlib'.  You can download a copy from git://sourceware.org/git/newlib-cygwin.git.  It has tags and you can determine the specific version released with your compiler and get the tagged version.
For example, syscalls.c is one implementation.  The Libc stubs document contains functions to implement.  However, you may wonder why you get these warnings.  There are various 'C' library function calls, such as srand(), assert(), etc while will drag in the 'C' file libraries.  You need to look at a map file and avoid these function calls if you wish to minimize overhead.
I am not sure of your code base and sub-sections of a map file would be helpful.  Here you have,

*

*_open_r

*_close_r

*_read_r

Which are from the 'reent' for re-entrant library.  Typically, the re-entrant functions are only needed for an RTOS or desktop operating system.  If you have a bare metal single main thread, you do not need these functions.  You can not call open() in an interrupt handler with this option :)  So, there is really only one context (and a single errno as well).  The 're-entrant' functionality is useless.  As is .fini sections, embedded devices don't 'shutdown' normally, they reboot.

What change caused this ?

You have linked with something (called a function) that brought in file system primitives in the 'C' library.

Can I disregard these warnings ?

It depends on your use case.  Are you a safety critical system?  Generally I would recommend fixing them so the next person is not confused.  Most likely if the code follows the path to these functions, something is already wrong/unhandled.

It looks like system calls, so I guess I can?

Not a question?

If so, can they be silenced ?

Either avoid the functions or provide alternate implementations that 'do the right thing'.  The 'right thing' will depend on your platform.

A: These are the methods that the system call needs to implement, you use the functions of the standard library (NEWLIB), so you should implement these methods according to your own platform
If you're sure you don't need to implement these, just add an empty implementation to the link
add link
void _close(void)
{
}
void _lseek(void)
{

}
void _read(void)
{
}
void _write(void)
{
}

before
[ 50%] Building C object CMakeFiles/xpad.dir/src/main.c.o
[100%] Linking C executable xpad
/home/wangkai/workspace/xpad/toolchain/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/wangkai/workspace/xpad/toolchain/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libc.a(libc_a-closer.o): in function `_close_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/closer.c:47: warning: _close is not implemented and will always fail
/home/wangkai/workspace/xpad/toolchain/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/wangkai/workspace/xpad/toolchain/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libc.a(libc_a-lseekr.o): in function `_lseek_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/lseekr.c:49: warning: _lseek is not implemented and will always fail
/home/wangkai/workspace/xpad/toolchain/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/wangkai/workspace/xpad/toolchain/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libc.a(libc_a-readr.o): in function `_read_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/readr.c:49: warning: _read is not implemented and will always fail
/home/wangkai/workspace/xpad/toolchain/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/wangkai/workspace/xpad/toolchain/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib/libc.a(libc_a-writer.o): in function `_write_r':
/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/writer.c:49: warning: _write is not implemented and will always fail
[100%] Built target xpad

after
[ 33%] Building C object CMakeFiles/xpad.dir/src/system_call.c.o
[ 66%] Linking C executable xpad
[100%] Built target xpad

A: The warnings you encountered were placed in syscalls implementation of libnosys (e.g. see close.c, and relevant warning.h.
At some point, you link against libnosys - either by

*

*-lnosys link flag (common in Makefiles, generated by STM32CubeMX),

*--specs=nosys.specs compile/link flag

The developers used a neat trick to embed warning messages into object files, using .gnu.warning.SYMBOL_NAME - Unfortunately I couldn't find official documentation, but you can read more about it here, and here.
The reason you see these warnings is that those syscalls are referenced "somewhere"... It might be a stray printf/putchar in your code, exit(), rand(), or some usage in libc itself.
Regarding the severity of the warnings
In freestanding, bare metal environments it is absolutely normal to use dummy syscalls, as we don't expect to interact with the operating system. If you use RTOS on your platform, there is probably a dedicated syscalls implementation waiting for you. So there is probably nothing to worry about this warning. I think that the warning message itself is a little bit misleading - by "fail" it means "do nothing and return error status", which is well-defined behavior that should not lead to abnormal program execution.
Side note: I checked libnosys.a from 10-2020-q4-major release of arm-none-eabi with objdump, and it didn't have those warning symbols.
Finally, how to get rid of the messages
As others mentioned, in freestanding environment, you can provide your own dummy syscalls, and don't link against libnosys. I searched through ld documentation and source code, and didn't find a linker option to suppress this warning.
Note that if you rely on dynamic memory allocation using malloc in C, or new i C++, your implementation of _sbrk MUST actually work (more info here), otherwise you may enter "debugging so funny that it lasts for weeks" zone.
Funnily enough, libnosys's implementation of _sbrk works AND doesn't have embedded warning symbol. I strongly recommend using it, unless you need to allocate heap on external RAM, etc.
The added benefit of using libnosys is the fact that you don't need to write your custom syscalls in EVERY project you make, which could be tiresome and error-prone .
TL;DR
Having said that, there is actually a method to get rid of the warnings from libnosys permanently:
Look for libnosys.a in your toolchain directory (in arm-none-abi case there will one for each architecture and float ABI), and delete .gnu.warning symbols from archives using:
arm-none-eabi-objcopy -w -R .gnu.warning.* libnosys.a
Note that this will irreversibly modify your toolchain files. Most likely in intended, and non-harmful way, but still. Use with caution
If you use CMake to build your project I would consider creating PRE_LINK command that copies relevant libnosys, strips it of warnings, and link with it instead.


text:
Q: Why do Windows 10 foreground apps mysteriously launch as background processes? Occasionally Task Manager shows that "Store", "Settings", and/or "Calculator" are mysteriously running as background processes.

*

*There's no corresponding foreground application, just the background processes.

*I haven't interactively run either during the current session.

*Neither is listed in the "Everything" tab of AutoRuns.

As discussed in my answer to this SuperUser question, these two background processes cause a delay in executing Windows shortcut keys. But besides that, it's just plain weird.
Does anyone know why these foreground apps are mysteriously launching themselves as background processes?
And, ideally, how I can prevent it from happening? As discussed elsewhere (SuperUser and Thomas Vanhoutte), I could uninstall the Calculator and Store apps. But it seems like overkill to uninstall them just to defeat a shortcut key delay.

A: Store probably runs for doing automatic update check.
To turn it off, go to Start -> Settings -> Privacy -> Background apps
and set it to Off.
More info in the article: How to Turn On or Off Background Apps in Windows 10.
You might also in this case turn off automatically-applied updates by going to
Settings -> Update & Security -> Advanced options
and
set "Choose how updates are installed",
to "Notify to schedule restart."
For the calculator :
I believe that this Modern app is among those that
Windows 10 tends to keep in memory if used once.
It probably runs in suspended mode, using very little memory, ready to be
launched quickly when called, which is more useful in a tablet than a computer.
Windows might forget about it if you kill it off a few times using the Task Manager
before shutting down. If this works, I advise in the future to use a third-party calculator instead of the Modern one, or it will come back.

A: I too am seeing the shortcut key delay issue in Windows 10. I believe it is caused by any Metro app sitting in the "suspended" state (as reported by Process Explorer). I have seen it caused by the Photos app, Video app, Calendar app, etc, which seem to launch randomly by themselves as he OP reports.
So it seem the shortcut key delay issue a general issue with (most/all?) apps in the suspended state.
I have checked the Background apps setting in Privacy, but it does not list all the problem apps. E.g. the Calculator and Video apps are not listed there.
Reported on the Microsoft forum: 3 second delay when using shortcut key to launch program
My solution for now is to have a batch file which I can run on demand, killing problem processes using taskkill /f.

A: Disabling the SuperFetch service can prevent applications from starting on their own.
We've found out that with SuperFetch running, some applications are started in the suspended state automatically once or twice an hour, even after you explicitly kill their processes. This happens for Windows Store/Modern UI/Metro apps like Photos, Calculator, Maps, Weather, Time and so on.
How to Disable SuperFetch
From the Command Line
Run this command under Administrator:
sc config sysmain start=disabled

Additionally, stop an already running SuperFetch:
sc stop sysmain

From the UI

*

*Press Windows+R, type services.msc and press Enter.

*Find SuperFetch in the list, and double-click it to open its properties.

*Set Startup type to Disabled.

*(Optional.) Click Stop to stop an already running SuperFetch.

*Click OK to save the changes.

A: Had the same problem, I had changed the settings of background apps, and it didn't change anything, the same apps were showing in the background and staying, the only way to shut them, was to start them and then shut them, then they would disappear from background.
I saw here that disabling superfetch was maybe the way...so I didn't do it.
I just deleted all the files in prefetch folder (c://windows/prefetch/) so it would start anew.
All the subsequent restart of Windows have not shown the problematic background apps again.


text:
Q: How to import a library with full dependencies in Choregraphe I am working with choregraph to develop an application for Nao robot.
I am trying to install a library that implements a speech to text functionality: it uses a simple HTTPS request.
I am not able to make it work because it has a lot of dependencies and choregraph doesn't have a tool to import them properly.
So my question is: how can I install any HTTPS library on choregraph without downloading every single dependency module of the library?
I would like to make it work also in the virtual robot.

A: The only way to bring external Python modules is to embed them in your Choregraphe project and to append the path to those modules to the PYTHONPATH, from inside your behavior. You will be then able to import your external modules.
That is to say, from a Python box in your Choregraphe behavior, and according to the documentation:
import os
import sys
sys.path.append(os.path.join(self.behaviorAbsolutePath(), 'path/to/module'))

Please note that since behaviors are running in the process of NAOqi, messing with the PYTHONPATH may impact every behavior. So it is good to restore the path when your behavior stops.


text:
Q: Purported UDP "connection" My understanding was that UDP doesn't form connections; it just blindly sends packets.  However, when I run
nc -u -l 10002

and
nc -u 127.0.0.1 10002

simultaneously (and so can send messages back and forth between terminals), lsof reports two open UDP connections:
nc ... UDP localhost:10002->localhost:35311
nc ... UDP localhost:35311->localhost:10002

If I open a third terminal and do nc -u 127.0.0.1 10002 again, to send another message to the original listener, the listener does not receive (or acknowledge, at least) the message, suggesting it is indeed tied to a specific connection.
If I implement a UDP echo server in Java like this and do sorta the same thing (on 10001), I get
java ... UDP *:10001
nc ... UDP localhost:52295->localhost:10001

aka, Java is just listening on 10001, but nc has formed a connection.
Based on my understanding of UDP, I'd expect both sides to behave like the Java version.  What's going on?  Can I make the Java version do whatever nc is doing?  Is there a benefit to doing so?
I'm on Ubuntu 20.04.3 LTS.

A: UDP sockets can be connected (after a call to connect) or they can be unconnected. In the first case the socket can only exchange data with the connected peer, while in the second case it can exchange data with arbitrary peers. What you see in lsof is if the socket is connected or not.

My understanding was that UDP doesn't form connections; it just blindly sends packets.

That's a different meaning of the term connection here. TCP has always "real" connections, i.e. an association between two endpoints which has a clear start (SYN based handshake) and end (FIN based teardown). TCP sockets used for data exchange are therefor always connected.
UDP can have associations between two endpoints too, i.e. it can have connected sockets. There is no explicit setup and teardown of such a connection though. And UDP sockets don't need to be connected. From looking at the traffic it can therefore not be determined if connected UDP sockets are in use or unconnected.

Can I make the Java version do whatever nc is doing?

Yes, see What does Java's UDP DatagramSocket.connect() do?
.

Is there a benefit to doing so?

An unconnected UDP socket will receive data from any peer and the application has to check for each received datagram where they came from and if they should be accepted. A connected UDP socket will only receive data from the connected peer, i.e. no checks in the application are needed to check this.
Apart from that it might scale better if different sockets are used for communication with different peers. But if only few packets are exchanged with each peer and/or if one need to communicate with lots of peers at the same time, then using multiple connected sockets instead of a single unconnected one might mean too much overhead.


text:
Q: tensorflow C API static library Can I build/get static library (.a files instead of .so files) of tensorflow C API? I need to include/link tensorflow c api in my C++ software xyz and then I build shared library xyz.so that will be sent to other party. The other party should be able to run xyz.so without installing/building tensorflow.

A: Download tensorflow c api and link .so files using CMakeLists.txt file.

A: I have gotten some things to work by compiling Tensorflow with the following bazel command:
bazel build --config=monolithic -j 1 //tensorflow:libtensorflow.so

And then linking together the object files with libtool for MacOS:
libtool -static -o libtensorflow_arm64_libtool_SO3.a $(cat bazel-bin/tensorflow/libtensorflow_cc.so.*.params | sed -e 's!-Wl,-force_load,!!' | grep -e '\.a$' -e '\.lo$' | sort -t: -u -k1,1)

Or ar for linux:
ar -cr libtensorflow.a $(cat bazel-bin/tensorflow/libtensorflow_cc.so.*.params | grep '\.o$')

I have not figured out all the details, but this does make at least version control and tensor allocation work.
EDIT:
In the end I opted for going with TFLite as it supports almost all TF operations and have Cmake support for building static libraries. For the full solution see this thread:
Has anyone experience in building a static library for the Tensorflow C++ API?


text:
Q: Is there an reason to use html as Facelets root instead of ui:composition? I notice the Netbeans wizard to create a Facelets template client page gives the option to have either html or ui:composition as the document root for the page.
For time out of mind I have always used the html option, then kept using it for consistency.  Yet I realized that if I used ui:composition then I would save two levels of indentation for the body of my document.
The only reason to keep with html that I can remember is that I read somewhere that this format was hypothetically useful in an IDE somewhere.  However I have never encountered it.
Is there any reason to keep using html as the document root?

A: Facelets is supposed to be "designer friendly". The point of being able to have extra tags around the Facelets markup, and of features like the jsfc attribute or ui:remove is to let you write JSF pages that will render correctly when previewed in a web browser without having to actually run the application in a container. (E.g.: To make it easier to just tweak CSS for a single view.)
If you have no need for this, you can safely leave the extra clutter out.


text:
Q: Flash Click Tag w SWFObject I hate flash, but one of our clients has sold a flash ad with a clickTAG and I can't get the click tag to work correctly. After vast searching and numerous attempts, I've got to:

This shows the ad correctly, the cursor is a pointer (the cursor was a pointer before I started implementing the clickTAG embed) but nothing happens when you click.
Any ideas on where I'm going wrong?

A: I cracked it (notice the so.addVariable):


text:
Q: Python 2.7: RuntimeWarning: overflow encountered in long_scalars (in datetime.timedelta) I receive the warning RuntimeWarning: overflow encountered in long_scalars when I use numbers of type numpy.int32 for initializing a timedelta. The numbers are not so big that an overflow should be expected.
The following code shows the problem:
from datetime import timedelta
import numpy

if __name__ == '__main__':

    a = numpy.int32(2147)
    b = numpy.int32(2148)
    print timedelta(seconds = a)      # works well
    print timedelta(seconds = int(b)) # works well
    print timedelta(seconds = b)      # bad result

This gives the output:
0:35:47
0:35:48
-1 day, 23:24:13.032704
[...]test.py:10: RuntimeWarning: overflow encountered in long_scalars
print timedelta(seconds = b)

I have tested some numbers. It seems to work well for numbers <= 2147 and gives a warning for numbers >= 2148.
I'm looking forward to explanations :)


text:
Q: Non equi Left outer join in hive workaround How to implement non-equi left outer join in hive involving more than two tables?
Query Used:
SELECT cs.SID, ins.ID, a.ID, e.id, i.id, cs.dateId, cs.timeId,cs.SSTRT,cs.SEND,cs.VAL,cs.IND,cs.TYP,cs.DTPE,cs.BCDE, cs.IVAL,cs.ICNT,cs.RDT,cs.REJ
from cs_item_hive cs
LEFT outer JOIN installation_hive ins ON  (cs.SID=ins.SN)
LEFT OUTER JOIN account_hive a ON (ins.AID=a.ID AND ins.MDID = a.MDID)
LEFT OUTER JOIN equipment_hive e ON ins.GBLSID=e.GSN
LEFT OUTER JOIN item_hive i ON (cs.BCDE=i.ibc AND ins.MDID = i.MDID AND ins.AID = i.AID)
where cs.SEND >= ins.IDAT AND cs.SEND < ins.RDAT;

Issue:
Records that are not matching WHERE condition are skipped. [As, Hive does not support non-equi join, where condition is used]
Requirement:
Records that are not matching the condition should have the ins.ID, a.ID, e.id, i.id substituted as NULL [as like equi-join].
How to implement something like this in hive:
SELECT cs.SID, ins.ID, a.ID, e.id, i.id, cs.dateId, cs.timeId,cs.SSTRT,cs.SEND,cs.VAL,cs.IND,cs.TYP,cs.DTPE,cs.BCDE, cs.IVAL,cs.ICNT,cs.RDT,cs.REJ
from cs_item_hive cs
LEFT outer JOIN installation_hive ins ON  (cs.SID=ins.SN AND cs.SEND >= ins.IDAT AND cs.SEND < ins.RDAT)
LEFT OUTER JOIN account_hive a ON (ins.AID=a.ID AND ins.MDID = a.MDID)
LEFT OUTER JOIN equipment_hive e ON ins.GBLSID=e.GSN
LEFT OUTER JOIN item_hive i ON (cs.BCDE=i.ibc AND ins.MDID = i.MDID AND ins.AID = i.AID);

Please guide me to resolve this issue.
Thankyou.

A: You can come pretty close with:
where (cs.SEND >= ins.IDAT AND cs.SEND < ins.RDAT) or
      (ins.IDAT is null)

Alternatively, I think you can use two queries, one for matches and one for non-matches.


text:
Q: IOS sdk 4.3 and camera effects like mirror, blur, thermal... etc? There were many voices about camera effects on IOS SDK 4.3 (as you can read here), after the final release i can't find anything about that on Apple API change log.
Was it my fault and i made inaccurate research with google and Documentation ? Anyone knows anything more about this subject ?

A: These effects are available via PhotoBooth on the iPad2 but not in the SDK as for as I am aware. Looking at the names PBThermalFilter for example it'd seem that may be the case.


text:
Q: PyInstaller Exe behaves differently to script Aight so I'm getting a user input from a secondary window using customtkinter.
When running the script from MSCode everything works fine.

*

*The User inputs into the CTkEntry widget.

*The textvariable properly assigns value.

*This value is accessed elsewhere.

However, when I use pyinstaller to create an .exe of the same script, the textvariable simply stops assigning it's value to the textvariable
Can anyone point me to where/what may be cause an error such as this?
Is it that these mods are not compatible?
As a side note: I am using CTkEntry in a similar manor with the main window and have had no such issues with it with identical syntax.
I'm using auto-py-to-exe with settings:

*

*One Directory

*Console Based (for dubugging)

*Locating the customTkinter lib folder

*--hiddenimport win32timezone (throws errors otherwise)

The window looks like:
self.entryString = tkinter.StringVar()
entryWidget = customtkinter.CTkEntry(master=self.window, textvariable=self.entryString)
entryWidget.pack()
customtkinter.CTkButton(master=self.window, text="Done", command=self.dismissWindow).pack()

Which is later accessed using:
self.entryString.get()

A: Alright so to close the question I did find and solve my issue.
I have a root window main. Inside main I have a button that opens another window form for the user to interact with. form itself also opens new windows.
The windows created with form are TkTopLevel , as they should be (I'm under the impression one should avoid multiple root windows)
What I didn't realise was that form was a root window, and not a TkTopLevel.
So when I returned to main, the textvariables in form were not updating their values. I have no idea what specifically causes this error within the Tk library, but after changing form to a TkTopLevel the interactions worked as intended.


text:
Q: In Dockerfile "php artisan storage:link" returns a non-zero code I can't understand why this is happening. I am trying to create a symlink but it fails. It only works if I ssh into the container after it has been created. When I build my project using Docker I get this error message:
Step 11/14 : RUN php artisan storage:link
 ---> Running in bbfd87dcdbf6
Could not open input file: artisan
ERROR: Service 'php-container' failed to build: The command '/bin/sh -c php artisan storage:link' returned a non-zero code: 1

But if I try to ssh into my container and run the same command then it works.
$ docker exec -it php-container /bin/bash

root@053d9cbd22eb:/var/www# php artisan storage:link
The [/var/www/public/storage] link has been connected to [/var/www/storage/app/public].
The links have been created.

Here is my Dockerfile
FROM php:7.4-fpm

# Set working directory
WORKDIR /var/www

# Install dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    libpng-dev \
    libjpeg62-turbo-dev \
    libfreetype6-dev \
    locales \
    libzip-dev \
    libmcrypt-dev \
    libonig-dev \
    zlib1g-dev \
    zip \
    jpegoptim optipng pngquant gifsicle \
    vim \
    unzip \
    git \
    graphviz \
    curl

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install extensions
RUN docker-php-ext-install pdo_mysql zip exif pcntl
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install gd
RUN docker-php-ext-install bcmath

# Permissions for Laravel
RUN chown -R www-data:www-data /var/www
RUN chmod -R 777 /var/www

# (!) This is not working.......
RUN php artisan storage:link

# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Expose port 9000 and start php-fpm server
EXPOSE 9000

CMD bash -c "composer install && chmod -R 777 /var/www && php artisan migrate --seed && php-fpm"

A: You must run composer install before php artisan command.
This is really important. you have error because artisan package not exist and actually vendor folder not created.
Finally you must change docker file to this :
CMD bash -c "composer install && chmod -R 777 /var/www && php artisan migrate --seed && php artisan storage:link


text:
Q: How can I know the font size (or percent) of the iOS with Swift? I wanna know the font size (or percent) of the iOS with Swift? I know that by using dynamic types a label adjust itself, but I wanna know what percent is it, is it to the minimum, to the maximum, in the middle?
Image sample:

A: Add this extension:
extension UITraitEnvironment {
    func printCurrentContentSizeCategory() {
        switch traitCollection.preferredContentSizeCategory {
        case .extraSmall:
            print("extra small")
        case .small:
            print("small")
        case .medium:
            print("medium")
        case .large:
            print("large")
        case .extraLarge:
            print("extra large")
        case .extraExtraLarge:
            print("extra extra large")
        case .extraExtraExtraLarge:
            print("extra extra extra large")
        case .accessibilityMedium:
            print("accessibility medium")
        case .accessibilityLarge:
            print("accessibility large")
        case .accessibilityExtraLarge:
            print("accessibility extra large")
        case .accessibilityExtraExtraLarge:
            print("accessibility extra extra large")
        case .accessibilityExtraExtraExtraLarge:
            print("accessibility extra extra extra large")
        default:
            print("Unspecified")
        }
    }
}

And now you can use it in any UIViewController, UIView, etc:
override func viewDidLoad() {
    super.viewDidLoad()
    printCurrentContentSizeCategory()
}


text:
Q: Recommendations for open/source text indexing and search I just discovered Lucene (Java library) and starting to read up on it.
I'm interesting in taking some works of literature (for example, Philo, Josephus), and indexing them, then doing the following types of analysis (similar to what some Bible software programs do):
1) find word x within 2 or 3 words of word y
2) find "work* of * hand*" - would find "works of your hands", "work of his hand" etc...
3) find literary patterns (also called "motiffs") such as they author uses the phrase "in that day".  (I think this might be the trickiest, might have to find all combinations of 2-7 word phrases then count them and rank them, only showing the top 25 for example).  This might show for example that Josephus like to use one sets of phrases, and Philo another.
Are there any open-source libraries that you would recommend?
My language preferences would probably be 1) Python, 2) C#, 3) Java.
Ideally no dependencies on any proprietary database.
Thanks,
Neal

A: Lucene is the best one out there in my opinion in terms of popularity, community, activity and tooling. I suggest you look at Solr which is built on top of Lucene. Another open source indexing framework I found is Egothor which I am not sure what is the adoption rate.
And here is a survey that might be help you in choosing the right one.
Here you can find more open source and commercial libraries. I have seen few of them supporting bindings for more than 1 programming language. If you have decided to go with Lucene, then you might need Luke for your debugging purposes.


text:
Q: ListView item click not working in Tabhost My issue is onItemClickListener  is not working on Listview which is under Tabhost. Any listview's onclick event is not working. i had tried everything. here is my code. please help me with this.
My Tabhost file
<android.support.design.widget.TabLayout
     android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/material_blue_grey_800"
    app:tabGravity="fill"
    app:tabIndicatorColor="@color/orange"
    app:tabMode="fixed"
    app:tabSelectedTextColor="@color/orange"
    app:tabTextColor="@color/white"></android.support.design.widget.TabLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

</android.support.v4.view.ViewPager>

Then primary layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"  >

    <!--<android.support.v7.widget.RecyclerView-->
        <!--android:id="@+id/songs_recycleview"-->
        <!--android:clickable="true"-->
        <!--android:focusable="true"-->
        <!--android:layout_width="match_parent"-->
        <!--android:layout_height="match_parent" />-->

    <!--<ListView-->
        <!--android:layout_width="wrap_content"-->
        <!--android:layout_height="wrap_content"-->
        <!--android:id="@android:id/list"-->
        <!--android:layout_alignParentBottom="true"-->
        <!--android:layout_alignParentRight="true"-->
        <!--android:layout_alignParentEnd="true"/>-->

    <ListView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/SongList"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"/>
</RelativeLayout>

Here is list adaptor
 public class LazyAdapter extends BaseAdapter {

private Activity activity;
private Fragment fragment;
private AudioListModel[] data;
private String[] test;
private static LayoutInflater inflater = null;
public ImageLoader imageLoader;

public LazyAdapter(Activity a, String[] d) {
    activity = a;
    test = d;
    inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageLoader = new ImageLoader(activity.getApplicationContext());
}
/*
  private OnItemClickListener mOnItemClickListener;

  public interface OnItemClickListener {
      public void onItemClick(View view, int position);
  }

  /*
      public LazyAdapter(Activity a,ArrayList<AudioListModel> d, OnItemClickListener OnItemClickListener) {
          activity = a;
          data = d.toArray(new AudioListModel[d.size()]);
          mOnItemClickListener=OnItemClickListener;
          inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          imageLoader = new ImageLoader(activity.getApplicationContext());
      }
  */
public LazyAdapter(Activity a, AudioListModel[] d) {
    activity = a;
    data = d;
    inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageLoader = new ImageLoader(activity.getApplicationContext());
}

public int getCount() {
    return data.length;
}

public Object getItem(int position) {
    return position;
}

public long getItemId(int position) {
    return position;
}

public View getView(int position, View convertView, ViewGroup parent) {
    View vi = convertView;
    if (convertView == null)
        vi = inflater.inflate(R.layout.rawlistview, null);
    TextView text = (TextView) vi.findViewById(R.id.songname);
    //TextView song_path=(TextView)vi.findViewById(R.id.songpath);
    ImageView image = (ImageView) vi.findViewById(R.id.image);

    if (test != null) {
        text.setText(test[position]);
        imageLoader.DisplayImage(data[position].bitmap, image);
    }

    if (data != null) {
        text.setText(data[position].track);
        //song_path.setText(data[position].Song_Path);
        imageLoader.DisplayImage(data[position].bitmap, image);
    }

    return vi;
}
 }

here is primary fragment class
  public class PrimaryFragment extends Fragment {
    RecyclerView rv;
    LazyAdapter adapter;
    ListView listView;
    View rootView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.primary_layout, container, false);

        ArrayList<AudioListModel> songsList = SongsManager.GetSongs();

        adapter = new LazyAdapter(getActivity(), songsList.toArray(new AudioListModel[songsList.size()]));
        //rv = (RecyclerView) rootView.findViewById(R.id.songs_recycleview);

        listView = (ListView) rootView.findViewById(R.id.SongList);
        LazyAdapter ad = new LazyAdapter(getActivity(), songsList.toArray(new AudioListModel[songsList.size()]));
              /*LazyAdapter ad = new LazyAdapter(getActivity(), songsList,
                new LazyAdapter.OnItemClickListener() {
                    @Override
                    public void onItemClick( View view, int position) {
                        Toast.makeText(getActivity(), "this is on click event", Toast.LENGTH_SHORT);
                    }
                });
        */
        listView.setItemsCanFocus(false);
        listView.setAdapter(ad);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Toast.makeText(getActivity(), "this is on click event", Toast.LENGTH_SHORT);
            }
        });

        return rootView;//inflater.inflate(R.layout.primary_layout, null);
    }

Please help me in this. My click is not working any tab......

A: Try setting your on click listener like this:
 listview.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView<?>adapter,View v, int position){
 Toast.makeText(getActivity(), "this is on click event", Toast.LENGTH_SHORT).show();} });

Do let me know if it changes anything for you.
EDIT: I just realised that reason you think onClick is not working could be because you are not showing your toast. You need to show toast by adding .show() like this:
Toast.makeText(getActivity(), "this is on click event", Toast.LENGTH_SHORT).show();


text:
Q: details tag missing from $_POST I'm working on a php school project and i have to use the details and summary tags, my problem is that when i submit my form all the fields are in $_POST but not the content of
i know a form submits based on the name so i gave it name and id, is it normal?
here is the fieldset from the form :
<legend>SITE</legend>

aide

titre : nom de votre site affiché dans l'entête

           couleur : de ce titre (format html ou css)

           image : nom du dossier des images

titre
<input id="SITE[titre]" name="SITE[titre]" value="Welcome" required="" size="25" type="text">

couleur
<input id="SITE[couleur]" name="SITE[couleur]" class="color" value="#FFF" '="" type="text">

images
<input id="SITE[images]" name="SITE[images]" value="img" required="" size="25" type="text">

A: Only the values of successful form controls will be included in submitted form data. Form controls include input, select, textarea and button.
The  element is not a form control.

A: You need to wrap everything in form tags and place a submit button
<form method="post" name="phpFileName" class="form-horizontal" enctype="multipart/form-data" role="form">
 <legend>SITE</legend>

 aide

titre : nom de votre site affiché dans l'entête

       couleur : de ce titre (format html ou css)

       image : nom du dossier des images

 titre
 <input id="SITE[titre]" name="SITE[titre]" value="Welcome" required="" size="25" type="text">

 couleur
 <input id="SITE[couleur]" name="SITE[couleur]" class="color" value="#FFF" '="" type="text">

 images
 <input id="SITE[images]" name="SITE[images]" value="img" required=""
size="25" type="text">

</form>


text:
Q: Call codeigniter hooks after pre_controller and before post_controller I want to validate request based on input post parameter. if using pre_controller not able to get post value. if post_controller used controller executed first and showing me validation error. I want to validate every request so do not want to manually write code in controller after post parameters.
following is code,
file: hooks.php
$hook['post_controller'][] = array(
    'class'    => 'Validate',
    'function' => 'society',
    'filename' => 'hooks.validate.php',
    'filepath' => 'hooks',
    'params'   => array()
);

file: hooks.validate.php
function society(){

        $CI = & get_instance();
        if($CI->is_hookable) {
            $method = $CI->input->method();
            $society_id = "";
            if($method == 'get' || $method == 'GET')
            {
                $society_id = $CI->get('society_id');
            }
            if($method == 'post' || $method == 'POST')
            {
                $society_id = $CI->post('society_id');
            }
            if($society_id!="")
            {
                if(!is_society_exists($society_id))
                {
                    $response['message'] = "Invalid or inactive society";
                    $response['status'] = false;
                    $CI->response($response, REST_Controller::HTTP_OK);
                }
            }
            else
            {
                $response['message'] = "Unkown request";
                $response['status'] = false;
                $CI->response($response, REST_Controller::HTTP_OK);
            }
        }
    }

A: The hook you want is "post_controller_constructor" which happens after the controller is created but before it is executed.
$hook['post_controller_constructor'][] = array(
    'class'    => 'Validate',
    'function' => 'society',
    'filename' => 'hooks.validate.php',
    'filepath' => 'hooks',
    'params'   => array()
);

Here's a more concise bit of code that (I think) gets the job done.
function society()
{
    $CI = & get_instance();
    if($CI->is_hookable)
    {
        //both input::post('item') and input::get('item')
        //return NULL if the item is not found
        //you don't need the following because NULL is empty too
        //$society_id = "";

        $method = $CI->input->method();
        //use the variable as the method to call
        $society_id = $CI->input->$method('society_id');

        if( ! empty($society_id))
        {
            if( ! is_society_exists($society_id))
            {
                $response['message'] = "Invalid or inactive society";
            }
        }
        else
        {
            $response['message'] = "Unkown request";
        }
        $response['status'] = false;
        $CI->response($response, REST_Controller::HTTP_OK);
    }
}

The line
$society_id = $CI->input->$method('society_id');

will call either $CI->input->get('society_id') or $CI->input->post('society_id') depending on what $CI->input->method() returns without the need for a bunch of if/else code.


text:
Q: Select element having biggest number Using jQuery I am able to loop through each div's HTML and determine which one has the greatest number, like this:

var biggestNum = 0;
$('div').each(function(){
    var currentNum = parseInt($(this).html());
    if(currentNum > biggestNum) {
        biggestNum = currentNum;
    }
});

alert(biggestNum);

5

14

3

How can I then select the containing div of the biggest number and do stuff to it?

A: One simple approach is use a descending sort() on the jQuery collection of elements and target the first after sorting. This has no impact on positioning in the dom

$('div').sort(function(a,b){
    return $(b).text() - $(a).text();
}).first().css('color','red')

5

14

3

A: Managed to find a solution myself by using a function. Working snippet:

var biggestNum = 0;
$('div').each(function(){
    var currentNum = parseInt($(this).html());
    if(currentNum > biggestNum) {
        biggestNum = currentNum;
    }
});

alert(biggestNum);

$('div').filter(function() {
  var num = +($(this).text().trim());
  return num >= biggestNum;
}).addClass('green');
.green {
  color: #00ff00;
}

5

14

3


text:
Q: How to create a login system that can validate user to enter valid username and password? I was trying to create a login system that can check if the username and password is include in the userlist (which I use it to store different user password and their name).
userlist = []
def userpage():
     print("user page accessed")
     opt = int(input("Enter '0' to log out"))
     if opt == 0:
          mainpage()

def signin():
     username = input("Please enter username: ")
     for user in userlist:
          if username in user:
               password = input("Please enter password: ")
               if password in user:
                    userpage()
               else:
                    print("Incorrect password")
                    mainpage()
          else:
               print("Unregister username")
               mainpage()

def signup():
     username = input("Please enter username: ")
     password = input("Please enter password: ")
     userlist.append([username,password])
     print(userlist)
     userpage()

def mainpage():
     opt = int(input("Enter '0' to sign up, '1' to sign in: "))
     if opt == 0:
          signup()
     elif opt == 1:
          signin()
mainpage()

Notice that I use print(userlist) to check whether the username and password is being store in the list or not. The signup function works(As from what I saw from the print(userlist), but there's issue with signin function(which I want to use it to check valid username and password). As the user will straight away access the userpage after they signup, the signin function works when the first user signup and sign in again after they logout. But the follow up user signup and wanted to sign in again after log out, it will keep saying it is an unregister username, but I can clearly see that the userlist have their username.

A: Your problem is that you raise an error immediately if the first array of credentials does not match. It checks the first user-password pair, then if it doesn't match,you raise an error. So your code should be:
def signin():
     username = input("Please enter username: ")
     for c,user in enumerate(userlist):
          if username in user:
               password = input("Please enter password: ")
               if password in user:
                    userpage()
               else:
                    print("Incorrect password")
                    mainpage()
          else:
               if c != len(userlist):
                    pass
               else:
                    print("Unregistered username")
                    mainpage()


text:
Q: TableView shows a column that doesn't exist I have the following FXML code for a TableView with two columns, yet it shows three as you see in the picture. I don't see why it would show three columns, I only specified two... Any tips?
FXML
<TableView fx:id="table"
           GridPane.columnIndex="1"
           GridPane.rowIndex="0">
    <columns>
        <TableColumn fx:id="timeColumn" text="time"/>
        <TableColumn fx:id="angleColumn" text="angle"/>
    </columns>

</TableView>

A: I found out how to make the columns resize with the size of the table. Simply added this to the FXML.
<columnResizePolicy>
    <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
</columnResizePolicy>


text:
Q: Xcode BoringSSL peer disconnect causing app to hang on startup Recently I started getting inconsistent BoringSSL issues that is causing my cordova/ionic app to hang.  It happens about 1 out of every 4 or 5 times I launch the app from Xcode to a physically attached test iPhone 6.  The test phone uses WiFi only (no carrier network).  Having a devil of a time find any solid solutions or what the root of the problem is.
Some indicate its DNS, others say its related to Firebase...I have tried a few of the fixes those threads have mentioned but none are working for me.
[BoringSSL] nw_protocol_boringssl_input_finished(1543) [C3.1:2][0x12fd335c0] Peer disconnected during the middle of a handshake. Sending errSSLClosedNoNotify(-9816) alert
TIC TCP Conn Failed [3:0x2805712c0]: 3:-9816 Err(-9816)
[BoringSSL] nw_protocol_boringssl_input_finished(1543) [C5.1:2][0x12fe46470] Peer disconnected during the middle of a handshake. Sending errSSLClosedNoNotify(-9816) alert
TIC TCP Conn Failed [5:0x280575f80]: 3:-9816 Err(-9816)
[BoringSSL] boringssl_context_alert_callback_handler(3724) [C6.1:2][0x12fd43710] Alert level: fatal, description: inappropriate fallback
[BoringSSL] boringssl_session_errorlog(224) [C6.1:2][0x12fd43710] [boringssl_session_handshake_incomplete] SSL_ERROR_SSL(1): operation failed within the library
[BoringSSL] boringssl_session_handshake_error_print(205) [C6.1:2][0x12fd43710] 5097281768:error:1000043e:SSL routines:OPENSSL_internal:TLSV1_ALERT_INAPPROPRIATE_FALLBACK:/BuildRoot/Library/Caches/com.apple.xbs/Sources/boringssl/boringssl-109.250.2/ssl/tls_record.cc:586:SSL alert number 86
[BoringSSL] boringssl_context_get_error_code(3617) [C6.1:2][0x12fd43710] SSL_AD_INAPPROPRIATE_FALLBACK
TIC TCP Conn Failed [6:0x280576640]: 3:-9860 Err(-9860)
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9860)
Task <02ADA890-35C5-4DE7-B0E5-6EC812CF79E6>.<1> HTTP load failed (error code: -1200 [3:-9860])
Task <02ADA890-35C5-4DE7-B0E5-6EC812CF79E6>.<1> finished with error - code: -1200
nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x12fe15ea0] get output frames failed, state 8196
nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x12fe15ea0] get output frames failed, state 8196

If the app sees this error when initializing, the app hangs at the splash screen.  If it makes it past this issue then the app works just fine and I only see nw_protocol_get_output_frames messages every so often (don't know what those are about either).
Anyone have any ideas as to what is causing this, where to look or possibly what the fix is?
Cordova CLI: 9.0.0 (cordova-lib@9.0.1)
cordova-ios: v5.0.0
Gulp version:  CLI version 3.9.1
Gulp local:
Ionic Framework Version: 1.3.4
Ionic CLI Version: 1.7.16
Ionic App Lib Version: 0.7.3
ios-deploy version: 1.9.4
ios-sim version: 8.0.1
OS: Mac OS X El Capitan
Node Version: v6.11.4
Xcode version: Xcode 10.1 Build version 10B61

A: I was stuck at this error and what I did was enable all kinds of logs on XCode and that revealed that the error with this BoringSSL was from a call to the API Crashlytics of google. What solved this matter to me was enter on firebase, enable crashlytics for my project, install the plugin (https://ionicframework.com/docs/native/firebase-crashlytics) and initialise it.
To find crashlytics on firebase you enter on the console and search on the left, under the menu quality, crashlytics. After that if you have already your GoogleService-Info.plist on your app, what remains is to install the plugin and initialise it according the docs.
[EDIT] Dont know if the above will contribute, because on another batch of tests I found that it didnt fix the issue. But when I add the next lines to config.plist it resolves:
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>app-measurement.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>
        <key>mtalk.google.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>
        <key>play.googleapis.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>
        <key>settings.crashlytics.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>
        <key>googleapis.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>
        <key>localhost</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
        <key>127.0.0.1</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <false/>
</dict>

https://forums.developer.apple.com/thread/42555
https://cocoacasts.com/app-transport-security-has-blocked-my-request