How do I build HUGE constructions in Minecraft?

Question: If I want to build a really, really huge structure in Minecraft, say, a castle with towers, walls, several floors and over a thousand of squaremeters/tiles per floor, what is the way to go?
How can I effectively accomplish the task without running, climbing etc. around a lot, trying to get up to a wall in order to reach somewhere etc.? Give general ideas and don't focus on my example (the castle) too much. What is a good way to plan such structures before starting to build them?
Comment: possible duplicate of [What tools do you use to help you build structures?](http://gaming.stackexchange.com/questions/10910/what-tools-do-you-use-to-help-you-build-structures)
Answer: Rule number one when taking on a big project: Don't do it alone! Recruit some friends to help you out.
You can use a pixel based editor (Photoshop, Paint, etc.) to plan your constructions out. Each pixel can be one block and then you just design what you want.
I don't know of any off the top of my head but scripts can help if you plan to do vrey repetitive actions. Stuff like backing up while placing blocks to create a wall. I'm sure there are macros that would let you capture keyboard/mouse commands which you can use to build your structures.
Comment: I have to slightly disagree here.  I think the #1 rule is plan ahead.  Without a good clear plan, adding more help can result in chaos.
Comment: Not saying it's the first thing you should do, just that it's my first rule when tackling something big. :)
Answer: Copy and Paste. You'll probably want to design the unique elements somewhere (in-game or in an image editing tool), then build them once in-game and copy and paste them in-game using a mod to create the large structures you're looking for.
WorldEdit has copy/paste support but loading it in Single Player requires some careful modifications. It's a bit easier to install if you're working on an SMP server.
For designing your project... Minecraft is really best. Be prepared to build a lot of temporary stairs to stand on as you test out designs. Or install a flying mod.
Answer: I would highly recommend the WorldEdit feature.
You could also use the TooManyItems mod for an in game inventory editor and you could install zombe's modpack for the flying ability.
Looking up a few tutorials can't hurt either. Check YouTube.
You can use Paint or Photoshop or indeed any image manipulation program for planning and you could ask a few friends for faster construction.
But in my opinion, MCEdit is the top of the hill when it comes to building giant structures.
Answer: Although most people recommended the use of either 3rd party tools or creative mode, if all you are going to do is a stone castle, then you can do a rig similar to this one:
<code> M *W
 *  *

(height of wall)

XX XX    * - blocks
XXXXX    X - ground
</code>
This is a cross-section of a rig that enables "fast and effortless"1 construction of pure stone walls.
Essentially, you place a magma source (from a bucket) in a high stand (height of your wall), surrounded on the side you don't want magma to flow by non-flammable material. The magma will flow 4 blocks sideways and afterwards will fall down. As soon as the magma curtain is formed, you can then pour water on the sides of the wall. As water flows faster than magma, the wall will be formed as soon as water reaches the ground.
You can then reuse the magma and water. This single rig can make walls with about 9 blocks width. You can combine more to make bigger walls. This is very useful if building in height as you don't need to process or place the stone blocks. This can't do the castle's floors, however.
1 - If you consider fast and effortless picking up a bucket of lava and another for water and then building a scaffold, which you would also need to build regardless.
2 - I've done this in head only, relying on physics that might have changed since the last time I played the game.
Answer: I'm assuming you are doing the building in survival mode, and don't have access to creative mode flight...

How can I effectively accomplish the task without running, climbing etc. around a lot, trying to get up to a wall in order to reach somewhere etc.?

Ender pearls! They take some time to get used to, and some practice using them properly, but once you have used them for a while, you will wonder how you survived without them. All you do is right-click with an Ender-pearl in your hand, and you will be instantly teleported to where the pearl landed, which is great for getting up to the second floor of a building or similar without needing to build a temporary stair-case to get up there.
Ender pearls are quite rare in the overworld, so I would recommend getting to The End and setting up at least a small, simple Enderman farm there.
Sand Pillars! When that is not an option, and you need to pillar up to high places, I would recommend towering up using sand. Then, when you no longer need your temporary tower, you quickly replace the bottom block with a torch (or use something like this), and the entire sand tower is removed without you needing to waste time and tool durability mining/digging away the temporary tower.
Answer: The best laid plans O' Mice An' Men...are the ones that will probably be finished.
Assuming you want to do this in Vanilla, without any Mod help or copy/paste, here's how to go about building something enormous.
Calculate
Before you even get started, you need to calculate how much material you're going to use to build it, and how much space.  If you're willing, you can open up a SuperFlat Creative world in order to get a good idea of how big your structure should be.  This is where your grade-school math skills will come in handy for figuring out how many blocks it will take to complete your structure.  Keep in mind the type of material you want to use, and use the width, length, and height of your structure to get a general idea of how much you'll need (always overestimate - it's better to go in with more than you need than it is to have less).
Harvest Resources
It's going to take a lot of resources to build this super structure, and unless you're using creative cheats, that means a lot of time gathering up things before you even begin.  If your structure is primarily made of wood, find out what type of wood you want to use and build a tree farm.  I like to lay down sand and patches of dirt to help space the trees out, but this isn't entirely necessary.
If you're building out of stone, find a hill and dig down dig down into the earth as deep as you can.  You may want to start a branch mine just to gather rare minerals while you're mining for stone anyway, and to build a rail system to transport the raw materials back up to the surface.
Either one of these farming tasks should take place near where you're going to eventually build your structure.  Which leads to, assuming you haven't already chosen...
Scout a Location
Location is absolutely key for any major construction, and you're going to want to pick a good one first.  You may already have a location in mind, in which case you can skip right past this step.
A good location should be near something important - a coastal area, or a river crossing, somewhere that will be memorable, since you're going to be spending so much time working on it, it'd be a shame if it were up on top of a mountain where no one will ever go (though leveling the top of a mountain for your castle WOULD be impressive...)
Flatness is imperative, but if you haven't got a flat surface, you can always make one.  TNT can help, but you'll eventually have to switch to basic shovels and picks.  Put some efficiency or unbreakable enchantments on them to make the job more bearable.
Build!
If you've done the previous steps correctly, you should have more resources than you need to complete the project.  Resource exhaustion can be one of the most frustrating parts of crafting a megastructure, which is why most of the prep here is not in planning out the shape, but in making sure you've got enough.  By preventing yourself from getting into a position where you'll have to keep going back underground for more and more resources, you avoid getting burnt out, and can construct your new fancy megabuilding to your heart's content.
Answer: Creative mode can be a major boon for this if you just want to build. Flying helps with tall structures.
Otherwise, I suggest doing it in multiplayer, since you'll probably want some people restocking supplies while others use them up.
Answer: Creative mode is a good idea because you will have unlimited resources to use plus the ability to fly.
This sounds like just what you need for this kind of tall and complicated project.
Answer: use blocks that stands out to mark things on the ground and use dirt block to build stairs to get to the top of the building such as a flag. Also use wood or block that can be easily destory to build the frame of the building.
Answer: Use the /fill cheat.
This helps create large planes or cubes of blocks using coordinates and Minecraft IDs. Usage:

/fill (X1) (Y1) (Z1) (X2) (Y2) (Z2) minecraft: (the item you want it built out of)

Have fun!
Edit: Use the Minecraft id "minecraft:air" to clear out an area, to "erase" the land.


The same Web API Code works on Windows 10 but not on Linux Debian Buster

Question: In the screenshot below, i have my Web API running with .NET5.0 on Windows 10 (left) and the same Web API running with .NET(core?)5.0 on Linux Debian Buster (right) (WSL2).

As you can see, on Windows it maps the controllers correctly, but not on Linux. I'm showing the Swagger page to be more explicit, but if I access the routes manually, the behaviour is the same.
Does anyone know what could be and how to solve this problem? I have to make it work on Linux because my deployment target is a debian based server.
Below are some code that may be useful (Startup.cs and a Controller declaration)
Startup.cs
<code>    public void ConfigureServices(IServiceCollection services)
    {

        services.AddControllers();
        services.AddDbContext<Core.Contexts.ComiesContext>(o => {o.UseSqlServer("name=LocalComiesDBConn"); o.ConfigureWarnings(p => p. Ignore(30000));});
        services.AddSwaggerGen(c => c.SwaggerDoc("v1", new OpenApiInfo { Title = "comies_services", Version = "v1" }));
        services.AddIdentity<ApplicationUser, IdentityRole>()
            .AddEntityFrameworkStores<Core.Contexts.ComiesContext>()
            .AddDefaultTokenProviders();

        var signingConfigurations = new Structures.ModelsConfigurations.SigningConfigurations(Configuration["TokenConfigurations:securityKey"]);
        services.AddSingleton(signingConfigurations);

        var tokenConfigurations = new AuthenticationConfiguration();
        new ConfigureFromConfigurationOptions<AuthenticationConfiguration>(Configuration.GetSection("TokenConfigurations")).Configure(tokenConfigurations);
        services.AddSingleton(tokenConfigurations);

        services.AddAuthentication(authOptions =>
        {
            authOptions.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
            authOptions.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;

        }).AddJwtBearer(jwtBearerOptions =>
        {
            var paramsValidation = jwtBearerOptions.TokenValidationParameters;

            paramsValidation.IssuerSigningKey = signingConfigurations.Key;
            paramsValidation.ValidAudience = tokenConfigurations.Audience;
            paramsValidation.ValidIssuer = tokenConfigurations.Issuer;

            paramsValidation.ValidateIssuerSigningKey = true;

            paramsValidation.ValidateLifetime = true;

            paramsValidation.ClockSkew = TimeSpan.Zero;
        });

        // Ativa o uso do token como forma de autorizar o acesso
        // a recursos deste projeto
        services.AddAuthorization(auth =>
        {

            auth.AddPolicy("Bearer", new AuthorizationPolicyBuilder()
                .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
                .RequireAuthenticatedUser().Build());
        });

        services.AddScoped<AuthenticatedOperator>();
        services.AddScoped<AuthenticationService>();
        services.AddTransient<UserManager<ApplicationUser>>();
        services.AddTransient<SignInManager<ApplicationUser>>();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseSwagger();
            app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "comies_services v1"));
        }

        app.UseHttpsRedirection();

        app.UseRouting();

        app.UseAuthorization();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
        });
    }
