Error:Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'navigationVersion'

Question: I get this error when make two changes
first, add the following dependency in my build.gradle file
dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$version_kotlin"
        classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"

Second add the line to my build.gradle(module) file
apply plugin: 'androidx.navigation.safeargs'

Answer: You need to specify your navigationVresion like below
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha01"

currently, you used a variable like navigationVersion but that variable is not defined in your Gradle file.


How do you reload and keep your reserve ammunition?

Question: When reloading in Advanced Warfare, there is something known as "Speed Reload" which let's you reload faster, at the cost of the entire magazine.
Being someone who has a somewhat bad habit of reloading after every kill, I do not want this to happen...
How do you reload normally and keep your magazine?
Answer: Speed reload is a new feature.
To perform a "classic" reload, tap "X" (on Xbox) or "Square" (on PS) once. This will reload your gun while keeping your ammo.
To perform a "quick" reload, tap the same button twice quickly. Your character will throw out the current mag, so you will lose the ammo that was remaining in it.
It's in fact very simple to test. Go into a private match, look at your total number of ammo (in mag and in reserve). Shoot 1 bullet, perform a quick reload, and look again at the total number of ammo. Do the same with a classic reload, and you'll see the number is not the same.

Edit:
As said by @Chantola, this might be broken at the time, and you should expect a fix in the next update.
Comment: @Rapitor: SledgeHammer Games released the first patch for AW (available on PC and PS, soon on Xbox), correcting the speed reload bug.
Comment: It seems to work correctly in the firing range area, but in actual matches it is definitely buggy.
Comment: @Rapitor: I have to admit I didn't even notice it's not working correctly in actual matches, I thought it was saving me some ammo but I guess not so much :)
Answer:
This has been addressed before as a glitch that happens to some people, randomly.

There is no fix yet, not even a temporary one. Your unfortunately going to have to live with it (at-least for now), until they patch this bug up.
Source
Comment: that makes sense, seeing as sometimes I keep me ammo and sometimes not. Do you know how to do the different reloads for when the bug is fixed?


should mail.jar and activation.jar go into CATALINA/lib?

