text:
Q: Samba 4 joined to AD: can access to shares using FQDN but not using IP or aliases I installed a new Openmediavault 4 server which I joined to my Active Directory managed by two Samba 4 Domain Controllers.
Specifications:

*

*Active Directory domain MY.AD.DOMAIN managed by two Samba 4 domain controllers (server-z1.my.ad.domain (192.168.70.201) and server-z2.my.ad.domain (192.168.70.202)

*One file server with Samba Version 4.5.12-Debian running on Openmediavault 4.1.0-1 (Debian 9 based)

*The IP address of the file server is 192.168.70.171

*The FQDN of the file server is server-f1.my.ad.domain

*The file server has an alias server-f10.my.ad.domain configured in the DNS

*I want to access to the file server from clients using the IP address (\192.168.70.171), the FQDN (\server-f1.my.ad.domain) and the DNS alias (\server-f10.my.ad.domain).

I joined Openmediavault using SSSD following the guide at https://forum.openmediavault.org/index.php/Thread/18886-Guide-how-to-join-OpenMediaVault-3-x-in-an-Active-Directory-domain/, and I can list domain users using getent passwd even after reboot.
The problem I have is that I can access to Samba shares on Openmediavault connecting to it using the FQDN (\server-f1 or \server-f1.my.ad.domain), but not using the IP address (\192.168.70.171) or the DNS alias (\server-f10 or \server-f10.my.ad.domain).
When I access using the IP address or the DNS alias I get this errors on the Openmediavault system:
Mar 15 20:14:54 server-f1 smbd[21103]: [2018/03/15 20:14:54.956409,  2] ../source3/librpc/crypto/gse_krb5.c:229(fill_mem_keytab_from_secrets)
Mar 15 20:14:54 server-f1 smbd[21103]:   ../source3/librpc/crypto/gse_krb5.c:229: failed to fetch machine password
Mar 15 20:14:54 server-f1 smbd[21103]: [2018/03/15 20:14:54.957928,  2] ../source3/librpc/crypto/gse_krb5.c:229(fill_mem_keytab_from_secrets)
Mar 15 20:14:54 server-f1 smbd[21103]:   ../source3/librpc/crypto/gse_krb5.c:229: failed to fetch machine password
Mar 15 20:14:54 server-f1 smbd[21103]: [2018/03/15 20:14:54.961733,  1] ../lib/param/loadparm.c:1729(lpcfg_do_global_parameter)
Mar 15 20:14:54 server-f1 smbd[21103]:   WARNING: The "syslog" option is deprecated
Mar 15 20:14:54 server-f1 smbd[21103]: [2018/03/15 20:14:54.961772,  1] ../lib/param/loadparm.c:1729(lpcfg_do_global_parameter)
Mar 15 20:14:54 server-f1 smbd[21103]:   WARNING: The "syslog only" option is deprecated
Mar 15 20:14:54 server-f1 smbd[21103]: [2018/03/15 20:14:54.961984,  2] ../source3/param/loadparm.c:2685(lp_do_section)
Mar 15 20:14:54 server-f1 smbd[21103]:   Processing section "[homes]"
Mar 15 20:14:57 server-f1 smbd[21103]: [2018/03/15 20:14:57.049955,  1] ../auth/credentials/credentials_secrets.c:410(cli_credentials_set_machine_account_db_ctx)
Mar 15 20:14:57 server-f1 smbd[21103]:   Could not find machine account in secrets database: Failed to fetch machine account password for DOMAIN from both secrets.ldb (Could not find entry to match filter: '(&(flatname=DOMAIN)(objectclass=primaryDomain))' base: 'cn=Primary Domains': No such object: dsdb_search at ../source4/dsdb/common/util.c:4575) and from /var/lib/samba/private/secrets.tdb: NT_STATUS_CANT_ACCESS_DOMAIN_INFO
Mar 15 20:14:57 server-f1 smbd[21103]: [2018/03/15 20:14:57.050031,  0] ../source3/auth/auth_domain.c:121(connect_to_domain_password_server)
Mar 15 20:14:57 server-f1 smbd[21103]:   connect_to_domain_password_server: unable to open the domain client session to machine SERVER-Z1.MY.AD.DOMAIN. Error was : NT_STATUS_CANT_ACCESS_DOMAIN_INFO.
Mar 15 20:14:57 server-f1 smbd[21103]: [2018/03/15 20:14:57.081918,  1] ../auth/credentials/credentials_secrets.c:410(cli_credentials_set_machine_account_db_ctx)
Mar 15 20:14:57 server-f1 smbd[21103]:   Could not find machine account in secrets database: Failed to fetch machine account password for DOMAIN from both secrets.ldb (Could not find entry to match filter: '(&(flatname=DOMAIN)(objectclass=primaryDomain))' base: 'cn=Primary Domains': No such object: dsdb_search at ../source4/dsdb/common/util.c:4575) and from /var/lib/samba/private/secrets.tdb: NT_STATUS_CANT_ACCESS_DOMAIN_INFO
Mar 15 20:14:57 server-f1 smbd[21103]: [2018/03/15 20:14:57.081968,  0] ../source3/auth/auth_domain.c:121(connect_to_domain_password_server)
Mar 15 20:14:57 server-f1 smbd[21103]:   connect_to_domain_password_server: unable to open the domain client session to machine SERVER-Z1.MY.AD.DOMAIN. Error was : NT_STATUS_CANT_ACCESS_DOMAIN_INFO.
Mar 15 20:14:57 server-f1 smbd[21103]: [2018/03/15 20:14:57.110632,  1] ../auth/credentials/credentials_secrets.c:410(cli_credentials_set_machine_account_db_ctx)
Mar 15 20:14:57 server-f1 smbd[21103]:   Could not find machine account in secrets database: Failed to fetch machine account password for DOMAIN from both secrets.ldb (Could not find entry to match filter: '(&(flatname=DOMAIN)(objectclass=primaryDomain))' base: 'cn=Primary Domains': No such object: dsdb_search at ../source4/dsdb/common/util.c:4575) and from /var/lib/samba/private/secrets.tdb: NT_STATUS_CANT_ACCESS_DOMAIN_INFO
Mar 15 20:14:57 server-f1 smbd[21103]: [2018/03/15 20:14:57.110683,  0] ../source3/auth/auth_domain.c:121(connect_to_domain_password_server)
Mar 15 20:14:57 server-f1 smbd[21103]:   connect_to_domain_password_server: unable to open the domain client session to machine SERVER-Z1.MY.AD.DOMAIN. Error was : NT_STATUS_CANT_ACCESS_DOMAIN_INFO.
Mar 15 20:14:57 server-f1 smbd[21103]: [2018/03/15 20:14:57.112016,  0] ../source3/auth/auth_domain.c:184(domain_client_validate)
Mar 15 20:14:57 server-f1 smbd[21103]:   domain_client_validate: Domain password server not available.
Mar 15 20:14:57 server-f1 smbd[21103]: [2018/03/15 20:14:57.112060,  2] ../source3/auth/auth.c:315(auth_check_ntlm_password)
Mar 15 20:14:57 server-f1 smbd[21103]:   check_ntlm_password:  Authentication for user [my.user] -> [my.user] FAILED with error NT_STATUS_NO_LOGON_SERVERS
Mar 15 20:14:57 server-f1 smbd[21103]: [2018/03/15 20:14:57.112088,  2] ../auth/gensec/spnego.c:720(gensec_spnego_server_negTokenTarg)
Mar 15 20:14:57 server-f1 smbd[21103]:   SPNEGO login failed: NT_STATUS_NO_LOGON_SERVERS
Mar 15 20:14:57 server-f1 smbd[21104]: [2018/03/15 20:14:57.121674,  2] ../source3/librpc/crypto/gse_krb5.c:229(fill_mem_keytab_from_secrets)
Mar 15 20:14:57 server-f1 smbd[21104]:   ../source3/librpc/crypto/gse_krb5.c:229: failed to fetch machine password
Mar 15 20:14:57 server-f1 smbd[21104]: [2018/03/15 20:14:57.125426,  1] ../lib/param/loadparm.c:1729(lpcfg_do_global_parameter)
Mar 15 20:14:57 server-f1 smbd[21104]:   WARNING: The "syslog" option is deprecated
Mar 15 20:14:57 server-f1 smbd[21104]: [2018/03/15 20:14:57.125460,  1] ../lib/param/loadparm.c:1729(lpcfg_do_global_parameter)
Mar 15 20:14:57 server-f1 smbd[21104]:   WARNING: The "syslog only" option is deprecated
Mar 15 20:14:57 server-f1 smbd[21104]: [2018/03/15 20:14:57.125698,  2] ../source3/param/loadparm.c:2685(lp_do_section)
Mar 15 20:14:57 server-f1 smbd[21104]:   Processing section "[homes]"
Mar 15 20:14:57 server-f1 smbd[21104]: [2018/03/15 20:14:57.197432,  1] ../auth/credentials/credentials_secrets.c:410(cli_credentials_set_machine_account_db_ctx)
Mar 15 20:14:57 server-f1 smbd[21104]:   Could not find machine account in secrets database: Failed to fetch machine account password for DOMAIN from both secrets.ldb (Could not find entry to match filter: '(&(flatname=DOMAIN)(objectclass=primaryDomain))' base: 'cn=Primary Domains': No such object: dsdb_search at ../source4/dsdb/common/util.c:4575) and from /var/lib/samba/private/secrets.tdb: NT_STATUS_CANT_ACCESS_DOMAIN_INFO
Mar 15 20:14:57 server-f1 smbd[21104]: [2018/03/15 20:14:57.197476,  0] ../source3/auth/auth_domain.c:121(connect_to_domain_password_server)
Mar 15 20:14:57 server-f1 smbd[21104]:   connect_to_domain_password_server: unable to open the domain client session to machine SERVER-Z1.MY.AD.DOMAIN. Error was : NT_STATUS_CANT_ACCESS_DOMAIN_INFO.
Mar 15 20:14:57 server-f1 smbd[21104]: [2018/03/15 20:14:57.227212,  1] ../auth/credentials/credentials_secrets.c:410(cli_credentials_set_machine_account_db_ctx)
Mar 15 20:14:57 server-f1 smbd[21104]:   Could not find machine account in secrets database: Failed to fetch machine account password for DOMAIN from both secrets.ldb (Could not find entry to match filter: '(&(flatname=DOMAIN)(objectclass=primaryDomain))' base: 'cn=Primary Domains': No such object: dsdb_search at ../source4/dsdb/common/util.c:4575) and from /var/lib/samba/private/secrets.tdb: NT_STATUS_CANT_ACCESS_DOMAIN_INFO
Mar 15 20:14:57 server-f1 smbd[21104]: [2018/03/15 20:14:57.227250,  0] ../source3/auth/auth_domain.c:121(connect_to_domain_password_server)
Mar 15 20:14:57 server-f1 smbd[21104]:   connect_to_domain_password_server: unable to open the domain client session to machine SERVER-Z1.MY.AD.DOMAIN. Error was : NT_STATUS_CANT_ACCESS_DOMAIN_INFO.
Mar 15 20:14:57 server-f1 smbd[21104]: [2018/03/15 20:14:57.257018,  1] ../auth/credentials/credentials_secrets.c:410(cli_credentials_set_machine_account_db_ctx)
Mar 15 20:14:57 server-f1 smbd[21104]:   Could not find machine account in secrets database: Failed to fetch machine account password for DOMAIN from both secrets.ldb (Could not find entry to match filter: '(&(flatname=DOMAIN)(objectclass=primaryDomain))' base: 'cn=Primary Domains': No such object: dsdb_search at ../source4/dsdb/common/util.c:4575) and from /var/lib/samba/private/secrets.tdb: NT_STATUS_CANT_ACCESS_DOMAIN_INFO
Mar 15 20:14:57 server-f1 smbd[21104]: [2018/03/15 20:14:57.257051,  0] ../source3/auth/auth_domain.c:121(connect_to_domain_password_server)
Mar 15 20:14:57 server-f1 smbd[21104]:   connect_to_domain_password_server: unable to open the domain client session to machine SERVER-Z1.MY.AD.DOMAIN. Error was : NT_STATUS_CANT_ACCESS_DOMAIN_INFO.
Mar 15 20:14:57 server-f1 smbd[21104]: [2018/03/15 20:14:57.466888,  0] ../source3/auth/auth_domain.c:184(domain_client_validate)
Mar 15 20:14:57 server-f1 smbd[21104]:   domain_client_validate: Domain password server not available.
Mar 15 20:14:57 server-f1 smbd[21104]: [2018/03/15 20:14:57.466920,  2] ../source3/auth/auth.c:315(auth_check_ntlm_password)
Mar 15 20:14:57 server-f1 smbd[21104]:   check_ntlm_password:  Authentication for user [my.user] -> [my.user] FAILED with error NT_STATUS_NO_LOGON_SERVERS
Mar 15 20:14:57 server-f1 smbd[21104]: [2018/03/15 20:14:57.466943,  2] ../auth/gensec/spnego.c:720(gensec_spnego_server_negTokenTarg)
Mar 15 20:14:57 server-f1 smbd[21104]:   SPNEGO login failed: NT_STATUS_NO_LOGON_SERVERS
Mar 15 20:15:01 server-f1 CRON[21106]: (root) CMD (/usr/sbin/omv-mkrrdgraph >/dev/null 2>&1)

This is my Samba global configuration:
[global]
workgroup = DOMAIN
server string = %h server
dns proxy = no
log level = 3
syslog = 3
log file = /var/log/samba/log.%m
max log size = 1000
syslog only = yes
panic action = /usr/share/samba/panic-action %d
encrypt passwords = true
passdb backend = tdbsam
obey pam restrictions = no
unix password sync = no
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
pam password change = yes
socket options = TCP_NODELAY IPTOS_LOWDELAY
guest account = nobody
load printers = no
disable spoolss = yes
printing = bsd
printcap name = /dev/null
unix extensions = yes
wide links = no
create mask = 0777
directory mask = 0777
use sendfile = yes
aio read size = 16384
aio write size = 16384
local master = yes
time server = no
wins support = no
client signing = yes
client use spnego = yes
kerberos method = secrets and keytab
dedicated keytab file = FILE:/etc/krb5.keytab
password server = server-z1.my.ad.domain, server-z2.my.ad.domain
realm = MY.AD.DOMAIN
security = ads
template homedir = /home/my.ad.domain/users/%U
netbios name = server-f1
netbios aliases = server-f10

Could you help me please?
Thanks!

A: although this is an old(ish) post, I have just encountered this issue myself today so I am sharing my solution to it.
When joining a Machine to Active directory, two sets of SPN's are created for the generated computer account, one on the FQDN and the second on the Netbios name (aka server name)
Netbios names are limited to 15 characters. so In my case the server name was longer than 15 characters- so when I joined it to the domain, the generated SPN for the computer account was cut off from the 15th characters on. the SPN however with the FQDN was complete- so accessing the shares with the Server name failed while accessing with FQDN worked.
Fixing SPN in active directory worked for me and will likely work for you as well (though not for IP addresses- for that you need NTLM)
You might also need to reboot the server after adding SPN's to its computer account.

A: You cannot use the IP, because Kerberos is bound to FQDN only.


text:
Q: Change gnome-terminal title to reflect the current directory? I want to change the title of the gnome-terminal window to reflect the current directory.
Is there a way to do that? A script may be?
The "change terminal title" threads did not help much.
Manually when we use the command:
gnome-terminal --title=$PWD

it works, but a new terminal instance is created (as expected).
I want to be able to use the
--title=$PWD

with the cd command.
Is there a way to achieve that?

A: I'm doing it like this to override the cd command and set pwd into the title:
function title { echo -en "\033]2;$1\007"; }
function cd { dir=$1; if [ -z "$dir" ]; then dir=~; fi; builtin cd "$dir" && title `pwd`; }
cd `pwd`

I just threw this into my ~/.bash_aliases. You could probably tweak this to do what you want.

A: since gnome-terminal uses the same control commands as xterm this page might be helpful.
Xterm Title for bash and other shells
TL;DR:
add following to your .bashrc
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'

A: PROMPT_COMMAND='echo -ne "\033]0;$(basename ${PWD})\007"' will display only the current directory as the title

A: I'm not an expert but you should try to edit your ~/.bashrc file. If I understood your problem correctly you can change your .bashrc according to my (I'm using Ubuntu 12.04). The "old" line is commented out and the new one is below it (with additional comment).
case "$TERM" in
xterm*|rxvt*)
  # OLD PS1 directive
    #PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
  # NEW PS1 directive, shows only current directory name as terminal window name
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\W\a\]$PS1"
    ;;