</code>
AuthController.cs
<code>[Route("api/v1/auth")]
[ApiController]
public class AuthenticationController : ControllerBase
{
    private readonly ComiesContext _context;

    private readonly AuthenticationService _authenticationService;

    public AuthenticationController(ComiesContext context, AuthenticationService authenticationService)
    {
        _context = context; _authenticationService = authenticationService;
    }

    // GET: api/<AuthenticationController>
    [HttpGet("register/template")]
    public async Task<ActionResult<Store>> Get()
    {
        ///hidden implementation, but trust me, this endpoint is working (when it's mapped)
    }
</code>
Comment: I have same behaviour with one project. How did you solve the problem?
Answer: I've made a sample project with the controller you posted, but I cannot reproduce the behavior. It is working, no problem there.
Try check the Swagger version, it should be above 5.6.3
<code>   <PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</code>
Comment: It is. The problem is not Swagger actually, I just showed it for y'all to see how the controllers are (or are not) mapped. But if I navigate to the route itself, it returns 404 as well, to all of em
Comment: May be it is connected with https? Try to setup https like here https://thegreenerman.medium.com/set-up-https-on-local-with-net-core-and-docker-7a41f030fc76
Answer: I encountered a similar issue and managed to find a solution that worked for me (although it may not be applicable to everyone). In my case, I had a folder named "API" with mixed casing (some letters in uppercase and some in lowercase), along with another folder named "Api" in all lowercase. Due to the case-insensitive nature of Windows, the folders were merged, and any .cs files within them were discovered. However, when I tried the same on Linux, the files were not detected. The root cause of this problem lies in the fact that Git for Windows, as well as the Windows operating system itself, are not case-sensitive, whereas Linux is. To resolve this issue, I recommend carefully examining the folder names and ensuring that the casing is consistent.


How to set up Grunt to exclude unused Bower libraries

Question: I have a grunt/bower/angular project that included dependencies such as angularjs.
When bower installs the angularjs dependency, or any other dependency, it pulls more than I want to include in my build.
For example, when bower installs angularjs, the bower_components directory contains angular.js and angular.min.js.  I only want to use one of the two scripts.
Could I set up Grunt to build my project and only include the libraries and resources I want from bower_components?  If yes and it involves specifying the libraries in the Gruntfile.js, is there an advantage of using Bower in this case?
Answer: Yes, you can use grunt-bower to do this job. you can specify which files you want to import for a specific package.
Here is a complete example with Fancybox package :
<code>bower: {
    dest:       'source/assets/images',
    js_dest:    'source/assets/js',
    css_dest:   'source/assets/css',
    fonts_dest: 'source/assets/fonts',
    options:    {
        expand:                false,
        keepExpandedHierarchy: false,
        packageSpecific:       {
            'fancybox': {
                files: [
                    'source/blank.gif',
                    'source/fancybox_loading.gif',
                    'firstname.lastname@example.com',
                    'source/fancybox_overlay.png',
                    'source/fancybox_sprite.png',
                    'email@example.com',
                    'source/jquery.fancybox.js',
                    'source/jquery.fancybox.css',
                    'source/helpers/jquery.fancybox-thumbs.css',
                    'source/helpers/jquery.fancybox-thumbs.js'
                ]
            }
        }
    }
}
</code>


Moisture in the bathroom is bubbling lead paint - how do I seal it?

Question: I live in a home built in the 1930s. The bathroom has been poorly remodeled at least twice. At the last remodel, before I moved in, the work wasn't finished. Within the shower everything is fine, but the paint on the arched wall on the shower/tub's exterior, which was left exposed at the last remodel, is bubbling away because of moisture. I've recently tested this area and found that it has traces of lead.

I am looking for a solution to seal the exposed section of wall without disturbing the lead paint. I don't have a true HEPA shopvac, which I feel prevents me from dealing with the lead paint and taking this wall down to the surface and starting from scratch. I won't be living in this home more than another year and I don't have a lot of experience doing DIY work. Would using a sealer like Zinsser Gardz work? The aesthetics of the fix don't matter - my only concern is preventing further disturbance or pulverization of the lead paint.
There is a section of this wall that is covered in broken plaster. Would finishing up the wall with some type of plaster repair compound do the trick?

I'm looking for solutions that I could implement myself. If this isn't possible and this is a problem a professional should tackle, I will take that under consideration.
Answer: I was researching exactly the same thing and came across a few products that does not require you to scrape the paint off.
EcoBond - you paint the surface and it will react with the lead.


Yellow line showing under import module statements

Question: I see this is a problem, but the program still runs. Where is the problem?

I can't solve this on my own even if I search it online. I need a pointer to where I can solve this problem.
Comment: What does it say on the `Problems` tab down near the bottom?
Comment: app.models.Cart.DoesNotExist: Cart matching query does not exist.
Comment: May or may not apply in this case: *[Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/)* (e.g., *"Images should only be used to illustrate problems that* ***can't be made clear in any other way,*** *such as to provide screenshots of a user interface."*).
Comment: At the very least it shouldn't be a dump of the entire (maximised) window (most is irrelevant).
Comment: https://github.com/microsoft/pylance-release/issues/2874 check answer here, select interpreter in easy words search for python.exe file in environment folder ex: activate\Scripts\python.exe
Answer: Those yellow lines means that the imported modules cannot be located.
This probably means that you downloaded the modules into a virtual environment and the modules are not installed globally. You are probably running the script with the correct virtual environment. Open your Command Palette with Ctrl + Shift + P and choose the correct Python interpreter.
Answer: For me, modules who have a yellow line under them are ones that your program doesn't need.  If I import a module that my program doesn't need functions from, a yellow line will show under it.
To fix this issue, hover over the statement with the yellow line under it, then click on Fix Issue.  A list will appear, with the first item probably being Remove unused import statements.
If, however, the list item says something like Select Python interpreter, then this answer would fix your problem.
Answer: probably solved, similar thing happened to me and I posted about it.. take a look at this post:  https://stackoverflow.com/a/76335963/19489427
hopefully it helps someone else
Answer: change your python interpreter from 3.10 global to 3.11. This worked for me and maybe works for you as well. To change interpreter ctrl+shift+p write python interpreter and change it accordingly.
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).


How to find geometrical figures areas?

Question: Find the area of the region that lies inside the circle $r = 1$
and outside the cardioid $r=1-cos\alpha$
We know that area can not be negative value(at least basic calculus).
I wonder where I made a mistake,I tried to show equations.
$$ 1=1-cos\alpha $$
$$\alpha = \pi/2,3\pi/2$$
\begin{equation}
\frac{1}{2}\int_{3\pi/2}^{\pi/2}f(x)^2d\alpha
\end{equation}
\begin{equation}
\frac{1}{2}(\int_{\pi/2}^{3\pi/2}1^2d\alpha-\int_{\pi/2}^{3\pi/2}(1-cos\alpha)^2d\alpha)
\end{equation}
$$ \int_{3\pi/2}^{\pi/2}1^2d\alpha = $$
$$ \frac{3\pi}{2} -\frac{\pi}{2}=\pi $$
$$ \int_{\pi/2}^{3\pi/2}(1-cos\alpha)^2d\alpha = $$
$$ 9\pi/2 - 3\pi/2 + 2 - (-2) + 0 - 0 $$
$$ 2\frac{1}{2}(\pi - 3\pi - 4)$$
$$ Answer: (-2\pi-4) $$
symmterical no required multiple by 2.
Comment: Your title has no mathematical content. Please write a title which expresses the mathematical content of your question. Take a look [here](https://math.meta.stackexchange.com/questions/9959/how-to-ask-a-good-question#10144) for guidelines on titles.
Comment: It's really hard to follow what you're doing.  Please try to organize this a little better.  Also  $\int_{\pi/2}^{3\pi/2}(1-cos\alpha)^2dx$ should be $\int_{\pi/2}^{3\pi/2}(1-cos\alpha)^2\color{red}{d\alpha}$
Comment: maybe give me clue a little bit.
Comment: @saulspatz ı did
Comment: If you just want to know if you did the integral correctly, you can type it in [WolframAlpha](https://www.wolframalpha.com/input/?i=&t=crmtb01)
Answer: You're mixing up polar and rectangular coordinates, your $dx$ should be $d\alpha$. But also the subtraction should be the other way around.
Finally, fix the computations.
You want to find the of the semicircle and subtract the area of the cardioid for $-\pi/2\le\theta\le\pi/2$. So you need
\begin{align}
\int_{-\pi/2}^{\pi/2}\frac{1^2}{2}\,d\alpha-\int_{-\pi/2}^{\pi/2}\frac{(1-\cos\alpha)^2}{2}\,d\alpha
&=\int_{-\pi/2}^{\pi/2}\frac{1-(1-\cos\alpha)^2}{2}\,d\alpha\\
&=\int_{-\pi/2}^{\pi/2}\frac{2\cos\alpha-\cos^2\alpha}{2}\,d\alpha
\end{align}
which is essentially elementary; an antiderivative is
$$
\sin\alpha-\dfrac{1}{4}(\alpha+\sin\alpha\cos\alpha)
$$
so you get
$$
\Bigl(1-\frac{\pi}{8}\Bigr)-\Bigl(-1+\frac{\pi}{8}\Bigr)=2-\frac{\pi}{4}
$$
Comment: Did you multiply 2 the final value?
Comment: @01dAI Why? You'd do it if you compute the integral from $\pi/2$ to $\pi$, which is possible because of the symmetry.
Comment: circle inside cardioid outside  [link]https://prnt.sc/swp3a8
Comment: @01dAI Oh, I misread. Fixed.
Answer:
if you look at the picture you  are asked to calculate have half a circle + the 2 times the area of the cardioid from 0 to pi/2, not  what you did! your calculation is right you subtracted the big left part of the cardiode from half the circle , no wonder it is negative.
Comment: [link]https://prnt.sc/swp3a8

How to find geometrical figures areas?


jquery .load dynamic image

Question: Is there any way I can use the .load event(or any other jquery event) with a dynamic image such as this
Whenever I try to use the .load or .get method to reload that page into the document it just come out as ��������  in Firefox and �PNG  in internet explorer.
What am I missing here? What would be the best way to do this?
Overall what I'm trying to accomplish here is to reload the captcha.php file into a div when a link is clicked and have a different captcha image be shown without refreshing the page.
The problem can be found here
http://www.seewhosoutthere.com/createAccount
clicking on the little blue "refresh" button next to the captcha will give the result I'm talking about.
The code currently being used for that page is
$('a#refresh').click(function(){
    $('#captcha').load('captcha.php');
});

Comment: There's probably an encoding issue (wrong character set being used somewhere). Can you post the full HTML, etc.? Or a link. Does the PHP file work independently?
Comment: its working for me , is it on some browser??
Comment: So are you asking how to reload different captcha images without a full page reload?
Comment: I edited my main post to show a page where the problem exists. I threw back up the captcha so you all can see.
Answer: Instead of .load() (which isn't intended for binary data...which is why you get those fun symbols with the encoding) you just need to create an  element with the right src and put it where you want in the document, for example:
$("", { src:"http://www.seewhosoutthere.com/captcha"}).appendTo("#myDiv");

You can test it out here.
Comment: @Ryan - if you want to load a new one you need to put a cache breaker on the URL, like this: http://jsfiddle.net/nick_craver/hQ8y2/2/
Comment: Hey nick, the problem with that is then it adds another captcha image(with the same security) to the same div so there are multiple images.
Comment: @Ryan - Oh if you want to replace it, just do `$('#myDiv').html($("", { src:"http://www.seewhosoutthere.com/captcha"}));`, or call `$('#myDiv').empty()` before...whichever :)
Comment: But that still only loads the identical captcha image, the image is not refreshed with a new code.
Comment: interesting. I've never heard of a thing like that. I'll have to do some research on that. Thanks much sir, that solved my problem.

jquery .load dynamic image


Close the all Activity of Current Application and launch Play store

Question: Is it possible to start an implicit activity on the stack, by clearing the entire history before it?
I am creating an application which have a concept of force upgrade from playsotre.
therefore I want to open play store at some moment and same moment I also want to close my application basically I want clear all activity of my Application after opening play store, but it didn't work.
My code snip:
btnForceUpdate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent goToMarket = new Intent(Intent.ACTION_VIEW)
                        .setData(Uri.parse("market://details?id=" + context.getPackageName()));
                goToMarket.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK); // clearing all activity task (Basically close the app)
                mDialog.cancel();
                context.startActivity(goToMarket);
            }
        });

