How do I get this weird screw back into this cone?

Question: I just bought a new armchair, and after screwing its legs in, I hit one of its feet ever so slightly against the floor and poof! Its foot flew right off.
It doesn't look broken, just displaced. I just need to get this round head of the screw back into the cone, but I just can't. Any tips?
The chair

The foot-cone that popped off the screw
Comment: I'm voting to close this question because furniture repair is off topic here per the [help].
Comment: I presume that when you got the chair, you got a bag of hardware that had the silver screw pushed through the gold cone. Part of the assembly was to turn the screw into a fitting in the bottom of the leg. Then, when moving the chair, the cone came off, but the screw stayed in place. Is this all correct? Have you tried holding the cone (foot) and turning the screw to simply screw it in?
Comment: Yeah, I'm not understanding what the problem is. "I just need to get this round head of the screw back into the cone, but I just can't." What does that mean?
Comment: Some analogue to a drift pin unless you have a scaffold builder or an ironworker for a neighbor. My knife has a [marlinspike](https://en.wikipedia.org/wiki/Marlinspike).
Comment: Might want to add a small washer to the screw so you have a greater hold on the foot.  I am guessing the foot came off and not the screw.
Comment: Try different angles of screw and shaft,  you may need to tap it a little.
Comment: Will the cone disassemble?
Comment: Are the feet visible at the bottom in the top picture the same cone piece as shown in the bottom picture?
Comment: Does the black thing we can see through the hole in the cone come off?  If so, remove it and thread the bolt back in through the hole.  You may need to squish the hole a little, since it's obviously hogged out to allow it to come off the bolt.
Comment: why don't you look at one of the other three feet? ... you are missing something
Comment: Thanks for your help everyone. I took the foot and the screw to a glass repair shop (because I was visiting one anyway), and the handyman there managed to pry open the foot with a flat screw driver, placed the screw back in, and then pressed the hole back in with a drift pin.
Answer: What did the manufacturer say when you contacted them to complain about this? I'm sure you are far from the first this has happened to, and they probably have standard advice and/or s standard kit for the repair.
If you're too embarrassed to ask (why?)... This looks like it was assembled by driving the screw from inside the cone, then snapping the plastic foot onto the bottom of the cone. So I'd start by investigating whether the latter can be unsnapped. But it may have been some kind of crimp installation that is hard to undo and redo.
Answer: I would get a washer with a hole that the screw just fits through, then adjust, with a hammer & drift, the washer so that it matches the angle of the screw head and cone.
That should stop the screw pulling through the cone.
Edit based on a comment - I would be looking at how to get the "foot part or face" off the cone to access the interior of the cone. It may be that the cone edge has been swagged over or even soldered...
Comment: @Freeman more pictures of the cone may help - perhaps the other face comes off...
Comment: That sounds like it might help _after_ the OP gets the screw back into the cone, which is what he asked about.
Answer: Oh no! To fix the issue, try using a rubber mallet or a piece of wood and gently tap the round head of the screw back into the cone. Applying some pressure while tapping might help secure it back in place without causing damage.


Cannot connect to Team Fortress 2 item server?

Question: It says "loadout not available - no connection to Steam"...what? What does this mean? I'm pretty sure I'm connected to Steam.
Answer: This happens to me every once in awhile.  Sometimes it fixes itself if you don't play for a bit (and by that I mean an hour up to a day) but if it doesn't fix itself, try restarting steam or your computer.


Download a file from a website that uses doPost request Java

Question: I'm new to java. I'm trying to write a code that download file from these web sites https://servizissiir.regione.emilia-romagna.it/FlussiMTS/ and https://www.ilmeteo.it/portale/archivio-meteo.
in both web sites, before starting download, the user has to set to parameters.
For the second one I use successfully this code because I can insert parameters in the URL .
<code>public class Downloader {

    public static void main(String[] args) {
        String remoteFile = "https://www.ilmeteo.it/portale/archivio-meteo/Bologna/2021/Gennaio?format=csv";
        String localFile = "src/Bologna.csv";

        try {
            FileUtils.copyURLToFile(new URL(remoteFile), new File(localFile), 20000, 20000);
        } catch (IOException ex) {
            System.out.println(ex.getMessage());
        }

    }
}
</code>
But with the first one I can't use the URL. The URL I see when I start download is https://servizissiir.regione.emilia-romagna.it/FlussiMTS/MobiliterServlet
So I think parameters are sent to a doPost servlet.
If I put this URL in the previous code I obtain a damaged rar archive in my local folder.
Comment: The first URL is just an HTML page, not a CSV. There is no way for you to know what HTTP method or "servlet method" handles the request to get a CSV file unless you have the source code
Answer: i found this solution
`
<code> public static void PostRequest(String url, int i) throws IOException, InterruptedException {
    RequestConfig rc = RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build();
    CloseableHttpClient client = HttpClients.custom().setDefaultRequestConfig(rc).build();
    HttpPost httpPost;
    ArrayList<NameValuePair> postParameters;
    httpPost = new HttpPost(url);
    postParameters = new ArrayList<NameValuePair>();
    postParameters.add(new BasicNameValuePair("forward", "esportaReportCSV"));
    postParameters.add(new BasicNameValuePair("yearPromptName", "AnnoMese:"));
    postParameters.add(new BasicNameValuePair("esportaReportCSV", ""));
    postParameters.add(new BasicNameValuePair("tipoIntervallo", "M"));
    postParameters.add(new BasicNameValuePair("AnnoMese:", "202108"));
    postParameters.add(new BasicNameValuePair("prompt", "Nessuno"));
    httpPost.setEntity(new UrlEncodedFormEntity(postParameters, "UTF-8"));
    CloseableHttpResponse response = client.execute(httpPost);
    HttpEntity entity = response.getEntity();
    if (entity != null) {
        if (response.getEntity().getContentType().getValue().trim().equals("application/zip")) {
            String name = response.getFirstHeader("Content-Disposition").getValue();
            String fileName = name.replaceFirst("(?i)^.*filename=\"([^\"]+)\".*$", "$1");
            FileOutputStream fos = new FileOutputStream("path/" + fileName);
            entity.writeTo(fos);
            fos.close();
            System.out.println("Download success!");
        } else if (!response.getEntity().getContentType().getValue().trim().equals("application/zip") && i < 10) {
            i++;
            PostRequest(url, i);
        } else if (!response.getEntity().getContentType().getValue().trim().equals("application/zip") && i == 10) {
            System.out.println("Download failed!");
        }
    }
    client.close();
}

public static void GetRequest(String url, int i) throws IOException, InterruptedException {
    RequestConfig rc = RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build();
    CloseableHttpClient client = HttpClients.custom().setDefaultRequestConfig(rc).build();
    HttpGet httpGet = new HttpGet(url);
    httpGet.setHeader("User-Agent", "User-Agent");
    CloseableHttpResponse response = client.execute(httpGet);
    HttpEntity entity = response.getEntity();
    if (entity != null) {
        if (response.getEntity().getContentType().getValue().trim().equals("text/csv")) {
            String name = response.getFirstHeader("Content-Disposition").getValue();
            String fileName = name.replaceFirst("(?i)^.*filename=\"([^\"]+)\".*$", "$1");
            FileOutputStream fos = new FileOutputStream("path/" + fileName);
            entity.writeTo(fos);
            fos.close();
            System.out.println("Download success!");
        } else if (response.getEntity().getContentType().getValue().trim().equals("text/html") && i < 10) {
            i++;
            GetRequest(url, i);
        } else if (response.getEntity().getContentType().getValue().trim().equals("text/html") && i == 10) {
            System.out.println("Download failed!");
        }
    }
    client.close();
}

public static void main(String[] args) throws IOException, InterruptedException {
    PostRequest("https://servizissiir.regione.emilia-romagna.it/FlussiMTS/MobiliterServlet" , 1);
    GetRequest("https://www.ilmeteo.it/portale/archivio-meteo/Bondeno/2020/Agosto?format=csv", 1);
    }
</code>
`
I also wrote the HTTP Get solution
to work the code needs the following jar files:
httpclient-4.5.6.jar
httpcore-4.4.10.jar
commons-codec-1.10.jar
commons-logging-1.2.jar
parameters and the http method can be found through a browser's developer tools


Serana disappeared during dawnguard questline.

Question: I am doing the Dawnguard questline and I was getting the last elder scroll from septimus sigmus.
I told her to wait while I was doing stuff with the lexicon as she kept getting in my way.
She did however follow me out when we were finished we then went to the dawnguard to talk to the moth priest and we now have to find a moth priests knife.
I went to Riverwood to feed and I'm not sure if she went there with me or not but I have not been able to find her at all throughout the rest of my game play. Nothing on google has helped me it's like she has just vanished from the game even though I still need her for quests.
Answer: First of all, check Fort Dawnguard or Volkihar Keep (depends on whom you sided with), since that's where she should reappear when she gets lost.
Otherwise, if you're playing on PC, you can use the console to either teleport to Serana via
player.moveto xx002B74

or her to you via
prid xx002B74
moveto player

Note that the xx has to be replaced by a number, usually one of 01, 02, 03 depending on the DLCs installed. You can also use help Serana to figure out the correct value.
Should you be on a console instead of PC, you probably will need to convert the savegame to PC, ask a friend with the PC version to do the above, and convert it back. Make sure that friend activates exactly the same DLCs and mods though, otherwise the re-converted savegame might fail to load.
Comment: Nitpick: Teleporting the player to Serana may be a Bad Idea if she has somehow gotten herself into some weird location where the game breaks.  Teleporting her to the player is probably safer.
Answer: If your on the dawnguard side just go back to fort dawnguard if she isnt there just leave and wait a couple days.


Evaluate the double integral with sin/cos

Question:
$$\iint_\limits{D}\sin(x)\cos(y) dA$$ where $A$ is bounded by $y = 1 + x, y = 1 - x, y = 0$.

So this is obviously a triangle region, lets split it into 2 region such that $D_1 + D_2 = D$.
Lets calculate: $\iint_\limits{D_1}\sin(x)\cos(y) dA$ first.
If I fix $y$ from say $0 \to 1$, then I get $x_{\text{left}} = -1$ and $x_{\text{right}} = 0$.
So I should get
$$\iint_\limits{D_1}\sin(x)\cos(y) dA = \int_{0}^{1} \int_{-1}^{0} \sin(x)\cos(y) dx dy = \sin(1) \cdot (\cos(1)  -1)$$
But this isnt right. How do I make sure I am getting the right limits?
Answer: How about  $\int_0^1\int_{y-1}^{1-y}\sin (x)\cos (y)dxdy $.  We get  $\int_0^1\cos (y)(-\cos (1-y)+\cos (y-1))dy =O $ because  $\cos  (x) $ is an even function.
Comment: Type \sin x, \cos x, \tan x, \csc x, \sec x, and \cot x, respectively, when you are in math mode to obtain $\sin x$, $\cos x$, $\tan x$, $\csc x$, $\sec x$, and $\cot x$.
Comment: But why doesnt my approach work?
Comment: Why are the limits from y -1 to 1 - y instead of -1 to 0??
Comment: You integrated over a rectangle.   You need variables in the limits of your first integral. ..
Comment: I solved for $x$ in terms of  $y$.  You could do it the other way :  $(x-1)$ to $(x+1)$, and $-1$ to $1$...
Answer: You let $y$ go from $0$ to $1$.  When $y$ is at some value, say $y=1/2$, then the range for $x$ is not $-1$ to $0$.  The left bound is the line $y=1+x$ and when $y=1/2,$ the left limit for $x$ is $-1/2$.  And it's different for every value of $y$.  So the $x$ limits can't be $-1$ to $0$.  They have to depend on $y$.
In general, as $y$ goes from $a$ to $b$, then $x$ goes from "left-function of $y$" to "right function of $y$".   (Or as $x$ goes from $a$ to $b$, then $y$ goes from "bottom function of $x$" to "top function of $x$.")  A region that can't be expresses in one of these two ways needs to be cut into regions which can be.
Comment: Thanks, I needed the logic behind it


PHP to Oracle using oci8/MDB2 - _doConnect: unable to establish a connection

Question: I'm running a Linux Fedora 19 setup with Oracle 11g, PHP 5.5.4, Apache 2.4.6, and PEAR 1.9.4. In addition to this, I have the OCI8 plug-in for PHP downloaded and enabled, and have downloaded MDB2 and the MDB2_Driver_oci8.
The goal is to connect my webpage to the Oracle 11g database. This already works in an existing setup (which I didn't do), and I'm trying to replicate it in a new setup.
For some reason, in the new server, it doesn't work. It generates an error:

_doConnect: [Error message: unable to establish a connection]
  ** oci8 (oci8)://gbsihr:xxx@localhost:1521/
An error occurred while trying to connect to the database server.
  Error message: MDB2 Error: connect failed

I truly have no idea what this means. This is my PHP connect function:
<?php
include_once('includes/configure.inc');
require_once 'MDB2.php';

function DB_connect($intSilent = -1){
    $db_dsn = $_SESSION['DB_Type'] ."://";
    $db_dsn .= $_SESSION['DB_Username'] .":";
    $db_dsn .= $_SESSION['DB_UserPassword'] ."@";
    $db_dsn .= $_SESSION['DB_Host'] .":";
    $db_dsn .= $_SESSION['DBPort'] ."/?service=";
    $db_dsn .= $_SESSION['DB_DbName'];

    if (PEAR::isError($dbconnect)) {
        print '
';var_dump($intSilent);print '
';
        print '
';var_dump($db_dsn);print '
';
        print '
';print $dbconnect->getDebugInfo();print '
';
        echo "An error occurred while trying to connect to the database server.
\n";
        echo "Error message: " . $dbconnect->getMessage() . "
\n";
        echo "A more detailed error description: " . $dbconnect->getDebugInfo() . "
\n";
        exit();
        // Check whether the object is a connection or
        if($_SESSION["gENDebugInfo"] == "On"){
            $_SESSION["gErrorNote"] = $dbconnect->getDebugInfo();
        }
        if ($intSilent < 0) {
            header("Location:" . $_SESSION["gENWebRoot"] . "showerror.php?ec=1003"); // Failed to connect
            exit();
        }
    }else{
        $dbconnect->setOption('portability', MDB2_PORTABILITY_ALL);
    }
    return $dbconnect;
}
?>

And this is the contents of configure.inc:
$_SESSION["gENWebRoot"] = '/hrweb/';
$_SESSION['DB_Type'] = 'oci8';
$_SESSION['DB_Host'] = 'localhost';
$_SESSION['DB_Username'] = 'gbsihr';
$_SESSION['DB_UserPassword'] = 'ids21';
$_SESSION["DBPort"] = '1521';
$_SESSION['DB_DbName'] =  'xe';

As this works on another setup, I'm not sure where the error lies. OCI8 seems to be in order, though I did go through hoops to get it working.
I did do some research, with only two vague results - one pointing to the oci8.php itself, and the other, an Oracle TNS error (unlikely, given the lack of errors).
Here are my attempts to solve the problem:
I tried copying the Basic Query Example from this website. I modified the "hr" and "welcome", and ran it on my new setup (it works fine on the older one). And this is the result:

oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with
  your system - please check that ORACLE_HOME and LD_LIBRARY_PATH are
  set and point to the right directories.   Error while trying to
  retrieve text for error ORA01804

I've also tried opening the httpd file in /etc/sysconfig/ and adding the following line to it:

LD_LIBRARY_PATH="/u01/apps/oracle/product/11.2.0/xe/lib
  export LD_LIBRARY_PATH

And yet when I try to echo $LD_LIBRARY_PATH in the CLI, it won't return anything. It does appear in phpinfo(), though:

This is in contrast to $ORACLE_HOME, which I have to load manually every start-up by typing in . /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh in the CLI, and does not appear under environments, but at least, can be echo'd.

There are a lot of variables in the old setup under environment; LD_LIBRARY_PATH, ORACLE_HOME, and ORACLE_SID being the most noteworthy. I only see LD_LIBRARY_PATH in the envvars file, though. Should I add them as well to the httpd file?
I'm not much of a Linux-person, sorry. Any help on this would be much appreciated.
Comment: Besides oci8 functions you could also try PDO.
Answer: I suggest you try to connect to your oracle database by using the plain oci8 functions and the same login parameters as you use for MDB2.
My guess is that this will fail as well, but might give you more error details.
Comment: update your question with the new code. where exactly does the error occur? during connection? during querying? during fetching? Also, did you use `oci_error()` to fetch the error message?
Comment: I've updated my question. The error of the new PHP file happens at line 3, which oci_connect. I've tried this on the older setup and it fetches everything fine. I've concluded that this is the result of a setup error, or something, but I fear that solving this side-problem might not actually solve the first one.
Answer: Can you connect to oracle outside of php?
I presume you have a valid tns.ora file set up.
I needed these two lines set in my VirtualHost definition, note TNS_ADMIN is defined also, perhaps you do too:
SetEnv ORACLE_HOME /opt/oracle/instantclient
SetEnv TNS_ADMIN   /usr/lib/oracle/11.2/client/network/admin/network/admin**

Comment: I can use Oracle SQL Developer from another machine to connect to the database. I have a Java program that tries, but gives me a pretty generic error: `Io exception: The Network Adapter could not establish the connection`
Answer: Just add this line

$dbconnect = DB::connect($db_dsn);

to function DB_connect
like this
...
$dbconnect = DB::connect($db_dsn);
if (PEAR::isError($dbconnect)) { ...


NSCalendar date error when converting to Hijri Calendar

Question: While converting a Gregorian calendar date to Hijri calendar date, it's one day behind  if we use NSIslamicCalendar and one day ahead when we use NSIslamicCivilCalendar.
I use below code for conversion:
NSTimeInterval seconds = [timeStampValue doubleValue];
NSDate *epochNSDate = [[NSDate alloc] initWithTimeIntervalSince1970:seconds];
NSCalendar *islamicCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSIslamicCalendar];
NSDateFormatter *dateFormatter =[[NSDateFormatter alloc] init]; [dateFormatter setCalendar:islamicCalendar];
[dateFormatter setDateStyle:NSDateFormatterFullStyle];
dateFormatter.locale =[[NSLocale alloc] initWithLocaleIdentifier:@"ar_SA"];
NSString * islamicDateString = [dateFormatter stringFromDate:thisDate];

UPDATE
I will add more details to the questions with examples.
First I have tried with NSIslamicCalendar:
We got the NSDate: 2014-06-17 14:00:04 +0000
After converting to NSIslamicCalendar: Tuesday, Shaʻban 20, 1435 AH
Correct date: Tuesday, Shaʻban 19, 1435 AH
with NSIslamicCivilCalendar:
We got the NSDate: 2014-06-17 14:00:04 +0000
After converting to NSIslamicCivilCalendar: Tuesday, Shaʻban 18, 1435 AH
Correct date: Tuesday, Shaʻban 19, 1435 AH
Please help us to fix this problem.
Comment: What is the date you are getting and what is the date you are expecting and why?  It seems like this conversion is pretty complicated (days start at sunset, etc?)
Comment: I have added some more details to the question.
Comment: From my limited research it seems that Sha'ban 20 would start at sunset on June 17th.  Is that right? What time zone are you doing this calculation from?
Comment: We are using epoch value to get the date. I think epoch value will always be in UTC/GMT.
Comment: A date is a date, the time zone information in the date is only relevant once you convert it to a string.  Just for fun, try an earlier value like June 17, 2014 00:00:00 +0000 and see what happens.
Comment: I tried that and I am getting the result as  Tue,18 Shaʻban 1435 05:30:00 +0530
Comment: Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/55831/discussion-between-shaan-and-borrrden).
Comment: Try using NSCalendarIdentifierIslamicTabular..
Answer: Salam. There is nothing wrong with the API. Please refer to this thread for an explanation.
NSIslamicCalendar and NSIslamicCivilCalendar
You need to choose which type of Islamic Calendar to use. Essentially, the hijri is based on moon sightings and therefore most prayer apps include a manual correction to allow the user to update the date should the date be incorrect.
The API is simply a predictive calendar when it comes to the hijri.
Comment: Do you know how to add day correction for hijri calendar?


Should I update every component as standalone?

Question: I'm a bit confused with the latest Angular update concerning standalone components. I read they are more efficient, but does this imply that every component (mid-size project) should be migrated to being a standalone component?
While it may be more efficient, with e.g. lazy loading, I thought that you have to import way too many modules for each component. Even though Angular does this automatically when migrating, I am unsure about future additions to the code :/
Can someone explain if or why I should migrate my project fully to consist of standalone components?
Answer: I recommend opting for standalone components and eliminating the ngModule structure. As outlined in this post, adopting standalone components can lead to a more optimised tree structure for your application.


NCrunch Won't Build After Deleting Extra Solution Configurations

Question: We had a solution with several additional solution configurations beyond the typical Debug and Release, and are going back to simply a Debug and Release. A few projects did not have a Debug build, or did not have a Release build.
I have:

Re-added Debug and Release to each project where missing
Changed solution config to Debug
Deleted the extra solution configurations
Changed each project to Debug (projects now match solution)
Deleted the web.*.config transforms

NCrunch is now reporting:

The OutputPath property is not set for project
  'nCrunchTemp_fab725ec-f404-4afe-9916-c4edb033c2bc'.  Please check to
  make sure that you have specified a valid combination of Configuration
  and Platform for this project.  Configuration='Local'
  Platform='AnyCPU'.  You may be seeing this message because you are
  trying to build a project without a solution file, and have specified
  a non-default Configuration or Platform that doesn't exist for this
  project.
NCrunch: This error is commonly caused by projects that are relying on
  the selected build configuration provided by Visual Studio in order to
  set the $(Platform) and $(Configuration) MSBuild  properties during a
  build.  Unless configured otherwise, NCrunch will normally use the
  default $(Configuration) and $(Platform) properties that are specified
  in a .proj file - thus in order for your project to  build with
  NCrunch it must be possible to build the project using command line
  MSBuild without needing to manually inject build properties.  You will
  most likely need to edit your .proj file to align its default
  $(Configuration) and $(Platform) properties with the property groups
  provided in the file.

"Local" is one of the old solution configurations.
I have looked for where NCrunch is picking up Local and cannot find it in any of the config screens or files.
The solution builds from Visual Studio in both Debug and Release configurations. It does not build with NCrunch. I've tried closing and reopening VS which made no difference.
Answer: Two additional changes were made - manual edits to the project file.

Project file still had default set to Local:
<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Local</Configuration>`

Manually edit this to say Debug.
That fixed most of the broken projects. One was still broken, with exact same error. In that project, the above  which sets the output path appeared BEFORE the property group which sets the default configuration. Thus, when the output path was evaluated, the configuration was blank, instead of Debug.
This line needs to appear after the default configuration line:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
    <OutputPath>bin\</OutputPath>
</PropertyGroup>`


Showing Sum through JLabel

Question: I'm a newbie to java, i just want to make a simple JFrame which takes two numbers as input through JtextFields, sum them and return the answer through JLabel... but it simply doesn't do it what it suppose to do, here is my code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.util.*;
public class gUi extends JFrame {
    private JLabel lbl;
    private JLabel lbl2;
    private JLabel lbl3;
    private JTextField tb;
    private JTextField tb1;
    private int num1;
    private int num2;
        public gUi(){
        super("Sum Dialog");
        setLayout(new FlowLayout());
        lbl = new JLabel("1st Number:");
        add(lbl);
        tb = new JTextField(15);
        add(tb);
        tb.addActionListener(new ActionListener()
        {
        public void actionPerformed(ActionEvent event){
         num1 = Integer.parseInt(tb.getText());
        }
        });
        lbl2 = new JLabel("2nd Number");
        add(lbl2);
        tb1= new JTextField(15);
        tb1.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent event ){
                num2= Integer.parseInt(tb1.getText());
            }
        });

        add(tb1);
        int sum= num1+num2;
        String ssum = Integer.toString(sum);
        lbl3 = new JLabel();
        lbl3.setText(ssum);
        add(lbl3);
    }
    }

