how to make conky true transparent?

Question: There is no true transparency. how can i fix it?
<code># By Jesse_Avalos , See me on Eye Candy Linux_  on Google +
#Modified by http://www.NoobsLab.com

background yes
use_xft yes
xftfont Roboto:size=9
xftalpha 0.8
update_interval 1
total_run_times 0
own_window yes
own_window_transparent yes
##############################################
# Compositing tips:
# Conky can play strangely when used with
# different compositors. I have found the
# following to work well, but your mileage
# may vary. Comment/uncomment to suit.
##############################################
## no compositor
own_window_type conky
own_window_argb_visual yes

## xcompmgr
#own_window_type conky
#own_window_argb_visual yes

## cairo-compmgr
own_window_type conky
own_window_argb_visual no
##############################################
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
stippled_borders 0
border_margin 5
border_width 1
default_color 1C1C1C
default_shade_color 000000
default_outline_color 000000
alignment top_right
minimum_size 600 600
maximum_width 900
gap_x 505
gap_y 70
alignment top_right
no_buffers yes
uppercase no
cpu_avg_samples 2
net_avg_samples 2
short_units yes
text_buffer_size 2048
use_spacer none
override_utf8_locale yes
color1 212021
color2 E8E1E6
color3 E82A2A
own_window_argb_value 0
own_window_colour 000000
TEXT
${goto 245}${voffset 25}${font GeosansLight:size=25} Today
${goto 124}${voffset -}${font GeosansLight:light:size=70}${time %I:%M}${image .conky/blackline.png -p 350,26 -s 10x189}
${offset 150}${voffset -55}${font GeosansLight:size=17}${time %A, %d %B}
${offset 380}${voffset -177}${font GeosansLight:size=25}Systems${font GeosansLight:size=22}
${offset 400}${voffset 5}${font GeosansLight:size=15}$acpitemp'C
${offset 400}${voffset 10}${cpu cpu0}% / 100%
${offset 400}${voffset 4}$memfree / $memmax${font GeosansLight:size=15}
${offset 400}${voffset 5}${if_up wlp6s0}${upspeed wlp6s0} kb/s / ${totalup wlp6s0}${endif}${if_up eth0}${upspeed eth0} kb/s / ${totalup eth0}${endif}${if_up ppp0}${upspeed ppp0} kb/s / ${totalup ppp0}${endif}
${offset 400}${voffset 5}${if_up wlp6s0}${downspeed wlp6s0} kb/s / ${totaldown wlp6s0}${endif}${if_up eth0}${downspeed eth0} kb/s / ${totaldown eth0}${endif}${if_up ppp0}${downspeed ppp0} kb/s / ${totaldown ppp0}${endif}

${goto 373}${voffset -162}${font Dingytwo:size=17}M$font
${goto 373}${voffset 7}${font Dingytwo:size=17}7$font
${goto 373}${voffset 1}${font Dingytwo:size=17}O$font
${goto 373}${voffset 1}${font Dingytwo:size=17}5$font
${goto 373}${voffset 1}${font Dingytwo:size=17}4$font
</code>
Comment: Can you post your `conky` code in your question?
Comment: @WinEunuuchs2Unix yes
Answer: Find this section:
<code>## no compositor
own_window_type conky
own_window_argb_visual yes

## xcompmgr
#own_window_type conky
#own_window_argb_visual yes

## cairo-compmgr
own_window_type conky
own_window_argb_visual no
</code>
Copy this code over top of the section:
<code>## no compositor
#own_window_type conky
#own_window_argb_visual yes

## xcompmgr
own_window_type conky
own_window_argb_visual yes

## cairo-compmgr
#own_window_type conky
#own_window_argb_visual no
</code>

how to make conky true transparent?


Redirecting domain and subdomain from http to https

Question: I want to redirect all http requests for my domain and subdomains to https. For example http://example.com should go to https://example.com and http://subdomain1.example.com should go to https://subdomain1.example.com, etc.
I have written this code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com$
RewriteRule ^(.*)$ https://%1.example.com$1 [R=302,L]

This code is only redirecting the subdomains but it is not redirecting the domain. What changes should I do the above code that it start routing for both.
Answer: You can use the following to redirect your domains to https :
RewriteEngine on

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]


How to get the inner text for a single node using HtmlAgilityPack

Question: My HTML looks like this:

                    Copyright © FUCHS Online Ltd, 2013. All Rights Reserved.

I would like to obtain this text from the markup and store it as a string in my C# code: "Copyright © FUCHS Online Ltd, 2013. All Rights ".
This is what I have tried:
   public string getvalue()
        {
            HtmlWeb web = new HtmlWeb();
            HtmlAgilityPack.HtmlDocument doc = web.Load("www.fuchsonline.com");
            var link = doc.DocumentNode.SelectNodes("//div[@id='footertext']");
            return link.ToString();
        }

This returns an object of type "HtmlAgilityPack.HtmlNodeCollection".  How do I get just this text value?
Comment: The text you want to get is not an attribute - it is a text node in the DOM. For what an html attribute is, [Xml attributes](https://www.google.co.il/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rja&uact=8&ved=0ahUKEwipwY-OjtfNAhXkNJoKHV-fC-wQFggkMAI&url=http%3A%2F%2Fwww.w3schools.com%2Fxml%2Fxml_attributes.asp&usg=AFQjCNG3z_8GA13PwLrj2SQRv2uLSbyCtg&sig2=8f2bj2MH369BcREluiGZkA).
Comment: @Veverke substituting one piece of misinformation with another is probably not such a good idea. XML isn't HTML, and the rules for attributes are different (although similar).
Comment: @Spender: Isn't html a subset of XML ? I thought XML was the umbrella for all "tagged" data structuring formats. I mean, if all these tagged languages are "Extensible Markup Languages", I thought, then, all "derive" from xml. Seems my unilateral association with Extensible Markup Language and XML is what is wrong (xml being the abbreviation of extensible markup language, versus XML representing an implementation instance of an extensible markup language).
Comment: @Veverke. XML is very strict about the format of attributes. HTML's rules are much looser. e.g. `id='foo'` is a valid HTML attr but invalid in XML. Really, they're both derivatives of SGML. Efforts to make HTML into XML (XHTML) have more or less failed.
Comment: Gotcha, you are right. SGML is what I had in mind. Thanks for the corrections.
Answer: You need the value of one node. Therefore it is better to use SelectSingleNode method.
HtmlWeb web = new HtmlWeb();
var doc = web.Load("http://www.fuchsonline.com");
var link = doc.DocumentNode.SelectSingleNode("//div[@id='footertext']/p");

string rawText = link.InnerText.Trim();
string decodedText = HttpUtility.HtmlDecode(text); // or WebUtility

return decodedText;

Also you may need to decode the html entity ©.
Comment: This should be the selected answer, indeed. We all missed that we are dealing with IDs (although sites will not "prevent" developers using repeated ids across the dom, in which cases selectsingle will not get the desired results, but these are edge and not-likely cases).
Answer: Here's what you can do:
string html = @"

                Copyright © FUCHS Online Ltd, 2013. All Rights Reserved.

";

//in my example I am not use HtmlWeb because I am working with the piece of html you provided. You will continue to you HtmlWeb and access the url...
HtmlDocument htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(html);

var texts = htmlDoc.DocumentNode.SelectNodes("//*[@id='footertext']").Select(n => n.InnerText.Trim());

foreach (var text in texts)
{
    Console.WriteLine(text);
}

Output:
Answer: public string getvalue()
{
    HtmlWeb web = new HtmlWeb();
    HtmlAgilityPack.HtmlDocument doc =web.Load("www.fuchsonline.com");
    var link = doc.DocumentNode.SelectNodes("//div[@id='footertext']");
    return link.InnerText.ToString();
}

Comment: but it said htmlagility pack does not contain any defination of InnerText
Comment: InnerText only works when we used SelectSingleNode() metod;
Comment: what if you do link.Document.Body.InnerText


Sending custom WCF requests via Sockets

Question: I've seen a few questions left half-answered regarding this topic.
I want to send a request to my self hosted WCF application, which uses NetTcpBinding.
The problem is, I have to use sockets.
I've written a transport binding element which opens a TcpListener(on the ChannelListener OnOpen)
This works fine, but in that case - I'll have to use my own message framing model.
Obviously, I'm not going to implement the net.tcp message framing model( http://msdn.microsoft.com/en-us/library/ff470920%28v=prot.10%29.aspx)
I've read a few posts(including http://blogs.msdn.com/b/carlosfigueira/archive/2008/01/13/writing-custom-requests-to-simple-wcf-services.aspx) which suggest I should send a request and interpret the bytes sent via a MessageEncoder/MessageInspector.
This way, I can basically create a message for each of my methods/operations(with minor
changes per request)
I tried this method and I got the bytes in question(through the use of a custom MessageEncoder) when I used a WCF channel(from a ChannelFactory).
I've saved those bytes, and sent them through a TcpClient  - the MessageEncoder wouldn't fire up.
When I Open a normal channel:
<code>        ChannelFactory<ITestService> factory = new ChannelFactory<ITestService>(new    NetTcpBinding(),
            "net.tcp://localhost:76599");

        factory.CreateChannel().DoSomething(string.Empty); //gets to MessageEncoder
</code>
When I try the same via Sockets:
<code>        TcpClient cli = new TcpClient("localhost", 76599);

        byte[] fileArray = File.ReadAllBytes("c:\\fileFromMessageEncoder.bin");
        cli.GetStream().Write(fileArray, 0, fileArray.Length); // Does not get to MessageEncoder
</code>
any ideas?
Comment: There is one thing about your post that's not clear to me: why must you use sockets to communicate with your server? Also, if you must use sockets, why not just build a simple socket server? Understanding what's motivating your unusual requirements might help to find the best solution.
Comment: @PaulKeister
I have a few clients that already use my contract(through different wcf bindings) - I want other clients(who use c++, Java or Mono) to be able to connect to the same WCF app, so I could manage the requests without using my own framing model.  That way, I could send binary data(from the client, wrapped in the WCF Contract interface) which would fire up an operation, and then return my response through a Channel I would implement myself.  Thanks in advance for any solution you might think of :)
Comment: Obviously you could create a functional Java or Mono client fairly easily by adding an endpoint with a SOAP or REST binding (you can use WCF for (managed) C++ on Windows). As for a cross-platform implementation of NetTcp, it's interesting to note that there are some patent warnings from Microsoft on the links you've provided. Clearly, you're swimming upstream in a pretty fast current. See this question for some background: http://stackoverflow.com/questions/6459619/mac-or-c-connection-to-binary-wcf/6459723#6459723
Comment: @PaulKeister using A SOAP or REST binding isn't relevant as I need
to use a tcp based transport for better performance.
My clients are developed by numerous developers outside my company,
so I need to be able to provide a single interface they can work with.Creating an implementation of the exposed Contract, which builds the binary data used by net.tcp seems to be perfect solution.The reason I'm not rebuilding the net.tcp message framing model is to avoid issues with Microsoft. However, reading the bytes sent to a MessageEncoder and sending those same bytes from the clients seems logical.
Comment: And obviously I'm interested in a cross-platform implementation.
Managed clients currently use another WCF endpoint.
Thanks again :)
Comment: You have a good reason for desiring a binary protocol. However, if you want a cross-platform binary protocol, perhaps you should consider not using WCF. Although this would require quite a bit of effort, it is very likely, in my opion, to result is a safer and more maintainable solution than trying to re-implement a WCF NetTcp client on multiple platforms.
Comment: @PaulKeister I've already implemented a TCP Server(wrapped in my own binding with a custom Transport).Even if eventually I won't go with the solution I've suggested, the TCP server implementation is always there as a backup plan.I simply don't understand why the bytes I'm receiving through the MessageEncoder don't produce the same result when I'm sending them via the client application.I suspect there might be some kind of handshake/negotiation involved before those bytes are actually sent.I'll try having another look at the RFC and see if I can find anything useful. Thanks for your input.
Answer: Finally got it to work.
I initiated the default handshake for a Net.Tcp connection prior to sending the bytes I got via the MessageEncoder.
It's important to note that the endpoint uri must be UTF-8 encoded.
The process is pretty easy - send the negotiation request, send an End Preamble message(0x0C) and wait for the server to return a Preamble Ack message(0x0B).
Then you can send the binary envelope and recieve the response from the WCF application.
I hope this post could help someone in the future.
<code>NegotiationConsts.Via via = new NegotiationConsts.Via(uri);
int arraySize = via.EndpointString.Length +
NegotiationConsts.DefaultRequestLength;