Question: I have several apps which require email (smtp) but also want Tomcat's own ERROR messages to be emailed.  I've found this works only if I put mail.jar into $CATALINA_HOME/lib and remove it from all the webapps (~/WEB-INF/lib)
First question: should activation.jar also go into Tomcat's lib folder?
Second question is: What happens if an unmonitored app includes these jars in its own lib? (it seems this breaks the log4j emails for Tomcat.  I'm confused why Tomcat doesn't find and use the classses in its own lib rather than throwing a smtp mail provider exception (presumably due to the multiple occurances of the same mail.jar in the classpath).
Answer: Those jars have to be on Tomcat's classpath if Tomcat uses them. Even if some webapp includes them too, every webapp has its own class loader and these jars are not visible to the lower level tomcat. The WebbappClassLoader implements the child-first delegation model in contrast to the Java default parent-first model.
Comment: thanks.  what isn't clear though is why the Email Appender for Tomcat messages failed when the mail.jar was included not just in the $catalina_home/lib folder but also in one of the webapp lib folders.  as soon as I removed the mail.jar from the webapp things worked.  makes me nervous that someone inadvertently putting mail.jar into a webapp breaks the log4j email appender for Tomcat-leel log messages.  The error is 'no provider' found, which seems to indicate a classpath issue (not finding the properties file in mail.jar).


How can I make facebook like buttons faster?

Question: in my website, for each blog entry I have a facebook like button. So on the index, there is multiple(more than 10 at the moment) like buttons.
These like buttons make my page a bit cumbersome to use. The total page time becomes several seconds and it's laggy/jumpy while loading(even though all the content is loaded) while it's loading. Is there anyway to fix this other than not showing the like button on the index? (a single like button on a page produces negligible lag)
For reference, my website is at http://lastyearswishes.com In firebug, you can see that the page load time is 20 seconds, of which about 200 milliseconds is tied back to my actual website. Each facebook like button appears to do three separate non-cacheable, unique requests.
Afterthought: Now (nearly 2 years later) I decided to give up on facebook. Even with asynchronous code it still enduced a noticable delay in page rendering time. It also uses some stange javascript that screws up my layout. When dropping in twitter buttons, my layout looked immediately the way it should (something with alignment and float that facebook did. I could never use margin or anything to get facebook to line up like I wanted)
Comment: btw, I just broke my website. It's not just you.
Comment: As an aside, I've also found that facebook's buttons are very obstructive to my CSS classes. Because of how little they are used, I'm actually considering removing them or replacing them with something else for social media
Comment: thanks for updating this helped me decide whether or not to include fb like, I decided against in the end
Comment: @SimonB Twtitter buttons are very easy to deal with and they were more appropriate for my audience anyway (tech blog)
Answer: Facebook Developers provides the javascript to create an  asynchronous Like button
found here: Loading the SDK Asynchronously
c/p'd here:

Updated:
Try just this portion (and add #xfbml=1 at the end of the URL, should be the same result on your site but async loading):

Put this script at the bottom of your page
Comment: This doesn't make it faster it just delays the process and allows the page to finish loading.  It makes the user think the page is done loading.  I am still looking for a way that could mass load all the like iframes, maybe something that could be implemented server side.
Comment: I don't have an app ID. I just use the generic "like this link" buttons
Comment: Updated post, should be able to load the facebook .js just like you already have it in your page but this loads it async


'double-conversion/double-conversion.h' file not found

Question: For a turn-by turn navigation/gps app I'm trying to combine React Native and MapBox Directions SDK.
Now I found a couple of medium post about how to bridge RN to Swift. The last couple of days I've been trying to combine them but in every method I use this 1 error pops up all the time:
<code>'double-conversion/double-conversion.h' file not found
</code>
The weird thing is that React-native builds fine without self-written code. After I wrote my own code it just breaks on this error.
Has someone of you guys had this before??
I'm using RN 0.60.4 . I've also tried older versions of RN but when I try to install my pods it doesn't generate my .xcworkspace
Thanks in advance ;p
Comment: See the relevant issue https://github.com/facebook/react-native/issues/25349
Answer: According to React Native issue:

You are using the RN version (0.60.4) which does not work with use_frameworks!. I suggest removing use_frameworks! from your Podfile or using the lastest RN from master.

Moreover, Facebook officially tracks the issue. It is said in release notes.

Note that we are aware of a compatability issue with use_frameworks!, and we're tracking an issue with workarounds and a future patch.


The variation of a function as a function

Question: Let $f:\mathbb{R}\rightarrow\mathbb{R^*}$ be a continuous function (when $\mathbb{R^*}=[-\infty,\infty]=2$ points compactification of $\mathbb{R}$, this is not so much necessary for the question).
Let $g(x)=T_x^b(f)$ be the total variation of $f\mid_{[x,b]}$, $g$ is monotonic function, hence $g$ is differentiable almost everywhere, and in particular g is continuous almost everywhere, which means $g$ is preserving convergence almost everywhere, but is $g$ preserving convergence $\textbf{everywhere}?$
But because $f$ is uniformly continuous (continuous on a close interval),
which means $$\forall\epsilon>0 \exists\delta>0:\mid x-y\mid<\delta\Rightarrow\mid f(x)-f(y)\mid<\epsilon$$ and because $$T_x^b(f)=\underset{P}{sup}\Sigma_{i=0}^{n_P}\mid f(x_i)-f(x_{i-1})\mid$$ when $$P_{n_P}:=\{x=t_0< t_1<...<t_{n_P}=b\}$$
It led me to think that $g$ is preserving convergence $\textbf{everywhere}.$
My attempt was to fix a small $\epsilon$, and build a partition $P$ such that the mesh of $P$ is the $\delta$ that derives from this $\epsilon$, but it is not enough to place in the definition of $T_x^b(f)$.
If $g$ is not always preserving convergence for $f\in C([a,b])$, is it preserving convergence for $f\in AC([a,b])?$
Thanks in advance.
Answer: Hint
Try $f(x)=xsin(\frac{1}{x})$ with $0$ at $x=0$. Then for every $\epsilon>0$ $T_0^\epsilon(f)=\infty$ but $T_0^0(f)=0$.


"Force" User Input and Checking for correct Input Type

Question: I have some functions calling for user input, sometimes string, int or whatever. so i noticed that if ENTER is pressed with NO INPUT i get an error. SO i did some research and i think i found that EVAL function may be what I'm looking for, but then again i read about its dangers.
SO here are my questions:

How can i check/force user input? EX: repeating the input string or maybe even warning user that he didn't enter anything?
how do i check for the correct type of input (int, float, string, etc) against whatever the user types without having my scripts returning errors?

I appreciate your feedback,
Cheers
Comment: Combine exception handling and loops... I think `eval` will not help you at all.
Answer: For question 1: enter pressed when prompted for input results in an empty string returned (are you using input() in your scripts?). Apparently empty string is not a valid input for your functions. For all I know, whatever you enter as the input, you end up with a string returned by input(). To check if a string is empty and repeat the prompt, you may try:
while True:
    answer = input('Enter something: ')
    if answer: break

And for question 2: for checking the type of argument provided, generally the Pythonic way is to handle it with try/except and not check explicitly for each valid/non-valid type. Also, in this scenario you have to do explicit manual conversion from string, so you only check the contents of the string, not deal with other types (at least not yet).  Because of than, you might be interested in string methods or re (regular expressions) module for checking if some particular substring is present (or not).
re module for python3.3 and
string methods for python3.3
For other versions of python, just select an appropriate value in the menu in the top of the page.
Comment: Thanks Mate, I looked for exception handlers and so on and got what i wanted, good suggestion! As for the first point about "forcing" user input your script works like a charm. But could you please translate it to English for me please? if answer: break means something like if there is input for answer break loop, right? but does break HAVE to be next to (:) or can it be below as usual? isn't no input interpreted as input (blank string), in which case why does it work?
Comment: @Newbie break may be in the standard indented block of code, and it is only coded like that (as in my answer above) in very simple cases, but then, for all I know, it's common use to have it in one line. `if answer:` checks if `answer` is True - for Python object truth tests, see http://docs.python.org/3.2/library/stdtypes.html - non-empty string is `True`, empty is `False`, so if the string is non-empty it breaks the loop. You could use `if len(answer) != 0:`, but there is no need for that in Python in most cases.
Comment: @Newbie and for the indentation of `break` in this case - iirc, you can have only non-compound statements in the same line as loop header, e.g. `while True: print('something')` and not a nested `if` or `for` in the same line (without a proper indentation block).
Answer: A reject all input unless of the correct type:
input_ = input('Enter some input: ')
try:
    input_ = int(input_) # or float(input_); str format is used with input() function by default
except ValueError: # can't convert
    pass # or some other friendly error message

To prevent empty inputs:
while True:
    input_ = input('Enter something: ')
    if input_: # if this value is not empty, for example None or ''
        break
pass # continue the program

Answer: To answer your second part of the question you can use the isinstance() function in python to check if a variable is of a certain type.
Comment: Thanks, not exactly what i was looking for but still good to know. The problem with this solution is that i still have to explicitly turn the input into int, float, etc which means i would get and error if i try turning a str into an int, for example. therefore i still have to use the exception handlers mentioned in the answer above. what i mean is that i tried for a couple hrs using isinstance to implement similar results like with try/except with no good results, sigh! thanks again, still good to enrich the knowledge.


Why do I get "file is not of required architecture" when I try to build my app on an iphone?

Question: My app seemingly runs fine in the simulator but the first time I hooked a phone up to my system and had it build for it I got a huge error log with things like:
Build SCCUI of project SCCUI with configuration Debug
CompileXIB HandleAlert.xib
cd /Users/gdbriggs/Desktop/SCCUI
setenv IBC_MINIMUM_COMPATIBILITY_VERSION 3.1
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr
/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/usr/bin/ibtool --errors --warnings --notices --output-format human-readable-text --compile
/Users/gdbriggs/Desktop/SCCUI/build/Debug-iphoneos/SCCUI.app/HandleAlert.nib /Users/gdbriggs/Desktop/SCCUI/HandleAlert.xib

/* com.apple.ibtool.document.warnings */
/Users/gdbriggs/Desktop/SCCUI/HandleAlert.xib:13: warning: UITextView does not support data detectors when the text view is editable.

Ld build/Debug-iphoneos/SCCUI.app/SCCUI normal armv6
cd /Users/gdbriggs/Desktop/SCCUI
setenv IPHONEOS_DEPLOYMENT_TARGET 3.1
setenv MACOSX_DEPLOYMENT_TARGET 10.5
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk -L/Users/gdbriggs/Desktop/SCCUI/build/Debug-iphoneos -F/Users/gdbriggs/Desktop/SCCUI/build/Debug-iphoneos -F/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/System/Library/Frameworks -filelist /Users/gdbriggs/Desktop/SCCUI/build/SCCUI.build/Debug-iphoneos/SCCUI.build/Objects-normal/armv6/SCCUI.LinkFileList -mmacosx-version-min=10.5 -dead_strip -miphoneos-version-min=3.1 -framework Foundation -framework UIKit -framework CoreGraphics -framework MessageUI -o /Users/gdbriggs/Desktop/SCCUI/build/Debug-iphoneos/SCCUI.app/SCCUI

ld: warning: in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/System/Library/Frameworks/Foundation.framework/Foundation, file is not of required architecture
ld: warning: in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/System/Library/Frameworks/UIKit.framework/UIKit, file is not of required architecture
ld: warning: in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics, file is not of required architecture
ld: warning: in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/System/Library/Frameworks/MessageUI.framework/MessageUI, file is not of required architecture
Undefined symbols:
  "_OBJC_CLASS_$_UIDevice", referenced from:
      __objc_classrefs__DATA@0 in SCAuthenticationHandler.o
  "_OBJC_CLASS_$_NSString", referenced from:
      __objc_classrefs__DATA@0 in CCProxy.o
      __objc_classrefs__DATA@0 in AlertSummaryViewController.o
      __objc_classrefs__DATA@0 in HomeLevelController.o
      __objc_classrefs__DATA@0 in SCAuthenticationHandler.o
      __objc_classrefs__DATA@0 in SCRequestHandler.o
  "_UIApplicationMain", referenced from:
  _main in main.o
  "_objc_msgSend", referenced from:
      _main in main.o
      _main in main.o
      _main in main.o
      -[SCCUIAppDelegate applicationDidFinishLaunching:] in

and it just keeps going.
At / near the bottom it says:
ld: symbol(s) not found
collect2: ld returned 1 exit status

What am I doing wrong?
Answer: Solution wich helped me:
Right click on target -> Get Info -> "Build" tab -> Setting with name: Framework search paths add value "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks" and move it to the top of paths list
Comment: This helped me! My problem was trying to run on the simulator, rather than the device. Putting this in solved both issues.
Answer: Did you specify those paths?  Looking at them, they're all pointing at: /Developer/Platforms/iPhoneSimulator.platform/... which explains why you're receiving the file is not of required architecture error;  it's expecting device libraries and its finding simulator libraries.
Comment: I suppose I did, but I'm not sure how, nor am I sure how to fix it.

I'm really new at all this - Mac, objective-c, iPhone, you name it.

Suggestions?
Comment: Note, the only thing I can remember specifying a path for was when I tried to import the MessageUI framework and to import it, I did "maneuver" to the folder you mentioned.  I couldn't figure any other way to import that framework though as it wasn't in the list of existing frameworks when I went to add it, so I clicked on the other... button and browsed until I found it - in the 3.1 simulator folder.
Comment: Ah that's why.  For some reason, the MessageUI framework doesn't show up as an existing framework.  To add it to your project, open up your target information.  (You can do this by selecting your build target, and right-clicking to select Get Info).  On the 'General' tab, you'll see 'LInked Libraries'.  Here you can add new libraries that are actually available.  MessageUI.framework is indeed one of those libraries.  This should solve your cross-platform build issues.
Answer: Old iPhone projects might have the "Framework Search Paths" set to non-existing SDK's like:
*/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/System/Library/Frameworks*

As this is hard-coded it did break as soon as that SDK was deleted by an XCode update.
Then a simulator build fails with basic symbols not found like "_OBJC_CLASS_$_NSString"
The flexible setting for the Target's "Framework Search Paths" is indeed: $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks
The "iOS Deployment Target" needs to be updated to iOS 3.0 as a minimum.
After setting these I could run my old app in the simulator.


Does a copper pipe need to be perfectly smooth to install a compression valve?

Question: I had to remove the compression valve for the toilet during my bathroom floor install.  When I started out I did not know how compression valves worked and ended up putting a lot of power into tightening the nut when I was intending to loosen it :-P Once I finally got the valve off the correct way, I found that my misguided efforts had resulted in a noticeable impression/dent in the copper pipe where the collar (ferrule?) of the valve had sat.  The dent is small, I'd say about on the level of the creases at the joints on your fingers when you hold them straight (I didn't get a picture with the valve off, but including one before I finally got the collar off to give a sense of how I kind of banged it up).
I decided to have a go at simply re-installing a new valve to see if it would work - that was 3 weeks ago and there is just a verrrrrry small amount of moisture below the valve now to suggest that there is just a verrrrry small leak.
Now I'm trying to decide if:

I should remove the valve I installed and cut the pipe so that I have a PERFECTLY smooth surface for the new valve to seal against the pipe.  I've got a pipe cutting tool but am somewhat concerned that I won't have much pipe left protruding once its cut.  I can pull the pipe up a bit with very little force so this doesn't seem like a HUGE issue.

If I do cut the pipe, do I need to cut it all the way down to where that dent is, about an inch, or just enough so that the spot where the collar of the new valve will go will be clean pipe? that i think would require cutting at most 1/2 of the pipe

Can I re-use this "new" collar that I installed 3 weeks ago over the somewhat dented pipe, or should I start afresh with a new one?  I guess I might as well just go new since they're not expensive and that's just a bit of extra insurance for a successful seal.

Any advice is much appreciated, thanks!!
Comment: When you cut the old ferrule off, will you have at least 1 1/4" to 1 1/2" of pipe extending from the wall? This is after you cut it directly behind the ferrule, removing the old nut and escutcheon. More the better. But the answer to your question is sorta, yes it has to be smooth were the ferrule goes, there is a little forgiveness using a compression fitting, a fresh one.
Comment: @Jack when if I cut the pipe where the old ferrule rested (so that it's all clean pipe), I'd have at least 1.5" extending from the floor as it naturally sits, 2" if I lift it a bit.  Another reason I hesitate to cut is that a bit of water still occasionally comes out of the pipe even with the main valve shut off (and all other fixtures open), so it'll be stressful to deal with that while cutting the pipe!
Answer: I have done four things with this second-hand olive issue:

wrap with 4 or 5 layers of ptfe then tighten normally. Usually is fine.

use a sealer such as plumbers mate or equivalent and that has also worked.

replace the olive but as you have compressed the pipe so much you may have to cut the pipe back. To do that you may have to get more pipe and pulling it may not be sufficient so you will have to get behind.

use a solder joint to put a fresh bit of pipe and push it back into the cavity but does depend on the cavity...
Comment: You put it around the olive before assembly so it fills the spaces.
Comment: Thanks @SolarMike!  Re #2 using the sealer - do you mean that's something I could just add to the pipe around the valve I've already installed (that would be amazing), or something that I would need to put around the ferrule during a fresh installation (i'm guessing this is more likely).


Error adding metrix to queue

Question: I am using Eureka, Zuul, Hystrix and composite services in my application. RabbitMq I am using for message queuing. While running test cases, I am getting Following exceptions. My tests are running fine but getting the exception as follows :
11:38:16.597 [task-scheduler-4] ERROR o.s.c.n.h.amqp.HystrixStreamTask -     Error adding metrics to queue
java.lang.IllegalStateException: Queue full
at java.util.AbstractQueue.add(Unknown Source) ~[na:1.8.0_66]
at  org.springframework.cloud.netflix.hystrix.amqp.HystrixStreamTask.gatherMetrics(H ystrixStreamTask.java:289) ~[spring-cloud-netflix-hystrix-amqp-  1.0.0.RELEASE.jar:1.0.0.RELEASE]
at sun.reflect.GeneratedMethodAccessor62.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~ [na:1.8.0_66]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_66]
at  org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMeth odRunnable.java:65) [spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [na:1.8.0_66]
at java.util.concurrent.FutureTask.runAndReset(Unknown Source) [na:1.8.0_66]
at  java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301( Unknown Source) [na:1.8.0_66]
at  java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [na:1.8.0_66]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_66]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_66]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_66]

Comment: Which version of Spring Cloud are you using? I'm getting similar error after upgrading Spring Cloud from Angel.SR4 to Brixton.M4. My RabbitMQ queue is **not** full and at least some metrics do get through.
Answer: It seems your queue is full. Increase the queue length either using x-max-length or x-max-length-bytes property.
More information can be found here
Answer: I experienced similar problem after upgrading Spring Cloud from Angel.SR4 to Brixton.M4. Replacing maven dependency <artifactId>spring-cloud-starter-bus-amqp</artifactId> with
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>

