Q:

Organising our software and website tags

A recent round of re-tagging highlighted that the way we are tagging questions relating to software and websites is highly inconsistent, and that not everyone is happy with the current state of affairs. This question seeks to reach a consensus on a tagging approach that:

Is easy for people doing the tagging to understand (especially for newbies), and does not require the intervention of more experienced users unless in exceptional circumstances
Allows individuals to easily locate questions related to the one they may ask/have asked
Allows individuals to easily follow/subscribe/filter to the tags they are interested in and be relatively certain that they aren’t missing questions of interest
Ensures that search engine results (which are prepended with the most popular tag on a question) entice newcomers to the site
Is helpful now, but also future-proof against growth in the site without a massive amount of re-tagging becoming necessary at any time

These requirements are not mutually compatible.
Background data on current tagging volumes (of course many questions have two or more of these tags so the volume of questions as a percentage of the site total is less than it might appear):

And some observations and questions (in no particular order):

software-recommendations (new tag) and tools
(longstanding tag) seem to overlap significantly. Do we need them
both?
The guidance for product-support says:

Related to the effective use of a product (principally software)
  intended to support or facilitate genealogical research. Where
  relevant, should be accompanied by a tag identifying the particular
  products.

However the tag is only used 5 times, so clearly it isn’t being
applied consistently, given that we have over 200 questions about
named products.
Should we retrospectively apply it to all named products/websites?
Or is naming the product/website sufficient to imply that product
support is required.
online has no guidance, and is used for a mixture of questions relating to finding online records, transferring/synching data between programs, participating in message boards elsewhere, using named websites, seeking product recommendations, url standardisation, and sharing/privacy concerns.
website has 24 questions, but there are 156 questions that name websites!
subscription has 4 questions, which might fit into “recommendation” or “product-support” tags if we can’t justify keeping it separate.
Do we need to differentiate between software and websites other than implicitly by product name.  If somebody specifically wants a recommendation for a desktop software product or an online solution, they can specify it in the question — is there any real value in tagging for this? Perhaps people want only to follow software-related questions and are violently disinterested in website-related ones? Is there a clearcut distinction between software and websites any more? Should we differentiate between websites for locating records and websites for other purposes?

I’m going to put my suggestions into separate answers, so people can vote for the ones they like and discuss the ones they don’t like (or make counter-proposals).

Parking some data points here as they're too long to go in comments...
The tag-wiki from the now defunct software
Use this tag for questions about software which can help with genealogy or family history research or record keeping. Do not use for questions about websites (which has a separate tag).
Most genealogists and family historians use software to help them perform their research and record the results. Questions using this tag could include:

How do I do X with a particular software programme?
What criteria should I use when selecting a software programme for X purpose?

If you're asking about a specific piece of software, tag the question with the name of the software as well. It would also be helpful if you were explicit in your question about the version of the software you're using and which operating system it runs on.
Don't ask:

What is the best software to do X?
Which software can do X?
What features should be supported in the programme I'm developing?

All these are likely to generate lists, opinions and debates and are not a good fit for our Q&A site. (Chat might be a good place to have those sorts of discussions).
Example Questions
What are the key features in genealogical software that will help me future proof my research?
How do I keep the different software and online trees I use in synch?
What standards exist for the exchange of genealogical information?
From the on-topic spiel of https://softwarerecs.stackexchange.com
This site is for questions asking for recommendations of software ready-to-use to accomplish a particular task, that is, “what software can I use to do …?”. While this includes software libraries for development use, note that recommendations of tutorials, data sources, media libraries (e.g. icon collections) etc. are off-topic – as are questions like “what technology to use for …?”
Good software recommendation requests have two components:

A purpose — a task to accomplish, a user story
Some objective requirements — a minimum set of features

