ubuntu setting system variables

Question: I am trying to protect my server as below system variables
net.ipv4.icmp_echo_ignore_all=1
# IP Spoofing protection
net.ipv4.conf.all.rp_filter=1
net.ipv4.conf.default.rp_filter=1
#Ignore ICMP broadcast requests
net.ipv4.icmp_echo_ignore_broadcasts=1
# Disable source packet routing
net.ipv4.conf.all.accept_source_route=0
net.ipv6.conf.all.accept_source_route=0
net.ipv4.conf.default.accept_source_route=0
net.ipv6.conf.default.accept_source_route=0
# Ignore send redirects
net.ipv4.conf.all.send_redirects=0
net.ipv4.conf.default.send_redirects=0
# Block SYN attacks
net.ipv4.tcp_syncookies=1
net.ipv4.tcp_max_syn_backlog=2048
net.ipv4.tcp_synack_retries=2
net.ipv4.tcp_syn_retries=5
# Log Martians
net.ipv4.conf.all.log_martians=1
net.ipv4.icmp_ignore_bogus_error_responses=1
# Ignore ICMP redirects
net.ipv4.conf.all.accept_redirects=0
net.ipv6.conf.all.accept_redirects=0
net.ipv4.conf.default.accept_redirects=0
net.ipv6.conf.default.accept_redirects=0
# Ignore Directed pings
net.ipv4.icmp_echo_ignore_all=1

Image:

But I get some error happen when I applied the rules.
sysctl: cannot stat /proc/sys/net/ipv4/conf/all/rp_filter: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/conf/default/rp_filter: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/conf/all/accept_source_route: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv6/conf/all/accept_source_route: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/conf/default/accept_source_route: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv6/conf/default/accept_source_route: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/conf/all/send_redirects: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/conf/default/send_redirects: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/tcp_syncookies: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/tcp_max_syn_backlog: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/tcp_synack_retries: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/tcp_syn_retries: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/conf/all/log_martians: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/conf/all/accept_redirects: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv6/conf/all/accept_redirects: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/conf/default/accept_redirects: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv6/conf/default/accept_redirects: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/icmp_echo_ignore_all: No such file or directory

Error images:

Here  cat -A /etc/sysctl.conf
net.ipv4.icmp_echo_ignore_all=1$
# IP Spoofing protection$
M-bM-^@M-^Knet.ipv4.conf.all.rp_filter=1$
M-bM-^@M-^Knet.ipv4.conf.default.rp_filter=1$
#Ignore ICMP broadcast requests$
M-bM-^@M-^Knet.ipv4.icmp_echo_ignore_broadcasts=1$
# Disable source packet routing$
M-bM-^@M-^Knet.ipv4.conf.all.accept_source_route=0$
M-bM-^@M-^Knet.ipv6.conf.all.accept_source_route=0$
M-bM-^@M-^Knet.ipv4.conf.default.accept_source_route=0$
M-bM-^@M-^Knet.ipv6.conf.default.accept_source_route=0$
# Ignore send redirects$
M-bM-^@M-^Knet.ipv4.conf.all.send_redirects=0$
M-bM-^@M-^Knet.ipv4.conf.default.send_redirects=0$
# Block SYN attacks$
M-bM-^@M-^Knet.ipv4.tcp_syncookies=1$
M-bM-^@M-^Knet.ipv4.tcp_max_syn_backlog=2048$
M-bM-^@M-^Knet.ipv4.tcp_synack_retries=2$
M-bM-^@M-^Knet.ipv4.tcp_syn_retries=5$
# Log Martians$
M-bM-^@M-^Knet.ipv4.conf.all.log_martians=1$
M-bM-^@M-^Knet.ipv4.icmp_ignore_bogus_error_responses=1$
# Ignore ICMP redirects$
M-bM-^@M-^Knet.ipv4.conf.all.accept_redirects=0$
M-bM-^@M-^Knet.ipv6.conf.all.accept_redirects=0$
M-bM-^@M-^Knet.ipv4.conf.default.accept_redirects=0$
M-bM-^@M-^Knet.ipv6.conf.default.accept_redirects=0$
# Ignore Directed pings$
M-bM-^@M-^Knet.ipv4.icmp_echo_ignore_all=1$
root@ubuntu-s-2vcpu-4gb-lon1-01:/etc#

Comment: Do those files exist and how are you changing these values? Please remove the spaces between the `variables` and `=` and `value`!
Comment: I did not change those I check on rp_filter file I see 1 numer value eixsting there but
I don't know why I get those error messages
Comment: Remove the spaces and see if the error goes away! Let this `net.ipv4.icmp_echo_ignore_broadcasts = 1` be this `net.ipv4.icmp_echo_ignore_broadcasts=1`.
Comment: You mean remove the space between one block to another block right
example: # Block SYN attacks to # Log Martians right?
Comment: No let me post a simple answer so you can follow! And are you adding them manuallly or from a script?
Comment: Note that the *images* actually show that the missing files are `/proc/sys/ net/xxx` (with some kind of non-printing character before the `net`) - I suspect there is something messed up in your editor settings - can you show us the output of `cat -A /etc/sysctl.conf` please?
Comment: I found this M-bM-^@M-^K maybe from editor
Comment: That's not right! How are you adding these keys, from a script or?
Comment: Ok It work well now
Answer: Rather than
net.ipv4.icmp_echo_ignore_broadcasts = 1

Change each line so no spaces exists between variables and the values, like so
net.ipv4.icmp_echo_ignore_broadcasts=1

Comment: I update new one as you see i update the question but still the same error
Comment: ... `man sysctl.conf` says *"whitespace before  and  after  a  token  or  value  is  ignored"* though?
Comment: I update error output please help to check it and those setting I try to clean space also but pass it to some text editor.
Comment: Let me try to track down the error!

ubuntu setting system variables


Removing random ticks at home

Question:

This might not be the right forum for this kind of question, but I figured I'd ask anyway.  We're finding random ticks at home, maybe one a day, sometimes one every other day.  They look like the picture above (pen for scale).  Our house has 3 floors and I've found them on all floors (i.e., they don't keep to one floor).  We don't have any pets and we're barely going outside (pandemic and all...).
My questions are:

How big of an issue is this? Are these dangerous? We're expecting a newborn in a month, so we're trying to be as careful as possible.
How do I remove them?
Comment: I'm voting to close this question as off-topic because it has nothing to do with Home Improvement.
Comment: Try Biology forum, with species-identification tag. Want to know if this is a dangerous tick. They might well know.
Comment: Ticks don't have wings and they're not reknowned for climbing stairs, nor do they jump.  They may be coming in on clothing.  Their usual tactic is to climb vegetation and then step across onto passing legs/clothing when you brush into them.   Do the paths that you walk outdoors have high grasses or any other springboards they could use?
Comment: Where do you live? Ticks are more prevalent in certain areas of the country. My son lives in rural NY State and they need to check themselves daily for them. Ticks live outdoors. I've never known them to nest in a house. People or animals carry them in. They can be dangerous. They carry Lyme disease for one. If you're out taking walks in fields or areas with undergrowth - that's their territory. You can Google how to remove them.
Comment: @PolypipeWrangler: doesn't look like a weevil, I count 6 legs + 2 "antlers"? Not sure what you call them. But 8 total little lines. I'll upload a closeup image
Answer: Yes, they can carry Lime disease among other things. Be sure to do tick checks until you fix the problem.
Diatomaceous Earth is an excellent and relatively safe way to deal with them. The best place to put it is outdoors around the house so that they are dealt with there and before they come into your home. In your case, they seem to be random so it would be hard to target them indoors but you can place some of the DE in corners and on carpet and rugs and it will help get any stragglers.
Comment: Thanks - I'll take at look at DE

Removing random ticks at home


Multi variable function and its corresponding range?

Question: How do we find the range of
$z=f(x,y)=1/\ln(4−x^2−y^2)$
1) Replace $t=\ln(4−x^2−y^2)$ and $t\in (−\infty,\ln4)$ and there is a DNE at ln('')=0
2) Find range of $1/t$ ; How is this done?
Answers: $(−\infty,0)∪(1/\ln4,\infty)$
Answer: We know the domain of $f(x,y)=\dfrac{1}{\ln(4-x^2-y^2)}$ is
$$\color{blue}{D_f=\{(x,y)\in\mathbb{R}^2:x^2+y^2<4~,~x^2+y^2\neq3\}}$$
and in this domain $0\leq x^2+y^2<4$ so
$$0< 4-x^2-y^2\leq4~,~(x^2+y^2\neq3)$$
the function $\ln x$ is increasing then
$$-\infty< \ln(4-x^2-y^2)\leq\ln4~,~(x^2+y^2\neq3)$$
with reciprocating we have some irregular points for $\dfrac{1}{\ln(4-x^2-y^2)}$ in $x^2+y^2=3$, and except points on this circle we see
\begin{cases}
f(x,y)\in(-\infty,0)~~~\text{for}~~~0< 4-x^2-y^2<3, \\
f(x,y)\in(\dfrac{1}{\ln4},+\infty)~~~\text{for}~~~3< 4-x^2-y^2<4.
\end{cases}
so
$$\color{blue}{R_f=(-\infty,0)\cup(\dfrac{1}{\ln4},+\infty)}$$


vision.PeopleDetector function in Matlab

Question: Have anyone ever used vision.PeopleDetector function from Computer Vision System Toolbox in Matlab?
I've installed it and tried to apply to images I have.
Although it detects people on the training image, it detects nothing on real photos. Either it doesn't detect people at all or detects people at parts of the image where they are not presented.
Could anyone share the experience of using this function?
Thanks a lot!
Here is a sample image:
Comment: I haven't used that particular function but the help says ""The object detects unoccluded people in an upright position."
Comment: Finding people in real photos is still an open research problem. What has been said in above comment is correct.
Comment: I've read help about vision.PeopleDetector and my question was if anybody ever successfully used it for any body detection problem. The matter is that, in the example it works quite well but when I try any (!) of my images, the function fails to detect anyone there. Despite the fact that people on image are unoccluded in upright positions
Answer: The vision.PeopleDetector object does indeed detect upright standing people in images. However, like most computer vision algorithms it is not 100% accurate. Can you post a sample image where it fails?
There are several things you can try to improve performance.