byte[] request = new byte[arraySize];

int count = 0;
request[count++] = NegotiationConsts.Version.RECORD_TYPE;
request[count++] = NegotiationConsts.Version.MAJOR_VERSION;
request[count++] = NegotiationConsts.Version.MINOR_VERSION;

request[count++] = NegotiationConsts.Mode.RECORD_TYPE;
request[count++] = NegotiationConsts.Mode.DUPLEX;

request[count++] = NegotiationConsts.Via.RECORD_TYPE;
request[count++] = via.Length;
via.EndpointString.CopyTo(request,count);
count+=via.EndpointString.Length;

request[count++] = NegotiationConsts.WCFEncoding.RECORD_TYPE;
request[count++] = NegotiationConsts.WCFEncoding.BINARY_ENCODING;

return request;
</code>

Sending custom WCF requests via Sockets


sparkline R creating html table

Question: I found package sparkline:https://github.com/htmlwidgets/sparkline
but I have no idea how to create in markdown/html data.frame with sparkcharts.
I know there is an example in link above, but I don't know how to create that data frame in html automatically.
Answer: I'm not really sure what your problem is or which data frame you refer to. The example on the link you provide is working perfectly. Try the following steps

Start R Studio
Install the sparkline package if you haven't
library(devtools)
install_github('htmlwidgets/sparkline')

Use File -> New File -> R markdown
Copy in the example from the htmlwidgets in the editor and hit the knitr button.

and you will get an html file with several examples.
Answer: I think this is what you are looking for: https://leonawicz.github.io/HtmlWidgetExamples/ex_dt_sparkline.html
you can also find a dummy example here:
R combining data tables DT package and sparkline package box plot with target value
As an example:
Boiled down dummy example as follows (disregard the last column in the data/table)
            library(data.table)
            library(DT)
            library(sparkline)

            hist.A<-rnorm(100)
            hist.B<-rnorm(100)
            hist.C<-rnorm(100)

            current.A<-rnorm(1)
            current.B<-rnorm(1)
            current.C<-rnorm(1)

            #whisker should show full range of data
            boxval.A<-paste(quantile(hist.A,probs=c(0,0.25,0.5,0.75,1)),collapse = ",")
            boxval.B<-paste(quantile(hist.B,probs=c(0,0.25,0.5,0.75,1)),collapse = ",")
            boxval.C<-paste(quantile(hist.C,probs=c(0,0.25,0.5,0.75,1)),collapse = ",")

            data<-data.frame(Variable=c("A","B","C"),Current=c(current.A,current.B,current.C),boxplot=c(boxval.A,boxval.B,boxval.C))
            data$boxWithTarget<-paste(data$boxplot,data$Current,Sep=",")

            cd <- list(list(targets = 2, render = JS("function(data, type, full){ return '' + data + '' }")))
            line_string <- "type: 'line', lineColor: 'black', fillColor: '#ccc', highlightLineColor: 'orange', highlightSpotColor: 'orange'"
            box_string <- "type: 'box', raw:true, showOutliers:false,lineColor: 'black', whiskerColor: 'black', outlierFillColor: 'black', outlierLineColor: 'black', medianColor: 'black', boxFillColor: 'orange', boxLineColor: 'black'"
            cb = JS("function (oSettings, json) {\n  $('.sparkSeries:not(:has(canvas))').sparkline('html', { ",
                    line_string, " });\n  $('.sparkSamples:not(:has(canvas))').sparkline('html', { ",
                    box_string, " });\n}")

            d <- datatable(data.table(data), rownames = FALSE, options = list(columnDefs = cd,
                                                                                fnDrawCallback = cb))
            d$dependencies <- append(d$dependencies, htmlwidgets:::getDependency("sparkline"))
            d

Comment: Although your answer is 100% correct, it might also become 100% useless
if those links are moved, changed, merged into another one or the main site
just disappear... **:-(** Therefore, please [edit] your answer, and copy
the relevant steps from the link into your answer, thereby guaranteeing
your answer for 100% of the lifetime of this site! **;-)** You can always
leave the links in at the bottom of your answer as a source for your
material...

sparkline R creating html table


Mysql : insert into select && where not exists

Question: I need to insert some data in  a table named 'queue' which is a patient queue in a particular date . Two fields data  will be inserted .Two fields name are 'PatientID' and 'Visiting Date'.  Table 'queue' like
QueueID      |         PatientID |           Visiting_date |
-------------|-------------------|-------------------------|
      1      |   4               |      Current date       |

table:queue
But while inserting the record there are two conditions :
Condition 1 : patitentID comes from patient table (given below)
Condition 2 : one record will be inserted to 'queue' table  if it does not exist  to prevent repeatation.ie  PatientID=4 will not be inserted if already  inserted.
-------------|-----------------|------------------|
 patitentID  |    Patient Name |    Contact no    |
-------------|-----------------|------------------|
     4       |  David          |  01245785874     |

table:patient
My SQL is: (it does not work)
INSERT INTO `queue`(`patientID`, `Visiting_date`)
SELECT  patient.`patientID`,'CURDATE()' FROM `patient`
WHERE NOT EXISTS (
    SELECT `patientID`, `visiting_date`FROM  `queue`
 WHERE `patientID` = '4' AND `visting_date`=CURDATE()
) LIMIT 1;

Comment: What error do you get?
Answer: You could set a foreign key to make sure the patients id exists.
In the Queue table you can set patientID as unique, this makes sure you can insert only unique id's in the queue table.
Also if you would like to be able to insert the same userID but with different dates you could specify unique constraint for multiple columns in MySQL.
If you want to solve it with a mysql query only you can use this question.
Answer: I would use a separate query to check if there is a user with that ID in that table.
SELECT * FROM queue WHERE PatientID = 4;
and then check the result of that query, if it returns a row, that means that there is a user in there and you don't do anything.
If the query doesn't return a row, that means you can now use a query to inert a user. Like this
INSERT INTO queue (PatientID, VisitingDate);


Is there a programmatic way to retrieve a player's current gamemode using the @minecraft/server module and WITHOUT using command blocks?

Question: In my custom tools addon, I've noticed a bug where you can get negative durability values by using the tool in creative mode, then switching to survival mode. This is because while vanilla tools don't take durability damage when used in creative mode, the custom ones do. I'd like to be able to reproduce the vanilla tool functionality by having my decrement-durability function be called conditionally only when the player is not in creative mode.
But, I haven't found any way of detecting which game mode is active within the main.js file.
I'm aware of how to detect players' game modes using command blocks, as discussed in this question, and also how to set the game mode using this command. And, I have found the documentation page for the GameMode enumeration in the @minecraft/server module, which lists all the possible modes. I would have expected there to be a way of finding which one is active, but if so it's not documented there.
There doesn't seem to be a getCurrentGameMode() method or anything similar for either the World or Player classes.
I guess it is probably possible to do something like programmatically place a command block and set its command, then set up a chain command block in 'conditional' mode that places a certain type of block only if the 'test for player in creative mode' command returned true, and then have the script check for that special type of block before replacing all three with air. But, I'd really prefer not to use a workaround like this.
So, is there a way of detecting the active game mode using only script functions, that does not require placing temporary blocks?
Answer: As of @minecraft/server version 1.10.0-beta, it is now possible to access the game mode programmatically using the new .getGameMode() method of the Player object.
Documentation: https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/player?view=minecraft-bedrock-experimental#getgamemode


Command created blocks update light level?

