text:
Q: Series where a tabletop gamer teen is transported from our world to one with magic This was a coming-of-age story.
It starts with the protagonist, a teenaged boy whose interests include TTRPGs like Dungeons and Dragons, going to an interview for a job. There he meets what turns out to be a creator deity who sends him to a magical world under the control of a group of sorcerers who owe allegiance to the creator deity's foe.
I remember it kind of as a footnote but two other teens from our world went missing and the protagonist discovers one, a jock has been killed and eaten by the wolves that live in the wooded area they are transported to, and a girl accidentally gets possessed by a demon but the protagonist cannot save her.
Relatively shortly into the story he finds himself witness to a battle and he saves prisoners from the attacking (evil) forces and when caught by their sorcerers accidentally ends up making a powerful magical bomb that breaks the siege by destroying most of the attacking forces. One of the prisoners becomes his traveling companion, a young boy.
The whole story is about him avoiding detection and increasing his magical knowledge until he eventually restores the worship of the "good deity" to the world and faces off with the "evil god" as it tries to enter and consume the world.
I read it around 2015, at my wife's recommendation but she read it years earlier. My impression is that it was published in either the 1990s or 2000's.

A: This sounds like The Unsuspecting Mage (2005) by Brian S. Pratt.
The hero is James Reese who is living with his grandparents since his parents were killed. One morning he goes downstairs to have breakfast and his grandfather shows him an ad for a job:

Magic! Real Magic! Ever wanted to learn?
We require someone with intelligence and a disciplined mind. Those well versed in
fantasy novels and role playing games a plus. May need to travel. Only those of good
character need apply. No appointment necessary. For preliminary interview, drop by at:
1616 Commercial Ave
Room 2334
Haveston, CA

He goes to the interview, where he finds a book and a letter telling him to read the first page and walk through a door marked "Private;" he does so and ends up in the fantasy world.
The paper had also had an article about a missing classmate of his, Seth Randle.  James finds Seth's body in the other world shortly after arriving (he actually heard him being killed the night after he arrived):

Horror grips James when he eyes settle on what's left of the poor guy's jacket. The letters H-A-V-E-S… are still discernable across what is left of the back of the jacket. It looked an awful lot like a letterman's jacket from his high school. Using the end of his walking stick he turns the torso over and sure enough, the name Randle is stitched across the front. So Seth wound up here just like I did, no wonder no one could find him.

There are more details (and some unfavourable reviews) on the Goodreads page, including a link for a free Kindle copy.


text:
Q: "I die" and "I'd die" I have a question about the pronunciation between "I die" and "I'd die". If I consider linking words and link the "d" in "I'd and the d in "die", the pronunciation of I DIE and I'D DIE would be the same. Would I only get either by the context?
Thank u.

A: My guess is that most native English speakers speaking colloquially will connect the [d] in "I'd" with the [d] in "die".  What happens is that in "I'd die", you get a geminate: the [d] sound is held longer before being spat out.
On the other hand, the [d] sound remains short in "I die".
That said, an English speaker could certainly separate these two words and create a small gap between them: the [d] at the end of "I'd" would them be released before the "die" is pronounced.  You'd get something like "I-duh-die".  But unless the speaker is trying to speak very slowly, normally a speaker will connect consecutive words.
Although many English speakers may not be able to describe the difference in sound between these words, it is quite clear when you hear them together.

redpajama_set_name: RedPajamaStackExchange


text:
Q: how to remove fixed position from menu hamburger icon How can I remove the fixed position from the hamburger icon so that I can position it relative to its parent div? Ive added this to a header in elementor but I cannot adjust the position by adding padding/margins etc to the header as it is fixed. I need to be able to add padding in the header using vw units so that the hamburger icon moves when the browser is resized. Ive tried changing some of the "position:fixed" css in here but not had any succcess achieving what I need yet.

@import url('https://fonts.googleapis.com/css?family=Rubik+Mono+One|Roboto+Mono:400,700&display=swap');
:root {
  --color-primary: #18181A;
  --color-secondary: #75757C;
  --color-dark: #364C62;
  --color-light: #F5F5F5;
  --font-family-primary: 'Roboto Mono', monospace;
  --font-family-secondary: 'Rubik Mono One', sans-serif;
  --td: 150ms;
  --te: cubic-bezier(0.215, 0.61, 0.355, 1);
}
html, body {
  height: 100%;
}
body {
  color: var(--color-dark);
  font-family: var(--font-family-primary);
  overflow-x: hidden;
  position: relative;
}
h1 {
  font-size: calc(1.5rem + 4vmin);
  font-weight: 700;
  margin-bottom: 2rem;
}
p {
  line-height: 1.4;
}
a {
  font-weight: 700;
}
.page-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  justify-content: center;
  margin: 0 auto;
  max-width: 45rem;
  padding: 1rem;
}
.page-container > * + * {
  margin-top: 1.5rem;
}
.nav-main {
  align-items: center;
  display: flex;
  height: 100%;
  justify-content: center;
  left: -100%;
  position: fixed;
  transition: left 0s calc(var(--td) * 2), transform 0s calc(var(--td) * 2);
  width: 100%;
}
.nav-main::before, .nav-main::after {
  content: '';
  background-color: var(--color-primary);
  height: 50%;
  left: 0;
  position: absolute;
  transform: translateX(-110%);
  transform-origin: 0 50%;
  transition: transform calc(var(--td) * 2) var(--td) var(--te);
  width: 100%;
  z-index: -100;
}
.nav-main::before {
  top: 0;
}
.nav-main::after {
  bottom: 0;
}
.nav-main .menu__item {
  opacity: 0;
  transform: translateX(-1rem);
  transition: opacity var(--td) var(--te), transform var(--td) var(--te);
}
[id="main-navigation-toggle"] {
  opacity: 0;
  position: fixed;
  top: -100%;
}
[id="main-navigation-toggle"] ~ label {
  cursor: pointer;
  position: fixed;
  right: 1rem;
  top: 1rem;
  z-index: 100;
}
[id="main-navigation-toggle"] ~ label span {
  display: block;
  height: 2rem;
  padding: 0.5rem;
  position: relative;
  transition: transform calc(var(--td) * 3) var(--te);
  width: 2rem;
}
[id="main-navigation-toggle"] ~ label span::before, [id="main-navigation-toggle"] ~ label span::after {
  background-color: var(--color-dark);
  bottom: 0;
  content: '';
  height: 4px;
  left: 0;
  margin: auto;
  position: absolute;
  right: 0;
  transition: transform calc(var(--td) * 3) var(--te);
  top: 0;
  width: calc(100% - 1rem);
}
[id="main-navigation-toggle"] ~ label span::before {
  transform: rotate(0) translateY(-100%);
}
[id="main-navigation-toggle"] ~ label span::after {
  transform: rotate(0) translateY(100%);
}
[id="main-navigation-toggle"]:checked ~ label span {
  transform: rotate(1turn);
}
[id="main-navigation-toggle"]:checked ~ label span::before {
  transform: rotate(45deg);
}
[id="main-navigation-toggle"]:checked ~ label span::after {
  transform: rotate(-45deg);
}
[id="main-navigation-toggle"]:checked ~ .nav-main {
  left: 0;
  transition: transform 0s;
}
[id="main-navigation-toggle"]:checked ~ .nav-main::before, [id="main-navigation-toggle"]:checked ~ .nav-main::after {
  transform: translateX(0);
  transition-delay: 0s;
}
[id="main-navigation-toggle"]:checked ~ .nav-main::after {
  transition-delay: calc(var(--td) / 2);
}
[id="main-navigation-toggle"]:checked ~ .nav-main .menu__item {
  opacity: 1;
  transform: translateX(0);
  transition: opacity calc(var(--td) * 2) var(--te), transform calc(var(--td) * 2) var(--te);
}
[id="main-navigation-toggle"]:checked ~ .nav-main .menu__item:nth-child(1) {
  transition-delay: calc(var(--td) * 2 * (1 * 0.25));
  z-index: -1;
}
[id="main-navigation-toggle"]:checked ~ .nav-main .menu__item:nth-child(2) {
  transition-delay: calc(var(--td) * 2 * (2 * 0.25));
  z-index: -2;
}
[id="main-navigation-toggle"]:checked ~ .nav-main .menu__item:nth-child(3) {
  transition-delay: calc(var(--td) * 2 * (3 * 0.25));
  z-index: -3;
}
[id="main-navigation-toggle"]:checked ~ .nav-main .menu__item:nth-child(4) {
  transition-delay: calc(var(--td) * 2 * (4 * 0.25));
  z-index: -4;
}
[id="main-navigation-toggle"]:checked ~ .nav-main .menu__item:nth-child(5) {
  transition-delay: calc(var(--td) * 2 * (5 * 0.25));
  z-index: -5;
}
.menu {
  position: relative;
  text-align: center;
  z-index: 1;
}
.menu > .menu__item {
  font-family: var(--font-family-secondary);
  font-size: 10vmin;
}
.submenu {
  left: 0;
  opacity: 0;
  position: absolute;
  transform: translateY(-10%);
  top: 100%;
  width: 100%;
  visibility: hidden;
  z-index: 2;
}
.submenu .menu__item {
  font-family: var(--font-family-primary);
  font-size: 3.5vmin;
  width: 100%;
}
.submenu .menu__link {
  color: var(--color-secondary);
  text-shadow: 1px 1px 0 var(--color-primary), 2px 2px 0 var(--color-primary);
}
.submenu .menu__link::before, .submenu .menu__link::after {
  display: none;
}
.menu__item {
  display: block;
  position: relative;
}
.menu__item:hover .menu__link::before, .menu__item:hover .menu__link::after {
  animation: blink 1s var(--td) steps(1, end) forwards infinite;
  transform: translateX(calc(100% - 0.5rem));
  transition-duration: calc(var(--td) * 3);
}
.menu__item:hover .menu__link::after {
  transition-delay: calc(var(--td) / 2);
}
.menu__item:hover .submenu {
  opacity: 1;
  transform: translateY(0);
  transition: transform calc(var(--td) * 2) calc(var(--td) * 3) var(--te), opacity calc(var(--td) * 2) calc(var(--td) * 3) var(--te), visibility 0s calc(var(--td) * 3);
  visibility: visible;
}
.menu__link {
  color: var(--color-dark);
  display: inline-block;
  font-weight: normal;
  overflow: hidden;
  padding: 0.5rem 1rem 0.125rem;
  position: relative;
  text-decoration: none;
  transition: color var(--td) var(--te), opacity var(--td) var(--te), transform var(--td) var(--te);
  z-index: 1;
}
.menu__link::before, .menu__link::after {
  content: '';
  background-color: var(--color-light);
  height: 50%;
  left: 0;
  position: absolute;
  transform: translateX(-110%);
  transform-origin: 0 50%;
  transition: transform 0s var(--te);
  width: 100%;
  z-index: -1;
}
.menu__link::before {
  top: 0;
}
.menu__link::after {
  bottom: 0;
}
.menu:not(:focus-within):not(:hover) .menu__item .menu__link {
  opacity: 1;
  transform: translate(0, 0);
}
.menu__item {
  --pull: 30%;
}
.menu__item .menu__link {
  opacity: 0.25;
  transition-duration: calc(var(--td) * 3);
  transform: translate(0, calc(var(--pull) * -1));
}
.menu__item .submenu .menu__link {
  opacity: 1;
}
.menu__item:hover > .menu__link {
  color: var(--color-secondary);
  opacity: 1;
  transform: translate(0, 0);
}
.menu__item:hover > .menu__link:hover {
  color: var(--color-light);
  transition-delay: 0s;
}
.menu__item:hover ~ .menu__item > .menu__link {
  transition-duration: calc(var(--td) * 3);
  transform: translate(0, var(--pull));
}
@keyframes blink {
  50%, 100% {
    opacity: 0;
  }
}
<input type="checkbox" id="main-navigation-toggle" class="btn btn--close" title="Toggle main navigation" />

      Home

      About

      Clients

          Burger King

          Southwest Airlines

          Levi Strauss

      Services

          Print Design

          Web Design

          Mobile App Development

      Contact