Try changing the ClassificationModel parameter to 'UprightPeople_96x48'. There are two models that come with the object, trained on different data sets.
How big (in pixels) are the people in your image? If you use  the default 'UprightPeople_128x64' model, then you will not be able to detect a person smaller than 128x64 pixels.  Similarly, for the 'UprightPeople_96x48' model the smallest size person you can detect is 96x48.  If the people in your image are smaller than that, you can up-sample the image using imresize.
Try reducing the ClassificationThreshold parameter to get more detections.

Edit:
Some thoughts on your particular image. My guess would be that the people detector is not working well here, because it was not trained on this kind of images. The training sets for both models consist of natural images of pedestrians. Ironically, the fact that your image has a perfectly clean background may be throwing the detector off.
If this image is typical of what you have to deal with, then I have a few suggestions. One possibility is to use simple thresholding to segment out the people. The other is to use vision.CascadeObjectDetector to detect the faces or the upper bodies, which happens to work perfectly on this image:
im = imread('postures.jpg');
detector = vision.CascadeObjectDetector('ClassificationModel', 'UpperBody');
bboxes = step(detector, im);
im2 = insertObjectAnnotation(im, 'rectangle', bboxes, 'person', 'Color', 'red');
imshow(im2);

Comment: Thanks for the response. Trying for example image from 'http://1.bp.blogspot.com/-W9JP5Qpp3cc/US9MKDR1xxI/AAAAAAAADk4/Z2qwAAsmGJc/s1600/postures.jpg' even varying the Threshold (from 1 down to 0.1 or even 0.01) some people from the photo are still not detected in terms of there is no window which would contain their face. In current example it's the men number 3. Why does this happen? Looking at the photo this men is not different in terms of his position from other people...


How to get the size of the duplicates in this query?

Question: Let's say I have the following data:
md5          file_size
1234          127.4
1234          127.4
1234          127.4
909           18.2
909           18.2
104           207

I want to find out how much data I have in duplicates -- that is -- if we have one of each of the files (unique by md5) how much space do we save? The answer should be:
md5        size_saved
1234       254.8
909        18.2
104        0

Here is the base query I have thus far:
SELECT file_size, SUM(file_size) total_size FROM files GROUP BY md5

I think the simplest way to do this is to do ABS(file_size - total_size), but I'm not sure how to do this without using a sub-select or an outer-query that has access to both the aggregate size and the single file size. What would be the proper way to do this, or is the only way with a subselect?
Answer: You could use:
SELECT
    md5,
    SUM(file_size) - MIN(file_size) AS size_saved
FROM yourTable
GROUP BY
    md5;

Demo
Note that my answer assumes that all records for a given md5 would always have the same file_size values, in the event that there be more than one record.  If not, then my answer would not work, but we would have to redefine the logic anyway in this case.
Comment: thanks for this, yes I think I was getting confused in my previous queries as there is some null data in there so the records kept looking wrong. Anyways, yes this is the right answer cheers!
Answer: I supposed if it is duplicate, the file size is the same, so you can try something like this :
select md5,file_size*(count(file_size)-1) as space_saved from files group by md5,file_size

Comment: @David542, without file_size in GROUP BY the SQL would be invalid. MySQL (at least older versions) allows it unless ONLY_FULL_GROUP_BY is used. Allowing partial group by can lead to non-deterministic results.
Comment: looks good. Why the group by on the `file_size` though? Wouldn't that be redundant?
Comment: @viorel -- that's my favorite part about older mysql versions! I find it so annoying when every field needs to be grouped or added in with an aggregated calc.
Answer: You can use file_size in GROUP BY, so you can easily include in select statement.
SELECT md5, SUM(file_size) -  file_size AS size_saved
FROM files
GROUP BY md5, file_size


Hide section for UITableView on first load

Question: I have a UITableView with 2 sections (the 1st for the filters and the 2nd for the data).
I want to hide the 1st section when the view is loaded.
The section appears only when I scroll on top.
I tested with scrollToRowAtIndexPath: but the result is not as expected.
Please help. Thanks.
Comment: Why not remove the section related data from table data. And add it when required and reload table ?
Comment: Do you have any code to add to your question for what you've tried?
Comment: - (void)viewDidAppear:(BOOL)animated {[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:NSNotFound inSection:1] atScrollPosition:UITableV}iewScrollPositionTop animated:NO];}
Comment: Otherwise I tested with a flag (showAllSections = NO). And in the delegate function numberOfRowsInSection, I return 0 for the section 0 if the flag is false; And when I scroll on top, I set the flag with YES and I reload the section 0.
Answer: You can add a BOOL variable to find out whether it is loading first time or not. Set it true in the viewDidLoad like:
- (void)viewDidLoad
{
    [super viewDidLoad];

    isFirstTimeLoading = YES;

}

Then in your numberOfSectionsInTableView: delegate method,
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    if (isFirstTimeLoading)  {
        return 1;
    } else {
        return 2;
    }

}

TableView scrolling to top can be find out using
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

In this method, check whether the row is top row. if yes then make isFirstTimeLoading to NO and reload data. Dont forget to change the data also if necessary.
Comment: Yes but the method willDisplayCell is also called at the first load no  ?
Comment: yes but at that time, isFirstTimeLoading is YES. So the section will not be added
Answer:
Take a BOOL variable for checking whether to load one section or
two section.
Make is YES in ViewDidLoad then,for the first time UITableView will load one section.
Then when UITableView will be scrolled to top,make that BOOL variable to NO

- (void)viewDidLoad
{
    [super viewDidLoad];

    isFirstTime = YES;
}

In datasource method of TableView

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    if (isFirstTime) {
        return 1;
    }
    return 2;
}

For checking the UITableView to scroll TOP.We will use delegate methods of UIScrollview.UITableView is the subclass of UIScrollView.

-(void)scrollViewDidScroll:(UITableView *)tableView{

  CGFloat content_Offset = tableView.contentOffset.y;

  if (content_Offset >= 0 && isFirstTime){
    //UITableview is scrolled to top
    isFirstTime = NO;
    [self.myTbaleView reloadData];
   }else if (content_Offset<0) {
    //UITableview is draged down
   }

}
Comment: It works only if I scroll BOTTOM first, then I scroll TOP. But if I scroll TOP when the tableview is loaded, it doesn't work.
Comment: Ok.Just see my edited post .You will get your answer.You just need to test "content_Offset >0".test it and let me know.
Comment: Thanks @goupilz.but the condition should be content_offset >= 0


What does the damage shorthand in Nethack mean?

Question: For example, on the wiki page for the Riders, it says Death's attack does

Attacks
  Touch of death 8d8, Touch of death 8d8

How am I supposed to interpret xdx?
Comment: Wolfram alpha has a nice feature where they show you the distribution, expected/average value, and do a random roll for you: http://www.wolframalpha.com/input/?i=8d8
Answer: This is standard D&D terminology, where the first number (x) indicates the number of times (or the number of dice) you roll and the dx indicates the type of die that is rolled (with the x indicating the number of sides).  In the case of 8d8, you would roll an 8 sided die 8 times and then sum the results.
Therefore, the damage done by Touch of Death is the sum of 8 random numbers between 1-8, which works out to a number between 8 and 64.  As per liori's comment, this value is more likely to be in the middle of that range than at the ends.  If you take all the possible outcomes of 8 rolls of 8 sided dice and graph the sums, you'll get a very nice bell curve.  Rolling 8 or 64 would be extremely unlikely, but rolling 32 would be extremely common.
A few examples:
1d20 would be 1 roll of a 20 sided die.
3d6 would be 3 rolls of a 6 sided die.
1d8 + 2 would be 1 roll of an 8 sided die, with 2 added to the result (so a number between 3 and 10).
Comment: It might be worth adding that e.g. `11k10` is something different than `1k100 + 10` due to the probability distribution. The more dices used (the first number), the more probable it is to get a result somewhere in the middle.
Comment: @liori: Just a peeve: *dice* is already plural. (The singular being *die*)


Hibernate error in create entity manger [ java.lang.NoSuchMethodError: org.hibernate.cfg.Environment.verifyProperties(Ljava/util/Map;)V ]

Question: I'm using Hibernate as a provider for JPA in Java EE 6 and JBoss 7.1.1 Final. I searched for solutions but im new with hibernate and I don't fix the issue. Im getting this error:
Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.cfg.Environment.verifyProperties(Ljava/util/Map;)V
at org.hibernate.boot.registry.StandardServiceRegistryBuilder.build(StandardServiceRegistryBuilder.java:278)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:173)
at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:34)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:165)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:114)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:71)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:52)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:78)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at Main.main(Main.java:13)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

My persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
             version="2.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

    <persistence-unit name="manager1" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
            <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/test_app"/>
            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
            <property name="hibernate.connection.username" value="test"/>
            <property name="hibernate.connection.password" value="test"/>
            <property name="hibernate.archive.autodetection" value="class"/>
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.format_sql" value="true"/>
            <property name="hbm2ddl.auto" value="create-drop"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
        </properties>
    </persistence-unit>
</persistence>

Main class for test the connection with DB
public class Main {
public static void main(String[] args) {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("manager1");
    EntityManager em = emf.createEntityManager();

    // ----- Creating Users

    EntityTransaction t = em.getTransaction();
    t.begin();

    User usuario1 = new User();
    usuario1.setUser_Name("User1");
    usuario1.setUserMessage("Text example 1");
    em.persist(usuario1);

    User usuario2 = new User();
    usuario2.setUser_Name("User2");
    usuario2.setUser_Name("Text example 2");
    em.persist(usuario2);

    t.commit();

    em.close();
    emf.close();
}

}
My libs
http://imgur.com/eL2KRXk
My project folder structure
https://i.stack.imgur.com/4mx5l.jpg
And finally my pom.xml
    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>agenda5</groupId>
    <artifactId>agenda5</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <hibernate-core.version>3.6.4.Final</hibernate-core.version>
        <mysql-connector-java.version>5.1.16</mysql-connector-java.version>
        <slf4j.version>1.6.1</slf4j.version>
        <log4j.version>1.6.1</log4j.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate-core.version}</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql-connector-java.version}</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${log4j.version}</version>
        </dependency>
    </dependencies>

</project>

Comment: so your JPA implementation jars are inconsistent. NoSuchMethodError has clear enough javadocs. Get jars that are consistent
Comment: All the jars installed in the project are installed via Maven, but I will fix the complete javadocs for the jars.