seems to have solved the problem. Depending on your dependencies, this might be helpful!
A more complete look at my deps:
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-redis</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-netflix-hystrix-amqp</artifactId>
        <version>${spring.cloud.netflix.hystrix.amqp.version}</version>
        <exclusions>
            <exclusion>
                <groupId>com.goldmansachs</groupId>
                <artifactId>gs-collections-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.goldmansachs</groupId>
                <artifactId>gs-collections</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-feign</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-hystrix</artifactId>
    </dependency>

Error adding metrix to queue


Conditionally assign a value to variable in .yml file

Question: I have a text file and a yml file
the text file has a variable
is_true = true

And the .yml file has another variable my_value which I want to assign it a value based on is_true condition
I have tried many solutions online but none of them works
For example
Example #1:
{% if is_true == true %}
  my_value:'A'
{% elif is_true == false %}
  my_value:'B'
{% endif %}

Example #2
my_value: $[if(is_true, 'A', 'B')]

I did try other examples as well but I wasn't able to properly set the value.
I am not sure if this is a syntax issue or not.
BTW I do not want to write an ansible task to do this,  just a yml file in which I am trying to set a value to a variable
Comment: You tagged this question with both Ansible and Jenkins, where are you trying to do this? In a playbook? In a Jenkinsfile? Else?
Comment: If this is in Ansible, use the inline-if of Jinja: `my_value: "{{ 'A' if is_true else 'B' }}"`
Answer: Try using the ternary filter:
- set_fact:
    my_value: "{{ (is_true == true) | ternary ('positive', 'negative') }}"
  when: is_true is defined

If the condition in parentheses is true the first value is assigned to my_value i.e. 'positive' - else if the condition is false the second value i.e. 'negative'
The when statement covers the case of is_true setting missing from your config.


Interaction between WPA_Supplicant and Netplan's YAML Files (if any) - 20.04 Wireless Networking

Question: Do WPA_Supplicant.Conf and Netplan YAML files negatively interact?  E.g. should I only be defining wireless APs in one and not the other?
Trying to figure out why my wifi won't work on Ubuntu Server 20.04 (on RaspPI 4 Model B - latest firmware and drivers installed, interface is up using ip link set wlan0 up, and have configured fixed-cable ethernet in netplan 99_wired.yaml.  Unplugged ethernet so that I shouldn't be encountering the auto-switching logic that defaults to wired (I forget the name of that at the moment).  Teed two network blocks into my WPA supplicant file using wpa_passphrase and removed the #psk with the password. Added priorities, country block, ctrl_interface, and update_config=1.  Unable to bring wifi up and start the wpa_supplicant.
I was wondering if I need to remove the wifis block in my 10_wifi.yaml file?  Or add my wifis block to my 99_Wired.yaml file?  Or leave out wifis altogether in netplan yamls because WPA_Supplicant handles it?
Really wish that Ubuntu Server had an easier way to configure wifi - certain projects in the house benefit from server rather than desktop images.
Thanks for your time and patience.
EDIT: even more confusing is from man netplan (quoted here to facilitate discussion):
"Properties for device type wifis:
Note that systemd-networkd does not natively support wifi, so you need wpasupplicant installed if you let the networkd renderer handle wifi."
Okay, clear enough, but then it says...
"access-points (mapping)
This provides pre-configured connections to NetworkManager."
Wtf? so what if I try to add a wifi without specifying access-points, it will complain about access points not specified.  But if I add the access point and password, wth did I put it in wpa_supplicant.conf, and which one is used at runtime?
Comment: Without seeing your .yaml files, it's difficult to assist. Edit your question and show us `cat /etc/netplan/*.yaml` and any WPA Supplicant files that you've changed.
Comment: See my answer below - that $#!^ takes way too much time otherwise.
Answer: Wasn't worth the time to troubleshoot, TBH, so leaving this here for others.  I reimaged the microSD card following these steps:
https://ubuntu.com/tutorials/how-to-install-ubuntu-on-your-raspberry-pi#3-wifi-or-ethernet
To me it is a bit unacceptable that this is the only easy way to make wifi work (during installation/system setup using network-config file).  But it's a workaround and I can now harden the system and actually start the project I intended to do on the Pi in the first place.
Answer: I am working through this myself right now, so I apologize in advance if any information is less than 100% accurate, but I can answer at least a few of your questions definitely:

netplan can run WIFI through systemd-networkd just fine.  I'm using it RN to write this and watch TV.
netplan creates a differently named unit file than the one used by wpa_supplicant (e.g. netplan-wpa-wlan0.service vs wpa_supplicant@.service
It does not look as if the netplan-wpa-ifname.service will collide with firstname.lastname@example.com, as it is named something completely different, avoiding the email@example.com naming convention altogether.
Therefore, you do not need to start email@example.com at all when using netplan
In the vein of the last answer, you do not need to create a/any .conf file(s) in /etc/wpa_supplicant/. if you're using netplan, it extrapolates all the info it needs from your .yaml file in /etc/netplan/..
netplan may need the wpa_supplicant package installed in order to invoke it during authentication to your SSID/AP, but I did just stop wpa_supplicant.service and my WIFI is still working

Sorry I don't have a better answer for that last one, as I am literally working through this right now as I write this.  I saw that your question(s) hadn't been answered, and thought it incumbent to do my part in helping the community.
You could test whether or not you need wpa_supplicant present by simply disabling wpa_supplicant.service before trying to connect to your SSID with netplan.  However, uninstalling it might be dicey, as Ubuntu has a tendency to remove huge meta-packages when people go uninstalling things that are intrinsic to their usage (e.g. uninstalling network-manager removes things like ubuntu-desktop, ubuntucinnamon-desktop, etc. so, disabling NetworkManager via /etc/NetworkManager/NetworkManager.conf in order to use systemd-networkd is far less painful).
Tip: the systemd-networkd, netplan.io and wpa_supplicant man files are extremely informative, if perennially verbose.  Good luck!


Showing $\displaystyle{\zeta(3)=\frac{1}{7}\sum_{n=1}^\infty\frac{n(2n+1)\zeta(2n+1)}{2^{2n-2}}}$

Question: I want to show the following infinite series representation for $\zeta(3)$ which I stumbled across on accident.
$$\zeta(3)=\frac{1}{7}\sum_{n=1}^\infty\frac{n(2n+1)\zeta(2n+1)}{2^{2n-2}}$$
Here is my attempt so far. By the series representation of $\zeta(2n+1)$,
$$\begin{align*}
\sum_{n=1}^\infty\frac{n(2n+1)\zeta(2n+1)}{2^{2n-2}}&=\sum_{n=1}^\infty\frac{n(2n+1)}{2^{2n-2}}\sum_{k=1}^{\infty}\frac{1}{k^{2n+1}} \\
&=\sum_{k=1}^{\infty}\sum_{n=1}^{\infty}\frac{n(2n+1)}{2^{2n-2}k^{2n+1}}
\end{align*}$$
and I am stuck. Evaluating the second sum using wolfram gives me,
$$\sum_{n=1}^{\infty}\frac{n(2n+1)}{2^{2n-2}k^{2n+1}}=\frac{16k(12k^2+1)}{(4k^2-1)^3}$$
for $\vert k\vert>1/2$, turning the problem into finding the infinite sum of some polynomial fraction, which I still can't evaluate.
Looking at the wiki for $\zeta(3)$ I see Euler gave the series representation,
$$\zeta(3)=\frac{\pi^2}{7}\left(1-4\sum_{k=1}^\infty\frac{\zeta(2k)}{2^{2k}(2k+1)(2k+2)}\right)$$
which some what resembles mine, so I'm guessing there's some trick I don't know of.
Any help? Thanks in advance.
Comment: Note that $\frac{4k(12k^2+1)}{(4k^2-1)^3}=\frac1{(2k+1)^3}+\frac1{(2k-1)^3}-\frac1{(2k+1)^2}+\frac1{(2k-1)^2}$ and $\sum_{k=1}^{\infty} \frac1{(2k-1)^3} = \frac7{8}\zeta(3)$, your answer can be directly deduced by your last step.
Comment: @bob $(2k-1)^2$ and $(2k+1)^2$ will be cancelled out by telescoping, leaving the first item, and the $(2k+1)^3$ is just an one-item shift of $(2k-1)^3$ yet lack of the first item, all those will be cancelled out, result in two $(2k-1)^3$ sums.
Comment: @bob Note that $\sum_{n=1}^{\infty}2n(2n+1)x^{2n-1}$ is just the second derivative of $\sum_{n=0}^{\infty}x^{2n+1}=\frac{x}{1-x^2}$, and you find this sum by let $x=1/(2k)$ (with a little change on the coefficient)
Comment: Do I understand correctly, you have $\zeta(3)$ on both sides?
Comment: Have you tried partial fraction decomposition?
Comment: @Ilya. Oh you are right. Then I guess the series has no meaning?
Comment: Well, it is still some dependence
Comment: @Nanayajitzuki. How would I evaluate the other terms?
Comment: @Nanayajitzuki. Thanks I see it now. Do you know how $$\sum_{n=1}^{\infty}\frac{n(2n+1)}{2^{2n-2}k^{2n+1}}=\frac{16k(12k^2+1)}{(4k^2-1)^3}$$ can be done by hand?
Answer: For $|z|<1$ we have $$\sum_{n=1}^\infty\zeta(n+1)z^n=\sum_{k=1}^\infty\left(\frac1{k-z}-\frac1k\right)=-\gamma-\psi(1-z)$$ (seen here and here, respectively; the first equality is easy to get after inserting $\zeta(n+1)=\sum_{k=1}^\infty k^{-n-1}$ and summing over $n$). Extracting the even part, we obtain $$\sum_{n=1}^\infty\zeta(2n+1)z^{2n}=-\gamma-\frac12\big(\psi(1-z)+\psi(1+z)\big).$$
Now multiply by $z$ and take the second derivative: $$\sum_{n=1}^\infty 2n(2n+1)\zeta(2n+1)z^{2n-1}=\psi'(1-z)-\psi'(1+z)-\frac z2\big(\psi''(1-z)+\psi''(1+z)\big).$$
The sum in the title of the OP is obtained at $z=1/2$. For $n>0$ we have $$(-1)^{n+1}\psi^{(n)}(1-z)=n!\sum_{k=1}^\infty\frac1{(k-z)^{n+1}}$$ (taking the $n$-th derivative of the equality at the beginning), hence
$$\psi'(1/2)-\psi'(3/2)=4,\\\psi''(1/2)-\psi''(3/2)=-16,\\\psi''(1/2)=-16\sum_{k=1}^\infty\frac1{(2k-1)^3}=-14\zeta(3).$$
That's sufficient.
Comment: Essentially, this answer boils down to using the definition of $\zeta$ and switching the order of summations (the digamma function appears only as a "known thing", with none of its specific properties used).
Comment: Thanks for the answer. I really like how the digamma function appears (even though none of its properties were used). Also, the proof for the other series (by Euler) is very neat, really appreciate it.
Answer: A proof of the mentioned series (by Euler), for completeness. We have, for $|z|<1$, $$2\sum_{n=1}^\infty\zeta(2n)z^{2n}=\sum_{k=1}^\infty\frac{2z^2}{k^2-z^2}=1-\pi z\cot\pi z$$ (the first equality after $\zeta(2n)=\sum_{k=1}^\infty k^{-2n}$ and summing over $n$; the second one is known, or obtained as the logarithmic derivative of the infinite product for the sine function). Then $$2\sum_{n=1}^\infty\frac{\zeta(2n)z^{2n+2}}{(2n+1)(2n+2)}=\int_0^z(z-t)(1-\pi t\cot\pi t)\,dt$$ and, if we put $z=1/2$ and substitute $t=x/\pi$, we obtain $$S:=\sum_{n=1}^\infty\frac{\zeta(2n)}{2^{2n}(2n+1)(2n+2)}=\int_0^{1/2}(1-2t)(1-\pi t\cot\pi t)\,dt\\=\frac14-\frac1\pi\int_0^{\pi/2}x\cot x\,dx+\frac2{\pi^2}\int_0^{\pi/2}x^2\cot x\,dx.$$
These integrals are evaluated using integration by parts and the Fourier series $$-\log|\sin x|=\log 2+\sum_{n=1}^\infty\frac{\cos 2nx}{n}.$$
With $\int_0^{\pi/2}x\cos 2nx\,dx=\frac{(-1)^n-1}{4n^2}$ (again, using i.b.p.), we easily get $$\int_0^{\pi/2}x\cot x\,dx=\frac\pi2\log2,\qquad\int_0^{\pi/2}x^2\cot x\,dx=\frac{\pi^2}4\log2-\frac78\zeta(3),$$ hence $S=\frac14\left(1-\frac7{\pi^2}\zeta(3)\right)$ as expected.


What is the Fourier transform of $f(x) = x^2 e^{-x^2}$?

Question: I have a hand-in for my math course, and don't really know how to attack it. I've seen examples of $x e^{-x^2}$, but can't quite seem to do it with $x^2$.
Comment: If you know how to compute the Fourier transform of $x e^{-x^2}$, just follow the same steps for computing the Fourier transform of $x^2 e^{-x^2}$. Where are you stuck at?
Comment: You should also clarify what are the normalization constants in your definition of Fourier transform (https://en.wikipedia.org/wiki/Fourier_transform#Other_conventions).
Answer: For $f(x)=x^2e^{-x^2}$ let $g(x)=e^{-x^2}$ with it's Fourier transform is ${\cal F}(g)=\dfrac{1}{\sqrt{2}}e^{-\frac{w^2}{4}}$, then
\begin{align}
g(x) &=e^{-x^2} \\
g'(x) &=-2xe^{-x^2} \\
g''(x) &=4x^2e^{-x^2}-2e^{-x^2} \\
 &=4f(x)-2g(x) \\
{\cal F}(g'')&=4{\cal F}(f)-2{\cal F}(g)\\
-w^2{\cal F}(g)&=4{\cal F}(f)-2{\cal F}(g)\\
{\cal F}(f) &= \dfrac{2-w^2}{4}{\cal F}(g)\\
{\cal F}(f) &= \dfrac{2-w^2}{4}\dfrac{1}{\sqrt{2}}e^{-\frac{w^2}{4}}
\end{align}
Answer: Hint:
You can use the fact that the Fourier Transform of $x^nf(x)$ is
$$
i^n\frac{d^nF(\omega)}{d \omega^n}
$$
where $F$ is the Fourier transform of $f$ ( and $\omega$ is the angular frequency)
Answer: Hint: Another method that is more laborious but easier to remember is to use the Taylor expansion:
$$x^2\exp(-x^2)=x^2\sum_{n=0}^{\infty}\frac{(-x^2)^n}{n!}=\sum_{n=0}^{\infty}(-1)^n\frac{x^{2n+2}}{n!}.$$
This the problem boils down to determining Fourier transforms of powers. This method might be not the best for this problem but sometimes it is very useful. Especially for Laplace transform this method is very powerful as powers of $x$ or $t$ can be determined very easily for the Laplace transform.
Comment: Power series expansions are awful for Fourier transforms as they get into infinite sums of distributions.
Comment: I know but I wanted to share the method as it might be a useful information to other users.
Comment: So can you actually conclude from this?


Vertically align logo and navigation bar?

Question: This is how my page looks so far: What I have so far...
I'd like to move the navigation bar up and vertically center it with the text "TEST".
This is my HTML:

SIMPLICITY

HOMEPAGES

homepage 2

homepage 3

homepage 4

homepage 5

SAMPLE PAGES

about us

services

our team

faq

coming soon

error 404

pricing tables

left sidebar

right sidebar

both sidebar

full width

portfolio

SHORTCODES

accordion

buttons

callout

columns

divider

list

message box

pricing table

tab

testimonials

toggle

twitter

BLOG

CONTACT

This is my CSS:
h1{
    font-family:bebas;
    font-size:48px;
    margin:0;
}

body{
    margin:0;
    padding:0;
    background-color:red;
}

header{
    background-color:white;
    margin:0;
}

.toolbar{
    background-color:#2d2d2d;
    width:100%;
    height:35px;
}

.container{
    width:960px;
    margin:0 auto;
}

.logo{
    padding-top:15px;
    padding-bottom:20px;
    color:#2d2d2d;
}

.nav-container{
    float:right;
}

#nav{
    list-style:none;
    font-weight:300;
    font-family: 'Open Sans', sans-serif;
    margin-bottom:10px;
    float:right;
    width:100%;
    position:relative;
    z-index:5;
}

#nav li{
    float:left;
    margin-right:10px;
    position:relative;
}