Fork This Nav Challenge

Click the toggle to open the menu and see the magic.

A: Is this what you're looking for? I added a wrapper around both the menu and the menu toggle (which allows you to maintain your relative CSS selectors to show/hide the navigation). The container is position:relative and I added a right margin to demonstrate your scenario above. I also changed the toggle label to position:absolute so it would follow the container.

@import url('https://fonts.googleapis.com/css?family=Rubik+Mono+One|Roboto+Mono:400,700&display=swap');
:root {
  --color-primary: #18181A;
  --color-secondary: #75757C;
  --color-dark: #364C62;
  --color-light: #F5F5F5;
  --font-family-primary: 'Roboto Mono', monospace;
  --font-family-secondary: 'Rubik Mono One', sans-serif;
  --td: 150ms;
  --te: cubic-bezier(0.215, 0.61, 0.355, 1);
}
html, body {
  height: 100%;
}
body {
  color: var(--color-dark);
  font-family: var(--font-family-primary);
  overflow-x: hidden;
  position: relative;
}
h1 {
  font-size: calc(1.5rem + 4vmin);
  font-weight: 700;
  margin-bottom: 2rem;
}
p {
  line-height: 1.4;
}
a {
  font-weight: 700;
}
.page-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  justify-content: center;
  margin: 0 auto;
  max-width: 45rem;
  padding: 1rem;
}
.page-container > * + * {
  margin-top: 1.5rem;
}
.navigation-container {
  position: relative;
  margin-right: 5rem;
}
.nav-main {
  align-items: center;
  display: flex;
  height: 100%;
  justify-content: center;
  left: -100%;
  position: fixed;
  transition: left 0s calc(var(--td) * 2), transform 0s calc(var(--td) * 2);
  width: 100%;
}
.nav-main::before, .nav-main::after {
  content: '';
  background-color: var(--color-primary);
  height: 50%;
  left: 0;
  position: absolute;
  transform: translateX(-110%);
  transform-origin: 0 50%;
  transition: transform calc(var(--td) * 2) var(--td) var(--te);
  width: 100%;
  z-index: -100;
}
.nav-main::before {
  top: 0;
}
.nav-main::after {
  bottom: 0;
}
.nav-main .menu__item {
  opacity: 0;
  transform: translateX(-1rem);
  transition: opacity var(--td) var(--te), transform var(--td) var(--te);
}
[id="main-navigation-toggle"] {
  opacity: 0;
  position: fixed;
  top: -100%;
}
[id="main-navigation-toggle"] ~ label {
  cursor: pointer;
  position: absolute;
  right: 1rem;
  top: 1rem;
  z-index: 100;
}
[id="main-navigation-toggle"] ~ label span {
  display: block;
  height: 2rem;
  padding: 0.5rem;
  position: relative;
  transition: transform calc(var(--td) * 3) var(--te);
  width: 2rem;
}
[id="main-navigation-toggle"] ~ label span::before, [id="main-navigation-toggle"] ~ label span::after {
  background-color: var(--color-dark);
  bottom: 0;
  content: '';
  height: 4px;
  left: 0;
  margin: auto;
  position: absolute;
  right: 0;
  transition: transform calc(var(--td) * 3) var(--te);
  top: 0;
  width: calc(100% - 1rem);
}
[id="main-navigation-toggle"] ~ label span::before {
  transform: rotate(0) translateY(-100%);
}
[id="main-navigation-toggle"] ~ label span::after {
  transform: rotate(0) translateY(100%);
}
[id="main-navigation-toggle"]:checked ~ label span {
  transform: rotate(1turn);
}
[id="main-navigation-toggle"]:checked ~ label span::before {
  transform: rotate(45deg);
}
[id="main-navigation-toggle"]:checked ~ label span::after {
  transform: rotate(-45deg);
}
[id="main-navigation-toggle"]:checked ~ .nav-main {
  left: 0;
  transition: transform 0s;
}
[id="main-navigation-toggle"]:checked ~ .nav-main::before, [id="main-navigation-toggle"]:checked ~ .nav-main::after {
  transform: translateX(0);
  transition-delay: 0s;
}
[id="main-navigation-toggle"]:checked ~ .nav-main::after {
  transition-delay: calc(var(--td) / 2);
}
[id="main-navigation-toggle"]:checked ~ .nav-main .menu__item {
  opacity: 1;
  transform: translateX(0);
  transition: opacity calc(var(--td) * 2) var(--te), transform calc(var(--td) * 2) var(--te);
}
[id="main-navigation-toggle"]:checked ~ .nav-main .menu__item:nth-child(1) {
  transition-delay: calc(var(--td) * 2 * (1 * 0.25));
  z-index: -1;
}
[id="main-navigation-toggle"]:checked ~ .nav-main .menu__item:nth-child(2) {
  transition-delay: calc(var(--td) * 2 * (2 * 0.25));
  z-index: -2;
}
[id="main-navigation-toggle"]:checked ~ .nav-main .menu__item:nth-child(3) {
  transition-delay: calc(var(--td) * 2 * (3 * 0.25));
  z-index: -3;
}
[id="main-navigation-toggle"]:checked ~ .nav-main .menu__item:nth-child(4) {
  transition-delay: calc(var(--td) * 2 * (4 * 0.25));
  z-index: -4;
}
[id="main-navigation-toggle"]:checked ~ .nav-main .menu__item:nth-child(5) {
  transition-delay: calc(var(--td) * 2 * (5 * 0.25));
  z-index: -5;
}
.menu {
  position: relative;
  text-align: center;
  z-index: 1;
}
.menu > .menu__item {
  font-family: var(--font-family-secondary);
  font-size: 10vmin;
}
.submenu {
  left: 0;
  opacity: 0;
  position: absolute;
  transform: translateY(-10%);
  top: 100%;
  width: 100%;
  visibility: hidden;
  z-index: 2;
}
.submenu .menu__item {
  font-family: var(--font-family-primary);
  font-size: 3.5vmin;
  width: 100%;
}
.submenu .menu__link {
  color: var(--color-secondary);
  text-shadow: 1px 1px 0 var(--color-primary), 2px 2px 0 var(--color-primary);
}
.submenu .menu__link::before, .submenu .menu__link::after {
  display: none;
}
.menu__item {
  display: block;
  position: relative;
}
.menu__item:hover .menu__link::before, .menu__item:hover .menu__link::after {
  animation: blink 1s var(--td) steps(1, end) forwards infinite;
  transform: translateX(calc(100% - 0.5rem));
  transition-duration: calc(var(--td) * 3);
}
.menu__item:hover .menu__link::after {
  transition-delay: calc(var(--td) / 2);
}
.menu__item:hover .submenu {
  opacity: 1;
  transform: translateY(0);
  transition: transform calc(var(--td) * 2) calc(var(--td) * 3) var(--te), opacity calc(var(--td) * 2) calc(var(--td) * 3) var(--te), visibility 0s calc(var(--td) * 3);
  visibility: visible;
}
.menu__link {
  color: var(--color-dark);
  display: inline-block;
  font-weight: normal;
  overflow: hidden;
  padding: 0.5rem 1rem 0.125rem;
  position: relative;
  text-decoration: none;
  transition: color var(--td) var(--te), opacity var(--td) var(--te), transform var(--td) var(--te);
  z-index: 1;
}
.menu__link::before, .menu__link::after {
  content: '';
  background-color: var(--color-light);
  height: 50%;
  left: 0;
  position: absolute;
  transform: translateX(-110%);
  transform-origin: 0 50%;
  transition: transform 0s var(--te);
  width: 100%;
  z-index: -1;
}
.menu__link::before {
  top: 0;
}
.menu__link::after {
  bottom: 0;
}
.menu:not(:focus-within):not(:hover) .menu__item .menu__link {
  opacity: 1;
  transform: translate(0, 0);
}
.menu__item {
  --pull: 30%;
}
.menu__item .menu__link {
  opacity: 0.25;
  transition-duration: calc(var(--td) * 3);
  transform: translate(0, calc(var(--pull) * -1));
}
.menu__item .submenu .menu__link {
  opacity: 1;
}
.menu__item:hover > .menu__link {
  color: var(--color-secondary);
  opacity: 1;
  transform: translate(0, 0);
}
.menu__item:hover > .menu__link:hover {
  color: var(--color-light);
  transition-delay: 0s;
}
.menu__item:hover ~ .menu__item > .menu__link {
  transition-duration: calc(var(--td) * 3);
  transform: translate(0, var(--pull));
}
@keyframes blink {
  50%, 100% {
    opacity: 0;
  }
}

  <input type="checkbox" id="main-navigation-toggle" class="btn btn--close" title="Toggle main navigation" />

        Home

        About

        Clients

            Burger King

            Southwest Airlines

            Levi Strauss

        Services

            Print Design

            Web Design

            Mobile App Development

        Contact

Fork This Nav Challenge

Click the toggle to open the menu and see the magic.


text:
Q: Rails Postgresql sort by random I am trying to pull out rows from a postgres database, I can pull them out desc but when I try random I get a Syntax error near random.
Error
PG::Error: ERROR:  syntax error at or near "rand"
LINE 1: ...  "hashtags".* FROM "hashtags"  ORDER BY tweet_id rand LIMIT...
                                                             ^
: SELECT  "hashtags".* FROM "hashtags"  ORDER BY tweet_id rand LIMIT 4

Code to pull it out

<% Hashtag.order("tweet_id desc").limit(4).each do |hashtag| %>

<%= hashtag.content %>

— @<%= hashtag.screen_name %>

 <% end %>

A: To fetch random entries from your database you have a few options. Here's a couple
1st approach
This will take 4 random entries out of your DB using SQL.
Hashtag.order("RANDOM()").limit(4)

2nd approach:
You can also use ActiveRecord sample() method to retrieve 4 random rows.
Hashtag.all.sample(4)

As of speed and efficiency; I made a mini-benchmark and tested two commands on my own db (contains 500 records).
The first approach (as expected) was more than twice faster than the second approach.
SQL: 1.8ms
Sample Method: 4.2ms

A: Just want to say. I was trying to shuffle my entries using postgres, but found a post where @instace.shuffle.each does it even better.


text:
Q: Find in the last day of the month using calendar on Android I am trying to change the last day allowed in my calendar Widget based on the current date or fix date.
The code below is using a date as a default start date and I need to allow the user to select between this date and date + 3 months later.
val maxDay = Calendar.getInstance()

setSelectedDate(currentShipDate.toDate())

maxDay.add(Calendar.MONTH, 3)

state().edit()
     .setMinimumDate(minDay.time)
     .setMaximumDate(maxDay.time)
     .commit()

The maxDay is now set to 3 months later using the currentShipDate. However, I am looking to allow the user to also select a date until the end of the 3rd months.
For example, if the ship happened in 21st July, you can change the shipping date til 31st October (instead of 21st October)
For example, if the ship happened in 10th July, you can change the shipping date til 31st October (instead of 10st October)
Any idea ?
Thanks for your help

A: Do it like this:

*

*Instead of adding 3 months, add 4 --> maxDay.add(Calendar.MONTH, 4)

*Set the day of the month to 1 --> maxDay.set(Calendar.DAY_OF_MONTH, 1)

*Subtract one day --> maxDay.add(Calendar.DAY_OF_MONTH, -1)
This will give you the last day of the third month.