import java.awt.*;
import javax.swing.*;
public class Main {

    public static void main(String[] args) {
        gUi g =new gUi();
        g.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        g.setVisible(true);
        g.setSize(180, 160);

    }

}

It Compiles Alright but not showing sum through JLabel when I put some intergers
through Textfields...
I am having this problem for a week and tried different things that I know so far but problem persists...
Comment: `int sum= num1+num2;` This piece of code will execute "immediately" and only once, and `num1` and `num2` are still `0`. The sum has to always be recalculated in your `actionPerformed` methods as well as the text of the sum label.
Comment: Hint: learn about java naming conventions. Class names go UpperCase; always. And avoid using "abbreviations" within your names, even "AddingNumbersFrame" or something like that would be more telling than "gUI".
Answer: You shouldnt put action listeners on your textfields (well, of course you can; but there are other options here).
You could add a button to your frame, maybe with the text "add". And whenever that button is clicked, you fetch the two values, add them; and push them into that third textfield.
As of now, your code is computing the sum of 0+0 only once; while your constructor is invoked. Instead, you have to make sure that this computation happens "later on" - when the user asks for it to happen!
But for the record: if you put the same action listener on your text fields, that would work, too. If that action listener simply fetches both labels, adds them, and puts the sum into field number 3.
Comment: You are very welcome. You might want to check for the updates I made to my answer. And of course: dont forget to accept that answer you think helped the most.
Answer: You have created a JLabel and setted its initial value to 0 (because initially both num1 & num2 are 0 ). What you need is to refresh the JLabel(recalculate & display the current sum in action performed method).
E.g.
private void updateSum() {
    lbl3.setText(String.valueOf(num1+num2));
}