#nav a{
    display:block;
    padding:5px;
    color:#2d2d2d;
    text-decoration:none;
}

#nav a:hover{
    color:#000000;
}

#nav ul{
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    background:#fff;
    padding-left:10px;
    padding-top:9px;
    padding-bottom:9px;
    list-style:none;
    position:absolute;
    left:-9999px;
    /*-webkit-box-shadow: 4px 4px 10px rgba(50, 50, 50, 0.75);
    -moz-box-shadow:    4px 4px 10px rgba(50, 50, 50, 0.75);
    box-shadow:         4px 4px 10px rgba(50, 50, 50, 0.75);*/
}

#nav ul li{
    padding-top:1px;
    padding-bottom:1px;
    float:none;
    background:#ffffff;
    font-size:15px;
    width:150px;
}

#nav ul a{
    white-space:nowrap;
}

#nav li:hover ul{
    left:0;
}

#nav li:hover a{
    /*background:#6b0c36;*/
    /*text-decoration:underline;*/
}

#nav li:hover ul a{
    text-decoration:none;
}

#nav li:hover ul li a:hover{
    background:#008ed7;
    color:#fff;
}

Is there a simple way to do this?
Comment: `margin:0 auto;` and `text-align:center;` will align it to the center if thats what you mean
Comment: Can you provide a mockup of what you want this to look like?
Comment: `.logo { position:absolute; top:0; left:0 }` ... absolute positioning will manage the offset of the navigation bar without resorting to floats.
Answer: Float the logo to the left. Then, add the proper margin to the navigation container.
.logo {
    float:left; /* alternatively, could use position:absolute; */
    /* other css */
}

.nav-container {
    margin-top: 12px;
    /* other css */
}

See Fiddle
Comment: this type of answer is very specific. what happens if the height of the header changes for some reason?
Comment: @avrahamcool While I agree this is very specific, the more general methods for vertical alignment involve tearing down the existing code. I don't find this the suitable forum for that, since there are numerous resources on the subject out there already.
Answer: .logo
{
    float:left;
}

#nav
{
    padding-top: 18px;
    float: left;
}
.nav-container
{
    float: left;
}

Currenty float:right is defined to #nav and for .nav-container make it as float: left. Add other styles accordingly.
DEMO
Answer: Just add the following code in your css.
.logo {
    float:left;
    /* other css */
}
#nav {
   margin-top:25px;
}

Here is the working example: http://jsfiddle.net/GawvT/


Is there a concurrency with UPDATE count=count+1?

Question: I wanted to know, will I run into any concurrency problem with this?
This is NOT in a transaction. This code is for Sqlite(prototype), but I plan to use it with either MySql or a SQL from MS
                command.CommandText =
                    "UPDATE tag_name SET count = count+1 "+
                    "WHERE tagid=@tagid";
                command.Parameters.Add("@tagid", DbType.Int64).Value = tagId;
                command.ExecuteNonQuery();

Comment: Just be careful you don't reference count in the WHERE clause. Otherwise you may end up with a "Halloween Problem" of your own (http://en.wikipedia.org/wiki/Halloween_Problem)
Comment: +1 for mentioning the halloween problem. I have no doubt that if you did not mention it i would have ran into that problem and wonder/complain about the problem all day (or week!) +1000 if i could :)
Comment: I hope none of my bugs end up in wikipedia!
Answer: I may be wrong, but I don't think you would have a problem; the tag_name table I would think would be locked while the UPDATE occurs, so that any other updates waiting to be executed would essentially be queued up rather than occurring concurrently.
Answer: No this shouldn't be a problem. By default the locking mechanism should take care of any concurrency issues in single statements.
Answer: I don't think so, I vaugely remember seeing something like this in a SQL server best practices example from Microsoft.
Answer: not a problem You will have implicit transaction anyway. So it should not be a problem.
Even if you change TRANSACTION ISOLATION LEVEL, it should work just fine, at least on SQLServer.


Redux-toolkit action arguments in WebStorm

Question: I started using redux toolkit, but when I try to dispatch an action with arguments I get a warning from IDE saying:
"Argument type {...} is not assignable to parameter type {payload: {...}}"

or "Invalid number of arguments, expected 2"

I guess it thinks that the state should be the first argument.
Any way to correct this?
EDIT:
I found a temporary solution for this specific issue.
Basically, what I did was, I moved those actions out of the file.
If before I had:
// reducer.js
const state = createSlice({
  // ...
  reducers: {
    handleNumber(state, action){}
  }
})

export const { handleNumber } = state.actions
export default state.reduer

now I have:
// reducer.js
export const state = createSlice({
  // ...
  reducers: {
    handleNumber(state, action){}
  }
})