text:
Q: The mappings //Entity and //Entity are inconsistent with each other - Symfony2/Doctrine2 Have spent literally the last 2 hours trying to fix this issue. I'm sure it's something stupid I am overlooking but It's properly got me stuck.
I am getting this error when I try and validate my database :
 [Mapping]  FAIL - The entity-class 'BC\InventoryBundle\Entity\ProductRecipe' mapping is     invalid:
 * The mappings BC\InventoryBundle\Entity\ProductRecipe#products and BC\InventoryBundle\Entity\Products#recipes are incosistent with each other.
 * The mappings BC\InventoryBundle\Entity\ProductRecipe#recipes and BC\InventoryBundle\Entity\Recipes#products are incosistent with each other.

[Mapping]  FAIL - The entity-class 'BC\InventoryBundle\Entity\Products' mapping is invalid:
* The mappings BC\InventoryBundle\Entity\Products#recipes and BC\InventoryBundle\Entity\ProductRecipe#recipes are incosistent with each other.

[Mapping]  FAIL - The entity-class 'BC\InventoryBundle\Entity\Recipes' mapping is invalid:
* The mappings BC\InventoryBundle\Entity\Recipes#products and BC\InventoryBundle\Entity\ProductRecipe#products are incosistent with each other.

I thought I had got my Inverse and Mapped by's wrong. So (I think) I have tried every possible combination but to no avail.
Here's my mapping files.
//Recipe.orm.yml
   oneToMany:
    products:
      mappedBy: productsProductRecipe
      cascade: ["all"]

//Products.orm.yml
   oneToMany:
    recipes:
      targetEntity: ProductRecipe
      mappedBy: recipes
      cascade: ["all"]

//ProductRecipe.orm.yml
BC\InventoryBundle\Entity\ProductRecipe:
type: entity
table: ProductRecipe
repositoryClass: BC\InventoryBundle\Entity\ProductRecipeRepository

id:
    id:
        type: integer
        generator: { strategy: AUTO }
fields:
    ammount:
        type: decimal
        presision: 10
        scale: 2

   manyToOne:
    products:
      targetEntity: Products
      inversedBy: recipes
      joinColumn:
        name: product_id
        referencedColumnName: id
    recipes:
      targetEntity: Recipes
      inversedBy: products
      joinColumn:
        name: recipe_id
        referencedColumnName: id

I have been using Doctrine:Generate:Entities for my entities so I won't paste them here unless asked for them. All the setters and getters are there.

A: Recipe.orm.yml
   oneToMany:
        products:
            targetEntity: ProductRecipe // Not present before
            mappedBy: recipes // Previously "productsProductRecipe"
            cascade: ["all"]

Products.orm.yml \\ Should rename for singular, also your relation is for Product
    oneToMany:
        recipes:
            targetEntity: ProductRecipe
            mappedBy: products // Previously "recipes"
            cascade: ["all"]

ProductRecipe.orm.yml
BC\InventoryBundle\Entity\ProductRecipe:
    type: entity
    table: ProductRecipe
    repositoryClass: BC\InventoryBundle\Entity\ProductRecipeRepository

    id:
        id:
            type: integer
            generator: { strategy: AUTO }
    fields:
        amount: // Previously "ammount"
            type: decimal
            presision: 10
            scale: 2

    manyToOne:
        products:
            targetEntity: Product
                // "Products" is named correctly but recipe is singular
                // so for the sake of uniformity
            inversedBy: recipes
            joinColumn:
                name: product_id
                referencedColumnName: id
        recipes:
            targetEntity: Recipe
                // Previously "Recipes", incorrect entity name
            inversedBy: products
            joinColumn:
                name: recipe_id
                referencedColumnName: id

Just at a cursory glance... It could be wrong though.


text:
Q: Youtube Javascript API callback after pause I would like to display an image with a play button, as soon as someone clicks the image I create a youtube player play it. As soon as someone clicks on the "pause" button I would like to hide the player and show the image again.
Is there some kind of callback I can use? I tried to use the onStateChange callback
onStateChange: function (event) {
    if (event.data === 2) {
        // logic to hide it
    }
}

The problem is: this event is fired when someone changes the time as well, so as soon as a user left click the timeline the video signals to "pause" and becomes hidden. Can I somehow check if the video is just buffering/changing the position instead of pausing actively by a user?

A: Hopeing this to work...
</script>

    Latest Product Video


text:
Q: Make regular expression case insensitive in ASP.NET RegularExpressionValidator Given this regular expression: "^[0-9]*\s*(lbs|kg|kgs)$"  how do I make it case insensitive?  I am trying to use this in a .net regular expression validator, so I need to specify case insensitivity in the pattern.
I can not use the RegexOptions programatically because I am specifying the regular expression in a RegularExpressionValidator

A: I found out.
Case sensitive: ^[0-9]\s(lbs|kg|kgs)$
Case insensitive: (?i:^[0-9]\s(lbs|kg|kgs)$)
I believe that this is specific to the .NET implementation of regular expressions.  So if you use this in the RegularExpressionValidator you have to turn off client side validation because the javascript regex parser will not recognize the ?i token.

A: Here is an alternative using a CustomValidator, when really needing case-insensitivity server-side and client-side; and the the Upper/lower [A-Za-z] char approach is too much.
This blends the various other answers, using the server-side RegEx object and client-side JavaScript syntax.
CustomValidator:
<asp:CustomValidator ID="cvWeight" runat="server" ControlToValidate="txtWeight"
  OnServerValidate="cvWeight_Validate" ClientValidationFunction="cvWeight_Validate"
  ValidateEmptyText="true" Text="*" ErrorMessage="Invalid entry." />

Code behind:
protected void cvWeight_Validate(object sender, ServerValidateEventArgs args)
{
    Regex re = new Regex(@"^[0-9]*\s*(lbs|kg|kgs)$", RegexOptions.IgnoreCase);
    args.IsValid = re.IsMatch(args.Value);
}

Client-side validation function:
function cvWeight_Validate(sender, args) {
  var reWeight = /^[0-9]*\s*(lbs|kg|kgs)$/i;
  args.IsValid = reWeight.test(args);
}

This is working fine for me, except when using a ValidationSummary. On the client-side validation, the error * shows, but I can't get the error message to display in the summary. The summary only displays when submitted. I think it's supposed to display; I have a mix of update panels and legacy code, which may be problems.

A: Can we make Regex case-insensitive in C#? : Yes

Set option inline via (?i) pattern construct or via  RegexOptions.IgnoreCase param

Can we make Regex case-insensitive in JavaScript? : Yes

Set flag via /pattern/flags syntax or the insensitive flag /REGEX/i

(Aside) Can we make Regex case-insensitive in HTML5 Pattern Attribute? : No
As Chris R. Timmons points out on RegularExpressionValidator doesn't ignore case:

There is no property in the RegularExpressionValidator control that
  allows regex options to be set.
If your control does both client-side and server-side validation, the
  regex must use a subset of regular expression syntax that both
  JS and .NET can execute. In this case, to make a regex ignore
  case it is necessary to use a character class construct like [a-zA-Z]
  to match both upper and lower case characters.
If your validation is done on the server-side only, you can use the
  more powerful .NET regular expression syntax. In this case, you can
  place the (?i) option at the beginning of the regex to tell it to
  ignore case.

So, if you want to use the out of the box validator, you're stuck with Geoff's solution of using character sets like this: [aA]

A: Easiest here is to just modify the regex to
^[0-9]*\s*([lL][bB][sS]|[kK][gG][sS]?)$

It's awful to read, but it will work fine.


text:
Q: input preprocessing in Keras I had a question about input preprocessing in Keras.
If you look at the pre-processing source code
https://github.com/keras-team/keras/blob/master/keras/applications/imagenet_utils.py#L149
the default preprocessing mode appears to be Caffe. Their snippet of code uses it directly too
https://github.com/fchollet/deep-learning-models
My question is, why is Keras not checking Keras.backend() to find the correct mode and do the pre-processing appropriately? Is this likely a bug?
My backend is tensorflow, so I am wondering if running the code directly as provided in their example is a good idea.
Thanks

A: Each model has its own preprocessing.
Some take the preprocessing from the code you've shown (where it's clearly declared with mode='caffe'). Some models declare its own preprocessing. Always import the preprocessing function from the same module as the model you're trying to instance, so you import the right function.
The mode is suited to how the model was built. If a model was built with the caffe mode, then it will only work well with input following that specification.
The same is valid for all other modes.

Tensorflow or Theano?
It doesn't really matter. Keras does handle those formats properly.
As you can see in that source code, keras has the K.image_data_format(), that is taken from your default configurations (you find your default configuration, which is usually channels_last, in the keras.json file).
Keras will handle the format correctly, no matter if you're using Theano or Tensorflow. I suggest, unless you have a reason or a clear preference, that you leave the configs as they are with channels_last. This makes it easier to integrate convolution layers with others and with loss functions. Everything in keras tend to work on the last axis, so, leave the channels at the last position as well to avoid extra work.


text:
Q: Add delay after showMessage() I have this code
<script type="text/javascript">
    var currentBlock;

    function onSuccessEditUser(result) {
        showMessage(result.Message);
        window.location = '@Url.Action("UserIndex")';
    }
</script>

and I would like to add a little delay after showMessage and before window.location.
How can I do that?

A: You can use setTimeout to fire off the code after a specified interval:
function onSuccessEditUser(result) {
    showMessage(result.Message);

    // Wait 1 second
    setTimeout(function() {
        window.location = '@Url.Action("UserIndex")';
    },1000);
}

A: use java script setTimeOut method to execute something after specified time
<script type="text/javascript">
var currentBlock;
function onSuccessEditUser(result) {
showMessage(result.Message);
// Wait 5 second
setTimeout(function() {
    window.location = '@Url.Action("UserIndex")';
},5000);
}
<script>

A: You could use a setTimeout(function(){showMessage(result.Message);}); function.
Or opt for jQuery $(..).delay(300); http://api.jquery.com/delay/
Whichever you prefer.


text:
Q: Implementing passingTest that returns all nodes in the node's subtree that satisfy a test I am not really sure how to really use this function. I searched the internet thoroughly but could not find an instance of an example of this function being used. In SceneKit, I am pretty familiar with the function that searches by the node's name.. but this one is confusing since it returns a reference to a bool, that specifies an array.. The definition goes like this
func childNodes(passingTest predicate: (SCNNode, UnsafeMutablePointer<ObjCBool>) -> Bool) -> [SCNNode]

I got up to this point.. which gives me ALL the nodes I do not know why..
let ballToDisappear = sceneView?.scene.rootNode.childNodes(passingTest: { (node, ballYesOrNo) -> Bool in
        if (node.position.x < (maxVector?.x)! && node.position.x > (minVector?.x)!){
            if (node.position.y < (maxVector?.y)! && node.position.y > (minVector?.y)!){
                if (node.position.z < (maxVector?.z)! && node.position.z > (minVector?.z)!){
                    return ballYesOrNo.pointee.boolValue
                }
            }
        }
                    return !ballYesOrNo.pointee.boolValue
    }
    )

Any help would be greatly appreciated! Thanks!

A: The definition of childNodes(passingTest:) expects a closure that takes two arguments and returns a Bool. The arguments to the closure are:

*

*child => the node to check (called node by you)

*stop => indicates to stop the test. Calling this ballYesOrNo as you did is inherently confusing, better name it stop as the documentation suggests.

So you'd have to modify stop if and only if you want to stop the algorithm. You'd never want to return the value of stop directly.
To say that a child node matches, you have to return true, else false.
Therefore:
let ballToDisappear = sceneView?.scene.rootNode.childNodes(passingTest: { (node, stop) -> Bool in
    if (node.position.x < (maxVector?.x)! && node.position.x > (minVector?.x)!){
        if (node.position.y < (maxVector?.y)! && node.position.y > (minVector?.y)!){
            if (node.position.z < (maxVector?.z)! && node.position.z > (minVector?.z)!){
                return false // or false here and true below??
            }
        }
    }
                return true // or true here, see above, depends on your logic
}
)


