How to respond to memory pressure notifications from GCD?

Question: I am using GCD to get memory pressure notifications.
GCD documentation describes some constants like so:

DISPATCH_MEMORYPRESSURE_WARN
The system memory pressure condition is at the warning stage. Apps
  should release memory that they do not need right now.
DISPATCH_MEMORYPRESSURE_CRITICAL
The system memory pressure condition is at the critical stage. Apps
  should release as much memory as possible.

Seems logical that I should free unused memory. However, in other places (man pages and source code) I find this note related to these constants:

Elevated memory pressure is a system-wide condition that applications
  registered for this source should react to by changing their future
  memory use behavior, e.g. by reducing cache sizes of newly initiated
  operations until memory pressure returns back to normal.
However, applications should NOT traverse and discard existing caches
  for past operations when the system system tem memory pressure enters
  an elevated state, as that is likely to trigger VM operations that
  will further further ther aggravate system memory pressure.

This confuses me. So should I free memory, or should I just stop allocating new memory?
Answer: MacOS has a virtual memory (VM) system that uses a backing store: the file system. The file system is used to hold memory that is not currently in use. When the system is running low on real memory (RAM), things in memory that are not actively being used can be written to disk and loaded back into RAM later.
iOS has a virtual memory system but not a backing store. When memory runs low the system asks apps to lower their memory footprint. If that does not free up enough memory the system will start killing apps.
The guidance you are quoting from the libdispatch headers is referring to the MacOS virtual memory system, not iOS.
On iOS an application should discard objects and reduce cache sizes when handling a memory warning. Particular attention should be paid to objects that are using dirty (non-purgeable) memory. This is memory the system can not automatically reuse on its own - it must be discarded by the application first. In a typical iOS application images (pictures) use the most dirty memory.


The demise of PDAs and the increase in size of smartphone screens

Question: I remember the brief period of time when PDAs were touted as the next big thing in the technosphere, and then as quickly as they arrived on the market they disappeared as smaller, slimmer and more powerful phones quickly became the next big thing. I don't remember reading too much of the commentary around the demise of the PDAs, but I do recall comments such as being too large and cumbersome as well as trying to pack too much functions and features being some of the factors that contributed to its downfall.
I was wondering if anyone has read studies or analysis on why PDAs didn't work out the way marketers thought it would, especially given that smartphones now are trending towards being larger and even more feature packed. Is it just timing or perhaps the invention of tablets and netbooks also had something to do with people accepting larger size smartphones?
Comment: PDA + cellphone + pager + camera + DMP (i-Pod) + game console (Gameboy) + GPS – keys ≈ smartphone
Answer: PDAs were very succesful and worked out just fine.
A smart phone is simply a phone that's also a PDA. PDAs never went anywhere. They just turned into phones.
As for sizes, the PDAs I used to use are about the same physical size as the Android and Apple phones out there today. I don't think size was a particular issue.
Comment: @Chop I guess the point of my answer was to refute the premise of the question. PDAs *were* succesful and there wasn't a demise of the PDA...the PDA simply morphed into the smart phone.
Comment: @chop phones today *are* PDAs. The Palm Pilots were a bit larger but not excessively so.
Comment: Did you get PDAs as slim as smartphones? Those I had or saw (two or three) were not cumbersome due to their screen size, but to all the rest: thick, large prominent borders around the screen, requirement of stylus (that was an argument Apple used to advertise the iPhone, until they announced the ApplePencil...), ... And obviously, the UX of the late Windows for those was adapted to that era. I don't think it would have much success now that we are grown accustomed to the UX of our smartphone OSs.
Comment: OK. I inherited one PDA from my father, but it was considerably thicker. The screen border was thick too. It was not comfortable to have it in the pocket, while I have no problem sliding a phone into it. When I saw for the first time a BlackBerry, I thought of PDAs indeed, but I was under the impression that today's phones were slimmer (though matching PDAs in "horizontal" dimensions). The UX of OSs have changed, that is undeniable, and that may be an element of answer too (PDAs were perceived as professional tools, while smartphones were designed to be sale-successes).
Comment: OK, that I fully agree with.
Answer: The entry into the market was not at the right time. Due to hardware constraints of the time period, innovative software was not able to run properly on PDA'S. Having too large of a device was annoying for users to deal with. Companies were also not clear on their target market. They should have focused on developing the technology to run on top of their product before building the whole product. Cell phones such as the iPhone came in at just the right time and thus gained huge market share.
Comment: Palm sold over 30 million palm pilots. That's not too shabby for the era. It wasn't a timing issue as much as it was simply a small market window...that period where hand held technology became affordable, but right before cell phones became 'smart'.


I use koa,koa-router,koa-body in my program.But the value of this.reauest.body is "{}"

Question: I use "form" to send data to my webserver.
front-end:
<form action="http://localhost:3131/users" method="POST" enctype="multipart/form-data" target="_blank">
    <fieldset>
        Name:
        <input type="text" id="name" name="name"/>
    </fieldset>
    <fieldset>
        Age:
        <input type="text" id="age" name="age"/>
    </fieldset>
    <fieldset>
        Wl:
        <input type="text" id="wl" name="wl"/>
    </fieldset>
    <fieldset>
        <input type="submit" value="Submit"/>
    </fieldset>
</form>

back-end code,
Github link:
var app     = require('koa')(),
router  = require('koa-router')(),
koaBody = require('koa-body')();

router.post('/users', koaBody,
  function *(next) {
    console.log(this.request.body);
    // => POST body
    this.body = JSON.stringify(this.request.body);
  }
);

app.use(router.routes());

app.listen(3131);
console.log('curl -i http://localhost:3131/users -d "name=test"');