Question: I am playing minecraft 1.8 vanilla
while creating a mob spawning room I have used commands to fill the required blocks. the room seems to be complete but with one issue.
you can see the light level 15 in the snapshot. However the room is totally concealed.
When I fill the blocks manually the light level goes down to 0 as expected.
so by using fill command why does the light level does not fall to 0
Comment: Looks like a bug. You should report it on the mojang website.
Comment: I agree with angus; it's probably a bug. A temporary fix would be to use commands for all sides but one, and fill that one in manually.
Comment: I suppose that means `/fill` commands don't cause lighting updates. You could try spawning a `FallingSand` entity and having it fall into a spot on the floor (`setblock X Y Z air` and then `summon FallingSand X Y Z {Block:"minecraft:your_block_here", Damage:?, Time:1}`)
Answer: This is a common bug that happens to me all the time.
I have a few way of fixing these:
Firstly, placing blocks (in particluar light emitting blocks) around the glitched light patches should fix the problem.
Secondly, if placing blocks doesn't work, try reloading minecraft and the world. Another thing I have found useful is to set your render distance to 2, then press back to game... and then put your render distance back up to 10-16 to fix.
Thirdly, if that doesn't work you can use McEdit to fix the glitched light blocks


Convergence of sequences of random variable

Question: Let $X$ be a random variable. Show that $\frac{X}{n}$ converges to zero in probability and almost surely, as $n \rightarrow \infty$.
I am sort of confused by this question since I only learnt a definition of convergence for a sequence of random variables. Am I reading something wrong ?
Comment: @user1952009 Not sure this is even *related*.
Answer: In thise case, the sequence of random variables is given by $X_n = \frac{X}{n}$. You just need to apply the definition of convergence in probability resp. almost sure convergence to solve this exercise.
Comment: I understand. thank you for the clarification
Comment: Could you show me how to do that ? I just want to use this as an example


How to improve the speed resetting a minimax chess board implementation?

Question: I am programming a chess engine with minimax.
I use an array with 120 elements for the board. For every possible move, I have to create a copy of this array which is really slow without using bitboard.
Can I fasten this board copy part, e.g. using strings?
pisces.forEach(pisce=>{
    pisce.forEach(move=>{
          let copy=[...board]
          //other stuff
          board=copy
    })
})

Comment: What is *other stuff* doing with the `board` (or the `copy`)? And why do you overwrite the original `board` with the `copy` in every iteration?
Comment: I need to check every pisces every move for certain position in other stuff I have to play currently chosen move by currently chosen pisce on board and pass it to minimax board should reset every time or I would end up making multiple move from one side
Answer: Instead of copying the board, you could consider using a "do-undo" system:
pisces.forEach(pisce=>{
    pisce.forEach(move=>{
        play(board, move);
        //other stuff
        undo(board, move);
    })
})

NB: in chess you need also to keep track of whether castling is still allowed, en passent capture is allowed, how many moves have passed since the last capture, pawn or castling move (for applying the 50-move rule), ... So a move object should have enough information to set and undo such state changes.
Comment: tanks a lot I had this problem with every other stuff like pistraking castle rights this helps a lot
Comment: Great question and answer. Would love to see the final implementation! Good luck!
Comment: This is the best way of doing it yes!


Can't stream videos

Question: Here is my videoview code :
<code>    Uri uri = Uri.parse(vidurl);
    MediaController mediaController = new MediaController(this);
    videoView.setMediaController(mediaController);
    videoView.requestFocus();
    videoView.setVideoURI(uri);

    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            videoView.start();
        }
    });
</code>
Videos I try to play are stored in my server. They are sent there from the same app, using a custom camera. Here is video capturing parameters: ( Just in case  something were wrong with those , I tried every combination, VP8 Format did stream , except the output had no audio and was rotated sideways)
<code>    mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
    mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
    mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

    if (currentCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) {
        mMediaRecorder.setOrientationHint(90);
    } else {
        mMediaRecorder.setOrientationHint(270);
    }

    mMediaRecorder.setVideoSize(list.get(sizex).width, list.get(sizex).height);
    mMediaRecorder.setVideoEncodingBitRate(1500000);
    mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
    mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
    mMediaRecorder.setVideoFrameRate(30);
    mMediaRecorder.setMaxDuration(15000);
    mMediaRecorder.setOutputFile(getVidFile().getAbsolutePath());
</code>
I've been trying to solve this for a long time but I am out of ideas now. I would like to stream those videos in a videoview. But instead of that , I have to wait 10-20 seconds. After that ,either video starts or it gives me an error that video can't be played.
Additional information:
Project minimum sdk is 18 , but I can change it if that will help.
My testing device is Asus Zenfone 2 (5.0)
I didn't test with any other device
Videos are stored in godaddy linux host. www.mydomain.com/videos/
Video encoding is h264 Baseline Profile
Moov atom is at top ( after fytp(or something like that) ) just as recommended
I tried using third party video player libraries like exomedia
Some videos do work , for example :

http://www.html5videoplayer.net/videos/toystory.mp4

I checked that videos encoding. It's encoded in h264 MAIN PROFILE ( from my research , main profile isn't supported for most of android devices , baseline profile is recommended instead) AND MOOV ATOM IS AT LAST POSITION. But this video plays just fine... dafuq?
EDIT:Properties of that toystory video which works:
1
2
And here is a video captured from my app with parameteres given above(notice the moov atom is at right place, but this still doesn't work )
3
4
Comment: Now I tried using mediplayer using a surfaceview and not forgetting to call prepareasync instead of prepare () , still didn't work.

E/MediaPlayer: Error (1,-2147483648)
Comment: Any error you find out ?? Instead of videoview.start() use mp.start()
Answer: Which network protocol is used when your video is streamed from server to app? Perhaps the network protocol you are using is not supported by VideoView.
VideoView only supports limited protocols.
According to android documents on "Supported media formats":
The following network protocols are supported for audio and video playback:
--RTSP (RTP, SDP)
--HTTP/HTTPS progressive streaming
--HTTP/HTTPS live streaming draft protocol:
<code>MPEG-2 TS media files only

Protocol version 3 (Android 4.0 and above)

Protocol version 2 (Android 3.x)

Not supported before Android 3.0
</code>
--Note: HTTPS is not supported before Android 3.1.
Comment: I don't know what is a network protocol. How do I check which one I'm using?
Comment: After examing your question again, I think the network protocol used is Progressive http.That should not be a problem. There are  questions similar to yours :http://stackoverflow.com/questions/11540076/android-mediaplayer-error-1-2147483648 and http://stackoverflow.com/questions/4728085/cannot-play-certain-videos. Their answers metioned "For 3GPP and MPEG-4 containers, the moov atom must precede any mdat atoms, but must succeed the ftyp atom."  In your question ,you mentioned your configuraiont is "Moov atom is at top ( after fytp(or something like that) )" .Maybe that is the problem.
Comment: according to this : http://www.adobe.com/devnet/video/articles/mp4_movie_atom.html

my moov atom is at correct position

Can't stream videos


Angular component not rendering when passed as a string in a innerHtml attribute

Question: I use an api that returns some html. Angular components are used in the html code but not shown in the application.
How can I show an angular component when it is stored as a string?
StackBlitz demo
Comment: No, this is not possible in current Angular version. Upto some extent you can achieve this by exposing your Angular Component as a web component using Angular Elements API, you can refer [this example](https://netbasal.com/understanding-the-magic-behind-angular-elements-8e6804f32e9f)
Answer: In general, this goes against how Angular works. There is no Angular feature for [innerHTML]. There are no component selectors there, not even a ViewContainerRef. Instead, because Angular exclusively trusts its own templates, any HTML, CSS, and JS that even appears somewhat suspect is eliminated as a security safeguard. So InnerHTML is outside limits.
You can try to dynamically load components and content with the ViewContainerRef.
Answer: I think rendering HTML that's returned from the server is not really recommended (you will have to trade off a lot of angular features, like *ngIf etc.). However, if you REALLY want to do it, it is a hard way: https://medium.com/acute-angular/angular-how-to-render-html-containing-angular-components-dynamically-at-run-time-ee8fc907b545
Maybe rethinking the logic a bit, let's say returning an array of components to be displayed, will work flawlessly, since you can string compare and append components directly.
Hope it helps!


Pull out a div from the bottom

Question: I have this code at jsfiddle
Quite simply, I want to pull it out from the bottom, on a fixed size page (1920x1080), I have this sample working to pull from the right edge, but not sure how to move it to the bottom.
Many thanks if you can help
HTML

        Yar, there be dragonns herre!

Script
$(function () {
    $("#clickme").toggle(function () {
        $(this).parent().animate({right:'0px'}, {queue: false, duration: 500});
    }, function () {
        $(this).parent().animate({right:'-280px'}, {queue: false, duration: 500});
    });
});

Style:
body {
    overflow-x: hidden;
}
#slideout {
    background: #666;
    position: absolute;
    width: 280px;
    height: 80px;
    top: 45%;
    right:-280px;
    padding-left: 20px
}

#clickme {
    position: absolute;
    top: 0; left: 0;
    height: 20px;
    width: 20px;
    background: #ff0000;
}

#slidecontent {
    float:left;
}

Answer: To move it to the bottom, simply make a small change to your CSS.
#slideout {
    background: #666;
    position: absolute;
    width: 280px;
    height: 80px;
    bottom: 50px;
    right:-280px;
    padding-left: 20px
}

Answer: Look at the following jsFiddle..
Basically I copied and pasted your code and manipulated using bottom positioning. that way you will be able to see the differences between the two.. both in CSS and JS. it is essentially the same logic as the code you posted.
Note that the body now has overflow:hidden; instead of overflow-x:hidden;

Pull out a div from the bottom


Executing wsl.exe with jenkins returns exit -1073740791