export default state.reducer

// actions.js
import { state } from './reducer'

export const { handleNumber } = state.actions

As said in the comment. Webstorm seems to pattern match stuff if those names are in the same file. But if they are in separate files, it looks into the typescript definition.
But it raises another issue, now when I Ctrl + click the function name in actions.js, instead of going to the function, it navigates to type declaration.
Comment: PHPStorm is doing same
Answer: RTK co-maintainer here. This looks very curious and should definitely work.
I'd like to look deeper into this. Could you please create a reproduction repository with this problem and post it to our github issue tracker?
Comment: looks like there has been an issue for a while now.
https://youtrack.jetbrains.com/issue/WEB-42559
Comment: here's the repo, I also added a picture in the assets folder.
https://github.com/andrei9669/redux-toolkit-webstorm
Comment: I see.
Unlike VSCode, which would use the TypeScript compiler in the background to find out the types of methods, even when you are writing JavaScript, WebStorm seems to just pattern-match stuff by name. And then it doesn't know the internals, but just "guesses" that `setNumberA` corresponds to the reducer definition, which is obviously wrong.
I'm sorry to say that, but in this case, it's just the tooling that's inferior. Can't really do anything about that :(
Answer: I have had a similar problem, I am not sure what is causing the problem, but I found removing/renaming your (hidden) .idea folder is useful. After that restart Webstorm and it should generate a new .idea folder that works.
So the problem seems to be there is something in Webstorm IDEA default settings that is causing this problem. Be sure to rename the .idea folder first if you're not sure if you want to keep some settings.
Hope this works!
Answer: it works of you export the actions with a different name, for example
const exmapleSlice = createSlice({
  name: 'exmapleSliceId',
  initialState: exmapleSliceInitialState,
  reducers: {
    _changeSomeField(state, action){
      state.someField = action.payload;
    }
  }
});

export const {
  _changeSomeField: changeSomeField,
} = exmapleSlice.actions;

Answer: I had the same issue but removing the .idea and restarting the ide worked.
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: I had the same issue while changing setting of typescript in webstorm by checked Recomplie on changes.


I need help getting program to output text file in a specific format.

Question: this is the program i have so far. it needs to output to a text file in a specific format but im having trouble please help. Its not outputting anything to the test file.
import java.util.*;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;

public class InputStream
{
public static void main(String[] args){
FileInputStream filestream;
BufferedReader reader;
FileOutputStream output;
PrintWriter writer;
String firstline;
String body = "";
String line;

try{
filestream = new FileInputStream("salary.txt");
reader = new BufferedReader(new InputStreamReader(filestream));
output = new FileOutputStream("test.txt");
PrintWriter writer1 = new PrintWriter("test.txt");
firstline = reader.readLine();

 String result = firstline + body;
 writer1.write(result);
 reader.close();
 reader = null;
 filestream = null;

   }
      catch(IOException e)
     {
     System.out.println(e);

  }

 }

}

Im having trouble getting this to output properly, but this is how it should look.
Example Input   file
Ralph Kramden associate 70817.75
Jon T. Doe assistant 79174.73
Ed Norton associate 69619.0
Tom Foolery full 116992.43

Sample  Output  file
Doe, Jon T. assistant 79174.73
-------
Total Salary: $79174.73
Average Salary: $79174.73
Kramden, Ralph associate 70817.75
Norton, Ed associate 69619.0
 -------
 Total Salary: $140436.75
 Average Salary: $79174.73

Comment: you have to read the file line by line (with a while-loop, for example). in your code you only get the first line?
Comment: while ((line = reader.readLine()) != null)
           {
             body = line;
             String result = firstline + body;
             writer1.write(result);
         }                                                                       this is the while loop i have and im not very sure what to do with it
Answer: First of all, when you are working with files, always close after you write in them to save.
You closed the "reader", but not the "writer".
Here is a example that output what you need:
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class InputStream {

private static final String ASSISTANT = "assistant";
private static final String ASSOCIATE = "associate";
private static final String FULL = "full";

public static void main(String[] args) {
    FileInputStream filestream;
    BufferedReader reader;
    PrintWriter writer;
    String line;

    double totalAssistant = 0;
    double totalAssociate = 0;
    double totalFull = 0;

    try {
        filestream = new FileInputStream("salary.txt");
        reader = new BufferedReader(new InputStreamReader(filestream));
        writer = new PrintWriter("test.txt");

        List<String> assistantList = new ArrayList<String>();
        List<String> associateList = new ArrayList<String>();
        List<String> fullList = new ArrayList<String>();

        while ((line = reader.readLine()) != null) {

            String[] split = line.split(" ");

            // Value
            double value = Double.parseDouble(split[split.length - 1]);

            // Type
            String type = split[split.length - 2];

            if (ASSISTANT.equals(type)) {
                totalAssistant += value;
                assistantList.add(line);

            } else if (ASSOCIATE.equals(type)) {
                totalAssociate += value;
                associateList.add(line);

            } else if (FULL.equals(type)) {
                totalFull += value;
                fullList.add(line);
            }
        }

        writeInFileOutput(writer, totalAssistant, assistantList);
        writeInFileOutput(writer, totalAssociate, associateList);
        writeInFileOutput(writer, totalFull, fullList);

        reader.close();

        writer.close();
    } catch (IOException e) {
        System.out.println(e);

    } finally {
        reader = null;
        filestream = null;
        writer = null;
    }

}

private static void writeInFileOutput(PrintWriter writer, double total,
        List<String> listLines) {
    for (String assistant : listLines) {
        writer.append(assistant).append("\n");
    }

    writer.append("-------\n");
    writer.append("Total Salary: $").append(String.valueOf(total)).append("\n");
    writer.append("Average Salary: $")
            .append(String.valueOf(total / listLines.size())).append(" \n\n");
}

}

Output:
Jon T. Doe assistant 79174.73
-------
Total Salary: $79174.73
Average Salary: $79174.73

Ralph Kramden associate 70817.75
Ed Norton associate 69619.0
-------
Total Salary: $257429.18
Average Salary: $128714.59

Tom Foolery full 116992.43
-------
Total Salary: $116992.43
Average Salary: $116992.43


Is the DotA Mod receiving the same patches as DotA 2?

Question: So Icefrog is working for Valve and releasing patches for DotA 2 which do not only include balance patches, but also more significant ones like the recent changes on the map.
Is the Warcraft 3 map being patched aswell, or was is left behind when Icefrog joined Valve for DotA 2?
Comment: If you downvote, please write a comment why so that I know what I could have done better :)
Answer: The last gameplay update that DotA received was 6.83c. As of now, the latest version of Dota 2 is 6.88b, which is seventeen versions ahead, five of which are major versions.
Historically, DotA had typically gotten updates within two months of Dota 2 getting it. As of now it has been over a year since the last gameplay update for DotA, so I think it is safe to assume that Icefrog has given up on trying to maintain parity. I find this especially probable because I don't believe that it is even possible to port some of the newer mechanics to the Warcraft 3 engine anyway.
However, there is a third-party group who has redone several further patches and made their own bugfixes for DotA 1, calling their fork DotA Allstars again. They're up to 6.85 right now. I'm not sure how much they will manage to port in the future, but you may be interested in that: http://d1stats.ru/


Matplotlib Pie Chart shows error with usage of slices

Question: Using matplotlib and pie chart shows error while using silces in there
from matplotlib import pyplot as plt

slices = [7, 2, 2, 13, 15]

activities = ["Sleep", "Eat", "Play", "Study", "Entertainment"]

colors = ['c', 'm', 'r', 'b', 'g']

plt.pie(slices,
        labels=activities,
        colors=[colors],
        startangle=90,
        shadow=True,
        explode=(0, 0, 0, 0.1, 0),
        # autopct='What is written on every section',
        autopct='%1.1f%%'
        )

plt.legend()

plt.title("Pie Chart")

plt.show()

Answer: You needed to pass colors instead of [colors] as the argument. The function expects a list, not a list of lists.
Please find the working code snippet below:
import matplotlib.pyplot as plt

slices = [7,2,2,13,15]

activities = ["Sleep","Eat","Play","Study","Entertainment"]

colors = ['c','m','r','b','g']

plt.pie(slices,
        labels=activities,
        colors=colors,
        startangle=90,
        shadow=True,
        explode=(0,0,0,0.1,0),
        autopct='%1.1f%%'
        )

plt.legend()

plt.title("Pie Chart")

plt.show()

The above code snippet generates the following output:


How to define multiple JButton actions from a different class

Question: I am writing a program where I need to do different actions for a separate class depending on which button is clicked.
public class NewJFrame{
    public static JButton b1;
    public static JButton b2;
    public static JButton b3;
}

public class Slot{

    int value;
    JButton button;

    Slot(int value, JButton button)
    {
        this.value=value;
        this.button=button;
    }
}

public class Game{
    Slot[] slots=new Slot[3];
    Game(){
        slots[0]=new Slot(1,NewJFrame.b1);
        slots[1]=new Slot(2,NewJFrame.b2);
        slots[2]=new Slot(3,NewJFrame.b3);
    }
    public void actionPerformed(ActionEvent e) {
        for(int i=0;i<3;i++){
            if(e.getSource()==slots[i].button)
                slots[i].button.setText(String.valueOf(value));
        }
    }
}

Something like this. Note that, I'm completely novice at GUI designing.
Comment: Please ask a more specific question. So far all you've done is to post some vague overly broad requirements. The more specific your question, usually the better and more specific the answer. Please have a look at [help] as well as the [how to ask good questions](http://stackoverflow.com/help/how-to-ask) sections for more information on how to improve your question and increase your chances of getting decent help.
Comment: Unrelated recs: None of the fields above should be static, especially JButtons. Class names should begin with upper case letters to conform with Java naming conventions, since if you do it this way, others will better understand your code and your problem.
Comment: Thanks for the renaming, but the more important correction is to improve your question so that it is more easily understood and answered.
Comment: For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/).
Comment: Your way of "solving" this problem is the exact opposite of what you should be doing. The proper solution is to not access those buttons in a static way. You've still not clarified your main question at all though.
Comment: @Shawon0418: Don't let the GUI editor dictate your design, for [example](http://stackoverflow.com/a/12505305/230513).
Comment: Thanks, yeah I get it that I should be more specific, but the actual program I have contains hundreds of lines of auto-generated code, I just want to save the trouble of copy-pasting it here and give potential helpers a headache. So I just gave the basic idea of what I want to do here. About the buttons being static, I was trying to call them normally, but got an error saying "non static variable b1 cannon be referenced from static context", the problem is solved after I made the button static.
Answer: Use Action to encapsulate functionality for use elsewhere in your program, e.g. buttons, menus and toolbars. The BeaconPanel shown below exports several actions that make it easy to use them in a control panel. To limit the proliferation of instances, the actions themselves can be class members. As an exercise, change controls to a JToolBar or add the same actions to a menu.
JPanel controls = new JPanel();
controls.add(new JButton(beaconPanel.getFlashAction()));
controls.add(new JButton(beaconPanel.getOnAction()));
controls.add(new JButton(beaconPanel.getOffAction()));

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Ellipse2D;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Timer;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