How do other sites that allow software-recommendations (or other recommendations) tag them
travel.stackexchange.com : software (Not all of these questions are software recommendations but some are, but it's a very low volume tag)
ebooks.stackexchange.com : software (Not all of these questions are software recommendations but some are, but it's a very low volume tag)
astronomy.stackexchange.com : software (Not all of these questions are software recommendations but some are, but it's a very low volume tag)
askubuntu.stackexchange.com : software-recommendation
askdifferent.stackexchange.com : software-recommendation
unix.stackexchange.com: software-rec (which is a synonym for software )
gis.stackexchange.com: software-recommendations (with a tag wiki excerpt that says Questions seeking software recommendations are better asked at the Software Recommendations Stack Exchange)
photography.stackexchange.com : equipment-recommendation
superuser.stackexchange.com : software-rec -- points users to the software-recommendations site but there are 700 open questions
bioinformatics.stackexchange.com : software-recommendation
gardening.stackexchange.com : plant-recommendations
Relevant to the 'shopping question' question
https://stackoverflow.blog/2010/11/23/qa-is-hard-lets-go-shopping/

A:

As there are only 10 questions with online I suggest re-tagging them to the most appropriate combination of tags and burninating online


Q:

How to use different activations in output layer in Keras in R

I want to combine more types of activations in output layer in Keras interface for R. Also, I want to use different loss functions for different outputs. Lets say I want to have first two neurons linear with MSE loss, second 2 neurons sigmoid with BCE loss and last output will be relu with MAE loss. By now I have this and it is not working:
model <- keras_model_sequential()

model %>% layer_dense(units=120, activation="selu",
           input_shape=dim(X)[2]) # this is hidden layer, this works fine

model %>% layer_dense(units=120, activation=as.list(c(rep("linear",2),
            rep("sigmoid",2), "relu"))) # output layer which is not working

model %>% compile(loss=as.list(c(rep("mean_squared_error",2),
             rep("binary_crossentropy",2), "mean_absolute_error")), # problem here ?
             optimizer=optimizer_adam(lr=0.001) ,metrics = "mae")

and after this I fit the model with model %>% fit(...) .
Error is the following:
Error in py_call_impl(callable, dots$args, dots$keywords) :
  ValueError: When passing a list as loss, it should have one entry per model outputs.
  The model has 1 outputs, but you passed loss=['mean_squared_error', 'mean_squared_error', ...

Any help is appreciated.
EDIT : only rewrited code so that is better readable.

A:

I think that if you want to have multiple outputs you need to use the functional (that is, not the sequential) API - see some examples here: https://keras.rstudio.com/articles/functional_api.html


Q:

ng-view not following CSS of 1 View

I have banged my head against my keyboard for a small formatting problem.
I am using ng-view and it seems to show the index view (main view using "#/" route) without the proper masonry CSS formatting, but it does show the other views (which are not in masonry format) properly. Here's the code:

Unformatted when using Ng-view:
<!DOCTYPE html>

      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
      <meta name="description" content="This is an example of a meta description. This will often show up in search results.">
      <title>ROBTG4</title>
      <link rel="shortcut icon" href="img/favicon.png">
      <link rel="apple-touch-icon" href="apple-touch-icon.png">

      <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:300,400,700,900&subset=latin,latin-ext">
      <link rel="stylesheet" href="css/slick.css"/>
      <link rel="stylesheet" href="css/revolution-slider.css">
      <link rel="stylesheet" href="css/bootstrap.css">
      <link rel="stylesheet" href="css/min/font-awesome.min.css">
      <link rel="stylesheet" href="css/global.css">
      <link rel="stylesheet" href="css/components.css">
      <link rel="stylesheet" href="css/widgets.css">

         <svg style="display: none;">
            <symbol viewBox="0 0 96 96" id="shape-arrow-left-light">
               <title>arrow-left-light</title>
               <path d="M84,44H21.656l21.456-21.456c1.562-1.562,1.562-4.095,0.001-5.657c-1.562-1.562-4.096-1.562-5.658,0L9.172,45.171l0,0  c-0.186,0.186-0.352,0.391-0.498,0.61c-0.067,0.101-0.114,0.21-0.171,0.315c-0.067,0.124-0.142,0.242-0.196,0.373  c-0.056,0.135-0.088,0.276-0.129,0.416c-0.032,0.111-0.075,0.217-0.098,0.331C8.028,47.475,8,47.737,8,48l0,0  c0,0.003,0.001,0.005,0.001,0.008c0,0.259,0.027,0.519,0.078,0.774c0.024,0.121,0.069,0.232,0.104,0.349  c0.039,0.133,0.07,0.268,0.123,0.397c0.058,0.139,0.136,0.265,0.208,0.396c0.054,0.098,0.096,0.198,0.159,0.292  c0.147,0.221,0.314,0.427,0.501,0.614l28.282,28.281c1.562,1.562,4.095,1.562,5.657,0.001c1.562-1.562,1.562-4.096,0-5.658  L21.657,52H84c2.209,0,4-1.791,4-4S86.209,44,84,44z"/>
            </symbol>
            <symbol viewBox="0 0 96 96" id="shape-arrow-left">
               <title>arrow-left</title>
               <path d="M84,44H21.656l21.456-21.456c1.562-1.562,1.562-4.095,0.001-5.657c-1.562-1.562-4.096-1.562-5.658,0L9.172,45.171l0,0  c-0.186,0.186-0.352,0.391-0.498,0.61c-0.067,0.101-0.114,0.21-0.171,0.315c-0.067,0.124-0.142,0.242-0.196,0.373  c-0.056,0.135-0.088,0.276-0.129,0.416c-0.032,0.111-0.075,0.217-0.098,0.331C8.028,47.475,8,47.737,8,48l0,0  c0,0.003,0.001,0.005,0.001,0.008c0,0.259,0.027,0.519,0.078,0.774c0.024,0.121,0.069,0.232,0.104,0.349  c0.039,0.133,0.07,0.268,0.123,0.397c0.058,0.139,0.136,0.265,0.208,0.396c0.054,0.098,0.096,0.198,0.159,0.292  c0.147,0.221,0.314,0.427,0.501,0.614l28.282,28.281c1.562,1.562,4.095,1.562,5.657,0.001c1.562-1.562,1.562-4.096,0-5.658  L21.657,52H84c2.209,0,4-1.791,4-4S86.209,44,84,44z"/>
            </symbol>
            <symbol viewBox="0 0 96 96" id="shape-arrow-right-light">
               <title>arrow-right-light</title>
               <path d="M12,52h62.344L52.888,73.456c-1.562,1.562-1.562,4.095-0.001,5.656c1.562,1.562,4.096,1.562,5.658,0l28.283-28.284l0,0  c0.186-0.186,0.352-0.391,0.498-0.609c0.067-0.101,0.114-0.21,0.172-0.315c0.066-0.124,0.142-0.242,0.195-0.373  c0.057-0.135,0.089-0.275,0.129-0.415c0.033-0.111,0.076-0.217,0.099-0.331C87.973,48.525,88,48.263,88,48l0,0  c0-0.003-0.001-0.006-0.001-0.009c-0.001-0.259-0.027-0.519-0.078-0.774c-0.024-0.12-0.069-0.231-0.104-0.349  c-0.039-0.133-0.069-0.268-0.123-0.397c-0.058-0.139-0.136-0.265-0.208-0.396c-0.054-0.098-0.097-0.198-0.159-0.292  c-0.146-0.221-0.314-0.427-0.501-0.614L58.544,16.888c-1.562-1.562-4.095-1.562-5.657-0.001c-1.562,1.562-1.562,4.095,0,5.658  L74.343,44L12,44c-2.209,0-4,1.791-4,4C8,50.209,9.791,52,12,52z"/>
            </symbol>
            <symbol viewBox="0 0 96 96" id="shape-arrow-right">
               <title>arrow-right</title>
               <path d="M12,52h62.344L52.888,73.456c-1.562,1.562-1.562,4.095-0.001,5.656c1.562,1.562,4.096,1.562,5.658,0l28.283-28.284l0,0  c0.186-0.186,0.352-0.391,0.498-0.609c0.067-0.101,0.114-0.21,0.172-0.315c0.066-0.124,0.142-0.242,0.195-0.373  c0.057-0.135,0.089-0.275,0.129-0.415c0.033-0.111,0.076-0.217,0.099-0.331C87.973,48.525,88,48.263,88,48l0,0  c0-0.003-0.001-0.006-0.001-0.009c-0.001-0.259-0.027-0.519-0.078-0.774c-0.024-0.12-0.069-0.231-0.104-0.349  c-0.039-0.133-0.069-0.268-0.123-0.397c-0.058-0.139-0.136-0.265-0.208-0.396c-0.054-0.098-0.097-0.198-0.159-0.292  c-0.146-0.221-0.314-0.427-0.501-0.614L58.544,16.888c-1.562-1.562-4.095-1.562-5.657-0.001c-1.562,1.562-1.562,4.095,0,5.658  L74.343,44L12,44c-2.209,0-4,1.791-4,4C8,50.209,9.791,52,12,52z"/>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-arrow-thin-left">
               <title>arrow-thin-left</title>
               <g>
                  <polyline fill="none" stroke-width="2" stroke-linejoin="bevel" stroke-miterlimit="10" points="37,15 20,32
                     37,49  "/>
               </g>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-arrow-thin-right">
               <title>arrow-thin-right</title>
               <g>
                  <polyline fill="none" stroke-width="2" stroke-linejoin="bevel" stroke-miterlimit="10" points="27,15 44,32
                     27,49  "/>
               </g>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-browser-search">
               <title>browser-search</title>
               <rect x="1" y="7" fill="none" stroke-width="2" stroke-miterlimit="10" width="62" height="50"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="1" y1="15" x2="63" y2="15"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="10" y1="11" x2="6" y2="11"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="18" y1="11" x2="14" y2="11"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="26" y1="11" x2="22" y2="11"/>
               <g>
                  <circle fill="none" stroke-width="2" stroke-miterlimit="10" cx="29" cy="33" r="6"/>
                  <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="33" y1="37" x2="41" y2="45"/>
               </g>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-cup">
               <title>cup</title>
               <path fill="none" stroke-width="2" stroke-miterlimit="10" d="M16,27c0,4.418,6.059,8,16,8s16-3.582,16-8V1H16V27z
                  "/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="20" y1="63" x2="44" y2="63"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="32" y1="35" x2="32" y2="63"/>
               <path fill="none" stroke-width="2" stroke-miterlimit="10" d="M16,7H7c0,0,0,9,9,9"/>
               <path fill="none" stroke-width="2" stroke-miterlimit="10" d="M48,7h9c0,0,0,9-9,9"/>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-heart">
               <title>heart</title>
               <path fill="none" stroke-width="2" stroke-miterlimit="10" d="M1,21c0,20,31,38,31,38s31-18,31-38
                  c0-8.285-6-16-15-16c-8.285,0-16,5.715-16,14c0-8.285-7.715-14-16-14C7,5,1,12.715,1,21z"/>
            </symbol>
            <symbol viewBox="0 0 28 15" id="shape-indicator">
               <title>indicator</title>
               <path class="st0" fill="#e8e8e8" d="M13.5,0L15,1.4L1.4,15L0,13.5L13.5,0z"/>
               <path class="st0" fill="#e8e8e8" d="M28,13.5L26.5,15L13,1.4L14.4,0L28,13.5z"/>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-laptop">
               <title>laptop</title>
               <g>
                  <rect x="8" y="12" fill="none" stroke-width="2" stroke-miterlimit="10" width="48" height="34"/>
                  <rect x="1" y="46" fill="none" stroke-width="2" stroke-miterlimit="10" width="62" height="6"/>
                  <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="34" y1="16" x2="30" y2="16"/>
               </g>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-layers">
               <title>layers</title>
               <polyline fill="none" stroke-width="2" stroke-miterlimit="10" points="18,26.066 2,33 32,45 62,33 46,26.067 "/>
               <polyline fill="none" stroke-width="2" stroke-miterlimit="10" points="18,39.066 2,46 32,58 62,46 46,39.067 "/>
               <polygon fill="none" stroke-width="2" stroke-miterlimit="10" points="32,32 62,20 32,7 2,20 "/>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-layout-4boxes">
               <title>layout-4boxes</title>
               <rect x="1" y="1" fill="none" stroke-width="2" stroke-miterlimit="10" width="62" height="14"/>
               <rect x="1" y="39" fill="none" stroke-width="2" stroke-miterlimit="10" width="31" height="24"/>
               <rect x="32" y="39" fill="none" stroke-width="2" stroke-miterlimit="10" width="31" height="24"/>
               <rect x="1" y="15" fill="none" stroke-width="2" stroke-miterlimit="10" width="31" height="24"/>
               <rect x="32" y="15" fill="none" stroke-width="2" stroke-miterlimit="10" width="31" height="24"/>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-layout-sideleft">
               <title>layout-sideleft</title>
               <rect x="1" y="1" fill="none" stroke-width="2" stroke-miterlimit="10" width="62" height="14"/>
               <rect x="1" y="15" fill="none" stroke-width="2" stroke-miterlimit="10" width="62" height="48"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="22" y1="15" x2="22" y2="63"/>
            </symbol>
            <symbol viewBox="0 0 289.3 286.2" id="shape-logo">
               <title>logo</title>

               <path class="st0" d="M267.1,143.3L267.1,143.3L267.1,143.3z M199.6,63.3c-14.3-9.2-30.7-15.2-47.7-16.2c-34.3-0.1-68.7-0.1-103,0
                  c-0.3,57.1-0.1,114.1-0.1,171.2c-0.1,9,0.2,18.1-0.2,27.2l-23.4-22.8c0-0.3,0-0.6-0.1-0.9c-0.3-5.3-0.1-10.6-0.1-15.9
                  C25,145,24.7,84.1,25,23.3h122.1c1.1,0,2.2,0,3.3,0c0.1,0,0.1,0,0.2,0c0,0,0,0,0.1,0c64.4,1.9,116.5,55.1,116.5,120
                  c0,51.7-33.1,96-79.2,112.8c-0.2,0.1-0.4,0.2-0.6,0.2c-0.9,0.3-1.8,0.6-2.7,0.9c0,0,0,0,0,0c-3,1-6,1.8-9,2.5c-4,1-8.1,1.8-12.2,2.4
                  c0,0,0,0,0,0c-2.3,0.4-4.7,0.7-7,1c-1.7,0-3.4,0-5.1,0c-1.4,0-2.7,0.1-4.1,0.1h-8.7c-6,0-12,0-17.9,0c-8.9,0-17.9,0-26.8,0
                  c-7,0-13.9,0-20.9-0.1v-0.7v-0.7v-0.7v-0.7v-0.7v-189h73.5c40.4,0,73.4,33.1,73.4,73.4c0,30-18.2,55.9-44.1,67.3
                  c-9,4-19,6.2-29.4,6.2h-25.7v-24.3V94.9l-23.9,0l0,122.7l0,21.8c8,0.1,15.9,0.1,23.9,0.1c11.6,0,23.2,0,34.8-0.1
                  c7-0.6,13.8-2,20.4-4.2c21.5-7.1,40.3-22,52.3-41.3c7.7-12.9,13.1-27.6,13.6-42.7c0.8-4.9,1-10,0.2-15
                  C240,107.2,223.5,79.8,199.6,63.3L199.6,63.3z M25,255l8.4,8.3l23.3,22.9h63.7h25.7c10.1,0,19.9-1.1,29.4-3.1
                  c64.7-13.7,113.7-71.4,113.7-140.1C289.3,64.4,224.9,0,146.2,0H0c0.1,76.6,0,153.2,0,229.8c0,0.2,0,0.4,0,0.6L25,255z"/>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-mail-heart">
               <title>mail-heart</title>
               <g>
                  <polyline fill="none" stroke-width="2" stroke-miterlimit="10" points="1,26 32,45.434 63,26    "/>
                  <polyline fill="none" stroke-width="2" stroke-miterlimit="10" points="11.334,21.667 1,26 1,63 63,63 63,26
                     63,26 52.666,21.667    "/>
                  <polyline fill="none" stroke-width="2" stroke-miterlimit="10" points="11,32 11,1 53,1 53,32   "/>
               </g>
               <path fill="none" stroke-width="2" stroke-miterlimit="10" d="M22,19c0,6.666,10,12,10,12s10-5.334,10-12
                  c0-2.762-2-5-5-5c-2.762,0-5,2.238-5,5c0-2.762-2.238-5-5-5C24,14,22,16.238,22,19z"/>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-mail">
               <title>mail</title>
               <g>
                  <rect x="1" y="13" fill="none" stroke-width="2" stroke-miterlimit="10" width="62" height="37"/>
                  <polyline fill="none" stroke-width="2" stroke-miterlimit="10" points="1,13 32,33 63,13    "/>
               </g>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-map-pin">
               <title>map-pin</title>
               <g>
                  <circle fill="none" stroke-width="2" stroke-miterlimit="10" cx="32" cy="22" r="6"/>
                  <path fill="none" stroke-width="2" stroke-miterlimit="10" d="M53,22.735C52.948,10.73,43.599,1,32,1
                     s-21,9.73-21,21.735C11,38.271,31.965,63,31.965,63S53.069,38.271,53,22.735z"/>
               </g>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-mixer">
               <title>mixer</title>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="12" y1="19" x2="12" y2="64"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="52" y1="0" x2="52" y2="45"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="32" y1="38" x2="32" y2="64"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="32" y1="0" x2="32" y2="26"/>
               <circle fill="none" stroke-width="2" stroke-miterlimit="10" cx="12" cy="13" r="6"/>
               <circle fill="none" stroke-width="2" stroke-miterlimit="10" cx="52" cy="51" r="6"/>
               <circle fill="none" stroke-width="2" stroke-miterlimit="10" cx="32" cy="32" r="6"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="12" y1="0" x2="12" y2="7"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="52" y1="57" x2="52" y2="64"/>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-mouse">
               <title>mouse</title>
               <path fill="none" stroke-width="2" stroke-miterlimit="10" d="M48,17c0-8.836-7.164-16-16-16S16,8.164,16,17v30
                  c0,8.836,7.164,16,16,16s16-7.164,16-16V17z"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="32" y1="1" x2="32" y2="21"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="16" y1="21" x2="48" y2="21"/>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-nav">
               <title>nav</title>
               <line fill="none" stroke-width="3" stroke-miterlimit="10" x1="0" y1="40" x2="64" y2="40"/>
               <line fill="none" stroke-width="3" stroke-miterlimit="10" x1="0" y1="32" x2="64" y2="32"/>
               <line fill="none" stroke-width="3" stroke-miterlimit="10" x1="0" y1="24" x2="64" y2="24"/>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-paintbucket">
               <title>paintbucket</title>
               <polygon fill="none" stroke-width="2" stroke-linejoin="bevel" stroke-miterlimit="10" points="3,38 28,63 54,37
                  61,36 33,8 "/>
               <path fill="none" stroke-width="2" stroke-linejoin="bevel" stroke-miterlimit="10" d="M32,27V6
                  c0-2.762-2.238-5-5-5s-5,2.238-5,5v13"/>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-pencil-ruler">
               <title>pencil-ruler</title>
               <polygon fill="none" stroke-width="2" stroke-miterlimit="10" points="1,63 1,2 62,63 "/>
               <polygon fill="none" stroke-width="2" stroke-miterlimit="10" points="14,54 14,30 38,54 "/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="8" y1="22" x2="2" y2="22"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="6" y1="30" x2="2" y2="30"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="8" y1="38" x2="2" y2="38"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="6" y1="46" x2="2" y2="46"/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="8" y1="54" x2="2" y2="54"/>
               <polygon fill="none" stroke-width="2" stroke-miterlimit="10" points="25,1 19,7 55,43 63,45 61,37 "/>
               <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="25" y1="13" x2="31" y2="7"/>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-phone">
               <title>phone</title>
               <g>
                  <rect x="16" y="1" fill="none" stroke-width="2" stroke-miterlimit="10" width="32" height="62"/>
                  <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="28" y1="5" x2="36" y2="5"/>
                  <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="16" y1="51" x2="48" y2="51"/>
                  <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="16" y1="9" x2="48" y2="9"/>
                  <circle fill="none" stroke-width="2" stroke-linejoin="bevel" stroke-miterlimit="10" cx="32" cy="57" r="2"/>
               </g>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-picture">
               <title>picture</title>
               <g>
                  <rect x="1" y="11" fill="none" stroke-width="2" stroke-miterlimit="10" width="62" height="42"/>
                  <polyline fill="none" stroke-width="2" stroke-miterlimit="10" points="1,47 24,27 36,39 42,31 63,49    "/>
                  <circle fill="none" stroke-width="2" stroke-miterlimit="10" cx="51" cy="22" r="5"/>
               </g>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-play">
               <title>play</title>
               <rect x="1" y="1" fill="none" stroke-width="2" stroke-linejoin="bevel" stroke-miterlimit="10" width="62" height="62"/>
               <g>
                  <polygon fill="none" stroke-width="2" stroke-linejoin="bevel" stroke-miterlimit="10" points="26,21 42,32
                     26,43  "/>
               </g>
            </symbol>
            <symbol viewBox="0 0 64 64" id="shape-video">
               <title>video</title>
               <g>
                  <polygon fill="none" stroke-width="2" stroke-miterlimit="10" points="46,30 63,20 63,52 46,42 46,52 1,52 1,20
                     46,20  "/>
                  <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="6" y1="28" x2="10" y2="28"/>
                  <line fill="none" stroke-width="2" stroke-miterlimit="10" x1="14" y1="28" x2="18" y2="28"/>
                  <rect x="7" y="36" fill="none" stroke-width="2" stroke-miterlimit="10" width="18" height="10"/>
                  <polyline fill="none" stroke-width="2" stroke-miterlimit="10" points="6,12 32,12 40,20    "/>
               </g>
            </symbol>
         </svg>

Home

About

Blog

Contact

            <button class="nav-toggle">
               <svg>
                  <use xlink:href="#shape-nav"></use>
               </svg>
            </button>

                     <svg class="mail">
                        <use xlink:href="#shape-mail"></use>
                     </svg>
                     rogreen@umich.edu

Copyright © Made with Love & Caffeine by Gfxbucket. All Rights Reserved.

The site becomes formatted when replacing  with the main.html view's code (of course, this makes it impossible to show the other routes since ng-view no longer exists, but it shows that the problem is caused by ng-view itself/angular, as I have directly linked all css and js files to the main.html view as well).

This is main.html - what I am trying to show in masonry through ng-view.

#BBUM Movement

            Hashtag Activism & Social Media

Nomsy

            Food Content Discovery Tailored to Your Diet

Swyft

            Safe, Nightly University Transportation

Bitcoin Trading

            Trading Against the Blockchain

Blaclist

            Redefining Mobile, Black Media

Learning More

            Yearning for Mentorship

Any thoughts on how to get ng-view to process main.html view correctly? Again all other views show up perfectly.

A:

If by masonry formatting you means that you are trying to use the library, seems you are missing the reference to masonry js file.
Add this somewhere in your html page along with your other script tags:


Q:

Get html input values in server side in asp.net

    <asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="Server">
     <script type="text/javascript">
      $(function () {
                    $("#slider-range").slider({
                        range: true,
                        min: 0,
                        max: 100,
                        values: [0, 75],
                        slide: function (event, ui) {
                            $("#value").val("" + ui.values[0] + " - " + ui.values[1]);
                        }
                    });
                    $("#value").val("" + $("#slider-range").slider("values", 0) +
                    " - " + $("#slider-range").slider("values", 1));
                });
      </script>
    </asp:content>

I am using this code for a slider in my asp.net page. Now the value in displayed in the Html input.
      <input type="text" id="value" style="border: 0; font-weight: bold;" />

it is displayed as 0-75. How can I get both the values (0,75) separately in my server side so that i can write the values in database.
How to change the code so that in my server side I can asign values to 2 variables. The slider contains min value(0) and max value(75)[selected by users].
var a= 0;
var b= 75;

A:

You could just do something like:
string[] vals = Request.Form["value"].Split('-');
int a = int.Parse(vals[0]);
int b = int.Parse(vals[1]);


Q:

How can I make a rectangular on the moving sprite in Cocos2d android?

CGRect targetRect = CGRect.make(target.getPosition().x - (target.getContentSize().width),
            target.getPosition().y - (target.getContentSize().height),
            target.getContentSize().width,
            target.getContentSize().height);

target is a sprite ... and I make to create a rectangular on the border of the sprite.
I tried to do this work by draw(GL10 gl) but I'm not getting the way to call it .
So, If someone have an idea how to do this . Please help me out of this... thanks in advance

A:

public void draw(GL10 gl){
        gl.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
        gl.glLineWidth(4);
        CCDrawingPrimitives.ccDrawCircle(gl, centerAnchor, 20*scaleX, ccMacros.CC_DEGREES_TO_RADIANS(90), 50, true);

            CCDrawingPrimitives.ccDrawCircle(gl, CGPoint.make((handposition.x-40f)*scaleX,(handposition.y+10f)*scaleY), 45*scaleX, ccMacros.CC_DEGREES_TO_RADIANS(90), 50, true);

            CCDrawingPrimitives.ccDrawPoint(gl, centerAnchor);

        gl.glLineWidth(1);
        gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
        gl.glPointSize(1);
    }

similarly you can draw rectangle by using ccDrawRect() method


Q:

How to open a new blank document in Pages from spotlight?

How can i open a new blank document in Pages app on Mac OSX Yosemite in Spotlight (and therefore in Alfred)?
Now, when i open Pages it first presents me with New document dialog and then Select Template dialog. Of course i click my way through all the prompts but it would be much more convenient to bring up Spotlight (or better yet Alfred) and just type something like Pages /n and go straight to typing.

A:

Part of the problem can be eliminated by selecting a default template in the Preferences.

Then, when opening from Spotlight or Alfred, a click on the new document button opens your default template.  [Blank in the case of the setting shown above.]
Then, one could create an Automator or Applescript workflow that is attached to a service evoked by a keystroke combination.

Edit: OP @Rusl added this Applescript to a keystroke combination.
tell application "Pages"
  activate
  make new document
end tell


Q:

Need logical solution for uncountable loop dillema

Supposed I have this kind of loop in java (not an exact code, neither it's a truly valid code, but just to give you a general perspective of situation):
print "
";
while (res = fetch(database)) {
    print ("
" + res.col['data'] + "
");
}
print "
";

and I have this CSS, which makes the last item on the list has red color.
ul li:last-child { color: red; }

this works fine on most browsers. the problems are:

I need to make this work on IE8 too.
IE8 doesn't support last-child.
I cannot test whether current iteration of "while" is entering last iteration or not. or let's say, there's no way I could check when the loop would end. this is not an ordinary loop, but let's just say like that. so I can't give the last
 a class, say class="lastchild".
I also tried with javascript and jquery, and both can't select "last-child" either, as they depends on the css for the selection, I think.

how is the best approach in this situation? thanks.

A:

print "
";
String liText=null;
while (res = fetch(database)) {
    if (liText!=null) {
        print ("
" + liText + "
");
    }
    liText=res.col['data'];
}

if (liText!=null) {
    print ("
" + liText + "
");
}
print "
";

Move the adding of the last line out of the while and apply desired style there


Q:

Error when push into gitlab

in this case I have installed a turnkey linux with gitlab. I´ve setted a static ip.
When I push a file it goes ok, but when I push all my symfony project it return an error
$ git push
Counting objects: 7854, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7449/7449), done.
Writing objects: 100% (7854/7854), 6.45 MiB | 2.08 MiB/s, done.
Total 7854 (delta 2669), reused 0 (delta 0)
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date

What I tried:

Modify the gitlab.yml inside /home/git/gitlab/config change the git max-size to 20971520 (20 mb)
Changed the postBuffer: git config --global http.postBuffer 524288000
also made different commits with a small portion of file, that works but not at all

A:

Another way to make it work as HTTP is to change the the config file og NGINX. The client_max_body_size default is 1M. So inside file /etc/nginx/nginx.conf add something like
http {
    client_max_body_size 100M;
}

By this way you can push through HTTP up to 100 mb


Q:

Bootstrap 3 issues with CSS background in header navbar

Here is my jsFiddle. As you can see, I am using Twitter Bootstrap 3 to create a simple 'header' nav menu.
There are two problems with this:

For the logo, I'm trying to use a CSS background instead of an  tag, and its either not rendering, or the box/window for the background is too small to display the actual logo; and
The nav menu is too "tall"; meaning I want it to be shorter and "hug" the menu links more closely. You'll notice there's a considerable amount of gray underneath all the links and that the 'Sign in' link needs to be horizontally aligned with the green 'Sign up' button

Per the logo issue, you'll notice that I'm trying to make the width bigger (50%), but the browser does not seem to be responding. It's also worth mentioning that /images/mylogo.png is a valid URL and that when I use an  tag instead of the /CSS background, the logo displays just fine.
Per the nav menu height issue, I suspect it may have something to do with this part:

    ...

But I can't tell for sure. Anybody see where I'm going awry?

A:

use this:

      WebSiteName

Home

Page 1

Page 2

Page 3

and then write this css in other file and attach to your html file
.header-height {
    height: 30px;
}

.navbar-brand {
    background: url(...);
    background-size: 50%;
    padding: ??; /* padding for vertical align */
}


Q:

Sum of digits of squares of a number and its reverse

I have observed the following:

Let $ab$ be a two digit number where $a$ and $b$ represent digits, and $ba$ be a two digit number with its digits in reverse order as $ab$. If the sum of the digits of $(ab)^2$ be $S_n$ and that of $(ba)^2$ be $S_r$, then
  $|{S_n-S_r}|=9n$ where $n=0 \: or\: 1 \: or \: 2$

In short, the difference of the sums of the digits is zero or a multiple of nine.
Example: $27^2=729 \\
72^2=5184\\
\text{Here,} \: (7+2+9)-(5+1+8+4)=0\\
\text{But here,} \: 46^2=2116\\
64^2=4096\\
\text{and} \: (4+0+9+6)-(2+1+1+6)=9$
Why is this happening? Is this true for any number?
I've checked for every two digit number, and it works.

A:

Recall that for any positive integer $x$ we have $x\equiv S(x)\;(\text{mod}\;9)$, where $S(x)$ denotes the sum of the decimal digits of $x$.

Allowing leading zero digits, let $x$ be an $n$-digit number and let $y$ be its reversal (i.e., the digits of $y$ are the same as those of $x$, but in reverse order).
\begin{align*}
\text{Then}\;\;&S(x)=S(y)\\[4pt]
\implies\;&S(x)\equiv S(y)\;(\text{mod}\;9)\\[4pt]
\implies\;&x\equiv y\;(\text{mod}\;9)\\[4pt]
\implies\;&x^2\equiv y^2\;(\text{mod}\;9)\\[4pt]
\implies\;&S(x^2)\equiv S(y^2)\;(\text{mod}\;9)\\[4pt]
\end{align*}


Q:

Cortar pixels da imagem sem distorce-la

Bom dia!
Eu quero cortar os lados de uma foto sem distorcer a mesma, é possível?
Por exemplo, tenho essa imagem aqui:

Ela tem 1200x1200
Eu queria tirar, vamos supor, 400px dos lados (200 de cada lado), ou sejam, quero que ela fique 800 x 1200
Mas, não quero distorcer imagem nem diminuir, quero manter a mesma coisa so que sem 200px de cada lado. Isso é possível?
Ilustração:

.imagem
{
    width: 400px;
    height: 400px;
    background: red;
    border: 2px solid;
    display: flex;
    justify-content: center;
    align-items: center;
}
.imagem-menor
{
    background: #95d6e0;
    width: 300px;
    height: 400px;
}

No caso, a parte vermelha é a que eu quero tirar, a do meio deixar, mas sem distorcer nada.

A:

Opção 1
Sim é possível vc pode usar a imagem como um background de uma div que tenha o tamanho que vc quer. Com o estilo background-position vc define a posição do seu background dentro da div no caso está centralizado na horizontal e vertical para deixar a mulher no meio e cortar as laterias igualmente
Veja o exemplo. fiz como vc sugeriu, 800x1200

.imagem {
    background-image: url(https://i.stack.imgur.com/4oeoT.jpg);
    background-position: center;
    background-size: cover;
    width: 800px;
    height: 1200px;
}

Opção 2
Outra opção seria colocar o estilo object-fit: cover na imagem, assim ela se comporta como um background dentro do tamanho que vc definir na tag img Mas isso não é totalmente crossbrowser consulte aqui para ver o suporte https://caniuse.com/#feat=object-fit (no IE não funciona)
Veja o exemplo para entender melhor.

.imagem {
    width: 800px;
    height: 1200px;
    object-fit: cover;
}

Opção 3
Vc pode colocar a imagem dentro de uma div com overflow:hidden e usar transform:translateX para ajusta-la dentro do container na posição desejada.
Veja o exemplo. Aqui eu diminui o tamanho proporcionalmente para vc ver que não deforma. Deixei uns comments no código leia.

.imagem {
    width: 400px;
    height: 600px;
    overflow: hidden; /* esconde as laterais sobrando da imagem */
}
.imagem img {
    transform: translateX(-14%); /* ajusta a imagem na horizontal na posição que vc quiser*/
    height: 100%; /* deixa a imagem sempre com a altura correta */
}

DICA: Apesar de vc não ver o que foi "cortado" essas laterais que estão escondidas fazem parte do arquivo da imagem, então o peso da imagem permanece o mesmo, e na hora da requisição o tamanho do arquivo continuará o mesmo. Considere tratar essas imagens antes de usa-las no site...


Q:

How to add a new command line option to symfony console

I am not an expert in Symfony, I need to add a new console option --country=XX to the symfony console.
This isnt a command, its an option which changes how whatever command is run, executes by selecting a different database to operate on by building the doctrine.dbal.dbname parameter such as api_fr, api_de, api_es, etc.
I have tried to search for a way to do this, but unfortunately everything comes back to adding commands, which is not what I want to do, I want to add an option.
I am building an API which part of it works with Symfony 2.8 and another part is using Symfony 3.x. I suppose the answer might be the same in both versions, but if you know how to do this in both versions and they are separate, please let me know.

A:

You can add an EventListener like this exemple:
use Symfony\Component\Console\Input\InputOption;

class YourOptionEventListener
{
    public function onConsoleCommand(ConsoleCommandEvent $event)
    {
        $inputDefinition = $event->getCommand()->getApplication()->getDefinition();

        // add the option to the application's input definition
        $inputDefinition->addOption(
            new InputOption('yourOption', null, InputOption::VALUE_OPTIONAL, 'Description of the option', null)
        );
    }
}

Then add it as a service:
<?xml version="1.0" ?>
<container ...>
    <services>
        <service id="app_yourOption.console_event_listener"
                 class="App\YourOptionBundle\EventListener\YourOptionEventListener">
            <tag name="kernel.event_listener" event="console.command" method="onConsoleCommand" />
        </service>
    </services>
</container>

You can check this documentation, in "Add a global command option" chapter, you can find what you need:
http://php-and-symfony.matthiasnoback.nl/2013/11/symfony2-add-a-global-option-to-console-commands-and-generate-pid-file/


Q:

Using clustered vs non-clustered index on large data in SQL

Given the following SQL Server table:

Employee (ssn, name, dept, manager, salary)

where ssn is the primary key.
Suppose there are 30 employee records per disk block. Each employee belongs to one of the departments. Explain why you should or shouldn't  put a non-clustering index on dept to speed up this query in the following two cases:
SELECT ssn
FROM Employee
WHERE dept = 'IT'

when there are 50 departments
when there are 5000 departments

My basic understanding of clustered vs. non-clustered indexes in SQL Server is that clustered indexes should be used when there is a large amount of data to be returned, as they will initially sort the table by that index. Therefore, I believe that in the second scenario, with 5000 departments, you should not put a non-clustering index on dept to speed up the query.
I am confused about the first scenario because, as there are only 50 departments, does it really matter if a non-clustering or clustering index is used? The only reason I can think it might matter is if a clustering index takes extra time to first sort the data, while a non-clustering index does not.
Which clustering or non-clustering index should I use in these two cases?

A:

Which clustering or non-clustering index should I use in these two
  cases?

With SSN as the primary key clustered index, a non-clustered index on dept will cover the query and be the most efficient regardless of the number of rows returned. Remember that the clustered index key (the primary key here) is implicitly included in non-clustered index leaf nodes as the row locator. This will avoid the need to access the separate data pages containing columns not needed by the query.
The execution plan should show only an index seek using the dept non-clustered index, touching only the data needed by the query.


Q:

IOServiceGetMatchingServices returning empty iterator in OSX 10.11 El Capitan

I have a small program to find out the Vendor ID and Product ID of all the USB CDC devices connected to Mac. The program uses the IOServiceNameMatching and IOServiceGetMatchingServices to get the matching dictionary and service iterator respectively as shown in the code snippet below:
matchingDictionary = IOServiceNameMatching("AppleUSBCDC");
IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDictionary, &serviceIterator);

I then iterate through serviceIterator to enumerate and extract the IDs of all the connected USB CDC devices. This used to perfectly work fine until OSX 10.10 but the IOServiceGetMatchingServices is returning empty iterator in OSX 10.11. Why is it returning empty iterator only on OSX 10.11 even though the USB CDC devices are connected? Is there an alternate way to get the device list in OSX 10.11?

A:

El Capitan changed the underlying names/architecture of the USB stack, I assume the service name is now different but I don't have a USB CDC device handy to check.
Use IORegistryExplorer (included with the Hardware IO Tools) to look at the device nubs you want to match against, and see what properties they have (and what you can try to search for with IOServiceNameMatching or IOServiceMatching).


Q:

How to make a system monitoring in ubuntu-touch?

I want to know a bit of system status in ubuntu-touch for cpu/ memory usage, but I don't know how to get something like the "system monitor" in ubuntu desktop. Is there any tool/ app for this?

A:

I don't really have an overview of apps, but if you install a terminal, you can use any of the text-based ones available in any Ubuntu system, such as top or htop. They don't have fancy graphics, but they do provide great information.


Q:

Functional testing conditionals with Intern/Leadfoot

I am wishing to conditionally execute some commands/assertions depending on whether previous assertions succeeded or not.
I can't seem to find a way to nest then calls or conditionally execute things using the chaining syntax of leadfoot.
Here is my test (the returns at the end of each function is due to this being compiled coffeescript):
tdd.test(tableUrl, function() {
    this.timeout = 60000;
    return this.remote.get(require.toUrl("tests/pages/" + tableUrl))
    .setPageLoadTimeout(60000)
    .setFindTimeout(20000)
    .findByCssSelector('.dataTables_wrapper table.dataTable')
    .then(null, function(err) {
      return assert.fail('', '', 'Table should exist');
    }).then(pollUntil(function() {
      var table;
      table = document.querySelector('.dataTables_wrapper table.dataTable');
      if (table.querySelectorAll('tbody td').length > 1) {
        return true;
      } else {
        return null;
      }
    }, null, 20000, 500)).then(function() {
      console.log('Assertion succeeded: Table should have data');
      return assert.ok(true, 'Table should have data');
    }, function(err) {
      return assert.fail('', '', 'Table should have data');
    });
  });

When a table does not exist, both 'Table should exist' and 'Table should have data' assertions should be reported as failing. However, only the last assertion is failing. When I comment out the 'Table should have data' error callback, the 'Table should exist' assertion is reported as failing correctly.
What I would like to do is

test if a table exists (via findByCssSelector).
a) If it exists, report that it exists and test to see that it has more than one td element. This is currently done via pollUntil to ensure that the command is complete/promise is resolved as soon as more than one td is found instead of waiting for the whole implicit wait time.
b) If it does not exist, report that it does not exist.

I can't seem to find a way of not executing the error callback of the second 'Table should have data' poll if the first findByCssSelector fails, due to lack of conditionals and only the last assertion failure being reported in a test.

A:

So conditional branching can happen with then calls, this answer addresses how to do conditional branching with intern.
The problem I was having was the pollUntil function not behaving the same way as a normal leadfoot Command method due to the function returning a callback function that returns a promise rather than a promise directly.
This can be circumvented by wrapping the pollUntil in an anonymous function, immediately calling the pollUntil function using the call method, passing in the current this value due to then setting the context of the callback to the Command object, and then finally chaining another Command.
This is what the above code turned into using correct conditional branching with pollUntil.
tdd.test(tableUrl, function() {
  this.timeout = 60000;
  return this.remote.get(require.toUrl("tests/pages/" + tableUrl))
  .setPageLoadTimeout(60000)
  .setFindTimeout(5000)
  .findByCssSelector('.dataTables_wrapper table.dataTable')
  .then((function() {
    return pollUntil(function() {
      var table;
      table = document.querySelector('.dataTables_wrapper table.dataTable');
      if (table.querySelectorAll('tbody td').length > 1) {
        return true;
      } else {
        return null;
      }
    }, null, 20000, 500).call(this).then(function() {
      console.log('Assertion succeeded: Table should have data');
      return assert.ok(true, 'Table should have data');
    }, function(err) {
      return assert.fail('', '', 'Table should have data');
    });
  }), function(err) {
    return assert.fail('', '', "Table should exist. Error: " + err.name);
  });
});


Q:

How can I debug a docker container initialization?

I had an issue with a container, even though it builds perfectly it does not properly start. The cause is a workaround I've added to the Dockerfile (for having a self-configured /etc/hosts routing)
RUN mkdir -p -- /lib-override /etc-override && cp /lib/libnss_files.so.2 /lib-override
ADD hosts.template /etc-override/hosts
RUN perl -pi -e 's:/etc/hosts:/etc-override/hosts:g' /lib-override/libnss_files.so.2
ENV LD_LIBRARY_PATH /lib-override

Obviously there's some error in there, but I wonder how can I get more info on what docker is doing while running. for example, this works:
$ docker run image ls
usr bin ...

But this doesn't:
$ docker run image ls -l
$

There is nothing in the logs and I can't call an interactive shell either. I can use strace to see what's happening but I was hoping theres a better way.
Is there any way I can set docker to be more verbose?
EDIT: Thanks to Andrew D. I now know what's wrong with the code above (I left it so his answer can be understood). Now the issue is still how might I debug something like this or get some insides at why ls -l failed why ls did not.
EDIT: The -D=true might give more output, though not in my case...

A:

Docker events command may help and Docker logs command can fetch logs even after the image failed to start.
First start docker events in the background to see whats going on.
docker events&

Then run your failing docker run ... command.
Then you should see something like the following on screen:
2015-12-22T15:13:05.503402713+02:00 xxxxxxxacd8ca86df9eac5fd5466884c0b42a06293ccff0b5101b5987f5da07d: (from xxx/xxx:latest) die

Then you can get the startup hex id from previous message or the output of the run command. Then you can use it with the logs command:
docker logs <copy the instance id from docker events messages on screen>

You should now see some output from the failed image startup.
As @alexkb suggested in a comment: docker events& can be troublesome if your container is being constantly restarted from something like AWS ECS service. In this scenario it may be easier to get the container hex id out of the logs in /var/log/ecs/ecs-agent.log.<DATE>. Then use docker logs <hex id>.

A:

Well the best I have found out so far is:
#stop the current demon and start it in debug modus
sudo service docker stop
dockerd -D # --debug

The just start the client from a new shell. The misconception was to think the client actually does anything at all... well it's just communicating with the daemon, so you don't want to debug the client but the daemon itself (normally).

A:

In my case, the -a (attach to STDOUT/STDERR) flag was enough:
user@machine:~$ docker start -a server_name
Error: The directory named as part of the path /log/log_path/app.log does not exist.
For help, use /usr/bin/supervisord -h

It showed the startup error (in our case, a missing log path used by supervisord).  I assume most container startup errors would show up here as well.


Q:

Can JCheckBox components be added to JComboBoxes?

Can JCheckBox components be added to JComboBoxes?  If so, how?

A:

There are ways to jimmy JCheckBoxes into a JComboBoxes, but it's not nearly as straightforward as using them in a JTable since JComboBoxes don't use cell editors, only renderers.  Let's see if I can re-find this on Google....
Please check here: JComboCheckBox
and here: Check Boxes in a Combobox


Q:

Data structure with at least O(ln N) on random access and at least O(ln N) on delete [NOT DUPLICATE]

There is no standard container which gives such guarantees out from the box, some additional manipulation are required (for instance, like Jerry Coffin suggested), it is NOT duplicate.

Are there any ready data structure/container with at least O(ln N) on random access and O(ln N) on delete? (stl/boost/etc)
Ordering of elements within container is not important.
Such operations may happen in series, like:

random access by index ( index is random too, rand()%size() )
delete this item
random access by index ( index is random too, rand()%size() )
delete this item

etc...

A:

Since you say ordering doesn't matter, you can do both in constant time using a vector.
Random access is (obviously) constant time.
Deletion in constant time can be done by swapping the element to delete with the last element, then deleting the last element.


Q:

Dialog box positive / negative buttons in different position depending on android version

I've been writing an new app for our company and came across an odd thing. On the test device (running 2.3.x) the alert dialog buttons will always be in the order of:
POSITIVE | NEGATIVE
Yet, when I tested the app on my personal cell (running 4.x) the alert dialog buttons were switched to:
NEGATIVE | POSITIVE
The code is obviously the same.
I don't really want to make different versions. But I could cater for later versions in code, and maybe (although its rubbish) swap the text of the positive and negative buttons... Which would work, I'm guessing, but it's a bit horrible!
The only problem I can foresee, is that our end-users aren't that tech-savvy and having multiple devices, using differing versions of the OS, could cause issues (which I could easily cater for, but would rather some kind of 'standard').
Is this something I can get around? Or is it best to leave as is and let the OS handle it (as I am doing now)? Also, are there any other small issues I'm going to run into. I.e. Can I guarantee that on 4+ devices that if I'm only using 2 buttons that they will remain in the above order.
What I'm hoping someone will post is a hidden flag that magically sets 4.x alert dialogs to 2.x style :) I'm pushing my luck, I know!
Cheers. Any help is greatly appreciated.

A:

It's an interesting piece of lunacy from Google (see issue 24138) but, as of ICS, this is how it's supposed to be. Definitely best to let the OS choose the ordering.


Q:

how to play radio through Loud Speaker in wp7

I implemented Radio in my Windows Phone7 Application using Below specified code,Now I want to give additional option to play through Loud speaker,
How can I full fill this option Any idea? is it possible?
FMRadio.Instance.CurrentRegion = RadioRegion.UnitedStates;
FMRadio.Instance.PowerMode = RadioPowerMode.On;
FMRadio.Instance.Frequency =101.5 ;

if (FMRadio.Instance.SignalStrength == 0.0)
{
   MessageBox.Show("Please connect your phone to the headset.");
}
}
catch (Exception ex)
{
   MessageBox.Show("Error Message:-> " + ex.Message + "FM Radio is not connected");
}

A:

It's not possible as there is nothing in FMRadio API that would allow you to do this.
The built-in Radio (accessible in the Music+Videos hub) does have this ability if you tap+hold the station number, but it's simply not available to developers.
It's also worth noting that WP8 devices don't have the radio enabled, but that may change in the future.


Q:

How do I run a shell command using the current selection as arguments?

An example:
A visual selection of:
 echo -e "hello
 \bworld"

followed by :w !bash prints:
hello
world

How can I get the same result if my starting point is:
hello
\bworld

More details:

I would like to pass a visual selection to a command that looks like this:
some_command -some_flag "selection_from_vim"

The visual selection from vim should be placed inside quotes in the command line command.
Like in the example, I would like to be able to select several lines.

A:

There's a shell solution for your issue and a Vim solution to it.
Shell solution
The shell solution to your issue is to have the shell read the contents (two lines with hello and \bworld) from standard input, then assemble the echo -e ... command and execute it.
You can do so using the shell's eval command, to reinterpret the assembled string as a shell command. You can use $(cat) to capture the standard input as a string in the command to be evaluated.
:w !eval 'echo -e "'"$(cat)"'"'

Note that this is a concatenation of three strings, first being echo -e ", including the opening double quote and the last being a single double quote. The middle one "$(cat)" is itself inside double quotes in order to preserve spaces and newlines (that's before eval has a run on it.) Note that this solution is fragile, as if your input has any "s in it, it will potentially break the command. But it's the closest one to your original example and to what you specified.
Vim solution
A solution within Vim is to use the :! command instead and assemble the shell command, in this case echo, inside Vim itself.
You can use :execute to run the command from a Vim string, and shellescape() to quote the argument to echo. Note that in this case you'll need to pass a non-zero second argument to shellescape(), so it escapes the newlines with a backslash, which makes it work correctly with :!.
First yank the visual selection into the default register with a y command.
Then execute the external command with:
:execute '! echo -e '.shellescape(@", 1)

(Here @" is the default register.)
This solution is quite robust to characters in the input, since shellescape() is doing the job of escaping special characters and quoting the string. (Note how we don't have any "s or 's that are passed to the shell, those are only Vim strings here.)
There's a small difference in how Vim runs :w !{cmd} and :!{cmd} here, in that with the former it doesn't clear the screen (switch back from the alternate screen) but does so with the latter.
One hacky workaround is to still use :w !{cmd} for the second case, perhaps with a small range of the current line. It will pass the external command that line as standard input, but as long as the command doesn't use the standard input, that shouldn't make a difference.
:execute '.w !echo -e '.shellescape(@", 1)


Q:

What is the difference between ::: and :::.() in scala

In the scala list class it is shown that:
List(1, 2) ::: List(3, 4) = List(3, 4).:::(List(1, 2)) = List(1, 2, 3, 4).
Shouldn't:
List(1,2) ::: List(3,4) = List(1,2).:::(List(3,4)) = List(3,4,1,2)
( method ::: prefixes the list)

A:

From the docs:
def :::(prefix: List[A]): List[A]

[use case]
Adds the elements of a given list in front of this list.
Example:
List(1, 2) ::: List(3, 4) = List(3, 4).:::(List(1, 2)) = List(1, 2, 3, 4)

In Scala, operators that end in : are right associative and the invoking object appears on the right side of the operator. Because it is right associative, the prefix method will be called on the object "to the right", which is List(3, 4).
Then it will do what its name says, it will prefix List(3, 4) with List(1, 2), and that's why you get List(1, 2, 3 ,4). Not the most intuitive thing in the world but it's like this:
a ::: b
// ending in :, so flip the argument order, call the method on b.
b .:: a // :: = prefix b with a
result = a(concatenated) with b

Now let's look at the right hand side:
List(3, 4).:::(List(1, 2))

The . dot is performing an inversion of the ::: prefixed invocation, so it will simply invert the two List objects before performing the ::: prefix operation.
List(3, 4).:::(List(1,2)) = List(1, 2) ::: List(3, 4) // exactly as the above.
// and now you it's the same story.

The . dot is a simply way to invert associative operators. a ::: b is the same as b .::: a


Q:

Converting data bind values to strings inside foreach knockout

I have this fiddle. All I want to do is , convert the values nested in each object literal to a string.

 function AppViewModel()
{
    var self = this;
    self.people = ko.observableArray([{"Name":"RobbStark",Id:1}, {"Name":"JohnSnow",Id:2}]);
}

ko.applyBindings(new AppViewModel());

I want to use a lookup
like
var valueMap={
    1:"SanJose",
    2:"San Francisco"
}

To get output like
RobbStark SanJose
JohnSnow San Francisco.

How do I convert the observable to a different value inside foreach ?

A:

All you have to do is call a javascript function from your text data-binding, passing in the current item ($data) from the for each loop as a parameter.  Example fiddle
Javascript:
var valueMap={
    1:"SanJose",
    2:"San Francisco"
}

 function AppViewModel()
{
    var self = this;

    self.people = ko.observableArray([{"Name":"RobbStark",Id:1}, {"Name":"JohnSnow",Id:2}]);
    self.parsedName = function (item) {
        return item.Name + " " + valueMap[item.Id];
    };
}

ko.applyBindings(new AppViewModel());

HTML

Note #1 under the KnockoutJS documentation contains more information about $data.


Q:

How to draw part of a large BufferedImage?

I have a 10000x10000 BufferedImage and I'm looking to draw only part of it to a Canvas, is there a way to do this using args such as:
x, y, width, height ?
So for example, drawImage(img, x, y, width, height) would draw a rectangle from the image starting at (x, y) and having (width, height) as the dimensions?
EDIT:
I'm going to re- word this question:
I have a 10000x10000 image and I only want to display a portion of it on the screen, the problem with just  offsetting it by x and y is that this still causes lag as the entire image is being rendered, just most of it off canvas. How can I basically make it so that the entire image is rendered but I can scroll around it without causing the canvas to lag?

A:

I have a 10000x10000 BufferedImage and I'm looking to draw only part
  of it to a Canvas, is there a way to do this using args such as:

Don't use canvas for custom painting in java. use JComponent or JPanel instead. It has a nice function paintComponent(Graphics g), override it and paint your image inside with g.drawImage(x, y, width, height, observer);
Swing graphics has Graphics.clipRect(int x, int y, int width, int height) to bound the area rectangle to which you wish to draw prior to drawing the image.

Edit (In response to your edited question):
First approach is to use BufferedImage..getSubimage(x, y, width, height) to get a sub image with specified rectangle region. It is faster.
    BufferedImage img = ImageIO.read(new File("file"));
    img = img.getSubimage(50, 50, 500, 500); // 500 x 500

This function will give you a new image cropped with the rectangle(x, y, width, height) of your original image you specified. Use the returned image to draw on your component.
Tutorial resource: Clipping the Drawing Region

Demo: Demonstrating clipping Image with Animation:

import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import java.util.*;
import java.util.logging.*;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.Timer;

class MyCanvas extends JPanel implements ActionListener
{
  public BufferedImage buffImg;
  public Rectangle rectangle;
  Random random;
  long lastTimeChanged;
  int dirX = 1, dirY = 1;
  volatile static boolean imageLoading = true;
    public MyCanvas() {
        random = new Random();
        rectangle = new Rectangle(50, 50, 250, 250);
        lastTimeChanged = System.currentTimeMillis();
        setBackground(Color.WHITE);
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);

        if(imageLoading)
        {
            showWaitForLoading(g);
            return;
        }

        g.clipRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
        g.drawImage(buffImg, 0, 0, getWidth(), getHeight(), this);

    }

    public void showWaitForLoading(Graphics g)
    {
        Graphics2D g2d = (Graphics2D)g.create();
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setColor(Color.DARK_GRAY);
        g2d.fillRoundRect(getWidth()/2-100, getHeight()/2-15, 200, 30, 30, 30);
        g2d.setColor(Color.WHITE);
        g2d.drawString("Loading image...", getWidth()/2 - 45, getHeight()/2 + 3 );
        g2d.dispose();
    }

    @Override
    public void actionPerformed(ActionEvent e) {

        long endTime = System.currentTimeMillis();
        if(endTime - lastTimeChanged > 500)
        {
            dirX = random.nextInt(2) == 0 ? -1 : 1;
            dirY = random.nextInt(2) == 0 ? -1 : 1;
            lastTimeChanged = endTime;
        }

        if(rectangle.x < 0)dirX = 1;
        else if(rectangle.x + rectangle.width > getWidth())dirX = -1;

        if(rectangle.y < 0)dirY = 1;
        else if(rectangle.y + rectangle.height > getHeight())dirY = -1;

        rectangle.x = rectangle.x + dirX * 10;
        rectangle.y = rectangle.y + dirY * 10;;

        repaint();
    }

}
public class CustomPainting {

    public static void main(String[] args) throws IOException {

        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
               final MyCanvas canvas = new MyCanvas();
               JFrame frame = new JFrame();
              frame.setSize(new Dimension(500, 500));
              frame.add(canvas);
              frame.setVisible(true);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

              Timer timer = new Timer(200, canvas);
              timer.start();
              new Thread()
              {
                  public void run()
                  {
                      try {
                          canvas.buffImg = ImageIO.read(new URL("http://images6.fanpop.com/image/photos/33400000/Cute-Panda-beautiful-pictures-33434826-500-500.jpg"));
                          MyCanvas.imageLoading = false;
                      } catch (IOException ex) {
                          Logger.getLogger(CustomPainting.class.getName()).log(Level.SEVERE, null, ex);
                      }
                  }
              }.start();
            }
        });
    }
}


Q:

jQuery: how to select the text in a text input

I'm trying to create a button linked to a text field that will let me select all the text in a textarea so the user can copy it to the clipboard.  I've tried this:
$('#selectCode').click(function() {
     var input = $('#MyTextBox');
     input.focus();
     input.select();
});

based on several examples I found online where you focus on the input and then select it.  But this doesn't seem to work in jQuery -- at least the way I'm doing it.  Can someone help?

A:

$(function(){
   $("#selectCode").click(function(){
     $("#MyTextBox").select();

   });
});

Here is the working demo : http://jsfiddle.net/vqGM4/3/


Q:

Could it be possible to launch a rocket from a balloon?

There are several (commercial) organisations looking into alternative means to launch space-bound rockets. One commonly proposed method is to use a large airplane as the launch platform. This method should, theoretically, reduce the cost of sending rockets into space.
Weather balloons can reach an altitude of 20 KM, or more. Could a balloon be used as a launch platform for space-bound rockets? I imagine skipping the first 20km of flight could significantly defray the cost of a launch.

A:

There are good reasons why balloons have not been used for launch systems.

Fragility of the balloons
The highly energetic nature of rocket launches
Limited control over balloon trajectory
Expense of Helium
Flammability of Hydrogen.

Balloons are inherently fragile. You have to have very thin, very light materials to make an effective high altitude balloon system. Baumgartener launched in a ballon that was 550 feet (168 metre) tall at launch, with 30 million cubic feet (850,000 m³) of helium at STP, to carry about 3150 pounds (1430 kg) of payload. The balloon itself could be easily punctured by a person intent on pushing a finger through it.
For comparison, the Falcon 9 launch mass is about 735,000 pounds (333,000 kg) - about 233 times the weight, before accounting for it's up to 14,000 pound (6350 kg) payload capacity. Plus, since the balloons are so fragile, one would need to use at least three and a gondola system that keeps them well separated, and so one is looking at about 7.2 billion (7.2e9) cubic feet (204 million m³) of lift helium to save on about 10% of launch fuel.
Helium isn't cheap. At 84 dollars per 1000 cubic feet (\$ 2.97/m³), that's \$6.048e8 (just over half a billion dollars) just in helium. The cost savings is not present for large launchers.
Hydrogen, a better lift gas, can be manufactured, but is still going to be about 4 billion cubic feet (113 million m³). But, if it catches fire, it will be a major flame issue. This will then drop any gondola and structure.
Keep in mind that a rocket launch produces up to a half-kilometer long plume of highly energetic gasses. Even tho' combustion has ended, those gasses may still be hot enough to damage the fragile balloon envelope. If that envelope is ignited, the balloon suffers a sudden (and probably catastrophic) loss of lift; if it's filled with hydrogen, it is almost guaranteed to suffer a catastrophic loss of lift.
A Balloon light enough to launch a significant payload will experience a sudden and massive lift as the rocket clears it. Provided that the envelope isn't compromised, loss of 95% of the mass will result in sudden and rapid ascent; not as fast as the rocket, but fast enough that recovery will be an issue. The lack of trajectory control also means having to carefully monitor airflow aloft. In order to recover, either the balloon must be able to compress the envelope, vent the envelope, or detach from the envelope; any of these options adds mass, and two of them render the lift gas a loss. Given the low-thicknesses needed to get efficient lift, compression is unlikely. Therefore most of the lift gas will be unrecoverable.
In the long run, it's simply too expensive and risky to use balloons to overcome the initial liftoff.

http://www.redbullstratos.com/technology/high-altitude-balloon/
http://en.wikipedia.org/wiki/Falcon_9
http://www.weldingandgasestoday.org/index.php/2012/04/a-look-at-rising-helium-prices/

A:

In order to stay within the scope of this question, I will reference one idea that I believe fits the criteria, although that might be disputable.
I'll call the idea balloon-tether LAS, and it was published in a journal paper in 2012.  The reason this idea is notable is that it started from a study of previously proposed LAS (Launch Assistance Systems), and formalized the requirements for a realistic system.  Because of this, I would say it's one of the "most possible" proposals.
Description
High altitude balloons would suspend large pulleys that are basically pulled by trains.  The system would be at a remote location and high altitude.  The value of the LAS itself is that it:

Increases altitude of the rocket
Gives the rocket some initial vertical speed (order of 1 km/s)

From the release point on, the rocket fires and attains orbit for a payload of around 7 kg.  This all sounds a little trite.  After all, it only accelerates the rocket to a fraction of orbital velocity, to an altitude only a fraction of LEO altitude, the payload is paltry, and the launch rate is only once per day.  But this is rocket science, by the rocket equation, these reductions make a bigger difference than you would think.
Here's a picture, with the pink being the balloons, the blue is the rocket, and brown is the tether.

Feasibility
Clearly you can launch something to orbit from balloons, but if there's no economic case for doing it, it won't ever happen.  The balloon-tether LAS shows mastery of a couple of the issues that will come with the territory.  Mainly, there is a problem that balloons are very limited in their lifting capacity.  For more lift you need a larger balloon, and you quickly start to push the limit of what's possible.  That puts a lot of downward pressure on the payload sizes.
Because of that size constraint, it's unlikely that any balloon system could compete with heavy lifting capacity or for manned flights.  Even for micro-satellites, you can't justify the production chain cost because the launch frequency demand isn't high enough.  That's why the balloon-tether LAS proposes a propellant depot model.
There are still some dubious parts to this proposal.  There are a couple of fields where exploratory engineering has been proposed using high-altitude tethered balloons.  Notably, solar energy, wind energy, and communication balloons.  There have been some historical precedents for tethered balloons flying at around 3 km.  Military technology bumps up on 7 km or so.  To get to the desirable weatherless regions you'll have to go much further, and we're also talking about using really large balloons.  There's still the option of not tethering the balloon, and just flying it up and launching a rocket.  But where's the re-usability in that?  That makes it a difficult equation to make a competitive launch system, although, that depends on the technology status for high altitude tethered systems.

A:

You probably could, but it wouldn't help very much.

The reason it's hard to get to orbit isn't that space is high up.
It's hard to get to orbit because you have to go so fast.

from XKCD What If? #58


Q:

Rails 4:How to make users view only files in their own office

I am creating a file tracking system whereby users can track the movement from one office to another. I've gotten most of the application to work but presently every user can view all files regardless of where it's in their office, or not because in the file index.
I am using File.all in my file index action. Is there a way I can have a user only view and track files that is only currently in their own office, while the registry officer(admin) can view and track all files?
My relationships between models:
File model
class Nasfile < ActiveRecord::Base
  belongs_to :category
  has_many :trackers, dependent: :destroy

  before_save :file_full_number, :on => [:create, :update]
    def file_full_number
        if self.file_sub.present?
            self.file_number = [self.file_number , self.file_sub].join('/')
        else
            self.file_number = self.file_number
        end
    end
end

Office Model
class Office < ActiveRecord::Base
  belongs_to :department

  has_many :users
  has_many :received_files,:class_name => 'Tracker', :foreign_key => 'office_sent_to_id'
  has_many :sent_files,:class_name => 'Tracker', :foreign_key => 'office_sent_from_id'

  def self.all_without(excluded)
    where("id NOT IN (?)", excluded)
  end
end

Tracker Model
class Tracker < ActiveRecord::Base
  belongs_to :nasfile

  belongs_to :sender, :foreign_key => :sender_id, class_name: 'User'
  belongs_to :receiver, :foreign_key => :receiver_id, class_name: 'User'
  belongs_to :office_receiving, :foreign_key => :office_sent_to_id, class_name: 'Office'
  belongs_to :office_sending, :foreign_key => :office_sent_from_id, class_name: 'Office'

  before_save :office_sent_to, :on => [:create, :update]

    def office_sent_to
        self.office_sent_to_id = self.receiver.office.id
    end

end

User model:
class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable,:recoverable
  devise :database_authenticatable, :registerable,
         :rememberable, :trackable, :validatable,
         :authentication_keys => [:username], password_length: 6..25

  belongs_to :office
  accepts_nested_attributes_for :office

  has_many :sent_files,:class_name => 'Tracker', :foreign_key => 'sender_id'
  has_many :received_files,:class_name => 'Tracker', :foreign_key => 'receiver_id'

  def email_required?
    false
  end

  def email_changed?
    false
  end

  def self.all_without(excluded)
    where("id NOT IN (?)", excluded)
  end

end

Thanks for the help

A:

Rather than doing
@files = File.all

try to filter the files you include by doing something like:
@files = File.where("office_id = ?", current_user.office_id)

This way, you only get files for the office to which the user belongs.
I don't know how you have your roles set up, but you can add some branching logic to allow registry officers to see all files, regardless of office:
if user.role = "registry officer"
  @files = File.all
else
  @files = File.where("office_id = ?", current_user.office_id)
end


Q:

How to make vscode show type info for exported function from another .js file?

Showing type information in vscode for Typescript files is pretty simply via the /// <reference path ... comment. However, I have the case where I use exported functions from one js file in another. The exported functions have been annotated to contain type information. Here's an example (lib/index.js):
/**
 * Put the executing thread to sleep for the given amount of milliseconds.
 * @param {number} milliseconds
 */
exports.sleep = function (milliseconds) {
    var end = new Date().getTime() + milliseconds;
    while (new Date().getTime() < end) { }
}

In my main.js file I do:
var lib = require("lib");
lib.sleep(500);

Unfortunately, vscode does not provide the call signature of that sleep function nor can I use cmd/ctrl+click to navigate to it.
I also created a typings file and referenced that in main.js, which works almost like I want, except that it doesn't take me to the original source, but instead to the typings file when I cmd/ctrl+click on the function name.
Is it possible and how to let vscode recognize exports in other JS files and provide call information and code navigation for them?

A:

Change require path to ./lib
var lib = require("./lib");
lib.sleep(500);


Q:

How can I change the revision number of a repository in Tortoise SVN?

I have a project that has a revision number of 3960. But unfortunately it is not under source control. Now I would like to put it under SVN and use Tortoise SVN. But when I put it there it will have revision from 1,2,3,4 and so on.
Is there a way to change the revision number to 3960?

A:

The safest way I can think of would be to make a dump file with an appropriate number of empty revisions, than load it. The format would be something like:
SVN-fs-dump-format-version: 2

Revision-number: 0
Prop-content-length: 56
Content-length: 56

K 8
svn:date
V 27
2009-01-12T14:58:15.449041Z
PROPS-END

Revision-number: 1
Prop-content-length: 56
Content-length: 56

K 8
svn:date
V 27
2009-01-12T14:58:40.758271Z
PROPS-END

Revision-number: 2
Prop-content-length: 56
Content-length: 56

K 8
svn:date
V 27
2009-01-12T14:58:44.509698Z
PROPS-END

You could omit the svn:date and it would still be a valid svn repository, but queries by {date} wouldn't work (just like they don't in any case where the dates are not monotonically increasing with revision). So it's probably best to fake up a string of plausible dates.
If you want 3960 such revisions, you probably want to write a script to generate the dump file. I leave that as an exercise to the reader :-)

A:

It is possible in theory, but not very useful.
If you need somehow to keep track of this information, you may consider creating a tag '3960', but otherwise leaving the normal revision process taking place.
As said in the manual:

Global Revision Numbers
  Unlike those of many other version control systems, Subversion's revision numbers apply to entire trees, not individual files. Each revision number selects an entire tree, a particular state of the repository after some committed change.
  Another way to think about it is that revision N represents the state of the repository filesystem after the Nth commit. When a Subversion user talks about “revision 5 of foo.c”, they really mean “foo.c as it appears in revision 5.”

A revision number is different than an **application version number" (the version number of your application): the latter is represented by a tag.

A:

First, I don't know a way to do this. If it would be possible, I think you have to use a svn-hookscript.
Second, the revision number in Source Control Systems has nothing to do with the revision (Version) Number of your Program. The Source Control System keeps track of every change you submit and so you may have much more submits than builds of your code.
It may differ every time, if you don't just submit changes with a new build-number and I don't think that you should just check in changes in such huge steps.
For keeping track of your build numbers you should use tags.


Q:

Long word wrap in nested tables

I'm trying to wrap a long word. I have seen this post : How to prevent long words from breaking my div?
It works great in a simple case like this :
.wrapWords
{
    white-space: pre;           /* CSS 2.0 */
    white-space: pre-wrap;      /* CSS 2.1 */
    white-space: pre-line;      /* CSS 3.0 */
    white-space: -pre-wrap;     /* Opera 4-6 */
    white-space: -o-pre-wrap;   /* Opera 7 */
    white-space: -moz-pre-wrap; /* Mozilla */
    white-space: -hp-pre-wrap;  /* HP Printers */
    word-wrap: break-word;      /* IE 5+ */

}

        AAAAAAAAAAAAAAAAAA

But my case has two nested tables like this :

                            BBBBBBBBBBBBBBBBBB

You can test this code here http://jsfiddle.net/ZmnQ6/4/

A:

table is taking the table-layout: auto; by default so as per contents increase the width also increases so you need to set table-layout to fixed.
table{
    table-layout: fixed;
}

demo


Q:

How to append a string into an object 'path' in Javascript?

I have this path in a string: var path = 'bonds.international.emergent' and the object portfolio.
I want to access portfolio.bonds.international.emergent, using the path in the path variable.
Something like portfolio[path], which obviously doesn't work. Anyone knows how to do this?

A:

If it's only dots, you can split:
var path = 'bonds.international.emergent';
var target = portfolio;
path = path.split('.');
for(var i = 0; i < path.length; i++) {
  target = target[path[i]];
}
alert(target); // = portfolio.bonds.international.emergent

Else, you can eval:
var target = eval('portfolio.' + path);

But avoid eval if you can.


Q:

Eigenvalues of block matrix of order $m+1$

How to find eigenvalues of following matrix?
$\begin{bmatrix}
mkI-A & -A & -A & \cdots & -A\\
-A & kI-A & O & \cdots & O\\
-A & O & kI-A & \cdots & O\\
\vdots & \vdots & \vdots & \ddots & \vdots\\
-A & O & O & \cdots & kI-A\\
\end{bmatrix}_{m+1}$
Where,
$A$ is any square matrix of order $n$,
$O$ is zero matrix of order $n$
$I$ is identity matrix of order $n$,
$k \in \mathbb{N}$
As well as one eigenvalue of above matrix is zero.
I think if we can convert above matrix in terms of either Kronecker product or Kronecker sum of two matrices then we can find eigenvalues of above matrix by taking multiplication or addition of two matrices respectively.
The other way is might be if we can convert above matrix in block diagonal matrix then we can find eigenvalues easily.

A:

At first, to summarize this problem, let replace diagonal factor matrices as:
$$
\begin{bmatrix}
X \\
Y
\end{bmatrix}
=
\begin{bmatrix}
\lambda-mk & 1 \\
\lambda-k & 1
\end{bmatrix}
\begin{bmatrix}
I \\
A
\end{bmatrix}
$$
where $\lambda$ is eigenvalue. Therefore, we can suppose the following determinant:
$$
\begin{aligned}
\det
\begin{bmatrix}
X & A & A & \cdots & A & A \\
A & Y & O & \cdots & O & O\\
A & O & Y & \cdots & O & O \\
\vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\
A & O & O & \cdots & Y & O \\
A & O & O & \cdots & O & Y
\end{bmatrix}
\end{aligned}
$$
Calculation determinant has an important property that each rows can be added or reduced from another row. Thus, top row can be subtracted from bottom row to extract the diagonal factor as $\det(Y)$. Then the block matrix becomes smaller from $(m+1)n$ square to $mn$ square:
$$
\begin{aligned}
\det
\begin{bmatrix}
X-AY^{-1}A & A & A & \cdots & A & O \\
A & Y & O & \cdots & O & O\\
A & O & Y & \cdots & O & O \\
\vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\
A & O & O & \cdots & Y & O \\
A & O & O & \cdots & O & Y
\end{bmatrix}
=&
\det
\begin{bmatrix}
X-AY^{-1}A & A & A & \cdots & A \\
A & Y & O & \cdots & O \\
A & O & Y & \cdots & O \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
A & O & O & \cdots & Y
\end{bmatrix}
\det(Y)
\end{aligned}
$$
Likewise, we repeat this operation until the block matrix becomes $n$ orders matrix. Eventually, the below determinant is obtained:
$$
\det(Y)^m\det(X-mAY^{-1}A)
$$
Now, we attempt to factorize the second determinant $\det(X-mAY^{-1}A)$ using this consideration. Then the whole result is shown below:
$$
\det(\lambda I-(kI+A))^{m-1}
\det\biggl(\lambda I-\cfrac{B+\sqrt{C}}{2}\biggr)
\det\biggl(\lambda I-\cfrac{B-\sqrt{C}}{2}\biggr)
$$
where:
$$
\begin{cases}
B=-2A+k(m+1)I \\
\\
C=4mA^2-5k(m+1)A+k^2(1+m)^3I
\end{cases}
$$
In conclusion, this $n(m+1)$ square matrix has $3n$ kinds eigenvalues. However, $C=O$ case is $2n$ kinds exceptionally because of multiple solution.


Q:

How should I maintain the cart to avoid frequent trips to the server?

My project in MVC is an order carting project.
The carting is done with the following structure.
There is an order object which holds:
cOrder -> List<cOrderItem>

cOrderItem-> List<dressing>, List<topping>, List<specialInst>

I am holding it in Session. Is it the right approach to hold it in Session without losing performance. Or should I follow an alternate approach?

A:

I presume what you mean by "trips to the server" you really mean "trips to the DB" because whenever are dealing with the Session you are at the server anyway.
The Session will do the job, however, there are a couple of caveats that might be a problem

Session is not persistent, it's all stored in memory. This means that there is the potential for you to lose the session at any point e.g. app pool recycle.
Given it's not persistent, this means that a users cart is only maintained within a single session i.e. if the users session expires they will effectively lose their cart.

One approach which I have used in the past is to use a client-side cookie to maintain a basket session, this means

It's persistent storage so it's retained across sessions (not just a single session)
Nothing is stored on the server
It's very quick

There are a couple of small caveats with this approach as well

Browsers need to have cookies enabled
Users can clear their cookies (as such, losing their basket)

However, I've found that these issues are very rarely a problem as most people enable cookies in their browser and most users very rarely clear their cookies (and the chances of them doing it during a session is relatively low).


Q:

Find the value of $\mathop{\sum\sum\sum\sum}_{0\leq i \leq j \leq k \leq l\leq n} 1$

Find the value of $$\mathop{\sum\sum\sum\sum}_{0\leq i \leq j \leq k \leq l\leq n} 1$$
I am not sure but perhaps the answer is ${n+5}\choose 5$.
We know that $\displaystyle\mathop{\sum\sum\sum\sum}_{0\leq i < j < k < l\leq n} 1
$ is ${n+1}\choose 4$. Can we do this problem from this fact using the Principle of Inclusion-Exclusion?
Solutions using bijection would be quite elegant as well

A:

This is the number of quadruples $(i,j,k,l)$
with $0\le i\le j\le k\le l$. Let $(i',j',k',l')=(i+1,j+2,k+3,l+4)$.
Then the $(i',j',k',l')$ are the quadruples with
$0<i'<j'<k'<l'\le n+4$. How many of these are there?


Q:

UIScrollView dynamic status bar

I have a scroll view with 2 views in it: a UIImagePicker (Snapchat-style camera view), and a UITableView.
The scroll view is inside of a navigation controller that the main viewController pushes to. I want the status bar and everything on it (time, battery, wifi, etc.) to be hidden on the camera view, but when you scroll to the right to the tableView, the status bar contents show back up, whether they do some kind of cool stretch animation as you scroll (would be awesome to figure that out) or any other solution possible.
Hopefully I worded this well enough for you to understand.

A:

Solution I found (More of a workaround)
declare a boolean called hidden.
Then I overrode these methods:
func scrollViewDidScroll(scrollView: UIScrollView){
    let xOffset = scrollView.contentOffset.x;

    if(xOffset > scrollView.contentSize.width/4)
    {
        if hidden == true {
            print("\nShow status bar\n")

            hidden = false
            UIView.animateWithDuration(0.3, animations: {
                self.setNeedsStatusBarAppearanceUpdate()
            })
        }
    } else
    {
       print("\nHide Status Bar\n")

        hidden = true
        UIView.animateWithDuration(0.2, animations: {
            self.setNeedsStatusBarAppearanceUpdate()
        })
    }
}

override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation {
    if hidden == false {
        return UIStatusBarAnimation.Fade
    } else {
        return UIStatusBarAnimation.Slide
    }
}

override func prefersStatusBarHidden() -> Bool {
    print("\nstatus Bar Changed to hidden = \(hidden)\n")
    return hidden
}

It fades the status bar in once you've at least scrolled half way, and slides the status bar back up once you've gone back half way again.


Q:

How to set parameters for scipy.stats distribution with a list

I am using the package fitter to fit continuous distributions to numpy arrays of data in Python. fitter.fitted_param returns a dictionary of tupples of varying length with the best-fit parameters for each distribution. These are the same parameters used to set these distributions in scipy.stats. I would like to use these tuples to set the parameters directly with scipy.stats, but I do not know how to do so. Any ideas?
Example:
>from fitter import Fitter
>import numpy as np
>data = np.random.random((1000,1))
>f = Fitter(data,distributions = ['norm','gamma'])
>f.fit()
>param = f.fitted_param['gamma']
>param
out:(20759.430545279687, -41.012521759919224, 0.0019996776498165851)

If I now want to create a new gamma distribution to generate gamma-distributed random values with the same a,loc and scale specified in param above, I need to write:
>from scipy import stats
>rv = stats.gamma(a=param[0],loc=param[1],scale=param[2])
>rv.rvs(100)

How can I set a,loc,andscale directly without typing them out explicitly? I want to be able to quickly fit any distribution with an arbitrary number of parameters and generate random values that follow that distribution.
Thanks for your help!

A:

You can do <distribution>(*param), provided that the list of parameters param is in the right order.
If it is not, you have to have your params in a dictionary and call it as keyword arguments with <distribution>(**param), for instance:
param = {"a": 20759, "scale": 0.001, "loc": -41}
stats.gamma(**param)

Edit: more information here: *args and **kwargs?


Q:

How can I convert an onload promise into Async/Await

I have the following Typescript that I would like to use async/await on.  But I can't seem to sort it out in my head how to do this.
private getWorkbookFromFile2(excelFile: File): Promise<xlsx.IWorkBook> {
    var loadedPromise = new Promise<xlsx.IWorkBook>((resolve, reject) => {
        var reader = new FileReader();

        reader.onload = (event: any) => {
            var data = event.target.result;

            var workbook = xlsx.read(data, { type: 'binary' });

            console.log(workbook.SheetNames);
            resolve(workbook);
        };
        reader.readAsBinaryString(excelFile);
    });

    return loadedPromise;
}

Can someone show me how this Typescript promise can be converted to use async/await

A:

TypeScript now supports asynchronous functions for engines that have native support for ES6 generators, e.g. Node v4 and above. Asynchronous functions are prefixed with the async keyword; await suspends the execution until an asynchronous function return promise is fulfilled and unwraps the value from the Promise returned. - Source

async function getWorkbookFromFile2(excelFile: File) {
    return new Promise<xlsx.IWorkBook>((resolve, reject) => {
        var reader = new FileReader();

        reader.onload = (event: any) => {
            var data = event.target.result;

            var workbook = xlsx.read(data, { type: 'binary' });

            console.log(workbook.SheetNames);
            resolve(workbook);
        };
        reader.readAsBinaryString(excelFile);
    });
}

Example consumption:
async function caller() {
    var workbook = await this.getWorkbookFromFile2(this.getFile());
    // The 'workbook' variable is an IWorkBook...
}


Q:

C++ : why bool is 8 bits long?

In C++, I'm wondering why the bool type is 8 bits long (on my system), where only one bit is enough to hold the boolean value ?
I used to believe it was for performance reasons, but then on a 32 bits or 64 bits machine, where registers are 32 or 64 bits wide, what's the performance advantage ?
Or is it just one of these 'historical' reasons ?

A:

Because every C++ data type must be addressable.
How would you create a pointer to a single bit? You can't. But you can create a pointer to a byte. So a boolean in C++ is typically byte-sized. (It may be larger as well. That's up to the implementation. The main thing is that it must be addressable, so no C++ datatype can be smaller than a byte)