*)
    ;;
esac

The result is that my terminal title is equal to my current directory title eg.
after cd Documents/projects my terminal title is projects (if file is open the terminal name is its name)

A: Updated Answer For White Space Problem by 'basename'
PROMPT_COMMAND='echo -ne "\033]0;$(basename "$(pwd)")\007"'

Upadate for answered Oct 23 '13 at 1:47 user2909452

A: I am using Gnome 42.3 (in Manjaro).
After some Google search, I was confused by the many answers so I tried to sort out what actually worked.
This works immediately in zsh:
precmd () {print -Pn "\e]0;%n@%m: %~\a"}

You can put in in ~/.zshrc.
precmd runs before every prompt, ensuring updating after cd.
This works immediately in bash:
PROMPT_COMMAND='echo -ne "\033]0;$(whoami):$(pwd)\007"'

You can put in in ~/.bashrc.
This feature is very useful
I have a deep file system with long directory names so if I display current directory in shell prompt then most of the terminal is filled with copies of the current directory name, so I need to have the information somewhere else and the menu bar is available therefore.
Also, I often work with many terminals, each one with different working directory, so, if the working directory is not displayed, I am lost.
Remark
I use X11, I doubt it will work with Wayland.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Create a map of only one country in DIVA-GIS I made a map of china with the places where the climate is suitable to plant Brussels sprouts.
The bounderies of China are in a shapefile. However the layer with the colormap showing where the climate is suitable goes beyond the boundaries of China and I only want a map of China. How can I fix this?
I'm completely new to GIS


text:
Q: override Asp.net Identity MVC5 I dont know asp.net identity work with EF, but I can override to I use Nhibernate.
currently I use custom roles by using filter in my project, I do not need to use anotations roles = "admin", because these roles are customized.
In asp.net identity will custom roles, or work the same way?
Anyone have a example?
Thanks

A: You can implement ASP.NET Identity using Nhibernate. You just have to implement the Identity core interfaces using NHibernate. Following post explains how you can create your custom storage provider http://www.asp.net/identity/overview/extensibility/overview-of-custom-storage-providers-for-aspnet-identity


text:
Q: How can I unlock single-user mode? I stupidly forgot the password to my MacbookPro. I have locked single user mode 2 weeks ago (for security reasons). How can I unlock single-user mode to get my password back?
Thanks guys :D

A: There is a way to geting if you follow this link to the Apple website where you will find information on resetting the administrators account password.
You will require a Mac OS install disc as close to the OS you are using as possible


text:
Q: Как правильно присвоить переменной значение? Всем привет, у меня такая задача вывести на экран текущую дату, я пытался сделать так:
int data = DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day;

Однако этот код делает не то что нужно, он складывает эти числа, а мне надо получить вот такой результат: 2012510, я попробовал сделать так:
string data = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();

Он выводит то что мне нужно, однако у меня в базе есть число такого вида: 201259 так вот мне надо от сегодняшнего числа отнять то что в базе(загнять данные в переменную я могу)
A: Да вы сделайте как вы делали во втором случае
Только потом переведите в число
Или например
string data = String.Format("{0:yyyyMd}", dt); // думаю лучше String.Format("{0:yyyyMMdd}", dt);
int dataInt = int.Parse(data);


text:
Q: Looking for tree organisation for database, based on one to many relationship both ways All the tree organisations for databases I've found documentation, papers or blogs about were built on a one parent node can have many children, but a child node can have only one parent, with a single original node - basis.
I am looking for a way to organise a database efficiently on a basis that a parent node can have many children, a child node can have many parents, and there are multiple original nodes.
The data is not going to change or move around much, but there will be insertions in the middle of the tree on a regular basis.
Any ideas or links to papers appreciated.

A: A tree is, by definition, one parent with many children, each of which can have many children. What you desire is a generalised network, not a tree.
There are many DBMS products which present a graph (i.e. generalised network) data model. Both items and the relationships between items are first-class objects. Typically both can have arbitrary labels and attributes. These products are also optimised for relationship-based processing such as friends-of-friends, shortest path or cluster detection. If navigating the network is more important for your use case than OLTP point updates or calculating bulk aggregates then one of these DBMS may suit.
From comment:

Is there a way of having a direction to this network though ? It's for storing school programme data, and the prerequisite knowledge for a certain course for example. (And that course can have many prerequisites and can be prerequisite to others, but there is a direction to the structure.)

All graph DBMSs implemented directed graphs. This means there is a "from" and a "to" in each relationship. This is analogous to, but different from, the "parent" and "child" in a relational database foreign key. A relationship's direction is set when the relationship is written to the DB. Relationships can be read in either direction, however, much like a SQL query can follow a foreign key to find the children given the parent, or the parent given a child.
A hypothetical graph for your school prerequisites might look like:
Basic math   <-- requires --  Advanced math  <--- requires ---¬
        ^                                                     |
        └-------  requires -----------¬                    Medicine
                                      |                       |
Basic chemistry  <-- requires --  Advanced chemistry  <-- requires

Medicine has two prerequisites - advanced math & advanced chemistry. Basic math is a prerequisite for two other subjects.


text:
Q: Find all irreducible polynomials of degrees $2$ and $3$ in $\Bbb{Z}_{2}[x]$.
Find all irreducible polynomials of degrees $2$ and $3$ in $\Bbb{Z}_{2}[x]$.