text:
Q: Config entries for DoctrineExtensions SoftDeleteable: gedmo/doctrine-extensions I'm trying to use softdelete option of gedmo/doctrine-extensions but for some reason when I call romove(), the record in database gets removed instead of updating deletedAt field.
In here, doc tells us to update config with:

$config->addFilter('soft-deleteable',
  'Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter');

This is just one of the examples I tried:
# app/config/config.yml
doctrine:
    orm:
        entity_managers:
            default:
                filters:
                    softdeleteable:
                        class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
                        enabled: true

References (just a few of them):

*

*DoctrineExtensions SoftDeleteable

*http://knplabs.com/en/blog/gedmo-doctrine-extensions-on-symfony2

*Can't enable SoftDeleteable in Symfony2 - Unrecognized options "filters"
So the question in simple terms, how do I configure it in config.yml?
CONTROLLER
public function delete($id)
{
    $profile = $this->profileRepository->findOneBy(['id' => $id]);

    if (!$profile instanceof Profile) {
        throw new ........
    }

    $this->entityManager->remove($profile);
    $this->entityManager->flush();

    return true;
}

ENTITY
use Gedmo\Mapping\Annotation as Gedmo;

/**
 * @ORM\Entity()
 * @ORM\Table(name="profile")
 * @Gedmo\SoftDeleteable(fieldName="deletedAt")
 */
class Profile
{
    /**
     * @ORM\Column(name="deletedAt", type="datetime", nullable=true)
     */
    private $deletedAt;
    ......
}

COMPOSER.JSON
"require": {
    "symfony/symfony": "2.6.*",
    "doctrine/orm": "~2.2,>=2.2.3",
    "doctrine/doctrine-bundle": "~1.2",
    "gedmo/doctrine-extensions": "2.3.*@dev",
    ......
},

CONFIG.YML
doctrine:
    dbal:
      default_connection: front
      connections:
        front:
          driver:   %database_driver%
          host:     %database_host%
          ........
        back:
          driver:   %database_driver%
          host:     %database_host%
          ........

    orm:
        auto_generate_proxy_classes: %kernel.debug%
        default_entity_manager:      front

        entity_managers:
            front:
                connection:       front
                mappings:
                    MyWebsiteBundle:
                        dir:      Entity
                    FOSUserBundle: ~

            back:
                connection:       back

MAPPING INFO:
inanzzz@inanzzz:/var/www/html/local$ php app/console doctrine:mapping:info
Found 8 mapped entities:
[OK]   My\Bundle\Entity\AbstractMerchantProfile
[OK]   My\Bundle\Entity\AbstractIntegration
[OK]   My\Bundle\Entity\APIConsumer
[OK]   My\Bundle\WebsiteBundle\Entity\User
[OK]   My\Bundle\WebsiteBundle\Entity\Profile
[OK]   My\Bundle\WebsiteBundle\Entity\Integration
[OK]   FOS\UserBundle\Model\Group
[OK]   FOS\UserBundle\Model\User

A: This is how I configured it
doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        auto_mapping: true
        filters:
            softdeleteable:
                class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
                enabled: true

A: Solution:
Included stof/doctrine-extensions-bundle in composer.json
"stof/doctrine-extensions-bundle": "1.2.*@dev",
Package is here. Documentation is here.
Enable bundle in AppKernel:
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle()
Since I have more than one entity managers in config.yml I did:
stof_doctrine_extensions:
    orm:
        em1:
            softdeleteable: true

doctrine:
    dbal:
      default_connection: em1
      connections:
        em1:
          driver:   %database_driver%
          host:     %database_host%
          .......

        em2:
          driver:   %database_driver%
          host:     %database_host%
          .......

        em3:
          driver:   %mws_database_driver%
          host:     %mws_database_host%
          .......

    orm:
        auto_generate_proxy_classes: %kernel.debug%
        default_entity_manager:      em1

        entity_managers:
            em1:
                connection:       em1
                mappings:
                    MyWebsiteBundle:
                        dir:      Entity
                    FOSUserBundle: ~
                filters:
                    softdeleteable:
                        class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
                        enabled: true

            em2:
                connection:       em2

            em3:
                connection:       em3


text:
Q: What is known about the Homorphus Charm and does it cure lycanthropy? Question inspired by reading this -> Why was an entire minor scene omitted from the French translation of "Harry Potter and the Chamber of Secrets"?
Please read Prof. Lockhart's quote in that question
In the quotes he claims that he performed the Homorphus charm and changed a werewolf back to human
It seems he was reading from one of his books and since his books are very popular, I can assume Homorphus charm is a real thing in Harry Potter
However, looking at Lupin in book 3, there doesn't seem to be any cure for lycanthropy at all
Is the Homorphus charm known to cure werewolf bites, in universe? Is the charm itself something Lockhart made up? What, if anything, is known about the Homorphus charm?


text:
Q: SQL realizando consulta errada Estou tentando identificar quais produtos do estoque atingiram a capacidade mínima ou estão abaixo dela.
Tentei da seguinte maneira:
SELECT * FROM produtos WHERE quantidade_minima <= quantidade

E obtenho o seguinte resultado:

Como podem ver quantidade é maior que quantidade_minima e ainda sim é avaliado como menor ou igual, o que pode esta causando esta avaliação errada?

A: acho que a query certa seria:
SELECT * FROM produtos WHERE quantidade <= quantidade_minima


text:
Q: How to explain that this is true or false?
How to explain this:
$ P(B\mid A)+P(B\mid A^c) ) = 1
$
Can anyone help me? I can't see how to explain this.
Thanks!

A: If $B$ is always true, then provided both $A$ and $\neg A$ happen with non-zero probability, the sum is $2 \not= 1$.

A: What you have written seems wrong. From total law of probability,
$P(B\lvert A)+P(B\lvert A^c)=P(B)$

A: Hint: Toss a fair coin once. Let $A$ be the event "head", and let $B$ be the event "neither head nor tail," or, if you prefer, "head or tail."
One can produce more complicated counterexamples.  For a mild variant, let $A$ be as before. Also roll a fair die, and let $B$ be the event the die shows a $6$.

A: $$
1-P(B|A)=\frac{P(A)-P(AB)}{P(A)}=\frac{P(AB^c)}{P(A)}=P(B^c|A)\ne P(B|A^c)
$$
So it should be
$$
P(B|A)+P(B^c|A)=1
$$


text:
Q: 'TypeError: 'builtin_function_or_method' object is not subscriptable' in binary searches For schoolwork I have to do binary searches, I followed the steps but I got the following error:

Traceback (most recent call last):   File "X:/Computer
  Science/Python/February 2018/25 02 18/binary searching.py", line 15,
  in
      end = aList.index[middle] TypeError: 'builtin_function_or_method' object is not subscriptable

Here is my code:
aList = [3,13,24,27,31,39,45,60,69]
end = len(aList) - 1
found = 0
start = 0

target = int(input("Please input the item you would like to search for:\t>"))
while start <= end and found == 0:
    middle = int((start + end) / 2)

    if aList[middle] == target:
        found = 1
        print(target , "is in the list.")

    if target < aList[middle]:
        end = aList.index[middle]
    else:
        start = aList.index[middle]
if found == 0:
    print("The search item was not found.")

A: See here In Python, what does it mean if an object is subscriptable or not?
and I paraphrase: "[to be subscriptable object must] implement the getitem() method"
index[middle] means "pull the value from dictionary index that has key equals to the value of variable middle"
Line 15 should look like as bellow - a function call:

end = aList.index(middle)


text:
Q: Laravel registration method do not give next available id to new user When a new user is registered through the registration form of Laravel framework, the id given to this new user is not the next id that exists in table users.
To give you an example, take a look to the next picture:

The id of the new registered user should be 6, and not 22.
What I assume is that for testing purposes I already have deleted some users from table users and that maybe the reason of the gap of ids.
Any ideas how to fix this?

A: Ids will not get reused, id column is using auto_increment by default
1 - user 1
2 - deleted
3 - deleted
4 - new user // new user will get id 4 not 2

if you manually delete users when doing your tests you should reset auto_increment
example with phpmyadmin

there is a AUTO_INCREMENT field you need to reset to the value you want


text:
Q: MSBuild.exe has stopped cmake error I was able to compile zlib yesterday with CMake but the only possible change was installing Windows 10 SDK 10.0.14393.33 and now that I configure it with the same choice (Visual Studio 14 2015 win64) I get the following error:

Any idea what could have gone wrong and how to fix it?
The C compiler identification is unknown
CMake Error: Could not find cmake module file: C:/Users/mona/playing-for-data/renderdoc/renderdoc/3rdparty/zlib/build /CMakeFiles/3.7.1/CMakeCCompiler.cmake
CMake Error at CMakeLists.txt:4 (project):
  No CMAKE_C_COMPILER could be found.

Configuring incomplete, errors occurred!
See also "C:/Users/mona/playing-for-data/renderdoc/renderdoc/3rdparty/zlib/build /CMakeFiles/CMakeOutput.log".
See also "C:/Users/mona/playing-for-data/renderdoc/renderdoc/3rdparty/zlib/build /CMakeFiles/CMakeError.log".

A: well, really weird but turns out you have to run CMake with right clicking on the executable and running it as admin. I am not sure if this is the correct solution but now it is working!!!

A: I had a similar problem (running CMake in admin mode does change the search PATH environment it runs in).
This problem is specific to msbuild and also does occur only in newer versions of CMake because the default build program was changed from devenv to msbuild.
What did help in my case was to put the following code in my VS toolchain file:
if (CMAKE_VS_DEVENV_COMMAND)
    set(CMAKE_MAKE_PROGRAM "${CMAKE_VS_DEVENV_COMMAND}" CACHE INTERNAL "")
endif()


text:
Q: using java native method I am creating a java program using native keyword.
class- HelloWorld.java is source code ,after compiling  , i generate a HelloWorld.h file.
and then in NetBeans I create  a c file , in which a include jni.h  header file
#include <jni.h>
#include <stdio.h>
#include "HelloWorld.h"

 JNIEXPORT void JNICALL
 Java_HelloWorld_print(JNIEnv *env, jobject obj)
 {
     printf("Hello World!\n");
     return;
 }

but when i buld the projet then this error come

HelloWorld.c:3:24: HelloWorld.h: No such file or directory
  HelloWorld.c:10:3: warning: no newline at end of file

i put the HelloWorld.h file in surce files  folder


text:
Q: Change icon on Navigation bar - Xamarin.Forms Android How can I set different icons in Xamarin.Forms - android.
One for the application, play store, user screen and other for the navigation page.
I updated Project.Droid/MainActivity.cs file:
[Activity(Label = "MyAppName", Icon =  "MyIconName", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]

But this way change two icons!!
Other way that I did, I updated ProjectForms/App.cs:
        Current.Resources = new ResourceDictionary();
        Current.Resources.Add("UlycesColor", Color.FromRgb(121, 248, 81));
        var navigationStyle = new Style(typeof(NavigationPage));
        var barTextColorSetter = new Setter { Property = NavigationPage.BarTextColorProperty, Value = Color.Black };
        var barBackgroundColorSetter = new Setter { Property = NavigationPage.BarBackgroundColorProperty, Value = Color.White };
        var barIcon = new Setter { Property = NavigationPage.IconProperty, Value = "newIcon.png" };

        navigationStyle.Setters.Add(barTextColorSetter);
        navigationStyle.Setters.Add(barBackgroundColorSetter);
        navigationStyle.Setters.Add(barIcon);
        Current.Resources.Add(navigationStyle);

But doesn't work!!
Any idea???

A: You could do it with custom renderer:
[assembly:ExportRenderer (typeof(NavigationPage), typeof(NavigationPageRenderer))]
namespace SuperForms.Samples.Droid
{
    public class NavigationPageRenderer : NavigationRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<NavigationPage> e)
        {
            base.OnElementChanged(e);

            var actionBar = ((Activity)Context).ActionBar;
            actionBar.SetIcon(Resource.Drawable.newIcon);
        }
    }
}