/** @see http://stackoverflow.com/a/37063037/230513 */
public class Beacon {

    private static class BeaconPanel extends JPanel {

        private static final int N = 16;
        private final Ellipse2D.Double ball = new Ellipse2D.Double();
        private final Timer timer;
        private final Color on;
        private final Color off;
        private final AbstractAction flashAction = new AbstractAction("Flash") {
            @Override
            public void actionPerformed(ActionEvent e) {
                timer.restart();
            }
        };
        private final AbstractAction onAction = new AbstractAction("On") {
            @Override
            public void actionPerformed(ActionEvent e) {
                stop(on);
            }
        };
        private final AbstractAction offAction = new AbstractAction("Off") {
            @Override
            public void actionPerformed(ActionEvent e) {
                stop(off);
            }
        };
        private Color currentColor;

        public BeaconPanel(Color on, Color off) {
            this.on = on;
            this.off = off;
            this.currentColor = on;
            timer = new Timer(500, new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    changeColors();
                }
            });
        }

        public void start() {
            timer.start();
        }

        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D) g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
            int x = getX() + N;
            int y = getY() + N;
            int w = getWidth() - 2 * N;
            int h = getHeight() - 2 * N;
            ball.setFrame(x, y, w, h);
            g2.setColor(currentColor);
            g2.fill(ball);
            g2.setColor(Color.black);
            g2.draw(ball);
        }

        private void changeColors() {
            currentColor = currentColor == on ? off : on;
            repaint();
        }

        private void stop(Color color) {
            timer.stop();
            currentColor = color;
            repaint();
        }

        public Action getFlashAction() {
            return flashAction;
        }

        public Action getOnAction() {
            return onAction;
        }

        public Action getOffAction() {
            return offAction;
        }

        @Override
        public Dimension getPreferredSize() {
            return new Dimension(N * N, N * N);
        }
    }

    public static void display() {
        JFrame f = new JFrame("Beacon");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        final BeaconPanel beaconPanel = new BeaconPanel(Color.orange, Color.orange.darker());
        f.add(beaconPanel);
        JPanel controls = new JPanel();
        controls.add(new JButton(beaconPanel.getFlashAction()));
        controls.add(new JButton(beaconPanel.getOnAction()));
        controls.add(new JButton(beaconPanel.getOffAction()));
        f.add(controls, BorderLayout.SOUTH);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);
        beaconPanel.start();
    }

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                Beacon.display();
            }
        });
    }
}

Comment: Also consider exporting a `List`.


Where can I find a list of possible events for an HTML element?

Question: I'd like to know the possible events that can come from an HTML span element. Is there some documentation somewhere for each HTML element that says what events it can trigger and how?
Answer: The list below is the closest that I have found.. Not sure if it covers all of them!! Notice that there is no onChange event handler for the span tag. Instead, you will have to use the MutationObserver to watch for changes being made to the DOM tree.
<code>+----------------+--------------------------------------------------------------+
| Event          |onActivate                      onAfterUpdate                 |
| Handlers       |onBeforeActivate                onBeforeCopy                  |
|                |onBeforeCut                     onBeforeDeactivate            |
|                |onBeforeEditFocus               onBeforePaste                 |
|                |onBeforeUpdate                  onBlur                        |
|                |onClick                         onContextMenu                 |
|                |onControlSelect                 onCopy                        |
|                |onCut                           onDblClick                    |
|                |onDeactivate                    onDrag                        |
|                |onDragEnd                       onDragEnter                   |
|                |onDragLeave                     onDragOver                    |
|                |onDragStart                     onDrop                        |
|                |onErrorUpdate                   onFilterChange                |
|                |onFocus                         onFocusIn                     |
|                |onFocusOut                      onHelp                        |
|                |onKeyDown                       onKeyPress                    |
|                |onKeyUp                         onLoseCapture                 |
|                |onMouseDown                     onMouseEnter                  |
|                |onMouseLeave                    onMouseMove                   |
|                |onMouseOut                      onMouseOver                   |
|                |onMouseUp                       onMouseWheel                  |
|                |onMove                          onMoveEnd                     |
|                |onMoveStart                     onPaste                       |
|                |onPropertyChange                onReadyStateChange            |
|                |onResize                        onResizeEnd                   |
|                |onResizeStart                   onSelectStart                 |
|                |onTimeError                                                   |
+----------------+--------------------------------------------------------------+
</code>
Comment: Thanks for the list but my question is which ones are specific to span. For example I just made a contenteditable span and tried copy pasting but got no oncopy or onpaste events. And your linked page lists Media Events and Window Events which don't apply to span. Here's all the events I get when I type a letter in my contenteditable span (it's between form tags): https://www.screencast.com/t/75jCCg1hrmWb
Why didn't it trigger onchange? If I change it to an input element I do get a change event. What is textInput?  That's not even in the w3schools list of events.
Comment: Check out my edited answer, does that list satisfy your question?!
List is all there, there is no onChange event for the span tag, you must use MutationObserver Instead.
Comment: Where did you get that list in your answer from?
Comment: It's not official documentation, but I found it here: http://www.java2s.com/Code/HTMLCSSReference/HTML-Tag-Reference/spanEventHandlers.htm
Comment: Ok that's just what I was looking for, thanks! It's a shame the official documentation isn't as thorough


Assasination Missions. How to invest money and make more money?

Question: I have finished the main story and all my main characters ended up making close to 31 Million apiece from the Big one. I only finished one Assassination mission so far which was the Hotel assassination, but i didn't play others because people advised me to reserve the Assassination missions to the end of the game.
This is all i know currently that these assassination missions end up killing some company's CEO and trick is to invest on their opposite number.
I want to know what others used to make money from these missions like if i should invest all my money on opposite company's stock from all the characters and play the mission and another question being once i complete the mission when is a good time to sell the stocks again?
Comment: Your lucky, I heard you can make over 500m from doing this smart investing, I didn't think of this or read about this until I passed the game as I wanted a blind run through the game. I might replay it. Please tell me how much money you make from this all together from your 31m
Comment: @Wojtek'Charkz'Hordyniec i will keep you posted about how much i make from these.
Comment: Lester usually hints towards where to make your investments.   I have had it go both ways.
Comment: i see mine as a different question. I am asking how much money to invest and whats the prime time to sell them.
Comment: why would you invest less than you have? the more you invest, the more you gain.
Comment: You end up with ~1.4b per character I think if you do all of them correctly after the big heist.
Answer: There are a handful of missions that allow you to make a fortune. Following the guide below, and save before each investment just incase something backfires.

The Hotel Assassination: Invest in Betapharmasuticals before the
mission and cash out afterward.
The Redwood Cigarette Assassination: Invest in Debonaire
Cigarettes before the mission. After the mission, sell all of your
share of Debonaire when it reaches maximum profit (around 80%).

Then invest in Redwood. Save your game 8 times to pass    (48 hours)
for Redwood shares to spike to 300%.

The Vice Assassination: Invest in Fruit before the mission and
sell    afterwards.
The Bus Assassination: Invest in Vapid after you complete    the
mission and cash out afterwards.
The Construction Assassination:    Invest in Gold Coast Development
before the mission and sell    afterwards.
Comment: wow investing in redwood was gold. i am on 220 million already with 3 assassinations to go.
Comment: so my question do i invest all my money on it completely? and 80% is the max it can go to?
Comment: Sorry, i'll edit into the question. Yes invest 100% if you follow this exactly you should be grand. Make saves before the mission each time just in case something back fires.
Comment: sleeping 8 times only passes 48 hours as Michael(see http://gaming.stackexchange.com/questions/131781/how-long-is-a-day-in-gta-v-in-real-time/131782#comment187045_131782), and weekends don't count on the stock market so be wary of this when you are waiting for your investments to grow
Comment: i eventually ended up making 1.3 Billion across all characters at end of all assasinations


What is "The Black Rock Ledger" good for?

Question: I recently got a page of "The Black Rock Ledger". It cannot be sold and except reading its text it does not seem to have any other purpose (except wasting stash/inventory space).
Should I keep this item? Will it be usable for something later? Maybe the all-mighty Cow Level?
Comment: The first letters of each entry, in the order of their pages spell out DHARMA.
Answer: It's an easter egg, referencing the TV series Lost. The page numbers 4, 8, 15, 16, 23, and 42 are also part of the Lost reference. Basically, you can throw it away if you want to, or keep it in your private collection.
Comment: Do you have a source on the lost reference ? Because there are opposing views expressed about the reference.
Comment: No, I don't, but I'm gonna make a wild claim and say that it's no coincidence that they used those numbers for the pages.
Comment: You can find a reference here: http://diablo.wikia.com/wiki/Black_Rock_Ledger
Answer: Don't throw it away. There might be something to it. Some have speculated there is more Lost Easter Eggs linked to it, concerning the black tornadoes that randomly pop up in the deserts. The reason is the Smoke Monster in Lost and the fact that the tornadoes look be made of smoke. I don't know, try going into one of those tornadoes with all Ledgers in your inventory, or perhaps throwing them all into the tornado. Who knows, anything is possible when it comes to Blizzard's sense of humor.
Comment: I have all 6 pages with me and ill try a few things but standing in the tordanoes does nothing
Comment: This is completely baseless speculation. I'm not sure why it has 3 up votes.
Comment: In this thread there are a lot of attempts at figuring it out: http://us.battle.net/d3/en/forum/topic/5151722071


Examples of disconnected metric spaces that cannot be isometrically embedded into a connected metric space

Question:
Please give me examples of disconnected metric spaces that cannot be isometrically embedded into connected metric spaces.

I have just started to study connected metric spaces and I haven't found out a metric space $X$ which isn't a subspace from another metric space such that $X$ isn't connected.
Every counterexample that I've looked, has been subspaces from a bigger metric space, e.g. $[0, 1]\cup[2, 3]$ which fails to be an interval in $(\mathbb{R}, |\cdot|$).
It might be topological space that isn't connected but for metric spaces? is there any apart from discrete metric spaces?
Thanks in advance
Comment: I think you should modify your title, saying something like "Examples of disconnected metric spaces that cannot be embedded into connected metric spaces" or similar.  The current title is a bit misleading.
Comment: FYI, not even discrete metric spaces (regardless of their cardinalities) are examples you seek.  Maybe such examples do not exist at all.
Comment: See the Kuratowski embedding defined [here](https://math.stackexchange.com/a/1043655/4280).
Comment: https://math.stackexchange.com/a/1040622/707239
Answer: If $X$ is any bounded metric space then $C(X)$, the space of real continuous functions on $X$ is  a connected metric space under the sup norm and the map $x \to f_x$, where $f_x(y)=d(x,y)$, is an isometric embedding of $X$ into $C(X)$. Hence the example you are looking for does not exist.
Comment: @EricWofsey Right, thank you.


Reinstall applications on a new system in an easy way?

Question: Say I want to migrate from Ubuntu to Debian, or the other way around, how can I reinstall all of my apps on my new system? For config it is super simple, just back up the home folder, but is there an easy way to reinstall all of your apps/software on the new system in an automated and simple manner?
Thanks
Comment: The debian packaging system was created in 1994, and beneath software centre (which is often modified and thus unique to a distribution, let alone different on the same distribution but for a different desktop) on both Debian and Ubuntu is that old dpkg/apt packaging which the post reports on. Further that method works regardless of DEsktop, and any nice 'easy' GUI tool would be specific to a specific desktop, or look ugly or drag in a huge amount of resources (libs) on different environments making its use costly. Thus I can't imagine anyone creating what you'd want.
Comment: Thanks. I am aware of that but it is a very old discussion (4-6 years old) and I was wondering if anything new came up that makes it easier. Like a plugin for the software center to simply read the installed apps and save that somehow.
Answer: Use a config manager. There are plenty of them around. The two that would be easier for you to use are saltstack, or Ansible. The latter is easiest. You can setup a playbook to install and configure all your installed software. See here for a how to.
Comment: You might want to consider expanding your answer and posting it on the duplicate candidate that has ~600 up-votes.


The icon from Bootstrap css file not loaded when offline

Question: I have datetime picker, The problem is no icon appear in the page. But if I disable line (comment out) from local bootstrap.css then add hyperlink bootstrap.css from http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.css its worked perfectly. So why? I want to local css file that I used to offline, I dont want to online css rendering.
Here my code :
    <link href="css/bootstrap.css" rel="stylesheet"/>
    <link href="css/bootstrap-datetimepicker.css" rel="stylesheet"/>

 <title></title>

        <form id="form1" runat="server">

                        <input type='text' data-date-format="MM/DD/YYYY HH:mm" class="form-control" />

        </form>

So its work if with this line,
<link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.css" rel="stylesheet"/>

I was downloaded that css then I used for offline but it not working. Please Help
Thank you,
Comment: Make sure that you are using the same version of bootstrap css and js.
Comment: is your problem solved?
Comment: Okay it solved. Many thanks! I was placed all of bootstrap master. But I dont know what the list folder is just needed from all folder? But is okay.
Answer: Place all the contents of bootstrap package in the folder including fonts provided by bootstrap
bootstrap folder structure is like
    bootstrap/
    ├── css/
    │   ├── bootstrap.css
    │   ├── bootstrap.css.map
    │   ├── bootstrap.min.css
    │   ├── bootstrap.min.css.map
    │   ├── bootstrap-theme.css
    │   ├── bootstrap-theme.css.map
    │   ├── bootstrap-theme.min.css
    │   └── bootstrap-theme.min.css.map
    ├── js/
    │   ├── bootstrap.js
    │   └── bootstrap.min.js
    └── fonts/
        ├── glyphicons-halflings-regular.eot
        ├── glyphicons-halflings-regular.svg
        ├── glyphicons-halflings-regular.ttf
        ├── glyphicons-halflings-regular.woff
        └── glyphicons-halflings-regular.woff2

you have not included the Font folder. Just Download the whole whole bootstrap package from there official site and keep the folder structure same and then include the css file as
<link href="bootstrap/css/bootstrap.css" rel="stylesheet"/>

Comment: Hi I was added that file but not working. Finnaly I copied all of master folder bootstrap and it working, but I realy dont know what exactly folder is needed. Thank you in advance!
Answer: Make sure you not only download the css stylesheet but also the glypicons included with it, when you donwload boostrap, it comes with a fonts folder, put that folder  in the same directory as the boostrap css.


Simple jQuery Slideshow Image Moving Downwards for a Split Second

Question: So I have this code here for a simple slideshow:
$("#slideshow > div:gt(0)").hide();

setInterval(function() {
  $('#slideshow > div:first')
    .fadeOut(100)
    .next()
    .fadeIn(1000)
    .end()
    .appendTo('#slideshow');
},  3000);

Here is my HTML div:

And here is a working fiddle: http://jsfiddle.net/shrimpboyho/9n9GK/
However, notice that when the pictures change you can see the previous image fade and move downwards before completely disappearing?
This is a problem for me because the slideshow needs to be placed above a paragraph of text, and the picture flashes on the text as the pictures change and it is annoying. Are there any ways I can fix this.
Answer:

is this max-height actually working, if yes, try this:

Answer: #slideshow {
    position: relative;
}
#slideshow > div {
    position: absolute;
    top: 0;
    left: 0;
}

this will place the images on top of each other.


Differentiate users with private_pub

Question: I'm trying to display a simple chat between users. I would like to design it like iMessages, to differentiate the senders, but I just can't figure out how to do so. No matter what I try, it always seems like message.sender == current_user , even for the receiver
Here's the js.erb for private pub:
<% publish_to "/comments/create" do %>
 var new_comment = $("<%= escape_javascript(render 'projects/comment', comment: @comment) %>");
  var comment_box = $('.feedback-index');
  new_comment.appendTo(comment_box);

  $('#comment_content').val('');
  $(' .fa-comment').text(" <%= @comment.project.comments.size %>");
 $('#messagesbox').scrollTop($('#messagesbox').prop("scrollHeight"));

<% end %>

Now, the tricky part, in my _message.html.erb, comment.sender == current_user is always true. I tried to implement two designs, based on the current user, using a helper :
HTML:
<div class="col-xs-8 col-sm-9 the-comment <%= self_or_other(comment) %>">

Helper:
module MessagesHelper
  def self_or_other(message)
    message.user == current_user ? "current-user-message" : ""
  end
end

unfortunately, my div always get the "current-user-message" class.
Am I missing something ?
Answer: Well, I found a clean solution to this problem:
Somewhere in the wrapper, add an input including your current_user id
<input type="hidden" value="<%= current_user.id %>" name="sender-id" id="senderid">

Then, in your js publish, retrieve it, and voila :)
<% publish_to whatever_you_want  do %>
    sender = $('#senderid').val();
    if (sender == "<%= current_user.id %>") {
       // do your stuff
    }