I am using below flag in intent object but it didnt work
goToMarket.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK); // clearing all activity task (Basically close the app)

Comment: try {
            final Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName()));
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            finishAffinity();
            startActivity(i);
        } catch (final android.content.ActivityNotFoundException ex) {
            ex.printStackTrace();
        }
Comment: can you tell me what happen currently i think it will start google play store but not clear current activity
Comment: @PankajAndroid , Yes are right it open play store but did not clearing my application activity stack
Comment: how about new task flag and finishaffinity_
Comment: @DhinakaranThennarasu Same behavior with `finishAffinity()`
Comment: @LavekushAgrawal can  you tell me your first activity(last activity which is in current statck) so i can help you
Comment: @PankajAndroid thanks for your quick responce, First Activity is LoginActivity and last Activity is Dynamic so we can not relay on last Activity statically.
Comment: Calling finish affinity before startActivity works for me. just wondering .
Comment: @LavekushAgrawal see my answer: make one new activity and start that activity and before start closeactivity you need to finish that activity and clear stack. now close activity is only in stack and when you start google play you need to finish close acitivity this will close whole app
Comment: @DhinakaranThennarasu `finishAffinity` is working on api level 15+ thank you.
Comment: @LavekushAgrawal working or not ??
Answer:   try {

        final Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName()));
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        finishAffinity();
        startActivity(i); //

   } catch (final android.content.ActivityNotFoundException ex) {
        ex.printStackTrace();
    }

Or if you want it to work in previous versions(< 15 API) of Android:
ActivityCompat.finishAffinity(this);

Answer: You need to make one activity with start google play like below
public class CloseActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_settings);

    final String appPackageName = getPackageName();
    try {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
        finish();
    } catch (android.content.ActivityNotFoundException anfe) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
        finish();
    }
}

}
Need to start this activity from class with below code:
Intent mIntent = new Intent(CurrentActivity.this,CloseActivity.class);
mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(mIntent);
finish();

Comment: This could be a solution but i do not aware which will be become the CurrentActivity in future.
Comment: CurrentActivity is the activity from right now you are starting Google play application. you need to make one single activity which i have mention with xml now you need to start that activity and it will start google play and close you application
Comment: Tell me your activity name from where you are starting this intent goToMarket= new Intent(Intent.ACTION_VIEW)
                        .setData(Uri.parse("market://details?id=" + context.getPackageName()));


How close does the pressure switch need to be to the tank

Question: We recently had a well installed (350 ft.) The pressure switch is set directly above the pump and the tank 2*3 feet from the switch. We wanted the tank behind the house, so we moved it.
It is approximately 8-10 feet from the switch. The water ran fine while we were checking the plumbing that was installed. When we tried to run the dirt and sediment from the well, the pump ran for a few minutes then quit pumping. The pressure switch could be heard clicking but no water would come. The well guy came out and said there was water pressure but the tank is too far from the pressure switch and we have to move it back. He says it can't be more than 4 feet from the switch.
Is this true and can we do something else besides moving the tank back?
Comment: It appears that you have your answer...you just don't like it.
Comment: Moving the switch creates no problems. A need to change the wiring, but that should not be a problem - it's just a logical consequence of moving the tank.
Comment: You could pay another well-drilling company to come out and verify the first company's statement, or... you could lump it. :( (Warning: Not a well expert:) Of course, you could move the switch closer to the tank's new location, but that could create other problems.
Answer: If the tank is too far from the switch, the pump fires up, the pressure at the switch rises, the pump shuts off, the pressure drops, the pump switches on... that's why it was clicking.
Options:

Relocate the switch; mine is 300 feet from the pump - it does not need to be near the pump. It needs to be near the tank. This is the obvious and most correct solution.
Put another pressure tank near the switch and leave the one behind the house - the tank there will provide some buffer to allow time to put pressure into the house tank as well, as opposed to the thrashing you experienced with no tank near the switch. More pressure tank capacity is pretty much always a good thing for a well system.


What's the difference between Instant and LocalDateTime?

Question: I know that:

Instant is rather a "technical" timestamp representation (nanoseconds) for computing.
LocalDateTime is rather date/clock representation including time-zones for humans.

Still in the end IMO both can be taken as types for most application use cases. As an example: currently, I am running a batch job where I need to calculate the next run based on dates and I am struggling to find pros/cons between these two types (apart from the nanosecond precision advantage of Instant and the time-zone part of LocalDateTime).
Can you name some application examples where only Instant or LocalDateTime should be used?
Edit: Beware of misread documentations for LocalDateTime regarding precision and time-zone.
Comment: **Incorrect** definition. `LocalDateTime` does *not* have a time zone!
Comment: Instant is more elementary, wrapping the standard long for the UTC. For a cron like batch not so logical a choice.
Answer:
tl;dr
Instant and LocalDateTime are two entirely different animals: One represents a moment, the other does not.

Instant represents a moment, a specific point in the timeline.
LocalDateTime represents a date and a time-of-day. But lacking a time zone or offset-from-UTC, this class cannot represent a moment. It represents potential moments along a range of about 26 to 27 hours, the range of all time zones around the globe. A LocalDateTime value is inherently ambiguous.

Incorrect Presumption

LocalDateTime is rather date/clock representation including time-zones for humans.

Your statement is incorrect: A LocalDateTime has no time zone. Having no time zone is the entire point of that class.
To quote that class' doc:

This class does not store or represent a time-zone. Instead, it is a description of the date, as used for birthdays, combined with the local time as seen on a wall clock. It cannot represent an instant on the time-line without additional information such as an offset or time-zone.

So Local… means "not zoned, no offset".
Instant

An Instant is a moment on the timeline in UTC, a count of nanoseconds since the epoch of the first moment of 1970 UTC (basically, see class doc for nitty-gritty details). Since most of your business logic, data storage, and data exchange should be in UTC, this is a handy class to be used often.
Instant instant = Instant.now() ;  // Capture the current moment in UTC.

OffsetDateTime

The class OffsetDateTime class represents a moment as a date and time with a context of some number of hours-minutes-seconds ahead of, or behind, UTC. The amount of offset, the number of hours-minutes-seconds, is represented by the ZoneOffset class.
If the number of hours-minutes-seconds is zero, an OffsetDateTime represents a moment in UTC the same as an Instant.
ZoneOffset

The ZoneOffset class represents an offset-from-UTC, a number of hours-minutes-seconds ahead of UTC or behind UTC.
A ZoneOffset is merely a number of hours-minutes-seconds, nothing more. A zone is much more, having a name and a history of changes to offset. So using a zone is always preferable to using a mere offset.
ZoneId

A time zone is represented by the ZoneId class.
A new day dawns earlier in Paris than in Montréal, for example. So we need to move the clock's hands to better reflect noon (when the Sun is directly overhead) for a given region. The further away eastward/westward from the UTC line in west Europe/Africa the larger the offset.
A time zone is a set of rules for handling adjustments and anomalies as practiced by a local community or region. The most common anomaly is the all-too-popular lunacy known as Daylight Saving Time (DST).
A time zone has the history of past rules, present rules, and rules confirmed for the near future.
These rules change more often than you might expect. Be sure to keep your date-time library's rules, usually a copy of the 'tz' database, up to date. Keeping up-to-date is easier than ever now in Java 8 with Oracle releasing a Timezone Updater Tool.
Specify a proper time zone name in the format of Continent/Region, such as America/Montreal, Africa/Casablanca, or Pacific/Auckland. Never use the 2-4 letter abbreviation such as EST or IST as they are not true time zones, not standardized, and not even unique(!).

Time Zone = Offset + Rules of Adjustments

ZoneId z = ZoneId.of( "Africa/Tunis" ) ;

ZonedDateTime

Think of ZonedDateTime conceptually as an Instant with an assigned ZoneId.

ZonedDateTime = ( Instant + ZoneId )