I fix the problem creating a hibernate.cfg.xml. But now I have a new Exception:

`[PersistenceUnit: manager1] Unable to build EntityManagerFactory`
Comment: which is not part of JPA. so you're presumably no using JPA now
Comment: Is not necessary create hibernate.cfg.xml?

Im getting new Exception when I create it:

`javax.persistence.PersistenceException: [PersistenceUnit: manager1] Unable to build EntityManagerFactory`

`org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager`
Answer: xml should be like the below
<persistence-unit name="manager1" transaction-type="JTA">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <properties>
                <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test_app</property>
                <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property
                <property name="hibernate.connection.username">test</property
                <property name="hibernate.connection.password">test</property
                <property name="hibernate.archive.autodetection">class</property
                <property name="hibernate.show_sql">true</property
                <property name="hibernate.format_sql">true</property
                <property name="hbm2ddl.auto">create-drop</property
                <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property
            </properties>
        </persistence-unit>
    </persistence>

Comment: That doesn't solve any NoSuchMethodError ... which is down to what jars the user has in the CLASSPATH.
Comment: Hi I hope by looking into the following statement,Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.cfg.Environment.verifyProperties(Ljava/util/Map;)V. It seems to be clear that while loading the perstance.xml file by org.hibernate.Configuration class, it found the definition of the xml is incorrect. if you could see the jar files the hibernate-core.jar it self contains .class file for org.hibernate.Configuration class. see the api @grepcode.com
Comment: Okay, and what is the solution?
Comment: format your persistance.xml file as above  suggested and then re-build your application then check once. it should work.
Comment: I fix the problem, but how can I create tables with the entities?
Comment: you could use the tag as  or if you are using mapping files then use  to generate the tables automatically by the ASTQueryTranslator of Hibernate known as Hibernate engine.this will use a class called EntityPersistors to persist the state of an object in to the RDMS as a table.
Comment: you could use the tag as  or if you are using mapping files then use  to generate the tables automatically by the ASTQueryTranslator of Hibernate known as Hibernate engine.this will use a class called EntityPersistors to persist the state of an object in to the RDMS as a table.


Variables in PL/SQL

Question: I am working on a rather large SQL script to be used with Oracle, but I'm running into an issue. First, let me outline how the script operates.

Declare variables`CUSTOMERID NUMBER;``SERVERID NUMBER;`
Create a customer if it doesn't exist
`SELECT ID INTO CUSTOMERID FROM CUSTOMER WHERE NAME = 'The Customer I just Inserted';`
Create the server if it doesn't exist, using the `CUSTOMERID` value to relate the server to the customer.
`SELECT ID INTO SERVERID WHERE HOSTNAME = 'the.server.i.just.created';`
For each service belonging to this server, insert the service using the `SERVERID` value to relate the service to the server.
Go to 2

Now this process seems to work well for just one customer with 15 servers, each having 6 services. But as soon as the next customer is introduced, I receive prompts for variable substitution. The way I'm using the variables on my insert is pretty straightforward:
INSERT INTO SERVERS(CUSTOMER_ID, HOSTNAME)
SELECT CUSTOMERID, 'the.server.i.just.created' FROM DUAL
WHERE NOT EXISTS (
    SELECT *
    FROM SERVERS
    WHERE HOSTNAME = 'the.server.i.just.created'
);

I have also attempted using the DECLARE ... BEGIN ... END; method, but I receive the same general results. Some examples I've seen suggest to use the :CUSTOMERID style variables, but those don't seem to work at all, where they are ending up with null values, which shouldn't be happening given the previous queries.
What I am needing help with is in understanding how to achieve this. I have very limited access to the production environment, so anything I do needs to be kept basic (e.g., no new functions, types, or procedures).
Answer: I actually stumbled across the answer after beating my head on the desk repeatedly.
Basically, what was happening was some of the customer names had ampersands in them, and the word immediately following the ampersand was attempting to bind as a variable. The solution was to SET DEFINE OFF; and all was well after that.
Thank you all for your time and consideration.
Answer: You can avoid some of the requerying using a RETURNING clause. For example:
SQL> var v number
SQL> print v
v
---------

SQL> insert into demo1 (col1) values (12345) returning col1 into :v;

1 row inserted

SQL> print v
v
---------
12345

This tends to be cleaner and more controllable in PL/SQL than in in a series of standalone statements called from a script.

Variables in PL/SQL


Two Uniform Independent Random Variables: When is one greater?

Question: You have two independent random variables: $X$ and $Y$, which are both uniformly distributed over $(0,1)$.
Consider the inequality $X^2- 4Y < 0$. What percentage of the time is the inequality true?
Answer: We want the probability that $Y\gt \frac{X^2}{4}$.
Draw the square with corners $(0,0)$, $(1,0)$, $(1,1)$, and $(0,1)$ where the joint density function "lives." Draw the parabola $y=\frac{x^2}{4}$. We want the probability that $(X,Y)$ ends up in the part $P$ of the square which is above the parabola.
Since the joint density is $1$, this probability is the area of $P$.  The picture shows that this area is
$$\int_0^1 \left(1-\frac{x^2}{4}\right)\,dx.$$
It is somewhat more pleasant to find instead the area of the rest of the square. This is
$$\int_0^1 \frac{x^2}{4}\,dx,$$
which is $\frac{1}{12}$. Thus the required probability is $\frac{11}{12}$.


C# BlockingCollection Dispose method

Question: Documentation of BlockingCollection<T> class has the following note:
Always call Dispose before you release your last reference to the
BlockingCollection<T>. Otherwise, the resources it is using will not be freed
until the garbage collector calls the BlockingCollection<T> object's Finalize
method.

And internal implementation of BlockingCollection<T> in C# has the following method:
///
/// Releases resources used by the <see cref="T:System.Collections.Concurrent.BlockingCollection{T}"/> instance.
///
/// <param name="disposing">Whether being disposed explicitly (true) or due to a finalizer (false).</param>
protected virtual void Dispose(bool disposing)