<% end %>

Differentiate users with private_pub


Objective C: Include class and call method

Question: I have built a class which has a few methods in it, once of which returns an array, lets call this class A.
I have a second class, class B, which I would like to use to call the method from class A.
But, now how do I call that method from class A and store what is returned in a var in class B?  Do I have to initiate the class?  I have made sure to include the .h file from class A into class B.
Thanks for helping a newbie.
UPDATE:
Here is how I thought I could do this (DataStore is my class A and pushRideData is my method that returns an array):
DataStore *store = [[DataStore alloc] init];
trailsArray = [store pushRideData];

Answer: Assuming you have files A.h, A.m B.h and B.m to define your two classes, then you need to do the following:

Make sure A.h and B.h are #imported into your projects PCH file (this is the easiest/fastest way, but you could also choose to import the files into all the .m files, instead).
If you refer to a class -- say, B *something in A.h -- before that class's header file is imported, then use a forward class declaration to shut up the compiler.  I.e. @class B; before the @interface A:NSObject in A.h
If you want to call an instance method of a class, you need to instantiate the class as you describe. Or, if the instance is created somewhere else, you'll need some mechanism to retrieve it.  A class method, perhaps, or a global variable or a controller or something like it.

None of this is really that much different than straight C save for a formal notion of Objects (as opposed to malloc'ing a bunch of memory and passing around pointers).
Comment: I had a similar question and your answer got me all setup. Thanks!
Answer: That's a fairly abstract question. Yes, you need an instance to be able to store instance variables in it. You will need to allocate and init the instance, assinging it to an instance or local (pointer) variable in the calling class unless it is one of the several in the Cocoa Touch frameworks which use the singleton pattern, such as the application delegate. Such singletons have special case-specific class methods for obtaining the singleton instance.
Comment: DataStore doesn't appear to be a class provided by Apple (I find no docs for it as of iPhone 3.1.3 anyway). So I guess I can't know for sure semantics of how it needs to be used.

But generally you need a pointer to a freshly created object, not just the type declaration:

DataStore *myDataStore = [[DataStore alloc] init];
Comment: And then you would use that instance pointer in the next line:

NSArray *trailsArray = [ myDataStore pushRideData ];
Comment: Sorry for being abstract, I updated my question with an example of how I though I was suppose to do it, but obviously it is wrong and not working.
Comment: OK, looks like you've edited it again and that should be correct for the general case, presuming "trailsArray" has been declared as an NSArray pointer previously.


Reverse IN function

Question: Consider the following table teammessages:
15:10 | Peter | I'm off to the store, call my mobile phone if you need me.
15:11 | Susy  | Have you seen the new scanner? It's lightning fast.
15:15 | Anne  | We have an emergency here, John broke the tap! Please switch off the water supply!
15:15 | John  | I did what?? :-D I'm in Vienna!
15:16 | Peter | I'm stuck in the elevator, help!
15:17 | Anne  | I said WATER, not POWER supply!

When I want to SELECT the urgent messages, containing key words like "help" or "emergency", from that chaotic freetext, I would have to have a "reverse IN" function, which doesn't check if the field is IN a given list of alternatives (WHERE APPLECOLOR IN ('YELLOW', 'RED')) but which checks if a value of the given alternatives is IN the field (WHERE freetext REVERSE_IN ('help', 'emergency')).
I've tried constructs like WHERE freetext LIKE ('%help%' OR '%emergency%'), but this gives me empty results.
Clarification: I can do this with freetext LIKE ... OR freetext LIKE ... OR freetext LIKE ... but it gets very long. So I am just looking for a shorthand like IN is in the "reverse case" (APPLECOLOR = 'RED' OR APPLECOLOR = 'YELLOW' <=> APPLECOLOR IN ('RED', 'YELLOW')).
Comment: It should be `WHERE freetext LIKE '%help%' OR  freetext LIKE '%emergency%'`
Comment: i would use Full-Text Search Functions ( https://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html ) because `LIKE %help%` never can use indexes.
Comment: @RaymondNijland Seems like overkill here. An indexed computed column might be a better option, where the column only  needs to be searched at insert/update.
Comment: "An indexed computed column might be a better option" This is MySQL not SQL Server @JoelCoehoorn
Comment: @RaymondNijland MySql calls them generated columns. It's still a better solution.
Comment: "MySql calls them generated columns" i know i meant dont use a SQL Server term in a MySQL tagged topic  @JoelCoehoorn..
Answer: The correct form of your original query is:
WHERE freetext LIKE '%help%' OR freetext LIKE '%emergency%'

However you might also like to consider using MATCH. For that you will need to have a FULLTEXT index on the message column which you can add with this command:
ALTER TABLE teammessages ADD FULLTEXT INDEX(message);

You can then search using a query like this one:
SELECT *
FROM teammessages
WHERE MATCH(message) AGAINST('help emergency' IN BOOLEAN MODE)

which will give you better results than LIKE, which would also match words like 'whelp' or 'helpful' or 'helps'. In your sample table, this query returns:
time        name    message
15:15:00    Anne    We have an emergency here, John broke the tap! Please switch off the water supply!
15:16:00    Peter   I'm stuck in the elevator, help!

This query also has the advantage of not getting long as fast as multiple LIKEs
Comment: With the `FULLTEXT` index it should be as fast as multiple `LIKE`s, if not faster.
Comment: This looks promising!
Comment: Here's an article showing `FULLTEXT` search much faster than `LIKE`: https://makandracards.com/makandra/12813-performance-analysis-of-mysql-s-fulltext-indexes-and-like-queries-for-full-text-search
Answer: I suggest a Generated Column.
Answers involving LIKE are going to be very slow here, and answers involving full text search (freetext) expressions are telling MySql to index every word in the column, rather than just the words you care about.
You can use a generated column to produce a simple Y/N or 1/0 result for just the words you care about that only needs to evaluate the full column data at INSERT/UPDATE time.
Comment: " full text search expressions are telling MySql to index every word in the column" full text index does not index every word by the way.. common english words like `the` `some` are not indexed.. Besides you can make you own filter list.. Also you can control the minimal string length of words you want to index.. it is all in the documentation https://dev.mysql.com/doc/refman/8.0/en/fulltext-natural-language.html and https://dev.mysql.com/doc/refman/8.0/en/fulltext-stopwords.html  and https://dev.mysql.com/doc/refman/8.0/en/fulltext-fine-tuning.html
Comment: This is a nice approach as well. :-)
Answer: You are probably looking for the words help and emergency. You don't want to find

Jake, your jokes are not helpful.
You must subtract the tax. Hope this helps :-)