To capture the current moment as seen in the wall-clock time used by the people of a particular region (a time zone):
ZonedDateTime zdt = ZonedDateTime.now( z ) ;  // Pass a `ZoneId` object such as `ZoneId.of( "Europe/Paris" )`.

Nearly all of your backend, database, business logic, data persistence, data exchange should all be in UTC. But for presentation to users you need to adjust into a time zone expected by the user. This is the purpose of the ZonedDateTime class and the formatter classes used to generate String representations of those date-time values.
ZonedDateTime zdt = instant.atZone( z ) ;
String output = zdt.toString() ;                 // Standard ISO 8601 format.

You can generate text in localized format using DateTimeFormatter.
DateTimeFormatter f = DateTimeFormatter.ofLocalizedDateTime( FormatStyle.FULL ).withLocale( Locale.CANADA_FRENCH ) ;
String outputFormatted = zdt.format( f ) ;

mardi 30 avril 2019 à 23 h 22 min 55 s heure de l'Inde

LocalDate, LocalTime, LocalDateTime

The "local" date time classes, LocalDateTime, LocalDate, LocalTime, are a different kind of critter. The are not tied to any one locality or time zone. They are not tied to the timeline. They have no real meaning until you apply them to a locality to find a point on the timeline.
The word "Local" in these class names may be counter-intuitive to the uninitiated. The word means any locality, or every locality, but not a particular locality.
So for business apps, the "Local" types are not often used as they represent just the general idea of a possible date or time not a specific moment on the timeline. Business apps tend to care about the exact moment an invoice arrived, a product shipped for transport, an employee was hired, or the taxi left the garage. So business app developers use Instant and ZonedDateTime classes most commonly.
So when would we use LocalDateTime? In three situations:

We want to apply a certain date and time-of-day across multiple locations.
We are booking appointments.
We have an intended yet undetermined time zone.

Notice that none of these three cases involve a single certain specific point on the timeline, none of these are a moment.
One time-of-day, multiple moments
Sometimes we want to represent a certain time-of-day on a certain date, but want to apply that into multiple localities across time zones.
For example, "Christmas starts at midnight on the 25th of December 2015" is a LocalDateTime. Midnight strikes at different moments in Paris than in Montréal, and different again in Seattle and in Auckland.
LocalDate ld = LocalDate.of( 2018 , Month.DECEMBER , 25 ) ;
LocalTime lt = LocalTime.MIN ;   // 00:00:00
LocalDateTime ldt = LocalDateTime.of( ld , lt ) ;  // Christmas morning anywhere.

Another example, "Acme Company has a policy that lunchtime starts at 12:30 PM at each of its factories worldwide" is a LocalTime. To have real meaning you need to apply it to the timeline to figure the moment of 12:30 at the Stuttgart factory or 12:30 at the Rabat factory or 12:30 at the Sydney factory.
Booking appointments
Another situation to use LocalDateTime is for booking future events (ex: Dentist appointments). These appointments may be far enough out in the future that you risk politicians redefining the time zone. Politicians often give little forewarning, or even no warning at all. If you mean "3 PM next January 23rd" regardless of how the politicians may play with the clock, then you cannot record a moment – that would see 3 PM turn into 2 PM or 4 PM if that region adopted or dropped Daylight Saving Time, for example.
For appointments, store a LocalDateTime and a ZoneId, kept separately. Later, when generating a schedule, on-the-fly determine a moment by calling LocalDateTime::atZone( ZoneId ) to generate a ZonedDateTime object.
ZonedDateTime zdt = ldt.atZone( z ) ;  // Given a date, a time-of-day, and a time zone, determine a moment, a point on the timeline.

If needed, you can adjust to UTC. Extract an Instant from the ZonedDateTime.
Instant instant = zdt.toInstant() ;  // Adjust from some zone to UTC. Same moment, same point on the timeline, different wall-clock time.

Unknown zone
Some people might use LocalDateTime in a situation where the time zone or offset is unknown.
I consider this case inappropriate and unwise. If a zone or offset is intended but undetermined, you have bad data. That would be like storing a price of a product without knowing the intended currency (dollars, pounds, euros, etc.). Not a good idea.
All date-time types
For completeness, here is a table of all the possible date-time types, both modern and legacy in Java, as well as those defined by the SQL standard. This might help to place the Instant & LocalDateTime classes in a larger context.

Notice the odd choices made by the Java team in designing JDBC 4.2. They chose to support all the java.time times… except for the two most commonly used classes: Instant & ZonedDateTime.
But not to worry. We can easily convert back and forth.
Converting Instant.
// Storing
OffsetDateTime odt = instant.atOffset( ZoneOffset.UTC ) ;
myPreparedStatement.setObject( … , odt ) ;

// Retrieving
OffsetDateTime odt = myResultSet.getObject( … , OffsetDateTime.class ) ;
Instant instant = odt.toInstant() ;

Converting ZonedDateTime.
// Storing
OffsetDateTime odt = zdt.toOffsetDateTime() ;
myPreparedStatement.setObject( … , odt ) ;

// Retrieving
OffsetDateTime odt = myResultSet.getObject( … , OffsetDateTime.class ) ;
ZoneId z = ZoneId.of( "Asia/Kolkata" ) ;
ZonedDateTime zdt = odt.atZone( z ) ;

About java.time
The java.time framework is built into Java 8 and later. These classes supplant the troublesome old legacy date-time classes such as java.util.Date, Calendar, & SimpleDateFormat.
To learn more, see the Oracle Tutorial. And search Stack Overflow for many examples and explanations. Specification is JSR 310.
The Joda-Time project, now in maintenance mode, advises migration to the java.time classes.
You may exchange java.time objects directly with your database. Use a JDBC driver compliant with JDBC 4.2 or later. No need for strings, no need for java.sql.* classes. Hibernate 5 & JPA 2.2 support java.time.
Where to obtain the java.time classes?

Java SE 8, Java SE 9, Java SE 10, Java SE 11, and later  - Part of the standard Java API with a bundled implementation.

Java 9 brought some minor features and fixes.

Java SE 6 and Java SE 7

Most of the java.time functionality is back-ported to Java 6 & 7 in ThreeTen-Backport.

Android

Later versions of Android (26+) bundle implementations of the java.time classes.
For earlier Android (<26), a process known as API desugaring brings a subset of the java.time functionality not originally built into Android.

If the desugaring does not offer what you need, the ThreeTenABP project adapts ThreeTen-Backport (mentioned above) to Android. See How to use ThreeTenABP….