And invoke it in action listener of textfield 1
tb.addActionListener(new ActionListener()
        {
        public void actionPerformed(ActionEvent event){
         num1 = Integer.parseInt(tb.getText());
            updateSum();

        }
        });

and textfield 2
tb1.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent event ){
                num2= Integer.parseInt(tb1.getText());
                updateSum();
            }
        });

Comment: Thanks a lot Sir! with the help of you guys i hope i will learn quickly.... thanks again!
Comment: Glad it helps :). Remember you can always upvote the answers which you find useful
Answer:
Have a look at the code below(includes comments):

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

/**
 * Shows a Stage that has two text Fields
 *
 */
@SuppressWarnings("serial")
public class UserInterface extends JFrame {

    private JLabel label1;
    private JLabel label2;
    private JLabel label3;
    private JTextField textField1;
    private JTextField textField2;

    /**
     * Constructor
     */
    public UserInterface() {
        super("Sum Dialog");

        // Layout
        setLayout(new FlowLayout());

        // 1st JLabel
        label1 = new JLabel("1st Number:");
        add(label1);
        textField1 = new JTextField(15);
        add(textField1);

        // 2 second JLabel
        label2 = new JLabel("2nd Number");
        add(label2);
        textField2 = new JTextField(15);
        add(textField2);

        // 3 third label
        label3 = new JLabel();
        label3.setSize(200, 30);
        add(label3);

        JButton button = new JButton("Calculate");
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                // calculate the sum when the Button is pressed
                int sum = Integer.parseInt(textField2.getText()) + Integer.parseInt(textField2.getText());
                label3.setText(Integer.toString(sum));
            }
        });
        add(button);

    }

    /**
     * Main method of the application
     *
     * @param args
     */
    public static void main(String[] args) {
        UserInterface main = new UserInterface();
        main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        main.setVisible(true);
        main.setSize(180, 160);

    }

}

Comment: Thank You Very Much GoXR3Plus! all of You people are very helpful... I really Appreciate it... it helped a lot.....
Comment: @Waleed Sagher :) After using Swing you should pass on JavaFX.

Showing Sum through JLabel


How to put youtube video on the same site

Question: If you go to the official website of Overwatch (https://playoverwatch.com/en-us/) and click on the "WATCH TRAILER" button, the youtube video will appear on the same website without having to direct you to the original youtube page where that video came from. How did they do that?
Comment: Youtube provides an embed tag for every video which you insert in your page HTML.
Answer: It's called using embed videos. you can do it with using iframes
YouTube Video Id
YouTube will display an id (like vhjTYfG), when you open video. You can use this id, and refer to your video in the HTML code.
To play your video on a web page, do the following:
- Upload the video to YouTube
- Take a note of the video id
- Define an  element in your web page
- Let the src attribute point to the video URL
- Use the width and height attributes to specify the dimension of the player
- Add any other parameters to the URL (see below)

This is an example code,

*Read more here. w3schools
Answer: Mr Vishwa is right. I just wanted to add.
Please have a look at this url
https://developers.google.com/youtube/iframe_api_reference
playoverwatch.com is using a similar technology


If $\lim\limits_{x\to a}f(x)$ exists, and $\lim\limits_{x\to a}[f(x) + g(x)]$ exists, does it follow that $\lim\limits_{x\to a}g(x)$ exists?

Question: This is a question from Spivak's Calculus. Question statement:
If $\lim\limits_{x\to a}f(x)$ exists, and $\lim\limits_{x\to a}[f(x) + g(x)]$ exists, does it follow that $\lim\limits_{x\to a} g(x)$ exists?

I have not been able to find a counterexample, so it seems that it exists. Here is my attempt at proof, and I'm mostly interested in validity of my proof.

Following is given:
$\forall \epsilon, \exists \delta_1: 0 < |x-a| < \delta_1 \Rightarrow |f(x) - L_1| < \epsilon$
$\forall \epsilon, \exists \delta_2: 0 < |x-a| < \delta_2 \Rightarrow |f(x) + g(x) - L_2| < \epsilon$
Let $\delta_2 \le \delta_1$. If greater $\delta_2$ works, then smaller one will of course work, and if smaller one works than that inequality follows from that.
Let $L_2 - L_1 = L_3$, that is $L_2 = L_3 + L_1$. Then we substitute:
$|f(x) + g(x) - L_1 - L_3| < \epsilon$
$|(g(x) - L_3) - (L_1 - f(x))| < \epsilon$
And by the inequality $|a-b| \ge |a| - |b|$:
$|g(x) - L_3| - |L_1 - f(x)| \le  |(g(x) - L_3) - (L_1 - f(x))| < \epsilon$
$|g(x) - L_3| - |f(x) - L_1| < \epsilon$
$|g(x) - L_3| < \epsilon + |f(x) - L_1|$
Since $\delta_2 \le \delta_1$, we can always choose epsilon greater than $|f(x) - L_1|$ so we can make substitution:
$|g(x) - L_3| < 2\epsilon$
And we can make $2\epsilon$ as small as we wish. This completes the proof.

Thank you for any help!
Comment: Do you already know that if $\lim\limits_{x\to c} F(x)$ exists and $\lim\limits_{x\to c} G(x)$ exists, then $\lim\limits_{x\to c}(F-G)$ exists? If so, set $F=f+g$ and $G=f$.
Comment: @Lovre: Your proof is valid; it can be streamlined a bit if you simply start from $|g(x)-L_3|$ and use the regular triangle inequality:\begin{align*}|g(x)-L_3| &= |g(x)-L_3 + f(x)-f(x)+L_2-L_2|\\\ &= |(g(x)+f(x)-L_2)-(f(x)-(L_2-L_3))|\\\ &\leq |g(x)+f(x)-L_2|+|f(x)-L_1|.\end{align*}
Comment: @Lovre: Concerning your desire to know whether you have a good grasp on the concepts: I think so, but it seems you may not have completely internalized the $\epsilon/\delta$ paradigm. I find the easiest way to understand it is as a two-player game: Player A comes up with an $\epsilon$, and Player B has to come up with a $\delta$ to make the inequalities come out right. The limit is proved if Player B can always win. I suggest you look at your proof and try to see how you slightly confused the roles of the $\epsilon$ being given (which you called $2\epsilon$)...
Comment: Your proof is OK, except for the formulation "we can always choose epsilon greater than" -- you can't choose $\epsilon$, since you have to find $\delta$ for given $\epsilon$ -- but the proof works nevertheless -- a better way to express what you're doing would be to say that you choose $\delta=\min(\delta_1,\delta_2)$; then both inequalities with $\epsilon$ hold for $\lvert x-a\rvert<\delta$. Also, it would be clearer and more precise if you chose $\epsilon/2$ for $L1$ and $L2$ at the outset and then ended up with $\epsilon$ at the end, since you want to show $\lvert g(x)-L_3\rvert<\epsilon$.
Comment: Ooooh. Thanks very much, very neat way... Didn't occur to me. Though I'm still wondering if my proof is correct, because I want to know whether I have good grasp on concepts or I have a gap in knowledge somewhere.
Comment: @joriki I see, thanks for the help.
Comment: @Lovre: ... and the ones that you were allowed to choose (which you called $\epsilon$ but should more appropriately have called $\epsilon/2$), i.e. think about where you were in the role of Player B and where you were in the role of Player A, and hence had to accept a given $\epsilon$ or were allowed to choose an $\epsilon$, respectively.
Comment: @Joriki: That's a neat way of looking at it, thanks. I had similar way of looking at it but this further helped.
Answer: So it can be marked off as answered...

Do you already know that if $\lim\limits_{x\to c}F(x)$ exists and $\lim\limits_{x\to c} G(x)$ exists, then $\lim\limits_{x\to c}\bigl(F(x)-G(x)\bigr)$ exists? If so, set $F(x) = f(x)+g(x)$ and $G(x) = f(x)$ to get the desired result.
The proof is (essentially) valid; it can be streamlined a bit if you simply start from $|g(x)-L_3|$ and use the triangle inequality:
\begin{align*}|g(x)-L_3| &= |g(x)-L_3 + f(x)-f(x)+L_2-L_2|\\
&= \left|\Bigl(g(x)+f(x)-L_2\Bigr)-\Bigl(f(x)-(L_2-L_3)\Bigr)\right|\\
&\leq \left|\Bigl(g(x)+f(x)\bigr)-L_2\right|+\Bigl|f(x)-L_1\Bigr|\\
&\lt 2\epsilon.
\end{align*}
Answer: I think your demonstration is correct. Maybe it is "more elegant" to take $\epsilon/2$ in the following sentences:
∀ϵ,∃δ1:0<|x−a|<δ1⇒$|f(x)−L_1|$<ϵ/2
∀ϵ,∃δ2:0<|x−a|<δ2⇒$|f(x)+g(x)−L_2|$<ϵ/2,
in a way that $|g(x)-L_3|<\epsilon$, given that $|x-a| < \delta_2$.
Note that this is the same as the following: If $\lim_{x\to a} f(x) = L$ and $\lim_{x\to a} h(x) = M$, then $\lim_{x\to a} [f(x)+h(x)] = L+M$.
Comment: In the last sentence I wrote, we assume the two limits $lim_{x\to a} f(x)$ and $lim_{x\to a} h(x)$ exist, and the conclude that the limit of the sum exists. The connection to your question is made writing $h(x) = - [f(x) + g(x)]$ (whose limit exists).
Comment: Thanks for the answer. :) But isn't that last thing proved for "if such limits exist", and we can't infer that it wouldn't exist if one of the limits didn't exist?
Comment: @Lovre: Writing $\lim_{x\to a}f(x) = L$ means "the limit exists, **and** is equal to $L$". Perhaps you are confusing it with$$\lim_{x\to a}(f+g) = \lim_{x\to a}f + \lim_{x\to a}g,$$which only holds "if all limits exist" (or more precisely, "if at least two of the limits exist", in which case all three will).
Comment: @Arturo: Actually, I think that was my point. What I wanted to say was that I wanted to prove that, as you say "if at least two of the limits exist" then all three will, where f+g and f are given to exist, while Ronaldo in last sentence outlined case when f and g exist.