So check whether your version of MySQL supports regular expressions where you can look for words:
select *
from teammessages
where freetext regexp '[[:<:]](help|emergency)[[:>:]]';

Rextester demo: http://rextester.com/ILROPQ12660
Comment: The beginning of a word. It has no length. It just indicates there is no letter or so before the word. (I.e. whelp wouldn't match because there is no beginning of a word before help.) `[[:>:]]` is the end of a word.
Comment: What is `[[:<:]]`?
Answer: WHERE freetext LIKE ('%help%' OR '%emergency%') does not work like this.
It should be:
WHERE freetext LIKE '%help%' OR freetext LIKE '%emergency%'

Additional: From documentation of LIKE function:

With LIKE you can use the following two wildcard characters in the
  pattern:

% matches any number of characters, even zero characters.
_ matches exactly one character.

mysql> SELECT 'David!' LIKE 'David_';
        -> 1
mysql> SELECT 'David!' LIKE '%D%v%';
        -> 1

Answer: you should try :
WHERE freetext LIKE('%help%')  OR freetext LIKE('%emergency%')

Comment: So there is no short way (`IN` is a short way of multiple `OR`s as well)? In such a chaotic team, the list of key words would become very long.
Comment: yes but with in you check all the value ,you just want to match string containing help or emergency. You also can add a table with all your fields and check that table it will be easier to maintain.
Answer: You could find all messages that are urgent with keywords you know by doing something similar to this:
SELECT * FROM teammessages WHERE freetext LIKE '%help%' OR freetext LIKE '%emergency%';

You could do the 'reverse' of this by using NOT LIKE this way:
SELECT * FROM teammessages WHERE freetext NOT LIKE '%help%' AND freetext NOT LIKE '%emergency%';

Comment: No, sorry, I might have been unclear, I do not want to negate the search, I want to "reverse" the `IN`: Do not look if the field is IN my given alternatives, look if one of those alternatives is IN the field!
Comment: The top query gives results that are IN the list (messages containing help/emergency). The second query gives you a list (messages that do not contain the words help and emergency). If that is not what you mean, could you clarify a bit more in the question?

Reverse IN function


How to unflatten a nodes array object to a nested object which represents a directory structure

Question: How do you write a function that will perform an unflattening transformation on a nodes array of objects which represents a directory structure or routing path tree. Also, should any paths involve creation of empty nodes, how do you create these nodes for the result structure. The empty directories have their path and children keys only. Here's an example nodes array:
For example, if nodes = [{id: 50, path: "/apple/banana"}], return
{
  "path": "/",
  "children": [
    {
      "path": "/apple",
      "children": [
        {
          "id": 50,
          "path": "/apple/banana",
          "children": []
        }
      ]
    }
  ]
}

I have this:
const tree = { path: '/', children:[] }
const sortedNodes = nodes.sort((a, b) => (a.path.split('/').length - b.path.split('/').length));
sortedNodes.forEach(node => {
  const dirs = node.path.split('/').slice(1)
  let traversed = tree // Hold the reference of tree

  dirs.forEach((dir) => {
    const foundChild = traversed.children.find(child => child.path.split('/').slice().pop() === dir)
    foundChild ? traversed = foundChild : traversed.children.push({ path: node.path, id: node.id, children: [] });
  })
})
console.log(tree);

Answer: You could split the path and get parts for iterating the nested objects.

var nodes = [{ id: 50, path: "/apple/banana" }],
    tree = nodes
        .reduce((t, { id, path }) => {
            path.split(/\//).reduce((r, _, i, p) => {
                var path = p.slice(0, i + 1).join('/') || '/';
                    temp = r.children.find(q => q.path === path);
                if (!temp) r.children.push(temp = { path, children: [] });
                return temp;
            }, t).id = id;
            return t;
        }, { children: [] })
       .children;

console.log(tree);
.as-console-wrapper { max-height: 100% !important; top: 0; }


How to tell when/if brick foundation needs to be repointed?

Question: My house's foundation is circa-1900 brick with lime mortar over a fieldstone base.
Should I consider repointing the brick a periodic maintenance task -- and if so, how can I tell when it should be done, or how often it should be scheduled for?
(In particular, I'm trying to decide whether I can get away with adding insulation to this part of the foundation, and I need to know how much access I would need to preserve.)
Comment: When you say "foundation", do you mean the part of the wall underground, or do you mean the above ground masonry upon which a wood (or similar) construction is built?
Comment: In my case, both. Fieldstone below frost line, about 6' of brick wall on top of that to about 2' above surface (painted outside, and I'm not seeing any obvious problems), then stick construction above that. If only houses came with real maintenance manuals...
Answer: Yes, lime mortar brickwork does need periodically repointing.  How often depends on the weather in your location (wet is bad, lots of freeze-thaw is bad, acid pollution is very bad), but I'd say probably every 20 to 40 years is about right.
If you cover the outside of the wall with insulation, then the mortar is largely protected from the weather, and is unlikely to need repointing.
I do have some concerns that moisture management in your house may depend on the moisture being able to evaporate away (compare with a modern house, where the Portland cement mortar is waterproof and the basic strategy is stop the water getting in in the first place).  Obviously if you have covered the walls with waterproof insulation, that stops rain wetting the wall, but there is still a potential problem with rising damp.  You may have a layer of slate in the wall.  This reduces water rising through the wall, but it doesn't eliminate it, and that water must have a way to escape.
Comment: Hm. I've been in the house 15 years. Gods know when repointing was last done. So it may be anywhere from midlife to overdue. Could just assume so I have a known baseline, but a way to know where I am on that spectrum would help... Currently uninsulated, and no plan to insulate the outside unless something much more major is needed; inside is possible but it sounds like the answer should be "repoint first because it'd be a mess to do second"
Comment: Is the mortar missing / cracked in places.  If so, it needs repointing; if not, not.  (Repointing lime mortar is quite easy, and very therapeutic.  Also, you don't need to worry about the mortar going off, so you can make up a reasonable sized quantity, store it in something sealed, and just use it up over a weekend or so.
Comment: Ok. Most of the mortar is presumably fine, then. I've already dealt with the area where settling had caused a significant separation. I probably should mortar the dry-stacked fieldstone layers at some point to help stabilize them and discourage critters, but that's presumably best done with modern cement. Now I need to deal with the cracking basement floor, but since I'm nervous about what's under it and about keeping things stable I'm gonna have a pro deal with that


Pasted text in interactive R session using Gnome Terminal in 21.04 is always highlighted -

Question: Yesterday I updated to Ubuntu 21.04. This is basically the same issue as this post. I solved the original issue (using this answer) of having the text highlighted when I paste something into the terminal by adding bind 'set enable-bracketed-paste off' to my ~/.bashrc.
However, I used R interactively from the terminal and when I paste something into the terminal, the same issue of highlighting the text appears. Even more annoying, if I paste multiple lines in then only the first one executes and the remaining lines are left 'piled up' (the line with assign(c_list[1]....). This means I have to hit enter twice before I can enter anything into the terminal.
This never used to happen before the update - does anyone know a fix?
Comment: I wonder if [this other workaround](https://askubuntu.com/a/1338768/100356) I had posted on my Gnome Terminal question would help you in this case?
Comment: Thanks I will try this - but I suspect if you are changing the highlight colour it won't change the fact that the pasted lines 'pile up'  (like in the image), meaning you have to hit enter twice for every line?
Comment: @user438383 using 20.04 LTS maybe safer to prevent such unpredictable behaviours...
Comment: The last command should not "hang". All commands are consecutively executed once you press Enter after having pasted, even if you do not copy the "enter" of the last line along. That it hangs for you may be a specific issue with your command. The behavior has changed in a sense that what you paste is not immediately interpreted line by line - it only is when you "confirm" by pressing enter.
Answer: The second more annoying problem looks like the 'enable-bracketed-paste On' option enabled by default in bash 5.1. To revert to the old behaviour create or edit .inputrc (in home dir) adding the line
set enable-bracketed-paste Off