The ThreeTen-Extra project extends java.time with additional classes. This project is a proving ground for possible future additions to java.time. You may find some useful classes here such as Interval, YearWeek, YearQuarter, and more.
Comment: Great answer. I think some confusion (at least mine) comes from the `Local` naming. My intuition for `Local` means in relation to where I am AND when I am (?!), which leads me to believe that it would actually be what a `ZonedDateTime` is.
Comment: Yes it is confusing. That is why java.time cleverly added the word 'Zoned' to the `DateTime` class name used by its predecessor Joda-Time (producing `ZonedDateTime`), to stress the difference from the "Local" classes. Think of the name "Local" as being shorthand for "needing to be applied to some particular locality".
Comment: @simonh Yes, there are cases where the "local" date time is appropriate. Besides those mentioned in my Answer, another common case in business is for appointments being made more than a couple months out in the future, far enough out that politicians might change the time zone rules, usually with little forewarning. Politicians frequently make these changes such as changing the dates when going on/off Daylight Saving Time (DST) or staying permanently on/off DST.
Comment: Prefixing with the word `Local` may have also been a way to differentiate from the java.util package, though somehow I feel there could have been a better word choice.
Comment: @simonh On the contrary… When that new employee signs his/her hiring papers defining their benefits including life insurance and then that new hire steps outside for a coffee only to get hit and killed by a truck, there are going to be many people such as Human Resources managers, insurance agents, and attorneys who are going to want to know the precise moment when that new employment took effect.
Comment: @specializt I suggest you post your own Question and Answer  to educate others about this mysterious retroactive and fault-tolerant calculations concept. I am curious.
Comment: @KevinM Ask a North Korean dentist why all their patients are showing up [a half-hour early this week](http://www.latimes.com/world/asia/la-fg-north-korea-time-20180505-story.html). All the patients are a half-hour ahead of the poorly-designed UTC-based appointment scheduling software.
Comment: If your future appointments are far enough out that a government might, in the interval, change the offset used in that zone, then you must use the *concept* of "3 PM January 27, 2019" without determining a point in the timeline. That means using a `LocalDateTime`; store that. When you need to determine a moment, a point on the timeline, apply a `ZoneId` to get a `ZonedDateTime`. If you want to see UTC, extract an `Instant` from that `ZonedDateTime`. But do not store these. Later, when the gov. does redefine the zone's offset, you'll get a different result when applying the `ZoneId`.
Comment: Great answer.  Just one improvement: `ZonedDateTime` should be viewed as an alternative form to represent an `Instant`, and `ZonedDateTime` is actually `LocalDateTime` + `ZoneId` (instead of `Instant` + `ZoneId`).   In another word: `LocalDateTime + ZoneId` = `ZonedDateTime`; and `ZonedDateTime` can be converted to `Instant`.  I understand the reason you said `ZonedDateTime = Instant + ZoneId`, as you need to specify the timezone you want to convert an `Instant` to a `ZonedDateTime`, but it seems a bit misleading in some aspect (especially if we look into the implementation of `ZonedDateDate`)
Comment: Conceptually, simply by the name of ZonedDateTime, it already hinted on what it is: it is a Date + Time (for which in JSR310/Joda, this is modelled as LocalDateTime) , that is Zoned (ie with Time Zone). So it is definitely not incorrect to mention LocalDateTime in discussion.
Comment: @BasilBourque

> Class implementation details are but a distraction
Not if we consider how `LocalDateTime("some-dst-overlap-time").atZone()` works versus `Instant.atZone()`.
Or `ZonedDateTime.parse("some-dst-overlap-time+ANYOFFSETWHATSOEVER[ZoneId]")`, which works identically to the `LocalDateTime.atZone` variant.
The `LocalDateTime`/`parse` variants will preserve the `LocalDateTime` component in case of law changes/dst, ignoring the offset in the parsed string, while the Instant variant will preserve the Instant.
Comment: Wanted to point out that there is an alternative to LocalDateTime in pre-java-8 world.
It's the java.sql.Timestamp itself.

If constructed using `Timestamp.valueOf(string)` and stored in a zone-less db column,then regardless of the tz it will be read back out with toString returning the original time (except the offset).

A quirk is, that if constructed with string, the milliseconds stored internally are completely awry and depend on the TZ.
So, build with millis - get millis. Same for string. Or `.toLocalDateTime` in java 8.

This is inherent to all java.util.Date based classes.
Comment: @AJW [*How to use ThreeTenABP in Android Project*](https://stackoverflow.com/q/38922754/642706). And you can easily use a search engine such as Duck Duck Go, Bing, or Google to find the phrase "API desugaring".
Comment: @iwat0qs Those stuck on Java 6 or Java 7 should use [*ThreeTen-Backport*](https://www.threeten.org/threetenbp/), not the terrible legacy classes such as`java.sql.Timestamp`. In such an environment, use `Timestamp` only for storing to or retrieving from the database. Immediately convert to/from the *ThreeTen-Backport* types. When parsing/generating text, use *ThreeTen-Backport* classes. And these folks should *really* put some thought into migrating to a modern version of Java.
Comment: @bphilipnyc I've had the same feeling about a better word choice. But I've yet to think of a better one, except perhaps the clunky term "Unzoned".
Comment: Great answer, @Basil Bourque, although i disagree with one assumption - that LocalDate is rarely useful in business apps. I think there are many cases where a date is important but the time portion isn't. You give an example of when an employee is hired. You'd almost certainly want to use a LocalDate to represent that. No-one wants to see that the employee started at midnight UTC, or 18:30 UTC the previous day if the employee is in India. You just want the date.
Comment: According to `org.hibernate.type.descriptor.sql.TimestampTypeDescriptor`, I noticed that, Hibernate do: `Timestamp.from(instant)` before it saves `Instant` date to SQL database as Timestamp. and then sets the timestamp value depending on JDBC Driver Timezone. (hence it is DB Timezone)
Comment: @BasilBourque In the case of the future appointment, why wouldn't you still just treat it as a date/time in UTC? Since UTC never changes, just always treat and store in the database in UTC. When displaying to a user you use their timezone rules at that point in time to show them the date/time in the future converted from UTC. Right? So would Instant be the best class to use at all times until needing to convert to a particular locale/timezone?
Comment: I get it they can change timezones. Let's look at this from the database perspective. You are saying that you would store appointments that are only somewhat in the future in UTC but then if it's far enough in the future you would not store it in UTC? Or would you store everything as UTC and then convert/display them differently based on how far in the future they are? That seems very inconsistent and arbitrary. You seem to be advocating for storing dates in the db Not in UTC and Not with specific timezone information. Or I'm just not following, which is possible
Comment: @AdrianShum *Conceptually*, adding `LocalDateTime` to this discussion is the wrong way to go. A `ZonedDateTime`, like `Instant`, represents a moment. A `LocalDateTime` *cannot* represent a moment, by definition, lacking the context of a time zone or offset-from-UTC. For example, `LocalDateTime.parse( "2018-03-11T02:30:00" )` (a) is a different moment on the east coast of the US versus the west coast of the US, and (b) does not even exist in much of the United States, as 2 AM to 3 AM is the "Spring Ahead" cutover of Daylight Saving Time (DST). Class implementation details are but a distraction.
Comment: I think your statement about business apps is unnecessary and also wrong - time-zone independent data is very important for a lot of businesses; if you need to be sure that your data still is valid in 10/20/30 years you *need* to use classes like these - system misconfigurations and miscalculations can corrupt your timestamps if they are bound to some timezone which is not the case with timezone-free stamps, they represent an abstract point in time which can be represented arbitrarily, depending on your needs. For instance : one could re-calculate everything with new timezones
Comment: @specializt Reread my last sentence that starts with "On the other hand". As I stated there, I agree with you about needing to use `LocalDateTime` to represent a date with time far enough in the future that we risk politicians changing the definition of the offset of their time zone(s).
Comment: its also the case for past timestamps - if (and only if) there is a need for re-calculation and/or re-interpretation; inside of fault-tolerant systems, for instance
Comment: @specializt I don't follow you there. For the past, time zone definitions do not change. So no risk associated with storing a date-time associated with a time zone such as a `ZonedDateTime`. But generally it is best to store passed moments in UTC. That means either an `Instant` or an `OffsetDateTime` set to `ZoneOffset.UTC`. But I don't see any reason to ever handle a past moment as a `LocalDateTime`.
Comment: like i said : if the timestamp is used for calculations and applied timezones could change in the future such a persistence field really is needed. This is the case for fault-tolerant systems and/or especially volatile calculation steps which need to be adjusted in the future according to local law and/or court orders. Calculations like these cannot be fixed to any assumption whatsoever and timezones basically are assumptions of system clock integrity, precision, data source validity and -integrity and so on. Imagine a court order re-defining a formula which has already been applied to data.
Comment: @specializt That is true for *future* moments, not *past*.
Comment: i think you fail to grasp the basic concept of retroactive and fault-tolerant calculations. Well ... its not that important, these requirements are way above what most programmers have to face and are actually a bit exotic. You just need to know that there are very valid needs for persistence fields like these and they also matter for **past** moments
Comment: Hi, **1-** what is difference between `instant.atZone( z )` and `ZonedDateTime.ofInstant( instant , z )`? **2-** If i want to update a field in a page by changing the day, is better to use the *instant* or the *LocalDateTime*?
Comment: @Arash (1) No difference. (2) If you mean to represent a moment, a specific point in time, you cannot use `LocalDateTime`, you must use the other three types as shown on my chart. To represent merely a date with time-of-day but without the context of an offset-from-UTC or a time zone, and therefore inherently ambiguous, use `LocalDateTime`.
Comment: @Basil Bourque  I have a working Android app that uses legacy Date, Calendar and Timestamp functions to provide local date, time and timer features for the user.  Works perfectly but I realize the code should be replaced with more robust and stable java.time code.  Are there any good tutorials about using API desugaring and/or ThreeTenABP to replace my legacy code for API <26.
Comment: @Basil Bourque  Very good, thank you for the reply and info, cheers.
Comment: Oh my, I don't remember what I was thinking back then. I agree with the backport and that sql time types are horrible. But in case the used JDBC drivers, especially in pre Java 8 world or a legacy codebase, are only supporting sql Date, Time and Timestamp, then understanding their quirks in relation to available DB types for time is useful. And not that difficult if you grok time at all.
Comment: @BasilBourque ORM framework mybatis maps `timestamp with timezone` to `java.time.OffsetDateTime`, do you think it's the right choice ?
Comment: @WestFarmer Yes, right choice. The JDBC specification correctly maps the SQL standard type `TIMESTAMP WITH TIME ZONE` to the Java type `java.time.OffsetDateTime`.  While the SQL standard uses the words "time zone", they actually mean offset from UTC. See section 4.5.1 of the [draft of SQL-92](http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt). So **the SQL type is a misnomer**. The SQL standard type should have been named `TIMESTAMP WITH OFFSET`. And you should think of it as such.
Answer: One main difference is the "Local" part of LocalDateTime. If you live in Germany and create a LocalDateTime instance and someone else lives in the USA and creates another instance at the very same moment (provided the clocks are properly set) - the value of those objects would actually be different. This does not apply to Instant, which is calculated independently from a time zone.
LocalDateTime stores date and time without a timezone, but its initial value is timezone-dependent. Instant's is not.
Moreover, LocalDateTime provides methods for manipulating date components like days, hours, and months. An Instant does not.

apart from the nanosecond precision advantage of Instant and the
time-zone part of LocalDateTime

Both classes have the same precision. LocalDateTime does not store the timezone. Read Javadocs thoroughly, because you may make a big mistake with such invalid assumptions: Instant and LocalDateTime.
Comment: I'd take LocalDateTime whenever I need dates and/or times. In hours, minutes, or so. I'd use Instant to measure execution times, for example, or store an internal field of sth happening then and there. Calculating next runs, as in your case? LocalDateTime seems appropriate, but it's an opinion. As you stated, both can be used.
Comment: sorry for misreading part on zone + precision. Sorry for repeating from above post: Considering a single time-zone application, in which use-cases would you favor LocalDateTime or vice versa?
Answer: You are wrong about LocalDateTime: it does not store any time-zone information and it has nanosecond precision. Quoting the Javadoc (emphasis mine):

A date-time without a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30.
LocalDateTime is an immutable date-time object that represents a date-time, often viewed as year-month-day-hour-minute-second. Other date and time fields, such as day-of-year, day-of-week and week-of-year, can also be accessed. Time is represented to nanosecond precision. For example, the value "2nd October 2007 at 13:45.30.123456789" can be stored in a LocalDateTime.

The difference between the two is that Instant represents an offset from the Epoch (01-01-1970) and, as such, represents a particular instant on the time-line. Two Instant objects created at the same moment in two different places on the Earth will have exactly the same value.
Comment: @manuelaldana It is more a matter of taste. I'd prefer LocalDateTime for anything user-related (birthday...) and Instant for anything machine-related (execution time...).
Comment: @manuelaldana A single time zone app is rare if not nonexistent. You might get away with ignoring time zones for a little app you whipped up for your local Baroque music club. But as soon as you need to post an event to people who travel (and cross time zones) they'll want that data tied to a time zone so their calendar app can adjust as needed. I suggest you learn to work with time zones properly in all your apps.
Comment: Considering a single time-zone application, in which use-cases would you favor LocalDateTime or vice versa?
Comment: @Tunaki Your use of the word 'offset' in the last paragraph is distracting. That word has a certain meaning in date-time work, so it's use here in this context could be unhelpful.
Answer: LocalDateTime has no time-zone information: one LocalDateTime may represent different instants for different machines around the world. So you should not try to use it with an implicit time-zone (the system's default one). You should use it for what it represents, for instance "New-year is January 1st, at 0:00": this means a different time at all points on the globe but it's wanted in this case.
Instant is a point in time at the Greenwich time-zone. Use it in addition to the user's time-zone to show him/her the start of a meeting in his/her time-zone, for instance.
If these two classes do not represent what you wanted to store/exchange, then maybe ZonedDateTime or another class may do a better job.
Here is a simple synthetic schema to get the big-picture of the classes in the java.time package and their relation to the ISO-8601 standard used to reliably and effortlessly exchange dates and times between Java and other languages or frameworks:

The schema is explained in details here: http://slaout.linux62.org/java-date-time/
Answer: I have dealt with time zones in many projects in my career. With hindsight, I must admit that we never got it 100% right because of the surprising complexity of the topic. This is why I decided to write a blog post with a detailed coverage of the java.time package.
There already are many excellent answers to the question posted above, but this blog post goes beyond just Java and also covers the interaction with technologies like relational DBs, NoSQL DBs (e.g. MongoDB) or JavaScript, which typically have a much more restrictive support than Java when it comes to time zones.
While I do recommend reading the article to get a detailed understanding of all the concepts, I would like to add two schemas from my post to give a quick overview.
The first diagram summarizes the features of the java.time classes which describe a point in time. Some classes stand for an absolute (or unequivocal) point in time (called moment), while others like LocalDateTime only describe a so-called wall-clock time:

The second schema provides a decision tree which will help you pick the right class for your use case.

Some of the decisions to make in this decision tree are anything but trivial. There are explained in more detail in my blog post.


The import javax.ws cannot be resolved on Eclipse

Question: I am developing a RESTful's Webservice on java using Eclipse with the next steps:

File>New>Dynamic Web Project

Then I configured these options:

Target runtime: Apache Tomcat v7.0;
Dynamic web module version: 2.5 (because  I am using Axis2);
Configuration: Default Configuration for Apache Tomcat v7.0 and  (both options)

In label "Modify" I added "Axis2 Web Services" and "JAX-RS (REST Web Services)"
Next, when I created my new class, I added

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

but Eclipse launches the notice

The import javax.ws cannot be resolved

I don't know the next question

Is it necessary to add all the files .jar to the path WebContent/WEB-INF/lib ?
Or you can create, for example, a new path WebContent/WEB-INF/lib-RESTproyect?
If I choose the second option, will I have a problem in the future with my project?
Comment: Yes it is necessary to add all thrid party jar on classpath because when deployed on server all library will automatically sync on server.
Comment: Add an implementation of JAX-RS specs, eg jersey etc... jars
Comment: @Darshan you have reason, but do you know if I would use another path, or I have to use "WebContent/WEB-INF/lib" by default? Thanks
Answer: Import the jar file: javax.ws.rs-api-2.0.jar
And add it to java build path. The issue will be resolved in windows.
Answer: Import the jar file: javax.ws.rs-api-2.0.jar And add it to java build path. The issue will be resolved in windows.
Link to the jar : http://www.java2s.com/Code/Jar/j/Downloadjavaxwsrsapi20jar.htm
Information on importing it to Eclipse : http://tech.amikelive.com/node-269/eclipse-quick-tip-resolving-error-the-import-javaxservlet-cannot-be-resolved/comment-page-1/


"Soft" restart an app after settings change

Question: Is there an easy way to relaunch my application from the starting window like it was freshly launched (show the splash screen and rebind all of my initial data)?
The reason being is that we have a line of business app that basically talks to different endpoints. If the endpoint changes in the settings, I want to show a dialog box when the settings pane closes that will ask to relaunch the app to get information for the newly selected endpoint.
If not, I can always have the application navigate back to the root frame of the application and rebind all of my data. Just was curious if there was an easier way.
Answer: I don't think you can force your app to restart so your best option seems to be to clean up all your state yourself and navigate back to the beginning. Perhaps also wrap any code you put in the App class' to handle app initialization events and call it again after you've cleaned things up.


Using redis' list data structure or a serialized ruby hash for storing data

Question: Greetings,
I want to store some data in a redis db and don't know which way I should go. The data is equivalent to something like an address with the variables name, street and number. They will be stored under the lower cased name as key, there won't be doublets.
Now, should I save it as a list or should I serialize the hash ({:name => 'foo', :street => 'bar', :number => 'baz'} for example) with JSON/Marshall and simply store that?
Regards
Tobias
Comment: I learned about redis hashes (>= 1.3.10) and they seem to be perfect!
Answer: Using an encoded json object is a pretty good idea. You can see some examples in hurl — check out how the models are saved.
Redis hashes are nice too, especially if you need atomic operations on hash values.
Comment: Redis hashes were the way to go, just perfect. Thanks!
Answer: Also you can use something like Nest to help you DRY up your keys:
addresses = Nest.new("Address", Redis.new)

this_address = addresses[1]
# => "Address:1"

this_address.hset(:name, "foo")
this_address.hset(:street, "bar")

this_address.hgetall
# => {"name" => "foo", "street" => "bar"}

If you need something more advanced, there's Ohm, which maps Ruby classes to Redis:
class Address < Ohm::Model
  attribute :name
  attribute :street
  attribute :number
end

# Create
Address.create(:name => "foo", :street => "bar")

# Find by ID
Address[1]

# Find all addresses with name "foo"
class Address < Ohm::Model
  attribute :name
  attribute :street
  attribute :number

  index :name
end

Address.find(:name => "foo")
# => Array-like with all the Address objects


Samba public share does not show up at "Network" in Windows, but is accessible

Question: I have set up a Samba public share as follows:
<code>[global]
    workgroup = MYWORKGROUP
    netbios name = SHUTTLESERVER
    security = user
    map to guest = bad user
    dns proxy = no
    guest account = nobody

    #to disable printer sharing error message
    printing = bsd
    printcap name = /dev/null

[public]
    comment = Public Share
    path = /home/villermen/public
    browsable = yes
    writable = yes
    guest only = yes
</code>
The share can be accessed and written to just fine by Windows using the server's name or ip, (\192.168.something or \SHUTTLESERVER). However, it does not show up in the list of network devices. My laptop on the same workgroup, and some other devices like my printer/router show up just fine. The server shows up as dlna device too if I install minidlna, no idea if that is of any use to the question though.
I'm running Ubuntu Server 14.04.3, and Samba 4.1.6-Ubuntu.
Would be great if someone shed some light on this, as I've tried pretty much every option to get this to work.
Gr.Viller
Comment: Same problem here, but only affects certain random folders
Answer: I've finally found the reason it was not showing up. After changing the workgroup to something arbitrary to both the server and my pc it got detected. Turns out there was already a device on the same network with the name of the workgroup, which was making it conflict in one way or another. Removing the device's lease from my router's dhcp table made the server appear on the workgroup in question.


Temperature readings are high on income eletrical feeds to the breaker box

Question: I am buying a home built in 2006 the incoming temp the temp on the left side is 200 degrees and the right side is 80 with full load on. My inspector sees a tie wrap stuck down the hookup on the left side and says that may be the cause of the heat difference and should be removed.
Comment: That's more than what a tie wrap would do.  What make/model is the panel?
Comment: My inspector says it is a square d  if that helps
Comment: Materials: 150 Amp - Interior main disconnect / distribution panel (square D).
Answer: With aluminum service conductors if an anti oxide compound was not used the connection may be failing. Also if the terminals were not properly torqued this can happen. The 2017 NEC has a new section on torque requirements for this very reason. Re torquing the service requires hot gloves and flash gear if the service is live. I have never found a zip tie to cause an over heating problem. But have found many terminations that needed to be tightened both with copper and aluminum wire (I have found more problems with aluminum than copper).
Comment: It is best to clean the outside contact area, if there is a spare inch of wire I would cut it off and clean the terminal then wipe anti oxide compound on the outer surfaces it doesn't take much. This level of cleaning the power needs to be off, I have done hot work like this but many will not (have only done this on life critical systems that we could not shut down).  I also pull the terminal set screw and add some compound on the threads when the terminal / set screw is aluminum. Re Torque the screw may work if the corrosion is not bad. The tempature will drop within minutes if  it works.
Comment: Just call the power company and have them shut it off at the meter.  A lot of smart meters these days have contactors which can be remotely thrown by the power company.
Comment: Does just squirting joint paste on the end of the service inlet conductor and then tightening down do any good? Or does one have to disconnect, clean oxide off with emery cloth or a wire brush through antioxidant joint paste, add more joint paste, and then torque to specs? Would one have to go so far as to spread the individual strands to deliver paste to the joint
Comment: I can imagine "exploratory" tightening of the lugs on the service entrance conductors in the panel without making a temperature measurement.  Would this be unwise?
Comment: In some heavy industrial facility's many panels are checked once a year with thermal imaging 2 of the facilities I have worked at checked at 6 months without a thermal image (torque driver used) on all aluminum feeders it did amaze me on very large motors how often there were problems. We do also find problems with copper but just a fraction compared to aluminum.


Splash Screen Activity forces my device to restart

Question: I am viewing an article on Xamarin that guides how we can add a Splash Screen on an AppCompatActivity. Whenever I run the application it forces my device to restart.
Here is what I have done to get the issue solved and I was failed.

Setting the Java max heap size to 1G
Properly followed the steps listed on Xamarin article for splash screen creation
Properly installed AppCompatv7 and v4 support

Still the issue is there.
Here is my code for it maybe I am doing something wrong in the coding part.
Splash Activity
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Support.V7.App;
using Android.Views;
using Android.Widget;

namespace TestApp
{
    [Activity(Label = "SplashActivity", MainLauncher = true, NoHistory = true, Theme = "@style/MyTheme.Splash")]
    public class SplashActivity : AppCompatActivity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            var startupTask = new Task(SimulateStartup);
            startupTask.Start();

        }
        private async void SimulateStartup()
        {
            await Task.Delay(4000);
            var intent = new Intent(this, typeof(MainActivity));
            intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask);
            StartActivity(intent);
        }
    }
}

MainActivity
using System.Threading.Tasks;
using Android.App;
using Android.Widget;
using Android.OS;
using Android.Support.V7.App;
using System;
using Android.Content;

namespace TestApp
{
    [Activity(Label = "MainActivity")]
    public class MainActivity : AppCompatActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);
        }

    }
}