Question: I have jenkins set up on a windows 10 computer that has WSL (Windows Subsystem for Linux). When I run, for example, from the terminal the simple command ""C:\Windows\System32\wsl.exe" --help" it works fine.
Doing the same as a step on jenkins with a windows batch command, I get the exit code-1073740791.
I have tried the following solutions that did not worked out:
-From a tip that it would not be allowed to run on System32, I tried copying the executable to another folder outside System32, but I get the same error;
-From another research, could be running under 32 bit, since the cmd is 64 bit, so I tried calling from the Sysnative "C:\Windows\Sysnative\wsl.exe", but I get file not found;
Also:
Sometime ago I had a similar issue running the bash.exe from the System32, solved it by using another bash.exe (grom gitbash).
Any hints on how to overcome this problem? I really need to run WSL to compile some projects in jenkins jobs.
Thank you for your time.
Answer: Not sure whether this is the answer or not (it may be), but the explanation and troubleshooting are a bit long for a comment.
It sounds like you may be on the right track with 32-bit vs 64-bit, but possibly a bit confused on which apps are which architecture.
On 64-bit Windows 10, wsl.exe is always 64-bit.  You can see this (assuming you have put it back in the right place) via:
> file /mnt/c/Windows/System32/wsl.exe
/mnt/c/Windows/System32/wsl.exe: PE32+ executable (console) x86-64, for MS Windows

Moving it doesn't change the architecture, of course.

since the cmd is 64 bit

It's really the architecture of Java and Jenkins that you need to worry about.  Is your Java 32-bit or 64-bit?
> file "$(command -v java.exe)"
/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath/java.exe: PE32 executable (console) Intel 80386, for MS Windows

I don't run much Java at the moment, but I happened to have a release installed from a while back on one of my systems.  Turns out it is 32-bit.
If your java.exe is 32-bit, then this would most likely explain why you can't run wsl.exe, which is 64-bit.

-From another research, could be running under 32 bit, since the cmd is 64 bit, so I tried calling from the Sysnative "C:\Windows\Sysnative\wsl.exe", but I get file not found;

I assume that you are referring to this answer or something similar.  It sounds like you may have tried that from CMD.  Let's do that here for reference:
>C:\Windows\Sysnative\wsl.exe

The system cannot find the path specified.

> wsl.exe

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

>

This is correct, since both CMD and WSL are 64-bit.  The purpose of Sysnative is to allow you to call a 64-bit from a 32-bit app.
However, if you try that from a 32-bit application, it should work.  Try from "Windows PowerShell (x86)":
> wsl.exe