I tried to follow (https://math.stackexchange.com/q/32416)'s answer but this part in their answer I do not understand:

A polynomial $p(x)$ of degree $2$ or $3$ is irreducible if and only if it does not have linear factors.  Therefore, it suffices to show that $p(0) = p(1) = 1$.  This quickly tells us that $x^2 + x + 1$ is the only irreducible polynomial of degree $2$.  This also tells us that $x^3 + x^2 + 1$ and $x^3 + x + 1$ are the only irreducible polynomials of degree $3$.

The part I don't understand is "it suffices to show $p(0)=p(1)=1$". Could someone please explain what this means and how this finds the irreducible polynomials?

A: Transform the "if and only if" statement as follows.

A polynomial $p(x)$ of degree $2$ or $3$ is reducible if and only if it has linear factor.

By the factor theorem,

$p(x)$ has linear factor iff $p(0) = 0$ or $p(1) = 0$.

Take the negation on both sides.

$p(x)$ has no linear factor iff $p(0) \ne 0$ and $p(1) \ne 0$.

Since we are in $\Bbb{Z}_2$, the RHS can be simply written as follows.

$p(x)$ has no linear factor iff $p(0) = p(1) = 1$.

In $\Bbb{Z}_2[X]$,

*

*$p(0) = 1$ iff the constant term is $1$.

*$p(1) = 1$ iff the polynomial contains odd number of terms.

This helps us to select the irreducible polynomials of degree $\le 3$ by eliminating those with even number of terms and/or no constant term.


text: Q: How to define target in multilayer perceptron? I want to do a word sense disambiguation project with multi layer perceptron in Persian language. I have some files, each for an ambiguated word. Some words have 2 senses, some 3 and some more. The files contain a lot of sentences and in front of each sentence I put a tab and then the proper sense of the ambiguated word. Then I extracted 1000 most frequent words of the file and made a binary vector (term document). (after omitting stop words and punctuation) If each word in each line is among the 1000 most frequent words, it puts 1 in the vector, unless it puts 0. So for example if a file has 500 sentence each in a line, the result is 500 lines of 1 and 0 and the columns count, is 1000 and a column for the tag of the sense. These are the input of the multi layer perceptron. Now the question is, 1) what is the target? How should I define it and what value it takes? 2) how many neurons does the output should have? 3) Is this XOR problem or And problem? (the number of hidden layers are 2, momentum is 0.02, and training iteration is 500)


text:
Q: Unable to Understand the meaning of a term in question in book Richard Brualdi Introductory Combinatorics in Chapter Polya Counting I am self studying Combinatorics from Richard Brualdi and I am unable to understand  a term in the following exercise on page 577 of 5th edition of the book:

Determine the symmetry group and corner symmetry group of an equilateral triangle .

I am unable to understand what author means by symmetry group and unfortunately unable to find it in the text.
While the meaning of term corner symmetry is clear that author means symmetries obtained by naming corners 1,2,3 and then rotational and reflection symmetry.
Edit 1-> Notation of Will Orrick
Can someone please tell what author means here?
I shall be really thankful.

A: I have used Brualdi's book in the past, but do not currently have access to a copy.  Google Books shows me three relevant excerpts from the 2nd edition.  The first is on page 554:

As a result a set of permutations which results by considering all the symmetries of a figure is automatically a permutation group.  Thus we have a corner-symmetry group, an edge-symmetry group, a face-symmetry group and so on.

Servaes has now posted a very useful answer that includes a longer excerpt containing the same text.
The second is a pair of exercises on page 590:

*Determine the symmetry group and corner-symmetry group of a triangle which is neither equilateral nor isosceles.

*Determine the symmetry group of a regular tetrahedron.  (Hint: There are 12 symmetries.)

The third, on page 609, is an apparent answer to an exercise:

*The symmetry group contains only the identity motion.  The corner symmetry group contains only the identity permutation of the three corners.

This looks like the answer to Exercise 5 mentioned above, although the number of the problem does not correspond.
The quotation in Servaes's answer confirms that the symmetry group of a figure is the set of geometric motions that map the figure to itself.  You will have to find the relevant passages in the book that define whether these motions include rotations and reflections or rotations only.  (I would start by looking for the text quoted above.  The surrounding text may contain useful information.)  My guess, based on the hint to Exercise 6, is that it is rotations only.
I will discuss the tetrahedron because it provides a good example of why it is necessary to distinguish the symmetry group, corner-symmetry group, edge-symmetry group, and face-symmetry group, even though all four groups are isomorphic in this case.  Assuming we are concerned with rotations only,  the symmetry group of the regular tetrahedron consists of the identity motion, eight rotations of either $120^\circ$ or $240^\circ$ about the four axes joining a corner to the center of the opposite face, and three $180^\circ$ rotations about the axes joining the centers of opposite edges.  To fully describe the group, the rules for composing these motions need to be stated.  Note that a set of motions forms a group in the algebraic sense when it is closed under composition of motions and contains inverses of all motions.
One typically gives names to each motion.  Label the tetrahedron vertices with the numbers $1$ through $4$, with $2$ $3$, and $4$ in counterclockwise order as viewed from vertex $1$.  You might use $r_1$ to mean a $120^\circ$ clockwise rotation about the axis through vertex $1$ (as viewed from above).  Then the $240^\circ$ rotation about this axis would be $r_1^2$.  Similarly, you might use $f_1$ for the $180^\circ$ rotation about the axis through the center of edge $1$-$4$ and the center of edge $2$-$3$.  The relations $r_1^3=e$ and $f_1^2=e$ hold, where $e$ is the identity motion (no motion at all).  Also $r_1f_1$ (the operation of first doing $r_1$, then doing $f_1$) equals $r_2$ (the $120^\circ$ clockwise rotation about the axis through vertex $2$, viewed from a vantage point above vertex $2$).  Two other $120^\circ$ rotations, $r_3$ and $r_4$ are defined similarly, as are two other $180^\circ$ rotations, $f_2$, about the axis joining the centers of edges $2$-$4$ and $1$-$3$, and $f_3$, about the axis going the centers of edges $3$-$4$ and $1$-$2$.  Hence the symmetry group is the set of motions
$$
\{e,r_1,r_1^2,r_2,r_2^2,r_3,r_3^2,r_4,r_4^2,f_1,f_2,f_3\}
$$
with composition of motions the group operation.  By a detailed analysis, one can work out the "multiplication table" for the group, which shows how all $12$ motions compose with each other.
The corner-symmetry group would be obtained by writing down the permutations of the vertices that correspond to each of the motions listed above.  The permutations corresponding to $r_1$, $f_1$, and $r_2$ are $(23)(24)$, $(14)(23)$, and $(14)(13)$.  The symmetry group and the corner symmetry group are clearly isomorphic.  The corner-symmetry group acts on a four-element set, the set $\{1,2,3,4\}$ of vertex labels.  The symmetry group, in contrast, acts on the geometrical object itself.
One can define the edge symmetry group in a similar way by labelling edges and determining how each of the motions permutes the edges.  Let edges $1$-$4$, $2$-$4$, $3$-$4$, $2$-$3$, $1$-$3$, and $1$-$2$ be labeled $a$, $b$, $c$, $x$, $y$, and $z$.  Then $r_1$ corresponds to the permutation $(az)(ay)(bx)(bc)$, $f_1$ to the permutation $(by)(cz)$, and $r_2$ to the permutation $(ac)(ay)(bx)(bz)$.  The edge-symmetry group acts on a six-element set, the set $\{a,b,c,x,y,z\}$ of edge labels.
Likewise for the face-symmetry group, which acts on the four-element set of face labels.  If each face is labeled with the same label as the vertex opposite, the face-symmetry group is identical to the corner-symmetry group and both are identical to the alternating group $A_4$ (consisting of all even permutations) on the set $\{1,2,3,4\}$.
All four groups are, in fact, isomorphic to each other, meaning, for example, that if each element in the multiplication table of the symmetry group is replaced with the corresponding element of the corner-symmetry group, the result is the correct multiplication table for the corner-symmetry group.  This raises the question: will the permutation group associated with any set of geometrical features of the tetrahedron will be isomorphic to the symmetry group?  The answer is no, as a trivial example shows: the body-symmetry group consists only of the identity motion since the tetrahedron has only one three-dimensional "facet", which always maps to itself.  A more interesting example comes from the set of three $180^\circ$ rotation axes mentioned in connection with the rotations $f_1$, $f_2$, and $f_3$.  If these axes are called $I$, $J$, and $K$, we can ask how they permute among themselves under the $12$ geometric moves in the symmetry group.  You can check that the three $180^\circ$ rotations, as well as the identity motion, all produce the identity permutation.  The rotations $r_1$, $r_2$, $r_3$, and $r_4$ all produce the permutation $(IK)(IJ)$, while their squares all produce the permutation $(IJ)(IK)$.  These are the cyclic permutations of $I$, $J$, and $K$ and therefore the "$180^\circ$-axis-symmetry group" is isomorphic to the cyclic group of order $3$.  There is a homomorphism of the symmetry group of the tetrahedron to this group, but not an isomorphism.
I'll leave it for you to work out the symmetry group and corresponding corner symmetry group for the equilateral triangle.  Assuming only rotations are to be considered, this is a group with three elements.  The symmetry group, corner symmetry group, and edge symmetry group are all isomorphic in this case, but the face symmetry group is not, as it's the group containing only the identity permutation.

A: On page 558 of the fifth edition of the book:

Let $\Omega$ be a geometrical figure. A symmetry of $\Omega$ is a (geometrical) motion or congruence that brings the figure $\Omega$ onto itself.

Hence the symmetry group of an equilateral triangle is the group of symmetries that map the equilateral triangle onto itself. Further in the same paragraph:

Hence we conclude that the symmetries of $\Omega$ act as a permutation group $G_C$ on its corners, a permutation group $G_E$ on its edges, and, in the case where $\Omega$ is three-dimensional, a permutation group $G_F$ on its faces. As a result, a set of permutations that results by considering all the symmetries of a figure is automatically a permutation group. Thus, we have a corner-symmetry group, an edge-symmetry group, a face-symmetry group, and so on.

Hence the corner symmetry group is the group of symmetries of the corners obtained by the action of the symmetry group of $\Omega$ on the corners.

A: From your description, this is what I think the author means:
Symmetric group (of order 3):  All possible permutations or 3 elements.  For example if you have elements a, b, and c, then the possible permutations are abc, acb, bac, bca, cab, and cba.  Standard notation for this group is $S_3$.
ref: https://en.wikipedia.org/wiki/Symmetric_group
"Corner symmetry group" (aka Dihedral Group of a regular triangle):  All reflections and rotations of polygon (triangle) with uniquely labelled corners.  The Dihedral Group of a regular triangle would generally be known as the Dihedral Group of order 6, since there are 6 distinct results for any combination of rotation and reflection about an axis of symmetry.  Standard notation for this group is $D_3$.
ref: https://en.wikipedia.org/wiki/Dihedral_group


text:
Q: Wrong result from select When I select something from the database like this it give me a wrong result:
SELECT *
FROM Werkwoord_spelling
WHERE tijd = 'tt'
AND soort = 'sw'
AND vorm = 'i'
OR vorm = 'j'
ORDER BY RAND()
LIMIT 20