Styles.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>

</resources>

splash_screen.xml
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item>
    <color android:color="@color/splash_background"/>
  </item>
  <item>
    <bitmap android:src="@drawable/splash" android:tileMode="disabled" android:gravity="center" />
  </item>
</layer-list>

colors.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <color name="primary">#4682b4</color>
  <color name="primaryDark">#2c6493</color>
  <color name="accent">#FFC107</color>
  <color name="window_background">#F5F5F5</color>
  <color name="splash_background">#4682b4</color>
</resources>

Answer: Please check your bitmap size. If it is too big it may cause a reboot: see Xamarin Android App causes device reboot
Comment: Thanks for the answer. my pictures size in kilobytes was 331KB but it's resoultion was 4488x5315.


Non-contact tester shows voltage in house circuit while three-lamp tester shows none

Question: None of the outlets or lights in my bedroom work. My non-contact tester shows the outlets are hot. My three lamp tester shows no juice reaching the outlets ( no lights light up when it's plugged in). Nothing will turn on when I plug it in either. What could cause this? I've tested both testers on known power sources and they appear to be fine.
Comment: I believe this could also be caused by a common or neutral wire that has a break in it.  The non-contact tester would show the voltage on the hot, but you wouldn't have a complete circuit to measure with a lamp or contact tester.
Comment: Your light tester probably requires something close to 120v. You may have a low voltage condition for one reason or another. Do you have any actual voltage readings?
Comment: I had problems with non-contact testers, but I only paid like $15 for it.  Same deal, I was doing some new runs and got false reads on it when I know the line was dead because I connected myself and hadn't plugged it into panel yet.
Comment: It doesn't show "no juice", it shows not enough for it to operate.  Since these are cheapie "pass-fail" testers, with no real insight into their internal workings, this sort of reading is "par for the course": it's telling you "fail", which you already knew.
Comment: Have you checked the breakers and checked for any GFCI outlets in line with your bedroom wiring?  Is this a new problem?   Details, please.
Comment: My voltage reads nothing on my voltmeter. Just found it strange that this is the only room in the house that this has occurred and it is the farthest room from the panel and service wire. There should be no wires running through this room that are carrying voltage to supply a farther room down the line. I was hoping that it would offer some insight as to why I have electricity to this room. Looks like it is just not connected to the panel. Now to find out where the disconnect is. Thanks for the feedback given by all and any more would be warmly welcomed.
Comment: Carl, the problem is new. We bought the house with the stipulation that the home seller would pay to fix the electric issues. Problems like splices outside of boxes, unnecessary secondary fuse panels, wires running along the floor,etc... This room was fine until these repairs were made. It was an original room in the house and I can't see what work was done. I can't see what's different or what's missing compared to before.  The house is from the mid 50's and has a hodge podge of work done from different areas. Let me know if this info helps and thanks
Comment: What does voltmeter show?
Answer: Non contact testers work by identifying an electrical field. The wiring normally is run in close proximity and the live wires induce a voltage that can be detected by the non contact tester but there is no potential or current available so the lighted tester will not light. This is normal and quite common I have more expensive Fluke testers and very cheap ones and they all work the same. You can duplicate this with 2 extension cords plug 1 in and put another one not plugged in next to the first. The larger the load on the plugged in cord the larger the field will be on the cord that is not plugged in but many times no load is needed to induce the field in just a few feet. (this is how transformers work but they have many wraps of wire to develop the potential).
Have you checked your circuit breakers? if the handle is partially tripped it needs to be moved to the off position then back to the on position to reset it. it is also possible that the circuit is protected by A GFCI device that has tripped other than a failed electrical connection.


How should cable (Romex) exit conduit to run bare along rafters in an unfinished detached garage?

Question: I am going to be installing a subpanel in an unfinished detached garage, and would like to install receptacles in each corner of the building.
Since the garage is unfinished (cinderblock walls), I'm going to place all of the cable ( as Romex) in Schedule 40 PVC conduit for the vertical runs from the receptacles to the rafters. To run the Romex between the building corners, I plan to run it stapled across the rafters more than 7 feet up.
At the top of each vertical conduit run, do I have to install a terminal adapter the end of the conduit electrical box & splice it to a Romex that's clamped to the box? Or is there some kind of bushing or strain relief connector that I can use on the end of the conduit, so the same piece of Romex can be run from one corner to the next?
Comment: With intact NM cable inside PVC conduit why do you need to do anything?  Just staple the cable near to where it exits the conduit.  The conduit protects the cable at lower levels, the plastic conduit end is not damaging to the plastic outer jacket of the cable, and the cable is appropriately fastened by staples to the ceiling.  Why add complexity?
Comment: Not an exact duplicate but see https://diy.stackexchange.com/questions/31149/can-romex-nm-b-cable-be-run-through-conduit
Comment: What kind of "terminal adapter" are you thinking of? You may want to include a picture or at least a link to one.
Comment: @jay613, I would tend to accept that myself, but I just want to insure that it's acceptable to the electrical inspector. As I'm a DIYer, I didn't know if there were any restrictions via NEC.
Answer: You can get a female adapter like this

and attach it to your PVC and then screw this adapter into it after removing the lock nut (Stock photos from home Depot). You can also add a PVC 90 degree sweep in the direction of the run if neatness counts.
Comment: @Ecnerwal  Thanks... need more coffee
Comment: Thanks, @Jack. That sounds like it'll work. Hopefully the inspector will accept it.
Comment: Why don't you try one of these and one with a bare conduit end and see if the inspector accepts either or both.    I think this would be my preferred solution if the cable were exiting the conduit into, say, a suspended ceiling where I'm fishing it further and unable to fasten it to anything.  But if you're stapling at the transition, IMO either way is OK and either way equally likely to irk an inspector for no good reason.


Android/JAVA: Async functions call to avoid blocking calls

Question: In my Android app, there's a function called userProfile(Promise promise) which looks similar as below:
@ReactMethod
public void userProfile(Promise promise) {
    String name = getName();
    String number = getNumber();
    String userDynamicId = getHttpDynamicId(); // network request
    ...
    promise.resolve(name + number + userDynamicId);
}

The userProfile is a ReactMethod which will be handled by UI thread, however, getHttpDynamicId() may cost long time due to the networking. Sometimes, the UI thread is blocked by this function.
Is there any easy way to using another thread to handler getHttpDynamicId() to avoid the GUI freezes? Or any other multi thread way to handle the problem?
Comment: https://developer.android.com/training/best-background
Comment: @MeowCat2012  Thanks for the documents, it's helpful. I'm looking at it right now. I will paste my solution here if I can work it out. If so, could you please help give a thumb up to counteract the '-1'. It's sad to see people gives the '-1' so easily without a reason.
Comment: Well, OK for this time. You could learn to `search` for existing solutions before asking a question, and browsing `Documentation|Reference|Online Courses|Tutorials` in the future. Not only saving others' time but also saving your own time. However as a beginner it's even hard to know where to start searching (e.g. what keyword to use, how to describe) so I do not think it really reasonable to vote down.
Comment: @MeowCat2012 Thanks for your understanding and also the link. I've managed to solve it. Will upload my solution later. I appreciate it!
Answer: From the link which Meow provided: https://developer.android.com/training/best-background. I managed to come up with the solution.
class MyCallable implements Callable<String> {
    @Override
    public String call() {
        String userDynamicId = "";
        try {
           // XXXXX Code to get ID
        } catch (Exception e) {
            console.error(e);
        }
        return userDynamicId;
    }
}

@ReactMethod
public void userProfile(Promise promise) {
    String name = getName();
    String number = getNumber();
    // instantiate MyCallable
    // Create executor and use Future to get the result from call()
    promise.resolve(name + number + userDynamicId);
}


Display short tags on one line

Question: The picture below is an image of the functionality from the site. In the column "Enter a code" the user can enter data using TagsInput.
I would like to slightly improve the functionality so that short tags are displayed on one line. I know that you can apply "inline", but then long tags go beyond the borders of the modal window.
.tag {
    display: flexbox;
    align-items: center;
    margin: 5px 0;
    margin-right: 5px;
    padding: 0 5px;
    border: 1px solid black;
    border-radius: 5px;
    color: black;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: fit-content;
    white-space: nowrap;
    position: relative;
}

I have already tried many options, and looked at many answers on stackoverflow, but did not achieve the result. Perhaps you can give me a hint.
Comment: `display: flexbox` is invalid, it should be `display: flex` but have you tried `display: inline-block`?
Comment: @Undo If I use display: flex then the ellipsis doesn't work. Yes, of course I tried display: inline-block
Comment: OK. My suggestion wasn't to use `display: flex`, I merely pointed out that `flexbox` is not a valid value to `display`
Answer: Would be nice if you add a bit more code that this. I'm guessing your tag class is on the children? What you need is to put the parent container in flex.

100
x

200
x

300
x

400
x

500
x

600
x

700
x

800
x

800
x

1000
x

    <input
      class="input"
      placeholder="Enter a code"
    />

.tag-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  width: 200px; /* Exemple width */
  border: 1px solid black;
}
.tag {
  text-align: center;
  margin: 5px 0;
  margin-right: 5px;
  padding: 0 5px;
  border: 1px solid black;
  border-radius: 5px;
  color: black;
}
.del {
  border: none;
  border-radius: 30%;
  background-color: transparent;
  cursor: pointer;
  color: black;
  margin-top: -2px;
}
.input {
  width: 100%;
  min-width: 50%;
  border: none;
  margin: 5px;
  border-bottom: 1px solid black;
}