There is only one call of this Dispose with argument disposing: true and finalization suppress after the call. But, surprisingly for me, there is no explicit finalizer in the class, and even no call of Dispose(false).
It looks like Dispose function is relatively simple and it just removes references to different objects for GC speed up. In this case, GC will do this work for us in the case when we forget to call Dispose() explicitly.
Can someone spot the light on the internals of this class? What is the purpose of a method Dispose(bool disposing)? Is it common practice to implement this method for .NET core libraries even in cases when it is not needed?
Comment: Wait handles are not free, you overlooked the `m_waitHandle.Dispose();` call it makes inside the dispose method.
Comment: About the message in the documentation, I did not check the presence of a finalizer on this type so I'll take your word for it not being there, but this may be a simple case of copy paste of some documentation, I see the exact same message posted on several types in the documentation.
Comment: The purpose of Dispose is to dispose of the wait handle, and you even linked to the source code that showed this, so I'm not really sure what you're asking about here.
Comment: It's a variation of [dispose pattern](https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-dispose). With no unmanaged resources it's simplified but still inherited classes may hold unmanaged resources so would need the full dispose pattern implementation while base class provides possibility to be involved in this by implementing this virtual method.
Comment: I understand the purpose of `Dispose()` method in case of its explicit usage (and I'm aware of Disposable pattern). But I'm curious about the case when no explicit `Dispose()` is called. It looks like the documentation says that in this case `Dispose()` will be performed at the finalization stage and presence of `Dispose(false)` method also looks like a confirmation of this hypothesis. But on the other hand there is no explicit finalizer and no calls to the `Dispose(false)` method.
Comment: Nothing is called at finalization stage unless it's explicitly specified in a finalizer, `Dispose` method in your case won't be called during a finalization.
Comment: It is for the usual reason a class has to implement the disposable pattern.  Not to hurry up its finalization, that is exceedingly rare, but to call the dispose method of any of the fields of the class which are disposable.  BlockingCollection uses [two SemaphoreSlim objects](https://referencesource.microsoft.com/#System/sys/system/collections/concurrent/BlockingCollection.cs,61).  In practice is pretty unusual to have to call it since such a collection tends to live for the life of the app, and it is hard to do reliably since you need to be sure all consuming threads are completed.
Answer: I think the MSDN documentation for how to properly implement the dispose pattern is worth a read. However, the answer to your question is that BlockingCollection is not sealed. This means that it can be derived. The reason for the void Dispose(bool disposing) is to allow derived classes to properly de-allocate the resources of the base class. So, for example, I could implement
class Foo : BlockingCollection<string>
{
  private bool disposed = false;

  ~Foo()
  {
    Dispose(false);
  }

  protected override void Dispose(bool disposing)
  {
    if (disposed)
    {
      return;
    }

    if (disposing)
    {
      // free managed resources
    }

    // free unmanaged resources

    disposed = true;
    base.Dispose(disposing);
  }
}

By doing this, when Dispose() is called, the BlockingCollection will call Dispose(true) on Foo, which will eventually call Dispose(true) on BlockingCollection, and you get the benefit that the ~Foo() finalizer is suppressed. If the Dispose() method is not called, the finalizer is not suppressed, and it is called, allowing Foo to still deallocate its unmanaged resources.

C# BlockingCollection Dispose method


How to find all Code Reviews across Projects and Collections in TFS?

Question: We have 4 Team Project Collections with a dozen-or-so Team Projects each. We've started using the integrated Code Review system, and request reviews across those Collections and Projects.
Is there an easy way to find all Code Reviews you're involved in, across Collections or at least across Projects in a Collection? I'd prefer a way to do it in the Team Explorer inside Visual Studio, but have access to the web portal as well. I'd already be happy if I could search within a Collection, if it's not possible to do it across them.
I've carefully review the "My Work" section of the Team Explorer, and also closed the sln to try to force the context of the Explorer to the entire Collection. No dice: the "My Work" header still shows the actual Project in a dropdown.
I've tried to create a custom "Query", but am not sure how to proceed. The query that is generated has a clause to filter on Team Project = @Project, but I deleted that leaving me with basically this query:
Work Item Type = Code Review Request

I've left out State <> Closed for testing purposes, and I'd create a seperate query (I think) for work item type Code Review Response, but before I go there: the above query seems to give only reviews for the currently selected Team Project. Additionally, upon saving it, I get presented with a dialog that wants me to save the query inside a specific Project, further suggesting that it's still project-specific.
I'm using TFS 2013 but we tend to upgrade whenever it's useful so if there's upcoming features in newer version that solve this I'd be happy to hear about them.
Bottom line: how to get an overview of all your Code Reviews on your TFS server?
Answer: On VS 2015, Go to Team Explorer Home > Click on Work Items ... > Select New Query > Select "Reviewed By" in the Field column and add the related username in the Value field and run the query. You will see all the Code reviews you have been a part.
Answer: Sadly I don't think there is a nice way to do what you are asking. Certainly not within Team Explorer. Code Reviews as you are aware get stored as work items and there is a strong boundary between Team  Projects, which among other things, work items cannot cross. A note for the future, depending on how your business operates, you could consider 1 Team Project Collection, 1 Team Project and segregate your work by Teams and Areas. http://nakedalm.com/one-team-project/ this doesn't help you now of course.
I'm pretty sure that you will not be able to create a query using TFS to return the items you want (note, if you could, you would need to query for Work Item Response that are assigned to you Assigned To = @Me and not the Work Item Request. The request is the person making the code review request and the response is the reviewer(s).
Do you have tfs reports enabled? If so, as ds19 suggests, you could query the tfs_Warehouse db directly.
Another solution might be the TFS API but you will need TFS 2015 for that (which is packed full of features by the way) (Even though the link says it's for Visual Studio Online, it works for On-Prem too.)
I know this doesn't answer your question but hopefully it gives you some things to think about
Comment: On the contrary (to your final remark), this answers my question just fine. Thank you for your insight, and confirming my suspicion that this isn't *easily* possible. Just looks like we have too many Collections / Projects for our actual use case.
Comment: It's not necessarily a bad thing. The problem is that often it is assumed that a Team Project = Product which is not necessarily the case! Glad that I could be of help
Answer: You can query the Tfs_Warehouse database:
SELECT count(*), dwi.[TeamProjectCollectionSK]
  FROM [Tfs_Warehouse].[dbo].[DimWorkItem] dwi
  where dwi.System_WorkItemType = 'Code Review Request'
  group by dwi.[TeamProjectCollectionSK]

Comment: How does one "query the Tfs_Warehouse"? I'm a developer using TFS, not quite a TFS-administrator. The `Open Query` screens (from Team Explorer > My Work > Code Reviews) is a visual GUI for creating queries.
Comment: He means the mssql database, Tfs_Warehouse, this is assuming that you have the data warehouse enabled
Answer: Can you please double check that your query does not return any code reviews from other Team Projects by clicking "Column Options" on the Results sections and add "Team Project" field? [And verifying that you have a Code Review Request on another Team Project].[Don't worry if the Filter has an option for the Team Project selected for your Team Project on the Column Options window].
You can also test this by adding another value for the "Team Project" clause.


Assign VSTS bug item to next release via Rest API

Question: I have a requirement to assign a VSTS bug item to be fixed in next release using VSTS Rest API. I'm assuming "Microsoft.VSTS.Build.IntegrationBuild" is the field to update with next release version. However this field is not available in VSTS bug item UI(Build and test integration field reference). I also need to retrieve the next release information for the project via VSTS API, Is it possible to do this with current VSTS Rest API? Please advice.
Thanks in advance.
Comment: There isn't any way to link a bug to a release.
Answer: There isn't the REST API to link bug work item to release. Also, we can't to do it through UI (e.g. web access)
The work item be linked to the build can be track in the release. So you can link work item to changeset (REST API or manually), then the build associate to this changeset will associate that work item.


JavaScript: Not Calling Constructor Function

Question: Can someone shed some light as to why this doesn't work the way I think it should (or what I'm overlooking).
function Pane(data) {
    var state = {
        show: function(data) {
            var pane = document.querySelector('.pane[data-content='+data.target+']');
            pane.classList.add('active');
        },
        hide: function(data) {
            var pane = document.querySelector('.pane[data-content='+data.target+']');
            var paneSibling = $(pane.parentNode.childNodes);
            paneSibling.each(function(sibling) {
                if(check.isElement(sibling)) {
                    var isActive = sibling.classList.contains('active');
                    if(sibling != pane && isActive) {
                        sibling.classList.remove('active');
                    };
                };
            });
        }
    }
    return state;
}

So I can console log Pane(arg).show/hide and it'll log it as a function, so why is it when I call Pane(arg).show it doesn't do anything? The functions in the object work (outside of the constructor function in their own functions).
Comment: looks like you always return the whole state object, wich wont execute
Answer: The function is returning the state object, so it will never return the constructed object, even when used with new. Since state contains those methods, you can just call the function and immediately invoke one of the methods on the returned object.
Now, if you're expecting show and hide to automatically have access to data via closure, it's not working because you're shadowing the variable by declaring the method parameters. You can do this instead:
function Pane(data) {
    var state = {
        show: function() {
            var data = data || arguments[0];
            var pane = document.querySelector('.pane[data-content='+data.target+']');
            pane.classList.add('active');
        },
        hide: function() {
            var data = data || arguments[0];
            var pane = document.querySelector('.pane[data-content='+data.target+']');
            var paneSibling = $(pane.parentNode.childNodes);
            paneSibling.each(function(sibling) {
                if(check.isElement(sibling)) {
                    var isActive = sibling.classList.contains('active');
                    if(sibling != pane && isActive) {
                        sibling.classList.remove('active');
                    };
                };
            });
        }
    }
    return state;
}

Then you can use it like this:
Pane({}).show();

Or like this:
var p = Pane();
p.show();

Or force a new argument when needed:
p.show({foo:'bar'});

Answer: You are overriding the original argument in each function.
So what you are doing is to find elements with the attribute data-content='undefined'
This obviously doesn't work.
So to fix this you should just remove the data argument in the show/hide function.
Here is a plnkr showing the problem and fix.


What are the pros and cons of a client state in Rome 2: Total War

Question: Question speaks for itself.
When being or having a client state, what are the pros and cons? Or, more to the point: what exactly does it do.
Additional questions:

Can you order your client state to do things for you?
Can a client state break its client status with you and attack you?
Do you get any other benefits except the fee per turn (which is meager in my opinion).
Answer: Cons
1.) They prevent edicts. If a client state exists in one of your provinces you can't issue edicts because you don't control 100% of the province.
2.) They hold back provinces by limiting what you can build. You can't control what your client state builds, and even if you could, their building do not contribute to your province.
3.) I don't think the income from the client state tribute is significantly higher than what you would earn from directly controlling their settlement.
4.) It's impossible to diplomatically assimilate them into your faction. They will forever maintain their independence, no matter how long you rule over them.
5.) Client state or satrop by conquest; they will hate you for the war, for the conquest, and for the occupation of their city.
Pros
1.) Their last one or two settlements are a considerable distance from your borders. It might be better to take what little you can get by forcing them to become a client state to avoid thinning out your forces to capture, and then defend their settlements.
2.) You need to end a war. If you are fighting wars on multiple fronts and need some relief, this might be a better option than a simple peace agreement.
3.) If you create a client state out of a peaceful faction without conquest or war, they will not have these negative modifiers.
4.)They do give you a positive modifier for treaties with the faction when you create a client state. There is a balanced and logical diplomacy system.
Question 1: Yes, but you are very limited to what you can build.
Question 2: Yes, they can break their status with you if you do conquest by violence however they are very unlikely to do that even when they hate you.
Source:
http://forums.totalwar.com/showthread.php/96002-What-is-the-point-of-Client-States
http://forums.totalwar.com/showthread.php/95952-How-are-client-states-supposed-to-work


Get element with a certain value in a stringified data attribute

Question: Example:

What would be the fastest way to find the div with foo value 123? At the moment im looping through the divs, converting the stringified object to a js object and check if the foo value is equal to 123? Can this be done without a loop? Thanks
Comment: Even if you can't avoid the loop couldn't use regex instead of converting the object? I guess somehow/somewhere you can't avoid the loop but you may boost your performance avoiding parsing.
Comment: @alex Why is it an invalid attribute? I thought data-XYZ were valid HTML 5 attributes, where XYZ is any text string.
Comment: @harag Because the original post used `"` as the attribute value delimiter and then used `"` internally for the JSON object's keys. Which, BTW, only `"` is *valid* for JSON according to the spec, so the edit has produced invalid JSON.
Comment: @alex Thanks for pointing out it was the `original` post, I've only seen the edited version and it looked right to me. As for the `"` for JSON, that is new to me so thanks for pointing that out as well.
Answer: You could use filter()
var divs = $("div").filter(function() {
    var data = $.parseJSON($(this).data("object"));
    return data.foo == 123;
});