Add icon to Resources/drawable folder:

How it will looks:


text:
Q: R (ggplot) function to add an 'empty' row in an existing legend, split legend? I'm currently working on a plot. It's all coming together, but i'm wondering about one thing... I tried googling this, but I couldn't found what I was looking for.
Right now, I've created a legend that I liked. With 'scale_color_manual' and 'scale_size_manual', I've created a combined legend that includes the thickness of the corresponding line and the color. I have put the code I used below.
scale_color_manual(name = "combined legend",
                     labels = c("Nederland totaal", "Noord-Holland", "Utrecht", "Noord-Brabant", "Zuid-Holland", "Gelderland", "Flevoland", "Overijssel", "Limburg", "Drenthe", "Zeeland", "Friesland", "Groningen"),
                     values=c("#000000", "#001EFF", "#2ECC71","#FF009D","#00FFCD",
                              "#FF8400", "#8514EB", "#EB1A14", "#FFE100",
                              "#FF00AA", "#00AAFF", "#16A085", "#B903FC")) +

scale_size_manual(name = "combined legend",
                        labels = c("Nederland totaal", "Noord-Holland", "Utrecht", "Noord-Brabant", "Zuid-Holland", "Gelderland", "Flevoland", "Overijssel", "Limburg", "Drenthe", "Zeeland", "Friesland", "Groningen"),
                        values = c(1.75, 0.8, 0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8))

This is what the legend looks like right now

My question is: Is it possible to create a little bit of space between the first 'legend' part (so "Nederland totaal" and the other lines?).
I want it to look more like this

(I made this for clarification via word).
Is there a function to add some space between certain legend items? I hope somebody could help me :))
More detailed:
The dataset I'm working with, are the average yearly housing prices per Dutch province for 2005 until 2019. I created a ggplot, the current plot looks like this now. It is basically a ggplot with the year on the horizontal axis and the average housing price on the vertical axis. I have sorted the color by province, and added the black, thicker line that corresponds the total average of the netherlands (which I also put in the province vector). I used geom_line all of the legend items are factors. I hope this was clear enough, if not, let me know

A: Could this be applied to your data?
library(tidyverse)

tib <-
  tibble(x = 1:3,
         a = 1:3,
         b = 1.5:3.5,
         c = 2:4) %>%
  pivot_longer(cols = a:c, names_to = "id", values_to = "val")

ggplot()+
  geom_line(data = filter(tib, id == "a"), aes(x, val, linetype = id))+
  geom_line(data = filter(tib, id != "a"), aes(x, val, colour = id))+
  labs(linetype = "legend", colour = NULL)

Gives you:

A: One option is to use stat_summary.
This will add another aesthetic to the graph, and thus another legend, far apart from the other one.
airquality %>%
  mutate(Month=factor(Month)) %>%
  ggplot(aes(x=Day, y=Temp, col=Month)) +
  geom_line() +
  stat_summary(aes(lwd="Nederland totaal"), fun=mean, geom="line", col="black") +
  theme_classic() +
  theme(legend.title = element_blank()) +
  guides(lwd = guide_legend(order = 1))

But the benefit of this method is that you don't have to calculate the averages per year and manually add it to your Province variable.


text:
Q: ps ax showing process or not When I execute ps ax command with grep, it' showing a single entry of test.py
test.py was just single print statement submitted like this:
nohup python test.py &

So I'm assuming it didn't take long to run. Should that entry still be there?
$ ps ax | grep test.py
18225 pts/0    S+     0:00 grep test.py


text:
Q: How to avoid querying multiple times in serializer? I have a model story.rb with field product_ids. it is a Arrayof ids.
in story_controller show action I have to return a story with it's products and stores. I am returning response through story_serializer. like this
Note: story has no association with store
class StorySerializer < ActiveModel::Serializer
  ----
  ----
 def products
    here my query for products using `product_ids`
 end

 def stores
    here is the problem
    to find stores, I have to find product's first and then find store's of that product. so again I am querying for products here.
 end

end

I have product_ids so i can easily returns all the related products of that story, but the problem is to return related stores. How can I return store's without querying for products again. Any suggestions would be helpful.

A: You can use memoization:
def products
  @products ||= begin
    some code
    more code
   end
end

or if it is just a short piece of code
def products
  @products ||= some code
end


text:
Q: tomcat + servlet: buffer error while write cookie i have a servlet that retrieve some data from database, write result into cookie and sent it to client.
But while i'm debugging my code, i've occours in a strange error:
Servlet.service() for servlet [StoricoAcquisti] in context with path [/Serv] threw exception
org.apache.coyote.http11.HeadersTooLargeException: An attempt was made to write more data to the response headers than there was room available in the buffer. Increase maxHttpHeaderSize on the connector or write less data into the response headers.

How can i fix it? should i write much more than a cookie if data overflow ?


text:
Q: QuickSort not sorting properly I have a this program to receive a struct, store it and then sort it. I have tried to use Shell Sort, but then I went for the Quick Sort Algorithm. However, when I try to print the array after sorting, it still returns it unsorted. Bear in mind im trying to sort it by 'num_aluno'.
CODE
typedef struct ALUNO
{
char primeiro_nome[15];
char segundo_nome[15];
int num_aluno;
float nota;

}ALUNO;

void swap(ALUNO* a, ALUNO* b)
{
ALUNO t=*a;
*a=*b;
*b=t;
}
int partition(ALUNO *studentList, int low, int high)
{
int pivot= studentList[high].num_aluno;
int i=(low-1);
int j;

for(j=low;j<=high-1;j++)
{
    if(studentList[j].num_aluno<=pivot);
    {
        i++;
        swap(&studentList[i], &studentList[j]);
    }
}
swap(&studentList[i+1], &studentList[high]);
return(i+1);
}
void quickSort(ALUNO *studentList, int low, int high)
{
if(low<high)
{
    int pi=partition(studentList, low, high);

    quickSort(studentList, low, pi-1);
    quickSort(studentList, pi+1, high);
}
}

int main()
{
ALUNO *studentList=NULL;
int currentPos, studentListSize=1;
//float grade_sum=0;

studentList=(ALUNO*)calloc(studentList, studentListSize*sizeof(ALUNO));

printf("Insira o numero de alunos \n");
scanf("%d", &studentListSize);

studentList=(ALUNO*)realloc(studentList, studentListSize*sizeof(ALUNO));

for(currentPos=0;currentPos<studentListSize;currentPos++)
{
    newStudent(studentList, currentPos);
}

quickSort(studentList, 0, studentListSize);

for(currentPos=0;currentPos<studentListSize;currentPos++)
{
    printStudent(studentList,currentPos);
}

free(studentList);

return 0;
}

Any help would be appreciated

A: The reason it doesn't sort the list is, i and j are always the same value in the partition function.
You should start j from high -1, not from low.
Also, you are not considering the values of studentList[i]. You must guarantee that it is larger than pivot, otherwise there may be a value which is smaller than the pivot, yet at the left part of the array.
Here, corrected it.
    int partition(ALUNO*studentList, int low, int high)
{
    int pivot = studentList[high].num_aluno;
    int i=low ;
    int j;

    for(j=high-1;j>=i;)
    {
        while(studentList[i].num_aluno < pivot)
         i++;
        while(studentList[j].num_aluno > pivot)
         j--;

            if(i<=j){
            swap(&studentList[i], &studentList[j]);
            i++;
            j--;
            }

    }
    swap(&studentList[i], &studentList[high]);
    return(i+1);
}

An additional advice in case you have not heard of it, do not choose the first or last values as pivots. Instead, use the median of three strategy.
Median of three strategy: Pick the first, middle and last elements in the unsorted array. Change their locations according to their values in a sorted manner. Then take the middle value and use it as a pivot. This way you are avoiding the worst time complexity(O(n^2)) of QuickSort.


text:
Q: ruby / rails `rescue in debug=': (RuntimeError)
Possible Duplicate:
ruby_threadptr_data_type error

I am new to Ruby / Rails, and having issues getting my environment setup on Ubuntu 12.04. I'm using rbenv (not rvm). Here is how i'm installing ruby:
# clone rbenv and the ruby-build plugin
git clone git://github.com/sstephenson/rbenv.git .rbenv
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

# initialize rbenv
export PATH=~/.rbenv/bin:$PATH
rbenv init -

# install ruby 1.9.2
rbenv install 1.9.2-p320
rbenv rehash

# change ruby version to 1.9.2
rbenv global 1.9.2-p320

I am trying to run the following hello-world app:
  https://github.com/renderedtext/base-app
I am running the commands recommended on the website
bundle install
bundle exec rake db:setup db:test:prepare
bundle exec rake spec
bundle exec rake cucumber

It fails at bundle exec rake spec with the following error:
NOTICE:  CREATE TABLE will create implicit sequence "roles_id_seq" for serial column "roles.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "roles_pkey" for table "roles"
NOTICE:  CREATE TABLE will create implicit sequence "users_id_seq" for serial column "users.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "users_pkey" for table "users"
/home/ubuntu/.rbenv/versions/1.9.2-p320/bin/ruby -S rspec ./spec/models/role_spec.rb ./spec/models/user_spec.rb ./spec/controllers/admin/base_controller_spec.rb ./spec/controllers/admin/users_controller_spec.rb ./spec/controllers/pages_controller_spec.rb ./spec/helpers/pages_helper_spec.rb
No DRb server is running. Running in local process instead ...
/var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:422:in `rescue in debug=':  (RuntimeError)
**************************************************
/var/lib/gems/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so: undefined symbol: ruby_threadptr_data_type - /var/lib/gems/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so

If you have it installed as a ruby gem, then you need to either require
'rubygems' or configure the RUBYOPT environment variable with the value
'rubygems'.