SQL statement error for a sum with two conditions in Where clause

Question: OK so I am using MVS 2015 to right a database using windows Forms and C#
This is what I coded
internal static decimal getExpenseSum(int parsedProjectID, string type)
    {
        decimal value = decimal.Zero;
        string query = "SELECT sum(TotalReceiptAmount) " +
                        "FROM Expense WHERE ProjectID = " +
                        parsedProjectID + " AND Type = " + type;
        SqlCommand cmd = new SqlCommand(query, conn);
        conn.Open();
        value = Convert.ToDecimal(cmd.ExecuteScalar());
        conn.Close();
        return value;
    }

And I am getting a exception stating that the column name 'Parts' is not a valid column name. when "Parts" is the type string sent to the function.
Comment: I don't see any 'Parts' in the code you provided
Answer: You need to quote your type parameter, otherwise it will be interpreted as a column name instead of a value:
string query = "SELECT SUM(TotalReceiptAmount) " +
               "FROM Expense WHERE ProjectID = " +
               parsedProjectID + " AND Type = '" + type + "'";

                                              ^            ^

Better yet is to use prepared statements to

handle parameter types automatically;
safeguard your code against sql injections;
optimize query execution.
Answer: type is varchar/string type, surround it with quotes:
string query = "SELECT sum(TotalReceiptAmount) " +
                    "FROM Expense WHERE ProjectID = " +
                    parsedProjectID + " AND Type = '" + type + "'";
                                                   ^____________^

For better readability do this for your varchar/string types:
type = "'" + type + "'";
string query = "SELECT sum(TotalReceiptAmount) " +
                    "FROM Expense WHERE ProjectID = " +
                    parsedProjectID + " AND Type = " + type ;

Answer: It seems like the string that you send to function - 'Parts' should be in quotes  when you compare for e.g. the resulting query from your code should  be :
SELECT sum(TotalReceiptAmount) FROM Expense WHERE ProjectID =                        parsedProjectID AND Type = 'Parts';

Answer: New error Object cannot be cast from DBNull to other types.
using
internal static decimal getExpenseSum(int parsedProjectID, string type)
    {
        decimal value = decimal.Zero;
        type = "'" + type + "'";
        string query = "SELECT sum(TotalReceiptAmount) " +
                        "FROM Expense WHERE ProjectID = " +
                        parsedProjectID + " AND Type = " + type;
        SqlCommand cmd = new SqlCommand(query, conn);
        conn.Open();
        value = Convert.ToDecimal(cmd.ExecuteScalar());
        conn.Close();
        return value;
    }