Here some rows from the result:
 527  Afgelopen zomer leefde jij al twaalf jaar. vt zw j leven leefde
 1346 Stop je nog met kletsen? tt zw j stoppen Stop

You can see that I have an 'vt' in row 527, but I only ask for rows with 'tt' as in row 1346.
How can I solve this?

A: you need to add parenthesis for your logical group.
i think the query is this
SELECT *
FROM Werkwoord_spelling
WHERE tijd = 'tt'
AND soort = 'sw'
AND (vorm = 'i'OR vorm = 'j')
ORDER BY RAND()
LIMIT 20

A: That is because you have an or in your where.
Change to:
SELECT * FROM Werkwoord_spelling WHERE tijd = 'tt' AND soort = 'sw' AND (vorm = 'i' OR vorm= 'j' ORDER BY RAND() LIMIT 20)

and it works fine.

A: Note that AND has precedence over OR, so your WHERE condition equivalents to:
WHERE (tijd = 'tt' AND soort = 'sw' AND vorm = 'i') OR vorm = 'j'

I guess it has to be:
WHERE tijd = 'tt' AND soort = 'sw' AND (vorm = 'i' OR vorm = 'j')

So use brackets.

A: Rewrite your query using a couple parenthesis like so:
SELECT * FROM Werkwoord_spelling
WHERE tijd = 'tt' AND soort = 'sw' AND vorm in ('i', 'j')
ORDER BY RAND() LIMIT 20

This way, you are telling the database to give you records if all of the conditions are met:

*

*tijd is tt

*soort is sw

*vorm is either i or j

In your query, the ORs position was an issue. The database was retrieving records that matched all of the conditions below

*

*tijd is tt

*soort is sw

*vorm is either i or j

*if all of the 3 above couldn't be matched, that's okay. Give me record if it has vorm = 'j'


text:
Q: How can I detect if docker for mac is installed? I have some makefiles where most of the stuff should run without configuration. These makefiles have used docker-machine in the past.
Is there a way to detect in bash if the user is using docker desktop for mac instead of docker-machine ?

A: The cleanest way I found so far is:
[[ $(docker version --format "{{.Server.KernelVersion}}") == *-moby ]]

A: The best way is to check for the existence of the DOCKER environment variables:

*

*DOCKER_HOST

*DOCKER_MACHINE_NAME

*DOCKER_TLS_VERIFY

*DOCKER_CERT_PATH

All four of these are set when eval $(docker-machine env) is run and are required for use with docker-machine.
The beta does not require any of them being set and in fact requires you to unset them in order to function properly.

You can also do a check in the docker info command looking for "moby" (the name of the docker for mac VM):
docker info | grep -q moby && echo "Docker for mac beta" || echo "Not docker for mac beta"

This is going to be dependent on consistency in the docker info results, however.

A:
These makefiles have used docker-machine in the past.

If possible stop using Machine. Recent Docker for Mac installation instructions note Docker Toolbox but suggest it's legacy now. Consider refactoring your scripts to check for Docker Desktop instead:
if [[ -n "$(docker info --format '{{.OperatingSystem}}' | grep 'Docker Desktop')" ]]; then
    echo "Docker Desktop found. Skipping installation ..."
else
    echo "WARNING! Docker Desktop not installed:"
    echo "  * Install docker desktop from <https://docs.docker.com/docker-for-mac/install/>"
fi

Explaination

*

*--format '{{.OperatingSystem}}' is a Go template which queries from docker info.

*grep 'Docker Desktop' is what you should be looking for if you're running Docker Desktop.

*-z returns true if the length of the string is 0 (from man bash).

*$(...) is command substitution which executes the grep without outputting to stdout.

Hat tip to Joe for his answer which cleanly filters the output from docker info. And if you refactor to stop using Machine you can consider removing VirtualBox from your environment setup and leverage the performance gains of xhyve – included with Desktop.

A: You can open the terminal and just type docker info and it will give you the details about the docker if it is installed on your mac.
If it says command not found : docker then it means you don't have docker installed on your mac.

A: You can do the following:
docker info --format "{{.OperatingSystem}}" | grep -q "Docker for Mac"

Check the exit code via:
if [[ $? -eq 0 ]]; then
    echo "Docker for Mac!"
else
    echo "Something else"
fi


text:
Q: how to count the frequency of a given word in python I want to find the frequency of the words "je" and "nous" in 75 texts.
In fact, I know how to make frequency lists at one time by importing os and so on. But this time, what I need, it's just the respective frequency of the two words.
And I tried to change the code of making frequency lists to achieve my goal but failed.
here is a part of my code:
wordlist_freq={}
for word in all_words:
    if word in wordlist_freq.keys():
        wordlist_freq[word] +=1
    else:
        wordlist_freq[word] =1

freq = {}

freq['je']=wordlist_freq['je']
freq['nous']=wordlist_freq['nous']

output[name]=wordlist_freq.items()

and it shows a KeyError: 'je'

I really can't understand it and my current idea is too stupid because I want to make a frequency list and then extra the frequency of "je" and "nous". There should be some easier solutions!!!
Please help me~ Thank you!!!

A: You can use Counter from collections for this
from collections import Counter

word_list = ["hi", "hi", "je", "nous", "hi", "je", "je"]
wordlist_freq = Counter(word_list)

In order to get the frequency of a word, you can use get method like this
wordlist_freq.get("je", 0)

I prefer using get instead of square brackets because get can return a default value when the word is absent in the Counter object.
If you choose not to use Counter and want to use the loop you shared in Q, you can still do that. But make sure that you get method on the dict to handle the cases where the word is not present in the dict.


text:
Q: Junk printing after linked list head deletion Each class room student(aluno) represents a linked list node.
After deleting by student name, my print function prints junk on the removed students former "position".
[EDIT] Added full code.
Full code:
#include <stdio.h>
#include <stdlib.h>

struct student{
    char *name;
    int number;
    struct student *next;
};

struct student *constructor(char *name, int number){
    struct student *newNode = (struct student *)malloc(sizeof(struct student));
    newNode->name = name;
    newNode->number = number;
    newNode->next = NULL;

    return newNode;
}

struct student *newStudent(struct student *node, char *name, int number){
    if (node == NULL)
        constructor(name, number);

    struct student *p = node;

    while(p->next != NULL) p = p->next;
    p->next = constructor(name,number);

    return node;
}

struct student *removeAluno(struct student *node, char *name){
    struct student *p = node;

    if (strcmp(p->name,name) == 0){
        struct student *devolver = p->next;
        free(p);
        return devolver;
    } //Removes head

    while(p->next != NULL){

        if (strcmp(p->next->name,name) == 0){

            if (p->next->next == NULL){ //Removes last element
                struct student *remover = p->next;
                p->next = NULL;
                free(remover);
            }
            else{ //Removes any element between head and last
                struct student *remover = p->next;
                p->next = p->next->next;
                free(remover);
            }

        }
        else
            p = p->next;
    }

    return p;
}

void printClass(struct student *students){
    struct student *p = students;

    while(p->next != NULL){
        printf("\nNome: %s, Numero: %d",p->name,p->number);
        p = p->next;
    }
    printf("\nNome: %s, Numero: %d",p->name,p->number);
    printf("\n");
}

int main(){
    struct student *a = constructor("Michael",15);
    newStudent(a,"John",14);
    newStudent(a,"Jack",13);
    printClass(a);
    removeAluno(a,"Michael");
    printClass(a);
    removeAluno(a,"John");
    printClass(a);
    removeAluno(a,"Jack");
    printClass(a);
    return 0;
}

My output:
//list after inserting Michael, John, Jack (in this order)
Nome: Michael, Numero: 15
Nome: John, Numero: 14
Nome: Jack, Numero: 13
//list after removing Michael
o, Numero: 7283408 //junk
Nome: John, Numero: 14
Nome: Jack, Numero: 13
//list after removing John
o, Numero: 7283408 //junk
Nome: Jack, Numero: 13
//list after removing Jack
Nome: ╚6o, Numero: 7283408 //junk

A: Your functions return struct pointers but in main you do not use their return. What you need to do is this in main-
a=newStudent(a,"John",14);

same for other functions .

A: You can use pointer to pointers:
For example, yo can change your remove function to:
struct student *removeAluno(struct student **node, char *name){
    struct student *p = *node;

    if (strcmp(p->name,name) == 0){
        struct student *devolver = p->next;
        free(p);

        *node = devolver;

        return devolver;
    } //Removes head

    while(p->next != NULL){

        if (strcmp(p->next->name,name) == 0){

            if (p->next->next == NULL){ //Removes last element
                struct student *remover = p->next;
                p->next = NULL;
                free(remover);

                *node = NULL;
            }
            else{ //Removes any element between head and last
                struct student *remover = p->next;
                p->next = p->next->next;
                free(remover);
            }

        }
        else{
            p = p->next;

        }
    }

    return p;
}

And your print function, to avoid problems when the list is empty, can change to:
void printClass(struct student *students){
    if(students==NULL)
        return;

    struct student *p = students;

    while(p->next != NULL){
        printf("\nNome: %s, Numero: %d",p->name,p->number);
        p = p->next;
    }
    printf("\nNome: %s, Numero: %d",p->name,p->number);
    printf("\n");
}

I have tried it, and get this output:
Nome: Michael, Numero: 15
Nome: John, Numero: 14
Nome: Jack, Numero: 13

Nome: John, Numero: 14
Nome: Jack, Numero: 13

Nome: Jack, Numero: 13


text:
Q: How to wake up an app on push notification when an app is in background Is there any way to launch an app when push notification is received from background?
I want to bring up a modal page (alert page with some info) when push notification is received.
I have tried to use the plugin https://github.com/katzer/cordova-plugin-background-mode, but no luck. (wakeUp and unlock function do not work)


text:
Q: How to aggregate and insert records in the dataframe based on condition?    COUNTRY   DATE         COMPANY   ITEM    SALES
0  TAIWAN   01-02-2019    CHINAM    TOY      2500
1  TAIWAN   05-02-2019    CHINAM    TOY      2500
2  TAIWAN   26-02-2019    CHINAM    TOY      2500
3  TAIWAN   01-02-2019    CHINAM    CERAMIC  500
4  TAIWAN   05-02-2019    CHINAM    CERAMIC  5500
5  TAIWAN   26-02-2019    CHINAM    CERAMIC  6500
6  TAIWAN   01-02-2019    CHINAM    KITCHEN  4500
7  TAIWAN   05-02-2019    CHINAM    KITCHEN  4500
8  TAIWAN   26-02-2019    CHINAM    KITCHEN  2300

I NEED TO AGGREGATE DATA BASED ON SOME CONDITION:
IF THE LAST DAY OF MONTH IN THE DATA FRAME IS SHORTER THAN THE ACTUAL LAST DAY OF MONTH i.e 28-02-2019, THEN I NEED TO AGG. DATA ON ITEM LEVEL AND INSERT THAT RECORD IN THE DATA FARME.
SUPPOSE IN MY DF LAST DATE 26-02-2019 BUT ACTUAL CALENDAR LAST DATE IS 28-02-2019.
IN THIS CONDITION I NEED TO AGGREGATE ON 'ITEM' LEVEL & INSERT RECORD IN THE DF ELSE DO NOTHING.
OUTPUT :
   COUNTRY   DATE         COMPANY   ITEM    SALES