/var/lib/gems/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `require'
/var/lib/gems/1.9.1/gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `<top (required)>'
/var/lib/gems/1.9.1/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `require'
/var/lib/gems/1.9.1/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `<top (required)>'
/var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:408:in `require'
/var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:408:in `debug='
/var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/configuration_options.rb:20:in `block in configure'
/var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/configuration_options.rb:19:in `each'
/var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/configuration_options.rb:19:in `configure'
/var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/command_line.rb:21:in `run'
/var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/runner.rb:66:in `rescue in run'
/var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/runner.rb:62:in `run'
/var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/runner.rb:10:in `block in autorun'
**************************************************
    from /var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:407:in `debug='
    from /var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/configuration_options.rb:20:in `block in configure'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/configuration_options.rb:19:in `each'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/configuration_options.rb:19:in `configure'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/command_line.rb:21:in `run'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/runner.rb:66:in `rescue in run'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/runner.rb:62:in `run'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/runner.rb:10:in `block in autorun'
rake aborted!
/home/ubuntu/.rbenv/versions/1.9.2-p320/bin/ruby -S rspec ./spec/models/role_spec.rb ./spec/models/user_spec.rb ./spec/controllers/admin/base_controller_spec.rb ./spec/controllers/admin/users_controller_spec.rb ./spec/controllers/pages_controller_spec.rb ./spec/helpers/pages_helper_spec.rb failed

Tasks: TOP => spec
(See full trace by running task with --trace)

It is also important to note that the server seems to already have ruby 1.9.1 installed (presumably using apt-get) but I would like to use 1.9.2 which is why I installed rbenv.
As a side note, I've also tried using rbenv with 1.9.3 and get the same error.
I tried to research and apply answers from other stack overflow questions (like ruby_threadptr_data_type error) but resulted in a segfault. Also, in my research most of the answers seemed to relate to rvm and 1.9.3 ... not rbenv and 1.9.2
Please help!

A: It seems like rspec couldn't load ruby-debug. Here's where it's happening if you're curious. You probably forgot to add require 'rubygems' in your spec_helper.rb. Do so and let me know if this fixed it.
UPDATE:
Try removing gem 'ruby-debug19' from Gemfile and replacing it with gem 'debugger' then run bundle in console and try again. ruby-debug19 is not maintained so this probably the cause. More about debugger. There's also link to ruby-debug19 installation instructions(if you feeling lucky).


text:
Q: Gaussian Elimination in Matlab I am using the matlab code from this book: http://books.google.com/books/about/Probability_Markov_chains_queues_and_sim.html?id=HdAQdzAjl60C
Here is the Code:
    function [pi] = GE(Q)

    A = Q';
    n = size(A);
    for i=1:n-1
      for j=i+1:n
         A(j,i) = -A(j,i)/A(i,i);
      end
         for j =i+1:n
            for k=i+1:n
        A(j,k) = A(j,k)+ A(j,i) * A(i,k);
         end
      end
      end

     x(n) = 1;
      for i = n-1:-1:1
        for j= i+1:n
          x(i) = x(i) + A(i,j)*x(j);
        end
       x(i) = -x(i)/A(i,i);
      end

      pi = x/norm(x,1);

Is there a faster code that I am not aware of? I am calling this functions millions of times, and it takes too much time.

A: MATLAB has a whole set of built-in linear algebra routines - type help slash, help lu or help chol to get started with a few of the common ways to efficiently solve linear equations in MATLAB.
Under the hood these functions are generally calling optimised LAPACK/BLAS library routines, which are generally the fastest way to do linear algebra in any programming language. Compared with a "slow" language like MATLAB it would not be unexpected if they were orders of magnitude faster than an m-file implementation.
Hope this helps.

A: Unless you are specifically looking to implement your own, you should use Matlab's backslash operator (mldivide) or, if you want the factors, lu. Note that mldivide can do more than Gaussian elimination (e.g., it does linear least squares, when appropriate).
The algorithms used by mldivide and lu are from C and Fortran libraries, and your own implementation in Matlab will never be as fast. If, however, you are determined to use your own implementation and want it to be faster, one option is to look for ways to vectorize your implementation (maybe start here).
One other thing to note: the implementation from the question does not do any pivoting, so its numerical stability will generally be worse than an implementation that does pivoting, and it will even fail for some nonsingular matrices.
Different variants of Gaussian elimination exist, but they are all O(n3) algorithms. If any one approach is better than another depends on your particular situation and is something you would need to investigate more.

A: function x = naiv_gauss(A,b);
n = length(b); x = zeros(n,1);
for k=1:n-1 % forward elimination
      for i=k+1:n
           xmult = A(i,k)/A(k,k);
           for j=k+1:n
             A(i,j) = A(i,j)-xmult*A(k,j);
           end
           b(i) = b(i)-xmult*b(k);
      end
end
 % back substitution
x(n) = b(n)/A(n,n);
for i=n-1:-1:1
   sum = b(i);
   for j=i+1:n
     sum = sum-A(i,j)*x(j);
   end
   x(i) = sum/A(i,i);
end
end

A: Let's assume Ax=d
Where A and d are known matrices.
We want to represent "A" as "LU" using "LU decomposition" function embedded in matlab thus:
LUx = d
This can be done in matlab following:
[L,U] = lu(A)
which in terms returns an upper triangular matrix in U and a permuted lower triangular matrix in L such that A = LU. Return value L is a product of lower triangular and permutation matrices. (https://www.mathworks.com/help/matlab/ref/lu.html)
Then if we assume Ly = d where y=Ux.
Since x is Unknown, thus y is unknown too, by knowing y we find x as follows:
y=L\d;
x=U\y
and the solution is stored in x.
This is the simplest way to solve system of linear equations providing that the matrices are not singular (i.e. the determinant of matrix A and d is not zero), otherwise, the quality of the solution would not be as good as expected and might yield wrong results.
if the matrices are singular thus cannot be inversed, another method should be used to solve the system of the linear equations.

A: For the naive approach (aka without row swapping) for an n by n matrix:
function A = naiveGauss(A)

% find's the size

n = size(A);
n = n(1);

B = zeros(n,1);

% We have 3 steps for a 4x4 matrix so we have
% n-1 steps for an nxn matrix
for k = 1 : n-1
    for i = k+1 : n
        % step 1: Create multiples that would make the top left 1
        % printf("multi = %d / %d\n", A(i,k), A(k,k), A(i,k)/A(k,k) )
        for j = k : n
            A(i,j) = A(i,j) - (A(i,k)/A(k,k)) *  A(k,j);
        end
        B(i) = B(i) - (A(i,k)/A(k,k))  * B(k);
    end
end

A: function Sol = GaussianElimination(A,b)

[i,j] = size(A);

for j = 1:i-1

    for i = j+1:i

        Sol(i,j) = Sol(i,:) -( Sol(i,j)/(Sol(j,j)*Sol(j,:)));

    end

end

disp(Sol);

end

A: I think you can use the matlab function rref:
[R,jb] = rref(A,tol)
It produces a matrix in reduced row echelon form.
In my case it wasn't the fastest solution.
The solution below was faster in my case by about 30 percent.
function C = gauss_elimination(A,B)
i = 1; % loop variable
X = [ A B ];
[ nX mX ] = size( X); % determining the size of matrix

while i <= nX % start of loop
    if X(i,i) == 0 % checking if the diagonal elements are zero or not
        disp('Diagonal element zero') % displaying the result if there exists zero
        return
    end
    X = elimination(X,i,i); % proceeding forward if diagonal elements are non-zero
    i = i +1;
end

C = X(:,mX);

function X = elimination(X,i,j)
% Pivoting (i,j) element of matrix X and eliminating other column
% elements to zero
[ nX mX ] = size( X);
a = X(i,j);
X(i,:) = X(i,:)/a;

for k =  1:nX % loop to find triangular form
    if k == i
        continue
    end
    X(k,:) = X(k,:) - X(i,:)*X(k,j);
end


text:
Q: Log in structure for iOS app Could somebody inform me if this is a proper way to implement a user session for an app:
If I have an iOS app where I want to provide certain functionality only to users who have logged in, and some other kind of functionality to users who haven't (say read vs. write functionality), then does the following architecture make sense...
1) I want to create global BOOL variable, e.g. loggedIn, that I can check against any time an app user wants to perform one of the functions under the "Authenticated-User-Only" list. I would like to know where to store this BOOL. Is NSUserDefaults best practice for storing a global boolean?
2) I'm trying to implement the Facebook iOS SDK, so when I return from a SSO with FB and the FB user has verified my app, can I then use that to set my global BOOL loggedIn to then be used throughout the app?
Thank you in advance.
Note -
This is all client-side, natively within the app. There are no webviews happening, the registry is going to query a server to return whether the user is valid or not.

A: Matt's answer is right-on for the existing SDK. I am adding some thoughts regarding the 3.0 revision (in beta now – and soon to be moved to the production branch.)
Derek, the scenario that you describe is common, and we wanted to make that case super simple to deal with in the SDK. In 3.0 we introduced FBSession to handle sessions. A single instance of FBSession handles a single user from login to logout.
Most applications only have a single user -- ever, so we also added a static method called activeSession, along with static helper methods to open the active session. (Note: the active session is not a singleton, because at different times in the execution of an application, a different instance of FBSession may be the active session.)
An application with authentication needs as straightforward as yours can generally do the following wherever you want to support a condition where you using Facebook Login optionally:
if (FBSession.activeSession.isOpen) {
    // perform an operation using the open FBSession.activeSession object
}

The BooleanOG sample application in the SDK shows an example of this pattern, where an action in the application also results in an open-graph post, but only if there is a currently active session with Facebook. Here is a link to the relevant line of code in the sample:
BOGFirstViewController.m
Hope this helps!

A: You could use a BOOL that's global, however that's more work then you'll have to do.
Instead, you can use the isSessionValid method that is provided by the Facebook iOS SDK to check if the user's session is valid.
To do this you can simply do the following in any classes that need this check to be performed:
YOURAPPDELEGATE *delegate = (YOURAPPDELEGATE*)[[UIApplication sharedApplication] delegate];

if ([appDelegate.facebook isSessionValid]) {  //Session is valid, facebook is the name of the instance of Facebook that is set in your app delegate, providing that's where you do the login handling, as per the tutorial on Facebook's developer site
    DO STUFF
}
else { //Session is NOT valid
    DO OTHER STUFF
}


text:
Q: Stripe, token is not generated on Live Server, on Local works fine as title i have a weird problem. I've tried to integrate Stripe payment gateway to my website, but the problem is token is not generated on Live Server while on Local Machine it works just fine...
My code:

/*index.php*/
<?php
  require_once('config.php');
?>

<form action="charge.php" method="post">

</form>

/*config.php*/

<?php
  require_once('stripe/init.php');

  $stripe = array(
    "secret_key"      => "sk_test_lcnCLz5lnSWPzhMRMOhjGcXD",
    "publishable_key" => "pk_test_KW35E5D3ShuLfvd60VHrRVJQ"
  );

  \Stripe\Stripe::setApiKey($stripe['secret_key']);
?>

/*charge.php*/

<?php
  require_once('config.php');

  $token  = $_POST['stripeToken'];
  $email  = $_POST['stripeEmail'];

  $customer = \Stripe\Customer::create(array(
      'email' => $email,
      'source'  => $token
  ));

  $charge = \Stripe\Charge::create(array(
      'customer' => $customer->id,
      'amount'   => 5000,
      'currency' => 'usd'
  ));

  echo '
Successfully charged $50.00!
';
?>


text:
Q: I have a problem when start apache on windows When I click start I get this error
2:30:55 PM  [Apache]    Problem detected!
2:30:55 PM  [Apache]    Port 80 in use by "Unable to open process" with PID 4!
2:30:55 PM  [Apache]    Apache WILL NOT start without the configured ports free!
2:30:55 PM  [Apache]    You need to uninstall/disable/reconfigure the blocking application
2:30:55 PM  [Apache]    or reconfigure Apache and the Control Panel to listen on a different port

A: open cmd in administrator mode and type this line
netstat -aon | findstr "80"

you will find pid of apps that use this port take that pid suppose we find pid 4 then type this line in cmd
tasklist /fi "pid eq 4"

you will get application name you can unistall this app or close
you can type in cmd
taskkill /PID 4 /F

also mostly 'Workstation' Services make trouble for port
you can stop through Services.msc and stopp 'Workstation' Services

A: Your port 80 is probably busy. What you can do is closing the service running on this port as Akram answered or, if you have to keep the port 80 free for something like node.js for exemple in my case or any other program, you can change the listening port in the Apache config files.
Go to XAMPP panel > Apache config button > httpd.conf
Then search for Listen 80 and edit it to Listen 8080 or Listen 8008.
/!\ Don't assign any other port than HTTP provided ones, you could have conflict between your services /!\
Remember that you'll have to change the address in the browser to access the server, for exemple http://localhost:8080 if you switched port to 8080.


text:
Q: Flutter: add flavors configuration into Visual Studio My flutter application has different flavors.
In Android Studio everything is setup in the flavor configuration panel, but where can I do that in Visual Studio Code?
I guess I have to edit the configuration.json but I cant find any reference online on how to do it.
I do not want every time to type flutter run --flavor app1 -t lib/main_app1.dart

A: You have to edit your launch.json file
{
            "name": "dev", // you can add nickname for it
            "request": "launch",
            "type": "dart",
            "args": [
                "--flavor", //flavor name
                "dev",
                "-t", // if your have different main file
                "lib/main_dev.dart"
            ]
},

A: You can pass additional arguments using a launch.json. If you don't already have one, click the Cog icon in the Debug sidebar and then select Flutter in the snippet-completion list. You can then add an args section, like this:
{
    "name": "Flutter",
    "request": "launch",
    "type": "flutter",
    "args": [
        "--flavor",
        "app1"
    ]
}

A: {
  "name": "App Dev",
  "cwd": ".",
  "request": "launch",
  "type": "dart",
  "flutterMode": "debug",
  "program": "lib/main_dev.dart",
  "args": ["--flavor", "dev"],
}


text:
Q: Cant install ziproxy I am trying to install ziproxy (http://packages.ubuntu.com/lucid/ziproxy) (http://ziproxy.sourceforge.net/download.html) using
apt-get install zizproxy but im getting this error below.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package ziproxy is not available, but is reffered to by another package.
This may mean that the package is missing, has ben obsoleted, or is only available from another source.

Why is this happening and how can i get around this or install it? It says i should be able to install using `apt-get install zizproxy i tried sudo apt-get install zizproxy and it still didnt work.