wsl.exe : The term 'wsl.exe' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ wsl.exe
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (wsl.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

> C:\Windows\Sysnative\wsl.exe
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

>

If you try that path from within Jenkins (assuming it is 32-bit), what do you get?
If C:\Windows\Sysnative\wsl.exe doesn't work for you from Jenkins, and assuming your Java is 32-bit, do you have the option to run 64-bit Java for this task?
Comment: Thank you for your detailed response.

Java is 64 bit and when I run on jenkins "C:\Windows\Sysnative\wsl.exe" it does not find it, so I guess the problem is not here.

Could it be any jenkins configuration that does not allow it to run System32 applications? I read some comments about "You cannot open windows processes through Jenkins running as a service".
Comment: Sure, some of those comments were from [this](https://stackoverflow.com/a/16310502/11299409) and [this](https://stackoverflow.com/a/57154624/11299409)
Comment: @JoãoP. Bummer - If it's something specific to Jenkins, I won't be able to try it out.  If you happen to find those comments again, can you link them in a reply to me, and I can at least see if I can think of a hack-around?  Thanks!


Net speed indicator for Ubuntu 15.04

Question: What are some net speed indicator available for Ubuntu 15.04 and how to install them?
Comment: @Raphael none of those are indicator applets
Comment: @Ravan: Please retract close vote: none of the duplicate are indicator applets.
Comment: @ParanoidPanda: ------^
Answer: You can use indicator-multiload for this. To install, run the following commands:
sudo apt-get update
sudo apt-get install indicator-multiload

Now, run indicator-multiload:
indicator-multiload & disown

Then, click on the indicator and select preferences to customize the output. You can display graphs, text or both for many different areas and not just netspeed.
Comment: I like this, but I wish I could make the network speed number appear in the indicator itself.
Answer: To add the Netspeed Unity Indicator use the following commands:
sudo apt-add-repository ppa:fixnix/netspeed
sudo apt-get update
sudo apt-get install indicator-netspeed-unity

Net speed indicator for Ubuntu 15.04


Should water heater thermostats be set to the same temperature?

Question: Should the top and bottom water heater thermostats be set to the same temperature?
I did a quick google search and saw all kinds of differing opinions.  for instance, this guy seems like he knows what he's doing:
http://www.youtube.com/watch?v=RCDvHIcPreo&t=2m09s
and he said the top thermostat should be set to a higher temperature than the low one, but other places I've read said they should be at the same temperature.
my water heater's old, if that makes a difference.  I didn't see a date, but the energy sticker had some reference to 1994.  sorry I don't have more info; the thing's wedged back in a tight closet and hard to get to.
Answer: Setting the top element slightly higher helps the elements to be used evenly.  If you set them to the same temperature, the bottom element will be the first one on every time, and frequently the only one used to maintain the temperature.  If you set the top element too much higher, then it will be used most of the time, and the bottom element acts more as a pre-heater.
Having them used evenly will spread out the minimum time to replacement.  But I wouldn't go through too big of an effort to change the settings on an old water heater.  Whenever your elements do go, or whenever you decide to change the temperature, that would be the time to make this adjustment.
Comment: I am changing the temperature which is why I'm asking.  What should the difference be?  5 degrees (F), 10?  Thanks!
Comment: When you change it, you'll be able to tell the temperature difference in the tank by when each element clicks on or off.  If you can't get them exactly the same, and you're not using any water at the time, err on the side of having the top element activate slightly more.  Cold water coming into the tank when water is running will reverse that balance.
Answer: The top element is always the first one on.  In fact the bottom element does not receive power until the top thermostat is satisfied.  I'm guessing that setting your top thermostat to a 150 would give you small amount of really hot water rather quickly, while setting the upper and lower thermostats evenly to a moderate temperature (115-125) would be your quickest way to get a full tank of hot water.
http://waterheatertimer.org/How-water-heater-thermostat-works.html
Comment: You should never set a residential hot water heater to 150 degrees.  It is dangerous!  Here is the time to get a third degree burn:  150 degree water for two seconds. 140 degree water for six seconds. 130 degree water thirty seconds.  120 degrees water five minutes.
Answer: Yes the hot water exits from top... I don't know who told him it exits from bottom that isn't even possible since the only tube going down that low in the tank is cold... You would never get good hot water if it exited from the bottom, it's simple thermodynamics, heat rises even in water therefore the most efficient way to pull hot water is from the top, if the top thermostat isn't satisfied the bottom will not come on... Remember to cut your power off before setting your thermostats, but there are many theories on what to set your temps on, I typically run my top 5-10 degree's hotter than the lower.. Some people do the same.. You can test what gives you solid heat for long time if you truly feel like just going through all of the hot water several times I suppose. I just kinda wing it, if your tank is too small then higher heat will give you longer time, but is dangerous especially if you have kids around.. There's really no right or wrong answer in my opinion..
Here's a link kinda showing the the basics of electric heaters..
http://www.whirlpoolwaterheaters.com/learn-more/electric-water-heaters/how-electric-water-heaters-work/standard-electric-operation/
Answer: I am a plumber and water hook up is on the top of the heater but the water that comes out through a dip tube that goes all the way to the bottom of the heater so the water you get to the faucet comes from the bottom of the tank not the top.
Comment: Hello, and welcome to Stack Exchange. This isn't true; hot water rises, and so the hot water output is from the top of the tank. The dip tube takes cold water in at the top of the tank and brings it to the bottom, preventing it from mixing with the hot water.


Files impossible to wipe, where are they saved?

Question: I installed Ubuntu on a USB disk, my installation is:
sudo fdisk -l /dev/sdb

Disk /dev/sdb: 7773 MB, 7773585408 bytes
240 heads, 62 sectors/track, 1020 cylinders, total 15182784 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0006f051

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          62    12289124     6144531+  83  Linux
/dev/sdb2        12290048    15182783     1446368   82  Linux swap / Solaris

I then zeroed blocks reserved
sudo tune2fs -m 0 /dev/sdb1

I have overwritten empty space in /dev/sdb1
dd if=/dev/urandom of=random.file bs=1024

Then I tried with photorec to recover deleted files "from whole partition" sdb1. Photorec retrives a lot of files, I do not understand where they are saved.
I have noticed that there is unallocated space between partitions, can it be the problem?
Photorec
PhotoRec 6.14, Data Recovery Utility, July 2013
Christophe GRENIER <email@example.com>
http://www.cgsecurity.org

Disk /dev/sdb - 7773 MB / 7413 MiB (RO) - Sony Storage Media

     Partition                  Start        End    Size in sectors
      No partition             0   0  1  1020  83 38   15182784 [Whole disk]
> 1 * Linux                    0   1  1   825 211 43   12289063
  2 P Linux Swap             825 226 37  1020  83 38    2892736

Comment: So you want to be 100% sure that all those files are unrecoverably gone, or do you need to recover some of these files? From what we can see you wiped **unused** drive space but your files were still located in a space appearing to be used in the filesystem.
Comment: I think we have a winner.... photorec doesn't find *only* deleted files... it finds anything on the disk that looks like a file without regard to whether it has been deleted or not.
Comment: I need those files are unrecoverably gone. I think they are files created from OS as temp files and then deleted, so it is possible they are in some space where I can't write to wipe them. How can I solve the problem?
Answer: Yes, that looks strange; I see two things that could have went wrong:
You did not give your actual dd command. Did you get error messages from it?
I'm not sure the dd command finished overwriting the whole partition with random data.
Assuming it did finish, I would think you made a typo and were running photorec on the whold disk, /dev/sdb , instead of the partition, /dev/sdb1. Or you worked on the swap partition, /dev/sdb2.
In both cases, photorec would have scanned the swap partition (as part of the whole disk, or separately). That partition contains data that was in main memory RAM at some time. The RAM could contain some or all blocks of files for a lot of reasonst - so it would be not surprising when these end up in the swap partition.
Comment: dd doesn't get any error and I run photorec only on sdb1. As said in previous comment I notice that recovered files are file created from OS as temp files and then deleted, so it is possible they are in same protected disk area, but I need to make them impossible to recover.
Answer: The only measure to securely remove all traces, remnants, and fragments of files in our hard drive is to backup those files we want to keep to another drive (not partition).
We can then completely overwrite the whole drive with Zeros (much faster) or random numbers, repartition it, and reformat that drive. After that any recovery will be impossible.
Finally we may restore our backup files.
Note that by doing so the UUID of the drive may change and the Master Boot Record will also be lost. Therefore we may have to edit references to that drive accordingly and we will also have to restore the MBR.


Where to define properties in a multi-modules Maven project?

Question: Currently, I have the following structure for my project Foo:
foo-parent
  +- pom.xml

project-foo
  +- pom.xml
  +- module-1
  |    +- pom.xml
  |    +- ...
  +- module-2
  |    +- pom.xml
  |    +- ...
  +- ...

In foo-parent, there is a pom.xml that defines all the generic configuration for my project (basic dependencies, plugins management, etc.).
The externalization of the parent helps me to have a stable parent configuration (which is not the case if the parent is the root pom.xml, which is also used for aggregating all modules).
The project-foo/pom.xml is only here to aggregate all the modules, and does not define any parent...
Now, I am modifying my project to use the Maven release plugin. Thus, I need to configure the <scm> information.
But where to put this information, since it depends on the branch where the code is located (i.e. the value of <scm> is different for the code in the trunk than in branch-X, or branch-Y).

Solution #1 Define the <scm> in the foo-parent project. This way, each module will have this information available. However, I will have several version of foo-parent project, one per branch. It will make the versioning of this parent quite harder...
Solution #2 Define the <scm> in the foo-parent project, but add a parameter inside (such as <scm>scm:svn:http://server/foo/${svn.branch}</scm>). However, this will just move the problem: where do I define the svn.branch property?
Solution #3 Define the <scm> in the project-foo/pom.xml, which will now have the foo-parent as parent, and change the <parent> of all sub-modules to point to project-foo/pom.xml (i.e. foo-parent > foo-root > module-X).
Solution #4 Define the <scm> (or svn.tag property) in each module. Don't really like that...
Solution #5 Any other idea?

My point of view is to use the solution #3, but what are your feelings about that?
Thanks.

Edit (regarding khmarbaise answer)
The project foo-parent is in reality in a sub-directory of project-foo, but is not aggregated by project-foo/pom.xml file. I said that I "externalized" it just to show that it is separated from the rest of the modules. The main interest of that is to try to keep the parent as stable as possible, and that's why I tried to separate the parent pom from the aggregation pom.
However, as I use extensively the Maven release plugin (not on that project, but on others projects), I think it's better to not continue on this track, and merge all the foo-parent/pom.xml in the project-foo/pom.xml. This will ease the management of my project.
Answer: If you like to use multimodules in maven you have to follow some best-practices which means first to have the parent into your structure and not outside. This means:
project-foo
  +- pom.xml (This is your parent for the module-1 etc.)
  +- module-1
  |    +- pom.xml
  |    +- ...
  +- module-2
  |    +- pom.xml
  |    +- ...
  +- ...

What is possible to deviate from that is to create a new folder:
project-foo
  +- pom.xml
  +- project-parent (pom.xml)
  +- module-1
  |    +- pom.xml
  |    +- ...
  +- module-2
  |    +- pom.xml
  |    +- ...
  +- ...

But than you have to define the parent a little bit strange for module-1:
  <parent>
    <groupId>..</groupId>
    <artifactId>..<artifactId>
    <version>..</version>
    <relativePath>../project-parent/<relativePath>
  </parent>

which i wouldn't recommend cause it produces more configuration than needed...
If you use the "default" which is the best-practice:
project-foo
  +- pom.xml (This is your parent for the module-1 etc.)
  +- module-1
  |    +- pom.xml
  |    +- ...
  +- module-2
  |    +- pom.xml
  |    +- ...
  +- ...

in your module-1 it looks like the following:
  <parent>
    <groupId>..</groupId>
    <artifactId>..<artifactId>
    <version>..</version>
  </parent>

and in your parent (in this case).
project-foo
  +- pom.xml (This is your parent for the module-1 etc.)

you have to define the modules you are using:
<modules>
  <module>module-1</module>
  <module>module-2</module>
  ..
</modules>

Apart from that you should also define your dependencyManagement and pluginManagement into that pom.
If you like to have a complete separate parent pom you have to define a separate project which contains the pom plus the scm configuration for that pom only and do a real release of that pom (like an jar artifact except that it is a pom) and of course a version which you can use in your project as parent.
Coming to the point of the SCM area: The only location for such kind of information within a multimodule build is in the project-foo/pom.xml:
project-foo
  +- pom.xml (This is your parent for the module-1 etc.)

Nowhere else will be the definition of the SCM never in the modules! Furthermore never use properties to define the scm-area just use the information you need:

    scm:svn:scm:svn:http:///project/trunk/
    scm:svn:http:///project/trunk/
    scm:svn:http:///project/trunk/

If you are woring about the problem using branches etc. you can handle that via the maven-release-plugin which gives you the possibility to create a branch via:
mvn release:branch

Based on that and during the release process the URL for the SCM area will changed appropriately. So you don't need to worry about them (Never use properties for them, cause it won't work!)
You also need to configure the distributionManagement area to define where to put SNAPSHOT and released version of your artifacts (I hope you are using a Repository Manager like Nexus, Artifactory or Archiva?).
I can recommend to read the Sonatype Book on multi-module builds etc.
Comment: Thanks for your answer. I think I know already how Maven works, even for multi-modules, but as my edition states, I try to "externalize" the parent `pom.xml`, which does not seem to be a good idea (at least in my context). So the solution will simply be to merge parent and aggregated pom.
Comment: Why is that not a good idea? As i described simply create a separate project from your "super-pom" and make a release from it (including scm plus distributionManagement. Than use this as parent in your project-foo/pom.xml as parent. That's it.
Comment: I think it's not a good idea *in my current context*. Having a separate pom just for one multi-modules project is not really an advantage compared to a single parent+aggregation pom in the root directory...
Comment: The advantage is you can reuse the created super-pom...but it's ok if you don't see it that way np.


What is the difference between `Content-Length` and `Transfer-Encoding`? urllib.request.urlopen

Question: I'm going to download using GitHub url.
However, the value received by urlopen is not always constant.
If you run the code below,
import urllib.request

url = "https://github.com/PixarAnimationStudios/USD/archive/v20.11.zip"
u = urllib.request.urlopen(url)

meta = u.info()
print(u.headers.keys())
print(u.headers.get("Content-Type"))
print(u.headers.get("Transfer-Encoding"))
print(u.headers.get("Content-Length"))

case1
['Date', 'Content-Type', 'Content-Length', 'Connection', 'Access-Control-Allow-Origin', 'Content-Disposition', 'Content-Security-Policy', 'ETag', 'Strict-Transport-Security', 'Vary', 'X-Content-Type-Options', 'X-Frame-Options', 'X-XSS-Protection', 'X-Varnish', 'Age', 'Via', 'X-Cache', 'X-Cache-Hits', 'Accept-Ranges', 'Vary', 'X-GitHub-Request-Id']
application/zip
None
30301735

case2
['Date', 'Content-Type', 'Transfer-Encoding', 'Connection', 'Access-Control-Allow-Origin', 'Content-Disposition', 'Content-Security-Policy', 'ETag', 'Strict-Transport-Security', 'Vary', 'X-Content-Type-Options', 'X-Frame-Options', 'X-XSS-Protection', 'X-Varnish', 'Age', 'Via', 'X-Cache', 'X-Cache-Hits', 'Accept-Ranges', 'Vary', 'X-GitHub-Request-Id']
application/zip
chunked
None

What is the difference between Content-Length and Transfer-Encoding?
i used python3.9
Answer:
What is the difference between Content-Length and Transfer-Encoding?

One tells you how long the response's content is (and may be absent), the other tells you whether the response is being sent using something other than directly sending the data (and may be absent).
In the first case, you're seeing that not using a chunked Transfer-Encoding means the server has to send Content-Length up front so your client knows it's received the whole file.
In the second, the file is being sent with chunked, so there's no upfront declaration of the complete length, and Content-Length is omitted. The length of the content can be determined from the sum of each chunk.
Comment: Thank you for your answer. Then, is there any way I can always include content-length? Or how can i getl the size by transfer-encoding?
Comment: I've added a link to https://stackoverflow.com/questions/4929484/how-to-determine-content-data-length-from-chunked-encoding-if-http-header-not-se . The answer is: download the file, and see how much you got. You'll need to ask a more specific question if that's not an option.


Show that expected number of years till first observation is exceeded for first time is infinite given infinite observations

Question: Let $X_1,X_2...$ be jointly independently random variables with common pdf given by $f(x_i)$. I am trying to show that $E[N]$ is infinite, where $N$ is the number of years till $X_1$ is exceeded for the first time, and $X_i$ represents the annual rainfall in the i-th year.
First I obtained the distribution function for N. Since $F(X_1)$ is the probability of a particular observation being less than $X_1$, it can be shown that: $$p(N=n)=F(X_1)^{n-1}(1-F(X_1)).$$
Next, I can express the expected value of $N$ as: $$E[N]=\sum_1^\infty nF(X_1)^{n-1}(1-F(X_1))=\sum_1^\infty nF(X_1)^{n-1} - \sum_1^\infty nF(X_1)^{n}. $$
At this point, I'm not sure how to proceed. Any advice?
Comment: $p(N=n)=F(X_1)^{n-1}(1-F(X_1))$ makes no sense -- the left-hand side is a constant and the right-hand side is a random variable.
Comment: @DavidS: This might be $P(N=n\mid X_1)$ (I haven't checked that), but it can't be $P(N=n)$; an equation that depends on $X_1$ on one side and not on the other makes no sense.
Comment: @DF: No, these events are correlated, since they all involve the same $X_1$.
Comment: @DF: They are. That doesn't mean that the events $X_i\gt X_j$ and $X_i\gt X_k$ are independent.
Comment: $X_1, X_2...$ share a common pdf but are jointly independent according to the question.
Comment: @joriki, yes, I'm sorry
Comment: @joriki I'm not sure what you mean in your first comment. The probability that N=2, for example, would be the probability of the 2nd observation being less than $X_1$ and the 3rd observation being larger than $X_1$.
Answer: The probability that $N\ge n$ is the probability that $X_1$ is the greatest of the first $n$ values, which is $\frac1n$. Thus
$$
\mathsf E[N]=\sum_{n=1}^\infty\mathsf P(N\ge n)=\sum_{n=1}^\infty\frac1n=\lim_{k\to\infty}H_k=\infty\;.
$$


Does Absorbing have any powers in Lego Marvel?

Question: I mean, the question might answer itself but I was wondering if you got Absorbing Man and bought him, does he have any powers? Like can he fly or do as his name says?
Answer: Per this FAQ on GameFAQs, he has no powers:

Absorbing Man - Character Token in Manhattan
Cost: 150,000
[...]
Powers:
None
Comment: Thanks for the info man! Now i know not to switch to him. :P Haha!


Make dynamically generated Textblocks to fit to their respective content

Question: I am making a Windows 8 app and I am displaying words in dynamically generated textblocks using gridview. I want each textblock to be of the exact width so as to fit to the respective word contained in it. Is there a way to do this?
Thanks
Comment: `Is there a way to do this?` - Yes, I'm pretty sure there's a way for whatever you're trying to do. Please read [**this**](http://mattgemmell.com/what-have-you-tried/)
Comment: The default `TextBlock` `Auto` `Width` should do this already, plus some `Padding` around it that built into the `Style`. The drawn width/height will change based on the `Horizontal` and `VerticalAlignment` though, so if you've tried it already and are coming across problems, this may be why. Plus, the `GridViewItem`s have their own padding, which you can also remove using a custom `Style`. You can view the default `Style` for `GridViewItem`s [here](http://msdn.microsoft.com/en-us/library/windows/apps/jj709915.aspx). (Scroll down a bit).
Answer: I tried generating textblocks in the codebehind dynamically and added text. The width of the resulting blocks was fitting the content.
So as soon as one dynamically generates text-blocks, they automatically fit to the content width.


Can we execute select statement in AND conditon (getting error missing expression)

Question: I am building a complex query. First here is my query
select LOSA_APP.app_ref_no AS "App.Ref.No."
from losa_app LOSA_APP,
     losa_app_z LOSA_APP_Z
where
    LOSA_APP.app_status='A'
and
    trunc(sysdate) between (nvl(LOSA_APP_Z.li_dt, LOSA_APP_Z.li_collect_dt)) AND ((trunc(sysdate)))
and
    (trunc(sysdate) - nvl(losa_app_z.li_dt,losa_app_z.li_collect_dt)) > 90
and
    (select losa_app_z.app_ref_no
     from losa_app_z
     where (trunc(sysdate) - nvl(losa_app_z.li_dt, losa_app_z.li_collect_dt)) > 90
    )

The problem is if i run the last query separately or i omit the last query then it is run fine, like if i only run
 (select losa_app_z.app_ref_no
  from losa_app_z
  where (trunc(sysdate) - nvl(losa_app_z.li_dt, losa_app_z.li_collect_dt)) > 90)

but if i run the whole query then i get the error
ORA-00936: missing expression
00936. 00000 -  "missing expression"
*Cause:
*Action:
Error at Line: 7 Column: 128

Line 7 is the line at which my last query and
    (select losa_app_z.app_ref_no from losa_app_z.... is present. What i am doing wrong ? Please help.
Thanks
Answer: You should compare result of this query
 and
 (select losa_app_z.app_ref_no
  from losa_app_z
  where (trunc(sysdate) - nvl(losa_app_z.li_dt, losa_app_z.li_collect_dt)) > 90
 ) = something_here

to something.
For future always try to manage your brackets properly. Count them if necessary.


Application.DoEvents in FormClosing event

Question: I have implemented my custom ThreadManager which has been working flawlessly during my tests. When user wants to close the application, the closing is suspended until all threads exit or they select to end the application without waiting (after 30 seconds have passed).
What I need to clarify is if using Application.DoEvents() could be dangerous in FormClosing event. Shall I use it or find another way of waiting for threads to exit?
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
    // save settings before exit
    Properties.Settings.Default.Save();

    // Update program about intention
    Program.ApplicationClosing = true;

    try
    {
        // Inform user with friendly message
        ShowModalWaitForm("Application is closing.");

        // Keep the timestamp in order to keep track of how much time has passed since form closing started
        DateTime startTime = DateTime.Now;

        // Wait for all threads to die before continuing or ask user to close by force after 30 seconds have passed
        // In case user prefers to wait the timer is refreshed
        int threadsAlive;
        do
        {
            if (_threadManager.TryCountAliveThreads(out threadsAlive) && threadsAlive > 0)
            {
                Application.DoEvents();
                Thread.Sleep(50);
            }

            TimeSpan timePassed = DateTime.Now - startTime;
            if (timePassed.Seconds > 30)
            {
                if (ShouldNotWaitThreadsToExit())
                {
                    break; // Continue with form closing
                }
                else
                {
                    startTime = DateTime.Now; // Wait more for threads to exit
                }
            }
        } while (threadsAlive > 0);
    }
    catch (Exception ex)
    {
        _logger.ErrorException("MainForm_FormClosing", ex);
    }
    finally
    {
        HideWaitForm();
    }
}

private bool ShouldNotWaitThreadsToExit()
{
    return MessageBox.Show(@"Press ""OK"" to close or ""Cancel"" to wait.", "Application not responding ", MessageBoxButtons.OKCancel) == DialogResult;
}

Comment: Why bother the user?  Do they know what is going on?  In most of my apps, I just exit the app immediately because there is no reason to not do otherwise. In the odd case when I have to make sure some file is closed or DB connection released, I just minimize the app and wait with a timer for 'thread shutdown' message/s or BeginInvokes() or whatever to come in.
Comment: Indeed, there is a DB connection that has to be released and also there are `WebBrowser` or `WatiN` calls that have to return, so killing the application is not recommended. Minimizing is not really  much different than showing the wait form.
Answer: I'd recommend putting your wait condition in another thread. Display a modal dialog from OnFormClosing method. Inside this dialog start worker thread e.g using BackGroundWorker class and dismiss this dialog when waiting finished.
Bonus topic possible drawbacks of calling Application.DoEvents Method
Comment: So this, basically means `e.Cancel = true` in `FormClosing`, right? ***Edit:*** No, it doesn't. I got it 100% now.


Is $\{(x,y) \mid (\exists f\in \operatorname{Homeo}(X))(f(x)=y)\}$ closed?

Question: Let $(X,\mathcal T)$ be a Hausdorff topological space and $A$ be the set all $(x,y)\in X^2$ for which there's a homeomorphism $f:X\to X$ such that $f(x)=y$. Is $A$ closed?
EDIT:
I think
$$A=\bigcup_{f\in \operatorname{Homeo}(X)}f$$
Comment: Your edit is correct.
Comment: So is it really a standard thing to denote the graph of a function $f$ by $f$? I
Comment: $f$  can be regarded as a relation on $X$, that is, a subset of $X^2$.
Answer: Consider $X=[0,1]$ with the usual topology inherited from the absolute value.
For every $n\geq 2$, it is easy to construct a piecewise affine homeomorphism $f_n$ of $[0,1]$ onto itself such that
$$
f_n\left( \frac{1}{2}\right)=1-\frac{1}{n}.
$$
So the points $(1/2,1-1/n)$ belong to $A$ and they converge to $(1/2,1)$ in $[0,1]^2$. Now if there was a homeomorphism $f$ of $X$ onto itself such that $f(1/2)=1$, we would have
$$
[0,1]\setminus \{1/2\}=f^{-1}([0,1)).
$$
The lhs is disconnected, while the rhs is connected. Contradiction. So $(1/2,1)$ does not belong to $A$. Hence $A$ is not closed.
Comment: You can be slightly more precise (with the same ideas): $A$ is the interior of the square plus the four corners $(0,0)$, $(0,1)$, $(1,0)$ and $(1,1)$. +1 anyway
Comment: Thanks. You're right. I only meant to answer the question and did not bother to determine $A$ completely. I guess I was lazy...
Comment: Hmmm. Posting a full answer versus posting a comment-hint. Who wins? :-)
Comment: @Martin You obviously win: you've got three upvotes with your comments.
Comment: I removed them, so you get the deserved votes. I'll stop bothering you with irrelevancies now, promised.
Comment: @Martin I don't recall you've ever bothered me.


How to verify water-feed entry-point into 2nd floor?

Question: BACKGROUND
A 2nd story living quarters is perched atop of a ground floor office.
There is high certainty based on history and observations that there is a slab leak: assume this is the case for this question.  It is desirable to find the water feed into the upstairs (entry point for a bypass).
PRECEDENT
There is a very similar second office / apartment configuration that has a copper pipe, that comes out of the slab, travels behind an office wall vertically and bridges and provides water to the 2nd floor:

The above photo is for the second office. The pipe in question is all copper. It was verified (by cutting the PVC pipe) that the small PVC pipe is the water-feed for a 'sister' location.
EFFORTS
A visual inspection was performed to find the water feed for said apartment: a copper pipe candidate is thought to be the the water-feed.

The goal is to confirm that it is the water feed without cutting the pipe.
QUESTIONS
What tests can be performed on said candidate copper pipe to confirm that it is the water feed?  Tests that are simple, easy, can be performed without elaborate tools (especially avoiding cutting) are appreciated.  Thank you
Comment: Look below for a shut off valve. Turn it. See if you have water flowing upstairs. That said, that copper to CPVC line _is_ a supply side line (it certainly isn't drain or vent at that small a diameter), is the question "is this the supply to upstairs?"
Comment: Also, changed "shall be" to "is". "Shall be" indicates a mandate for a future event, while "is" connotes a current happening. I don't think you're intending that there _must_ be a slab leak at some point in the future, most people would prefer to avoid that...
Comment: Also, [very closely related](https://diy.stackexchange.com/questions/203588/how-to-minimize-waterback-flow-mess-when-cutting-an-in-service-pipe), though not _quite_ a dupe. It is the same picture, though...
Comment: @FreeMan  After months of searching the candidate-pipe was found last night: so I probably am biased and badly want this to be the feed. Thanks for the updates.  The same picture provided to show the "sister" of the system under consideration.
Answer: with all the water off heat the pipe at one location then turn the water on and see if the heat moves in response to this.
the heat is going to move slowly by conduction with the water off, so it may take a few tries to get a definate answer.  you could perhaps measure how fast the hot spot cools, with and without water flow.
Answer: EPILOGUE
The vertical copper pipe at the top of the drywall is the slab pipe. This answer documents the details and thought process that confirmed the hypothesis.
BACKGROUND
I hope this answer helps a future reader.
Because of time constraints and I believe I had a 90+% chance I had the right pipe.  The goal was to minimize any water released when cutting the copper pipe in the ceiling.
From the outside, I wrenched the slab pipe open slightly so that the water in the slab would drain.  It drained very quickly, which signaled the pipe is close and increased my confidence.   The next step was to cut the copper pipe in the ceiling: creating a water feed input port and slab pipe output-port.
CONFIRMATION OF OUTPUT PORT:
When the copper pipe was cut, a few drops of water dribbled out, which again boosted my confidence I had the right pipe.   To confirm that this ceiling copper pipe is the extension from the outside, I temporarily connected a PEX pipe to the hypothesis output-port with a Shark-bite push connector for easy install & removal.  The open end of the PEX pipe was positioned outside next to the water valve.
This setup allowed me drive water through the leaky slab pipe and out the new PEX pipe.  The water that flowed through the PEX pipe confirmed the hypothesis that said ceiling copper pipe is connected to the outside valve and the upstairs feed point.
BEFORE

AFTER
Comment: "I wrenched the slab pipe open slightly" what, exactly, does this mean? I'm envisioning you taking a monkey wrench to a piece of copper pipe and twisting until you've created a leak, but I'm also pretty certain that this _isn't_ what you did...
Comment: @Freeman. Correct, there was a connector that bridged PVC to Copper, which was wrenched on.  It was critical that anything done during the evaluation phase could be "undone" to the extent possible.
Comment: I'd have gone with "screwed" instead of "wrenched", but that's probably just me...
Comment: Or maybe "loosened".


JRE 32bit vs 64bit

Question: I've been using Java for a while now, and my typical ritual of setting up a new dev machine requires the norm of downloading and installing the latest JDK from Oracle's site.
This prompted an unusual question today, does it matter if I use the 32bit or 64bit JRE bundle?
From thinking back on it, I've installed both versions before and my normal toolchain plugs happily in (Eclipse). In my day-to-day programming, I do not recall ever having to change something or think about something in a different way just because I was using the 64bit JRE (or targetting the 64bit JRE for that respect).
From my understanding of 64bit vs. 32bit - it really boils down to how the numbers are stored underneath the covers... and I do know that int is a 32 bits and long is 64 bits... same with float being 32 bits and double is 64 bits -- so is it just that Java has abstracted even this subtlety away, and perhaps has been "64 bit compatible" all along?
I'm sure I'm missing something here besides not being able to install a 64 bit JRE onto a 32 bit system.
Comment: With a 32-bit JVM you are limited to `-Xmx` < 4GB, but it on 64-bit the only limit is hardware/virtual memory.
Comment: @JimGarrison I think this is also further dependent on the OS too. On Windows with a 32bit JRE I think the max heap is somewhere < 2GB.
Comment: Windows is even more restricted: https://stackoverflow.com/questions/1434779/maximum-java-heap-size-of-a-32-bit-jvm-on-a-64-bit-os.
Comment: @wumpz: I think you're talking about 32-bit Windows, not 32-bit JVM on 64-bit Windows.  You definitely want to use a 64-bit OS if you have more than 2GB or so of physical RAM, because it makes the OS less efficient if it can't just map all the memory at once into kernel address space, and instead has to play tricks to map different pages when needed.
Answer: 64-bit vs. 32-bit really boils down to the size of object references, not the size of numbers.
In 32-bit mode, references are four bytes, allowing the JVM to uniquely address 2^32 bytes of memory. This is the reason 32-bit JVMs are limited to a maximum heap size of 4GB (in reality, the limit is smaller due to other JVM and OS overhead, and differs depending on the OS).
In 64-bit mode, references are (surprise) eight bytes, allowing the JVM to uniquely address 2^64 bytes of memory, which should be enough for anybody. JVM heap sizes (specified with -Xmx) in 64-bit mode can be huge.
But 64-bit mode comes with a cost: references are double the size, increasing memory consumption. This is why Oracle introduced "Compressed oops". With compressed oops enabled (which I believe is now the default), object references are shrunk to four bytes, with the caveat that the heap is limited to four billion objects (and 32GB Xmx). Compressed oops are not free: there is a small computational cost to achieve this big reduction in memory consumption.
As a personal preference, I always run the 64-bit JVM at home. The CPU is x64 capable, the OS is too, so I like the JVM to run in 64-bit mode as well.
Comment: Compressed oops have been the default since pretty much forever (well at least 5 years). On top of that, there are several "modes" of compressed oops, depending on the heap size range, so for the same size of heaps (~2GB or less) that you'd be able to use 32-bits, you don't pay much cost at all to use compressed oops (no scaling needed, the oops can be used directly with the high bits zero). So 64-bit is close to being strictly better.
Comment: Freshly started Netbeans with my set of projects uses 600MB on x32 Java8, same thing started on x64 JVM uses 1180MB - twice more. That's why me personal preference is - use x32 JVM unless memory usage goes roughly beyond -Xmx1200, this is the largest heap size JVM is able to allocated (with slight differrence depending on the host OS).
Comment: Actually it's slightly more than 1200 MB, could be up to like 3-3.5G http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#gc_heap_32bit
Answer: As you note, primitive numeric types in Java are well-defined.
However, the choice between 32-bit and 64-bit JVMs can matter if your Java application is using native-code libraries, which may be built for use in a 32-bit application, a 64-bit application, or both.
If you have native libraries that support only 32-bit applications, you either need to use a 32-bit JVM, or build 64-bit versions of the libraries.
Comment: as a rule of dumbs, develop with 32 bit JRE and run in 64 bit JRE?
Answer: Depending on context, for local development I will always use a 64-bit JDK.  Primarily because I would likely need the whole memory space for builds and the IDE.
That being said for integration to production, I would recommend 32-bit if it is possible.  Why?
For some Java EE servers that are licensed for production use, it would depend on some factors like which machine how many cores etc.  For WebSphere Liberty Profile specifically, you are also limited to 2GB.
64-bit JREs would take up slightly more memory and if you're trying to constrain it to something like 2GB or better yet 2x 1GB cluster you would have more flex space to work around in without paying a cent.
From https://plumbr.eu/blog/java/should-i-use-32-or-64-bit-jvm

Problem 1: 30-50% of more heap is required on 64-bit. Why so? Mainly
  because of the memory layout in 64-bit architecture. First of all –
  object headers are 12 bytes on 64-bit JVM. Secondly, object references
  can be either 4 bytes or 8 bytes, depending on JVM flags and the size
  of the heap. This definitely adds some overhead compared to the 8
  bytes on headers on 32-bit and 4 bytes on references. You can also dig
  into one of our earlier posts for more information about calculating
  the memory consumption of an object.
Problem 2: Longer garbage collection pauses. Building up more heap
  means there is more work to be done by GC while cleaning it up from
  unused objects. What it means in real life is that you have to be
  extra cautious when building heaps larger than 12-16GB. Without fine
  tuning and measuring you can easily introduce full GC pauses spanning
  several minutes. In applications where latency is not crucial and you
  can optimize for throughput only this might be OK, but on most cases
  this might become a showstopper.

To limit your impact for your Java EE environment, offload parts of it to other microservices such as ElasticSearch for search, Hazelcast for caching, your database for data storage and keep your Java EE server to host your application core itself rather than running the services inside it.
Answer: I think there are two main differences to consider. One has been mentioned here but not the other.
On the one hand, as other mentioned, the memory and data types. 32-bits and 64-bits JVMs use different native data type sizes and memory-address spaces.

64-bits JVMs can allocate (can use) more memory than the 32-bits ones.
64-bits use native datatypes with more capacity but occupy more space. Because that, the same Object may occupy more space too.
For JVMs which the Garbage Collector (GC) freezes the machine, the 64-bits versions may be slower because the GC must check bigger heaps/objects and it takes more time.
There is an IBM presentation explaining these differences.

And on the other hand, the supported native libraries. Java programs that use JNI to access native libraries require different versions depending on the type of JVM.

32-bits JVMs use 32-bits native libraries and 64-bits JVMs use 64bits libraries.
That means that, if your program uses libraries that rely on native code such as SWT, you will need different versions of them. Note in the SWT download page, there are different versions for Linux/Windows 32- and 64-bits. Note that there are different versions of Eclipse (each one with a different version of SWT) for 32- and 64-bits.
Some applications, such as Alloy, are packaged with 32-bits native libraries. They fail with 64-bit JVMs. You can solve these problems just downloading the corresponding 64-bits native libraries and configuring the JNI appropriately.
Comment: The Oracle JVM includes an option to use ["compressed oridinary object pointers"](https://wiki.openjdk.java.net/display/HotSpot/CompressedOops). Basically, the JVM can use 32-bit values as pointers to objects in memory instead of 64-bit values. You may check the `UseCompressedOops` flag.
Comment: x86-64 also has more registers than ia32, so the actual asm generated by a JIT compiler can be more efficient (fewer spills/reloads to/from memory).  It's also a more orthogonal compiler-target, since the low byte of all 16 registers is directly accessible.  I'm not sure if JIT has much use for RIP-relative addressing, but it does make position-independent code easier/more efficient than in 32-bit mode.
Comment: Are there any 64-bit JVMs that use the [x32 ABI](https://en.wikipedia.org/wiki/X32_ABI)?  (32-bit pointers in long mode?)  That would have all the advantages of both (small pointers -> smaller cache footprint for GC, while still doing 64-bit integer ops with a single instruction.)
Comment: Neat.  That's not quite as efficient as x32, where limiting all pointers to be in the low 32 bits of address space lets you use them by just zero-extending them.  Java goes for some extra overhead in "decoding" (left shift by 3 and add to heap base).  But fortunately an x86 addressing mode can do `[base + index*8]`, so it should be pretty efficient to dereference, and only take an extra instruction to compare with a non-encoded pointer.  And of course it costs extra when encoding.  Anyway, looks like a sensible tradeoff for Java, since they don't want to limit the heap to 4GB.
Comment: What do you mean by "native datatypes"? Do you mean Java data types like `int`, `long`, `char` and so on? Or are you referring to some native C++ code inside the JVM itself? The latter is mostly irrelevant since the vast majority of your memory use will usually be part of the Java heap whose data types mostly haven't changed sizes (with a caveat about references). Most important native data types (which, really) probably don't change sizes too: certainly if you're doing a lot of off-heap stuff or have native code you can choose to keep the data types the same size.
Comment: On top of that references are also going to be same size due to "compressed oops" which is the default, for any heap size where you can make a direct comparison. So 64-bit is pretty much strictly better. Sure, you might note that if you need greater than 32 GB heaps you'll have 64-bit references, but if you need that big of a heap 32-bits is out of consideration by definition, since it has a max heap size of ~2 GB.
Comment: Primitive data types (such as `int`, `long` or `char`) work mostly equal in both types of JVMs. Their size do not change. The size only changes for references. Operations on such types are atomic for any one with less than 32 bits. Some operations will be not atomic in 32-bit JVMs when the data is greater than 32 bits. However, these differences may be neglible.  -- Differences occur mainly in objects or libraries that interact with native libraries. -- for the size of primitive data types, you may check https://stackoverflow.com/questions/9511836/size-of-java-primitives-on-32-64-bit-jvm
Answer: Do I need to understand the difference between 32-bit JVM and 64-bit JVM?
If you aren't building a performance critical application, you don't have to understand the difference. The subtle difference between 32-bit JVM and 64-bit JVM wouldn't make much difference to your application. You can skip reading further
Does 64-bit JVM perform better than 32-bit JVM?
Most of us think 64-bit is bigger than 32-bit, thus 64-bit JVM performance will be better than 32-bit JVM performance. Unfortunately, it's not the case. 64-bit JVM can have a small performance degradation than 32-bit JVM. Below is the excerpt from Oracle JDK documentation regarding 64-bit JVM performance:
"Generally, the benefits of being able to address larger amounts of memory come with a small performance loss in 64-bit VMs versus running the same application on a 32-bit VM.
The performance difference comparing an application running on a 64-bit platform versus a 32-bit platform on SPARC is on the order of 10-20% degradation when you move to a 64-bit VM.  On AMD64 and EM64T platforms this difference ranges from 0-15% depending on the amount of pointer accessing your application performs."
Does 32 bit JVM or 64 bit JVM matter anymore.
What are the things to consider when migrating from 32-bit JVM to 64-bit JVM?
a. GC Pause times
The primary reason to migrate from 32-bit JVM to 64-bit JVM is to attain large heap size (i.e. -Xmx). When you increase heap size, automatically your GC pause times will start to go high, because now there is more garbage in the memory to clear up. You need to do proper GC tuning before doing the migration, otherwise your application can experience several seconds to few minutes pause time.
b. Native Library
If your application is using Java Native Interface (JNI) to access native libraries, then you need to upgrade the native libraries as well. Because 32-bit JVM can use only 32-bit native library. Similarly, 64-bit JVM can use only 64-bit native library.
Comment: dup http://www.javaprogrammingforums.com/java-programming-tutorials/42036-subtle-differences-between-32-bit-jvm-64-bit-jvm.html
Comment: x86 32 vs. 64-bit is special because 64-bit mode has twice as many integer and FP registers for the JIT compiler to use.  For other ISAs (like SPARC), that's not the case: 32-bit SPARC already had enough registers so it's *just* wider pointers, and 64-bit integers with a single register / single instruction.  So outside of x86, the only benefit is for code that uses 64-bit integers, or code that needs more than 4GB of memory.  But it's a much less obvious tradeoff on x86, where larger pointers still hurt (cache footprint / mem bandwidth) but more registers for more efficient code helps.
Comment: @BhargavRao: What was the point of removing a mention of a specific tool (GCeasy) from this answer?  Was this flagged as spam / self-promotion?  Your change didn't have an edit message and it looked like a sensible suggestion.
Comment: @PeterCordes, Your guess is correct. I've sent a note to the poster, they can edit it in once they provide self-attribution.

JRE 32bit vs 64bit


Create list from input using interact in Haskell

Question: I'm starting out with Haskell and was looking into I/O mechanims. I read up on the interact function which takes a function of type String -> String as parameter. I tried to write a simple program that takes to numbers from stdin and creates a list and prints it line by line.
import Data.List

readIn = sort . map read . words
writeOut = unlines . map show
rangeList [n,m] = [n .. m]
main = interact (writeOut . rangeList . readIn)

For some reason it wont print the numbers. Could you help me out?
Comment: Quick comment: since `rangeList` always has exactly two values as input, it's probably better to use a 2-tuple `(n,m)` rather than a list, since a list should be able to have any number of values. As for the rest of the program, it looks absolutely fine at first glance; I'll try running it now and see if I can get it to work.
Answer: interact requires you to input an end-of-file (EOF) to stdin with Ctrl+D (or Ctrl+Z on Windows); when I type that combination, the output appears as required. This is necessary because, as the documentation for interact states, 'the entire input from the standard input device is passed to [interact] as its argument'; due to this, you need to explicitly signal the place where stdin ends.
(By the way, I'm not even sure how you got your program to compile; GHC gives me lots of 'ambiguous type' errors when I try. I had to add type signatures to get it working, at which point I found the solution above to work.)


Question on Rudin 10.5

Question:

I don't understand what does it mean that "A primitive mapping is thus one that changes at most once coordinate" ( what do we mean in darkened $x$ in the $10.5$ ? is it the set of all points $x$ $\in$ $E$ where $g(x)$ $\neq$ $0$ ? )
Hence, I don't understand from where does  the $(10)$ inequality come.
$G(x) = x + [g(x) - x_m]e_m$.
Any help would be appreciated.
Answer: The notation $\mathbf x$ stands for a vector in $\Bbb R^n$. Suppose, say, that $n=4$ and that $m=3$. Then$$G(x_1,x_2,x_3,x_4)=\bigl(x_1,x_2,g(x_3),x_4\bigr).$$So, only the third coordinate of $(x_1,x_2,x_3,x_4)$ is changed. And then$$G(x_1,x_2,x_3,x_4)=(x_1,x_2,x_3,x_4)+\bigl(0,0,g(x_3)-x_3,0\bigr).$$
Comment: Rudin is saying that there is a function $g\colon\Bbb R\longrightarrow\Bbb R$ such that$$\bigl(\forall(x_1,x_2,x_3,x_4)\in\Bbb R^4\bigr):G(x_1,x_2,x_3,x_4)=\bigl(x_1,x_2,g(x_3),x_4\bigr).$$So, $G$ leaves the first, second and fourth coordinates unchanged and only changes (eventually) the third coordinate.
Comment: For instance (taking again my previous assumption that $n=4$ and that $m=4$), the second component of $G(x_1,x_2,x_3,x_4)$ is just $x_2$. The partial derivative of this with respect to $x_1$, $x_3$ and $x_4$ is $0$, whereas its partial derivative of this with respect to $x_2$ is $1$.
Comment: $$G(x_1,x_2,x_3,x_4)=\bigl(x_1,x_2,g(x_3),x_4\bigr).$$ can you explain this line more explicitly?
Comment: What has your second comment to do with your question?
Comment: it's part of $10.5$
Comment: I know. But it is **not** part of your question.
Comment: I know but I forgot it to ask in the question. so I would be grateful if you will answer on this question too
Answer: You should understand that i$\neq m $ doesn't mean that i $\lt m $

Question on Rudin 10.5


Disabling notifications for the sender using apex toolkit

Question: I'd like to disable all sender notifications while using the apex toolkit. I disabled the notifications in the DocuSign account by unchecking all of the boxes, however, the sender is still receiving the notifications. I am assuming I need to add code to the apex class in order to disable these notifications. I don't see anything here (https://developers.docusign.com/docs/salesforce/apex-toolkit-reference/notifications.html) to help me with that, but I'm no developer so I could be overlooking it.
Answer: You can't control another users notifications, only they can control the notifications that they're receiving by going into their settings and changing it there. If a user joins your account, they'll automatically inherit the notifications set at the account level, but it won't affect existing users.


Detect Excel File Format Type via VBA

Question: I'm trying to import an xlsx worksheet into an xls workbook and ran into an error regarding the number of rows is greater in the xlsx then the xls. I'd like to add a check to the beginning of my macro which detects in the open workbook is xls and then saves as xlsx and re-opens with new format.
I am fairly certain I can do this via checking the "file extension", but I'd feel better utilizing some sort of function built into Excel/VBA which can detect if a file is "Excel 97-2003" style workbook as users can simply change a file extension without changing file type. Is there a way to programmatically check what type of workbook is currently open? ActiveWorkbook.
I don't have any code to share as all I can find is related to checking if file is open, or checking file extension etc etc. Perhaps my google-fu is off today, but I am not getting anything related in my searches so I have tried nothing.
Comment: e,g,: `If ActiveWorkbook.Worksheets(1).Columns.Count = 256 Then`: An `.xls` file has only 256 columns.
Comment: @VBasic2008 thats only a step above checking file extension, I was hoping to find a function built for this exact purpose which "BigBen" has shown in his answer.
Answer: I'd use the Workbook.FileFormat property:

Returns the file format and/or type of the workbook. Read-only XlFileFormat

If ActiveWorkbook.FileFormat = xlExcel8 Then
   ActiveWorkbook.SaveAs fileFormat:=xlOpenXMLWorkbook
End If

Detect Excel File Format Type via VBA