Answer: OK so that worked but I am doing it three times for ""Parts"" ""Tools"" and """other"" and of course Ive just only entered one for parts and then the form goes back to the project form and tries to do theese sums and there is nulls for Tools and Other. so Ill have to do a try catch.....
 but thank you all for the solve....
That is the meat of my project if you will workflow add customer....
Now on to adding projects to existing customers and then reports. YEAH and once again thank you


How can I stop primer from eating my roller handles?

Question: Whenever I use primer, it seems like I get about one room's worth of coverage before the roller handle seizes up, so that I'm pushing the roller along the wall instead of rolling it.  I'm conscientious about cleaning my painting tools immediately after use; I've tried cleaning the handle during use too, but this still happens.
Is there any way to prevent this, or should I just buy cheaper roller handles for priming, and keep the higher-quality tools for the paint (where I don't have this problem)?
Answer: A better roller frame may actually be the right solution. I used this roller to paint most of my house after giving up on the cheap ones. It does a pretty good job of sealing the ends so that paint doesn't get inside to the rotating components. It's also got bearings to help it roll smoothly.

Unfortunately, I've used it only with Behr interior eggshell paint, so I can't tell you how it will do with primer.
EDIT: Mike B. reports good results with primer for the same roller.
Comment: +1 for the Wooster Roller.  Very strong frame and reliable.  I used it for both priming (cheap PVA brand) and painting (various Behr brands) throughout my 1400 SQFT house.  No hiccups.
Comment: That did the trick.  I spent the weekend priming with one of these, and the roller handle was still moving freely when I checked it this morning.
Comment: @Mike B. Thanks for the input concerning primer performance for the roller. I rolled it into the answer.
Comment: +1  I have also had similar problems with the rollers seizing up in the past, and when I upgraded to this (or a very similar) roller, I didn't have that problem anymore.  It works great with both primer and paint.


What load panel should I use?

Question: About 25 years ago I built a solid log cabin with 200amp service. The load center is on an interior wall (and hard to get at) and there is a 200amp disconnect just below the meter outside (so the load center is really a subpanel).
I am going to add solar power and was initially going to do that through a subpanel as I don't have room on my primary load center. My original plan was to mount a 100amp subpanel outside and tie it to my main load center (i.e. 100amp subpanel off of the 200amp subpanel).
Then I had this epiphany; why not convert my disconnect to a 200amp primary panel then run both my main 200amp load center and the 100amp subpanel off of what was previously a disconnect? Then I though even more, why not just install the the solar breakers in this new, primary panel and forget adding a new subpanel just for the solar. I discussed this in general with the power company inspector who thought that was fine. So I ordered a Homeline 200amp panel and a 200amp Branch Breaker to supply my main load center.
Subsequently, I have talked with an electrician who has suggested a feed-through panel. I think his concern was that if the house was drawing 200amp (unlikely but theoretically possible) and the solar system putting out amps, that would exceed the breaker capacity? I'm just not sure I understand the concern.
I already have the new panel and 200amp Branch Breaker; I know a feed-through panel would be cheaper (and probably a little easier to wire) but I already have my head wrapped around what I have.

Any thoughts/comments?
Thanks!
Comment: What model of Homeline panel did you buy to serve as this new panel?
Comment: Square D by Schneider Electric HOM3060M200PRBVP Homeline 200 Amp 30-Space 60-Circuit Outdoor Main Breaker Load Center - Value Pack (Plug-on Neutral Ready)
Comment: This is the branch breaker: Homeline Plug-on Circuit Breaker HOM2200BB Branch 200 AMP
Comment: It's a bigger panel than I need but I estimate I will need 18 spaces for solar breakers, branch breaker, a sewer pump that is currently tapped on to the line (thanks water company) and I would like some extra space "just in case".
Comment: How many solar inputs are you planning to feed into this panel?
Comment: Two strings 10 panels each with microinverters. Each string goes to a DP 20amp breaker. Control unit needs its own DP 20amp breaker. Plan to eventually expand to 3-4 strings total. Will be using Enphase products.
Comment: How many kW/string of capacity are we looking at here?
Comment: 330watt panels so theoretically 3.3kW per string. At 240v I guess that is about 14amps max.
Comment: These microinverters can go to 13 on a string so it's possible someone could max out a string at 13 x 330 = 4.29kW
Comment: Next time, instead of leaving yourself 3-4 spaces "just in case", leave yourself *like 20 spaces* "just in case". I am not exaggerating.  There's *always* another add-on, and it's bad enough when a builder sticks you with a too-small panel; it's even more frustrating when the damage is self-inflicted.
Answer: Talk to your inspector (AHJ), but I suspect you have too much solar for your panel's bussing
Normally, all the current in a panel is sourced from a single point, and thus the panel busbars are protected by a single OCPD (main breaker or upstream feeder breaker), meaning that the panel's busbars cannot be overloaded without eventually tripping the OCPD.  However, when you start adding interconnected power sources, such as solar inverters, to the picture, this assumption stops holding, and it's quite possible to severely overload a panel's busbars without tripping any breakers if you start tacking inverters onto your panel without considering its busbar ampacity ratings.
This is enshrined in the NEC in the requirements in 705.12(B)(2), and more specifically in 705.12(B)(2) point (3), with subpoints (a) and (b) potentially applicable here, as subpoint (c) would effectively limit you to 0A of solar due to the presence of other loads in the panel along with the 200A feeder breaker, and subpoints (d) and (e) do not apply to your equipment at all:

(3) Busbars. One of the methods that follows shall be used to
  determine the ratings of busbars in panelboards.
(a) The sum of 125 percent of the power source(s)
  output circuit current and the rating of the overcurrent device
  protecting the busbar shall not exceed the ampacity of the
  busbar.
Informational Note: This general rule assumes no limitation in
  the number of the loads or sources applied to busbars or their
  locations.
(b) Where two sources, one a primary power source and
  the other another power source, are located at opposite ends
  of a busbar that contains loads, the sum of 125 percent of the
  power source(s) output circuit current and the rating of the
  overcurrent device protecting the busbar shall not exceed
  120 percent of the ampacity of the busbar. The busbar shall be
  sized for the loads connected in accordance with Article 220. A
  permanent warning label shall be applied to the distribution
  equipment adjacent to the back-fed breaker from the power
  source that displays the following or equivalent wording:

                          WARNING:
                POWER SOURCE OUTPUT CONNECTION —
            DO NOT RELOCATE THIS OVERCURRENT DEVICE.
The warning sign(s) or label(s) shall comply with 110.21(B).

However, given that you have multiple strings of microinverters and no AC combiner subpanel in your plans, the "Where two sources..." condition in subpoint (b) may not apply to your scenario, leaving you operating under subpoint (a)'s rules, which for your panel (which likely has 225A busbars, as per this Square-D drawing), limit you to a maximum of 20A of actual solar current, or 4.8kW of solar; in other words, with the panel you have and assuming subpoint (b) does not apply, you can put in 14 microinverters' worth of solar, maximum, before you start risking a panel overload.
If your AHJ is willing to consider a consolidated group of breakers, located at the far end of the loadcenter bussing from the main, as a single power source for the purpose of applying subpoint (b), then your situation starts looking rosier.  In this case, you can use the 120% multiplier for busbar ampacity found in that subpoint, leading to a net effective ampacity of 270A.  This means that you have 56A of actual solar current available to you (70A of remaining busbar rating divided by 125%), which gives you enough headroom for your current installation, and permits a maximum of 13.44kW of solar, or enough for the 40 microinverters called for in your four-string ultimate plan.  This likely will require a written Code variance issued by your AHJ inspector, though.
There is an alternative solution, but it requires different hardware
Since you do not wish to have a separate AC combiner subpanel in your system, which is the normal solution employed in multi-string microinverter systems, we will need different hardware to meet that constraint if the AHJ does not permit you to operate under 705.12(B)(2) subpoint (3)(b) with multiple sources aggregated on the far end of the busbar.  In particular, you'll need to return your panel (which wasn't a bad choice for an additional panel, by the way: your thinking of "get plenty of spaces" was precisely what one should do in the circumstance as getting more slots when you already have the chance is far cheaper than installing another panel later), and get a somewhat more unusual piece of hardware in its stead, known as a split bus generator loadcenter.
Unfortunately, Square-D no longer makes an outdoor-rated split bus generator loadcenter, and never made one in Homeline for that matter, which means that the HOM2200 will have to get returned as well if you go down this path.  Siemens makes  a suitable unit, namely the W3042B1200GEN, but it (and its W3042L1225GEN main-lug counterpart) are quite scarce/hard-to-find as Siemens/Murray (prefix L for the Murray part number) parts.  However, the W3042B1200GEN serves as the basis for the Generac 5453 and 5454 split bus loadcenter/transfer switch combinations; while the Generac 5453 (no transfer actuator) is unobtanium, the Generac 5454 (factory fitted transfer actuator) is readily available, and can be used for this, along with a QN2200R feeder breaker and a few Siemens branch breakers, with some work.
In particular, you'd need to:

remove the factory-fitted transfer actuator, voltage sense breaker, and generator breaker,
add filler pieces (Siemens ECQF3s) to fill in the spaces in the cover that were twisted out at the factory,
replace the factory-fitted standby load section feeder breaker (a Q2125) with a Q270, making sure to torque the lugs on the new breaker to the specified tightening torque using a torque screwdriver, and
install and fit the panel, including the Siemens QN2200R feeder breaker in the upper section along with Siemens QP branch breakers for other loads desired, and Siemens Q220 branch breakers in the lower section for the individual microinverter strings.

This lets you apply 705.12(B)(2) subpoint (3)(b) in a straightforward, "as intended" fashion while preserving your desire to not have a separate enclosure for your solar AC combiner.  It does do a fair bit of surgery on the panel, but the Siemens/Generac generator-ready loadcenters were designed and intended for field installation of the transfer hardware, so this isn't such a huge deal, and we are blanking out the spaces designed as reserved for transfer-associated breakers in the loadcenter's wiring diagram as well.  Since the panel in question here uses 225A busbars in its upper section as implied by this Siemens drawing, we can safely reuse the 705.12(B)(2) subpoint (3)(b) analysis we performed above for the existing Homeline panel, and we don't have to worry about overloading the lower section as it can handle 125A, which is far in excess of what the Code permits your solar system to expand to.
Of course, if you wish a separate combiner box, nothing stops you from doing that
If you'd rather use a separate AC combiner subpanel for your microinverters, that is of course fine too.  I would use a simple 4/8 space, 100A or 125A, NEMA 3R Homeline loadcenter for this, namely the HOM48L125GRB, with a HOM270 in your new 200A panel for the feeder breaker, HOM220s for the branch breakers for now (to be replaced by HOMT220220s in the ultimate configuration), and 3 6AWG copper conductors in a 1/2" RMC nipple for the feeder back to the main panel, mounting the subpanel on whichever side of the main panel the solar circuits come in on.  The reason to shortchange this panel on slots is because this panel is reserved for PV sources only, and cannot have loads mixed in without severely complicating the busbar ampacity calculations for the main panel.
Comment: Wow! Tremendous information. Let me study what you have outlined. I suspect I will have questions. I'm not tied to keep my current panel; it can be returned. I also don't like the idea of getting special dispensation from from utility company. I am not against having a separate PV panel.
Comment: @drjrt -- I take it that your utility is the only entity that has to sign off on it, not your city/county/...?
Comment: Yes. I've already talked with them and they supported what I was THINKING of doing which makes me concerned the guy who will be inspecting me might not have much experience with solar.
Comment: I think I understand the concern. One question: why not just get a bigger panel, such as 300 amp (or a lug center) and then Replace the breaker with a 200amp break? Or is the breaker part of the bus and thus not rated for the high amperage?
Comment: Regarding the third option, which I think I will use, the PV sub panel you recommend HOM48L125GRB is a lug center with no main breaker; fed off of the HOM270 in my new main panel, correct? Also, the 30 space panel I have now seems like overkill. Should I swap it for something smaller like the HOM12M200PRB?
Comment: @drjrt -- that 30 space panel is *not* overkill at all!  (Better to have extra spaces now than to have to use double-stuffs or go back and put *another* panel in later because you ran out of space, *again*)  And yes, the HOM48L125GRB is a main lug panel with no main breaker; the feeder is protected by the HOM270 in the main panel.
Comment: @drjrt -- also, the problem with going bigger in amps is that you'd be forced into 400A equipment if you went any bigger amp-wise than what you have, and that imposes fairly major cost and availability constraints (there is no such thing as a 400A loadcenter in Homeline, for instance -- you have to use a NQ panelboard and QO breakers if you want to stay in Square-D yet have 400A busbars)
Comment: This has all been incredibly helpful and has helped me to understand. I'm going to convert my 200amp disconnect to the Homeline 30 space panel that I have already purchased, run my interior (main home panel) off of the SqD 200amp Branch Breaker I already have, Mount the HOM48L125GRB next to my new outdoor load center and run it off a HOM270 and reserve that for PV only.
Comment: The solar company that will be doing the install (I used them for my home solar) has their own contracted electrician so I will ask them to run this by him and I will also have utility company guy their for the disconnect to review what I am doing before I start anything. Your input has been extremely helpful. Thank you.
Comment: Don't know if you are still able to contribute but I've cleared option 3 above with the inspector for the utility who handles their solar. The only thing he is requesting is a "visible mechanical disconnect, not just a breaker" between the PV panel and the main panel. Do you have any suggestions? Only 60 amp units seem to be common locally.
Answer: I'll grant my experience is not nearly that of ThreePhaseEel.  But I would cleave the 705.12(B) gordian knot very simply:

A.  The solar problem.  Much as I hate outside panels, I would install an "outside" panel that attaches to only solar arrays and the interior panel. Either add a main-lug panel to the disconnect you already have, or combine them into a main-breaker panel that also has panel slots.
Take a picture because you'll never hear me say this again: but get a SMALL panel to deter any temptation to put anything else in here, because this paradigm falls apart if you add any other loads.
The interior subpanel gets a breaker, which cannot exceed the bus rating of the outside main panel. (225A is ok even if the utility main is 200A).  Either it is a) a breaker in this outside panel, or b) this outside panel has thru-lugs and the interior panel has its own "main" breaker.  From a purchasing POV, the latter would probably be cheaper.

B.  Replace the "main" subpanel inside the house with a Rather Large one to solve the "panel full" problem forever.  Do not use that new 30/60 HOM panel for this; it's too small.  You want a 40-space, and ideally a 42-space (implying industrial grade).  It's particularly important here, because you must never be tempted to put anything but solar panels in the outside panel.
My rule of thumb is "finish with 50% of spaces unused", though I also limit myself to 42-space panels because prices go ballistic above that.  I normally don't recommend replacing a primary panel, but you a)  installed it in the first place and b) can fully de-energize it.

So the condition 705.12 is worried about is now impossible - the loads can't overdraw the 225A panel busing because they are breakered for <= that.

If you ever want to do something with a Tesla PowerWall or other "stay up when the grid is down" system, this provides a nice single place to do all that, at the outside panel (presumably, replacing it).
Comment: Got it. Just wanted to be sure I understood. Thanks
Comment: Just to be sure I understand, you are recommending adding a lug panel after the disconnect OR changing that to a breakered panel, a PV only panel off the above panel, and my interior home panel off the above panel?
Comment: The multiple 20A PV panel breakers, I didn't say a third panel just for them, *but there is nothing wrong with that if you want to do  that*.  I would have  just put them in the main panel, so the main panel is nothing but several solar breakers and the feed to the subpanel where all the loads are.

What load panel should I use?


Do I need to remove mould from plywood before treating?

Question: I have a shed base on piers topped with plywood that was finished last Winter and covered up to help protect from the elements.
However some water made it through (or general dampness of being covered) through the tarp material and has made the plywood grow a little black mould. The timber joists are fine though, I guess ply is a bit more porous.
I'm going to coat the joists and ply with crecote preservative to help prevent this happening again. Do I need to remove the mould before and if so how. Anything else I can do to prevent further mould - it won't be covered again so I think it was just due to lack of airflow.
Thanks in advance
Answer: Yes, you should remove the mold. It seeps into the wood and would prevent your sealers from doing their job to the fullest. Bleach is good for surface mold but it doesn't penetrate the surface. I've used white vinegar, one cup to 3 quarts water. Scrub the mixture on the wood and then spray off with water. Let the wood totally dry and follow the directions for your preservative. Good luck and stay safe out there.


Let $ T/N = \Phi(G/N) $. Why $ K \cap T = 1 $?

Question: Let $ G $ be a soluble group whit $ \Phi(G) = 1 $ that $ \Phi(G) $ is a Frattini subgroup of $ G $. Let $ K $ and $ N $ are minimal normal subgroup of $ G $ that $ K \neq N $. Let $ T/N = \Phi(G/N) $. Why $ K \cap T = 1 $?
Answer: Your statement, after little thinking, found interesting. It is possibly equivalent to say that with your hypothesis, there is a maximal subgroup of $G$ which contains one of $K$ and $N$ but not the other.
I tried to prove this in following way: we use following theorem from Huppert-Endliche Gruppen Chapter III, Theorem 4.4.

Let $G$ be a solvable group and $A$ be an abelian normal subgroup such that $A\cap \Phi(G)=1$. Then $A$ has a complement in $G$ (i.e. $\exists$ $H\leq G$ such that $AH=G$ and $A\cap H=1$.)

(1) In a finite group, minimal normal subgroup is direct product of simple subgroups (isomorphic within themselves).
(2) Since $G$ is solvable, $K$ would be solvable and hence by (1), $K$ is direct product of cyclic (sub)groups of same prime order. Same is true for $N$. (so $K,N$ are abelian also.)
(3) Since $K$ and $N$ are distinct minimal normal subgroups, we have $K\cap N=1$, hence every element of $K$ commutes with every element of $N$, and so $KN$ is an abelian normal subgroup.
(4) Since $KN$ is abelian and $KN\cap \Phi(G)=1$, there is a complement $H$ of $KN$ in $G$.
(5) Thus $G=(KN).H$ with $KN\cap H=1$. Hence $N\cap H=1$, and as $N\trianglelefteq G$, we have $NH$ is a subgroup of $G$.  In particular, $|G|=|KN|.|H|=|K|.|N|.|H|$.
(6) $NH$ is proper subgroup since $|NH|=|N|.|H|<|G|$. Let $M$ be any (proper) maximal subgroup of $G$ which contains $NH$.
(7) Then $M$ can not contain $K$ (otherwise, $M$ will contain $K.N.H=G$).
In particular, $M$ is a maximal subgroup of $G$ such that

$M$ contains $N$;
$M$ do not contain $K$.

(8) Now coming to your normal subgroup $T$. This $T$ is intersection of those maximal subgroups of $G$ which contain $N$.
(9) If $K\cap T\neq 1$ then by minimality of $K$ we must have $K\subseteq T$, i.e. whenever a maximal subgroup contains $N$, it contains $K$ as well. This is contradiction by (7).


What defines a game's "replay value"?

Question: I've heard the term "replay value" thrown around a lot in many game reviews and some publications.
As implied from the question, what does it mean? What actually defines it? Is it how long it takes to play the game? The number of assets in the game? How engaging the game is? How good looking the game is?
Comment: Steve Yegge on Borderlands replayability despite the game's design: http://steve-yegge.blogspot.co.uk/2012/03/borderlands-gun-collectors-club.html See also procedural generation: http://en.wikipedia.org/wiki/Procedural_generation
Comment: lootfest,new game + , unlockables, multiplayer, secrets & multiple endings
Answer: Replay value is simply a generic term for "What could motivate people to play the game again after playing through it once?"
Neither the time to play through or the graphics have anything to do with that.
Examples for factors that add to replay value:

Branching story where players might play again to experience the other branches.
Extensive character customization that might get players to try to play through using a different play style, e.g. stealth vs brute force.
Randomization where players experience only some parts of all that the game might have to offer so they play again to maybe experience the other parts. This can also be randomized item drops in diablo-like games.
Comment: You're discussing the difference between intrinsic and extrinsic motivation.  The "Achievements" system encourages you to do something you may not necessarily enjoy to obtain a reward that you do value.  Intrinsic motivation means that you do it just because you enjoy doing it.  There is an Extra Credits episode dedicated to this distinction: http://www.penny-arcade.com/patv/episode/intrinsic-or-extrinsic
Comment: Dam you merlin! *people like you* make *people like me* (who want to give lazy un-efforted answers) actually have to try! Curses! (good answer btw lol)
Comment: There is a "new" trending factor that teams up with replay-value, and it's the achievement completion: I've experienced this on the Xbox community especially, where a lot of people consider the game 100% complete only after you completed all the achievements too. They add new challenges to the base game, as well as a good replay value.
There is also the increasing difficulty level to be considered (eg: Borderlands-series, Mass Effect-series, Diablo-series)
Comment: I like this answer, but I think it's missing something. I've seen games that have little to none of the qualities you've mentioned that have high replay value. Great games can be entertaining and fun to play for a second, third, and more times even when you know what is coming. Games where you solve puzzles tend to fail in this area, because the puzzles are no longer fun once you've solved them.
Comment: Often when a game has been completed once, it can be replayed with more available options: a harder difficulty settings, or you keep your inventory/stats/settings from the ending of the game... quite fun running around with lvl-20 weapons in a lvl-01 zone.
Comment: I think one way to summarise many of the factors you mentioned is simply 'depth'.  Personally, I find that carefully balanced gameplay is also crucial; many otherwise great games have been ruined by shallow, obvious ways to win.
Comment: @Zoot I was just in the progress of writing something similar when I saw your comment pop up. I personally feel like achievements are simply a crutch for getting people to play the game again instead of, well, *achievements*. A good game that offers real choices will be played again and again, even if it has bad graphics, no achievements and no increasing difficulty. Well known example is Baldurs Gate (1&2) which people still play because every playthrough can be different.
Comment: What about games like Tetris or Civilization?  There's nothing really "new" in subsequent plays, other than the satisfaction of trying to overcome some arbitrary challenge.  I would equate the replayability of these games with the replayability of something like crosswords, board games, ultimate frisbee.
Comment: Both Tetris and Civilization have a high degree of "randomization" at initial play, where any sort of starting block/location can drastically affect the rest of the game.  I feel like I should also mention that while Super Mario Bros may not seem like it has any of these features, despite being quite replayable, what it does have is Branching PATHS.  Finding ways to beat it as quickly as possible, or traversing every single level, or finding ways to skip the levels you hate, any variety in the manner in which one can win increases the game's replayability.
Answer: Replay value is a game's ability to be re-played. Either after death, or more importantly after victory. It generally specifically refers to how often you will pick the game up off the shelf to play it AGAIN after you've beaten it the first time. Some games, such as the Metal Gear genre, Borderlands genre, the Resident Evil genre, and many others, were actually DESIGNED to be played multiple times, and have content that reflects this. Beating the game (the first time) is just the beginning.
This can be accomplished in a myriad of ways, as everyone has something that speaks to them specifically. But many games have attempted to work replayability into their core game mechanics using methods such as:

Keeping some or all of your levels and\or inventory and continuing again from the beginning with or without the enemies and tasks rescaled to your level.
Starting the game again with a new playable character
Starting the game again from a new perspective, giving you insights into previously unknown parts of the story
Starting the game again as normal, but with a harder difficulty
Starting the game again with the games levels mirrored to be backwards
Multiple acheivememts to be obtained for 100% completion, some of which cannot all be gathered in one, or even several playthroughs.
Unlocking a new game mode upon completion
Including a online or local multiplayer experience so once the original campaign is finished there is still other people to slay play with.
Having multiple game modes other than just multiplayer or singleplayer in the first place so there is more to do from the beginning.
Giving the player cosmetic additions upon completions.

And many others...
Some games have great replayability without any of these qualities as well. Some games are just THAT good. There is so much content, and the story was so good, and the characters so iconic, that you just want to play it again and again, much like reading a good book or watching a good movie. The most famous game never intended to be replayed to such an extent but still was good enough to garner this form of reputation that comes to mind is Final Fantasy 7.
Comment: Classic Steve Yegge rant on Borderlands, as a case study: http://steve-yegge.blogspot.co.uk/2012/03/borderlands-gun-collectors-club.html
Comment: Two other good examples of good replay value games are the elder scrolls and the stanly parable.
Answer: This is a partial answer that adds on to the 2 great answers provided by both dbemerlin & Ender.
One thing that can really add to replay value is a multiplayer mode (in addition to single player. I am specifically leaving out multiplyer-only games as they are a beast of their own). Each time you pick it up and play with your friends it will be a new experience.
Comment: A separate Multiplayer mode isn't exactly "replay value". On the other hand, co-op multiplayer through the actual storyline is a different proposition. (see: Saints Row 3 and 4)
Answer: It's probably worth mentioning a few things that tend to detract from replay value, too:

Annoying controls / user interface
Poor camera positioning, especially for 3rd person games where the player has to negotiate lots of enclosed spaces
Long, unskippable cutscenes or unavoidable stretches of highly monotonous gameplay
Lack of ways to increase the difficulty of the game on subsequent runs
Lack of a sensible scoring/stats system
Comment: The two first point don't affect replayability any more than they affect the playability of the game in general, so I wouldn't include them here.
Comment: If you don't like a game enough to play it, your chances of replaying it are also pretty low, I'd say.
Answer: What makes a game replayable, is going deeper into the world, I'll use Portal 2 as an example, you can wander around, and find hidden areas, and uncover more of the story if you play it again. I don't really know how to elaborate on this to be honest, but if you're trying to build in replayability, you need to add funny little hints

What defines a game's "replay value"?


How to restore a deja-dup backup using a ubuntu booted from usb live?

Question: I had my hd broken and now I'm using a live ubuntu booted from a usb.
I need to restore my backup into a external hard-drive.
I was able to start deja-dup and select my backup hd, but it gives a permission deniederror. :(
Answer: Permission denied calls for insufficient permission, try launching deja-dup using sudo it should work then.


Old chime doorbell - how to connect to a switch to silence it overnight

Question: I have an old doorbell and need to connect it to a switch. I get some people ringing at 4am and need to be able to disconnect it. Can anybody help, please?
Which cable is the one to use? and how to do it, please?
Comment: Note that this unit originally had two chimes. The idea was that when the front door button was pushed, the coil would be energized to hit the missing chime; releasing the button would let the spring rebound to hit the other, resulting in a "bing-bong" two-note sound. Pressing the back door button would energies the coil the other way hitting the surviving chime, and then returning more weakly so the rebound did not hit the missing chime, sounding only the one-note "bong". Occupants would thus know which door to go to.
Comment: IDK for sure, but I'd start by disconnecting the black wire from the terminal and see if that does the trick.  If it does, reconnect it, cut it, and wire in a single switch with some extra wire to get the switch where you want it.
Answer: If you have easy access to this bell module and if it's normally open as pictured, the easiest way to silence it would be to shove a pencil eraser onto the end of the hammer.  One big enough to completely immobilize the hammer.  Then in the morning you just remove it.
If you want to do it with a switch you can cut any of the wires, and use an automotive or marine switch (12V) or one for electronics projects, in line with the cut wire.  (Note: "Any wire" assumes there is only one door with a button.  If there is a second one, you'll have to use certain wires.)
Adding a picture of where the hammer is, as requested in comment.

The idea is to prevent the end of the hammer from hitting the chime.  The other chime is missing, and the other end of the hammer does not need covering as a result.
Comment: @Huesmann  I mean, sure, reaching up and flicking a switch is X work and reaching up and sticking something between the hammer and chime is 2X or 3X.  But X is pretty small right?  And we're all evading the question of why 4am visitors are so frequent and why disabling the doorbell would thwart them, whatever their intentions are?
Comment: @jay613 I was talking about the effort of sticking a pencil eraser on the hammer every day.  IDK why my comment was deleted...
Comment: @Huesmann I get random comments deleted without explanation.   Sometimes I think it's a moderator deleting something irrelevant.  But your comment was perfectly relevant.  Anyway, who are you or I to say how much effort is too much effort in making it just a tiny bit harder for people to wake you up at 4am every day?   Which is to say the question becomes more ridiculous each time I think about it.  :)   People are ringing your bell at 4am?   Why?  What is their motivation?  And how will silencing your doorbell stop them from whatever it is they are up to?
Comment: @jay613 Thank you. That's very kind. It seems to have been manipulated as I removed the hammer and remaining dong, and still makes noise. I"ll cut one of the inner dark orange cables and see if it works. Then, I"ll connect via a one way switch.
Comment: @jay613 no kidding—who rings someone's doorbell at 4am?  Only a psychopath!  OP, do you have lots of kids in your neighborhood who like to prank people, or something?


Capslock works on letters but not on punctuation

Question: I've installed Lubuntu 18.04 on my wife's desktop, and yes, she's that kind of user which types capslock to ponctually type uppercase characters...
Here is the problem : I have a french keyboard (PS/2 Logitech with multimedia buttons). Lubuntu detected it as "french azerty (obsolete)".

When I type Shift a, it gives me A
When I type Capslock then a, it gives me A
When I type Shift ;, it gives me .
When I type Capslock then ;, it gives me ;

I tried to change the keyboard to "french azerty (variant)" but no change on the punctuation. The quite good indicator is that the top-left key under escape type either æ or ².
Do other french users had the same problems ?
Comment: I don't think the CAPS LOCK is supposed to work on non-letters.
Comment: Possible duplicate of [How can I remap the Caps Lock key to be Shift Lock?](https://askubuntu.com/questions/628981/how-can-i-remap-the-caps-lock-key-to-be-shift-lock)
Comment: @Goufalite not on my Windows 10 (US keyboard), and not on any other Windows system or keyboard I have used in the past 15 years.
Comment: Capslock has no effect on keys other than letters. It means there would be no effect of capslock on number keys., punctuation keys or numpad.
Comment: Yes, but it didn't bother me, I think it can be change into *System parameter* -> *Keyboard*
Comment: On (my) Windows Capslock works on non-letters... Given that my wife comes from Windows, this is quite a bad transition... I'll take a look at @damadam 's hint later.
Answer: From How can I remap the caps lock key to be shift

Install gnome-tweak-tool:
sudo apt install gnome-tweak-tool

Start gnome-tweak-tool:
gnome-tweak-tool

Change the CapsLock behavior from Deactivated to CAPS Lock activate the Shift Lock

You can now type 1234 with CapsLock (but be careful, Shift + Mouse on an application icon open a new window).

UPDATE for 18.04:

Start gnome-tweaks
gnome-tweaks

Go to Keyboard & mouse -> Additional Layout Options (refered as Options supplémentaires d'agencement on my screenshot) -> CapsLock Behavior

Change CapsLock from Desactivated to Use CapsLock as Shift (there are some different options, test and choose which one fits to your use)
Comment: Works on Lubuntu, but you must type `gnome-tweaks` instead... Quite buggy (hangs and crashes) but furthermore doesn't solve my problem even after a reboot
Comment: Since this is Lubuntu, I don't think gnome-tweak-tool would be the appropriate tool here.


CSS transition property on page exit

Question: I need a few objects on my pages to animate out when a user clicks a link. I want each object to scale and fade out but not all objects such as the navigation buttons.
I was thinking that upon a user clicking a link, the page delays 1 second before opening the redirecting the link to allow fade out giving the animation time to take effect.
Comment: could you show your attempts in a fiddle?
Comment: Take a look at below web site on Using CSS transitions. https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_CSS_transitions
Answer: Look at the JS event window.onbeforeunload
https://developer.mozilla.org/en-US/docs/Web/API/window.onbeforeunload
It will hopefully be enough to just run the exit animations when this function is triggered - it generally takes the browser around a second to unload the page completely but this varies depending on your browser, page size and cpu speed.
Assuming you're using plain JS and you know how to do CSS transitions, the simple way to make animations occur on page exit is something like this:
window.onbeforeunload = function(e){
    document.getElementById('myDiv').className = 'out';
}

Where myDiv id the element you want to animate and out is the CSS class representing the final stage of your transition.
Here is a JSfiddle: http://jsfiddle.net/X5vKS/
If you need finer control over the wait time, you could use the onbeforeunload function with setTimeout to delay the page exit by the length of time of your animation. This is slightly complex for a JS beginner but is quite doable.
Comment: I've added a working JSfiddle example above. Please click the tick mark next to my answer to mark it as correct.
Comment: i have no idea how to implement this lol. I am a novice. can you assist? much appreciated..
Comment: You didnt provide much info in the question (always include code if possible) but I've added an example to show you the principal.
Comment: Thanks for that but when I put that exact code into my html editor is does not go red. It will go red once I click the link, then press the back button in my browser... I will press tick because you have put time into this but still not working
Comment: Thanks. My fiddle above works fine in the latest versions of Chrome/Firefox/IE. If you need help debugging your project, you could post your code to a new fiddle and ask a new question on stack overflow

CSS transition property on page exit


Regular expression for replacing word in text that skips sections of text

Question: I have the below HTML file (simplified code):
<!DOCTYPE html>

...

  This is my header!
  {% include "header.tpl.html"%}

And I have the below code snippet in JS that is supposed to replace all occurences of "header" in the HTML:
const v = 'header';
let re = new RegExp(`${v}`, 'gi');
fileStr = fileStr.replace(re, '{% test %}');

As I result, I get:
<!DOCTYPE html>

...

  This is my {% test %}!
  {% include "{% test %}.tpl.html"%}

So, the first {% test %} replaced works as expected, but the regular expression also detects occurrences inside curly brackets, which messes up my template.
How do I build a regular expression that skips all text between {% and %} markers?
Answer: You can match the strings inside{%...%} and capture them in order to be able to skip them:

var fileStr = ' This is my header!\n  {% include "header.tpl.html"%}';
let v = 'header';
let re = new RegExp(`({%[^]*?%})|${v}`, 'gi');
fileStr = fileStr.replace(re, (x,y) => y || `{% test %}`);
console.log(fileStr);

The ({%[^]*?%})|header pattern matches and captures {% + zero or more chars as few as possible, and then %} into Group 1, or matches header string in a case insensitive way in any other context.
Then, if Group 1 matches, the replacement is the Group 1 value, so the {%...%} substrings are kept as is, and then header is replaced with test.
You may also use
let re = new RegExp(`({%[^]*?%})|\\b${v}\\b`, 'gi');

to replace whole words only (but only if these words have no special chars, otherwise, you would need other types of boundaries).
Comment: It actually works as spec'ed - thanks, not sure what was broken on my end.
Comment: This is very good. How would you modify the regex to exclude HTML tags as well? (for example )
Comment: @Miki ``let re = new RegExp(`(<[^>]*>|{%[^]*?%})|\\b${v}\\b`, 'gi');``
Comment: Thanks. I think there is an extra back slash next to \b. Also, this regex will exclude anything between symbols, like header, that should not be excluded.
Comment: @Miki Did you *try* it?


How to allow post_to_twitter only once(on create or on update)?

Question: I have a tweeted field in my model.
When user creates a new post he can check out a checkbox that will also make  a posting to twitter.
  after_create :post_to_twitter, if: :tweeted

If the checkbox was checked on create, it'll be hidden from user on other updates of the post.
<% unless @post.tweeted? %>
  <%= f.input :tweeted, inline_label: "Tweet this", as: :boolean %>
<% end %>

But if user didn't check it on create how can I allow it to be checked on update only once.
So posting to twitter can be performed only once on create or update. After the tweet was posted the checkbox should be hidden.
Answer: It is as simple as the following in your model:
after_create :tweet_with_condition

def tweet_with_condition
 if tweeted_changed? && tweeted.present?
    # post to twitter code blocks or method
 end
end

In your form you should do something like following. Where you can set 2 condition. One is checking if @post is a new record or the post has not tweeted yet.
  <%= f.input :tweeted, inline_label: "Tweet this", as: :boolean if @post.new_record? or !@post.tweeted? %>

Comment: it makes a posting on create but nothing happens on update. But I think this is almost what I need.
Comment: Oh, it works just fine when I call tweet_with_condition for both after_create and after_update. Thanks!
Answer: You can check if the user is updating the post for the first time by checking that the created_at and updated_at timestamp for the post are same.
<% if !@post.tweeted? && (@post.created_at == @post.updated_at) %>
  <%= f.input :tweeted, inline_label: "Tweet this", as: :boolean %>
<% end %>

Comment: I know how to hide the checkbox depending on conditions. I don't know how to set up my model properly.


How to update SQLite3 database after adding object to a Class?

Question: I just added the num object, and tried adding it to my admin, but I get the following error: Exception Value:
no such column: game_riddle.num
Here is the class:
class Riddle(models.Model):
"""represents a riddle, comprising a question and hints"""
world = models.ForeignKey(World)
question = models.TextField()
num = models.IntegerField()

I have a small database and the last time I added the object I had to run:sqlclear and then syncdb
How can I fix my bug without clearing the database?
Comment: but I dont want to clear or drop tables...
Answer:
Read this documention: http://south.readthedocs.org/en/0.7.6/installation.html
easy_install South
After install, put 'south' in your installed_app in settings
Don't forget to sync: python manage.py syncdb
Run this command: python manage.py schemamigration app_name --auto
The migrate: python manage.py migrate

That's it. Next if you add new model or have changes. Just do step 5 and 6 and your model will be updated.
Answer: You will need to use a migration tool such as South:

South brings migrations to Django applications. Its main objectives
  are to provide a simple, stable and database-independent migration
  layer to prevent all the hassle schema changes over time bring to your
  Django applications.


Angular2 app public URL without port number

Question: What I have to config to access an Angular2 app from a remote server without a port number.
For example: My server where wakanda is running is www.myserver.com and my Angular2 app is reachable via localhost:8000. Now I'll use something like www.myserver.com/myapp/ to see my Angular2 app.
I've found the webpack.config.js, but no idea whether this is the right place to do it or what config to set.
Answer: Check your protractor.conf.js file. In this file change your baseUrl.
baseUrl: 'your base url',

Answer: No idea about what wakanda is, but only point you have to mind is your baseUrl, which for your localhost seems to be "/" and you want it to be "/myapp" in production.
You'll need to set it up in index.html inside the head tag like this:

  <base href="/myapp">
  ...

And in webpack config
output: {
  publicPath: '/myapp',
  ...
},

Answer: Public URLs by default map to port 80. You can specify ng serve --port 80 in your package.json file in your Angular2 directory so that the application is accessible without specifying port.


How to add a Planner Tab to a Microsoft Team

Question: How do I use Microsoft Graph to add tabs to an existing Channel.  In particular I want to add a Planner tab and a custom Web site Tab.  Looking at the graph I don't see a way to create Tabs.  I can see creating Channels, but not tabs.
Answer: The Microsoft Graph doesn't appear to have that functionality built in yet and I don't believe that the PowerShell modules do either.
Here's a reference to the Teams api overview: https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/teams_api_overview
I haven't come across anything for tabs.


How can I remove Cairo Dock from my desktop after having uninstalled it?

Question: I have uninstalled Cairo Dock and now that I have done this, it is still attached to my desktop.
Every time I reboot the computer and sign in, a warning shows up on my desktop regarding my installation. I would like to get rid of it all together but I am not sure how.
It seems as though all is uninstalled except the toolbar. How can I fix this?
Comment: Please post the warning you get, and how you uninstalled CD to better see where your issue migth be.
Answer: Try this command :
sudo apt-get purge cairo-dock cairo-dock-plug-ins && sudo apt-get autoremove

Answer: This will delete every package name start with word cairo:
sudo apt-get remove --purge cairo*
Comment: Please elaborate on what this command is supposed to do and how it will help to solve the problem.
Comment: Downvote because there are other unrelated packages with names starting with "cairo".


My html website overflowing the right way when i click my login screen and back to my main page

Question: first of all thank you for your help. I am desining a new/blog web site, and this is my problem. When i click to my login page and return to previous page and hit the F5 key, my page is overlflowing the right site. How can i fix that?

body{ width:100%; overflow-x: hidden;}
.start{

    margin: 0;
    padding: 0;
    height: 40.7vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: whitesmoke;
}

.image{
    width: 450px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    margin: 0 9px;
}
.image img{
    width: 100%;
}
p{
    font-size: 17px;
    text-align: justify;
    line-height: 26px;
    margin-top: 20px;
}

*{
  margin: 0;
  padding: 0;
  text-decoration: none;
  font-family: "Open Sans",sans-serif;
}

header{
  height: 90px;
  background: #2f3640;
}

.inner-width{
  max-width: 2000px;
  padding: 0 40px;
  margin: auto;
}

.logo{
  float: left;
  padding: 12px 0;
}

.logo img{
  height: 62px;
}

.navigation-menu{
  float: right;
  display: flex;
  align-items: center;
  min-height: 90px;
}

.navigation-menu a{
  margin-left: 10px;
  color: #ddd;
  text-transform: uppercase;
  font-size: 14px;
  padding: 12px 20px;
  border-radius: 4px;
  transition: .3s linear;
}

.navigation-menu a:hover{
  background: #fff;
  color: #2f3640;
  transform: scale(1.1);
}

.navigation-menu i{
  margin-right: 8px;
  font-size: 16px;
}

.home{
  color: #ff6b6b;
}

.about{
  color: #0abde3;
}

.works{
  color: #feca57;
}

.team{
  color: #5f27cd;
}

.contact{
  color: #1dd1a1;
}

.menu-toggle-btn{
  float: right;
  height: 90px;
  line-height: 90px !important;
  color: #fff;
  font-size: 26px;
  display: none !important;
  cursor: pointer;
}

@media screen and (max-width:1200px) {
  .menu-toggle-btn{
    display: block !important;
  }

  .navigation-menu{
    position: fixed;
    width: 100%;
    max-width: 400px;
    background: #172b4d;
    top: 90px;
    right: 0;
    display: none;
    padding: 20px 40px;
    box-sizing: border-box;
  }

  .navigation-menu::before{
    content: "";
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid #172b4d;
    position: absolute;
    top: -10px;
    right: 10px;
  }

  .navigation-menu a{
    display: block;
    margin: 10px 0;
  }

  .navigation-menu.active{
    display: block;
  }
}

.search-box{

    position: absolute;
    top: 6%;
    left:25%;
    transform: translate(-50%, -50%);
    background: #2f3640;
    height: 40px;
    border-radius: 40px;
    padding:10px;
}

.search-btn{
    color: #e84118;
    float:right;
    width:40px;
    height:40px;
    border-radius:50%;
    background: #2f340;
    display:flex;
    justify-content: center;
    align-items: center;
    transition: 0.4s;
}

.search-txt {
    border:none;
    background:none;
    outline:none;
    float:left;
    padding:0;
    color:white;
    font-size:16px;
    transition:0.4s;
    line-height:40px;
    width:0px;
}
.search-box:hover > .search-txt {
    width:240px;
    padding:0 6px;
}

.search-box:hover > .search-btn {
    background:white;
}

div.ü{
    position:relative;
    left:150px;
    vertical-align:top;
}
div.yayın{
    position:relative;
    left:150px;
}
img.u {
vertical-align:top;
}
<!DOCTYPE html>

<link rel="stylesheet" href="css/menubar.css">
<link rel="stylesheet" href="css/style.css">
<title>Alba</title>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css">

           Anasayfa
           Hakkımızda
           Çalışmalar
           Yazarlar
           İletişim
          Giriş Yap

     <input class="search-txt" type="text" name="" placeholder="Aramak İçin Tıklayın">

           Yayın Akışı

Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC

Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC

Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC

Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC

Comment: Try to add for example border: 1px solid #F00; to all elements so under * in your css to see the element that overflows then try to inspect it, maybe it will help you to find why is that happening.
Answer: I Had The Same Problem As Yours,
In Local Host That Occurs With Me Sometimes.
Try Without Local Host.
Maybe That Will Work..
(As In The ScreenShot I Saw You Are Using Local Host..)
!>> [It can also be CSS Problem]


Am getting response from server after sending user name and password , but i can't able to validate response in Login page?

Question: I am getting a response from a server after sending user name and password but I am not able to validate the response in Login page.
I am getting the below response.
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
[manager POST:urlStr parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject)
{
    NSLog(@"String%@",urlStr);
    _responceString = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];

    NSError *localError = nil;
    if ([_responceString isEqual:@"fail"]) {
        NSLog(@"Do Nothing");
    } else {
        NSDictionary *studData = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:&localError];
        NSLog(@"response == %@", studData);

    _userDetailsString = [studData valueForKey:@"category"];
    _messageArray=[_userDetailsString valueForKey:@"Message"];
    _usernameArray=[_userDetailsString valueForKey:@"First_Name"];
    _resultArray=[_userDetailsString valueForKey:@"result"];

       //  _resultArray = [[studData valueForKey:@"category"] valueForKey:@"result"];

         NSLog(@" value is %@", _resultArray);

if ([_resultArray isEqualToString:@"Success"]) {
                 NSLog(@"response == %@", _resultArray);

          [self.activityIndicatorView stopAnimating];
             _objHomeviewcontroller=(HomeViewController*)[self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];

                [self.navigationController pushViewController:_objHomeviewcontroller animated:YES];

         }
         else
         {
             [self.activityIndicatorView stopAnimating];

             UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Alert" message: @"invalid data" preferredStyle:UIAlertControllerStyleAlert];
                              [alertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
                                  [self dismissViewControllerAnimated:YES completion:nil];
                              }]];

                            [self presentViewController:alertController animated:YES completion:nil];

         }

The response:
response == {
    category =     (
                {
            "First_Name" = Sahithi;
            "Last_Name" = L;
            "branch_id" = "05/10/2018 13:11:27  PM";
            result = Success;
            roles = Parent;
        }
    );
}

Comment: Include some relevant code where your problem lies. E.g how did you receive this response in code.
Comment: You are getting a result `Success`. Does that mean that the validation was successful?
Comment: how to validate to go  next page .
Comment: `valueForKey` applied to an array returns an array, so `isEqualToString` will always fail. It's unclear what you are going to accomplish. Please learn to read the response, it's very simple: `()` is array, `{}` is dictionary.
Comment: from the response structure you have pasted, Your category is an array of dictionary. so you need to get the first object from array and then do the code that you are doing now.
Comment: NSArray *array = [studData valueForKey:@"category"] will return array. Get the first object of the array by NSDictionary *dictionary = [array firstObject] and then do [dictionary valueForKey:@"First_Name"] and [dictionary valueForKey:@"result"] to get the login details
Answer: See if this helps. You are looking for the result property. If it is equal to Success you can move to the next view controller.
If( [[[[studData valueForKey:@"category"] firstObject] objectForKey:@"result"] isEqualToString: @"Success"]) {

    // goto the next view controller
    _objHomeviewcontroller=(HomeViewController*)[self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];

    [self.navigationController pushViewController:_objHomeviewcontroller animated:YES];

} else { // goto another view controller}

Comment: Please don't adopt bad habits and suggest `valueForKey` unless you can explain why the KVC functionality is needed. Modern (for many years) recommended ObjC syntax is `studData[@"category"]` or at least `[studData objectForKey:@"category"]`


How can I add more space for indicators?

Question: I am running 12.04 LTS and have used My Unity to set the Launcher as needed, and even added Classic Menu Indicator to the top bar to the far right, next to the default icons.
I found Classic Menu Indicator here:  http://www.florian-diesch.de/software/classicmenu-indicator/
My question is, with that very same small amount of icon space available at the top right, how do I add more items?
I understand the rest of the top bar from middle to far left is used by the active app.  is there a way to tweak the space it takes to open more room for custom items?
I use these systems as hardcore work machines to every centimeter of user space is worth pursuing.
Answer: The area will autoadjust in size based on the amount of indicators you have loaded, so the more you add it will just grow.
See this list for a list of available indicators:

What Application Indicators are available?