A: Make sure that the Universe repo is enabled, and try the same command again:

sudo apt-get install ziproxy

Or download from Source.
To enable Universe Repo from command line, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:
sudo gedit /etc/apt/sources.list

Once the file opens, make sure the lines below are in there, otherwise; add them in
deb http://us.archive.ubuntu.com/ubuntu/ precise universe
deb-src http://us.archive.ubuntu.com/ubuntu/ precise universe
deb http://us.archive.ubuntu.com/ubuntu/ precise-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates universe

Then do
sudo apt-get update

Then install ziproxy.


text:
Q: select all textarea which does NOT have a certain class in Jquery I have several textareas like:
<asp:textbox class="input ThisIsRussia" ..... />
<asp:textbox class="input" ..... />
<asp:textbox class="input ThisIsSparta" ..... />
<asp:textbox class="input" ..... />

Now, I have to select all the textarea / textbox which does not have the class "ThisIsSparta", how do I do it?
I was checking the Jquery selectors website and it said I have to uses
[name!=value]

for this purpose, but when I did this:
$('textarea[class!=ThisIsSparta]').SlideUp();

it was affecting my spartan textarea too!
Am I missing something?

A: $('textarea').not('.ThisIsSparta');


text:
Q: Specific Term for prejudice/prejudiced behaviour (racial, gender, etc...) that justifies itself by a prior history of prejudice? If someone made the following, certainly problematic, statements:
"There is a higher risk (member of oppressed minority) will underperform at a job or task, since it is more likely they are traumatized or disenfranchised by prejudice and/or poor treatment they have suffered in the past."
"(Member of oppressed minority) cannot be trusted, since there is an above average likelihood they will harbor mistrust or resentment due to being treated poorly before."
Is there a specific term for this kind of thinking/prejudiced behaviour - which can easily lead to a factually racist or other anti-minority outcome, WITHOUT a need for the person making that kind of judgement to be themselves categorically racist or against the minority in question?

A: OED:

institutional racism  n. discrimination or unequal treatment on the basis of membership of a particular racial or ethnic group (typically one that is a minority or marginalized), arising from systems, structures, or expectations that have become established within society or an institution.
1967   S. Carmichael & C. V. Hamilton Black Power 4   When..thousands more [black children] are destroyed and maimed physically, emotionally, and intellectually because of conditions of poverty and discrimination in the black community, that is a function of institutional racism... It is institutional racism that keeps black people locked in dilapidated slum tenements.

There is also the slightly different
Systemic racism n. discrimination or unequal treatment on the basis of membership of a particular racial or ethnic group (typically one that is a minority or marginalized), arising from systems, structures, or expectations that have become established within society or an institution.

1968   L. P. Zimmer in M. Boyd Underground Church ii. 29   I am pretty well aware of..my increasingly forceful abhorrence of war, police brutality, corrupt politics, systemic racism, and money-grubbing religious structures.

and
institutionalized racism which suggests more a growth of racism within a body and which is considered acceptable by its members.

A: This might be described as self-fulfilling prophecy, as "self-fulfilling bias", or as "confirmation bias". I regret that I cannot think of a shorter term or a single word. It will be interesting to read what others say.
confirmation bias may be slightly too strong for what you describe because it often related to underlying desire rather than casual behaviour.
Psychology Today: Once we have formed a view, we embrace information that confirms that view while ignoring, or rejecting, information that casts doubt on it. Confirmation bias suggests that we don't perceive circumstances objectively.


text:
Q: Compare grid predictions I am interested in methods to compare "predictions" of an inhomogeneous Poisson process, against "sparse" data.
The model I have is that of inhomogeneous Poisson process, say on the unit square $[0,1]^2$, with intensity function $I(x,y)$.  We can factor $I$ as $I(x,y) = \mu f(x,y)$ where $\mu$ is the overall rate of the process (which I am not so interested in) and $f$ is a probability density.
I have various methods which produce a finite probability distribution in the form of a grid / matrix of size $N\times M$ say.  The value in cell $(i,j)$ is meant to be an estimate of the integral of $f$ over that cell.
I then wish to "score" these predictions against a realisation of the process, say points $(x_i, y_i)_{i=1}^n$.  Typically $n$ is small, much smaller than $NM$.
I don't really know how to go about this:

*

*Should I bin points, assigning $(x_i, y_i)$ to the cell it occurs in?  That would seem to lose information for an event which occurs near the boundary of a cell.

*I could take a Bayesian approach, perhaps, and compute Bayes Factors.  This is the same as computing likelihoods in this case.  This doesn't seem to take much account of the geometry of the problem.


text:
Q: Add 0's to the end of an integer for(i=0; i<array.length; i++){
  sum = 4 * 5;
}

What I'm trying to do is add ((array.length - 1) - i) 0's to the value of sum. For this example assume array length is 3. sum equals 20. So for the first iteration of the loop i want to add ((3 - 1) - 0) 0's to the value of sum, so sum would be 2000. The next iteration would be ((3 - 1) - 1) 0's. so sum would equal 200 and so on. I hope what I am trying to achieve is clear.
So my questions are:
Is it possible to just shift an int to add extra digits? My search thus far suggests it is not.
If not, how can i achieve my desired goal?
Thankyou for reading my question and any help would be greatly apreciated.

A: You can just multiply it by 10 however many times.
200 * 10 = 2000

etc
So in your case, you'd have to use a for loop until the end of the array and multiply sum every iteration. Be careful though, because the max value of an int is 2^31, so it of surpasses that, it will roll back to 0

A: You can add n zeroes to the end of a number, sum by multiplying sum by 10 * n.
int sum = 20;
for (int i = 0; i < ary.length; ++i) {
    int zeroesToAdd = ary.length - 1 - i
    sum *= (zeroesToAdd > 0) ? zeroesToAdd * 10 : 1
}
System.out.println("Sum after loop: " + sum);

A: for(int i=array.length; i>0; i--){
  sum = 20;
  for(int j=0; j < (i - 1); j++)
  {
     sum *= 10;
  }
}

Use inner loop to multiply by 10 the number of times i is for that iteration. You would need to reset sum in your outer loop each time.

A: Multiply by 10 instead, and use < (not >) like
int sum = 20;
int[] array = { 1, 2, 3 };
for (int i = 0; i < array.length; i++) {
    int powSum = sum;
    for (int j = array.length - 1; j > i; j--) {
        powSum *= 10;
    }
    System.out.println(powSum);
}

Output is (as requested)
2000
200
20

A: *

*You will want to check your for-loop condition: i>array.length. Since i starts at 0, this loop will not run unless the array's length is also 0 (an empty array). The correct condition is i < array.length.

*This "shift" you want can be achieved by creating a temporary variable inside the loop that is equal to the sum times 10i. In Java's Math library, there is a pow(a,b) function that computes ab. With that in mind, what you want is something like this:

int oldSum = 4 * 5;

for (int i = 0; i < array.length; i++) {
    int newSum = oldSum * Math.pow(10,i);
}

A: For array of length = n; you will end up adding (n - 1) + (n - 2) + ... + 2 + 1 + 0 zeros for i = 0, 1, ... n-2, n-1 respectively.
Therefore, number of zeros to append (z) = n * (n-1) / 2
So the answer is sum * (10 ^ z)
[EDIT]
The above can be used to find the answer after N iteration. (I miss read the question)
int n = array.length;
long sum = 20;
long pow = Math.pow(10, n-1); // for i = 0
for (int i = 0; i < n; i++) {
    System.out.println(sum*pow);
    pow /= 10;
}


text:
Q: State in OpenGL This is some simple code that draws to the screen.
GLuint vbo;

glGenBuffers(1, &vbo);

glUseProgram(myProgram);

glBindBuffer(GL_ARRAY_BUFFER, vbo);

glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);

//Fill up my VBO with vertex data
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexes), &vertexes, GL_STATIC_DRAW);

/*Draw to the screen*/

This works fine. However, I tried changing the order of some GL calls like so:
GLuint vbo;

glGenBuffers(1, &vbo);

glUseProgram(myProgram);

glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);

//Now comes after the setting of the vertex attributes.
glBindBuffer(GL_ARRAY_BUFFER, vbo);

//Fill up my VBO with vertex data
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexes), &vertexes, GL_STATIC_DRAW);

/*Draw to the screen*/

This crashes my program. Why does there need to be a VBO bound to GL_ARRAY_BUFFER while I'm just setting up vertex attributes? To me, what glVertexAttribPointer does is just set up the format of vertexes that OpenGL will eventually use to draw things. It is not specific to any VBO. Thus, if multiple VBOs wanted to use the same vertex format, you would not need to format the vertexes in the VBO again.

A: I believe that's because the last argument to glVertexAttribPointer is pointer which is an offset into a the VBO after glBindBuffer(nonzero) but when a VBO is not bound it's supposed to be a pointer to an actual array of data.  So if you weren't using VBOs at all the last argument would be &vertexes and it wouldn't crash.

A:
Why does there need to be a VBO bound to GL_ARRAY_BUFFER while I'm just setting up vertex attributes?

No, you're not "just" setting up vertex attributes. You're actually creating a reference with the currently bound buffer object.
If there's no buffer object bound, then gl…Pointer will create a reference to your process address space pointed at the given address. Since this is a null pointer in your case, any attempt to dereference a vertex will cause a segmentation fault/access violation.

To me, what glVertexAttribPointer does is just set up the format of vertexes that OpenGL will eventually use to draw things.

No. It also creates a reference to where to get the data from.

It is not specific to any VBO.

Yes it actually is specific to the bound VBO, or the process address space if no VBO is bound. And changing the buffer binding will not update along the gl…Pointer references.


text:
Q: How to upload multiple file in one form Interface
I have a few file upload, then how to upload all the file only for input that have files.
DO i need to upload one by one or push all in one array, then save the data using the array.
any suggestion ?


text:
Q: iOS Simulator - offline mode Does anybody know how to make the iPhone/iPad simulator become offline?
Regards!

A: If you set os x offline, the iPad simulator will be offline. Otherwise, no.

A: There's a tool called "Network Link Conditioner" but it seems that its only for OX Lion and xCode 4.1+ installed. Take look at: http://osxdaily.com/2011/08/10/simulate-internet-connectivity-bandwidth-speeds-network-link-conditioner/ - i use it almost everyday :)

A: Install Network Link Conditioner from Apple. And you will have possibility to change to offline mode.