Comment: Thanks for the reply, but unfortunately your solution doesn't work. I have updated the question and added more code
Comment: I've edited my answer to fit your code as much as possible, but if not I suspect it might be some interfering styles from your react components?
Comment: Thanks for the advice. Your code is not quite suitable for me, but it led me to the right idea))
Comment: Yeah I never used react so I can't help you too much with that but glad it could help you at least a bit!

Display short tags on one line


Is there any good way to represent the order change before and after sorting on a value in a data frame?

Question: I have a Pandas data-frame and I will be sorting it on a particular column. If I want to plot the data to represent how the data is changing before and after sorting, is there any good way?
Before Sorting
ID ||| Map Score
----------------
1  ||| 13
2  ||| 15
3  ||| 1
4  ||| 5
5  ||| 6

After  Sorting
ID ||| Map Score
----------------
2  ||| 15
1  ||| 13
5  ||| 6
4  ||| 5
3  ||| 1

I've thought of using a Chord diagram (Python plotly module) but I just want to know if there are any better solutions out there.
Please advise.
Thanks!
Answer: This is one way that came to my mind; using a bar chart for before and after sorting the DataFrame. It might not be the best way though.
df = pd.DataFrame({'ID': [1,2,3,4,5], 'Map Score': [13, 15, 1, 5, 6]})