A:

Memory is byte addressable. You cannot address a single bit, without shifting or masking the byte read from memory. I would imagine this is a very large reason.

A:

A boolean type normally follows the smallest unit of addressable memory of the target machine (i.e. usually the 8bits byte).
Access to memory is always in "chunks" (multiple of words, this is for efficiency at the hardware level, bus transactions): a boolean bit cannot be addressed "alone" in most CPU systems. Of course, once the data is contained in a register, there are often specialized instructions to manipulate bits independently.
For this reason, it is quite common to use techniques of "bit packing" in order to increase efficiency in using "boolean" base data types. A technique such as enum (in C) with power of 2 coding is a good example. The same sort of trick is found in most languages.
Updated: Thanks to a excellent discussion, it was brought to my attention that sizeof(char)==1 by definition in C++. Hence, addressing of a "boolean" data type is pretty tied to the smallest unit of addressable memory (reinforces my point).


Q:

JAVA why is arrayCopy a System call?

Example
short size = 1234;
    byte[] payload = {12,43, 55,123, 11, 55};

byte [] shortSize = ByteBuffer.allocate(2).putShort(size).array();
byte[] entirePayload = new byte[shortSize.length+payload.length];

System.arraycopy(shortSize, 0, entirePayload, 0, 2);
System.arraycopy(payload, 0, entirePayload, 2, payload.length);