A: Install Little Snitch and temporarily block all connections from iOS Simulator when the dialog comes up.

A: If you want to test something in the local environment like a web app for iOS with cached features, you can add a rule to your hosts file pointing to your localhost, then you can comment the line every time you desire to make it inaccessible.

A: Ideally, all app's network communication goes through one point. By commenting out a relevant code or creating a dummy error it's rather straightforward to make it look like all the responses have timed out.
[[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
//          if (error) {
              if (self.delegate) {
                  [self.delegate networkError: error];
              }
//          } else {

I find it good enough for the actual development. It's quick and cheap, even if a bit dirty, while allowing to continue working without the hassle of a constant WiFi toggling. Once successfully enabled, even pretty specific scenarios are easy to simulate.
When the work is finished, turning off macOS WiFi for the final testing is a good idea, though.

A: On macos, turning off wifi and plugging your phone with USB hotspot mode on works a treat.
Simple and reliable for everything including testing reachability.


text:
Q: Converting from Java to C++. Why can't I use methods of a different class the same way in C++? I'm trying to convert a Java program to C++. This is the Java code (which IS working perfectly):
//class MyProgram:

public class MyProgram {
    private static ArrayList mylist;
    //no constructor
    public static int numberOfItems(){
        return mylist.size();
    }
}

//second Java program, MyList

public class MyList {
    public MyList(){
        for (int i = 0; i < MyProgram.numberOfItems; i++)
            System.out.println("Test");
    }
}

This works exactly as I'd hope. However, when converting to C++, the for loop header is giving me errors because it doesn't recognize numberOfItems. The implementation is exactly the same, except a vector instead of an arraylist. My question is: why does not NOT work in C++? Why DOES it work in Java? I've never written an object before where I didn't have to call the constructor to use the methods of that class. How can I achieve this same thing in c++? I can post the c++ code but it looks extremely similar and it seems pointless.

EDIT: C++ CODE:
//MyProgram.h

#ifndef MYPROGRAM_H_
#define MYPROGRAM_H_

 #include <vector>

namespace std;

class MyProgram {
public:

    int numberOfItems();

private:
    vector<Checkpoint> mylist;

};

#endif /* MYPROGRAM_H_ */

//MyProgram.cpp

#include "MyProgram.h"

int MyProgram::numberOfItems()
{
    return mylist.size();
}

//MyList.h:

#ifndef MYLIST_H_
#define MYLIST_H_

#include <vector>

using namespace std;

class MyList {
public:
    MyList();
    virtual ~MyList();
private:
    vector<Checkpoint> path;

};

#endif /* MYLIST_H_ */

//mylist.cpp

#include "MyList.h"

MyList::MyList()
{
    int i;
    for(i = 0; i < MyProgram.numberOfItems(); i++)
    {
        path.push_back(0);
    }
}

A: change MyProgram.numberOfItems to MyProgram::numberOfItems()

A: So, you have a misunderstanding of is a class member vs object member. This post will provide you the information that you really need:
When do I use a dot, arrow, or double colon to refer to members of a class in C++?.
Also, like frinji1 said, MyProgram::numberOfItems() is what you want.


text:
Q: Evaluating the "Value" Attribute I'm attempting to use the OpenAmplify API to evaluate the content of a URI. The point is to draw out the topics that are truly relevant to the article. Unfortunately, the topical analysis I'm getting back is:

*

*Huge, and

*Varied

Neither quality is terribly useful for what I'm trying to do because the signal to noise ratio is being heavily skewed towards noise. I'm analyzing web content, so there is a certain amount (perhaps a large amount) of irrelevant content (ads, etc.) involved. I get that.
Nonetheless, many of the topics being returned are either useless (utterly non-sensical, not even words), irrelevant (as in, where did that come from?) or too granular to provide any meaning or insight. I can probably filter out most of this noise using the value, um, value that is returned for each domain, subdomain, topic, et al, but I don't really know what it means.
Certainly I understand that the value it's a measure of "the prominence of the word in the text," but the number itself appears entirely arbitrary in a way that I prevents me saying something like "ignore any terms with a value less than 50" and have it carry any real meaning.
Are there any range criteria that I can use to help me understand how to use a topic's value score as a filtering threshold? Alternatively, is there another field that I should be using for this sort of filtration?
Thanks for your help.

A: From other channels, I've learned that the value attribute can't be evaluated the way I was hoping. It means different things for different signals and none are defined in such a way that are meaningful for this kind of requirement.


text:
Q: Where is the error in my calculation for a simple bosonic system? $ \newcommand{\ket}[1]{\left|#1\right\rangle}
$I was doing some calculations and I came across something that confused me and maybe you can explain to me where my reasoning is wrong. Let's say I have some bosonic systems described by the tensor product of four independent states:
$$ \ket{\psi} = \ket{n_1} \otimes \ket{n_2} \otimes \ket{n_3} \otimes \ket{n_3} \tag{1}\label{1}$$
The vacuum state is of course
$$ \ket{\varnothing} = \ket{0} \otimes \ket{0} \otimes \ket{0} \otimes \ket{0} \tag{2}\label{2}$$
Let's define some composite operator
$$ \hat{A}=\sum_i \hat{a}_i \tag{3}\label{3}$$
where $\hat{a}_i$ is the annihilation operator for the $i$-th state of the tensor product. The action of the adjunct of the operator $(\ref{3})$ onto the vacuum state $(\ref{2})$ is
$$ \begin{align}
\hat{A}^\dagger\ket{\varnothing}&= \ket{1} \otimes \ket{0} \otimes \ket{0} \otimes \ket{0} \\
&\quad+\ket{0} \otimes \ket{1} \otimes \ket{0} \otimes \ket{0} \\
&\quad+\ket{0} \otimes \ket{0} \otimes \ket{1} \otimes \ket{0} \\
&\quad+\ket{0} \otimes \ket{0} \otimes \ket{0} \otimes \ket{1} \tag{4a}\label{4a}\\
&=\ket{\psi} \otimes \ket{\psi} \otimes \ket{\psi} \otimes \ket{\psi} \tag{4b}\label{4b}
\end{align}$$
where
$$ \ket{\psi} = \ket{1} + 3\ket{0} \tag{5}$$
Now, repeating this identical for the operator $(\ref{3})$ as written results in
$$ \begin{align}
\hat{A}\ket{\varnothing}&= 0 \otimes \ket{0} \otimes \ket{0} \otimes \ket{0} \\
&\quad+\ket{0} \otimes 0 \otimes \ket{0} \otimes \ket{0} \\
&\quad+\ket{0} \otimes \ket{0} \otimes 0 \otimes \ket{0} \\
&\quad+\ket{0} \otimes \ket{0} \otimes \ket{0} \otimes 0 \tag{6a}\label{6a}\\
&=\ket{\psi} \otimes \ket{\psi} \otimes \ket{\psi} \otimes \ket{\psi} \tag{6b}\label{6b}
\end{align}$$
where
$$ \ket{\psi} = 3\ket{0} \tag{7}$$
which is obviously not correct, since the result should be the zero-vector. Where is my mistake? Is the step from $(\ref{4a})$ to $(\ref{4b})$ actually allowed? Clearly, for $(\ref{6a})$ to $(\ref{6b})$ this cannot be the case.

A: Each term in eq. (6a) is multiplied by zero (not the $\vert 0 \rangle$ vector, but the number zero). Therefore the whole is identically zero (the number again).
I also do not agree with result (4b). The fourfold tensor product of the given $\vert \psi \rangle$ (5) contains a term $\vert 1,1,1,1 \rangle$ which is clearly absent from (4a).


text:
Q: A Scheme procedure that returns the largest index used in a program L Say I have a program defined:
(define myprog
  (a-program
   (list (labeled 'A12 (add1 'X)) (unlabeled (sub1 'Y4)))))

I want to write a procedure to find the largest index used in the above program.
A test case would be like:
>(max-index myprog);myprog is the program defined above
12
;this is from A12 because its the largest index used.

I know that scheme has a built in function that finds the largest element in a list like
(max 3 5 9)
would give me 9
but in my case, I understand that I would have to parse my program and also consider omitted indices will correspond to 1; X corresponds to X1.
I can write a function that does this easily in lists but not a 'program'.
If someone could tell me what should I first look at, that'll be helpful.
Thanks.

A: "A Program" in the sense defined in your question is a list of lists, and nothing else. If you know how to write a function that does what you need for "a list" please post it here, you'll see that it works for "a program" too.


text:
Q: Better way to dynamically create HTML form I need to dynamically create HTML form. So I can to it using 2 approaches:
1) Use JS to create form
  var myId = document.createElement("input");
  myId.setAttribute("type", "hidden");
  myId.setAttribute("name", "myId" + index);
  myForm.appendChild(myId);

and so on..
2) Use innerHTML and writing valid HTML code:
    document.getElementById("myForm").innerHTML +=
'<input type="hidden" name="myId' + index + '"/>';

What approach is better? What is usually way to dynamically create form? For me second approach is more readable

A: Creating dynamic forms by concatenating string in javascript becomes unmanageable as the HTML size begins to grow.
The recommended approach is to use a template engine to create dynamic HTMLs.
Handlebars.js is one of the more popular template engines out there.
There's also a site that helps you choose a template engine for your need.

A: second approach is the best because it gives you the possibility to verify the exact composition of the page. at least in my opinion.


text:
Q: Write formula to cell does not accept sys decimal separator / Reginal Format / Excel VBA The sample code below runs fine if windows is in USFormat (decimal = point) but breaks when ran in Dutch format (decimal=comma).
Why?
Is there a way to write the formula to a cell in comma-decimal format that does not require replacing each comma back to point?
Sub TestHandleRegionalFormat()

    SourceData = "-.1"

    Application.UseSystemSeparators = True
    ActiveSheet.Cells(1, 2) = GetDecimalSeparator
    ActiveSheet.Cells(2, 2) = Application.DecimalSeparator

    If GetDecimalSeparator = "," Then SourceData = Replace(SourceData, ".", ",")

    ActiveSheet.Cells(3, 2) = SourceData + 1000

    ActiveSheet.Cells(4, 2) = "=" & SourceData & "+1000"

End Sub
Public Function GetDecimalSeparator()
    'http://stackoverflow.com/a/32992918/4797660
    GetDecimalSeparator = Mid(Format(1000, "#,##0.00"), 6, 1)

End Function

USFormat output

DutchFormat output

A: You're trying to set the formula of the cell using the default property of the Range returned by .Cells(4, 2), which is .Value.  To set a cell to a formula using the current system locale, you need to use the FormulaLocal property instead.
This should work:
ActiveSheet.Cells(4, 2).FormulaLocal = "=" & SourceData & "+1000"


text:
Q: storing values from calc function as a variable in scss Hello there fellow coders,
I'm just starting out with SCSS; which is beyond awesome! There is one question I have regarding variables. I am wanting to calculate the width of divs plus it's padding, margins, and borders within a navigation element. I am then wanting to pass that calculated width into a variable like this:
$numbDivs:       4;
$divWidth:       150px;
$divPadd:        10px;
$divBorderWidth: 1px;
$divMarg:        2px;

$navBreakPoint:  calc( #{$numbDivs} * ( #{$divWidth} + ( ( #{$divPadd} + #{$divBorderWidth} + #{$divMarg} ) * 2 ) ) );

I've enen tried it without the #{} portion, and that didn't work.
It might just be that scss doesn't support this...but it would be nice.
Thanks for all of y'all's posts.

A: calc() is a function of CSS, not Sass.  If you want to store the result as a variable, drop the string interpolation and just calculate it:
$navBreakPoint:  $numbDivs * ($divWidth + (($divPadd + $divBorderWidth + $divMarg) * 2));

It is worth noting that calc() does not worked in combination with media queries (see: calc() not working within media queries)