plt.bar(df['ID'], df['Map Score'], align='edge', width=-0.4, label='Before')
df_sort = df.sort_values(by='Map Score', ascending=False)
plt.bar(df['ID'], df_sort['Map Score'], align='edge', width=0.4, label='After')

plt.ylabel('Map Score')
plt.xlabel('ID')
plt.legend()


Where should I connect a C wire on my Goodman PGB030075-1 furnace?

Question: Is this where I can piggyback for c wire on Vine thermostat?

Thanks
Comment: Can you measure 24V from R to C on your control board?
Comment: I don't know will have to check, now I read on another thread "If there's an empty terminal on the transformer, connect there."  And as per picture about I have an empty middle terminal
Answer: Right part, wrong wire
While the terminal you have circled does attach to the transformer, it attaches to the primary side of the transformer (i.e. the AC mains side).  You need the secondary side common, which on your system is the blue wire coming off the transformer (if there are multiple blue wires leading to that terminal, you can tap any of them).
Comment: Shouldn't need to tap it there the board appears to have a C terminal at the bottom next to the G which should be connected to the transformer COM via board trace.
Comment: @DanD. -- can you point out where that C terminal is? I don't see one in the photo posted, nor is there one in the wiring diagrams in the manual I found...
Comment: It is on page 13 of the manual you linked to on the relay board you have to zoom in to read the terminal labels.
Comment: @DanD. -- that may be a different model of control than what the OP has...
Comment: No blue wire, please see the new picture
Comment: I found the c terminal and wired thernostat to it, didn't work, tested no power
Comment: Where did you find the C terminal at? Can you edit a photo of that into your question?
Comment: The top picture, the bottom right is where I found the c terminal
Comment: I may of hook the blue wire to the thermostat and black wire to c terminal wire.  Hot week here so will try later when the temperature comes down


Errors after upgrading Ubuntu from 19.04 to 19.10

Question: I was trying to download a package and I couldn't do it because the sources.list contained links that were deprecated.
While upgrading, I saw the following error:
<code> An upgrade from 'disco' to 'focal' is not supported with this tool.
</code>
So, I searched and came across this link Cannot upgrade from disco 19.04 to focal 20.04 after end of life using do-release-upgrade method
In it's comments, I came across this link https://tips.graphica.com.au/upgrading-from-retired-ubuntu-releases/
Briefly, I did the following steps:

Edited /etc/apt/sources.list to point to:
"deb http://old-releases.ubuntu.com/ubuntu" and not any other repository.
Ran sudo apt-get update && sudo spt-get upgrade
The 19.04 was fully updated and upgraded and I could install softwares from there.
I tried to now update to 19.10 and then to 20.04. For it, I ran command: do-release-upgrade
It said that disco to focal is not possible.
So, I followed the link specified earlier and I modified  ~/.cache/update-manager-core/meta-release
I found out that, there disco, eoan, focal were present in which only focal's supported parameter was 1 so I changed the supported parameter of Eoan and disco to 1 too
Then I ran the command do-release-command.
It was running smooth. 2 hours were past. I was left at a purple screen for half an hour. I pressed power off button and restarted the system with Ubuntu. The grub's look was a bit changed which specified that it got installed., but then when I clicked on Ubuntu, following error was present. This is the picture after I clicked on BIOS.
Comment: You shouldn't use the power button to shutdown the computer (didn't SysRq keys allow you to command the kernel to shutdown?  that's safer!). Given you did, like a power-outage, I'd suggest you boot a *live* media and `fsck` (or check your file-systems) before you attempt to boot your system. A re-install (without format) would have been faster & allowed skipping 19.10 jumping straight to 20.04 (and not touch user files, only system directories are wiped & packages re-installed).
Answer: You cannot upgrade from an unsupported release (19.04, and b.t.w., even your target release, 19.10, currently is not anymore supported). You always should remember upgrading while your current release is still supported.
At this stage, a fresh reinstall is your only option to install a newer and supported system.
Comment: A downvote, OK, but that is the answer nevertheless. Like it or not.


Font width returns incorrect values

Question: The following code should return the width in pixels of the character 'a' in the default font; it doesn't:
import pygtk
gtk.require20()
import gtk

t = gtk.TextView()
print t.get_style().get_font().width("w") # Always returns -6

Comment: t.get_style.string_width("test") doesn't work either as it only returns 6.
Answer: gtk.Style.get_font() is deprecated, as evidenced by the DeprecationWarning you get when you try to call it; I assume that's why it's not working. On my PyGTK there isn't any such function as gtk.Style.string_width().
You should use Pango:
import pygtk
pygtk.require20()
import gtk

t = gtk.TextView()
print t.create_pango_layout('w').get_pixel_size()

Font width returns incorrect values


Broadcasting (two) vectors in Eigen C++

Question: Suppose I have an input ArrayXd of size 3:
<code>P[1]
P[2]
P[3]
</code>
My required symmetric MatrixXd is of size [3,3]:
<code>-P[1]*P[1]+P[1]   -P[2]*P[1]         -P[3]*P[1]
-P[1]*P[2]        -P[2]*P[2]+P[2]    -P[3]*P[2]
-P[1]*P[3]        -P[2]*P[3]         -P[3]*P[3]+P[3]
</code>
Solution in pseudo code:
<code>-1.0 * P.broadcast.rowwise() * P.broadcast.colwise() + diag(P)
</code>
Problem:
The Eigen manual explains that you can broadcast a vector, but only in combination with a Matrix (or two-dimensional Array). How is it done with two vectors?
Answer: You're looking for an outer-product which is nothing else than a standard matrix product:
<code>-P * P.transpose() + P.asDiagonal()
</code>

Broadcasting (two) vectors in Eigen C++


How to prepare a rough concrete slab for pavers

Question: I tore my old wood deck out and am planning to lay pavers on top of the concrete slab that was beneath it.
I'm following the instructions here, photo below:

The inner paver bricks will have a layer of sand underneath them, so they will be level. But the border pavers are just glued down.
But this seems to be assuming the top of the concrete slab is finished... mine is very rough:

What can I do to level the concrete before laying the border pavers on top of it? Or is that not necessary, can I just glue them to the rough surface?
Comment: You could set your boarder in bed of mortar, this allows you to fill the voids and and adjust the height. Watch some brick laying / paver setting videos,
Comment: The sand is the leveler, you level the sand. (*screed Pipe is for leveling the sand*)   Your boarder will need to be set at the finished  height of the pavers **on** the sand.
Comment: isherwood: I added more pictures. It's only dark because of dirt/moss. I don't think it's asphalt
Comment: @ferret You mean use mortar everywhere?  That is probably your best bet for a successful project.
Comment: @AlaskaMan I'm asking about leveling the border, which in their instructions is glued, not placed on top of sand
Comment: That looks like asphalt. Is it? Concrete doesn't usually degrade in that pattern and it looks very dark.
Comment: Need to work out how much levelling you need in the middle before you can set the border height - unless you want the border to be alot below or worse case if you use alot of mortar alot above [unless of course that's a design feature :-)]
Comment: Getting the pavers the exact same height, with some glued and some floating on sand will a problem.  **If possible**,  could edging be added to the slab to contain the pavers...all floating on sand?
Comment: @Steve sounds like I will have to use sand/mortar everywhere since it's such an Uneven surface
Answer: My pa did a rather extensive paver back patio with curved steps, concentric pavers, a retaining wall and other challenges.  It looks beautiful.  Some of it is laid on existing concrete, some on packed gravel before the sand.  He used masonry mortar and concrete fill for the steps and edge pieces and it has definitely stood the test of time.  As mentioned in AlaskaMan's comment, the thickness of mortar allows you to lay the section in sand first and match the edge to the height of that.  After 25 years a small section of the lower patio has sunk about 3/4 inches because the gravel wasn't packed hard enough, but otherwise the whole thing is rock solid including parts without concrete base.  It will also deal with the unevenness of your pad, which to my eye does look like asphalt, as isherwood suggests.
One other note if you lay brick over solid pads, any drainage problems that exist with the pad will continue to exist under the sand.
Comment: So I would do the inner part first with sand, and then for the border I would put mortar on the concrete and pavers on the mortar?
Comment: Yep you just lay the pavers in mortar like ordinary brick and tap them into place with your trowel.  This does require that your pad be somewhat solid under it so if your edge isn't already square and you don't want asphalt peeking out you may want to rent a rock saw and cut the edge straight.  You could try to pour it square to enlarge it too, but that does appear to be asphalt, so if you pour concrete around it you may get a seam that has problems with frost cycling.
Comment: I would also cut some conduit or suitably thin tube in half lengthwise and lay it into the mud every few feet to make sure the edge doesn't contain water in the sand and cause a drainage problem.


Part of facebook Share Dialog (iframe) is not visible and I cannot move it

Question: I am using the following code to share some content from my website on facebook:
FB.ui({
    method: 'share',
    href: shareUrl
}, function(response){
    if (!response || response.error_message) {
        showError(response);
}});

This is what happens, the Share dialog (iframe) opens at the bottom-left corner of the screen:

after a few seconds my photo is loaded in the share dialog... but since the photo is large it pushes the share dialog beyond the screen... I am not able to move/drag the dialog either...
Is it possible to open the dialog somewhere else? or make it movable?
Answer: I found the behavior of facebook share dialog inconsistent... the iframe appears at the center of the screen in dev environment and it appears at the bottom-left corner of the screen in the test environment... I decided to make it a popup instead of an iframe:
FB.ui({
    method: 'share',
    href: shareUrl,
    display: 'popup'
}, function(response){
    if (!response || response.error_message) {
        showError(response);
}});

Here is facebook's share dialog documentation, which is not particularly useful anyways.