text:
Q: Can't hide navigation bar using only CSS and HTML I am working on the Free Code Camp project for which you need to make a product landing page.
I have everything that I want already except for two things.

*

*The navigation bar goes behind the hero header image

*When the user scrolls down, I want the navigation bar to be hidden – it currently does not do this.

Here is my code:

@import "https://fonts.googleapis.com/css?family=Lato:400,700";
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: #eee;
  font-family: 'Lato', sans-serif;
}

#page-wrapper {
  position: relative;
}

li {
  list-style: none;
}

a {
  color: #000;
  text-decoration: none;
}

/** global classes styling **/

.container {
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
}

.btn {
  padding: 0 20px;
  height: 40px;
  font-size: 1em;
  font-weight: 900;
  text-transform: uppercase;
  border: 3px black solid;
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
}

.grid {
  display: flex;
}

header {
  position: fixed;
  top: 0;
  min-height: 75px;
  padding: 0px 20px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background-color: #eee;
}

@media (max-width: 600px) {
  header {
    flex-wrap: wrap;
  }
}

.logo {
  width: 60vw;
}

@media (max-width: 650px) {
  .logo {
    margin-top: 15px;
    width: 100%;
    position: relative;
  }
}

.logo>img {
  width: 100%;
  height: 100%;
  max-width: 300px;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  margin-left: 20px;
}

@media (max-width: 650px) {
  .logo>img {
    margin: 0 auto;
  }
}

nav {
  font-weight: 400;
  background-color: white;
}

@media (max-width: 650px) {
  nav {
    margin-top: 10px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0 50px;
    transition: top 0.1s;
    /* Transition effect when sliding down (and up) */
  }
  nav li {
    padding-bottom: 5px;
  }
}

nav>ul {
  width: 35vw;
  display: flex;
  flex-direction: row;
  justify-content: space-around;
}

@media (max-width: 650px) {
  nav>ul {
    flex-direction: column;
  }
}

#hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 300px;
  margin-top: 50px;
}

#hero>h2 {
  margin-bottom: 20px;
  word-wrap: break-word;
}

#hero input[type="email"] {
  max-width: 275px;
  width: 100%;
  padding: 5px;
}

#hero input[type="submit"] {
  max-width: 150px;
  width: 100%;
  height: 30px;
  margin: 15px 0;
  border: 0;
  background-color: #f1c40f;
}

#hero input[type="submit"]:hover {
  background-color: orange;
  transition: background-color 1s;
}

@media (max-width: 650px) {
  #hero {
    margin-top: 120px;
  }
}

#features {
  margin-top: 30px;
}

#features .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 125px;
  width: 20vw;
  color: darkorange;
}

@media (max-width: 550px) {
  #features .icon {
    display: none;
  }
}

#features .desc {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 125px;
  width: 80vw;
  padding: 5px;
}

@media (max-width: 550px) {
  #features .desc {
    width: 100%;
    text-align: center;
    padding: 0;
    height: 150px;
  }
}

@media (max-width: 650px) {
  #features {
    margin-top: 0;
  }
}

#aboutOurApp {
  margin-top: 50px;
  display: flex;
  justify-content: center;
}

#aboutOurApp>iframe {
  max-width: 560px;
  width: 100%;
}

#pricing {
  margin-top: 50px;
  display: flex;
  flex-direction: row;
  justify-content: center;
}

#aboutOurCompany {
  margin-top: 1px;
  display: flex;
  flex-direction: row;
  justify-content: center;
}

.product {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: calc(100% / 3);
  margin: 10px;
  border: 1px solid #000;
  border-radius: 3px;
}

.product>.level {
  background-color: #ddd;
  color: black;
  padding: 15px 0;
  width: 100%;
  text-transform: uppercase;
  font-weight: 700;
}

.product>h2 {
  margin-top: 15px;
}

.product>ol {
  margin: 15px 0;
}

.product>ol>li {
  padding: 5px 0;
}

.product>button {
  border: 0;
  margin: 15px 0;
  background-color: #f1c40f;
  font-weight: 400;
}

.product>button:hover {
  background-color: orange;
  transition: background-color 1s;
}

@media (max-width: 800px) {
  #pricing {
    flex-direction: column;
  }
  .product {
    max-width: 300px;
    width: 100%;
    margin: 0 auto;
    margin-bottom: 10px;
  }
}

footer {
  margin-top: 30px;
  background-color: white;
  padding: 20px;
}

footer>ul {
  display: flex;
  justify-content: flex-end;
}

footer>ul>li {
  padding: 0 10px;
}

footer>span {
  margin-top: 5px;
  display: flex;
  justify-content: flex-end;
  font-size: 0.9em;
  color: #444;
}

body {
  background-color: white;
}

.hero-image {
  /* Use "linear-gradient" to add a darken background effect to the image (photographer.jpg). This will make the text easier to read */
  background-image: url("https://collectivecloud.org/wp-content/uploads/2019/12/iphone-410324_1280-1024x682.jpg");
  /* Set a specific height */
  height: 900px;
  width: 1920px;
  max-width: 100%;
  /* Position and center the image to scale nicely on all screens */
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  position: relative;
}

.hero-text {
  text-align: center;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 50px;
}

.hero-text button {
  border: none;
  outline: 0;
  display: inline-block;
  padding: 10px 25px;
  color: black;
  background-color: #ddd;
  text-align: center;
  cursor: pointer;
}

.hero-text button:hover {
  background-color: #555;
  color: white;
}

Features

About Our App

Pricing

Auto Build Websites

Best app out there

SEO Optimization

              Increases the quality and quantity of website traffic by increasing the visibility of a website or a web page to users of a web search engine

Responsive Design

              Responsive web design is an approach to web design that makes web pages render well on a variety of devices and window or screen sizes.

24/7 Support

              We provide 24/7 full support to our customers who are always looking to improve their business.

We at Collective Cloud, LLC offer a range of services that will improve your business and help your business have a better internet presence. We offer a pro website with features tailored to your business that will give you a competing edge in
          your industry.

Free App

FREE

Contains Ads

Restricted Functionality

No Social Media

            <button class="btn">Select</button>

Paid App

$100

No Ads

Full functionality

Can Upgrade

            <button class="btn">Select</button>

Pro App

$200

No Ads

Premium Functionalities

Code-Level Support

            <button class="btn">Select</button>

Checkout How it Works

Best Website Development App in the World

Don't miss out on any updates!

          <form id="form" action="https://www.freecodecamp.com/email-submit">
            <input name="email" id="email" type="email" placeholder="Subscribe Now" required />
            <input id="submit" type="submit" value="Get Started" class="btn" />
          </form>

Privacy

Terms

Contact

About Us

          Copyright 2020, Collective Cloud, LLC

A: in your CSS add
position: relative;
left: -14px;

or just use
overflow: hidden;   //it won't show at all
overflow: auto;     //scrollbar will only show when content is more


text:
Q: Debugging - Capture The State Of An iOS App My app has a bug, which I am unable to replicate when it is run when plugged into the computer.
I see it three times a day and it is quite annoying.
Is there any way to capture the state of the app (when not connected to the computer) and see what's going on? Kind of like what XCode does when you use a breakpoint, but somehow send the data to it (or some order tool that I am unaware of) wirelessly.

UPDATE:
The app does not crash. It's just that certain UITableViewCells don't work as they should at certain times.

A: Try using Crashlytics its awesome for crashes. You should also use TestFlight which will give you live sessions/logs of your app. These both combined will tell you many things.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Evaluation of a Sum Find the sum:
$$\sum_\limits{i=0}^\infty\sum_\limits{j=0}^\infty \frac{1}{a^i\cdot a^j}$$ where $i \not= j$ and $a>1$

A: $$\sum_\limits{i=0}^\infty\sum_\limits{j=0 \\ i\not=j}^\infty \frac{1}{a^i\cdot a^j}$$
$$\sum_\limits{i=0}^\infty\sum_\limits{j=0}^\infty \frac{1}{a^i\cdot a^j}-\sum_\limits{j=0}^\infty \frac{1}{a^{2j}}$$
$$=\left(\sum_\limits{i=0}^\infty \frac{1}{a^i}\right)\left(\sum_\limits{j=0}^\infty \frac{1}{a^j}\right)-\frac{1}{1-\frac{1}{a^2}}$$
$$=\frac{1}{1-\frac{1}{a}} \cdot \frac{1}{1-\frac{1}{a}}-\frac{a^2}{a^2-1}$$
$$=\left(\frac{a}{a-1}\right)^2-\frac{a^2}{a^2-1}$$
$$=\frac{a^2}{a-1}\left(\frac{1}{a-1}-\frac{1}{a+1}\right)$$
$$=\frac{2a^2}{(a-1)^2(a+1)}$$
Hope this helps you.


text:
Q: ghc-7.6 class instances for dependent types Heterogeneous lists are one of the examples given for the new dependent type facility of ghc 7.6:
data HList :: [*] -> * where
  HNil :: HList '[]
  HCons:: a -> HList t -> HList (a ': t)

The example list "li" compiles fine:
li  = HCons "Int: " (HCons 234 (HCons "Integer: " (HCons 129877645 HNil)))

Obviously we would like HList to be in the Show class, but I can only come up with the following working class instantiation that uses mutually recursive constraints (superclasses):
instance Show (HList '[]) where
  show HNil = "[]"

instance (Show a, Show' (HList t)) => Show (HList (a ': t)) where
  show l  = "[" ++ show' l ++ "]"

class Show' a where
  show' :: a -> String

instance Show' (HList '[]) where
  show' HNil = ""