This does still use a loop internally though.
Comment: Not really. A loop is unavoidable in this case due to the requirement to check the value of the `data` attribute of each div. Neither method will be prohibitively slow though.
Comment: Thanks, im developing for ie7, thats why im asking >(
Answer: Use jquery selector
 function getdiv(id) {
              var divs = $('div[data-bh="{"foo":' + id + '}"]');
          }

Answer: You dont need to parseJson, this should work
var divs = $("div").filter(function() {return $(this).data("object").foo == 123;});

read towards the end to see more examples, http://www.elijahmanor.com/2012/03/find-jquery-bug-5-defective-data.html
but as @Rory Mentioned, this does use loop internally
Comment: That will always result in an empty collection. Use `return` and `==`.


CSS Styling Issue: classes are styled together, but look vastly different

Question: Trying to figure out why my input fields for my username & password are dramatically different, when they are paired together on my CSS file. Im fairly new and just thinking around, but not sure why there is a size difference.
Wonky sizing from password/ username fields. Disregard the horrible image as the logo, just playing around with it all.

*{
  font-family: "lato", sans-serif;
}
body{
  background-color: #59c9fc;
}
.login-div{
  margin: 100px auto;
  width: 350px;
  background-color: #fff
  padding: 60px;
}
.logo{

  background-color:#59c9fc;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  margin: 0 auto;
  margin-bottom: 10px;

}
.logo img{
  width: 100%;

}
.title, .sub-title{
  text-align: center;
  color: #505050;
  font-size: 35px;
}
.sub-title{
  font-size: 18px;

}

.form{
  width: 100%;
  margin-top: 30px;
}
.form input{
  font-size: 18px;
  padding: 10px 20px 10px 5px;
  border: none;
  outline: none;
  background: none;

}

 .username, .password {
  display: block;
  border-radius: 500px;
  border: 1px solid rgba(0, 0, 0,0.2);
  padding: 10px;
  margin: 10px 0;
  background-color: #fff;

}
.form svg{
  height: 20px;
  margin-bottom: -5px;
  margin-left: 10px;
  margin-right: 5px;
}
.options{
  display: flex;
  flex-direction: row;
  justify-content:space-between;
  padding: 5px 0px;
  margin-bottom: 30px;
}
<!DOCTYPE html>

  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link rel="preconnect" href="https://fonts.gstatic.com">
  <link href="https://fonts.googleapis.com/css2?family=Lato:wght@300;400&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="main.css" class="css">
  <title>Document</title>

Education Community

K-12 Education Consultants

        <svg class="svg-icon" viewBox="0 0 20 20">
          <path
            d="M12.075,10.812c1.358-0.853,2.242-2.507,2.242-4.037c0-2.181-1.795-4.618-4.198-4.618S5.921,4.594,5.921,6.775c0,1.53,0.884,3.185,2.242,4.037c-3.222,0.865-5.6,3.807-5.6,7.298c0,0.23,0.189,0.42,0.42,0.42h14.273c0.23,0,0.42-0.189,0.42-0.42C17.676,14.619,15.297,11.677,12.075,10.812 M6.761,6.775c0-2.162,1.773-3.778,3.358-3.778s3.359,1.616,3.359,3.778c0,2.162-1.774,3.778-3.359,3.778S6.761,8.937,6.761,6.775 M3.415,17.69c0.218-3.51,3.142-6.297,6.704-6.297c3.562,0,6.486,2.787,6.705,6.297H3.415z">
          </path>
        </svg>
        <input type="text" class="text" placeholder="username or email">

        <svg class="svg-icon" viewBox="0 0 20 20">
          <path
            d="M17.308,7.564h-1.993c0-2.929-2.385-5.314-5.314-5.314S4.686,4.635,4.686,7.564H2.693c-0.244,0-0.443,0.2-0.443,0.443v9.3c0,0.243,0.199,0.442,0.443,0.442h14.615c0.243,0,0.442-0.199,0.442-0.442v-9.3C17.75,7.764,17.551,7.564,17.308,7.564 M10,3.136c2.442,0,4.43,1.986,4.43,4.428H5.571C5.571,5.122,7.558,3.136,10,3.136 M16.865,16.864H3.136V8.45h13.729V16.864z M10,10.664c-0.854,0-1.55,0.696-1.55,1.551c0,0.699,0.467,1.292,1.107,1.485v0.95c0,0.243,0.2,0.442,0.443,0.442s0.443-0.199,0.443-0.442V13.7c0.64-0.193,1.106-0.786,1.106-1.485C11.55,11.36,10.854,10.664,10,10.664 M10,12.878c-0.366,0-0.664-0.298-0.664-0.663c0-0.366,0.298-0.665,0.664-0.665c0.365,0,0.664,0.299,0.664,0.665C10.664,12.58,10.365,12.878,10,12.878">
          </path>
        </svg>
        <input type="text" class="password" placeholder="password">

          <input id="remember-me" type="checkbox">
          Remember me?

          Forgot Password

      <button class="signin-btn">LOGIN</button>

        New client? Register here.

Comment: You set the password input display to block with `.username, .password { display: block;...`. While this rule also has the `.username` class, the username input field isn't using it, so it's not a block element
Comment: Oh gotcha, thank you so much !
Answer: Remove the password class form the password input.
<input type="text" placeholder="password">

* {
  font-family: "lato", sans-serif;
}

body {
  background-color: #59c9fc;
}

.login-div {
  margin: 100px auto;
  width: 350px;
  background-color: #fff padding: 60px;
}

.logo {
  background-color: #59c9fc;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  margin: 0 auto;
  margin-bottom: 10px;
}

.logo img {
  width: 100%;
}

.title,
.sub-title {
  text-align: center;
  color: #505050;
  font-size: 35px;
}

.sub-title {
  font-size: 18px;
}

.form {
  width: 100%;
  margin-top: 30px;
}

.form input {
  font-size: 18px;
  padding: 10px 20px 10px 5px;
  border: none;
  outline: none;
  background: none;
}

.username,
.password {
  display: block;
  border-radius: 500px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  padding: 10px;
  margin: 10px 0;
  background-color: #fff;
}

.form svg {
  height: 20px;
  margin-bottom: -5px;
  margin-left: 10px;
  margin-right: 5px;
}

.options {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  padding: 5px 0px;
  margin-bottom: 30px;
}
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Lato:wght@300;400&display=swap" rel="stylesheet">

Education Community

K-12 Education Consultants

      <svg class="svg-icon" viewBox="0 0 20 20">
        <path d="M12.075,10.812c1.358-0.853,2.242-2.507,2.242-4.037c0-2.181-1.795-4.618-4.198-4.618S5.921,4.594,5.921,6.775c0,1.53,0.884,3.185,2.242,4.037c-3.222,0.865-5.6,3.807-5.6,7.298c0,0.23,0.189,0.42,0.42,0.42h14.273c0.23,0,0.42-0.189,0.42-0.42C17.676,14.619,15.297,11.677,12.075,10.812 M6.761,6.775c0-2.162,1.773-3.778,3.358-3.778s3.359,1.616,3.359,3.778c0,2.162-1.774,3.778-3.359,3.778S6.761,8.937,6.761,6.775 M3.415,17.69c0.218-3.51,3.142-6.297,6.704-6.297c3.562,0,6.486,2.787,6.705,6.297H3.415z">
        </path>
      </svg>
      <input type="text" class="text" placeholder="username or email">

      <svg class="svg-icon" viewBox="0 0 20 20">
        <path d="M17.308,7.564h-1.993c0-2.929-2.385-5.314-5.314-5.314S4.686,4.635,4.686,7.564H2.693c-0.244,0-0.443,0.2-0.443,0.443v9.3c0,0.243,0.199,0.442,0.443,0.442h14.615c0.243,0,0.442-0.199,0.442-0.442v-9.3C17.75,7.764,17.551,7.564,17.308,7.564 M10,3.136c2.442,0,4.43,1.986,4.43,4.428H5.571C5.571,5.122,7.558,3.136,10,3.136 M16.865,16.864H3.136V8.45h13.729V16.864z M10,10.664c-0.854,0-1.55,0.696-1.55,1.551c0,0.699,0.467,1.292,1.107,1.485v0.95c0,0.243,0.2,0.442,0.443,0.442s0.443-0.199,0.443-0.442V13.7c0.64-0.193,1.106-0.786,1.106-1.485C11.55,11.36,10.854,10.664,10,10.664 M10,12.878c-0.366,0-0.664-0.298-0.664-0.663c0-0.366,0.298-0.665,0.664-0.665c0.365,0,0.664,0.299,0.664,0.665C10.664,12.58,10.365,12.878,10,12.878">
        </path>
      </svg>
      <input type="text" placeholder="password">

        <input id="remember-me" type="checkbox">
        Remember me?

        Forgot Password

    <button class="signin-btn">LOGIN</button>

      New client? Register here.

Codepen: https://codepen.io/manaskhandelwal1/pen/OJRKZEy?editors=1100
Comment: Incidentally, there is no "text" class in the CSS. The OP may have intended the "username" class.
Comment: I told to add the text class as he wanted to add some styling to both inputs. It is the same as remove it. I should change it. Thanks ✌.


Gps Track Detection Algorithm

Question: I am working on an Android app that will record (with GPS) the tracks that a user rides on their dirt bike. After finishing a ride I would like to be able to analyse this data and find the tracks that were ridden.
I will define a track as the travelled area between two intersections. An intersection being two or more points that are close enough to each other to be classified as one point. Obviously I need to decide on some sort of threshold for this.
Obviously I can do this with brute force checking every point against every other point but I think there must be a more efficient approach.
Any ideas on a better way?
Thanks Guys.
Comment: Working opensource algorithm here
http://stackoverflow.com/questions/4480434/simplification-optimization-of-gps-track/36195571#36195571
Answer: Kalman filter is frequently used to reject error (noise) points and to simplify GPS tracks and estimate real trajectories. Wiki page looks rather complex, so it would be nice to find some practical articles about track filtering.
Answer: To be practical:

the GPS points must be in the order of your ridding, so you only need to check some continuous points to be a intersection.
for every point, make it the center of a circle, see how many points stands in the circle, then you can combine these points into one intersection.
the generated intersections will also be in the order of your ridding.
Comment: How would this work in the situation where you come across the same intersection from a different track later in the ride?
Comment: @user1381573 if the points are (a1, a2, b1, b2, c1, c2, a1, a2), the generated intersections will be (a, b, c, a). think (a1, a2), (b1, b2) and (c1, c2) are both very close to each other.
Answer: For on-the-run stream like track simplification (I call it "streamplification") is: you keep a small buffer of the points the GPS sensor gives you, each time a GPS point is added to the buffer (elevation included) you calculate the max XTD (cross track distance) of all the points in the buffer to the line segment that unites the first point with the (newly added) last point of the buffer. If the point with the greatest XTD violates your max tolerated XTD error (25m has given me great results) then you cut the buffer at that point, register it as a selected point to be appended to the streamplified track, trim the trailing part of the buffer up to that cut point, and keep going. At the end of the track the last point of the buffer is also added/flushed to the solution. This algorithm is lightweight enough that it runs on an AndroidWear smartwatch and gives optimal output regardless of if you move slow or fast, or stand idle at the same place for a long time. The ONLY thing that maters is the SHAPE of your track. You can go for many minutes/kilometers and, as long as you are moving in a straight line (a corridor within +/- tolerated XTD error deviations) the streamplify algorithm will only output 2 points: those of the exit form last curve and entry on next curve.
Check this Q&A also
Simplification / optimization of GPS track

Gps Track Detection Algorithm


Memory alignment errors using Eigen with a dynamic library with Visual Studio 2013

Question: I've been using Eigen in my software, and I've run into an issue today, caused by changing my code from building a static library to dynamic library in Windows, using Visual Studio 2013.  The reason for this switch was not related to Eigen.
I am embedding Eigen in my own library file, which itself is then linked into my application(s).  As mentioned before, this library had been a static library until today; I have just updated my codebase to generate a DLL file instead.
Since making this change, I am now getting the following error message from Visual Studio:
The Block at -------------------- was allocated by aligned routines, use _aligned_free()
(that this message pops up numerous times with different addresses each time; I've used dashes above, as I don't believe that the specific addresses are relevant to this issue).
choosing "retry" opens the debugger to line 255 on Memory.h
Visual studio IntelliSense (when not debugging) suggests that EIGEN_ALIGN and EIGEN_HAS_MM_MALLOC are both defined as 1, EIGEN_MALLOC_ALREADY_ALIGNED and EIGEN_HAS_POSIX_MEMALIGN are both undefined.  Accordingly, it should be running _mm_free(ptr), which (again-based from IntelliSense) is an alias for _aligned_free(a).  As such, it appears that this code should be running the correct function, but it isn't.
When I change the code back to a static library, this issue goes away.
The only thing remotely relevant that I found from numerous Google searches was an article from Intel Fortran Compiler saying that this error message might come from a library which was compiled in an earlier version that is called by code compiled with the latest version.  Aside from the fact that I am using Visual Studio C++ 2013, I have rebuilt the code numerous times to be sure that it is all fully recompiled from a clean state and this error message persists.
I have downloaded the latest code from the mercurial repo (default branch), but this did not solve the problem.
I've tried to be as thorough as I could be.  If you need any more information, please let me know.
Edit:
Further context:
The 'client code' which utilizes the DLL in this case is Google Test; the error message is raised after testing an expectation -- i.e. the class in the DLL file is running the destructor to cleanup a temporary object.  I am not attempting to do evil things like allocate memory in the DLL file and then de-allocate it in the driver app -- that's partly why I find this to be so confusing....
Comment: Are you sure the DLL and the client using the DLL have been built the same? I'm thinking out loud - now that it is separate that the DLL is doing mallocs and frees one way and the client could be doing something else. Usually for this reason its not good practice for a client to call free on an object created in a DLL. Usually you export cleanup(ie free) routines from the DLL so that a client can call those instead of doing it directly. Same would be true for object creation.
Comment: @MichaelPetch I'm quite certain they're built the same. Certainly the DLL and static lib are identical (I only change the one setting).  Also- I'm not calling free from the client -- the code in question is DLL cleanup code.  In my case, the client is Google Test, which is running unit tests on the code in the library; the breakpoint is reached at a point where a temporary Eigen matrix destructor should be called.  I will update the question and clarify this for the benefit of others.  I see that this was not clear before.
Answer: I had this exact issue. I converted my static library which uses Eigen to a DLL and started getting these errors when unit testing with gtest. As there's no solution, I'll provide what I did to resolve the issue. Essentially the problem will be that you've created a new interface to the class containing Eigen matrices/vectors as member variables, and that interface creates a pointer to the class with your Eigen member variables.
Firstly, if you've got member variables which are Eigen matrices or vectors then you should read this. In summary you need to add

public:
   EIGEN_MAKE_ALIGNED_OPERATOR_NEW

to your class definitions where you use Eigen as member variables. Presumably you'll also be getting warnings about warning C4316: object allocated on the heap may not be aligned 16 if you're using the Visual Studio compiler.
Now, I still had issues after I used the EIGEN_MAKE_ALIGNED_OPERATOR_NEW, this was due to using atomic with an Eigen matrix class; boost::atomic<Eigen::MatrixXf> as a member variable. I imagine alignment is quite important when guaranteeing atomicity.


Sabotaged by X New Star Lite laptop running Ubuntu

Question: I have a Star Lite laptop that was purchased with Ubuntu as the operating system.
It was put into the EFI Shell version 2.70 [5.13]
<code>Current running mode 1.1.2
Device mapping table
fso :HardDisk-Alias hd12a65535a1 blk0
     PciRoot (0x0)/Pci(Ox12,0x0/Sata(0x0,0x0,0xFFF,0X0)/HD(1,GPT,E8B712B6-A82C-4388-A5AF-
     E0F4A3BD966B,0x800,0x800,0x100000)
blk0 :HardDisk - Alias hd12a65535a1 fso
blk1 :HardDisk - Alias (null)
blk2 :BlockDevice - Alias (null)

Press ESC in 1 second to skip startup. , any other key to continue.
Shell>_
</code>
Nothing happens when I press Esc or any other key; it is frozen. So I was wondering if I download ubuntu and reinstall it will that fix the problem? I am not worried about saving any files.
Answer: Prepare an Ubuntu 22.04 live USB by following the instructions in What is the proper way of creating installation media from Ubuntu iso?, and boot from it. Select the Try Ubuntu option to start an Ubuntu 22.04 live session. If the Ubuntu live session runs successfully click the Install Ubuntu 22.04
LTS icon on the desktop to start the Ubuntu 22.04 installer. From the Installation type screen of the Ubuntu installer select the Erase disk and install Ubuntu option.


Number of words with non-English characters, special characters such as punctuation, or digits at beginning or middle of word

Question: I need to count words with non-English characters, special characters such as punctuation, or digits at beginning or middle of word.
I trying to do it with re, and now it seems like
begin_searcher = re.compile(r'[0-9]+[\w\-]')
middle_searcher = re.compile(r'[\w\-]+[0-9]+[\w\-]')
both_searcher = re.compile(r'[0-9]+[\w\-]+[0-9]+[\w\-]')

But it works completely wrong. Anyone, who knows re better me, please help.
I need to count this:
'asfas1254asffas'
'125safasffa'
'asd!asfg'
'asff#dasf'
'sex!!!!'
'safщовфау'

etc
Comment: What output are you expecting from this input?
Comment: sorry, I forget about it. I think `True-False` enough, or word if `True`, `None` if `False`. Anyway I'll change code after-all
Answer: Since you mentioned "non-english" characters, I recommend using regex instead of stock re, because of the weak unicode support in the latter. Unless I misunderstood the question, you're looking for something like:
regex.match(ur'^\p{L}*[\p{P}\p{Nd}]*\p{L}+$', s) #

where s is expected to be a unicode object. This matches u"123щовßß" and u"щов456ßß" and rejects u"щовßß!!!".
Comment: I cant use non-standart libs :( Thank you anyway.
Answer: If it could help:
def find_alphabetic_words(self, text):
                    letters = ascii_letters
                    letters_nd_term = letters + "?!,."
                    return not any([set(text[:-1]).difference(letters),text[-1] not in letters_nd_term])


no graphics hardware acceleration (glx) in 20.04?

Question: I've just intalled ubuntu 20.04 on my laptop:
> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:    20.04
Codename:   focal

My laptop has two graphic cards:
> lspci -k | grep -iA3 vga
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
    Subsystem: ASUSTeK Computer Inc. 2nd Generation Core Processor Family Integrated Graphics Controller
    Kernel driver in use: i915
    Kernel modules: i915
--
01:00.0 VGA compatible controller: NVIDIA Corporation GF116M [GeForce GT 555M/635M] (rev a1)
    Subsystem: ASUSTeK Computer Inc. GeForce GT 555M
    Kernel driver in use: nvidia
    Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia

therefore, it is eligible to prime/optimus feature:
> prime-supported
yes

I set the default graphics controller to be the nvidia one:
> prime-select nvidia
Info: the nvidia profile is already set

... las, after reboot, the system runs fine, but there is no graphics hardware acceleration: browser games run terribly slow. This is confirmed by:
> glxinfo
name of display: :1
Error: couldn't find RGB GLX visual or fbconfig

Answer: solution: using
apt list *nvidia* | grep install

... I could compare my previous 19.10 system with the 20.04 one, and discovered that nvidia-dkms-390 package was missing (why ?).
So, installing it solved the problem:
apt install nvidia-dkms-390


Number of blocks in this design $(V,\mathcal{B})$ $|V|=16$ and $\mathcal{B}$ has size $4$

Question: Let $(V,\mathcal{B})$ be a design in which $|V|=16$, each block in $\mathcal{B}$ has size $4$, and each pair of points occurs in precisely one block.

How many blocks are in this design?

Try 1: Now I can see that we have ${16 \choose 2}=120$ different blocks of size $2$. But this leaves the remaining two positions to be anything. They could be one of the other $2$-blocks.
I can't see how to get there from here. So I abandon this.

Try 2: $16$ blocks with $1$ paired with the other numbers. Without recounting the $(1,2)$ pair $15$ with $2$. This is where I realise this can't work because I am ignoring the other two numbers

Try 3:
every $1$ pairing
$\{1,2,3,4\},\{1,5,6,7\},\{1,8,9,10\},\{1,11,12,13\},\{1,14,15,16\}$
$2$
$\{2,5,6,7\},\{2,8,9,10\},\{2,11,12,13\},\{2,14,15,16\}$
$3$
$\{3,5,6,7\},\{3,8,9,10\},\{3,11,12,13\},\{3,14,15,16\}$
$4$
$\{4,5,6,7\},\{4,8,9,10\},\{4,11,12,13\},\{4,14,15,16\}$
$5$
$\{5,8,9,10\},\{5,11,12,13\},\{5,14,15,16\}$
$6$ has three, $7$ has three, $8$ has two, $9$ has two, $10$ has two and $11,12,13$ have one.
This gives a total of $5+4*3 + 3*3 + 2*3 + 3=35$
This might not even be right, and it is exhaustive. How can I do this properly???

Try 4:
I tried to construct a latin square, but soon realized this would only give me blocks of size $3$(I believe)
Answer: If every pair of elements is contained in precisely 1 block, then each element is contained in 5 blocks, because in each block there are 3 other elements, and $16=3\cdot 5+1$. We have 16 elements, therefore $16\cdot 5$ is 4 times the number of blocks. Thus the number of blocks must be 20, if there is such a design.
From the catalogue of small designs we know, that there is precisely one such design.
Remark: your Try 3 does not work simply because you are putting some pairs of elements too many times together into one block. For example, pair 15,16 appears 5 times.
Answer: Your first attempt is a good start. You have ${16 \choose 2} = 120$ pairs that each need to show up precisely once together in a block.  Each of the $b$ blocks contains ${4 \choose 2} = 6$ pairs, giving $b \cdot 6 = 120$.  Thus $b = 20$.


iOS multiplayer game - what to use for the multiplayer part?

Question: I'm developing a game for iOS that should include the multiplayer. It's not a turn-based, rather a real-time game. I know I can use some different approaches here:

Game Center multiplayer (has matching and searching for matches, gives authentication out-of-the-box, additional are leaderboards and achievements)
As far as I know, OpenFeint also includes some multiplayer helpers
I can also write my own sever code, but woudn't it be reinventing the wheel? I'd also loose all the good stuff from GC...

Any suggestions here? What's the leading market solution, that doesn't take too much to integrate into a game; I'd like to be able to send short bits of data between players (player position + action taken) in a real time. Best would be to reduce the lag :)
Answer: personally, i think the easiest way to go is with gamecenter. it was pretty straightforward to integrate it into an existing game - i'd say it took 2-3 weeks. the main problems that we encountered were to do with the game simulation not being particularly suited to multiplayer, rather than anything to do with dealing with gamecenter.
Answer: You may also consider Nextpeer (disclosure: I work there). GameCenter is good, but it has the downside of not being cross-platform. We offer a solution that is cross-platform (iOS, Android and Unity3d) and is geared towards multiplayer in casual games. So we provide the hosting, the player-to-player communication, the matchmaking, and Facebook integration.


Finding the series expansion of $\frac{1}{z-b}$ around $a$

Question: I'm working through a question where I'm asked to find the series expansions of various functions around certain points. I've found the answer for most of the examples, but the last part of the question asks me to find the series expansion of $f(z) = \frac{1}{z-b}$ around some point $a$, and I can't work out how it's done.
I'd really appreciate any help you could offer me.
Answer: Just us the fact that$$\frac1{z-b}=\frac1{(z-a)-(b-a)}=-\frac1{b-a}\times\frac1{1-\frac{z-a}{b-a}}$$and expand $\dfrac1{1-\frac{z-a}{b-a}}$  using the geometric series.


Let $(X,\tau)$ be a topological space. If $X$ has the Bolzano-Weierstrass property then $X$ is compact.

Question: Where the indiscrete topology was used (in the counterexample)?
Let $(X,\tau)$ be a topological space. If $X$ has the Bolzano-Weierstrass property then $X$ is compact.
Counterexample
Let $Y$ consist of two points; give $Y$ the topology consisting of $Y$ and the empty set. Then the space $X = \mathbb{Z}_{+} \times Y$ is limit point compact, for every nonempty subset of $X$ has a limit point. It is not compact, for the covering of $X$ by the open set $U_n = \{n\} \times Y$ has not finite collection covering $X.$
Comment: Note: I know the definition of the trivial topology but I don't see where was applied in the proof.
Comment: Or what happens If one doesn't use it.
Answer: It is used in the highlighted portion.

give $Y$ the topology consisting of $Y$ and the empty set. Then the
  space $X = \mathbb{Z}_{+} \times Y$ is limit point compact, for
  every nonempty subset of $X$ has a limit point.

That is true only because in Y, every point is a limit point because it has the indiscrete topology.
Let the points of Y be named $y_1$ and $y_2$. For any point $z=(n, y_1)\in X$, any neighborhood of $z$ must also contain the point $(n, y_2)$ (and vice versa). So every point of $X$ is a limit point.  Note that the author has used the product space notation for X, I.e., the author is using the topology on $X$ which is a product of the discrete topology of $\mathbb{Z}_+$ and whatever topology is put on $Y$.
As to what happens if Y did not have the indiscrete topology... there are only 3 other possible topologies - the discrete topology and the two Sierpiński topologies. In all those cases, you can find a singleton set that is open in X and it is no longer true to say "every nonempty subset of $X$ has a limit point".
Comment: If $Y=(y_1,y_2), x=y_1, n=1 $ then $\mathbb N\times Y-\{x\}=(1,(y_1,y_2))-\{y_1\} \bigcap (y_1,y_2)=y_2$? where x is the limit point.
Comment: @Isabella Please see an expanded answer I posted. Two things I don't follow in your comment: One si the meaning of "x=y_1" and the second is the meaning of {y_1}. Points in X are ordered pairs, so I don't follow what {y_1} by itself means.
Answer: Points in $X$ look like $(n,y)$ with $n \in \mathbb Z$ and $y \in Y = \{y_1, y_2\}$.
Let $A$ be a nonempty subset of $X$ and let $x \in A$. If $U$ is an open set containing $x$, then it must be of the form $B \times Y$ with $B \subset X$ due to the topology of $Y$.
If $x = (n,y_1)$ for $x \in \mathbb Z$, then $x$ is a limit point since $U - \{x\}$ contains the point $(n,y_2)$ and is therefore nonempty. Hence every point in $X$ is a limit point.

Edit: The topology on $X$ is the natural product topology of the discrete topology on $\mathbb Z_+$ and the indiscrete topology on $Y$. That is, a set $U = G \times Z$ is in the topology of $X$ if $G$ is in the topology of $\mathbb Z_+$ (any subset) and  $Z$ is in the topology of $Y$ (i.e. $\emptyset$ or $Y$).
Comment: The topology on $X$ is the natural product topology of the topology on $\mathbb Z_+$ and the topology on $Y$.
Comment: $Y$ has the trivial topology. X has the trivial topology too?
Comment: @Isabella No. In order for the example to work, the sets $\{n\}$ must be open in $\mathbb Z_+$.
Comment: But if you notice, in the statement it says something about a topological space $(X,\tau)$, and  $X=\mathbb N\times Y$, what is the topology $\tau$ of X?
Comment: Shouldn't be $A\subset B?$
Comment: @Isabella Not necessarily. I edited to $B \subset X$.


For which $k$ we have: $|x_k-\alpha|\le10^{-16}|\alpha|$ where $\alpha$ is a solution of the equation $10x-\sin x=3$?

Question:
Let iterative method which is determined by the formula $x_{n+1}=\frac{\sin (x_n)+3}{10}$ for $x_0=0.33$. For which $k$ we have: $|x_k-\alpha|\le10^{-16}|\alpha|$ where $\alpha$ is a solution of the equation $10x-\sin x=3$?

The iterative function is $F(x)=\frac{\sin (x)+3}{10}$.  Let $e_k=|x_k-\alpha|$.
$$e_{k+1}=|x_{k+1}-\alpha|=|F(x_k)-F(\alpha)|=|F'(\theta)|\cdot|x_k-\alpha| \text{ for } \theta \text{ between }x_k,\alpha $$ So: $|x_k-\alpha|=\frac{|x_{k+1}-\alpha|}{|F'(\theta)|}$ and we want to $\frac{|x_{k+1}-\alpha|}{|F'(\theta) \alpha|}\le10^{-16}.$
However I don't know how I can calculate $k$ because $\frac{\sin (x_k)+3-10\alpha}{\cos (\theta) \alpha}\le 10^{-16}$ is difficult to estimate...
Answer: We can estimate $|F(x) - F(y)| \le |x - y|/10$, so certainly $|x_k - \alpha| \le 10^{-k} |x_0 - \alpha|$.  That will give us a rough (but not very big) bound, and if we want
a more exact number we can compute a few iterations.
Answer: As Robert Israel answered, a good idea would be to perform a few iterations (this is quite easy with a spreadsheet).
Let me be very lazy perrforming four iterations with
$$x_{n+1}=\frac{\sin (x_n)+3}{10}\qquad \text{with} \qquad x_0=0.33\qquad \text{and} \qquad \Delta_n=x_{n+1}-x_{n}$$ Below are the results (I included the logarithm of $\Delta_n$ since it is a typical parameter for the order of convergence))
$$\left(
\begin{array}{cccc}
n & x_n & \Delta_n & \log_{10}( \Delta_n) \\
 0 & 0.330000 & 2.4043 \times 10^{-3} & -2.61901 \\
 1 & 0.332404 & 2.2736 \times 10^{-4} & -3.64328 \\
 2 & 0.332632 & 2.1491 \times 10^{-5} & -4.66775 \\
 3 & 0.332653 & 2.0313 \times 10^{-6} & -5.69223 \\
 4 & 0.332655 & 1.9199 \times 10^{-7} & -6.71672
\end{array}
\right)$$
Plotting $\log_{10}( \Delta_n)$ as a function of $n$ reveals an almost perfect linear relation. A quick and dirty linear regression gives
$$\begin{array}{clclclclc}
 \text{} & \text{Estimate} & \text{Standard Error} & \text{Confidence Interval} \\
 a & -2.61892 & 0.000075 & \{-2.61925,-2.61860\} \\
 b & -1.02444 & 0.000031 & \{-1.02457,-1.02430\} \\
\end{array}$$
So, let us use $$\log_{10}( \Delta_n)=-2.61892-1.02444\,n$$ Using if for $10^{-16}$ leads to $n = 13.0619$ so, more than likely $n=14$.
Just to check, let us continue the rigorous calculation of the sequences and effectively
$$\log_{10}( \Delta_{13})=-15.9546\qquad \text{and} \qquad \log_{10}( \Delta_{14})=-16.9616$$


Where can I find these textured cast concrete blocks?

Question: I am trying to match up some old blocks but ain't having much luck.
Would anybody know the name or style of the block?
Answer: I can't find them offered online either. The quality/style has changed quite a bit since those were made, and I think they've been outmoded.
I found something similar: http://www.uticacast.com/Veneer.htm


Expected value of independent random variables

Question: So I have this problem where I need to find $E(4X+3Y-2Z^2-W^2+8)$ where $W,X,Y,Z$ are all standard normal and I'm kind of confused on how to find the expected value here. I thought to do it we just had to add the means together like this: $E(X_1+X_2+X_3)=\mu_1+\mu_2+\mu_3$ as long as they are iid of course. How come the answer is $5$?
I tried doing $$\begin{align}E(4X+3Y-2Z^2-W^2+8)\\ =E(4X)+E(3Y)-E(2Z^2)-E(W^2)+E(8)\\ =4E(X)+3E(Y)-2E(Z^2)-E(W^2)+8\\=(4*0)+(3*0)-(2*0)-0+8\\=8\end{align}$$ And quite obviously $8$ doesn't equal $5$. So I'm just not sure where I went wrong.
Comment: $E(X_1+X_2+X_3)=E(X_1)+E(X_2)+E(X_3)$ is true so long as the right hand side is meaningful, no matter where they are *iid* or not.
Answer: The variance of $Z$ is $E(Z^2)-(E(Z))^2$. Since the variance is $1$, and $E(Z)=0$, we have $E(Z^2)=1$. Same for $W^2$. That gets us $5$. The error was in thinking that $E(Z^2)=0$ and $E(W^2)=0$.
Comment: Ah I see, I think I knew that too. Thanks for the reminder.
Answer: You cant open $E(X+Y^2 ) = E(X) + E(Y^2)$.
It is not linear at all .
Comment: Linearity of expectation has nothing to do with independence... it's just linear, period.


Problems with gulp and gulp-diff

Question: I'm wanting my gulpfile.js to compare what is in my angular concatenated file before it has ng-annotate run and after so I can see what injections it made.  I can't quite get the syntax.  I keep getting different versions of the error which says gulp can not stat my file.
The code that I'm stuck on is below.  I'd be happy to do it in one pass but had no success with that either.
gulp.task('scripts', function () {

    gulp.src(['public/app/**/*.js'])
        .pipe(concat('main-noanotate.js'))
        .pipe(rename({suffix: '.noannotate.js'}))
        .pipe(gulp.dest('public/dist'));

    return gulp.src(['public/app/**/*.js'])
        .pipe(concat('main.js'))
        .pipe(ngAnnotate())
        .pipe(diff('main.noannotate.js'))
        .pipe(diff.reporter({ fail: true }))
        .pipe(gulp.dest('public/dist'))
});

Comment: I'm still struggling with this.  I got it sort of working (posted a blog post) but it still is not right.  I can't run my scripts task inside a normal full gulp default processing.  http://peterkellner.net/2014/11/14/angular-ngannotate-better-way/
Answer: gulp-diff is trying to diff against the original source file, but there is no original source file on disk as you're working with the result of a concatenation of multiple files. I recommend splitting out your gulp tasks and writing to a temporary .build directory.
Here is an example of clearing a build workspace.
To set things up, create a new directory and run:
npm install del gulp gulp-concat gulp-diff gulp-header; mkdir -p src; echo "foo" > src/foo.txt; echo "bar" > src/bar.txt

Then create this gulpfile.js:
'use strict';

var gulp = require('gulp');
var diff = require('gulp-diff');
var header = require('gulp-header');
var concat = require('gulp-concat');
var del = require('del');

gulp.task('default', ['clean']);

gulp.task('clean', ['build'], function(cb) {
  del(['.build'], cb);
});

gulp.task('build', ['concat'], function() {
  return gulp.src('.build/all.txt')
    .pipe(header('//stream test\n'))
    .pipe(diff())
    .pipe(diff.reporter())
    .pipe(gulp.dest('./dist'));
});

gulp.task('concat', function() {
  return gulp.src('src/*.txt')
    .pipe(concat('all.txt'))
    .pipe(gulp.dest('.build'));
});

Then try running gulp. It should concat the file and put the output into the temporary .build directory. That file is then used to diff against. In the above example header is doing the job of amending the file (this might be where you apply ngAnnotate instead).
Comment: Perfect! just tested and it works every time. I owe you Mr. Sky!

Problems with gulp and gulp-diff


javax.servlet.ServletException: Class [org.springframework.web.servlet.DispatcherServlet] is not a servlet

Question: I am deploying a Spring 6.0.5 on Tomcat 8.5.81 with the following configuration (using web.xml and org.springframework.web.servlet.DispatcherServlet).
My web.xml is configured as follows:
<servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>

    </servlet>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/dispatcher-config.xml</param-value>
    </context-param>

       <listener>
   <listener-class>
     org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>

<servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

dispatcher-config.xml is as follows:
 <mvc:annotation-driven/> <mvc:resources mapping="/resources/**" location="/resources/"/> <context:component-scan base-package="org.mainPackage" /> <context:annotation-config/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix">
                <value>/WEB-INF/views/</value>
            </property>
            <property name="suffix">
                <value>.jsp</value>
            </property>
        </bean>

And finally pom.xml relevant dependencies are what follows:
<properties>

    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <java.version>17</java.version>
    <tomcat.version>8.5.81</tomcat.version>
    <servlet-api.version>3.1.0</servlet-api.version>
</properties>

 <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
   <version>6.0.5</version>
</dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>6.0.5</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>6.0.5</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.servlet.jsp.jstl</groupId>
            <artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
            <version>3.0.0</version>
        </dependency>

<dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

The root cause of the error being :
java.lang.ClassCastException: class org.springframework.web.servlet.DispatcherServlet cannot be cast to class javax.servlet.Servlet (org.springframework.web.servlet.DispatcherServlet is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @4ac6da24; javax.servlet.Servlet is in unnamed module of loader java.net.URLClassLoader @28c97a5)

Why this is happening? and how can this issue be solved?
Thanks.
Answer: Spring 6 has moved from javax to jakarta completely.
With that in mind other of libraries needs to be updated.
Tomcat 8.5 to Tomcat 10.
And JDK 1.8 to JDK17.
Also please keep in mind that any javax libraries need to be replaced with the one that uses jakarta.
I think that replacement for that is

<dependency>
    <groupId>jakarta.servlet</groupId>
    <artifactId>jakarta.servlet-api</artifactId>
    <version>6.0.0</version>
    <scope>provided</scope>
</dependency>

Or you can simply keep your Tomcat and JDK version but use Spring 5.
So in short

javax is for Spring 5, and any Tomcat until Tomcat 10.
jakarta libraries are for Spring 6, Tomcat 10, and minimum JDK17.

You cannot mix jakarta and javax because simply they are not compatible unless you are ready to rename packages by hand.
Comment: I downgraded all Spring dependencies (core, context, mvc..) to The type version 5.3.25 with scope provided but now I get an error in the ServletInitializer class saying  `ServletInitializer must implement the inherited abstract method WebApplicationInitializer.onStartup(ServletContext)`


How do I interact with mobs after changing game mode?

Question: I have a problem, whenever I change from creative to survival mode, it wont let me interact with mobs, I cant attack them nor feed them.
Comment: What exact /gamemode commands are you using? What version of Minecraft? You SHOULD be able to attack mobs without a weapon (@MBraedley), unless you gave yourself a weakness effect (which I assume you did not do).
Comment: This is standard behaviour.  `/give` yourself a sword if you want to attack them.
Comment: Are you sure you can not interact? Try /give (your name) diamond_sword 1
then
Comment: @JamesOfDaPeach Yeah, I suppose your correct. I guess I just keep getting fed up with punching mobs.
Comment: Can you interact with the game in general (e.g. break/place blocks)? Are you using any mods?
Answer: In creative mode the mobs are set to basically ignore you. (nobody wants a creeper messing up there creative mojo.) They will only notice you or engage with you if you touch them in some way. (note: not sure if just looking at an enderman will set him off in creative. you may have to touch them as well)
Hope this helps.
Comment: Endermen do get angry if you look at them in creative, they will come up really close and do the thing where their mouths open, but won't be able to hurt you


Make title of page bold

Question: I tried to make the title of the page bold but the  tag just shows up as a tag instead of making it bold. How do I fix this?
<code>document.title = "<b> Text </b>";
</code>
Comment: Possible duplicate of [How to bold title html tag](https://stackoverflow.com/questions/56121872/how-to-bold-title-html-tag)
Answer: You can't.
The title element can only have text node descendants, not elements.
It is primarily used in user interface elements such as favourite menus and browser tabs which are not designed to hold formatted text.

Make title of page bold


Passing value to Bootstrap Modal for PHP PDO Query

Question: I am displaying a table of values with two options, delete or update. When I select delete I want to display the row to be deleted. This last point using Bootstrap Modals.
This is my Delete Modal

        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>

Delete a Campaign

Please find the campaign ID to be deleted below

        <input type="text" name="bookId" id="bookId" value="" />

            #
            Description
            Creation Date
            Credit
            ROI
            Active

          <?php

             $id = $row['data-campaignid'];// This is where I am having the problem
             $stmt = $user_home->runQuery("SELECT * FROM campaigns WHERE id_campaigns=:id");
               $stmt->execute(array(":id"=>$id));
             while($row=$stmt->fetch(PDO::FETCH_BOTH))
             {
                 ?>

                <?php print($row['id_campaigns']); ?>

                <?php print($row['descripcion']); ?>

                <?php print($row['fec_creacion']); ?>

                <?php print($row['saldo']); ?>

                <?php print($row['ROI']); ?>

                <?php print($row['active']); ?>

            <?php
             }
             ?>

        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

So as you can see I am passing a value "bookid" to the modal using the following JQuery script
$(document).on("click", ".open-DeleteDialog", function () {
     var myCampaignId = $(this).data('campaignid');
     $(".modal-body #bookId").val( myCampaignId );

});

The difficulty I am encountering is how to use the value of the input (bookID) to pass it over to the PHP PDO Query and execute it while being able to show that data on the table.
Comment: Possible duplicate of [How to pass $\_GET variables from a link to a bootstrapmodual?](http://stackoverflow.com/questions/32433765/how-to-pass-get-variables-from-a-link-to-a-bootstrapmodual)
Answer: JQuery is executed on client side while SQL queries are on server side.
So, you need to use AJAX. This would be a very long answer, please take a look at this CRUD+AJAX tutorial.


Text cut at page break when print

Question: My text inside a div is cut at page break when trying to print in Chrome. I've tried all kinds of page-break-xxx, as well as orphans: 5; widows: 5; page-break-after: avoid; page-break-before: avoid;. I've also tried to set the div to display as table, block, inline, inline-block... but nothing works. I've spent a lot of time googling... I believe this must be answered somewhere... Could anyone point me to a direction as how or where to find the solution? Thanks in advance!

    {{ product.metafields.a }}

    {{ product.metafields.b }}

    {{ product.metafields.c }}

The code looks like above. They are actually tabs, and I force them to all show up on print. I've tried all kinds of page-break-xxx on .tab-pane.
{{ product.metafields.x }} are basically texts like H2, P tags.
Comment: can you post the full code?
Comment: Possible duplicate of [CSS Printing: Avoiding cut-in-half DIVs between pages?](http://stackoverflow.com/questions/907680/css-printing-avoiding-cut-in-half-divs-between-pages)
Answer: I don't know why it didn't work at first... probably used on the wrong element. but just tried again and this fixes the problem
CSS Printing: Avoiding cut-in-half DIVs between pages?
Answer: Try adding class to your elements,
for instance.

then on your print.css
add this
.no-break{ page-break-before: always; }

This will allow your page from being uncut.
Comment: thanks for your tip. I tried adding `page-break-before: always` on `.tab-pane` (which is the wrapper around the text), and the text elements inside, but neither is a success.

Text cut at page break when print