But the result is --> this.request.body is {}.
What am i doing wrong?
Answer: You are using multipart/form-data as your form data encoding, so in your server code you should pass the correct option to koa-body constructor.
kaoBody = require('koa-body)({ multipart: true });

Comment: Thank you ! now--> {"fields":{"name":"qq","age":"dd","wl":"dd"},"files":{}}


Why would Type.GetType() work and Assembly.GetType() not work?

Question: I'm trying to locate a type at runtime from a list of assemblies; my code is something like this:
foreach (Assembly assembly in assembliesToSearch)
{
    Type t = assembly.GetType(assemblyName);
    if (t != null)
    {
        return t;
    }
}

, and the problem that I have is that t is always coming up as null. Playing around with the debugger and the Intermediate window in VS2010, I noticed the following when I put a breakpoint inside the loop:
Type.GetType(typeof(MyNamespace.MyClass).AssemblyQualifiedName)

works OK, but
assembly.GetType(typeof(MyNamespace.MyClass).AssemblyQualifiedName)

does not (when assembly is the assembly that I know contains the class I'm looking for - in the debugger, I can put a watch on assembly.GetTypes(), browse to the class I'm trying to instantiate, and call assembly.GetType("MyNamespace.MyClass, MyNamespace")).
Does anyone know why searching all assemblies using Type.GetType() works, but searching the assembly that I know contains the type using assembly.GetType() does not?
Answer: From the MSDN docs for the two methods, Type.GetType() expects an assembly-qualified name of a type whereas Assembly.GetType() expects the full name of the type. These are not the same thing.
typeof(MyNamespace.MyClass).AssemblyQualifiedName evaluates to an assembly-qualified name of a type (something like MyNamespace.MyClass, MyAssembly, Version=220.127.116.11, Culture=neutral), so it does not work with the Assembly.GetType() call which is expecting a string in the format MyNamespace.MyClass.
This is probably down to the fact that when you pass the assembly-qualified name to the Assembly.GetType() call, it is looking for a type in the assembly whose full name matches what you have supplied. It cannot find one, so you get a null returned. This is not the case with the Type.GetType() call as it expects to get an assembly-qualified name of a type and can locate both the assembly and the type.

Something to note:
If you are "trying to locate a type at runtime from a list of assemblies" as you say, you are probably better off using the Assembly.GetType() call on each assembly in the list and passing in the type's full name. Type.GetType() will most likely be using the references of the currently assembly to resolve the type, so if the type exists in an assembly that is not a reference, it will not be found.
Comment: Thanks for the response; my initial code sample doesn't show it clearly, but inside my loop where I'm calling Type t = assembly.GetType(assemblyName), assemblyName is "MyNamespace.MyClass, MyAssembly", so by my reckoning, it ought to be returning the expect Type.
Comment: @David: `MyNamespace.MyClass, MyAssembly` is still an assembly-qualified type name. You need to drop the assembly name from that string for it to work with `Assembly.GetType()`.
Comment: @adrianbanks - where did you learn "Type.GetType() will most likely be using the references of the currently assembly to resolve the type" - it doesn't seem to be in the [MSDN here](http://msdn.microsoft.com/en-us/library/w3f99sx1(v=vs.110).aspx).  Also, what is the "current assembly"?  In the case I'm looking at now, the assembly with the type - which is found! - isn't the assembly with the currently executed method and isn't a reference of it ... but it _is_ an assembly on the call stack.  (The reason for my question: The Version in my assembly name is wrong but the type is found.)
Comment: I presumed it by thinking about how it might work. It is unlikely that every possible assembly would be searched (e.g. every dll in the GAC plus every dll in the current application's path), so it stands to reason that the assembly's references would be used in the search path. I would take "current assembly" to mean the assembly that contains the type where the `Type.GetType()` is being used. "but it is an assembly on the call stack" - so you mean a reference of a reference? If so, then I would expect that to be found because the type resolver will be doing a recursive reference walk.
Comment: @adrianbanks - Well I mean that the reference goes the wrong way ... the assembly higher on the call stack has a reference to the assembly containing the type that contains the method that is calling `Type.GetType()` - but not the other way around.  I wonder if the answer is in _Essential .NET Volume 1_? (Isn't it a shame that that book never had a 2nd edition or a Volume 2?)
Comment: @adrianbanks - [Here, in MSDN](http://msdn.microsoft.com/en-us/library/yx7xezcf(v=vs.110).aspx) there's a note that says `There is no version checking for assemblies without strong names, nor does the runtime check in the global assembly cache for assemblies without strong names.`  So that settles my question.  Thanks!


How to make application trusted to outlook

Question: I have created one application which is reading outlook mail, but when user install that application in their system and run it; they are getting pop up from outlook saying that "Some external application want to access your outlook, do you want to grant access to it?.... ". How can I make my application trusted to outlook?
Answer: One way would be to create the application as an add-in in Outlook.
Add-ins are trusted.
Another way would be to use a 3th party component like "outlook redemption"
Comment: I have already written application, I am not sure how can I make this application as an outlook add in. Could you help me guiding the possible ways?
Comment: You could look into VSTO to create an addin. You might have to change some things tough as an outlook addin is executed from within outlook (You'd add buttons to the toolbar/ribbon of outlook so the user can access them)


How do you steer the screw attack in Metroid Prime 3: Corruption?

Question: When I received the screw attack in Metroid Prime 3: Corruption, I was told that I could steer while using it by using , which appeared to be the analog stick on the nunchuck.
But try as I might, no matter what direction on the nunchuck's analog stick I press, I always go straight while using the screw attack...
How do you steer the screw attack in Metroid Prime 3: Corruption?
EDIT: Here's a full screen capture:
Answer: I need to post some screen captures to demonstrate this, but I discovered that you can steer the screw attack using the control stick. It's just that you can only steer about 5° or 10° in either direction. Starting in a large, open room I jumped, space jumped, and then started to screw-attack and held right on the nunchuck's analog stick, and jumped as far as I could. I then repeated this holding left on the analog stick as well as not touching the analog stick at all. The difference was very slight, but there was a difference.
EDIT: Here's some screen captures:
I tried three tests, starting from here each time:

If I use the screw attack all five times and don't hold any direction, I end up here:

Using the screw attack and holding left, I hit the pillar before I can jump all 7 times:

If I hold right on the analog stick when using the screw attack, I do go right. Check the map:

So the difference is very slight, maybe 5° or 10° in either direction. But there is a difference...
Answer: You can not decisively steer the screw attack. Like in Metroid Prime Two, the Screw Attack is used for clearing long horizontal distances, and climbing up the screw jump walls.
Though it's been a while since I played the game, I imagine the item-tutorial tips were referring to this latter ability.
Comment: I'm so tempted to accept this answer since it's how I feel, LOL. I'll probably post a screen capture, because I don't think they were referring to the screw jump walls. I can climb those without using the control stick at all, the game automatically reverses my direction for me...
Comment: A picture would help diagnose, for sure.
Comment: I did some tests and will post some screen shots soon...
Comment: I posted screen captures, both of the instructions, as well as my test proving that the steering does work, it just barely has any effect at all...


Returning code block in Scala

Question: I was trying to implement the closure example in Scala, from Neal Ford's Functional Thinking presentation which is in Groovy. Refer slide # 43 & 44 https://sea.ucar.edu/sites/default/files/Functional_Thinking.pdf
  def makeCounter : Unit = {
var localVar = 0
return { localVar += 1 }
}

This code returns an anonymous function. Now I want to increment the localVar by invoking this anonymous function.
I have two questions:
1. How do I invoke the anonymous function?
2. After invoking it how do I check if the value of localVar is incremented or not?
First I tried this -
val c1 = makeCounter(). It threw below error:
    error: makeCounter of type Unit does not take parameters
Then I tried this.
    val c1 = makeCounter
This didn't give any error. Only printed c1: Unit = ().
Then,
print(c1) printed (), whereas c1() gave the same error.
Comment: "This code returns an anonymous function." - Then why did you declare its return type as `Unit`?
Comment: I think he is mixing by-name Unit parameters with pure Unit.
Answer: First of all. Don't use return, its semantics is completely different in Scala than in Java or Groovy.
The Unit type isn't a synonym for anonymous function. It's more like a indication of side-effects.
The type for an anonymous function is () => A. In your case you want a function that doesn't return any thing, but causes a side-effect. So its type should be () => Unit.
Let's see some code:
def makeCounter : () => Unit = {
  var x = 0
  { () => x = x + 1 }
}

val counter = makeCounter
counter(); counter(); counter()

Great! We made makeCounter give us a fresh counter!
There is only one problem. x is a local variable in the method makeCounter and since it's never returned we can't see its value! Ever! We could, for example, remove x from the method, making it public in the outer scope. But it's not very functional. Instead let's make the function return it:
def makeCounter : () => Int = { // Notice now, instead of Unit we use Int
  var x = 0
  { () => x = x + 1; x }
}

val counter = makeCounter
println(counter(), counter(), counter())
val counter2 = makeCounter
println(counter2(), counter2(), counter2())

You will see "1,2,3" twice. Once for each counter.
Comment: @som-snytt Actually, I have problems visually parsing your version. I didn't even know you could arrange things like that.
Comment: Sorry, I only read as far as `should be ()=>Unit` when I posted my version. Maybe you could remove the extra semi and braces from the final answer.  "Is that your final answer?"
Comment: @pedrofurla If I don't use return it gives an error - "error: block must end in result expression, not in definition". So I returned it. But still println(counter()) doesn't print anything
Comment: I wouldn't normally put it on a single line except for typing it in the REPL.  But compare http://stackoverflow.com/a/18159362/1296806 and more explanation at http://stackoverflow.com/a/13873899/1296806.
Comment: What puzzled be was the `;`. So, shall it be `(() => v += 1) ; v` returning v? Or shall it be ``(() => v += 1 ; v)`, return a function that returns v? If I didn't test I'd still be thinking the former is what happens.
Comment: I see what you mean.  I wear special bi-focal lenses just for this syntax.  For the record, I didn't see your comment because of no at. I don't know why SO thinks I'm not interested in a stream of commentary to which I have contributed. Or OK, "contributed".  I guess SO would say, This is not a chat room. So 1990s.
Answer: I didn't look at the presentation, so I don't know if this is functional thinking or just one of the slides on the road to functional thinking, but:
scala> def f: () => Int = {
     | var v = 0
     | () => v += 1 ; v }
f: () => Int

scala> val g = f
g: () => Int = <function0>

scala> g()
res0: Int = 1

scala> g()
res1: Int = 2

scala> g()
res2: Int = 3

The function literal returned by f is, of course, everything after the parens.
Comment: This works fine. But I have a conceptual doubt here. As I understand, this function definition with def f: () => Int implies that it will not take any parameters and return an Int. But isn't that wrong because this function is returning an anonymous function and not an Int? Or am I missing anything here?
Comment: @VarunPaprunia Method `f` is parameterless. See how it's invoked on line 2 without parens. It returns a `() => Int`. Value `g` is applied using `g.apply()` or `g.apply` (with parens automatically added) or `g()` (as call to `apply`).

Returning code block in Scala


how to convert json string to javascript array in jsp?

Question: In my jsp below is code.how to access (String jsonname)in javascript  as javascript array? currently, it doesnot print anything.
   ArrayList<String> name=new ArrayList<String>();
   name.add("Ravi");
   name.add("Vijay");
   name.add("Ajay");
   Gson gson = new Gson();
   String jsonname = gson.toJson(name);

Comment: can you print out the value of `jsonname` ?
Comment: @Ahmad["Ravi","Vijay","Ajay"]
Comment: Sorry, my mistake. It is possible to use JSON.parse on arrays
Comment: @Ahmad then, how can i convert java Arraylist to javascript Array?
Comment: What error is reported when you try the code above?
Comment: @Ahmad print nothing
Comment: @Ahmad that was  my typing error, i have correct code. but its not working
Answer: You've named your ArrayList name, but you're trying to add to list
Solution
ArrayList<String> name=new ArrayList<String>();
   name.add("Ravi");
   name.add("Vijay");
   name.add("Ajay");
   Gson gson = new Gson();
   String jsonname = gson.toJson(name);


Ubuntu 17.10: change keyboard delay

Question: How to set the keyboard's autorepeat delay with stock Ubuntu 17.10? It feels to sluggish by default.
Answer: In Settings>Universal Access, select "Repeat Keys" under "Typing" header:
Comment: Arg! I was searching under Devices > Keyboard.
Answer: For me it worked like this:
Open terminal and edit this file:
$ sudo gedit /etc/pulse/daemon.conf
Find the setting "enable-deferred-volume", remove the semicolon at the start of the line if is commented out and set its value to "no"
enable-deferred-volume = no
Reboot the system.
_
See more:
https://community.spotify.com/t5/Desktop-Linux/Delay-when-changing-volume/td-p/1589346

Ubuntu 17.10: change keyboard delay


How to generate parameterless constructor at compile time using scala 3 macro?

Question: how to generate a private parameterless constructor on a class (at compile time) when it annotated with @entity
annotation - in scala 3 macros
class entity extends scala.annotation.StaticAnnotation
@entity
class Student(val id: Long, val name: String) {
  //??? at compile time generates: private def this() = this(0, null)
}

Comment: Macro annotations in Scala 3 can be considered WIP at the moment (see: https://contributors.scala-lang.org/t/scala-3-macro-annotations-and-code-generation/6035) but they aren't released, so you can either wait an indefinite time, or use some other approach (type class generation, scalafix rewrites, etc).
Comment: You can generate code at pre-compile time with Scalameta/SemanticDB/Scalafix or at compile time with compiler plugin.
Comment: Scala 3 macros are `def` macros, not annotations. You can't *generate* code with them. https://stackoverflow.com/questions/67770927/macro-annotations-in-scala-3 https://stackoverflow.com/questions/59473523/how-to-generate-a-class-in-dotty-with-macro https://contributors.scala-lang.org/t/scala-3-macro-annotations-and-code-generation/6035 https://users.scala-lang.org/t/macro-annotations-replacement-in-scala-3/7374
Answer: Starting from Scala 3.3.0-RC2, there appeared macro annotations (implemented by Nicolas Stucki).
Macro annotation (part 1) https://github.com/lampepfl/dotty/pull/16392
Macro annotations class modifications (part 2) https://github.com/lampepfl/dotty/pull/16454
Enable returning classes from MacroAnnotations (part 3) https://github.com/lampepfl/dotty/pull/16534
New definitions are not visible from outside the macro expansion.
The macro annotation adding auxiliary constructor should be the following:
build.sbt
scalaVersion := "3.3.0-RC3"

import scala.annotation.{MacroAnnotation, experimental}
import scala.quoted.*

object Macros:
  @experimental
  class entity extends MacroAnnotation:
    def transform(using Quotes)(tree: quotes.reflect.Definition): List[quotes.reflect.Definition] =
      import quotes.reflect.*

      tree match
        case ClassDef(name, constr, parents, selfOpt, body) =>
          val constrSym = Symbol.newMethod(tree.symbol, "<init>", MethodType(Nil)(_ => Nil, _ => TypeRepr.of[Unit]))
          val constrDef = DefDef(constrSym, _ => Some(
            Apply(Select.unique(New(Inferred(tree.symbol.typeRef)), "<init>"), List('{0}.asTerm, '{null}.asTerm))
          ))

          val res = List(ClassDef.copy(tree)(name, constr, parents, selfOpt, body :+ constrDef))
          println(res.map(_.show))
          res

        case _ => report.errorAndAbort("@entity can annotate only classes")

import Macros.entity
import scala.annotation.experimental

object App:
  @entity @experimental
  class Student(val id: Long, val name: String)

//scalac: List(@scala.annotation.experimental @Macros.entity class Student(val id: scala.Long, val name: scala.Predef.String) {
//  def this() = new App.Student(0, null)
//})

Macro Annotations in Scala 3
How to generate a class in Dotty with macro?
Scala 3 macro to create enum


Fortify Security issue- Unreleased Resources: Database in java

Question: I have scanned my project using fortify tool, in the generated fortify report I got Unreleased Resource: Database issue in the following code:
<code>    PreparedStatement prepStatement = null;
    Connection connection = null;
    Connection connection1 = null;
    ResultSet resultSet = null;
     try {
        connection = DBManager.getNewConnection(); //Line number=a
        prepStatement = connection
                .prepareStatement("select P from table_name where parameter1 = ? and parameter2 = ?");
        prepStatement.setLong(1, parameter1 );
        prepStatement.setLong(2, parameter2 );
        resultSet = prepStatement.executeQuery();
        if (resultSet.next()) {
            var1= resultSet.getString("var");
        }
    } catch (Exception e) {
        LOGGER.error("Unable to set the var field", e);
        throw new DatabaseRuntimeException(e,
                language.plainTxt("Unable to set the var field"));
    } finally {
        DBManager.close(prepStatement, resultSet);
        DBManager.close(connection);    //line number: b
    }
}//method end//  line number=c
</code>
Analysis trace shows:

line a: connection refers to a database connection.
line b: close(connection).
line c: connection no longer refers to a database connection. //connection end scope : Database resource leaked.

Anybody let me know how can I fix this issue?
Answer: What you're not taking into account here is a RuntimeException in the line "DBManager.close(prepStatement, resultSet);".
If that line fails with an exception the connection will never be closed.
That's probably why fortify flags it as a potential resource leak.


Semiring construction from a monoid

Question: Reading throug the paper Definable sets up to definable bijections in Presburger groups by Raf Cluckers and Immanuel Halupczok, I have come across a construction (Definition 2.2.1) that builds a commutative semiring out of a commutative monoid $M$.
At first, I thought it was talking about the set of all maps $M\to \mathbb{N}$ with finite support where + is given by addition of maps and $\times$ is the Cauchy product
$$
(f \times g)(z) = \sum_{a+b = z} f(a)g(b) \cdot \textbf{1}_z
$$
where $\textbf{1}_z$ is the map sending $z \mapsto 1$ and every other element to $0$. The construction continues by identifying the elements
$$
\begin{array}{c}
\textbf{1}_a + \textbf{1}_b = \textbf{1}_{a+b}\\
\textbf{1}_0 = 0\\
\textbf{1}_g = 1\\
\end{array}
$$
where $0$ and $1$ are the neutral elements of the resulting semiring and $g$ is a preselected element of $M$.
The authors provide an example (after Theorem 2.3.4) of such a construction applied to the monoid $\mathbb{N}_\infty$.
When I follow this construction, I get that the elements of the resulting semiring are equivalence classes represented by
$$
\mathbb{N}_+ \cup \{\infty\}
$$
while they assert that they should be given by
$$
\mathbb{N} \cup \{\infty, \infty^2, \infty^3,\dots\}
$$
Is there another construction of a semiring where after doing the identification this is the resulting semiring?
They name the construction as reduced symmetric algebra, but reading about symmetric algebras I can't figure out what is the mathematical object they are constructing.
Comment: @MartinAzpillaga It is silly to ask us to reverse-engineer a construction to explain something you read in a paper which you haven't even cited for us. Someone may be able to do it, but otherwise you are not giving the rest of us much to go on.
Comment: What I read here is "I came across a construction... at first I thought it was this other construction..." so now I am confused if you are describing the other construction or the one you are confused about. Please clarify.
Comment: https://en.wikipedia.org/wiki/Outline_of_algebraic_structures#Types_of_algebraic_structures ?
Comment: @rschwieb The construction I provide was my first guess, but it is not the correct one. I am looking for a different construction that provides the semiring with elements $\mathbb{N} \cup \{\infty,\infty^2,\dots\}$ when applied to the example given.
Comment: @MartinAzpillaga You're saying that you're familiar with semigroup rings and you think that is not the construction implied?
Comment: @MartinAzpillaga Put that in the body of the question, not the comments...
Comment: @MartinAzpillaga I am looking at Definition 2.3.1 right now, and I cannot see any resemblance to your question. [This is what I'm looking at](https://arxiv.org/pdf/1706.02997.pdf)
Comment: @rschwieb That one is the correct paper. There is a chance that I am totally wrong. My question is: What is this reduced symmetric algebra they define there?
Comment: @rschwieb http://latexsearch.com/ may help if you can mimic what would be written in the paper.
Comment: @MartinAzpillaga OK, I've got it. You are apparently looking at Definition **2.2.1**. So... if you could be a little more careful that would be nice.
Comment: Thanks for pointing that out, the question has been accordingly updated.
Comment: @MartinAzpillaga In a case like this, it's also in your best interest to provide the description. Making readers chase through links and documents to figure out what you're talking about is going to deter a lot of them. The entire description is not even as long as what you already wrote.
Comment: It looks like a straightforward quotient of a free semiring (or semigroup-semiring, if you prefer), but the weird part is that the semigroup operation is being blended with the $+$ operation of the semiring. (for normal semigroup rings, of course, the semigroup operation becomes the $\cdot$ operation of the semigroupring.) That's very strange to me, and I don't recognize it, or even know if it's a real thing. But it probably is a thing. Math is a big ocean.
Comment: @rschwieb At least is not only me who finds it strange. Seems like you are close to understand it though. It would be great if you could add a proper answer explaining the construction in more detail.
Comment: https://en.wikipedia.org/wiki/Presburger_arithmetic  is my first thought that you might be missing it's not necessarily peano arithmetic multiplication doesn't happen in presburger based on that article.
Comment: @MartinAzpillaga If I understood it, I would post an answer. Honestly I'm a bit skeptical about it. I just don't see what's happening to the original semigroup operation. My advice would simply to be to email the authors directly. I found [one author](http://rcluckers.perso.math.cnrs.fr/) right away, and I didn't search for the other one.
Comment: "Later on, the authors provide the example ..." Be more precise and give us the precise page and line.
Comment: @J.-E.Pin A reference to the example has been added to the question. It is just after Theorem 2.3.4
Answer: I think the construction as given in the article is correct. First of all, given a set $G$, the free commutative semiring over $G$ is the semiring of commutative polynomials $\mathbb{N}[(X_g)_{g \in G}]$.
Let $G$ be a commutative monoid and let $s: (\mathbb{N},+) \to G$ be a monoid homomorphism. Now, the semiring defined in the article is the quotient $SG$ of $\mathbb{N}[(X_g)_{g \in G}]$ by the relations $X_0 = 0$, $X_{s(1)} = 1$ and $X_g + X_h = X_{g+h}$.
Suppose first that $G = \mathbb{N}$. Then, one gets by induction the relations $X_n = n$ for all $n$ and hence $SG = \mathbb{N}$. If now $G = \mathbb{N} \cup \{\infty\}$, one gets the further relations $X_n + X_\infty = X_\infty$, whence $n + X_\infty = X_\infty$, for all $n \in \mathbb{N}$ and $X_\infty + X_\infty = X_\infty$. It follows that in this case, $SG$ is the quotient of $\mathbb{N}[X_\infty]$ by the relations $n + X_\infty = X_\infty$ and $X_\infty + X_\infty = X_\infty$. It follows that $kX_\infty = X_\infty$ for all $k > 0$. Moreover
$X_\infty^2 = X_\infty(1 + X_\infty) = X_\infty  + X_\infty^2$.
Consider now a polynomial $c_{i_1}X_\infty^{i_1} + \ldots + c_{i_n}X_\infty^{i_n}$, with nonzero coefficients and $i_1 < \dotsm < i_n$. Then
$$c_{i_1}X_\infty^{i_1} + \dotsm + c_{i_n}X_\infty^{i_n} = X_\infty^{i_1} + \dotsm + X_\infty^{i_n} = X_\infty^{i_n}$$
and thus $SG = \mathbb{N} \cup \{X_\infty^k \mid k \in \mathbb{N}\}$.

Semiring construction from a monoid


Thread in rails for creating object

Question: In my controller, I have :
@a = Myobject.new params
@b = Myobject.new params2

In the models folder, I have a class (no a model) :
class Myobject
 attr_accessor: :var1, :var2, :var3
 def initialize params
  # Some processes with SQL queries and classes variables.
  @var1 = result_of_a_sql_query
  @var2 = a_hash
  @var3 = params[:varpost]
 end
end

But it's slow.
I would like to launch this 2 object creations in parallel. (with thread or other)
I've tried :
t1 = Thread.new {@a = Myobject.new params}
@b = Myobject.new params2
t1.join

But I've got an error : Circular dependency detected while autoloading constant Myobject
How can I launch this 2 commands in parallel ?
Thank you.
Comment: Do you need to perform options on these objects immediately or is this a simple creation process? Also, which rails version are you using?
Comment: I don't think, I edited the class in my question. I think it's a simple creation process. I'm not in my work, I think rails 4 (but i'm certain >3.5)
Comment: rails version is 4.1.2
Comment: did you ever figure out how to get around this issue? im having the same one
Answer: If you are working with complex object creation, but you need to get a prompt response back to your user, then it may be best to actually queue your object creation jobs where they can be processed on the system's own time rather than going through the whole thing during your action.
You might look at the various background job gems available to you. On the current application I am working with, updates are dropped into a Resque queue asynchronously and then pulled out and actions performed on the database as possible. This approach can work very well and is fairly standard in cloud environments.
If you need the data available on the front, that would not work as well but you could create simple proxy objects to return most of the data in a view, or simply perform async updates and maintain a front-end version of the data model too.
Comment: I would like just launch the first `@a = Myobject.new params` then wait where I want that job finishes. The two object creations are separate. I'm surprised there isn't another simply way. Why with simple thread, it doesn't work ?

Thread in rails for creating object


Can a Wii U work with a hardware RAID for external HDDs?

Question: I'm looking at a Hardware RAID enclosure (like this) for my Wii U. I would like to use external storage so I can fit more games on it, but would like RAID 1 (mirroring) to protect my data since the Wii U's method of "backing up" (manually, game-by-game copying save data in a multi-step process) is far too involved to do on a regular basis.
But I've never used a RAID setup like this before--will it be read just like a single disk and therefore work on a Wii U? Or does this require some drivers normally present on a computer operating system or not? Does it depend on device or are all hardware RAID enclosures usable on a Wii U? I know it will need external power (or 2 USB ports for power) but I'm not sure how the Wii U will treat a hardware RAID'd device.
Answer: That depends on RAID implementation for a device. From the specs of this specific device it seems that it's hardware configured using DIP switches and doesn't requeres any drivers, specifically

Supporting OS:
The H212 is OS independent and will work with any OS that supports USB
  host devices.

That means that it looks like a regular drive to device that is using it. So, unless there is no specific incompatibility the device should work fine with Wii U.


How to use ngStyle with :nth-child?

Question: I am new to Angular, and I am trying to style items after the 6th child but it doesn't work. I can color everything, but when I add the nth-child part it doesn't work. Do I have a wrong syntax?
[ngStyle] = "div:nth-child(n+6){'background-color': 'red'}"

 Secret Password is Tuna

  {{clickLog}}

<button (click)="clickEvent()">Show Details</button>
<button [disabled]="!checkIfEmty()" (click)="resetUserName()">Reser Username</button>

Comment: You can't use a css selector inside an inline style definition. Quite a few other syntax issues also. Maybe re-teach yourself the fundamentals of html / css before attempting this.
Comment: The `ngStyle` directive applies the CSS styles to the element itself. You need to use the component style file (the CSS or SCSS) for this.
Comment: Here is solution https://stackblitz.com/edit/angular-num8ry
Comment: @31piy Thank you for  your answer. I have style file, but wanted to try styling with ngStyle.
Answer: You can use pseudo class in the component CSS file.
app.component.css
div:nth-child(n+6) {
  background-color: red
}

But you should have proper structure for it in template.
Or you can use index of ngFor.
app.component.ts

= 6 ? 'red' : '' }">
  {{clickLog}}

Comment: I think there is error while complie `Parser Error: Got interpolation ({{}}) where expression was expected at column 0 in [{{'background-color': i >= 6 ? 'red' : '' }}]`

How to use ngStyle with :nth-child?


Is this a correct proof of $\overline{A\cup B}=\overline{A}\cup\overline{B}$

Question: I'm trying to prove that $\overline{A\cup B}=\overline{A}\cup\overline{B}$, with $A,B\subset X$ and closure defined by $$\overline{A}=\{x\in X:\text{every neighbourhood of $x$ intersects A}\}$$
I first show that  $\overline{A\cup B}\subset\overline{A}\cup\overline{B}$, so let $x\in\overline{A\cup B}$
Then every neighbourhood $U$ of $x$ intersects ${A\cup B}$, i.e $$(A\cup B)\cap U\neq \emptyset\implies (A\cap U)\cup(B\cap U)\neq\emptyset$$ which means that every neighbourhood of $x$ intersects $A$, or $B$, or both, i.e $x\in\overline{A}\cup\overline{B}$. Is this correct?
For the other direction could I start with $(A\cap U)\cup(B\cap U)\neq\emptyset$ and just reverse the steps?
Answer: No, in your setup, every neighbourhood $U$ intersects $A$ or $B$. But it has to be always $A$ to conclude that $x \in \overline{A}$ and likewise for $B$. But you only know that you intersect one of them for a given $U$.
That's why it's better to go by contradiction: suppose $x \in \overline{A \cup B}$ but $x \notin \overline{A} \cup \overline{B}$, so $x \notin \overline{A}$ and $x \notin \overline{B}$. Not being in the closure of $A$ gives you that there is a neighbourhood of $x$, say $U_1$ such that $U_1 \cap A = \emptyset$, and not being in $\overline{B}$  another neighbourhood $U_2$ of $x$ such that $B \cap U_2 = \emptyset$. Now...
For the other direction: $A \subseteq A \cup B$ so $\overline{A} \subseteq \overline{A \cup B}$, and also for $B$, hence....
Comment: Can you clarify which step in the proof is flawed?
Comment: @Loobear23 You have only shown $x \in \overline{A} \cup \overline{B}$ if you have shown $x \in \overline{A}$ or $x \in \overline{B}$ by definition of union. You wrongly apply the definition of $\overline{A \cup B}$ instead.
Comment: @Loobear23 There is a difference between $\forall U: U \cap (A \cup B) \neq \emptyset$ and $\forall U: U \cap A \neq \emptyset$ or $\forall U: U \cap B \neq \emptyset$. In general we cannot go from the first to the second but in a topology we can.
Comment: I understand, so for a contradiction, since $(A\cap U)\cup(B\cap U)\neq\emptyset$ for all $U$, can I take $U=U_1\cap U_2$? This would give $(A\cap U_1\cap U_2)\cup(B\cap U_1\cap U_2)=\emptyset$ which is a contradiction
Comment: @Loobear23 indeeed, but you use that open sets are closed under intersections. So for general sets this reasoning could fail.


Comparing two .txt files showing common words or phrases

Question: I am trying to compare two .txt files and find out every common word in the two (ignoring case sensitivity. If someone could point me towards the right direction that would be helpful. (I don't have any python writing experience, just editing a few scripts)
Comment: @bernie: the innocent "or phrases" at the end of the question makes it a slightly more complex problem.
Comment: Well spotted. I agree that also searching for phrases makes this a more complex problem. How much more complex depends on how many edge-cases the OP wishes to accommodate.
Answer: This will give you list containing common words from two files. Output format is list.
<code>with open('a','r') as f, open('b','r') as g:
  l=f.readlines()
  l1=g.readlines()
  print list(set(l)&set(l1))
</code>


How does the Workshop's vehicle repair feature work?

Question: The Workshop's bonuses are described as:

Real Workshop - Automatically Repair Body and Tire damage for vehicles parked overnight.
Construction Expertise - +100% Construction Rate. REQUIRES TOOLS EXPERT.

So, if I have a Workshop and a Tools Expert that "knows a little something about tools and construction" (Isaiah Marcus)...

By how much will the car's body and tire damage be repaired if I had it parked overnight?
And if I have a car with one blown tire, how many nights will it take to repair it?

Is the length of repair time affected by how many tires are blown?

Will cars that are on fire still be repaired (does it count as a body damage)? How long will it take? I'm asking because I have a car that is on fire that has been parked on the parking space for two days and nights now... but it's still on fire:
Answer: There are 3 levels of the Work Area (level 3 has 2 variants)

Level 1: Work area - repairs your weapon only
Level 2: Workshop - repairs weapon and partially repairs cars (flat tires, dented bodies)
Level 3 (Machine Shop): repairs weapon and fully repairs cars (restores to mint condition)
Level 3 (Munition Shop): Same as level 2, but allows you to make advanced explosives

Cars parked in marked parking spaces are instantly repaired at dawn.
Note that although you don't need a Construction expert to run a Machine Shop, you DO need one to build it.
You can refer to the game's wiki page for more information.
Comment: This should be the accepted answer


Prove that every number of form $3k$, $3k+1$ can be reached

Question: An ant starts at point $0$ of the number line.  In the first step it moves to $1$. After that the ant can move in steps of length $2x$ or $\frac{x}{2}$ if it has moved the amount $x$  in the previous step. The ant can't move backwards and can only move in steps equal to a natural number.

Which numbers can it reach?
Answer: We can start a way from $1$ or $3$ so if we can reach $w$ we can also reach $w+3$ and because we can reach $0,1$ we can reach any point of form $3k,3k+1$ and because in every two consecutive moves we move as a multiply of $3$ we can't reach numbers of form $3k+2$.

If we write the numbers that can be reached in at most $100$ moves from small to big find $2012$th number.

The book just found the $2012$th number that is like $3k$ or $3k+1$ and haven't checked if they could reached in less than $101$ moves. It is very likely  the answer to be true since powers of $2$ can be large enough but I can't prove it.
Answer: Okay, suppose we want to get $3k$ where $0 \le k \le 1023$
$k$ will be a $10$ digit binary number = $a_9a_8a_7a_6a_5a_4a_3a_2a_1a_0$.
Case $1$.  $a_9a_8 = 11$.
Then if we spend the first $22 = 2(10+1)$ steps doing $1+2+4 +.... + 2^9 + 2^8 + 2^9 + 2^8 + 2^7 + .... + 4 + 2 + 1 + 2 = 2^{10} - 1 + 2^8 + 2^{10} - 1 + 2 = 2^{12}+ 2^{8} = 2^{10} + 2^9+2^9 + 2^8 = 3(2^9 + 2^8)=3(a_9a_800000000)$.
So this is $22$ steps plus whatever it takes to do $3k': k = a_7a_6a_5a_4a_3a_2a_1a_0$.
(Note: We ended that stretch at $2$, so the next step can be $1$ and we can start a new number.
Case 2: $a_9a_8 = 10$.
If we spend the first $20 = 2*10$ steps doing $1+2 + 4 + ... +2^9 + 2^8 + 2^7 + ... + 2 + 1 + 2= (2^{10} -1)+(2^9 - 1) + 2 = 2^{10} + 2^9 = 3*2^9 = 3(a_900000000)$.
So this is $20$ steps plus what ever it takes to do the sake $k'$ above.
Case 3:  $a_9a_8 = 01$.
Well we can do similar to case 2 to get in $18$ steps $1+2 + ... 2^8 + 2^7 + ... + 1 + 2=3*2^8 = 3*(a_9a_800000000)$ to reduce it to $18$ plus whatever it takes to get the $3*k'$ above.
And Case 4: $a_9a_8 = 00$ then it will take only whatever it takes to get teh $3*k'$ above.
So at the very most is will take $22$ steps plus whatever it takes to get the $3k'$ above.
By similar argument the absolute must it will take to get $3k'$ will be $2(8+1)=18$ plus whatever it takes to get $3k'': k'' = a_6a_5a_4a_3a_2a_1a_0$.
Reiteration five times it will take at most $22  + 18 + 14 + 10 + 6 = 70$ steps to get $3k$ for any $0 \le k \le 1023$.
And after achieving a distance of $3k$ we can finish with $3k + 1$ to get $3k+1$ in $71$ steps.
I'm not sure what the text had in mind to solve this but $100$ steps is plenty to get: $m_1 = 1; m_2 = 3; m_3= 4;  m_{2k} = 3k; m_{2k + 1} = 3k + 1; $ are for $k < 1024$ within $100$ steps.
The only issue is to prove that only numbers of the form $3k$ and $3k + 1$ are possible.
There are several ways to do this and what you gave in the $OP$ is fine.
I suppose the easiest would be induction.  If a sequence $S= +,......$ where $+$ doubles then ants step and $-$ halves it, results in a distance of $k$ then the sequence $+, -, S$ will results in $k+3$ and a sequence of $+, S$ will result is $1 + 2k$.  As all sequences begin with $+$ and for every sequence can be achieve by either adding a $+$ or a $+, -$ to the beginning, this recursively describes all possible results.
A sequence of $1$ step can end in $1$ and a sequence of $2$ steps can end in $3$ both are of the forms $3k$ or $3k+1$.
If we assume all sequence of at most $m$ steps result in a distance of the form $k$ or $k + 1$.  then a sequence of $m+1$ steps will result in distance of the form $3+ 3k = 3(k+1)$, $3+3k + 1 = 3(k+1) + 1$, $1 + 2*3k = 3(2k) + 1$, or $1 + 2*(3k + 1) = 6k + 3 = 3(2k + 1)$.
Comment: I can't get the part "So we can get 3k within $(4∗9−2∗8−2)+(4∗7−2∗6−2)+(4∗5−2∗4−2)+(4∗3−2∗2−2)+(4∗1−2)=18+14+10+6+2=50$ moves (at most)" could you explain more please?
Comment: let me redo the whole thing.  this is kind o f sketchy although i think it is true it is pretty sketchy and it might not be.  Give me a few hours.
Comment: We can get $3*(1100000000)$ in $(4*9 - 2*8 -2)=18$ moves.  So we can get we get $3*(11000000)$ in $(4*7 - 2*6 -2)= 14$ moves.  and $3*(110000)$ in $4*5-2*4-2 = 10$ moves and so on to get $3*11111111111$ in $50$ moves.  That is the maximum number of moves required to get any number.
Comment: But we can get $2^9-2^8$ in $18$ moves not $2^9+2^8$
Comment: Oh, you're right.  But that's okay. A ten digit number will have isolated $1$ representing $2^j$ or strings of $111$s between zeros representing $2^m(2^j - 1)$.  There are at most *5* of these significant values.  We have an upper limit on how long it will take to get these. Either $4*j-2m-2$ or $2j$.


Which primer and paint for metal roof home in Maine?

Question: Having a lot of problems researching painting my steel roof here in Maine. I've had the paint folks at Home Depot and Lowes and Sherwing Williams all give me contradicting advice...LOL
The roof is black and the paint is streaking off. It's not practical to strip the roof.  I'm planning on power washing, priming, and paiting.
For the life of me I can't find a primer recommended for roofs (all the primers for metal I'm told are not recommended for roofs). The few that I think would work are crazy money $200+ per gallon (I'm thinking $50-60 per gln).
Killz, Rust-O-Leum, Zinser - I'm told no.
As for the paint, Behr has one in a Google search but the people at Home Depot have never heard of it so they can order it, but they can't advise on the best primer for it or even if it will be okay for a roof.
Can anyone help out?
I have about 700sqf of steel roof to paint. Needs to be black or tintable to black. I'm using an Avanti AV-Aps1. I've also seen lots of "coatings" but not sure if they're the best or if they'd work with my sprayer.
Thank you all for your time!
Rob
Comment: I imagine most steel roofing uses baked on paints for long life.  Not recommended and does not work can be two different things.  The difference between lifetime and a few years.  As with all paint jobs the preparation is about 90% of the job.  You want a good base to start with.
Comment: Is this a galvanized steel roof? Can you walk on it without damaging it? What is the contour of the roof?
Comment: Generally, if a black steel roof has paint "streaking off" that's a failure of the roofing and should be replaced under warranty, unless it's quite old. If you don't strip it, any new paint that's over old paint that's prone to "streaking off" will leave when the paint under it lets go. If the roof is galvalume you don't need to paint it at all. A suitable paint is more likely to be found via an industrial supplier than home supply stores, but without proper preparation it's not going to last.
Comment: Maybe try a boat repair place.  They might know of some paint/primer that will last.
Comment: Do you have foam insulation on the roof deck?
Comment: Would look into a DTM (direct to metal). Sherwin Williams Pro Industrial DTM might be an option. Never used it on a roof before so I can't speak on that but have used it extensively on metal doors and steel products.
Answer: These types of coatings would not typically be found in consumer paint stores. As a primer, I would suggest researching coatings like Sherwin Williams DTM acrylic. Note that not all stores will carry this product, as some specialize in more industrial coatings.
I've personally used dtm on doors, it works well, but still isn't on par with a factory baked paint.
Comment: DTM is "direct to metal" in paint, by the way.


Help on wiring diagram for baseboard heaters

Question: Can I wire in parallel 2 wall thermostats to 2 separate baseboard heaters along with another baseboard heater with a thermostat already installed in the heater?
I have drawn up a diagram of what I'm trying to do but I need help in knowing what wires to connect and where
This is for a 200 amp service with 20 amp double pole breaker and a double pole honeywell therostats with 750 watt baseboard heater per thermostat.
Can someone connect the letters on my diagram if it's possible to do this?
Thank you.
Comment: I think you're gonna need more cables.
Comment: Do you need room 2 and room 3 to be completely independent? I don't think you want room 3 on only when room 2 is on.
Comment: ye, in all 3 rooms want the heaters are on independently
Comment: Instead of a cable from room 2 heater to room 3 heater, you need a cable from room 2 thermostat to room 3 heater. If necessary this cable could follow the physical path via room 2 heater.
Comment: yes independently
Answer: You can't do it with the cables as shown! You need a new cable from before  the second thermostat and the third heater. Like so:

Not shown are green/bare ground wires connecting the grounds on everything.
Because in the US, 240 volts is two opposite leg hots, red and black wire are interchangeable.
Comment: Thank you so much for showing how to connect the wires and for pointing out where I had incorrectly ran to the last heater and it makes sense to me what you said. I didn't include the ground wire for simplicity but will connect them too. Much appreciated for taking the time to help me.
Comment: Thank you, you have been so helpful.

Could you tell me the following?

1: I am limited to wall space and the only wall available to me is above a light switch. So would it be ok to if I put a thermostat above a light switch?

 2: can I put a thermostat on a wall with another thermostat adjacent behind it on same wall?

3: I just realized that the stat on the baseboard heater I got is a single pole stat... Can I still tie into the single pole even though the other two stats are double pole or should i get another heater with double pole installed?

Thanks
Comment: @fritz For #3, as long as the heater is rated for ~240 volts, it's fine, even if the thermostat is single-pole.
Comment: Thanks  @doxylover for your help. Appreciated your responses.


Burning smell in my clothes dryer

Question: There is a burning smell inside my clothes dryer  after it runs. Does anyone know what that could be? There is no smoke (thankfully) but it definitely has a mild to medium smell or something burning. I think its a gas powered dryer (its hard to get to the back too look) but the smell is closer to burning lint than to gas.
My first response was to clean out the area under the lint collection basket. We clean the collection basket before each use but the area under that had collected a fair amount of lint and so I cleaned it after we first smelled the smoke. I also checked the exhaust hose that connects to the wall but there was no lint in there. I then ran the dryer again after this cleaning and it still smells of smoke. Is there another place to clean? Do I just have to let it run some to let it air out? Or, is there something else I should do?
I am fairly handy myself but don't have any experience with troubleshooting dryers. Is this something I could probably remedy myself or is it something more serious that requires me to call a repair person?
Answer: I had this issue with my electric GE dryer. The plate on the inside had trapped lint that was turning brown and causing the burning smell which smelled like sulfur or burning rubber depending who you talked to. It required unscrewing 3 torx bolts and removing the back plate on the inside of the dryer. I then cleaned out the lint with a vacuum and some wet wipes. I laid the dryer on it's back and put the 3 screws in and voila! Done. 5 minutes of work no more burning smell. Other manufacturers require taking apart the back to access the lint behind the plate. I hope that this helps someone.
Answer: If it smells like burning lint, it's probably burning lint.  If the seals are worn around the lint trap (as evidenced by the amount collected underneath), the interior of the dryer can accumulate lint really fast.  I'd remove the case and vacuum and or blow out the lint that has collected there.
This would also be a perfect time to give your dryer vent a good cleaning.  If it's clogged or severely constricted, this can also cause lint to back up into the dryer chassis.
Either of these situations can be a pretty serious fire hazard, and given that you're already smelling burning, I wouldn't use the dryer until you've done both of these.
Answer:
There is a burning smell inside my clothes dryer after it runs. Does anyone know what that could be?

Yes.  Burning smells are a common indicator that something is burning.  So something is burning.

There is no smoke (thankfully) but it definitely has a mild to medium smell or something burning. I think its a gas powered dryer (its hard to get to the back too look) but the smell is closer to burning lint than to gas.

Getting to the back to look is going to be easier for you than anyone on the internet.  Use a chair to stand on and take a peek.  Bring a flashlight with you in case there is not ambient light behind the dryer.  Do not drop the flashlight behind the dryer, or fall off the chair.
You could also try shutting off the gas to your house and see if the dryer still works.

Do I just have to let it run some to let it air out? Or, is there something else I should do?

Configure its controls NOT to provide heat, and then run it for a few hours with heat off, in an attempt to move enough air through it to clear smells.  Have a fire extinguisher ready.

I am fairly handy myself but don't have any experience with troubleshooting dryers. Is this something I could probably remedy myself or is it something more serious that requires me to call a repair person?

Open the dryer up (remove the outer casing and look inside).  Use visual sensing to identify the area or areas that are chared, and replace them with OEM parts from the manufacturer.
Comment: You aren't really helping your case...
Comment: Gee willikers!  I hope that makes you feel warm inside.  You'll need it this winter, after this dryer burns your house down.
Comment: I marked the other answer as correct even though yours was technically correct because that answer was not as condescending as your answer.
Answer: You may also want to check if you have any cracks on the blower wheel. This could also cause a burning smell on your dryer
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Answer: Lint fire in a gas dryer is more likely than in an electric model.  Accumulated lint close to an open flame is not good!  Disassembly to access the floor, gas valve assembly and chimney is required for cleaning.  YT videos are available to help. 1/4" and 5/16" magnetic nut drivers make the job easier!
Comment: directing someone to do more searching isn't really the quality we expect in an answer around here.

Burning smell in my clothes dryer


Math.Atan2(double.NegativeInfinity, double.PositiveInfinity) - bug, or undocumented breaking change?

Question: Consider double result = Math.Atan2(double.NegativeInfinity, double.PositiveInfinity);.
In .net 4.8 this returns NaN.
In .net Core 3.1 or later this returns -0.7853981633974483.
The documentation for Math.Atan2() states:

If x or y is NaN, or if x and y are either PositiveInfinity or NegativeInfinity, the method returns NaN.

I suppose "either PositiveInfinity or NegativeInfinity" could mean "both PositiveInfinity or both NegativeInfinity" in which case it would not apply to my example (because x is NegativeInfinity and y is PositiveInfinity) but that seems rather subtle - and in any case, it still seems to be a bug or a breaking change.
So is this a bug or an undocumented breaking change - or am I just misunderstanding things?
(I discovered this because after porting one of our unit test libraries to .net 5 some unit tests started failing because of this change in behaviour.)
Comment: The C function `atan2` gives -0.7853981633974483 (-45 degrees) too (check `man atan2`). It seems like .NET Framework is the odd one out here.
Answer: This looks to be the result of a fix of a mismatch between the old behaviour and the IEEE 754 specified behaviour. But the documention hasn't caught up to the new behaviour yet.


Rails 3 Resource routing for join models

Question: I have a many-to-many relationship between users and teams (as a has_many :through), and I'm trying to setup a "team members" join model as a resource in the routes.
In my layouts I've setup a "team context form" that sets a session variable for the current_team, and I want the route for the team_members resources to be defined as /team_members/:user_id/show.  Is there any way to do this with the resources :team_members in routes.rb?
I've tried using :path_names => {:action => "\some\url"}, however for actions that require an :id the router appends the route to be something like "\:id\some\url"
Answer: edit:
If you want to be able to edit the team membership, you could have
resources :users do
    resources :team_members
end

and then, to edit the membership => /users/:user_id/team_members/:id/edit
And then you can do whatever you want in the team_members_controller.
Or as numbers1311407 said, just resources :team_members and you'll have all the rest routes to work with the team memberships.

Really don't want the standard /teams/:team_id/users/:id ?
If you really want /team_members/:user_id/show
You could just do
get "/team_members/:id/show" => "users#show"

But I dont think it's a good idea.
Comment: "users#show" and "users#edit" are actually different from the route and view that I actually want.  I want to be able to edit and show based on team context which user is in the team, and be able to change their permission status as a member of that team.  Since permissions are defined as a part of the `team_member` model, I want to essentially be able to change that one string as an admin of the `current_team`;  I really haven't found a way of doing this other than setting up the routes individually as part of a namespace.
Comment: This reinforces the argument that team_member (the membership) should probably be treated as its own distinct resource and referenced by id, which eliminates all route complications.  It would also allow you to singly nest membership resources under both users and teams.

/memberships/:id,
/users/:user_id/memberships/:id,
/teams/:team_id/memberships/:id
Comment: It is by default, right? If he set up a join model, it automatically has an id. edit: sorry, didnt see his comment on your post :)
Answer: if the relationship is many-to-many then the route you're looking to write doesn't reference the team, unless this show page is intended to show all teams a user belongs to?
This would work out of the box if you assigned an ID to the join model and simply used its natural GET route, e.g. /team_memberships/:id
Edit: sorry I didn't read the 2nd paragraph carefully, if you are storing the team in the session you could (as suggested by someone else) set up team_members as a singleton resource and pull the team from the session when getting the member.
If it works in the app, though, considering team_membership as its own resource is probably more naturally RESTful.
Comment: I had apparently set the `id => false` in the migration as previously I was going for a habtm.
Answer: I wonder if what you're looking for is:
resource :team_members do
  resources :users
end

The "resource" command creates a route where team takes no :id and would allow you to look up the team using your current_team session variable.
You'd get these path in your app:
/team_members            #  team_members#show
/team_members/users      #  users#index
/team_members/users/:id  #  users#show

In each case you're responsible for looking up current_team.


Get back to gnome/Enlightenment from the command line

Question: So say I accidentally hit CTRL+ALT+SHIFT+BACKSPACE and drop to the commandline from my nice clean engligntenment interface. How do I then get back?
I've tried startX, Xwindows, gnome but none of those commands seem to work. Any idea?
Answer: You should be able to restart Enlightenment by opening a command line and running the following command:
<code>/usr/bin/enlightenment_start &</code>


difference ways of css property checking Jquery vs regular

Question: I was wondering what would be the difference in these two codes
$('.stars li').each(function(i){

  if(this.style.display !== 'none'){
    this.style.display = 'none';
    return false;
  }
});

and this code
$('.stars li').each(function(i){

  if($(this).css('display', '')){
    $(this).css('display' = 'none');
    return false;
  }
});

why the first one iterate over each li element, however the second one doesn't it stays on the first element?
Answer: $(this).css('display', '')

is an expression that evaluates to a value - what it evaluates to is the $(this) jQuery object, which has also had its display changed. So the condition
if($(this).css('display', '')){

will always be satisfied, because objects are truthy.
Use $(this).css('display') === 'none' instead (one argument) to retrieve the current computed display style.

if ($('div').css('display') === 'none') {
  console.log('Div hidden');
} else {
  console.log('Div not hidden');
}

if ($('span').css('display') === 'none') {
  console.log('Span hidden');
} else {
  console.log('Span not hidden');
}

Keep in mind that
this.style.display

checks the display property on the element itself, whereas
$('div').css('display')

checks the computed display property. The element may have a display applied (eg, from CSS like div { display: none }) despite not having a display property of the element's own style object.
Comment: Thank you soo much that was clear enough, so I would say its better to use the this.style.display than $('div').css('display') since the div properties has already css by default which is { display: none }


Custom quick action on a widget

Question: I am trying to develop a custom quick action window to be shown on clicking on the widget.
Something similar to what is there in Twitter application (Android Quick Actions UI Pattern). Am facing problems in adding custom quick action view due to limitations of the remote views used in widgets.
Could any one please help me on this??
Thanks,
Kabini
Answer: You might want to have a look at this:
http://code.google.com/p/simple-quickactions/
It's a short, easily-digested demo of a possible approach for implementing something similar to Quick Actions.

Custom quick action on a widget


Easiest way to get the "ride a pig off a cliff" achievement?

Question: I'm having some difficulty getting this achievement - currently I am placing my saddle on a pig close to a cliff, but as soon as I jump on the pig always turns around and walks back towards safety..
Any tips on getting my porcine friend to play nice?
Comment: Title should read "How do I ride a pig off a cliff?" :)
Answer: Update ver 1.4.2 added a Carrot on a Stick, an item used to control where the pig will move and where it will move.  Using that will enable you to easily control your pig for the achievement.
It is a good idea to have the Feather Falling enchantment on some armor to protect yourself from the fall; also advisable is having a pool of water below to break your fall (no fall damage, qualifies for achievement)
Comment: Carrot on a Stick was added on Oct 25, 2012 (ver 1.4.2). Added to dev versions on Sep 6th, 2012 (12w36a).
Answer: Here's how one guy got it done:
Comment: Once the pig is near the ledge, you can hit it (while still riding it) to bump it off. No need to wait for the pig to jump.
Comment: I can't help but think pushing it off with water would be easier than that video
Comment: Seems like overkill, according to [this](http://gaming.stackexchange.com/questions/20844/how-high-must-a-cliff-be-to-fly-a-pig-off-of-it).
Comment: I agree, this is a little overkill but basically how I ended up doing it - you don't need to dig such a large pit, just enough for the pig to take damage
Answer: You can help yourself with a bucket of water placed opposite to the cliff. The flow will push the pig off.
Answer: Use a carrot on a stick to guide the pig off the cliff, but it's recommended you have diamond boots enchanted with feather falling if the cliff is more than 22 blocks high.


Using Types.NVARCHAR with oracle JDBC driver to work with Cyrillic chars

Question: I am trying to use the "New Methods for National Character Set Type Data in JDK 1.6", to get a standard JDBC solution to handle cyrillic chars, but when the execution reaches any line with NVARCHAR type, for instance:
preparedSelect.setObject(3, "суббота", Types.NVARCHAR);

Then I get this exception:
java.sql.SQLException: Invalid column type
    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:131)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:197)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:269)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:490)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7922)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7502)
    at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:7975)
    at oracle.jdbc.driver.OraclePreparedStatementWrapper.setObject(OraclePreparedStatementWrapper.java:222)

I also tried to use setNString() but I get an even more strange exception:
java.lang.AbstractMethodError: oracle.jdbc.driver.OraclePreparedStatementWrapper.setNString(ILjava/lang/String;)V

If I use java -Doracle.jdbc.defaultNChar=true myApplication with regular Types.VARCHAR, the Russian words are stored correctly. But using -Doracle.jdbc.defaultNChar=true is not an option since I'm working on a legacy application, I do not have control of running production environment, I'm just writing a component to it. Furthermore, this "Readme for NChar How-to" states that "This conversion has a substantial performance impact". So setting everything to NChar by default when only less than 1% of my tables needs this conversion in not a smart choice.
I'm using oracle thin driver and I have ojdbc6.jar and orai18n.jar in my classpath.
I'm looking for a standard JDBC solution. I can not use any methods or constants with "oracle" on them. OraclePreparedStatement is not an option for me.
I tried using Types.NVARCHAR with MSSQL Server and it runs fine.
Comment: Did you try using setNString() and see if it works?
Comment: I edited my question with an update about setNString()
Comment: To rule out the obvious: did you try to call the good old `setString()`? I have successfully stored arabic characters with that.
Comment: Yes I did. I only get upside-down question marks stored there ('¿¿¿¿¿'). This is because the default oracle charset is not UTF8. I have Oracle XE installed on my local machine and it stores fine using regular setString(). But I can't go asking more than 50 clients to change their default database charset, since they already have UTF16 for N-charset.
Answer: I found the solution!
I was using ojdbc 188.8.131.52. When I switched to 22.214.171.124, I could get setNString() working properly.
 But I'm still getting the same java.sql.SQLException: Invalid column type if I use setObject() with Type.NVARCHAR. Shame on you Oracle...
Anyway, the solution: switch to ojdbc 220.127.116.11
Answer: I managed to make it work some time ago with the following incantations. These methods are an excerpt from a bigger class.
import com.mchange.v2.c3p0.C3P0ProxyStatement;
import oracle.jdbc.OraclePreparedStatement;

    static {
        try {
            SET_FORM_OF_USE_METHOD = OraclePreparedStatement.class.getDeclaredMethod("setFormOfUse", new Class[] { Integer.TYPE, Short.TYPE });
        } catch (NoSuchMethodException ex) {
            LOG.fatal("Can't find the setFormOfUse method", ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException {
        if (st instanceof OraclePreparedStatement) {
            ((OraclePreparedStatement)st).setFormOfUse(index, OraclePreparedStatement.FORM_NCHAR);
        } else if (st instanceof C3P0ProxyStatement) {
            try {
                C3P0ProxyStatement c3p0St = (C3P0ProxyStatement) st;
                c3p0St.rawStatementOperation(SET_FORM_OF_USE_METHOD, C3P0ProxyStatement.RAW_STATEMENT, new Object[]{index, OraclePreparedStatement.FORM_NCHAR});
            } catch (IllegalAccessException ex) {
                throw new UnexpectedException("Error calling setFormOfUse through C3P0", ex);
            } catch (IllegalArgumentException ex) {
                throw new UnexpectedException("Error calling setFormOfUse through C3P0", ex);
            } catch (InvocationTargetException ex) {
                throw new UnexpectedException("Error calling setFormOfUse through C3P0", ex);
            }
        } else {
            throw new IllegalArgumentException("Unkown PreparedStatement implementation: " + st.getClass() + ". Maybe an unknown connection pool is hiding the OraclePreparedStatement?");
        }

        st.setString(index, (String) value);
    }

The nullSafeSet method is structured to work directly on OraclePreparedStatement instances, or on C3P0ProxyStatement in case you have the C3P0 connection pool; other options will have to be used in case of different pools.
This method worked with the ojdbc14.jar from Oracle 10.2.0.4.
Comment: As we can see in "New Methods for National Character Set Type Data in JDK 1.6" they say "use the setFormOfUse method... ...is discouraged because this method will be deprecated in future release" and they also say: "If the setObject method is used, then the target data type must be specified as Types.NCHAR, Types.NCLOB, Types.NVARCHAR, or Types.LONGNVARCHAR"
Comment: The problem with this solution is because it is Oracle dependent. I am looking for something JDBC standard since our system works in both MSSQL Server and Oracle. Looks like Microsoft JDBC driver is more Java compliant than the Java "owner" itself.
Comment: As far as ojdbc14.jar is implied, there probably is no standard jdbc way to do it. I'm not sure about the driver version you are using; anyway, if this works, you could use it for oracle, and revert to the standard way for everything else.


Javascript snippet not working in Chrome, but works in Internet Explorer

Question: I have a really basic snippet of javascript code that works in Internet Explorer, but not Google Chrome. Here's the line it breaks on:
var formChildren = document.getElementById('myForm').children;

This is the first line in my script. The error I receive is:
cannot read property 'children' of null.

Does anyone know if I'm missing something? I can't imagine why Chrome would error out on such a basic line.
This is part of an MVC 4 project if that makes any difference.
Thank you in advance!
Comment: Do a console.log of `document.getElementById('myForm')`.  Does it print null?
Comment: It appears to be working in Chrome, at least in a simplified version: http://jsfiddle.net/XRFAb/
Answer: Chrome actually does return null in an instance where it is unable to find an element with that ID. You could hide this error by using (document.getElementById('myForm') || {}).children
Answer: My problem is solved. Yes I did some extra testing and realized that I was able to use getElementsByName successfully on both IE and Chrome so I took a look and realized I forgot to add the Id to the form. It was still unexpected that IE knew what it element was without the id set, but the problem is solved.
Thank you Kyle and hackNightly, your input helped a lot in narrowing down my answer.


The sum $\sum_{k=0}^{n} (-1)^k \frac{{n \choose k}}{{n+k \choose k}}=\frac{1}{2}$

Question: The sum $$\sum_{k=0}^{n} (-1)^k \frac{{n \choose k}}{{n+k \choose k}}=\frac{1}{2}?$$ can be checked by Mathematica. Here, the question is how to do it by hand?
Answer: Let $$S_n=\sum_{k=0}^{n} (-1)^k \frac{{n \choose k}}{{n+k \choose k}}= \frac{n!^2}{(2n)!} \sum_{k=0}^{n}(-1)^k \frac{(2n)!}{(n-k)!~ (n+k)!}=\frac{1}{{2n \choose n}} \sum_{k=0}^n (-1)^{n-k} \frac{(2n)!}{k! (2n-k)!}=(-1)^n
\frac{1}{{2n \choose n}} \sum_{k=0}^{n} (-1)^k {2n \choose k}=\frac{1}{2}.$$


Prove that the infimum of half-open intervals contained in O is also in O

Question: Let O be a non-empty open set. Let $x \in O$ and define $a_x = \inf \{a \in \mathbb{R} \mid (a, x] \subset O\}$. Prove that $(a_x, x] \subset O$.
The question seems pretty straightforward but I do not know how to clearly prove that the half-open interval of the infimum is also entirely contained in O. I know that $(a_x + \epsilon, x] \subset O$ for any $\epsilon > 0$ by definition of infimum. How can I conclude from here that also $(a_x, x] \subset O$ itself?
Comment: I edited this for proper use of \mid, and the difference is visible.  I also put in a proper use of \inf, and that becomes quite visible in expressions like $a\inf b$, which appears as $a\text{inf}b$ if \text{inf} is used instead of \inf, and in a "displayed" context, a\inf_{c\in C} b appears as $\displaystyle a\inf_{c\in C}b$, and that doesn't happen with \text{inf}. ${}\qquad{}$
Answer: Let $y\in(a_x,x]$. If $y=x$, then clearly $y\in O$. If not, then $y\in(a_x,x-\varepsilon)$ for some $\varepsilon>0$. Hence there exists $\delta>0$ such that $|y-z|<\delta$ implies $z\in(a_x,x-\varepsilon)$. Therefore $y\in(y-\delta, y+\delta)\subset (y,x]\subset O$, and as $y-\delta>a_x$, it follows by the definition of infimum that $y\in O$.


Why does my code throw up an extremely odd error code?

Question: I am doing Georgia Tech's CS1301xII lately. However, this question's error message is just strange
mystery_list = ["Taylor Swift", "Twenty Two", "Georgia Tech"]

#You may modify the lines of code above, but don't move them!
#When you Submit your code, we'll change these lines to
#assign different values to the variables.

#Above is a list of strings. Don't worry if this syntax is a
#little unfamiliar, we'll talk you through it and then cover
#it more in chapter 4.3.
#
#Write some code that will count the number of instances of
#the letter 't' in the list of strings. Count both capital
#'T' and lower-case 't'. Then, print the number of instances
#of the letter 't'.
#
#For example, with the list declared above, you would print
#6: two in the first string, three in the second, one in the
#third.
#
#Because we haven't used lists very extensively, we've
#gotten you started. The loop below will iterate through each
#string in the list. Next, you want to iterate through each
#letter in the current string, check if it's a t, and
#increment a counter if so.

#You'll want to add some code before the loop here.
counter = 0
listnum = 0
listletter = 0
for string in mystery_list:
   while listnum <= len(mystery_list):
       if mystery_list[listnum][listletter] == "T" or mystery_list[listnum][listletter] == "t":
           listletter += 1
       if listletter > len(mystery_list[listnum]):
           listletter = 0
           listnum += 1

This is the error message:

../resource/scripts/run.sh: line 1:   669 Killed                  python3 $VOC_SELECTED_FILE
  Command exited with non-zero status 137

If it were a usual error like syntax or division by zero or pretty much every single error, it would give me the non-zero status 1.
So my questions are:
1. How do I fix my code
2. What does this error message even mean???
Comment: Does it take like 30 seconds or some other seemingly fixed time for that error to appear? Then it probably means that the server is killing the script because it's running for too long, probably because you have an infinite loop.
Comment: Ok, thanks. It was an infinite loop. It was taking forever
Comment: But how should I fix it?
Comment: Error codes are not completely standard but 137 usually means out of memory. Your infinite loop ate it all up.
Answer: You have an infinite loop in your code. listnum is always 0 causing Infinite while loop. So the server is terminating your script giving the weird error.
Here is a simple solution:
mystery_list = ["Taylor Swift", "Twenty Two", "Georgia Tech"]
counter = 0
for string in mystery_list:
    counter+=string.lower().count("t")

Answer: Edited on your code.
mystery_list = ["Taylor Swift", "Twenty Two", "Georgia Tech"]
counter = 0
listnum = 0
listletter = 0
for string in mystery_list:
    while listnum < len(mystery_list):
        print('Letter:',mystery_list[listnum][listletter],'sTRING: ',mystery_list[listnum])
        if mystery_list[listnum][listletter] == "T" or mystery_list[listnum][listletter] == "t":
            counter += 1 # increment counter only if T matches
        listletter +=1  # iterete forworward no matter what
        if listletter >= len(mystery_list[listnum]):
            listletter = 0
            listnum += 1

Changes:

you forgot to increment counter, instead incremented iterator variable.
listletter reset condition must be >= as index starts from 0.


Not able to disable zoom with meta tag

Question: When i try to disable zoom with a meta tag like this:
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

The only result i get is that the page starts zoomed really in and all the divs that are sized after %, get way to small because the page automaticly zooms out again and I am able to zoom anyway. So this method did not work for me at all. My question is there any other method or is there something wrong with the current method?
Comment: What device did you test this on?
Comment: *" because the page automaticly zooms out again"* - Any Javascript in your page which changes styles?
Comment: I tested it on my iphone in safari, the same problem occurs in google chrome inspector when it is in mobile mode. @KobyDouek
Comment: I do change the opacity and visibility of some elements trough javascript. @KobyDouek
Comment: ...still open? Did You tried by adding `shrink-to-fit=no` to the viewport`meta tag?
Answer: This works IOS 10
document.addEventListener('touchmove', function(event) {
    event = event.originalEvent || event;
    if (event.scale !== 1) {
       event.preventDefault();
    }
}, false);

Or
<meta name="viewport" content="width=480, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,target-densitydpi=device-dpi, user-scalable=no" />

Comment: This made accidental zoom not happen, but i can still zoom if i really try.
Comment: The other suggestion did the same as Chandra Kumar's answer
Comment: try this
Answer: Try this:
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,target-densitydpi=device-dpi, user-scalable=no" />

Comment: This made zoom disabled but it starts the page way to zoomed in so the divs get weird
Answer: Is there any Javascript on your page which puts focus on a form field when the page loads? That would cause zooming on an iPhone, especially if the font size of the field is less than 16px.

Not able to disable zoom with meta tag


Can I refresh the server status without logging out/in?

Question: A friend and I want to join a server that is FULL, so we are waiting for a moment when the server becomes VERY HIGH in population to join.
As far as I know, logging out and in is necessary to refresh the server list.
I can't find on google any server list to refresh on the go to avoid this cumbersome method.
Is there anything like that?
Answer: Clicking on world selection just randomize the world list, it does not refresh or update it. As far as I know, logging in and out would be the only option to refresh the world list. Also, you may want to check this question I made.


11/16 OD Toilet shut off

Question: My house is 1920s, New England. its been upgraded and added onto a few times.
2nd floor toilet shut off was leaking.
I cut off the valve as I was unable to safely get a torch on it to un-solder it.
I shut off hot and  cold water to the 2nd floor as the faucet and tub have mixing vales.
The supply ID is 1/2" so I got this  1/2 in. Nominal Compression Inlet x 3/8 in. O.D. Compression Outlet 1/4-Turn Angle Valve
To my horror, the OD of the pipe is 11/16 (maybe brass? older copper?)
As I understand, 1/2" copper is 5/8 OD so my part doesn't fit.
.
What part(s) do I need to button this back up?
Comment: Not answer to your question but about the size, I wonder if newer pipes have thinner walls due material cost, better manufacturing etc
Comment: Photo of the pipe cleaned up might help.
Comment: I'll try to get a photo in here, but really it's just a few inches of pipe coming out of the wall.  11/16 OD, 1/2 ID.  Can't find adapters or valves to get there.
Comment: You can not get the  nut and compression ferrule over the pipe ? Have you cleaned it by sanding it with emery cloth ?
Comment: @AlaskaMan exactly. Pipe OD is too big.  I haven't fully cleaned it up yet wit.  but it's very clearly too big. I mean I could sand it down, but I would have to remove so much, I doubt I'd be able to keep it uniform enough to trust putting a fitting on.
Comment: @Zipper1365 I was just trying to ascertain if it had been cleaned down to bare metal. Perhaps you could see how a 7/8 ferrule would fit. https://www.buyfittingsonline.com/7-8-in-sleeve-brass-compression-fitting-sae-060115/ IF it would compress to seal then Maybe an adapter to go from 7/8 to threaded ?  Such as https://www.homedepot.com/p/BrassCraft-7-8-in-O-D-Brass-Compression-Union-Lead-Free-62-14X/300293410 I found brass pipe that has 11/16 O.D. but no ferrules yet.
Comment: To clarify, I suppose this doesn't have to be compression. I was not comfortable un-soldering this valve here (I'm just not steady enough for near fished walls). so just figured cutting it and replacing with compression would be easiest. I do  know someone else who has more finesse than me and could solder something in if there is an adapter that would fit on the inside the 1/2" ID maybe?
Comment: Hey, I think I'm seeing that 3/8 copper pipe has 1/2 OD.  might I be able to step this down to 3/8 copper (and a 3/8 valve) by inserting 3/8 pipe or 3/8 FTG x MIP it into the 1/2 ID of the supply pipe ?!
Comment: If there was a valve soldered directly to it, it would be very strange if it were something other than common pipe size. Can you *please* post a picture of the pipe with the old valve held up next to it?
Comment: Did you cut it or sweat it off ??  It just does not look like copper or brass, the thickness of the wall would suggest steel.  If you cut it are you sure you did not cut threads off ?
Comment: I cut it with a small pipe cutter. it felt soft like copper - i imagine steel would not have been so easy. and the cross section definitely had a rosy/coppery color to it. is chromed copper/brass a thing?
Comment: That first pic with the calipers looks like you're measuring the width of the pliers' handle. It took a minute to realize that the ID prongs were inside the pipe itself!
Answer: Here is what I determined after some research
Some (many) people seemed to think that this was caused by water freezing in the pipe and expanding the tubing but others debunked that because it tends to split the pipe and there would be other evidence of the freezing. I also don't believe that it was a freeze cycle.
Pipe and tubing sizes were set in the early 1900's BUT apparently Westinghouse supplied an 11/16" pipe which was more commonly installed on the west coast but can also be found throughout the country. Some plumbing supply houses carried fittings through the 1980's until they were considered obsolete and unnecessary.
The problem was solved in a couple of ways:

use a swage tool to sweg it out to receive a 1/2" pipe soldered on to it
have couplers made out of copper stock on a lathe
Comment: Thanks for looking into that a bit for me!  I suspect that this bathroom was redone in the late 80s or early 90s so that explains the source of the current (now removed) valve and the lack of availability of a direct replacement. I'm going to wait a bit to accept an answer in case there are other options out there, though. I'm hoping for a more or less off the shelf solution.
Comment: I accepted your answer since it addressed the question as it was posed. however. I've since discovered that there's a lot I don't know! turns out that this was/is standard 1/2 copper that had a sleeve over it. the valve and the sleeve were a packaged deal. that's why the walls appeared thicker and that's why noting fit it to do what I wanted. I have since been able to painstaking remove the sleeve and and attach a standard compression shut off to the stub
Comment: I ran into a very similar situation yesterday. I believe I have a BrassCraft valve with a 5 inch extension (model  CS41/ CS41B/ CS47) that is soldered/sweated onto a standard 5/8 OD tube. So the inner diameter of the extension tube of the valve assembly is sufficient to accommodate the outer diameter of the copper tubing.

I hate soldering so I am trying to get a plumber to come out and do the repair. For the future, if I encounter a valve like this that does not turn off, I will simply put in a repair value that has 3/8 inch for both input and output.
Comment: @Zipper1365 - it would be good of you to write that up in an answer. Certainly leave your up vote & check mark here, since Ack helped you out so much, but because your answer is buried in a comment, [others](https://diy.stackexchange.com/a/232415/34147) might not read all the comments and see your answer.
Comment: Thanks for the answer accepted and especially for checking back in to fill in the rest of the story, that will surely help others at some point. I'm glad that it worked out
Answer: After more investigation, it turns out that this was/is standard 1/2" copper that had a solder-lined sleeve over it. The valve and the sleeve were a packaged deal. That's why the walls appeared thicker and that's why nothing fit it to do what I wanted.
The photos in this question show the sleeve quite well.  In my case, unfortunately, the end of the sleeve was in the wall and not visible for my initial assessment.
The pipe cutter obscured the two layers in the cross section and likely also added an internal lip that gave me an incorrect inside diameter reading.
I have since been able to get heat and pliers on it and was able  to painstakingly remove the sleeve peeling back bit by bit like a bad tin can lid. After peeling back enough of it, I was able to attach a standard compression shut off to the stub.
Soon after adding the compression shut off, I realized that in my heavy heating to de-solder the sleeve as I peeled it back, I may have melted an upstream fitting.  Not knowing how far away that might be tucked in the wall, I opened the wall and found a questionable looking upstream elbow joint just behind the drywall.
I replaced the elbow and stub like I should have just done in the first place.
Answer: I have the same issue-in New England this was common into the 1990s.  This is a chrome plated copper tubing used for toilet water feeds. 11/16" OD is correct. Only solution is to call a plumber. Not something you can get at a Home Depot/Lowe's.
Comment: Not sure that "call a plumber" is "the only solution", since the OP had another solution noted in the comments on the accepted answer. Of course, that points to putting answers in comments as a `Bad Idea™`, since people miss information when that's the only location for it.

11/16 OD Toilet shut off


VMware: kernel headers not found!

Question: Just updated my ubuntu to 20.04 and when i tried to run VMware and VMware Kernel Module started compiling Virtual Machine Monitor and Virtual Network Device and it failed
i started VMware using terminal and i had this issues:

/bin/sh: 1: flex: not found

which i fixed by installing flex
and

Cannot open /dev/vmmon: No such file or directory

that i don't exactly remember how i fixed and now i'm getting this window that says:

Kernel headers for version 5.4.0-39-generic were not found

but i have headers installed as you can see here!
Comment: I had a similar problem. This instruction page helped me https://www.tecmint.com/install-kernel-headers-in-ubuntu-and-debian
Answer: Everytime that my Ubuntu MATE 18.04 LTS updates something related to the kernel, VMware Workstation stops working and errors out with the same message that you are reporting: Kernel Headers not found.
The following solution works, most of the times, for me.
Manually installing the missing headers
Open a terminal and install the headers that VMware wants; following your screenshot, the command should be:
sudo apt install linux-headers-5.4.0-39-generic

After this installation, restart VMware and it should change the error window for a window of "Several modules must be compiled and loaded into the kernel". Press Continue, and wait until it finishes.If says an error mid-instalation, close VMware and try it again; most of the times I have to go though some errors before it finishes correctly.
Please do note that, at least in my case, the linux-headers version it wants tends to be different every time this error appears.
But sometimes, the solution above will not work, and ocasionally I'll find out that VMware requieres an already-installed header that does not want to be detected (like your problem).
Removing and reinstalling the required headers
We are going to remove the header VMware is referring to and then manually reinstall it.
First of all, run this command to see which header is currently in use:
uname -r

If the current header is the one that VMware is complaining about, then DON'T CONTINUE.Only remove the header version if you know that you are not using it currently.
To remove a header, just do an apt purge like you would do with any other apt package.
sudo apt purge linux-headers-5.4.0-39-generic

Now that's removed, reinstall it again with:
sudo apt install linux-headers-5.4.0-39-generic

Once installed, fire up VMware again and see if it works or not.

VMware: kernel headers not found!


Linq-to-sql speed when getting table count

Question: Is this:
Dim mydata = (From c In dc.Table Select New With {c.ID}).Count

any faster than this:
Dim mydata = (From c In dc.Table Select c).Count

assuming the table has a good number of fields?
Comment: If you post code, XML or data samples, **PLEASE** highlight those lines in the text editor and click on the "code samples" button ( `{  }` ) on the editor toolbar to nicely format and syntax highlight it!
Answer: The short answer:  no.
The SQL generated by the LINQ-to-SQL engine should be essentially the same for both forms (if not exactly the same) because you're calling .Count() immediately on the query.
A compiled query version, on the other hand, would be faster after the first execution.  Here's one way to do a compiled query for this:
Public Shared FetchCount As Func(Of DataContext, Integer) = _
    CompiledQuery.Compile(Function(context as DataContext) _
        (From c in context.Table Select c).Count())

DataContext would need to be the Type of the LINQ-to-SQL DBML, and Table would need to be the appropriate table.  And, I believe you'll need to import System.Data.Linq to have access to CompiledQuery.
Comment: @ChrisPhelps - thanks - remember to upvote if you think the answer is good.  It gives us all warm-fuzzy feelings.


Connecting to a VPN on a remote linux server (VPS) fails

Question: I've been trying to connect to a VPN through my Ubuntu VPS, but every time I try, the server shuts down.
Perhaps the connection blocks the ssh, and all the traffic when I try to connect?  I tried connecting with a VPN to a Dedicated Server with Ubuntu Linux, first 18.04 then 16.04, and to a virtual private server with Ubuntu Linux. Both failed, so at least I know there's no difference.
I just get disconnected and I can't connect to my VPS unless I reboot it. Is there any way I could set up a VPN on my VPS or at least is there a way to change my VPS internal IP multiple times?
So I'm using the NordVPN .deb application. After I successfully install it, I connect with my password and email, then I use ''nordvpn connect'' (sometimes I specify the server which I want to connect to, for example nordvpn connect es/br/us/etc). It says Connecting.. then the linux server just freezes, and in about 10 seconds I get disconnected.

But I didn't stop there. I tried using NordVPN manually via OpenVPN. I installed the packages, and the same thing happened, after I connected, the VPS just dropped, and I had to reboot it.
I don't have any errors to show since it's just connecting - failing - shutting down. It might also be the service I use for VPS however I'm really desperate to find a service that allows me to use VPN. I really need it for my project and In 2 attempts all failed.
Please let me know if you need further information in the comments and I will edit the question. I might have missed some things since it's pretty late, tried to work this out all day.
Comment: WhIch release of Ubuntu did you try bare metal, and in the VPS? Can you try an alternate version?
Comment: I tried this on Ubuntu 18.04.  I'm not sure what do you mean as an alternate version. @K7AAY
Comment: Fer exx, 16.04, 19.10
Comment: I have tried on 16.04 too.
Answer: the server doesn't shut down or freeze, it gets disconnected from the shh because the traffic is being forwarded from the vpn ip.
I reboot multiple times my server trying to connect with a vpn on, but the vpn was starting with the system reboot.
I realize that it was still possible to connect to the server using the web console of linode.
I checked for the vpn service status and it was connected through US-C UDP (443). Typing:
curl http://ipinfo.io/ip

I checked for my ip. It was a different ip.
I think if you need to change VPS internal IP multiple times you could use a firewall to be able to connect to the ssh while vpn is connected, or you could use a shh script to disconnect  the vpn once the task you need the new ip for is completed.