Is there a underlying reason this is a Java System call?

A:

Perhaps arraycopy would have fitted better on java.util.Arrays, but that class wasn't added until Java 1.2, whereas arraycopy was there at the very beginning of Java. System seems like the next best place to have put it.
Note too that this method is implemented in native code to make it faster, so it is a bit special.


Q:

How do I make a luminescent gas cloud?

How can I make a luminescent gas cloud, similar to the one shown in the picture below (labeled "Trapped Atoms")? Thank you.

A:

Simple Sphere with Emission as a Volume would be sufficient. We will use for both methods mostly the same setup. Gradient Texture > Color Ramp > Emission shader.
Color Ramp will control color and smoothness.
Emission > Strength... Strength.
Without Emission.

They will look like gas spheres and emission will not affect other meshes.

With Emission.

This ones will affect meshes with light.


Q:

Does the sqlite 'file change counter' overflow when it exceeds the maximum size?

According to http://www.sqlite.org/fileformat.html SQLite3 maintains a 4-byte big-endian integer file change counter in byte 24..27 of the database file.
Does the file change counter overflow when it exceeds the maximum size?
(I feel the answer is: yes, it does overflow)

I ask because I wanted something akin to checksum for the sqlite file, and found file change counter through another StackOverflow question:
Checksum for a SQLite database?