instance (Show a, Show' (HList t)) => Show' (HList (a ': t)) where
  show' (HCons h l) = case l of
    HNil      -> show h
    HCons _ _ -> show h ++ ", " ++ (show' l)

The code compiles fine and li is shown properly. Compile flags needed are:
{-# LANGUAGE DataKinds, TypeOperators, KindSignatures,
FlexibleContexts, GADTs, FlexibleInstances #-}

I tried many variants of the following far more direct definition, but it doesn't compile without me being able to understand the ghc error messages:
instance Show (HList '[]) where
  show HNil = "[]"

instance (Show a, Show (HList t)) => Show (HList (a ': t)) where
  show l  = "[" ++ (show' l) ++ "]" where
    show' (HCons h s) = case s of
      HNil      -> show h
      HCons _ _ -> show h ++ ", " ++ (show' s)

Some Haskell / ghc specialist might understand why this can't work and I would be happy to hear the reason.
Thank you
Hans Peter

Thank you, hammar, for your two nice working examples, improving on my first example.
But I still don't understand why my second example doesn't work. You say that "... show' only knows how to show the current element type and not the remaining ones." But wouldn't that comment not also apply in the following (working) code:
instance Show (HList '[]) where show HNil = ""

instance (Show a, Show (HList t)) => Show (HList (a ': t)) where
   show (HCons h t) = case t of
      HNil      -> show h
      HCons _ _ -> show h ++ ", " ++ (show t)

A: As Nathan said in the comments, show' only knows how to show the current element type and not the remaining ones.
As in your first example, we can get around this by making a new type class for show', although you can get away with only one Show instance:
-- Specializing show' to HLists avoids needing a Show' (HList ts) constraint
-- here, which would require UndecidableInstances.
instance (Show' ts) => Show (HList ts) where
  show xs = "[" ++ show' xs ++ "]"

class Show' ts where
  show' :: HList ts -> String

instance Show' '[] where
  show' HNil = ""

instance (Show a, Show' ts) => Show' (a ': ts) where
  show' (HCons a s) = case s of
    HNil     -> show a
    HCons {} -> show a ++ ", " ++ show' s

Another more hackish way of getting all the necessary Show constraints into show' is to use ConstraintKinds to directly build a list of all the necessary constraints.
-- In addition to the extensions in the original code:
{-# LANGUAGE TypeFamilies, ConstraintKinds, UndecidableInstances #-}
import GHC.Exts

-- ShowTypes [a, b, c, ...] = (Show a, Show b, Show c, ...)
type family ShowTypes (a :: [*]) :: Constraint
type instance ShowTypes '[] = ()
type instance ShowTypes (a ': t) = (Show a, ShowTypes t)

instance ShowTypes ts => Show (HList ts) where
  show xs = "[" ++ show' xs ++ "]"
    where
      show' :: ShowTypes ts => HList ts -> String
      show' HNil = ""
      show' (HCons h s) = case s of
        HNil     -> show h
        HCons {} -> show h ++ ", " ++ show' s

A: Thanks to hammar's second solution I can now offer an even more general approach, which works for a general class (but I suppose that he had this in mind anyway):
type family ConstrainedTypes (a :: [*]) (f :: * -> Constraint) :: Constraint
type instance ConstrainedTypes '[] b = ()
type instance ConstrainedTypes (a ': t) b = (b a, ConstrainedTypes t b)

instance ConstrainedTypes ts Show => Show (HList ts) where
  show xs = "[" ++ show' xs ++ "]"
    where
      show' :: ConstrainedTypes ts Show => HList ts -> String
      show' HNil = ""
      show' (HCons h s) = case s of
        HNil     -> show h
        HCons {} -> show h ++ ", " ++ show' s

Thank you again for the great help.


text:
Q: Determinating the subclass. Polymorphism or instanceof Say i have 3 classes. One class which is superclass, and the other two those who inherit from it. If i have an instance of the superclass, and i want to know for which of the two subclasses, this object is instance of.
Which of two methods are considered best practise:
1) use instanceOf or getClass() and compare, or
2) declare an  abstract method on the superclass and implement it on subclasses to get an enum which represents the class.

A: The best practice in this case is polymporphism. Create an abstract method in the super class. Subclasses will be obliged to provide concrete implementation. No need for instanceof or getClass.

A: Most of the time, polymorphism is the better answer. If you have to ask which subclass, then when new subclasses are added, there's the danger of forgetting to add new "if" parts to that question.

A: You should use instanceOf. With the approach of enum you must know before hand that you will be later checking for instance and classes have to be prepared for it. So i would prefer instanceOf.

A: Short answer: It is probably the case that you're trying to use the class object, or class name, in a way which is best avoided; and by avoiding it you would probably make your code cleaner and easier to understand and extend.
Long(er) Answer: When writing Object-Oriented software code, specifically Java, the principle of (Subtype) Polymorphism is employed heavily. To make it super-simplified in the context of your question: If you have an instance of class A, with class A being extended by B and C, you endeavor to only treat A as a "general" A, using its public methods and members; and if you want something different to be done for B and C, you write a method doSomething() for this action on A's, implemented differently in B and in C by overriding A.doSomething()  (the default implementation for A's).
(As suggested in @EvgeniyDorofeev's answer, if there's no default action, you can make your default method be abstract; but then A has to be an abstract class.)
This has several advantages:

*

*A's code does not need to be familiar with B and C.

*If you later add other classes, say, D extending A and E extending C, you would not need to modify your existing code - just override doSomething() in them.

*You don't need to worry about using getClass() or creating artificial enums for classes... :-)

but it is sometimes also criticized, as part of a more general criticism of Object-Oriented approaches (see, for example, The Noun Shuffle at OOP Oversold).
PS: Sometimes you can't avoid using getClass() (say, for preparing a log message containing the class name); OP didn't specify the exact problem s/he is facing, so it's difficult to tell. At any case, do not go down the path of writing your own enums for classes; use getClass() (from which you could also get the class name if you really need it). Also, you might find there's a library you can use which takes care of these things for you so you don't have to getClass() at all (that's the case for logging, the example I just gave.)

A: Usually the best practice is by calling the boolean function instanceOf(), this should work just fine.
Although I myself find your second solution much easier to use, but the first one is considered to be good programming practice.


text:
Q: Handling Charset (User input -> Php -> Mysql and back again) Please go here to see my problem, its within the card on the left hand side of the page:
http://gumonshoe.net/magic/card/?card=258
Apostrophes are getting converted to ascii it looks like from various foreign text formats. I've seen this, but since I'm using american english which is probably the basic defaults I can't reproduce the error to test it.
I figure there's got to be a correct way to be passing the characters around, I just don't know what it is.
The answer I'm looking for will tell me where in this chain things are getting messed up.
User Form on web page for input >>
javascript method >>
php >>
mysql

As far as I can tell this is happening in PHP. Its definitely wrong in the database by the time it gets there.
I'd be most happy with a solution that fixes everything from this point on, rather than a patch to fix what's in the db already as I can just find/replace those instances easily enough.
Thanks for all the help. Searching gave me mixed results, but I couldn't find anything that outright seemed identical to my problem and explained it from the basics up.
Again, thanks much!
Does it have anything to do with this:
mb_internal_encoding

A: It does not happen in just one place, it always happens in the communication between two ends. That could be in the communication between browser<->php or php<->mysql
You should make sure to have a charset meta tag in your html header, something like:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

That way, your web browser knows what charset to use when posting data to your server (and what charset to use when rendering your page).
When connecting to mysql, you should make sure that your connection is speaking the same charset at both ends, and that should be the same charset as the web browser is using:
mysql_query('set names utf8');

Now, you should be fine.


text:
Q: Why javax.xml.soap.SOAPConnection FIRST call takes much more time than subsequent calls? I don't get this one. I have been trying on different server and recently I have tried on my own lab/network (no network issue). I am building a request using a template xml file containing a constant SOAP request (validated with SOAPUI). I am measuring the call like this :
            long startTime = System.nanoTime();
            request.sendRequest();
            long estimatedTime = System.nanoTime() - startTime;

I have built some kind of system monitor which sends a request every minute and measures the response time. Now when I get the results the first call takes much more longer every time. The last test I ran : First call was 320ms and the other calls are all returning around 180ms.
Here's the code snippet. As you can see, I am instantiating the SOAPConnection and Message before the measurement and call.
public void createRequest() {
    try {
        request = MessageFactory.newInstance().createMessage();
        SOAPPart soapPart = request.getSOAPPart();
        soapPart.setContent(new StreamSource(new FileInputStream(filename)));
        request.saveChanges();

        scf = SOAPConnectionFactory.newInstance();
        sc = scf.createConnection();

    } catch (SOAPException | FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

public void sendRequest() {
    // TODO Auto-generated method stub
    try {
        response = sc.call(request, url);
    } catch (SOAPException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

Any ideas ?
Thanks in advance to anyone for your contribution. It is very appreciated.
PS. Yep. I know I need to rework the code on exception... I just didn't spent the time on this part yet.


text:
Q: how to make a dynamic three dimensional array where only the first dimension is the dynamic one in c i have a three dimensional bit table array as
bit_table[dim1][100][200];
The second and third dimensions are always the same.
But dim1 have to grow with time.
when this bit_table is full its size need to grow in the dim1 dimension and the old content needs to be retained
To retain the old content of the table, should i just create a temporary array, copy the old array data to it, and, after the array is expanded, copy back this data? Or is there a better way to do it?
EDIT:
int dim1=10;
unsigned char (*bit_table)[100][200] = (unsigned char)malloc(dim1 * sizeof(*bit_table));
printf("enter new dimension\n");
     scanf(dim1);

....

A: You could do something like this:
int (*bit_table)[100][200] = malloc(dim1 * sizeof(*bit_table));

...

bit_table = realloc(bit_table, dim1_new * sizeof(*bit_table));

...

free(bit_table);

Obviously, you will need appropriate error-handling for both of these calls.  In particular, if realloc fails (in the above code) then you will end up with a memory leak.

A: Sorry but I didn't see any special difficulty here. Besides the realloc as Charlesworth mentioned. You can also:
typedef unsigned char bit_table_elem[100][200];

// if you're using c, linked list will be a good choice
// but if you really need indexing, then use the realloc way...
struct bit_table_list {
    bit_table_elem elem;
    struct bit_table_list* next;
}

// if you're using c++, std vector will be better
std::vector<bit_table_elem> bit_table


text:
Q: How to configure multiple modules using .net configuration files I have a few .net modules/libraries I am referencing from my main application. Each of the modules/libraries can be configured and after I build them they each have a configuration file such as MyModule1.dll.config, MyModule2.dll.config.
When I build my main application an app.config file is outputted to the output directory.
I am wondering how to configure MyModule1, MyModule2 etc. Should I include config sections for each in the app.config file or should I have a separate config file for each module where I load a config file for each one? The separate config per module is described here: http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/2710647c-6414-42c4-90b7-fd7603f55ae0/? This would mean that I would copy MyModule1.dll.config and MyModule2.dll.config to the output directory as well.
Can anyone give me some advice on what is the best practice/proper way to do this?
Edit:
From MyModule1.dll I can explicitly load MyModule1.dll.config using
Uri p = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
Configuration config = ConfigurationManager.OpenExeConfiguration(p.LocalPath);

but if MyModule1.dll references and uses one of my common libraries MyCommonLib.dll how can I have MyCommonLib.dll be configured from the same config file MyModule1.dll.config?

A: If you are using the Properties folder system in Visual Studio, and want Visual Studio to sync them automatically, you will want to use the config-per-module approach you have described simply for productivity.
Alternatively, if you are just dealing with  or  entries, it may be easier from one config file. My only advice here is to go with whatever is easiest and the most natural way for whoever else is/will be working on the project.

A: Without knowing exactly what configuration you have, I'd say you should merge the the config files into the main exe config. This way you don't need any extra code to get things working. This is how most .NET applications work, and is what most people will expect. (Look at a web.config -- sections from all over the place end up in there.)
If you're using the strongly-typed settings in Properties that Visual Studio offers, this will work fine. You simply merge the configSections and copy the specific parts from each config file over to the main one. We've done this for a while and it's worked out just fine.

A: Have you considered using Spring.NET to manage your configuration? Of course you get a ton of other features, too, but configuration is a great place to start with Spring.
You can put some configuration in local files with each library, and then reference those files in the main application's configuration file. People who use your libraries can decide whether they want to reference your config files, write their own, or something in between.

A: I would suggest that you go with the exe.config if you don't have to manage too much configuration information.
Or you can consider using a configuration management framework like those included with Microsoft Enterprise Library or Spring.net

A: It all depends upon how separate your libraries are from your application.
If you deploy the same libraries to multiple applications, it may be a better idea to keep the configurations separate.
If it's just the one application, use one configuration file. Then all your configuration is in one place.


text:
Q: How would I write a promql query to find the historical average for the current day of the week at the current time How would I write a promql query to find the historical average of some value for the current day of the week at the current time.
Example 1:
If the current day of the week is Monday and the current time is 3pm
How can I find the average of some value for the last 10 Mondays at 3pm

Example 2:
If the current day of the week is Saturday and the current time is 5:55am
How can I find the average of some value for the last 10 Saturdays at 5:55am

I'm sure there is probably a name for what I'm trying to do but statistics is not my strong suit.


text:
Q: Varying Line Width in Drop Down Menu How do you create varying line heights using CSS in a drop down menu? As you can see below, I am changing the font sizes of each element, however, the new font is not being applied once selected. Thanks!
<select>
        <option class="w1">&#9472&#9472&#9472&#9472</option>
        <option class="w2">&#9472&#9472&#9472&#9472</option>
</select>

option.w1  {
  font-size: 5px;
}
option.w2  {
  font-size:8px;
}

https://jsfiddle.net/kwham1bf/1/

A: Unfortunately, there is no way to select an element's parent using CSS. In this case, the parent is the select and the child is the selected option.
If you need to style the select based on the selected option, you'll have to resort to using JavaScript:

var select = document.querySelector("select");

select.addEventListener("change", function() {
    var selected = document.querySelector("option:checked");
    var selectedFontSize = getComputedStyle(selected, null).getPropertyValue("font-size");
    select.style.fontSize = selectedFontSize;
});
option.w1  {
  font-size: 5px;
  background-repeat: repeat;
  display: inline-block;
  position: static;

}

option.w2  {
  font-size:8px;
  background-repeat: repeat;
  display: inline-block;
  position: static;
}

option.w3 {
  font-size: 11px;
  background-repeat: repeat;
  display: inline-block;
  position: static;
}

option.w4 {
  font-size: 14px;
  background-repeat: repeat;
  display: inline-block;
  position: static;
}

option.w5 {
  font-size: 17px;
  background-repeat: repeat;
  display: inline-block;
  position: static;
}

option.w6 {
  font-size: 20px;
  background-repeat: repeat;
  display: inline-block;
  position: static;
}

Width

  <select>
    <option class="w1">&#9472&#9472&#9472&#9472</option>
    <option class="w2">&#9472&#9472&#9472&#9472</option>
    <option class="w3">&#9472&#9472&#9472&#9472</option>
    <option class="w4">&#9472&#9472&#9472&#9472</option>
    <option class="w5">&#9472&#9472&#9472&#9472</option>
    <option class="w6">&#9472&#9472&#9472&#9472</option>
  </select>


text:
Q: How to share DataAnnotations between EF CodeFirst Poco classed and ViewModel classes in MVC? I am using EF-CodeFirst to create the database from my Poco objects and their configuration.
I have heavily used Dataannotation (Required, DataLength, RegularExpression, DataType) to get metadata to MVC and have the error messages pointing to a ressource to localize them later.
For simple CRUD operations this is not a problem.
But as soon as I have the need for ViewModel classes I loose the Dataannotations from my Poco objects.
How can those 2 designs be combined without having to hurt the DRY (dont repeat yourself) principle?
Thanks
   Andreas

A: Those two designs can't and shouldn't be combined. Your view models are tied to the views so personally I redefine all the necessary attributes on my view models and believe it or not I don't care about DRY in this case. I do this because the requirements of my views change quite often (yeah customers are capricious) whereas I reuse always the same domain models. For me a view should never know about the existence of a domain model. A view should be dummy and all that it should know about is the view model which is passed to it by the controller.
I know that there are people who might think different and I respect their opinion. So by saying this I am only exposing my personal point of view and my way of working with ASP.NET MVC. And to be quite honest with you my models are POCO objects without any DataAnnotations so I don't encounter such problems. I use DataAnnotations on my view models only for formatting purposes (stuff like DataType, DisplayName and DisplayFormat) and no validation attributes. I use FluentValidation.NET for this purpose.

A: You can accomplish what you're asking pretty easily.  Darin has a very valid point that applies well to larger projects, but I think for the smaller projects it sounds like overkill.  It also seems like it depends a great deal on whether you're using DataAnnotations for validation or using a 3rd party library.  The repitition involved in not doing this would make for quite a maintenance nuisance, IMHO.  There's also the fact that you spend a lot of lines of code just copying data from the DB to the view model; ORMs are supposed to help eliminate that, but so far the solution doesn't appear very good.
Here's an example snip of code on how to do what you want.  The first class is partial, with the main body being in the EF generated code (I'm going model first, not code first).  Also, as an example, Question has a FK to QuestionGroup.  In the DB this is a column named GroupID, but in the ViewModel there's a property named GroupName for displaying in a nice little grid (Telerik Grid, actually, which basically breaks if you try to pass in an EF object).
[MetadataType(typeof(QuestionMetadata))]
public partial class Question
{
}

public class QuestionMetadata
{
    public Int32 ID { get; set; }

    [Required]
    [Display(Name="Question")]
    public String QuestionText { get; set; }

    [Display(Name = "Order")]
    public Int16 SortOrder { get; set; }
}

[MetadataType(typeof(QuestionMetadata))]
public class QuestionViewModel
{
    /* Fields found in the original model */

    public Int32 ID { get; set; }

    public String QuestionText { get; set; }

    public Int16 SortOrder { get; set; }

    /* Fields that map child object data for this view model */

    [Display(Name = "Question Group")]
    public String GroupName { get; set; }
}

IMHO both EF and Telerik are forcing me to not be very DRY here, but there's nothing I can do.  EF should be generating these DataAnnotations by default (or at least have the option), since it obviously knows which fields are required (not null) or what the max length of various strings are.  Then Telerik forces me to create the ViewModel, which is also painful.


text:
Q: How to compare each element in my arraylist to find the nth smallest of the two arrays? import java.util.*;

public class Main {

    public static void main(String[] args) {
        // this section of code will require user input to have the value of n to be set
        System.out.println(("What number would you like to set n equal to ?"));
        Scanner sc = new Scanner(System.in);
        System.out.print(("n= "));
        int value = sc.nextInt();
        System.out.println((""));

        // this section of code set the two array only to hold the value of n
        Random rand = new Random();
        ArrayList<Integer> setA = new ArrayList<Integer>();
        for (int i = 0; i < value; i++) {
            int picks = rand.nextInt(1000);
            setA.add(picks);
        }
        Collections.sort(setA);
        System.out.println(setA);

        ArrayList<Integer> setX = new ArrayList<Integer>();
        for (int k = 0; k < value; k++) {
            int picks = rand.nextInt(1000);
            setX.add(picks);
        }
        Collections.sort(setX);
        System.out.println(setX);
        solution(setA,setX,value);
    }

    private static int solution(ArrayList<Integer> A1, ArrayList<Integer> X1, int value) {
        // This section of code is where the arrays will be compared to find the nth smallest.
        ArrayList<Integer> setF = new ArrayList<Integer>();
        for (int c = 0; c < A1.size(); c++) {
            for(int k = 0; k < X1.size(); k++) {
                if(A1.get(c) < X1.get(k)) {

                }
            }
        }

        System.out.print(setF);
        return value;
    }
}

So far i have my program set up to have the user enter a number that will be used for the size of the array. Once the number has been entered the arrays are created with random numbers that will be place in order. Next I would like to go through each element of my arrays and compare to see which numbers can be placed in my Final array. In my final array is the nth smallest number which will be return. I can not merge the two array together.
For example if n = 10  below are my two arrays

A [124, 264, 349, 450, 487, 641, 676, 792, 845, 935]
B [2, 159, 241, 323, 372, 379, 383, 475, 646, 836]

124 < 2  this statement is false so 2 would get added to my final array list. Array B should move to the next element in the list.
124 < 159 this is true so 124 gets added to my final array list.  Array A should move to the next element in the list.
264 < 159 this statement is false so 159.
Final Array [2,124, 159,...]
n smallest is 383.
Hopefully that example gives you an ideal of what I'm trying to accomplish.if you have something better let me know please..

A: Your solution would work but you can make your solution's time complexity o(n) rather than o(n^2).
What you could do is, since the arrays are equally sorted, you can compare both elements at position zero (like you're doing) and then whichever element is smaller, pop that element from the array and add it to the final array. Keep testing the zero(th) indexed element until one of the arrays is empty. Once its empty, you can just append the remaining other array on the end of the final array and that should achieve what you want.
So in some java code implementation:
private ArrayList<Integer> sortTwoArrays(ArrayList<Integer> arrayA, ArrayList<Integer> arrayB) {
    ArrayList<Integer> finalArray = new ArrayList<>();
    while(!arrayA.isEmpty() && !arrayB.isEmpty()) {
        if (arrayA.get(0) < arrayB.get(0)) {
            // remove element and store
            finalArray.add(arrayA.remove(0));
        }
        else {
            finalArray.add(arrayB.remove(0));
        }
    }

    // Find out which array is not empty
    // Adds remaining contents of non-empty array to end of finalArray
    if (!arrayA.isEmpty()) {
        finalArray.addAll(arrayA);
    }
    else if (!arrayB.isEmpty()) {
        finalArray.addAll(arrayB);
    }

    return finalArray;
}

To get the nth smallest value, just add the value the user passes in as an argument to the function and then when you're returning the function, just return finalArray.get(nthIndex)
Example code showcase here.

Note: The original two ArrayLists will get destroyed from this method
If you want preserve the two arrays, I recommend keeping track of both indexes in the list inside variables and then incrementing based on when one item is less than another. Additionally, change the If statement check after the whie-loop from an isEmpty() check to a comparison like so indexOfArrayA == arrayA.size() - 1.

I hope this helps in anyway.


text:
Q: "Failed to cache field with id" unexpected error on list item edit Some of our users are receiving "Unexpected errors" when modifying list items. They are third party, but have access to our internal SharePoint site. Our site admin sees "Failed to cache field with id" errors when checking logs.
I am not able to recreate error when doing same change on the list items. This problem is reoccurring for ~5 third party users.
How can I troubleshoot this?
A MS employee mentioned content database size/transaction log space... would this transaction log space change based on end-user saving changes?
https://social.technet.microsoft.com/Forums/sharepoint/en-US/72cfe4c1-ff23-455a-b562-8cfcc2ee45db/sp-log-failed-to-cache-field-with-id?forum=sharepointgeneralprevious

Failed to cache field with id "{...}", overwrite=0
System.NullReferenceException: Object reference not set to an instance of an object.    at Microsoft.SharePoint.WebControls.LookupField.Validate()     at System.Web.UI.Page.Validate()     at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)     at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Thank you for your time,

A: Do you have any Custom Webpart on the page? Are you getting the error on the page load or while saving? if you are having custom webpart please check the permissions of the users


text:
Q: Files do not show in Windows XP I have an external hard which is full.  My windows 7 shows all of the files and there is no problem, but in Windows XP none of the files are visible (it also shows that the hard is full).
I enabled the "show hidden items" and disabled the "hide protected files" Folder Options, but it doesn't make any difference at all.
Any idea?

A: Get to a DOS prompt (Start Menu -> Run -> Cmd) and type the following commands (I'll assume that drive E: is assigned to your external hard drive):

*

*dir E:\ /a

*exit

If you see files listed there before typing "exit," then there's something odd going on with your Windows installation in that it can't reveal these files to you (a scan for SpyWare or viruses may be in order).
If there are no files listed there, then it may be a compatibility issue (do you have XP patched up to Service Pack 3?), or there is corruption on the disk that Windows 7 can safely ignore (because it's got a newer NTFS code base) while XP is effected.
* VERY IMPORTANT * At any rate, before you change anything on the drive (fixing errors with tools like "chkdsk" requires changing the contents of the drive), make sure you have a backup copy of it all first just in case any of the changes cause it all to be lost.


text:
Q: Mac OS latex workshop does not build pdf, error shown is: Recipe terminated with fatal error: spawn pdflatex ENOENT I installed latex workshop in VSCODE (on Mac OS), but the pdf does not build. Instead it throws the error:
Recipe terminated with fatal error: spawn pdflatex ENOENT.
Does anyone know the solution as I would have assumed the package would work by simply installing?

A: I found this issue to occur when launching VSCODE from the anaconda GUI. Launching VSCODE directly in launchpad on MAC OS did not through any errors and simply compiled and built the pdf. Hence, this issue appears to be specific to the anaconda installation and launch.

A: You need to install MacTex for Latex Workshop to work. After installing MacTex, you'll see TexLive Utility which you will use to install all the packages.
If you have all of it installed, then it throws an error because the environment variable is not set in PATH. You can check this by typing
echo $PATH in your terminal or reading the error message in the log.
To fix this:

*

*Open your Library folder and navigate over to TexShop. Open "Engines" and move latexmk engine from "inactive" back to "Engines" folder.

*After doing this, you have to add /usr/local/texlive/2022/bin/universal-darwin to your $PATH.

*Open Terminal and type ls -a to view all files.

*Type open .zshrc in the terminal and add /usr/local/texlive/2022/bin/universal-darwin: after bin:. Save the text editor and close it.

*Now, type source .zshrc in the terminal.
Restart your Visual Studio Code, and it should work. Type echo $PATH in Terminal and you should be able to see the path we just added.


text:
Q: Hive is configured on my windows but not responding I have installed hive 0.11 on my windows and using hadoop 0.23 package.
I set every thing and while using the hive command hive prompt is showing like hive>
But, after this whatever the command i'm using hive is not responding.
What i has to do for this?? I have set path as well.


text:
Q: Mixing c++ string with c I have a c and cpp file
mycpp.cpp
fun()
{
//code goes here....
}

mycpp.h
#include<string>
struct str{
std::string a;
};
func();

myc.c
#include "mycpp.h"

func();
//with other c codes..

This is a part of large code list. So it gets compiled via c++ and c.
My problem is when mycpp.h is compiled through myc.c (which is included in myc.c) , Compiler throws an error saying fatal error: string: No such file or directory
Is there some wrapper mechanism to overcome this scenario?

A: You cannot include a C++ header file in a C file.
Declare the function func() with C linkage, and refer to it as an extern function inside your C file.
Example:
mycpp.cpp
void func(void)
{
    /* foo */
}

mycpp.h
extern "C" void func(void);

myc.c
extern void func(void);

/* you can now safely call `func()` */

You cannot use std::string in C, if you want to access your string, you have to pass it accordingly into your C code, by passing it a char const* with the contents of the string. You can get access to this string by calling std::string::c_str(). You can read more about c_str() here.


text:
Q: How to handle HTTP Basic Authentication in AVURLAsset? I am trying to develop a custom movie player in iPhone using AVPlayer. But I am just wondering that if the m3u8 url response sends back an authentication challenge, how do I handle that. I do know about didReceiveAuthenticationChallenge and NSURLConnection but no clue about how does it work in this context.
Any help is appreciated.
-Soumya

A: We've made a different approach to a similar issue as we had to comply with redirects in HTTP, too. We did the authentication in cookies and set them for a whole domain:
NSDictionary *properties = [NSDictionary dictionaryWithObjectsAndKeys:
                            kAuthCookieDomain, NSHTTPCookieDomain,
                            kAuthCookiePath, NSHTTPCookiePath,
                            kAuthCookieName, NSHTTPCookieName,
                            kAuthCookieValue, NSHTTPCookieValue,
                            kAuthCookieDiscard, NSHTTPCookieDiscard,
                           nil];
NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties:properties];
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie];


text:
Q: Reduce multiple matrixes to single matrix and perform value addition I have a list (array) of matrixes in a data structure like so:
const data = [
  {
    matrix: {
      rows: {
        ROW1: {
          cols: {
            COL1: "4",
            COL2: "2"
          }
        },
        ROW2: {
          cols: {
            COL1: "1",
            COL2: "4"
          }
        },
        ROW3: {
          cols: {
            COL1: "2",
            COL2: "1"
          }
        }
      }
    },
  },
  {
    matrix: {
      rows: {
        ROW1: {
          cols: {
            COL1: "1",
            COL2: "6"
          }
        },
        ROW2: {
          cols: {
            COL1: "2",
            COL2: "3"
          }
        },
        ROW3: {
          cols: {
            COL1: "5",
            COL2: "2"
          }
        }
      }
    }
  }
];

I would like to sum up the values defined at the same ROW:COL pairs and end up with a single matrix like so:
const newMatrix = {
  rows: {
    ROW1: {
      cols: {
        COL1: "5",
        COL2: "8"
      }
    },
    ROW2: {
      cols: {
        COL1: "3",
        COL2: "7"
      }
    },
    ROW3: {
      cols: {
        COL1: "7",
        COL2: "3"
      }
    }
  }
};

I do not know beforehand how many matrixes I might receive in the data array. I also do not know beforehand how many rows and columns I receive.
I started off by calling reduce() on the data but got stuck because I cannot think of a way of finding and then summing up the data at ROW:COL pairs of the same name.
const newMatrix = data.reduce(( accumulator, current ) => {
  let newMatrix;
  // ...???
  // find? forEach? Object.entries? for loops? maps inside maps?
  // Everything I tried failed
  return newMatrix;
});

I have also messed around with forEach(), Object.values(), find() and all sorts of for loops inside other loops but I keep ending up in some kind of brain loop myself.
I realise this might not be enough to work yet but I'm new at programming and don't know where to go next.
I have been stuck for 2.5 days now on this very problem so even if no straight up solution is offered I would appreciate any tips or guidance in the right direction.
Unfortunately I have no peers who I can ask for help.
Thank you.

A: You have to do it in reverse, meaning loop for columns, then rows, then matrices. Following code has detailed solution.

    function sumMatrices(data)
    {
        // if data empty or has missing fileds, return null
        if(
            !data ||
            !data[0].matrix.rows ||
            !data[0].matrix.rows.ROW1.cols ||
            data.length == 0 ||
            Object.keys(data[0].matrix.rows).length == 0 ||
            Object.keys(data[0].matrix.rows.ROW1.cols).length == 0)
        {
            return null;
        }

        // else sum and return the result matrix
        else
        {
            // Get matrix, row, and column counts
            let numOfMatrices =  data.length;
            let numOfRows = Object.keys(data[0].matrix.rows).length;
            let numOfCols = Object.keys(data[0].matrix.rows.ROW1.cols).length;

            // Copy matrix structure
            let result = JSON.parse(JSON.stringify(data[0]));

            // Fields base names to be addressed
            let rowWord = 'ROW';
            let colWord = 'COL';

            // Loop in reverse: columns -> rows -> matrices
            for (colNum = 1; colNum < numOfCols+1; colNum++){
                let currentCol = colWord + colNum;

                for (rowNum=1; rowNum<numOfRows+1; rowNum++){
                    let currentRow = rowWord + rowNum;
                    let sum = 0;

                    for (matrixNum = 0; matrixNum < numOfMatrices; matrixNum++) {
                        sum += parseInt(data[matrixNum].matrix.rows[currentRow].cols[currentCol]);
                    }
                    result.matrix.rows[currentRow].cols[currentCol] = "" + sum;
                }
            }
            console.log(result);
            return result;
        }
    }

    const data = [
    {
      matrix: {
        rows: {
          ROW1: {
            cols: {
              COL1: "4",
              COL2: "2"
            }
          },
          ROW2: {
            cols: {
              COL1: "1",
              COL2: "4"
            }
          },
          ROW3: {
            cols: {
              COL1: "2",
              COL2: "1"
            }
          }
        }
      },
    },
    {
      matrix: {
        rows: {
          ROW1: {
            cols: {
              COL1: "1",
              COL2: "6"
            }
          },
          ROW2: {
            cols: {
              COL1: "2",
              COL2: "3"
            }
          },
          ROW3: {
            cols: {
              COL1: "5",
              COL2: "2"
            }
          }
        }
      }
    }
  ];

   sumMatrices(data);

A: Since the number of row and column is not static, a recursive function will be applied to get the sum without assuming column or row property name.

const data = [{
    matrix: {
      rows: {
        ROW1: {
          cols: {
            COL1: "4",
            COL2: "2"
          }
        },
        ROW2: {
          cols: {
            COL1: "1",
            COL2: "4"
          }
        },
        ROW3: {
          cols: {
            COL1: "2",
            COL2: "1"
          }
        }
      }
    },
  },
  {
    matrix: {
      rows: {
        ROW1: {
          cols: {
            COL1: "1",
            COL2: "6"
          }
        },
        ROW2: {
          cols: {
            COL1: "2",
            COL2: "3"
          }
        },
        ROW3: {
          cols: {
            COL1: "5",
            COL2: "2"
          }
        }
      }
    }
  }
];

var result = {};
var sum = function(from, to) {

  var keys = Object.keys(from);

  for (let i = 0; i < keys.length; i++) {
    if (to[keys[i]] === undefined) {
      to[keys[i]] = from[keys[i]];
    } else {
      if (typeof from[keys[i]] === "object") {
        sum(from[keys[i]], to[keys[i]])
      } else {
        to[keys[i]] = parseInt(from[keys[i]]) + parseInt(to[keys[i]]);
      }
    }
  }
};

for (index in data) {
  sum(data[index], result);
}

console.log(result);

A: You can try looping through the keys of your object and build your final result adding the values as you go.

const data = [
    {
        matrix: {
            rows: {
                ROW1: {
                    cols: {
                        COL1: "4",
                        COL2: "2"
                    }
                },
                ROW2: {
                    cols: {
                        COL1: "1",
                        COL2: "4"
                    }
                },
                ROW3: {
                    cols: {
                        COL1: "2",
                        COL2: "1"
                    }
                }
            }
        },
    },
    {
        matrix: {
            rows: {
                ROW1: {
                    cols: {
                        COL1: "1",
                        COL2: "6"
                    }
                },
                ROW2: {
                    cols: {
                        COL1: "2",
                        COL2: "3"
                    }
                },
                ROW3: {
                    cols: {
                        COL1: "5",
                        COL2: "2"
                    }
                }
            }
        }
    }
];

const sumMatrices = (array) => {

    const summed = { matrix: { rows: {} }};

    array.forEach((item) => {

        Object.keys(item.matrix.rows).forEach((row) => {

           if (!summed.matrix.rows[row]) summed.matrix.rows[row] = { cols: {} };

           Object.keys(item.matrix.rows[row].cols).forEach((col) => {

               if (!summed.matrix.rows[row].cols[col]) summed.matrix.rows[row].cols[col] = 0;

               summed.matrix.rows[row].cols[col] += +item.matrix.rows[row].cols[col];
           });
       });
    });

    return summed;
};

console.log(sumMatrices(data));


text:
Q: Run custom execution in Maven before version 3.3.1 is it possible to run a single execution of a custom maven plugin before version 3.3.1?
groupid:artifactid:goal@id does only work from version 3.3.1 upwards. So how can I target a single execution id without using phases?


text:
Q: How to short length number in JavaScript when I calc this value I got a big number like 48.4979898749,
how convert this to 48.49 ???

A: You could take the number and apply Number#toFixed with the wanted number of digits.

var valuee = document.getElementById("valueNum"),
    result = document.getElementById("res");

valuee.onkeyup = function () {
    "use strict";
    result.innerHTML = "المبلغ المطلوب " + (valuee.value * 0.0680).toFixed(2) + " دولار";
};
<input type="text" id="valueNum">


text:
Q: Having a hard time with the law of the iterated logarithm Let's say you have infinitely many i.i.d. Bernouilli variables $X_1, X_2, \cdots$ of parameter $p=\frac{1}{2}$. For instance, the binary digits of a random number. Let $S_n = X_1 + \cdots X_n$.
The law of the iterated logarithm (see here) states that
$$\lim_{n\rightarrow\infty}\sup \frac{S_n-np}{\sqrt{2np(1-p)\log\log n}}=1.$$
I can't replicate this behavior by simulations no matter what I do. Wikipedia shows a chart explaining why the $\log \log n$ is needed in the formula (see here) but not sure what data it is based on: it goes all the way to $n=\infty$, it can't be real data if it contains an infinite number of observations. In all my tests, the $\log \log n$ makes the $\lim \sup$ tends to 0, not 1.
Now let
$$Z_n=\sqrt{n}\cdot\Big(\frac{S_n}{n} - p\Big) = \frac{S_n -np}{\sqrt{n}}.$$
Here $p=\frac{1}{2}$. Of course $Z_n$ is asymptotically normal $N(0,pq)$. So technically $Z_n$ could be arbitrarily high, extremely high, and this happening regularly, suggesting that $\lim \sup Z_n =\infty$. This is in agreement with the law of the iterated logarithm. Yet based on simulations with $n=10^{10}$ and a very good random generator, all evidence suggests that $\lim\sup Z_n$ is bounded by a rather small constant, less than 1. This contradicts the law of the iterated logarithm, it seems.
Below is the chart for $Z_n$ based on 10 billion observations.

It was produced with the following random generator:
$Y_{k+1}=3Y_k - \lfloor 3Y_k\rfloor$ with $Y_1=\sqrt{2}$ and $X_k = \lfloor 2Y_k\rfloor \in \{0, 1\}$. This random generator is aperiodic and has other nice features. In this case $p=\frac{1}{2}$.
My question
What am I missing here? Why do my results (and above is one of many tests) seem to contradict the law of the iterated logarithm? Is it the fact that the successive $Z_n$ are highly correlated? But this is assumed too in the law of the iterated algorithm, right? Or am not properly understanding the law of the iterated algorithm or the concept of $\lim \sup$?
Notes about the above random generator
The sequence $Y_n$ is completely wrong after 45 iterations or so due to error (caused by machine precision) propagating exponentially fast from one iteration to the next one. However this is not an issue, it's like starting with a new seed every 40 iterations or so. It is not an issue because the sequence $Y_n$ is ergodic.
Ideally I wanted to use $Y_{k+1}=2Y_k - \lfloor 2Y_k\rfloor$ but in the programming language I used (Perl) the iterates erroneously reached zero after 45 iterations due to the way computations are done by the computer. The computation of $2Y_k$ can be carried very efficiently in base 2, it's just shifting the binary digits.
The speed of computations in the actual version of the generator is significantly improved (by an order of magnitude) if you replace $3Y_k$ by $Y_k + Y_k + Y_k$ in the source code.

A: You are looking at a truly tiny simulation.  Here's one that went out to $n=2^{1000} \approx 1.07\times 10^{301}:$

(In order to plot it I thinned the walk to $999$ values equally spaced horizontally and connected them with line segments.  The actual simulation is, of course, much more detailed than can be shown here :-).)
Clearly this walk repeatedly hits (and slightly exceeds) the $\pm 1$ thresholds.  The Law of the Iterated Logarithm says this behavior will continue ad infinitum, with the excursions beyond this threshold growing ever rarer.
The range from $n=10^8$ to $n=10^{10},$ which is basically that visible in your plot, is bounded on the left and right by the light blue lines.  In the overall context, we can hardly expect the scaled random walk to vary much within such a narrow interval.
The point is that this law requires you to plot the scaled, standardized random walk on a logarithmic (or even log-log) axis for the index $n.$


text:
Q: How can I find sum of nested lists in python without using any library? my list is somethin similar to below:
my_list = [[[1,2],[2,3],[1,0]],[[0,1],[1,2]],[[8,9],[2,3],[1,0]]]
so, here I am expecting my resulted list is sum of elements divided by all elements
from , above list my expected output is:
res = [[1.3333,1.6667],[0.5,1],[3.6667,4]]
'''
my_list = [[[1,2],[2,3],[1,0]],[[0,1],[1,2]],[[8,9],[2,3],[1,0]]]
res = [[0,0,0],[0,0,0],[0,0,0]]
for j in range(len(my_list[0])):
    tmp = 0
    for i in range(len(my_list[j])):
        tmp = tmp + my_list[i][j]
    res[j] = tmp / len(my_list)

'''
tried above but not working.

A: You have 2 nested lists and you need to do the math the inner one.
res = [[sum(y)/len(y) for y in x] for x in my_list]
In my solution, x is the iteration of the outer list. But it is himself a list. So, we iterate it as y.
The result is
[[1.5, 2.5, 0.5], [0.5, 1.5], [8.5, 2.5, 0.5]]

A: The functions you'll need to use are len, zip, and sum.  I'll break it down step by step to help make it clear what role each individual function  plays, with the final line being the complete solution:
>>> my_list = [[[1,2],[2,3],[1,0]],[[0,1],[1,2]],[[8,9],[2,3],[1,0]]]

>>> [len(a) for a in my_list]
[3, 2, 3]
>>> [[x for x in zip(*a)] for a in my_list]
[[(1, 2, 1), (2, 3, 0)], [(0, 1), (1, 2)], [(8, 2, 1), (9, 3, 0)]]
>>> [[sum(x) for x in zip(*a)] for a in my_list]
[[4, 5], [1, 3], [11, 12]]

>>> [[sum(x) / len(a) for x in zip(*a)] for a in my_list]
[[1.3333333333333333, 1.6666666666666667], [0.5, 1.5], [3.6666666666666665, 4.0]]

A: My interpretation of your question from the various comments is:

Given an m by n (m rows, n columns) matrix, I want a function f that returns the mean of each of the n columns. f should work with any 2D matrix (m and n are unknown). Return the result of applying f to each matrix in my_list.

The following nested loop does this sum over columns:
res = []
for sub_list in my_list:
    res.append([])
    for column in range(len(sub_list[0])):
        col_total = sum(sub_list[i][column] for i in range(len(sub_list)))
        res[-1].append(col_total / len(sub_list))

print(res)

Gives
[[1.3333333333333333, 1.6666666666666667], [0.5, 1.5], [3.6666666666666665, 4.0]]


text:
Q: Work Item Only View in TFS 2013 Express How do I set up a work item only view in TFS 2013 Express?
There is no such a group built in.

A: "Work Item Only View" has been replaced by a "Limited" view in Team Web Access.
See http://msdn.microsoft.com/en-us/library/jj159364.aspx#how_to for more information on how to change it.
If you're not seeing it, it could be that you're not at the root administration page for TFS, or you're not an administrator.  Try going directly to http(s)://[server]/tfs/_admin/_licences.

A: I suggest you to access Team Explorer, included in Visual Studio
You must connect by entering Server Url , Team Project Collection & Team Project
You have also easy solution by Add In On Excel (Add In Excel is installed with Team Explorer), Open WIQL query writetd on your Portal for example
On 2013 you have new organization on your Team Explorer, if you don't find you can use search engine


text:
Q: SqlAlchemey nullslast order in relationship I'm defining a relationship in my class and I need to apply a nullslast to the order_by.  How would I do this in the relationship or is there another way to go about it?
flags = relationship("Flag",
    backref=backref("box", lazy="select"),
    cascade="all,delete,delete-orphan", order_by="Flag._order",
    )

A: I was able to get what I wanted by following this advice and making the order_by negative with a desc.  Hope it works with more than mysql.
flags = relationship("Flag",
    backref=backref("box", lazy="select"),
    cascade="all,delete,delete-orphan", order_by="desc(-Flag._order)",
    )


text:
Q: SQL Server: statement in a batch all execute as one transaction? So I ran a SQL batch with a bunch of UPDATE statements:
UPDATE...;
UPDATE...;
UPDATE...;

Turns out the batch ran as a single transactions consequently many locks were created (our database monitoring software clearly shows that it was one big transaction) so apparently its similar to me writing BEGIN...COMMIT around the batch:
BEGIN TRANS;
UPDATE...;
UPDATE...;
UPDATE...;
COMMIT;

Is that really the case? Are batches always executed as one transaction? (I am not in 'explicit transaction' mode) and why is that, and can it be configured or is that just the behavior of SQL Server?
Would it change anything if I wrap every statement in a BEGIN..COMMIT, something like:
BEGIN TRANS;
UPDATE...;
COMMIT;
BEGIN TRANS;
UPDATE...;
COMMIT;
BEGIN TRANS;
UPDATE...;
COMMIT;

Thank You!

A: Assuming that you are executing your UPDATEs from a SSMS Query Window, you can refactor your code to
BEGIN TRANS;
UPDATE...;
GO
UPDATE...;
GO
UPDATE...;
GO
COMMIT;

GO WILL make each UPDATE execute prior in its own batch in the order called, but won't be committed until the final COMMIT is called.
I have tested this via the following example that you can run for yourself in SSMS.
SET NOCOUNT ON
GO

IF EXISTS ( SELECT * FROM sys.tables WHERE name = 'BatchTest' )
    DROP TABLE dbo.BatchTest;
GO

CREATE TABLE dbo.BatchTest (
    id INT IDENTITY (1,1) PRIMARY KEY NOT NULL
    , col1 VARCHAR(50)
    , col2 VARCHAR(50)
    , col3 VARCHAR(50)
    , col4 VARCHAR(50)
)
GO

DECLARE @i INT = 1;
WHILE ( @i <= 100 ) BEGIN
    INSERT INTO dbo.BatchTest ( col1 ) VALUES ( 'col1_' + CAST ( @i AS VARCHAR(10) ) );
    SET @i += 1;
END
GO

SELECT * FROM dbo.BatchTest ORDER BY id;

/*
    -- test tran/commit --
    -- manually select and execute the code below after the BatchTest has been created and populated with data --

    SET NOCOUNT ON
    GO

    BEGIN TRAN;
    UPDATE dbo.BatchTest SET col2 = 'col2_' + CAST ( id AS VARCHAR(10) );
    GO
    UPDATE dbo.BatchTest SET col3 = 'col3_' + CAST ( id AS VARCHAR(10) );
    GO
    UPDATE dbo.BatchTest SET col4 = 'col4_' + CAST ( id AS VARCHAR(10) );
    GO
    --COMMIT;
    ROLLBACK;

    SELECT * FROM dbo.BatchTest ORDER BY id;

*/

Please note the comments in the code about selecting and executing the tran/commit test.
The single ROLLBACK undoes all of the UPDATEs within the current transaction, regardless of the use of GOs, whereas COMMIT will commit them all. Obviously, you should do more your diligence and test against your data, but this might help with your locking issues.
Some follow-up reading in regard to SQL Server's use of GO and its intentions:
https://learn.microsoft.com/en-us/sql/t-sql/language-elements/sql-server-utilities-statements-go?view=sql-server-2017


text:
Q: collection list and gridview I want to add Mark1,Mark2,Mark3,Mark4,Mark5 and assign it to the Sum to show in the gridview.
i want to add those marks through any function and assign it to the Sum property. how to do it? thanks
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void procees()
    {
        List<student> ml= new List<student>();

        student s1 = new student() {
            Name = "ram",
            Id = "gn01",
            Mark1 = 90,
            Mark2 = 89,
            Mark3 = 75,
            Mark4 = 45,
            Mark5 = 65,
            Sum = ""
        };
        ml.Add(s1);

        dataGridView1.DataSource = ml;
    }

    private void button1_Click(object sender, EventArgs e)
    {
        procees();
    }
 }

 public class student
 {
     private string name;

     public string Name
     {
         get { return name; }
         set { name = value; }
     }

     private string id;

     public string Id
     {
         get { return id; }
         set { id = value; }
     }

     private int mark1;

     public int Mark1
     {
         get { return mark1; }
         set { mark1 = value; }
     }
     private int mark2;

     public int Mark2
     {
         get { return mark2; }
         set { mark2 = value; }
     }
     private int mark3;

     public int Mark3
     {
         get { return mark3; }
         set { mark3 = value; }
     }
     private int mark4;

     public int Mark4
     {
         get { return mark4; }
         set { mark4 = value; }
     }
     private int mark5;

     public int Mark5
     {
         get { return mark5; }
         set { mark5 = value; }
     }
     private int sum;

     public int Sum
     {
         get { return sum; }
         set { sum = value; }
     }
 }

A: Remove private field 'sum':
 private int sum;

Let the pubic property 'Sum' to calculate the sum:
 public int Sum
 {
     get { return Mark1 + Mark2 + Mark3 + Mark4 + Mark5; }
 }


text:
Q: Repair Ubuntu and Windows system loading from dualboot I have some strange behavior with my ThinkPad X1 Carbon Gen 4th. It has two OS: Windows 10 and Ubuntu 20.04 I working only with Ubuntu, but I cannot delete Windows, because it is a work laptop.
Earlier I have some problems with suspend on Ubuntu - it doesn't loaded and I had to reboot it, because laptop doesn't load and has blank black screen.
I googled some solution to this problem and installed a screensaver. But after some time, after rebooting, my laptop won't load Ubuntu. But, Windows refused to load also.
I can work in ubuntu only in recovery mod and I tried to install a new kernel, but with new version ubuntu doesn't load at all.
How can I fix this problem, and what's the reason of this behavior?
Also, I think what it can be videodrivers, but i have internal videochip (intel) and Windows can't loaded too.
May be something wrong with GRUB?


text:
Q: Provide generic class instead of a mapper class while executing an API using resttemplate I'm trying to write an integration test for one of the API, but however it returns a XML object, where I don't have any corresponding class inorder to map. How can I do without any class?
Here is my code
HttpHeaders authHeaders = new HttpHeaders();
authHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
authHeaders.add("Authorization", "Bearer "+oAuthToken );

UriComponentsBuilder builder=UriComponentsBuilder.fromUriString(PES_END_POINT + PES_RESOURCE)

   .queryParam("count", "100")
   .queryParam("app-name", "bb")

 HttpEntity entity = new HttpEntity(authHeaders);

 Object response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity , Class<T> ); --> Here what generic class can I provide?

Any help would be greatly appreciated.

A: just use the ObjectMapper
        ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity , String.class);
        JavaType javaType = objectMapper.getTypeFactory().constructType(yourClass);
        YourGenericClass<T> result = objectMapper.readValue(response.getBody(), javaType);


text:
Q: What is my "App ID"? Where is it? I signed up for Facebook APPS, now where is my app ID? Is it a number? Where do I find it? It's required for facebook moderation, and it asks for this app id, but it is nowhere to be found. Nowhere.

A: Go to developers.facebook.com. List of apps should be on the left. The AppID/API Key should be right under the "Settings" header.


text:
Q: ECHO program in C# i'm trying to make a program in C# that behaves like the well-known echo command. Everything works fine except when I try to print a quoted String.
For example, in the echo command you type:
echo "Hello, world!"

And you get as output:
"Hello, world"

But when I run my program I get:
Hello, world!

This is the code:
using System;

namespace CSharpEcho
{
    public class Echo
    {
        public static void Main(String[] argv)
        {
            Int32 ArgsLength = argv.Length;

            if(ArgsLength == 0)
                Console.WriteLine("You have to write something!");
            else
            {
                String Str = "";

                foreach(String args in argv)
                {
                    Str += args + " ";
                }

                Console.WriteLine(String.Format("{0}", Str));
            }
        }
    }
}

A: Environment.CommandLine holds exact command line contents.
So your code can be :
public static void Main(String[] argv)
{
  Console.WriteLine(Environment.CommandLine);
}

A: Double-quote characters in strings are kind of tricky. Try this:
Console.WriteLine(String.Format(@"""{0}""", Str));

The @ symbol makes the string into a string literal, meaning that there are no "escape" characters. The outer pair of double-quotes are the normal quotes around a string, and the inner double-pair of double quotes are actual quote characters.

A: If you want your output to be "Hello, world". You can use something like this:
var text = "\"Hello, World\"";


text:
Q: How to make use of data field from ffprobe's show_packets show_data I have this ffprobe command reading from rtsp feed. My aim is to extract video frame and audio frame from the feed along with their associated pts_time. My rtsp feed has h265 video format and aac audio format.
I need to pass the video data to OpenCV for processing. OpenCV takes bgr24 format. I used to rely on ffmpeg -i rtsp:// -c copy -f rawvideo -pix_fmt bgr24 -pipe: where its stdout produces video frame in bytes. I am not so sure if this is similar to the "data" in ffprobe packets or not. Doing so has limitation when I need to work on audio and synchronizing audio and video. It seems ffprobe provide both audio and video data naturally in one simple command along with pts_time reference.
I have been trying find reference for show_data and its use of data. It would be appreciated if anyone provide guidance on this.
ffprobe -hide_banner -loglevel fatal -i rtsp://... -show_packets -show_data -print_format json
{
"codec_type": "video",
"stream_index": 0,
"pts": 28128,
"pts_time": "0.312533",
"dts": 28128,
"dts_time": "0.312533",
"duration": 3600,
"duration_time": "0.040000",
"size": "7937",
"flags": "__",
"data": "\n00000000: 0000 0102 01d0 02b9 7420 4bfb 5df1 637e ........t K.].c~\n00000010: 0000 0302 2067 e2e9 48f8 6197 3952 8432 .... g..H.a.9R.2\n00000020: a689 afb5 69ec 0ca>
},
{
"codec_type": "audio",
"stream_index": 1,
"pts": 6280,
"pts_time": "0.392500",
"dts": 6280,
"dts_time": "0.392500",
"duration": 1024,
"duration_time": "0.064000",
"size": "258",
"flags": "K_",
"data": "\n00000000: 0102 9ffe 0b24 2ad1 2962 a5ca a569 0275 .....$*.)b...i.u\n00000010: 15a0 f442 2f92 95ee abca 7892 00f6 aac8 ...B/.....x.....\n00000020: ff8d f8b7 f368 5fb>
},


text:
Q: $A=\{1,2,3,4,5\}$. How many functions $f : A \to A$ so that $(f\circ f)(1) = 3$
$A=\{1,2,3,4,5\}$
How many functions $f : A \to A$ so that $f$ is onto?
$5!$

is this correct?

How many functions $f : A \to A$ so that $(f\circ f)(1) = 3$?
$f(1)=1, f(1)=2, f(1)=3, f(1)=4, f(1)=5$?

I don't know what to do...

How many onto functions $f : A \to A$ so that $(f\circ f)(1) = 3$?

A: Your first answer is correct. As for the second question, consider the following process of constructing a suitable function:
$f(1)$ has to be something.  If $f(1)$ is $1$, then $f(f(1))=1$, which is disallowed.  So, set $f(1)=a$, where $a$ is some number in this set which isn't $1$.
Our constraint is that $f(f(1))=3$.  That is, $f(a)$ has to be $3$.  So, set $f(a)=3$.  We are now sure that our function, however we proceed to construct the rest of it, will satisfy the constraint $f(f(1)) = 3$.  Proceed to extend the function to all other numbers in this set.  Note that any function satisfying the constraint may be constructed in this fashion.
Now, we ask the question: how many ways are there to proceed through this process?
In our first step, setting $f(1) = a$, we have four choices of $a$.  Having chosen an $a$, we have no choice but to set $f(a) = 3$.  We have $3$ more distinct elements $t\in A$ whose value $f(t)$ must be chosen from a set of the $5$ possible options in $A$.
Thus, there are $4\times 5 \times 5 \times 5 = 500$ possibilities.

All right, apparently this process is confusing, so let's build an example function.
First, we need to choose some $a \neq 1$.  Let's say $a = 4$.  Now, we have $f(1) = 4$, and $f(4) = 3$.
With that settled, we have to figure out what $f(2),f(3),$ and $f(5)$ are.  Let's say $f(2) = 1$, $f(3) = 3$, and $f(5) = 4$.  We now have a suitable function.  We could have picked any of $5$ values for each of $f(2),f(3)$ and $f(5)$.

A: The first answer is correct.
Hint :
$f \circ f (1)=3$   means
$f(1)=2$ and  $f(2)=3$
or $f(1)=3$ and  $f(3)=3$
or $f(1)=4$ and  $f(4)=3$
or $f(1)=5$ and  $f(5)=3$


text:
Q: NPM packages not getting installed in Windows-10 from Artifactory Issue Description: I use Artifactory for my NPM packages. While trying to install them in "Windows - 7", it's working fine. But in "Windows - 10" it's showing error and packages are not getting installed.
Error:
npm ERR! 403 forbidden
nmp ERR! 403 a package version that is forbidden by your security policy.
Version:
Node- 14.15.5
npm- 6.14.11
Note:

*

*Using NVM for managing node

*.npmrc: Authentication and registry updated.

*Packages are getting installed in Windows - 7 with same configuration.

A: npm install attempts to download a package that violates the policy, developers will see an error similar to the following.
$ npm i lodash@1.0.0
npm notice Could not download lodash 1.0.0 due to policy violations. Use `npm audit fix` to upgrade this dependency.
npm ERR! code E403
npm ERR! 403 Forbidden - GET https://registry.npmjs.com/lodash/-/lodash-1.0.0.tgz

To fix this error, use npm audit fix to upgrade dependencies to versions that don't violate policy.


text:
Q: problems installing Zend Framework 2 in 1 and 1 shared hosting I'm trying to deploy on a 1&1 shared linux hosting the Zend Skeleton Application that I obtained from github (https://github.com/zendframework/ZendSkeletonApplication) via a SSH connection.
I have those files already in the server, but when doing the installation's last step that's explained in github (php composer.phar install) I get the following error:
X-Powered-By: PHP/4.4.9
Content-type: text/html

Parse error:  syntax error, unexpected '<' in /homepages/45/d*******/htdocs/zend_test/ZendSkeletonApplication/composer.phar on line 75

I can see that the PHP version that shows there is 4.4.9, but I've set up the server to have php 5 (phpinfo() shows 5.4.7). I've also included an .htaccess file in the root of the installation's folder with the AddType x-mapp-php5 .php instruction, as explained here, but that doesn't seem to do anything.
EDIT:
Files structure as requested below:
[root]
    [vendor]
      [ZF2]
         [bin]
         [demos]
         [library]
         [resources]
         [vendor]
         composer.json
         LICENSE.txt
         README.md
      .gitignore
      README.md`

A: Try /usr/local/bin/php5 composer.phar install
Otherwise 1&1 would be the best people to contact for gaining access to PHP5 on the command line.

A: So instead of following the directions in github I downloaded the skeleton app from there and manually added the ZF2 library in the vendors folder and all worked fine

A: The default PHP executable is PHP4 (4.4.9) for whatever reasons. You have to manually select the right PHP executable to get Composer running. There's a php5 executable at /usr/bin/php5 but it is 5.2.17 at the day of writing this, which is not sufficient to run composer, minimum is 5.3.2.
They also have a newer PHP 5 executable comically called php6 located at /usr/bin/php6 which is currently version 5.4.19. This one will do the job.
To install composer use this:
curl -sS https://getcomposer.org/installer | php6

To use composer use this:
php6 composer.phar


text:
Q: Error on jQuery().appendo i want to ask about the extensions of jQuery, especially in Yii framework.
i got some stuck on this code :
jQuery("#repeateEnum").appendo is not a function
this code is triggered from both of this code :

*

*<table class="appendo-gii" id="<?php echo $id ?>">

*<?php $this->widget('application.extensions.appendo.JAppendo',array(
        'id' => 'repeateEnum',
        'model' => $model,..
?>
how could i fix it? Thanks for any reply.

A: If the library is properly included, check in the JS console for errors when you load the page. Maybe something else is breaking the JS.

A: have you included following js ?

refer live example at http://deepliquid.com/projects/appendo/demos.php
refer another good reference here


text:
Q: TransactionTooLargeException When Taking Photo I'm having a problem in my app when I create an intent to launch the camera app to take a picture, my app crashes and I receive the following error:
2021-06-11 18:07:46.914 7506-7506/com.package.app E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 14763232)

...

2021-06-11 18:07:49.567 7506-7506/com.package.app E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.package.app, PID: 7506
    java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 14763232 bytes
        at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:161)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: android.os.TransactionTooLargeException: data parcel size 14763232 bytes
        at android.os.BinderProxy.transactNative(Native Method)
        at android.os.BinderProxy.transact(BinderProxy.java:510)
        at android.app.IActivityTaskManager$Stub$Proxy.activityStopped(IActivityTaskManager.java:4524)
        at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:145)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

The photos, after they are taken in the camera app and returned to my app, are saved in a Room database. Interestingly, the problem only happens if there is a photo already saved in the row of the database that I'm trying to add/replace a photo. When creating a new row or taking a photo in a row which has no picture, I'm able to take the photo and save it into my database without any problem.
My Room database has a TypeConverter which converts bitmaps into base64 string for storage in the database and back to a bitmap when required to view it. After playing with the code for a while, I  tried removing the Converter from the database and implementing it's functions into my viewmodel and fragment. The app works now regardless of whether there is a picture being replaced or not.
I now suspect something to be wrong with how I implemented the Converter but I'm not sure what it could be. Please look at my code below.
Fragment
lateinit var currentPhotoPath: String

@AndroidEntryPoint
class Fragment : Fragment(R.layout.fragment) {

    private val viewModel: ViewModel by viewModels()
    private var _binding: FragmentBinding? = null

    private val binding get() = _binding!!

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        _binding = FragmentBinding.inflate(inflater, container, false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        binding.apply {
            ivPicture.setImageBitmap(viewModel.entryPictures)

            fab.setOnClickListener {
                viewModel.onSaveClick()
            }
        }

        viewLifecycleOwner.lifecycleScope.launchWhenStarted {
            viewModel.event.collect { event ->
                when (event) {
                    ViewModel.Event.NavigateToPhotoActivity -> {
                        dispatchTakePictureIntent()
                    }
                }
            }
        }

        setHasOptionsMenu(true)

    }

    private val REQUEST_IMAGE_CAPTURE = 23

    private fun dispatchTakePictureIntent() {

        Intent(MediaStore.ACTION_IMAGE_CAPTURE).also { takePictureIntent ->
            val packageManager = requireContext().packageManager
            takePictureIntent.resolveActivity(packageManager)?.also {
                val photoFile: File? = try {
                    createImageFile()
                } catch (ex: IOException) {
                    Toast.makeText(activity, "Error Creating File", Toast.LENGTH_LONG).show()
                    null
                }
                photoFile?.also {
                    val photoURI: Uri = FileProvider.getUriForFile(
                        requireContext(),
                        "com.package.app.fileprovider",
                        it
                    )
                    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI)
                    requireActivity().startActivityFromFragment(this, takePictureIntent, REQUEST_IMAGE_CAPTURE)
                }
            }
        }
    }

    @Throws(IOException::class)
    private fun createImageFile(): File {
        val timeStamp: String = SimpleDateFormat("yyyyMMdd_HHmmss").format(Date())
        val storageDir: File? = context?.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
        return File.createTempFile(
            "JPEG_${timeStamp}_", /* prefix */
            ".jpg", /* suffix */
            storageDir /* directory */
        ).apply {
            // Save a file: path for use with ACTION_VIEW intents
            currentPhotoPath = absolutePath
        }
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == Activity.RESULT_OK) {

            lifecycleScope.launch {

                val takenImage = BitmapFactory.decodeFile(currentPhotoPath)

                viewModel.onPhotoRetrieved(takenImage)

                binding.ivPicture.apply {
                    visibility = View.VISIBLE
                    setImageBitmap(takenImage)
                }
            }

        } else {
            Toast.makeText(activity, "Error Retrieving Image", Toast.LENGTH_LONG).show()
        }
    }

    override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
        inflater.inflate(R.menu.menu_fragment, menu)
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        return when (item.itemId) {
            R.id.icon_photo -> {
                viewModel.onTakePhotoSelected()
                true
            }
            else -> super.onOptionsItemSelected(item)
        }
    }

    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }
}

ViewModel:
@HiltViewModel
class ViewModel @Inject constructor(
    private val dao: EntryDao,
    private val state: SavedStateHandle
) : ViewModel() {

    val entry = state.get<Entry>("entry")

    var entryPictures = entry?.pictures

    private val eventChannel = Channel<Event>()
    val event = eventChannel.receiveAsFlow()

    fun onSaveClick() {
        if (entry != null) {
            val updatedEntry = entry.copy(
                pictures = entryPictures
            )
            updatedEntry(updatedEntry)
        } else {
            val newEntry = Entry(
                pictures = entryPictures
            )

            createEntry(newEntry)
        }
    }

    private fun createEntry(entry: Entry) = viewModelScope.launch {
        dao.insert(entry)
    }

    private fun updatedEntry(entry: Entry) = viewModelScope.launch {
        dao.update(entry)
    }

    fun onTakePhotoSelected() = viewModelScope.launch {

        eventChannel.send(Event.NavigateToPhotoActivity)
    }

    fun onPhotoRetrieved(bitmap: Bitmap) = viewModelScope.launch {
        entryPictures = bitmap

    }

    sealed class Event {
        object NavigateToPhotoActivity : Event()
    }
}

Database:
@Database(entities = [Entry::class], version = 1)
@TypeConverters(Converters::class)

abstract class Database : RoomDatabase() {

    abstract fun entryDao(): EntryDao

    class Callback @Inject constructor(
        private val database: Provider<com.mayuram.ascend.data.Database>,
        @ApplicationScope private val applicationScope: CoroutineScope
    ) : RoomDatabase.Callback() {

        override fun onCreate(db: SupportSQLiteDatabase) {
            super.onCreate(db)

            val dao = database.get().entryDao()

            applicationScope.launch {
                dao.insert(Entry(null))
                dao.insert(Entry(null))
                dao.insert(Entry(null))
                dao.insert(Entry(null))
            }
        }
    }
}

Converter

class Converters {

    @Suppress("DEPRECATION")
    @TypeConverter
    fun bitmapToString(bitmap: Bitmap?): String {

        val outputStream = ByteArrayOutputStream()

        if (android.os.Build.VERSION.SDK_INT >= 30) {
            bitmap?.compress(Bitmap.CompressFormat.WEBP_LOSSY, 50, outputStream)
        } else {
            bitmap?.compress(Bitmap.CompressFormat.WEBP, 50, outputStream)
        }
        val imageBytes: ByteArray = outputStream.toByteArray()

        return Base64.encodeToString(imageBytes, Base64.DEFAULT)
    }

    @TypeConverter
    fun stringToBitmap(string: String): Bitmap? {
        val imageBytes: ByteArray = Base64.decode(string, Base64.DEFAULT)

        return BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.size)

    }
}

DataClass:
@Entity(tableName = "entry_table")
@Parcelize
data class Entry(
    val pictures: Bitmap?,
    @PrimaryKey(autoGenerate = true) val id: Int = 0
) : Parcelable

Changes I made to get it to work:
In ViewModel, modified onPhotoRetrieved function to convert image to string
    fun onPhotoRetrieved(bitmap: Bitmap) = viewModelScope.launch {

        val outputStream = ByteArrayOutputStream()

        if (android.os.Build.VERSION.SDK_INT >= 30) {
            bitmap.compress(Bitmap.CompressFormat.WEBP_LOSSY, 50, outputStream)
        } else {
            bitmap.compress(Bitmap.CompressFormat.WEBP, 50, outputStream)
        }
        val imageBytes: ByteArray = outputStream.toByteArray()
        val result = Base64.encodeToString(imageBytes, Base64.DEFAULT)

        entryPictures = result

    }

In fragment, added the convert string to bitmap function in onViewCreated
val imageBytes: ByteArray = Base64.decode(viewModel.entryPictures.toString(), Base64.DEFAULT)
val result = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.size)
ivPicture.setImageBitmap(result)

Also changed type of val pictures to String? instead of Bitmap? in my data class and commented out @TypeConverters in my Database.

A: Fix
In short you need to reconsider saving images in the database and consider storing a path to the image (or suitable part thereof, to uniquely identify the image)  with the actual image being store at a suitable location.
An alternative, but perhaps still quite costly resource wise. Could be to consider storing manageable chunks of images (perhaps consider 100k chunks).
e.g. How to use images in Android SQLite that are larger than the limitations of a CursorWindow?
Another alternative could be to store smaller images (if any consider they are photos) in the database but larger images as paths.
e.g. How can I insert image in a sqlite database
The Issue
What you have come across is a precursor (pun intended :)) to other problems with the size of images.
That is you have exceeded the 1Mb limit of a Parcel as explained by TransactionTooLargeException which includes :-

The Binder transaction buffer has a limited fixed size, currently 1MB, which is shared by all transactions in progress for the process. Consequently this exception can be thrown when there are many transactions in progress even when most of the individual transactions are of moderate size.

Your parcel(image) appears to be 14763232 i.e. 14Mb.
Even if you increased the parcel Size you could then hit the Android SQLite implementation and therefore Room issues with Cursor size limitations and or the inefficiencies of the reduced number of rows in a Cursor.

When creating a new row or taking a photo in a row which has no picture, I'm able to take the photo and save it into my database without any problem.

When inserting the limitations aren't there as you insert on an individual basis. The limitations are when extracting the data as typically/often groups of data are extracted in a single request and an intermediate buffer is used (i.e. a Cursor is a buffer).


text:
Q: Package management for coexisting Python 2 and 3 I have been using Python 2.7 for a while now and installing packages using pip install without any issue. I just started using python 3 for a certain code and realized how confusing having different versions of Python can get.
I have Fedora 25, the default Python version is 2.7.13 and the default Python 3 version is Python 3.5.3,
I want to be able to use python 2.7 and python 3, my general question is:
What are the best practices when installing packages for both Python 2 and Python 3 on one machine?
As I mentioned using pip install in Python 2.7 works fine, but what about Python 3? I can:

*

*use pip3 install

*use python3 -m pip install
Which one should I use and how does it affect the python 2 version of the module? pip3 is not installed on Fedora 25, which raises a new question: how should I install it? as I understand I can:

*

*use dnf install python3-pip (it is unclear if that actually works when pip for Python 2.7 is installed)

*use python3 get-pip.py
Finally, would it be a good idea to create a Python 2 and a Python 3 virtual environment to address this issue?
From what I have read on the internet there does not seem to be a clear consensus on these questions, I hope this thread will clarify.

A: pip3 install and python3 -m pip install — both work perfectly and don't have any impact on Python 2. You can have as many Pythons in your system as you want; I for one have Python 2.7, 3.4, 3.5 and 3.6. To distinguish different versions of pip I use versioned names: pip3.4 install.
And of course I use virtual environments and virtualenvwrapper quite intensively.