0  TAIWAN   01-02-2019    CHINAM    TOY      2500
1  TAIWAN   05-02-2019    CHINAM    TOY      2500
2  TAIWAN   26-02-2019    CHINAM    TOY      2500
3  TAIWAN   01-02-2019    CHINAM    CERAMIC  500
4  TAIWAN   05-02-2019    CHINAM    CERAMIC  5500
5  TAIWAN   26-02-2019    CHINAM    CERAMIC  6500
6  TAIWAN   01-02-2019    CHINAM    KITCHEN  4500
7  TAIWAN   05-02-2019    CHINAM    KITCHEN  4500
8  TAIWAN   26-02-2019    CHINAM    KITCHEN  2300
9  TAIWAN   01-02-2019    CHINAM    TOY      7500
10 TAIWAN   05-02-2019    CHINAM    CERAMIC  12500
11 TAIWAN   05-02-2019    CHINAM    KITCHEN  11300

A: My first thought (assuming this solution will be used on multiple years so you can't just group by month) is splitting the date into three columns: month, day, year. Then something like this group by:
df.groupby(["month", "year"]).agg({ITEM: lambda x: np.nan if is_last_day(x["day"].max(), x["month"], x["year"]) else aggregating_method(x["ITEM"]) } )

Where the is_last_day method could be done nicely with date time methods, and aggregating method is however you want to aggregate. Sorry if the code isn't exactly working, as I couldn't test it, but hopefully it gives an idea of the thought process. Let me know if you have any other questions, or if I completely misunderstood your question. Good luck!

A: IIUC,
df_sums = (df.groupby(['COUNTRY', 'COMPANY', 'ITEM'])[['DATE','SALES']]
             .agg(DATE=('DATE', lambda x: x.iloc[-1] + pd.Timedelta(days=7)),
                  SALES=('SALES', 'sum')).reset_index())

pd.concat([df, df_sums])

Output:
  COUNTRY       DATE COMPANY     ITEM  SALES
0  TAIWAN 2019-01-02  CHINAM      TOY   2500
1  TAIWAN 2019-05-02  CHINAM      TOY   2500
2  TAIWAN 2019-02-26  CHINAM      TOY   2500
3  TAIWAN 2019-01-02  CHINAM  CERAMIC    500
4  TAIWAN 2019-05-02  CHINAM  CERAMIC   5500
5  TAIWAN 2019-02-26  CHINAM  CERAMIC   6500
6  TAIWAN 2019-01-02  CHINAM  KITCHEN   4500
7  TAIWAN 2019-05-02  CHINAM  KITCHEN   4500
8  TAIWAN 2019-02-26  CHINAM  KITCHEN   2300
0  TAIWAN 2019-03-05  CHINAM  CERAMIC  12500
1  TAIWAN 2019-03-05  CHINAM  KITCHEN  11300
2  TAIWAN 2019-03-05  CHINAM      TOY   7500


text:
Q: JAXB unmarshal to concrete class without using xsi:type in xml but using actual concrete class name I wonder if someone can help me with a JAXB problem.
If I have an abstract class with 2 concrete implementations:  For example (I have left out most of the markup/xml for brevity):
public abstract class Vehicle{}

public class Car extends Vehicle{}

public class Van extends Vehicle{}

Is there a way to have the xml below unmarshall correctly to the appropriate concrete class
<request>
  <car>...</car>
</request>

rather than the following:
<request>
  <vehicle xsi:type="car"></vehicle>
</request>

The reason I need this is to be backward compatible with our already published API.
Thanks in advance.

A: I have just answered in russian speaking community on similar question. Probably you looking for something like that:
@XmlElements({
      @XmlElement(name = "car", type = Car.class),
      @XmlElement(name = "van", type = Van.class)
})
public List<Vehicle> getVehicles() {
      return vehicles;
}

Some quick example:
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.*;
import java.io.StringReader;
import java.util.List;

public class Test {

    public static void main(String... args) throws JAXBException {
        String xmldata = "<request><car></car><van></van></request>";
        StringReader reader = new StringReader(xmldata);

        JAXBContext jaxbContext = JAXBContext.newInstance(Request.class);
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

        Request request = (Request) unmarshaller.unmarshal(reader);

        for (Vehicle object : request.getVehicles()) {
            System.out.println(object.getClass());
        }
    }
}

@XmlRootElement(name = "request")
class Request {
    private List<Vehicle> vehicles;

    @XmlElements({
            @XmlElement(name = "car", type = Car.class),
            @XmlElement(name = "van", type = Van.class)
    })
    public List<Vehicle> getVehicles() {
        return vehicles;
    }

    public void setVehicles(List<Vehicle> vehicles) {
        this.vehicles = vehicles;
    }
}

abstract class Vehicle {
}

class Van extends Vehicle {
}

class Car extends Vehicle {
}

The output will be:
class Car
class Van

UPD:
Update after comment. For single entry it will work anyway just remove List:
@XmlRootElement(name = "request")
class Request {
    private Vehicle vehicles;

    @XmlElements({
            @XmlElement(name = "car", type = Car.class),
            @XmlElement(name = "van", type = Van.class)
    })
    public Vehicle getVehicles() {
        return vehicles;
    }

    public void setVehicles(Vehicle vehicles) {
        this.vehicles = vehicles;
    }
}

Hope this will help.

A: You can use annotations and annotate the concrete implementations. In this case @XmlType() above Car or Van. This way you will keep your xml generic.


text:
Q: Why ActiveModel::ForbiddenAttributesError error? Here's my model
class User < ActiveRecord::Base
  def self.from_omniauth(auth)
    where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
      user.provider = auth.provider
      user.uid = auth.uid
      user.name = auth.info.name
      user.oauth_token = auth.credentials.token
      user.oauth_expires_at = Time.at(auth.credentials.expires_at)
      user.save!
    end
  end
end

Here's my controller
class SessionsController < ApplicationController
  def create
    user = User.from_omniauth(env["omniauth.auth"])
    session[:user_id] = user.id
    redirect_to root_url
  end

 def destroy
   session[:user_id] = nil
   redirect_to root_url
 end
 end

I tried looking into the database if any duplicate entry has been made. But no. Please let me know if you can help.

A: Just change the where(condition) to:
where(provider: auth.provider, uid: auth.uid)

The 1st approach fails because of the method #permitted? which AR calls (if defined) to sanitize the attributes.
> h = auth.slice(:provider, :uid)
> h.class
=> OmniAuth::AuthHash < Hashie::Mash
> h.permmitted?
> false

However, a simple Hash will not have #permitted? defined, thus it will just continue:
> h = { provider: auth.provider, uid: auth.uid }
> h2.permitted?
NoMethodError: undefined method `permitted?' for {:provider=>"facebook", :uid=>"XXXX"}:Hash

Reference: https://github.com/rails/rails/blob/master/activemodel/lib/active_model/forbidden_attributes_protection.rb#L19)


text:
Q: Type mismatch when trying to replace I have a variable age_n .  it is numeric (float).
for exampel if i type
    count if age_n>65
If gives me 77.
So then if I type
    replace age_n = "0" if (age_n < "65")
it says type mismatch.
I have tried putting 65 without quotes and it still doesn't work.

A: Another form to do it is
recode age_n (0/65=0 "0") (66/150=1 "over 65")

So you have a dummy with your requirement (from 0 to 65, values change to 0, appearing a "0" in the table; from 66 to 150, values change to 1, appearing this time "over 65" in the table). If you want to maintain values of age_n,
gen age_n2=age_n

and do the process with age_n2 instead of age_n.


text:
Q: Is there an efficient way to perform this ActiveRecord query? I have several models: Tickets, Seats, Sections, TicketTypes.
Ticket belongs_to Seat
Seat belongs_to Section
Section belongs_to a TicketType
and TicketType holds all the price information.
At the moment, to get some of the price information I need to do ticket.seat.section.ticket_type.things_i_need which selects seat, then executes another select statement for the section, then another for the ticket type.
Is there a more efficient way to get the information I need? I tried using joins, merge, and includes but couldn't get the information I need.

A: I'm not sure if you've tried this but I would think it would be:
@ticket = Ticket.includes(seat: { section: [:ticket_type] }).find(params[:id])
@ticket.seat.section.ticket_type.things_i_need


text:
Q: How to create popup media player on listview in android? I have a songs list-view and I want to show pop-up media player when item in list-view clicked. A pop-up is a activity. But I don't know how to show pop-up activity on list-activity.Please can anybody help me ?

A: One way is to use an ACTION_VIEW intent to open the video in Android's video player. (If you have other apps installed that can also play video the user will be prompted to choose one, and they can set a default to save being prompted every time.)
So for example, in your ListActivity subclass's onCreate method:
getListView().setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        try {
            Intent in = new Intent(Intent.ACTION_VIEW);
            in.setDataAndType(Uri.parse("http://example.org/video.mp4"), "video/*");
            startActivity(in);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
});


text:
Q: Capacitance and conductors The capacitance of a sphere of radius a is : $C=Q/V=1/4\pi\epsilon_0a$. If the charge density is assumed on its surface $Q=\rho_s4\pi a^2$, this gives a charge density $\rho_s$:
$\rho_s = \frac{\epsilon_0}{a} V ~~(C/m^2)$
The smaller the sphere, the smaller the charge density to obtain a uniformm potential V, hence the smaller the capacitance.
However, this analysis is valid regardless of the nature of the material which could also be an insulator. Is the capacitance a purely geometrical feature?
Where does the nature of the material comes into account? Is it related to the amount of work necessary to drag the electrons from the material to its surface? Where conductors would require less work than insulator?

A: Your formula for the capacitance of the sphere, i.e., the relation between the voltage $V$ and the charge $Q$ on its surface,  is correct and identical to the case of a conductive sphere because you assume that the charge is evenly distributed with density $\rho_s$ on the surface. Due to Gauss law, the formula would also be correct if the charge were a point charge in the center of the sphere or distributed in the sphere with spherical symmetry. This is completely independent of the material. In general, however, you need a conductor for a capacitor. If the sphere were an insulator, the charge would not (re-) distribute evenly over (the surface of) the sphere when charge is transported to or from a point on the surface. Thus the capacitance formula would not be valid any longer and you could not use the sphere as a capacitor because you could not charge and discharge it into a circuit easily.

A: Indeed capacitance is a purely geometric feature! You are spot on in your statement that indeed capacitance is related to the work required to drag an electron from one surface to another. This is seen from the definition of potential as work per unit charge. That is, $$C=\frac{Q}{V}=\frac{Q}{W/q_0} \Rightarrow C\propto\frac{1}{W}.$$ Hence we can think of the capacitance (per unit test charge) as being an inverse measure of how much work has to be done to assemble the charges. Now since $W$ itself is always proportional to the total charge $Q$, you can count that it will always cancel, leaving nothing but factors that depend on the geometry of the configuration.
As for the question about the material; people would never use insulators themselves as capacitors in the sense that I believe you are suggesting. Rather the surfaces (or "plates") that bound our region where the electric field is, are always made of conducting material. What usually is the case is that we insert an insulating material between the two surfaces. What this does is reduce the electric field between the plates and thereby increases the capacitance. Mathematically, this amounts to (for linear materials) taking $$\epsilon_0\rightarrow\epsilon:= \epsilon_0 \epsilon_r$$ in all of your equations. Where $\epsilon_r$ is called the "relative permeability" or "dielectric constant" (sometimes you also see this called $\kappa$. So this is how we account for the capacitance where we have different materials sandwiched between the plates.


text:
Q: Jasmine test cases for inner function calls returning response I am trying to write the jasmine test case for a function which in turn calls another function and returns a response. Seems like the function is called but i am not getting the value that is set inside the function.
Controller Function:
 angular.module('serviceApp')
.controller('startWorkscopeCtrl', function ($rootScope, $log, $scope, CommentService) {

    $scope.getTextById = function (id) {
        CommentService.get({ id: id }, function (response) {
            $scope.text = response;
            $scope.textCount = $scope.text.length;
        });
    };
 });

The service is referenced in another js file where it makes the rest service call to the backend service.
angular.module('restServiceModule', ['ngResource'])
    .factory('CommentService', function($resource){
    return $resource(
        {
            get: {
                method: 'GET',
                isArray: true,
                url: window.urlPrefix + '/commentservice/:id',
                params: {
                    id: '@id'
                }
            }

        });
    })

Test Case:
var mockTextComment;
var fakeText = ['testPass'];
beforeEach(function(){
    mockTextComment = {
        get: function(){
            return fakeText;
        }
    };
});

it('should get comments by asset id', function () {
    spyOn(mockTextComment, 'get');

    inject(function ($controller) {
        ctrl = $controller('startWorkscopeCtrl', {
            $scope: scope,
            CommentService: mockTextComment
        });

        scope.getTextById(40107);
        expect(scope.textCount).toEqual(1);

    });
});

With this, i am getting the below error:
**Expected undefined to equal 1.
Error: Expected undefined to equal 1.**

Not sure where i am doing wrong. Any pointers on this will be helpful.

A: It looks like CommentService.get does not return a value; it calls back a function upon completion. Therefore, a CommentService mock would look like this:
var mock = {
    get : function(arg1, callback){
        callback(fakeText);
    }
}


text:
Q: Can we transfer solr indexes from one server to other server instead of reindex Hi i did a pg dump of data from one server to other. now im having jetty solr indexes which needs to transferred to the other server to avoid reindexing of the whole data and other server contains tomcat solr. if it is possible to transfer indexes guide me how it can be done

A: Shutting down the first server and then creating a backup of the index directory should be enough. The directory usually have to sub directories, data and conf. The first contains the index files themselves, while the latter contains the configuration for the core.
This assumes that you're not running in cloud mode with zookeeper etc. In that case following the "Making and restoring backups" page on the community wiki is probably a good idea. This will be different depending on which version of Solr you're using.


text:
Q: simulator running prob-iphone sdk When I run my app I got this error ans quit application. I used 4.0 and 4.1 simulator. Please help me any one.....
2011-05-16 17:13:59.113 Dragon-Kish[15784:9303] AQMEIO_Base::DoStartIO: timeout
2011-05-16 17:13:59.114 Dragon-Kish[15784:9303] AQMEDevice::StartIO: error -66681
2011-05-16 17:13:59.114 Dragon-Kish[15784:9303] CA_UISoundClientBase::StartPlaying: AddRunningClient failed (status = -66681).


text:
Q: Ajax call to Struts2 action producing javax.xml.transform.TransformerException I'm trying to write a small example of calling a Struts2 action from Ajax and getting data back using XML. When the call executes, I get a javax.xml.transform.TransformerException (shown below). Eventually, I want to get the name property out of the data XML that comes back from the Ajax call.
I'm probably missing something simple here but I'm at a loss as to what's missing.
My action from struts.xml:
<action name="AjaxFormSubmit" class="test.FormSubmit" >
    <result type="xslt">
        <param name="exposedValue">fName</param>
    </result>
</action>

Javascript:
$.ajax({
    url: "AjaxFormSubmit.action",
    error: function( data )
    {
        alert( "error" );
        alert( data );
    },
    success: function( data )
    {
        alert( "success" );
        alert( data );
    }
});

My action class:
public class FormSubmit extends ActionSupport {

    public FormSubmit()
    {
        System.out.println( "in FormSubmit constructor" );
    }

    private String fName;

    public String getFName() {
        return fName;
    }

    public void setFName(String fName) {
        System.out.println( "setting fName: " + fName );
        this.fName = fName;
    }

    public String execute() throws Exception
    {
        System.out.println( "in execute" );

        return SUCCESS;
    }
}

The exception:
Aug 9, 2012 1:32:20 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
SEVERE: Unable to render XSLT Template, 'null'
Error transforming result - [unknown location]
    at org.apache.struts2.views.xslt.XSLTResult$1.error(XSLTResult.java:351)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.postErrorToListener(TransformerImpl.java:788)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:731)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:336)
    at org.apache.struts2.views.xslt.XSLTResult.execute(XSLTResult.java:392)
    at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:374)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:278)
    at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
    at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:90)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:192)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
    at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:511)
    at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)
Caused by: javax.xml.transform.TransformerException: Operation not supported.
    ... 68 more

A: What's missing is the XSL template, as indicated by the error:
SEVERE: Unable to render XSLT Template, 'null'

The "xslt" result type docs state a "location" param defines the template.
Do you actually want an XSL result, or just XML? Are you really transforming it?

A: I think that an implementation of XSLTResult was changed and parameter location is now required.
But you still can view generated XML when you use XSL file below:
<?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
        <xsl:template match="/">
            <xsl:copy-of select="*"/>
        </xsl:template>
    </xsl:stylesheet>

A: Try this, will help you in Struts 2.0.14 with jsonplugin-0.32.jar. it worked for me.
struts.xml:
<struts>
     <package name="example" extends="json-default">
        <action name="HelloWorld" class="example.HelloWorld"  >
            <result type="json" />
        </action>
              <action name="HelloWorld1" class="example.HelloWorld"  >
            <result name="success" >example/HelloWorld.jsp</result>
        </action>
    </package>
</struts>

action class Helloworld.java:
package prabhakar;

import glb.DB;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Prabhakar
 */
public class HelloWorld  {

    private List<StateMaster> stateList= new ArrayList<StateMaster>();
    private List<RegnMaster> regnList= new ArrayList<StateMaster>();

    private Integer stateId;
    public Integer getStateId()
    {
    return this.stateId;
    }
    public void setStateId(Integer stateId)
    {
    this.stateId=stateId;
    }
    public List<StateMaster> getStateList() {
        return stateList;
    }

    public void setStateList(List<StateMaster> stateList) {
        this.stateList = stateList;
    }
     public void setRegnList(List<RegnMaster> regnList) {
        this.regnList = regnList;
    }
    public List<RegnMaster> getRegnList() {
        return regnList;
    }

    public String execute() throws Exception {

        stateList=DB.getStateData()//
        if(stateId !=null)
          {
         regnList=DB.getRegnByStateId(stateId);
          }

        //setMessage(getText(MESSAGE));
        return "success";
    }

    /**
     * Provide default valuie for Message property.
     */

}

You can directly call HelloWorld.action to view the JSON data or else you can bind the JSON data to a form element below.
JSP page HelloWorld.jsp:
  /*
     Prabhakar
  */

<%@ page contentType="text/html; charset=UTF-8" %>

<%@ taglib prefix="s" uri="/struts-tags" %>
<script>
<%@include file="../js/jquery-1.7.1.min.js"%>
</script>
    <html>

<!-- JavaScript Plugins -->
  <script>
       function getLoad(){

       var stateId = $('#state').val();

$.getJSON('HelloWorld.action', {'stateId': stateId},
    function(data) {

           var divisionList = (data.regnList);

                var options = $("#regn");
                options.find('option')
    .remove()
    .end();
     options.append($("<option />").val("-1").text("--Select--"));
$.each(divisionList, function() {

    options.append($("<option />").val(this.regnId).text(this.regnName));
});
    }
);}
   </script>

<!-- jQuery-UI Dependent Scripts -->

    <body>
        State List <s:select name="stateId" list="stateList" id="state" listKey="stateId" onchange="getLoad()" listValue="stateName" headerKey="0" headerValue="--select--" />
        Regn List <s:select name="regnId"  list="regnList" listKey="regnId" id="regn" listValue="regnName" headerKey="0" headerValue="--select--" />
    </body>
</html>

:) :)


text:
Q: A constructible type deriving from DbContext could not be found in the selected file (EF Power Tools Beta 3/Visual Studio 2012) I'm trying to use the "View Model" feature of the EF Power Tools Beta 3 as heavily depended on by Julie Lerman within Visual Studio 2012.
I originally had the "sequence contains no matching element" problem many people seem to have encountered. The solution in the above article is an acceptable workaround that fixes the problem.
I'm now encountering the second error:
"A constructible type deriving from DbContext could not be found in the selected file"
The proposed cause of the problem in Julie's blog and in this question is that there is a conflicting extension somewhere.
I have disabled all possible extensions, yet I'm still receiving the error.
Is there any more information on how to resolve this?
Alternatively, I'm also using VS2013 Preview. Is this (working) functionality available in this version of Visual Studio?

A: I have had this issue in the past. It comes when your Context, "does too much"
I left that comment deliberately vague. But you can generally narrow it down to your constructor code.
If the powertool cant easily instantiate your context due to constructor params or the constructor  starts up power station, the tool gives up...
There is no doubt a more technical analysis around parameter-less constructors but you will know enough to avoid.   I use commented out VANILLA constructor that I use for view generation purposes. Then put it back when done for live work. ;-)
public class MyFANCYDbContext : DbContext  {
   MyFANCYDbContext( what is here??? Can EF powertool supply this ?){

     Inside the Constructor... do I start a power station ? Any other issues
        preventing the Create object  MyFancyDbContent from succeeding ?
  }
}

EDIT: try the simple constructor that refers to a VALID entry in App.config.


text:
Q: How to develop Chrome extension with WebStorm? There is no code prompt when writing a Chrome extension with WebStorm.
What should I do?

A: Installing @types/chrome as suggested in How do I use WebStorm for Chrome Extension Development? should help:


text:
Q: BeautifulSoup soup.prettify() gives strange output I'm trying to parse a web site and I'm going to use it later in my Django project. To do that, I'm using urllib2 and BeautifulSoup4. However, I couldn't get what I want. The output of BeautifulSoup object is weird. I tried different pages, it worked (output is normal). I thought it is because of the page. Then, when my friend tried to do the same thing, he got normal output. I couldn't manage to figure out problem.
This is the website I'm going to parse.
This is an example of the weird output after the command "soup.prettify()":
t   d       B   G   C   O   L   O   R   =   "   #   9   9   0   4   0   4   "       w   i   d   t   h   =   "   3   "   >   i   m   g       S   R   C   =   "   1   p   .   g   i   f   "       A   L   T       B   O   R   D   E   R   =   "   0   "       h   e   i   g   h   t   =   "   1   "       w   i   d   t   h   =   "   3   "   >   /   t   d   >   \n           /   t   r   >   \n           t   r   >   \n                   t   d       c   o   l   s   p   a   n   =   "   3   "       B   G   C   O   L   O   R   =   "   #   9   9   0   4   0   4   "       w   i   d   t   h   =   "   6   0   0   "       h   e   i   g   h   t   =   "   3   "   >   i   m   g       s   r   c   =   "   1   p   .   g   i   f   "       w   i   d   t   h   =   "   6   0   0   "   \n                   h   e   i   g   h   t   =   "   1   "   >   /   t   d   >   \n           /   t   r   >   \n   /   t   a   b   l   e   >   \n   /   c   e   n   t   e   r   >   /   d   i   v   >   \n   \n   p   >   &n   b   s   p   ;   &n   b   s   p   ;   &n   b   s   p   ;   &n   b   s   p   ;   /   p   >   \n   /   b   o   d   y   >   \n   /   h   t   m   l   >\n
\n \n'

A: Here is a minimal example that does work for me, including the snippet of html that you have a problem with. It's hard to tell without your code, but my guess is you did something like ' '.join(A.split()) somewhere.
import urllib2, bs4

url = "http://kafemud.bilkent.edu.tr/monu_tr.html"
req = urllib2.urlopen(url)
raw = req.read()
soup = bs4.BeautifulSoup(raw)

print soup.prettify().encode('utf-8')

Giving:
....

....

A: Possibly you and your friend use different parsers. BeautifulSoup will use the parser it considers "best", and thus prefer lxml for speed reasons (if installed).  If using recent versions of Python (and the last version of the included parser), there are cases which are handled better by BeautifulSoup(text, 'html.parser'); this is the case e.g. when there are unmasked < characters (instead of <) in text content.

A: This looks like you have your XML coming in with an encoding that beautifulsoup isn't expecting. My guess is that your XML is in UTF-16 and beautifulsoup is reading it as UTF-8. Python offers the .encode and .decode functions for switching between different encodings. Something like
myXmlStr.encode("utf-16").decode("utf-8")

Would probably solve your problem if the issue is your incoming XML encoding. I'm new to beautiful soup myself, but a quick google suggests that if the  problem is the encoding of the output, prettify accepts an encoding parameter:
soup.prettify("utf-16")

Without more information I can't give you a clearer answer - but hopefully this points you in a helpful direction.


text:
Q: Hibernate JPA Spring Boot I have created all the models for my spring boot application and successfully specified the relation between them as per business logic. In my properties file, I set the hibernate auto-ddl option as create to generate all the tables as per the relationship between the entities. I am also using liquibase for database migration.
The problem is that, from the logs I can see that hibernate is altering the table before creating it and therefore throwing the run time exception saying "Table not found". Why it is altering the table before creating it? How to solve this issue?
Any help would be highly appreciable. Thanks in advance.
Some logs example
Error executing DDL "alter table application drop foreign key FKrtuepaxepo3o6x0pkn0w62ucg" via JDBC Statement.

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "APPLICATION" not found; SQL statement:
alter table application drop foreign key FKrtuepaxepo3o6x0pkn0w62ucg

.......
.......
.......
Hibernate: drop table if exists application
create table application (id bigint not null auto_increment
alter table application add constraint UK_5jl5nuoh207t0japuutb4avd4 unique (application_name)

Why it is expecting table name as "APPLICATION" before creating "application"
@Table(name = "application")
    @EqualsAndHashCode(onlyExplicitlyIncluded = true)
    public class Application extends AbstractAuditingEntity implements Serializable {

        private static final long serialVersionUID = 1L;
}

I am using H2 database in the development and MYSQL in production. But, previously, I was using the "org.hibernate.dialect.MySQL5InnoDBDialect" dialect in "application-dev.yml". Changing it to h2 dialect(org.hibernate.dialect.H2Dialect) solved the problem.
But,what should be the proper dialect in application-prod.yml? I am using MYSQL in production. Current dialect I am using here is "org.hibernate.dialect.MySQL5InnoDBDialect". This will further create problem in production.
application-prod.yml
datasource:
#    type: com.zaxxer.hikari.HikariDataSource
    driverClassName: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/appscoredb
    username:
    password:
    hikari:
      poolName: Hikari
      auto-commit: false
#  h2:
#    console:
#        enabled: true
#        settings:
#          web-allow-others: true
  jpa:
    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
    database: mysql
    hibernate:
      ddl-auto: none

    show-sql: true
    properties:
      hibernate.id.new_generator_mappings: true
      hibernate.connection.provider_disables_autocommit: true
      hibernate.cache.use_second_level_cache: false
      hibernate.cache.use_query_cache: false
      hibernate.generate_statistics: false
  liquibase:
    # Remove 'faker' if you do not want the sample data to be loaded automatically
    contexts: prod, faker
    enabled: false

A: It is solved by using this dialect: org.hibernate.dialect.MySQL5Dialect
I hope it could help someone in near future.


text:
Q: Joining two tables to get max login time of person I have two tables. One for Customer and other is for managing login history. Now what I want to do is to get the customer name and email from customer table, and last login time from loghistory table.
I have used the query:
select cust_email, login_time, cust_email
from customer
left join login on customer.cust_id = login.cust_id
GROUP by cust_id

It gives me the correct result showing NULL for the customers who never logged in, but gives the first login time of other customers not the latest one. How do I get the last login time of customer?

A: Use MAX() & columns which are in SELECT statement must be aggregated or it should be with GROUP BY clause :
select c.cust_email, max(l.login_time)
from customer c left join
     login l
     on c.cust_id = l.cust_id
GROUP BY c.cust_email;

Note : Use table alias that is easy to understand & read.

A: use max() function
   select cust_email,max(login_time) as max_login_time from customer
   left join login on customer.cust_id=login.cust_id
   GROUP by cust_email

A: I think you should use simple "Join" not left join with a order by clause. Try this:
select cust_email, login_time, cust_email
from customer
join login on customer.cust_id = login.cust_id
GROUP by cust_id
Order by login_time esc


text:
Q: Why am I getting undefined reference errors? I'm getting undefined reference errors. Can you please figure out why?
Errors:

*

*undefined reference to Breuken::Breuken(int, int)

*undefined reference to Breuken::som()
(I'm kinda new in c++ programming. I am currently working on a project now, using header files another source file and main source file.)
Here is my code:
Header File (Breuk.H):
using namespace std;
class Breuken{
    Breuken(int, int);
    void som();

    void setTeller1(int);
    void setNoemer1(int);
    int getTeller1();
    int getNoemer1();

private:

    int teller1;
    int noemer1;
};

Source File(Breuk.cpp):
#include <iostream>
#include "Breuk.h"

using namespace std;

Breuken::Breuken(int tel1, int noem1)
{
    setTeller1(tel1);
    setNoemer1(noem1);
}

int Breuken::getTeller1()
{
    return teller1;
}
int Breuken::getNoemer1()
{
    return noemer1;
}

void Breuken::setTeller1(int tel1)
{
    teller1 = tel1;
}
void Breuken::setNoemer1(int noem1)
{
    noemer1 = noem1;
}
int Breuken::som()
{
    cout<<"Breuken zijn: "<<getTeller1()<<" / "<<getNoemer1()<<endl;
}

main file(main.cpp):
#include <iostream>
#include "Breuk.h"

using namespace std;

int main()
{
    Breuken br(1, 2);
    br.som();
    return 1;
}

A: If I got this right, you want to use a class, but the only thing you did is declare some functions without actually defining them.
What you need to do is put everything in your header inside a class like that:

class Breuk {
private:
    int teller1;
    int noemer1;

public:
    Breuk(int tel1, int noem1);

    void som();

    void setTeller1(int tel1);
    void setNoemer1(int noem1);

    int getTeller1();
    int getNoemer1();
};

Also, don't forget to give the variables inside the function head a name!
The .cpp file you need to get the reference to the class right (the part before the ::). It has to be the same name as your class. Also, it's not so great to use setter inside the constructor. It's better to reference the member variables directly (the variables inside the class). In order to do that you need to use "this->variable". "this" will refer to the current class you're in. That means if you write this->teller1 it will refer to the variable teller1 inside the class.
#include <iostream>
#include "Breuk.hpp"

using namespace std;

Breuk::Breuk(int tel1, int noem1)
{
    // setTeller1(tel1);   theoreticly ok but its better to access
    // setNoemer1(noem1);  member variables (variables inside a class) directly

    this->teller1 = tel1;
    this->noemer1 = noem1;
}

int Breuk::getTeller1()
{
    return teller1;
}
int Breuk::getNoemer1()
{
    return noemer1;
}

void Breuk::setTeller1(int tel1)
{
    teller1 = tel1;
}
void Breuk::setNoemer1(int noem1)
{
    noemer1 = noem1;
}
void Breuk::som()
{
    cout << "Breuken zijn: " << getTeller1() << " / " << getNoemer1() << endl;
}

in the main.cpp you only made a small mistake with the return 0 and the name of the class.

#include "Breuk.hpp"

using namespace std;

int main()
{
    Breuk br(1, 2); // make sure u use the same name your class has

    br.som();

    return 0; // return 0 at the end: it means that the program executed correctly
              // return 1 would mean that an error occured
}

Also, I suggest using .hpp files instead of .h files. There is no real difference but it's more common to use .hpp for c++.


text:
Q: Liquid Pre inside Table Cell Basically its a 2 column setup, with a dynamic width content column, and a static width menu column.
The content column is going to contain pre-tags (with code), and I need overflow:auto on the pre-tag inside the table to work.
So far I've had little luck. The nature of the pre tag forces a certain size on the table cell, which in turn refuses to be any smaller than the width of the pre tag.
Can anyone help out?
Ps. I've placed a second pre-tag on the page, which works as intended, but thats probably because it's not inside a table.

A: Add white-space: pre-wrap; to the element. max-width:100% may help too.

A: I found an acceptable solution.
The solution is a negative right margin for the pre (code) element.
Basically, a negative right margin will force the pre to shrink if it needs to.
I made margin-right -800px, and the width 97%.
I noticed that the width, paddings and borders need tweaking if to look good at all resolutions, but the solution works.
A simple solution that was hard to dream up.
[EDIT]
There was a link to an example, but it has been taken down.


text:
Q: Using the definition of $\lim_{x\to a} f(x) = \infty$ , prove that $\lim_{x\to 0} \frac{4x+\sqrt{5}}{2x^3+x^2} = \infty$ This is my working so far:
$$\lim_{x\to a} f(x) = \infty$$
if,
$\forall K > 0, \, \exists \delta >0$ s.t. $|f(x)|>K$ when $0<|x-a|<\delta$ & $x\in \text{Dom}(f)$
Proof: Given $K>0$, find $\delta>0$ s.t. $|f(x)| > K$ when $0<|x-a|<\delta$
i.e. that,
$$\left|\frac{4x+\sqrt{5}}{2x^3+x^2}\right| > K\quad \text{ when }|x|<\delta$$
My problem begins here in that I haven's a clue how to simplify $\left|\frac{4x+\sqrt{5}}{2x^3+x^2}\right| > K$ and get something in terms of $x$ or $|x|$ to then determine my $\delta$ accordingly.
Thank you for taking the time and $\textbf{hints only please!}$

A: Hint
We have that
$$\left|\frac{4x+\sqrt{5}}{2x^3+x^2}\right|=\dfrac{1}{x^2}\left|\frac{4x+\sqrt{5}}{2x+1}\right|.$$ Assume $|x|< 1/4.$ Then
$$|4x+\sqrt{5}|> \sqrt{5}-1$$ and $$|2x+1|< \dfrac12. $$

A: If $|x| < 1/4$, numerator > 1
and |denominator|
$=|x^2(2x+1)|
< |x^2/2|$.

A: Then, $|x|<\delta\le\frac{1}{4}$ and for $\delta=\sqrt{\dfrac{\sqrt 5-1}{2K}}$ we have that $|f(x)|>\dfrac{\sqrt 5-1}{2x^2}>K$, with the restriction that $\delta\le\dfrac{1}{4}$ leading to the restriction $K>8(\sqrt5-1)$ which is definitely $\textbf{not}$ $\forall K>0$. This solution is $\textbf{wrong}$. Delete this if you consider it necessary, but please mention this in comments as I cannot do it. Setting random boundaries does not work in general. It leads to restrictions that cannot be handled.


text:
Q: Div getting hide behind flash content I want to show a previous and next div over flash content which is opening in iframe.I have tried all the wmode=opaque or wmode=transparent or wmode=window, but fail to work in IE8.
I can't add because flash content is coming from other site. I am loading the other site in iframe.

A: DEMO: http://jsfiddle.net/pjgxt/2/
HTML

prev

next

CSS
#container {
    position: relative;
    width: 400px;
    padding-left: 100px;
    padding-right: 100px;
    border: 1px solid red;
}

.controls {
    position: absolute;
    width: 100px;
    height: 100px;
    top: 50px;
    background-color: lime;
    z-index: 10;
}

.prev {
    left: 50px;
}
.next {
    right: 50px;
}

iframe {
    width: 100%;
    height: 200px;
    position: relative;
    z-index: 5;
}

Notes

*

*z-index controls the layering of elements.

*You can only apply a
z-index to elements that have a position of relative or
absolute.

A: try it with giving z-index property to div


text:
Q: Datagrip не подсвечивает таблицы SQL Server Datagrip не видит таблицы, созданные в Microsoft SQL Server в других файлах
На скриншотах приведено объявление таблицы и попытка обратиться к ней в другом файле. Как это дело исправить?
К базе данных, в которой создаю таблицу, я, естественно, подключаюсь (скриншот 3)

A: Есть несколько способов:

*

*Вам нужно создать DDL data source и расширить этими файлами MS SQL data source. Тогда будет работать аводополнение.

*Подключить консоль с MS SQL data source к файлу SQL


text:
Q: Can I update ApplicationModule and get updated Value on each injection Can I change value stored in Application module and get it back in new Activity or somewhere else? I've tried this code, I expected that @Provides annotated method will calling every time since I call DaggerExampleBuilder.builde().appComponent(...).build().inject()
Here is code from my ApplicationModule:
 @Module
public class ApplicationModule {
    private HandsFreeApp app;
    private Property currentProperty;

public ApplicationModule(HandsFreeApp app) {
    this.app = app;
    Log.d("myTag", "ApplicationModule: "+hashCode());
}

@Provides @Singleton Context provideAppContext() {
    return app;
}

@Provides @Singleton RestClient provideRestClient(Realm realm) {
    TokenDataStore tokenDataStore = new TokenDataStore(realm);
    GetTokenUseCase tokenUseCase = new GetTokenUseCase(new TokenRepository(tokenDataStore));
    return new RestClientRetrofit(tokenUseCase);
}

@Provides @Singleton Realm provideRealm() {
    Realm.setDefaultConfiguration(new RealmConfiguration.Builder(app).build());
    return Realm.getDefaultInstance();
}

@Provides @Singleton Property getCurrentProperty(Realm realm) {

    if(currentProperty == null) {
        BookingStore store = new BookingLocalStore(realm);
        currentProperty = store.getPropertyList().toBlocking().first().get(0);
    }
    Log.d("myTag", "getCurrentProperty: "+currentProperty.getName());
    return currentProperty;
}

public void setCurrentProperty(Property currentProperty) {
    this.currentProperty = currentProperty;
    Log.d("myTag", "setCurrentProperty: "+this.currentProperty.getName());
}}

But getCurrentProperty() invoked only once

A: Annotating getCurrentProperty(Realm) with @Singleton means that Dagger will memoize the result of that @Provides method and use it for the rest of the lifetime of that component.  See http://google.github.io/dagger/users-guide.html#singletons-and-scoped-bindings.
If you want the method to be invoked each time Property is requested, remove @Singleton.


text:
Q: Difficulty sending values to input fields (sounds ridiculous) EDITED: New information: When I inspect the field, and the code is highligted (in the inspector), then the statements all work as they should, but when the field isn't highlighted anymore, the statements do not appear to work.  Hopefully this helps diagnose the issue.
I have a wufoo form (a hosted form that you can embedd, send to spefic email on submit etc).  I have a field on that form that I am trying to populate with a certain piece of data once I click a button.  I believe I have the correct code to make this happen, and it should work:
    $('#my-button').click(function() {
      $('#Field3').val("something");
    });

I have tried many different ways:
    $('input[id="Field3"]').val("something");
    $('input[name="Field3"]').val("something");

and a few reaches which I didn't really think would work..
    $('#Field3').append("something");
    $('#Field3').text("something");

There are a few things that confuse me here, and I will post screens below showing what I mean. I can type all of these commands in the console once the page is loaded and nothing will happen to the field (with the id of Field3)...most of the time.  But on several occasions, I would reload the page, try a few statements again, yes the same ones, and then it would work.  No idea why or how, but it is sort of an intermittent thing.  Obviously that's probably not the case, but I am pretty confused as to why this is happening;
Below are three screens of my console.  For the first two, the field finally populated after about 10 or more tries in the console, and then continued to work while using commands that didn't work before.  The last screen is an attempt that did not work at all:
[![Eventually Works After Last Command][1]][1]
[![Eventually Works After Last Command][2]][2]
[![Did Not Work][3]][3]

[1]: http://i.stack.imgur.com/JKVxY.jpg
[2]: http://i.stack.imgur.com/MLca8.jpg
[3]: http://i.stack.imgur.com/0viRA.jpg

(Apologies for the way I had to post these images, I keep getting formatting errors that will not let me continue to save the post unless I cmd+k them)
I try everything in the console first, but I can not find any patterns here.  Any ideas or input would be greatly appreciated, and thank you for your time.

A: At this point I'm pretty sure the problem has to do with the form-code switching or adding certain classes under certain conditions, so I downloaded the code from my Wufoo account rather than embedding it.  Then I only added the code for the view (not css or JS), and it works now.
My original statements (not the reachers) all work fine now when I try them.  Thanks for the time everyone.

A: I know you solved your issue, but figured I'd chime in in case you or others have this issue again in the future.  It sounds like your issue was related to execution order.  Wufoo's embed scripts are asynchronous, so it's very likely that the input fields in question didn't yet  exist on your page at the time your jQuery click handler was evaluated.  Changing your original code to jQuery's "on" method instead of "click" would likely have solved your problem, as "on" provides a delegated event listener.  At any rate, glad you got everything sorted out!

A: In the console I assume there is no jQuery loaded.
I usually write:
document.getElementById('Field3').value = "something";

A: Updated your Jsfiddle. The only thing I changes, I added the reference of the
Jquery. Might be that's the problem.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>


text:
Q: Why OnValidatePrincipal is not called when navigating in Blazor pages and how to fix it I have cookie authentication & OpenId setup to handle the OnValidatePrincipal:
.AddCookie(Constants.Cookies, options =>
{
  options.Events.OnValidatePrincipal = ValidatePrincipalAsync;
}

static async Task ValidateAsync(CookieValidatePrincipalContext context)
{
   //  context.Request.Path
}

Inspecting the request path in the handler, I see it's is called for Request.Path with these paths: /, /_blazor/initializers, /_blazor/negotiate, /_blazor.
The handler is also called if navigate to any Razor server page (Pages/Test.cshtml).
But when I navigate in the Blazor app to different Blazor pages, the handler is not called.
Why isn't it called for Blazor pages too? Is it because Blazor server works with web sockets?
But isn't a problem that the validator is not called when navigating through the Blazor pages ? How to change so it's called for Blazor pages too?


text:
Q: Measured Earth local gravity I am looking for measured data of the local gravity on Earth. I know this website (https://www.ptb.de/cartoweb3/SISproject.php). The idea is nice but it looks a bit old and I would like to have an alternative source.

A: The best open-source source on Earth's gravity is EGM 08 (Earth Gravitational Model 2008):
http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm2008/
Of course, EGM08 defines an abstract equi-potential surface (as a spherical harmonics expansion), so it doesn't have anything to do with force; however, it also comes with gravitational anomalies (which are deviations in the magnitude of the acceleration) and defections from vertical.


text:
Q: Where is my exposed root of my webpage in the directory structure of Azure console? I created a new .NET based web application named shabang using the web client and it displays the default woohoo-page when I browse to shabang.azurewebsites.net. Then, I discovered that there's a console in the web client and when I use it, I can see a directory structure including my login name, home directory etc. However, I can't find the files being served and, since I can see a web page being rendered when browsing, I'm certain they are there, somewhere.
Where is the (or equivalent of) wwwroot?
I've googled it but it's a bit hard to word what I'm asking in a way that Google will understand. Just a bunch of guides that are way too advanced to distill the information from.

A: By default, it is d:\home\site\wwwroot. It can also be modified using the Azure Portal.
Note that you should use the Kudu Console to see it. e.g. https://shabang.scm.azurewebsites.net


text: Q: liferay-commerce Liferay DXP and Liferay Portal come with a powerful E-Commerce System named Liferay Commerce. As the underlying platform, it's extremely extensible, has a complete API. Use this tag for programmatic customizations for Liferay Commerce. Consider tagging [tag:liferay] or a versioned Liferay tag as well. Name the specific version you're working on.


text:
Q: Is neutrino in superposition state else how does it knows when to change flavor? Is the neutrino being in all 3 flavors at the same time until observed if not how does it know when to alter its mass and become another flavor?

A: No, it does not have all three  flavors at the same time, it oscillates between flavors.
A neutrino, because of lepton number conservation always starts with a fixed flavor, and then the probability of finding a specific flavor oscillates, let us take an electron neutrino from the link:
:

Electron neutrino oscillations, long range. Here and in the following diagrams black means electron neutrino, blue means muon neutrino and red means tau neutrino

The neutrino  wave function squared "knows", given the initial conditions, it gives the probability distributions.