A:

The actual value of the file change counter does not have any meaning (it is not a version number); the only important thing is that it is different from all other recent values.
A quick test shows that the value wraps around:
$ sqlite3 test.db 'create table t(x);'
$ od --skip-bytes 24 --read-bytes 4 -tx1 test.db | cut -c9-
00 00 00 01
(lots of changes ...)
$ od --skip-bytes 24 --read-bytes 4 -tx1 test.db | cut -c9-
ff ff ff ff
$ sqlite3 test.db 'drop table t;'
$ od --skip-bytes 24 --read-bytes 4 -tx1 test.db | cut -c9-
00 00 00 00


Q:

What does white commit background in inteliJ mean?

I have merged B into branch A but branch A has no commits with white background in InteliJ. I merged B into branch A at 3/31/2017 5:00PM. Thank you!

A:

Background color indicates commits that are included in the current branch (the one checked out at the moment). White background shows commits that are not present in the current branch.
Since you merged into A, A should be your current branch (unless some specific --fast-forward merge was used), and commits from it should not have a white background.
The screenshot, however, does not make it clear where the branch A is, where the branch B is and what branch is currently checked out.

merged B into branch A at 3/31/2017 5:00PM

There is no such a merge commit on the screenshot. Maybe log is not refreshed properly?


Q:

Was an adobe fort or a palisade fort more defensible?

All else equal, when these types of forts were in use, was an adobe fort or a palisade fort more defensible?
A bit of what-if led to this question. Russians ostrogs such as Nizhnekamchatsk and Fort Ross had palisade perimeters while Spanish presidios such as Tubac and Santa Barbara had adobe perimeters. The two empires never battled (at least in the Americas) even though their most remote forts fell within about 100km of each other. Sample (not necessarily representative) images follow:

A:

Adobe forts are more defensible. Perhaps the most famous one was the Alamo. During the war for Texas independence, it was defended by less than 200 Texans for nearly two weeks against odds of 10-15 to one.
A palisade fort was mainly a stopgap against relatively small bands of soldiers. It was vulnerable to artillery and even fire. One such fort was Fort Washington during the American Revolution, which was captured at odds of 8 to 3 in less than a day. After taking heavy casualties in the approach over rough ground, the British breached the walls on two sides, "overrunning" the American positions.