In how many ways can $6$ students be selected from a group of $8$ if two brothers may not be selected together?

Question: Find the number of ways of selecting $6$ students from a group of $8$ if Ah Chye and his brother must not be chosen together.
I tried $8C6$, but I don't know how to not choose Ah Chye and his brother.
Comment: There are two possibilities.  Neither Ah Chye nor his brother are chosen or one of the two brothers is selected along with five of the other six students.
Answer: Interpreting this as Ah Chye (one student) plus his brother, and another 6 arbitrary students.
Performing $_8C_6$ is all the ways to choose 6 students from the 8, leaving a multitude of ways for Ah Chye to be picked with his brother. There are 3 disjoint cases to consider:

Ah Chye is picked for the group. This means that his brother was not chosen. Since we've already chosen 1 student for the group, there are 5 remaining spots, and 6 children to fill them (since we used Ah Chye and can't use his brother). This can be done in $_6C_5$ ways.
Ah Chye's brother is picked for the group. This means that we can't also choose Ah Chye, and we have the same number as case 1: $_6C_5$.
Neither Ah Chye nor his brother were chosen. Since we haven't picked any group members yet, there are still 6 available spots, and 6 students need to fill them. There is only 1 way to choose 6 from 6 (choosing all of them).

Thus the total number of ways to choose 6 from 8, if Ah Chye can't be chosen with his brother is the sum of these disjoint cases: $2\cdot _6C_5 +1$
Comment: Another method is to subtract those committees in which both brothers are selected from the total.
Answer: Method 1:  We consider cases, depending on whether neither brother is selected or exactly one of the brothers is selected.
Neither brother is selected:  All six of the selected students must be selected from the six students other than Ah Chye and his brother.  This can be done in

 $$\binom{6}{6}$$

ways.
Exactly one of the brothers is selected:  We must choose one of the two brothers and five of the other six students, which can be done in

 $$\binom{2}{1}\binom{6}{5}$$

ways.
Total:  Since the two cases are mutually exclusive and exhaustive, the number of ways six students can be selected if Ah Chye and his brother are not selected together is

 $$\binom{6}{6} + \binom{2}{1}\binom{6}{5}$$

Method 2:  We subtract the number of selections in which Ah Chye and his brother are both selected from the total number of ways of selecting six students.
As you found, there are
$$\binom{8}{6}$$
ways to choose six of the eight students.
If Ah Chye and his brother are both selected, then four of the other six students must be selected, which can be done in

 $$\binom{2}{2}\binom{6}{4}$$

ways.
Hence, the number of ways of selecting six of the eight students without selecting both Ah Chye and his brother is

 $$\binom{8}{6} - \binom{2}{2}\binom{6}{4}$$


Swap image with text ( CSS or jQuery? )

Question: I'm trying to swap an image logo with text on mouse hover.
I have been looking at jquery and css to create this transition, but I haven't been lucky with finding a solution. Hopefully you can help me out a bit.
This is what I'm stuck with.
Example
http://jsfiddle.net/VugzA/
HTML

            Some Text

CSS
#logo ul {
list-style: none;
margin-left: -20px;
}

.logo_icon {
display: block;
}

.logo_icon:hover {
display: none;
}

.text {
display: none;
}

.logo_icon:hover + .text {
display: block
}

Answer: Here is an update to your fiddle
Updated html:

Some Text

and updated css:
.logo_icon {
    display: block;
}
.text {
    display: none;
}
#logo a:hover .logo_icon
{
    display:none;
}
#logo a:hover .text
{
    display:block;
}

What i do here is tie the hover event on the link instead of like you did (hover on image and text), and the image and text span are children of that element. So, when you hover on the link, the specific styles apply.
Comment: Please explain why this works and also see http://meta.stackexchange.com/questions/145987/how-to-educate-new-users-about-accepting-answers
Comment: [This is a demo modified](http://jsfiddle.net/fernandosavio/VugzA/2/) from @trajce.. maybe it helps
Comment: if this answers your question, please mark it as an answer :)
Comment: Thanks for mention this @andyb. i wasnt aware of that :)

Swap image with text ( CSS or jQuery? )


gdb with assembler: Print status of carry flag

Question: I've got an x86 assembler program which I'm debugging with gdb. Is there a way to print the status of the carry flag inside gdb with, like, "print $cf"?
Comment: `layout reg` is awful quite frankly.
Comment: If you use `layout reg`, you'll get a split-screen with register values (include EFLAGS).  Registers modified by the last single-step are highlighted, so it's really great for debugging.  See http://stackoverflow.com/tags/x86/info for a quick description.
Answer: You can use:
info registers eflags

to get the entire set of flags. You'll see a line like:
eflags  0x41  [ CF ZF ]

which means that the eflags register is set to 0x41, with the carry and zero flags set.
Comment: You can also `'print $eflags'`, or `'print/x $eflags'`
Comment: thanks a lot! could you help me find the "accept answer" checkbox on this page ^^ ? EDIT AH ok just the big check mark
Comment: @Employed Russian: If you post this as an answer, I'll vote you up too
Comment: an alternative that is also likely to be more portable by providing equivalent information outside of x86 is to use the name `ps` instead of `eflags`
Answer: I check the EFLAGS register using
(gdb) p $eflags
$3 = [ PF ZF IF ]

where "p" is just short for the "print" command.
I also find it helpful to see the bits using "/t" ( also /x for hex, /d for decimal).
(gdb) p/t $eflags
$4 = 1001000110

You can then compare with the chart for the EFLAGS register.
Answer: Another nice option with gdb is to add a watchpoint on eflags.
GDB Examining the Symbol Table
This is program to sum 12345 and 23456 as found in a good tutorial from tutorialspoint: TutorialPoint assembly tutorial
unroot@unroot-VirtualBox:~/NASM$ gdb -q add5dig
Reading symbols from add5dig...done.
(gdb) set listsize 100
(gdb) list 0
1    section .text
2        global _start
3
4    _start:
5        mov ecx,5   ;number of digits in each number to be added
6        mov esi,4   ;used to move the esi pointer to point at the rightmost digits to be summed
7        clc         ;clear carry flag
8
9    add_loop:                   ;iterates through add_loop, decrementing ecx after each iteration until ecx equals 0
10        mov al,[num1+esi]      ;mov
11        adc al,[num2+esi]      ;add with carry, nicely sets carry to 0 if there is no carry and to 1 if there is a carry
12        aaa                    ;ascii adjust after addition
13        pushf                  ;push flags onto stack
14        or al,30h              ;OR value with 0b0001 1110. (essentially adds 0x30 to the ascii adjusted value, ascii 0x30 is '0', which converts the number to its ascii representation for proper display)
15        popf                   ;pop flags from stack
16
17        mov [sum+esi],al       ;moves sum of the two digits into the correct space in memory
18        dec esi                ;point esi at the next digit to the left
19        loop add_loop          ;checks if exc==0, loops if not, continues if yes
20   ;printing message
21        mov edx,len
22        mov ecx,msg
23        mov ebx,1
24        mov eax,4
25        int 0x80
26   ;printing sum
27        mov edx,5
28        mov ecx,sum
29        mov ebx,1
30        mov eax,4
31        int 0x80
32   ;exiting
33        mov eax,1
34        int 0x80
35
36    section .data
37    msg db 'The sum is:',0xa
38    len equ $ - msg
39    num1 db '12345'
40    num2 db '23456'
41    sum db '     '              ;reserves 5 spaces in memory for sum
(gdb) break _start
Breakpoint 1 at 0x8048080
(gdb) break add_loop
Breakpoint 2 at 0x804808b
(gdb) run
Starting program: /home/unroot/NASM/add5dig

Breakpoint 1, 0x08048080 in _start ()
(gdb) watch $eflags
Watchpoint 3: $eflags
(gdb) info registers
eax            0x0    0
ecx            0x0    0
edx            0x0    0
ebx            0x0    0
esp            0xbffff0b0    0xbffff0b0
ebp            0x0    0x0
esi            0x0    0
edi            0x0    0
eip            0x8048080    0x8048080 <_start>
eflags         0x202    [ IF ]
cs             0x73    115
ss             0x7b    123
ds             0x7b    123
es             0x7b    123
fs             0x0    0
gs             0x0    0
(gdb) cont
Continuing.

Breakpoint 2, 0x0804808b in add_loop ()
(gdb) info registers
eax            0x0    0
ecx            0x5    5
edx            0x0    0
ebx            0x0    0
esp            0xbffff0b0    0xbffff0b0
ebp            0x0    0x0
esi            0x4    4
edi            0x0    0
eip            0x804808b    0x804808b <add_loop>
eflags         0x202    [ IF ]
cs             0x73    115
ss             0x7b    123
ds             0x7b    123
es             0x7b    123
fs             0x0    0
gs             0x0    0
(gdb) cont
Continuing.

Watchpoint 3: $eflags

Old value = [ IF ]
New value = [ CF AF IF ]
0x08048098 in add_loop ()
(gdb) info registers
eax            0x101    257
ecx            0x5    5
edx            0x0    0
ebx            0x0    0
esp            0xbffff0b0    0xbffff0b0
ebp            0x0    0x0
esi            0x4    4
edi            0x0    0
eip            0x8048098    0x8048098 <add_loop+13>
eflags         0x213    [ CF AF IF ]
cs             0x73    115
ss             0x7b    123
ds             0x7b    123
es             0x7b    123
fs             0x0    0
gs             0x0    0
(gdb)

The watchpoint catches that the Carry Flag and Adjust Flag in the eflags register have been altered when the program adds '6' and '5'


Hybrid graphics on desktop with Ivy Bridge

Question: While there's plenty of resources on laptop hybrid graphics, I couldn't find any relevant info on desktop hybrid graphics. Suppose following scenario: I have an Ivy Bridge CPU with integrated GPU and a discrete GPU. Can I switch between them without rebooting? (My display has two inputs, so I want to literally switch active devices)
Thanks
Answer: bumblebee. http://bumblebee-project.org/
Switching devices can be done using xrandr. Try xrandr -q.
Comment: I think that only works with Nvidia GPUs and on laptops, or am I mistaken?
Comment: Yes, you are correct.


Sorting data in one .txt file from highest to lowest and printing it to another text file

Question: I have created a quiz for a  teacher and all the scores are stored in a file for each class for example, if a student was in class 1 their score would be copied into a text file called class1 and the data would be written like:
aaron, 1
lllll, 10
kkkkk, 7

However my next task is to create another program for the teacher to use so she types in which class she wants and what she wants it sorted in (alphabetically, average and highest to lowest) and it prints it when run. This is my code so far I have managed to do the alphabetical part but am struggling on the average and the highest to lowest part:
viewclass= input("choose a class number and either alphabetically, average or highest?")

if viewclass=='1 alphabetically':
    with open('class1.txt', 'r') as r:
        for line in sorted(r):
             print(line, end='')

elif viewclass=='2 alphabetically':
    with open('class2.txt', 'r') as r:
        for line in sorted(r):
             print(line, end='')

elif viewclass=='3 alphabetically':
    with open('class3.txt', 'r') as r:
        for line in sorted(r):
             print(line, end='')

Comment: unrelated: don't repeat the same code three times: use a function or take the filename from a `dict`.
Comment: Could you show the example input and output that corresponds to "average", and "highest to lowest" order?
Comment: @J.F.Sebastian I dont know what you mean???
Comment: Please don't use SO to cheat on your GCSEs.
Comment: @AaronLad: Are you referring to my first comment or the second one (or both)?
Comment: @J.F.Sebastian    the second one i'm just a beginner at coding
Comment: `a b c` is sorted "alphabetically". `c b a` is (probably) sorted "highest to lowest". I don't understand what order "average" specifies. Could you provide an example that illustrates "average" order?
Answer: The key is to define a proper sort key and to use reverse.  I presume for 'highest' you want the following.
r = '''\
aaron, 1
lllll, 10
kkkkk, 7'''.split('\n')
# r is an iterable of non-blank lines, like a file

def score(line):
    return int(line.split(',')[1])

for line in sorted(r, key=score, reverse=True):
    print(line)

###
lllll, 10
kkkkk, 7
aaron, 1

I do not know what you mean by 'average'.
Comment: by average i mean the scores added together and divided by how many there are. But i first need to do it so only the last 3 scores are stored for each student which is confusing me slightly


Can't create directory in etc for hadoop?

Question: I am following hadoop installation tutorial. It says that

Unpack the downloaded Hadoop distribution. In the distribution, edit the file etc/hadoop/hadoop-env.sh to define some parameters as follows:

but when I open etc directory, I right-click to create a new directory inside. But "Create New Folder" option is disabled in context-menu. How can I create it?
Comment: a normal user doesn't have write access in `/etc` folder. you need root access for that.
Answer: Probably because nautilus is not opened as root (superuser).
Try to launch it from root with sudo nautilus&. But know that everything that you will do from that will not be accessible for standard users. So do not create files in your home directory.
Comment: First, I misunderstood the instruction that there is another etc folder in downloaded hadoop package. Second I did not know about nautilus (yes I am so new [: ). Now I am OK. Thanks.


Is it possible to dynamically change PolyLine.strokeThickness values?

Question: I'm writing a mapmaking program and I've got a very nice effect where the width of the river changes dynamically as the user draws it:

As you draw the river you can see the width increase and decrease. Here is the code:
<code>   Point TempP = new Point();
                Point TempPBottom = new Point();

                int ChangeRiverSize = 0;
                int HowMuch = 0;

                ChangeRiverSize = rnd.Next(1, 11);
                if (ChangeRiverSize == 1)
                {
                    HowMuch = rnd.Next(1, 3);
                }

                polyLine.Stroke = System.Windows.Media.Brushes.LightBlue;
                if (HowMuch == 1)
                    RiverWidth--;
                else if (HowMuch == 2)
                    RiverWidth++;

                polyLine.StrokeThickness = RiverWidth;

                TopPolyLine.Stroke = new SolidColorBrush(Colors.CornflowerBlue);
                TopPolyLine.StrokeThickness = 2;

                BottomPolyLine.Stroke = new SolidColorBrush(Colors.CornflowerBlue);
                BottomPolyLine.StrokeThickness = 1;

                currentPoint = e.GetPosition(MainCanvas);
                TempP = currentPoint;
                TempP.Y = TempP.Y - (RiverWidth / 2);

                TempPBottom = currentPoint;
                TempPBottom.Y = TempPBottom.Y + (RiverWidth / 2);

                polygonPoints.Add(currentPoint);
                TopPolygonPoints.Add(TempP);
                BottomPolygonPoints.Add(TempPBottom);

                polyLine.Points = polygonPoints;
                TopPolyLine.Points = TopPolygonPoints;
                BottomPolyLine.Points = BottomPolygonPoints;
</code>
The problem is that when the user lets up on the mouse button it seems that the river goes back to a uniform width. The fact that the two riverbanks move in and out fool the eye, however.
I'm thinking that a polyline can only have one width for the entire length of the line. Is there anyway around this?
Comment: A river on a map is usually a filled area, not a stroked line.
Comment: I do fills for lakes, forests & swamps. I was just hoping to do this with a stroked line.
Answer:
I'm thinking that a polyline can only have one width for the entire length of the line. Is there anyway around this?

No, you have to use a filled area instead.


How to return Dialog.Delegate directive to Alexa Skill model?

Question: I want to create a simple multi-turn dialog with the Alexa Skill model. My intent consists of 3 slots, each of which are required to fulfill the intent. I prompt every slot and defined all of the needed utterances.
Now I want to handle the request with a Lambda function. This is my function for this specific Intent:
function getData(intentRequest, session, callback) {
    if (intentRequest.dialogState != "COMPLETED"){
        // return a Dialog.Delegate directive with no updatedIntent property.
    } else {
        // do my thing
    }
}

So how would I go on to build my response with the Dialog.Delegate directive, as mentioned in the Alexa documentation?
https://developer.amazon.com/docs/custom-skills/dialog-interface-reference.html#scenario-delegate
Thank you in advance.
Answer: With Dialog.Delegate directive you cannot send outputSpeech or reprompt from your code. Instead those defined in interaction model will be used.

Do not include outputSpeech or reprompt with the Dialog.Directive.
  Alexa uses the prompts defined in the dialog model to ask the user for
  the slot values and confirmations.

What this means is that you cannot delegate and provide your own response, but instead you can use any other Dialog directive to provide your outputSpeech and reprompt.
Ex: Dialog.ElicitSlot, Dialog.ConfirmSlot and Dialog.ConfirmIntent.
At any point, you can take over the dialog rather than continuing to delegate to Alexa.
...
    const updatedIntent = handlerInput.requestEnvelope.request.intent;
    if (intentRequest.dialogState != "COMPLETED"){
       return handlerInput.responseBuilder
              .addDelegateDirective(updatedIntent)
              .getResponse();
    } else {
        // Once dialoState is completed, do your thing.
        return handlerInput.responseBuilder
              .speak(speechOutput)
              .reprompt(reprompt)
              .getResponse();
    }
...

The updatedIntent parameter in addDelegateDirective() is optional.
It is an intent object representing the intent sent to your skill. You can use this property set or change slot values and confirmation status if necessary.
More on Dialog directives here
Comment: Perfect, thank you. I struggled with the alexa documentation, this was very helpful.
Comment: const currentIntent = handlerInput.requestEnvelope.request.intent
Comment: @Cicil I would recommend you add how to get the currentIntent for reference
Answer: In nodejs you can use
if (this.event.request.dialogState != 'COMPLETED'){
    //your logic
    this.emit(':delegate');
} else {
     this.response.speak(message);
     this.emit(':responseReady');
}

Comment: Thank you, that helped to get a grip of the mechanics at work.
Comment: this is v1 code. the answer from Cicil uses v2 so it's preferable
Answer: In nodeJS we can check the dialogState and act accordingly.
if (this.event.request.dialogState === 'STARTED') {
      let updatedIntent = this.event.request.intent;
      this.emit(':delegate', updatedIntent);
} else if (this.event.request.dialogState != 'COMPLETED'){
     if(//logic to elicit slot if any){
          this.emit(':elicitSlot', slotToElicit, speechOutput, repromptSpeech);
     } else {
          this.emit(':delegate');
     }
} else {
     if(this.event.request.intent.confirmationStatus == 'CONFIRMED'){
           //logic for message
           this.response.speak(message);
           this.emit(':responseReady');
     }else{
           this.response.speak("Sure, I will not create any new service request");
           this.emit(':responseReady');
     }
}

Comment: Thank you for providing the code snippet. I went with another solution but it helped a lot to understand this elicitSlot functionality.


What does this icon mean in Pidgin's buddy list?

Question: What does this icon mean in Pidgin's buddy list?

I can't figure it out. No specific tool-tip appears when hovering the mouse pointer over it, only the status of the user, which appears when you hover the mouse pointer over any user.
Comment: Hover over it. You should see a tooltip. Or just, click it.
Comment: In the question I explained *"No specific tool-tip appears when hovering the mouse pointer over it, only the status of the user, which appears when you hover the mouse pointer over any user."*
Answer: It means that you are blocking the user.
Source: https://developer.pidgin.im/wiki/Using%20Pidgin#Whatdotheiconsnexttomybuddymean
Comment: So the user doesn't see me but I see him/her?


How to Convert Array to String[] in C#

Question: string[] B = C.OfType<object>().Where(o =>o  != null).Select(o => o.ToString()).ToArray();

I try to Convert Array C to string[]
but, Array C have a lot of null and I hope null change to " "
What Should I do?
Comment: try this
string[] B = C.OfType().Where(o =>o  != null).Select(o => o.ToString()).ToArray();
Answer: You don't need OfType<object>(), simply call string.Concat:
var s = string.Concat(C.ToArray());

If you look at documentation:

The method concatenates each object in args by calling the parameterless ToString method of that object; it does not add any delimiters.
  String.Empty is used in place of any null object in the array.'
Answer: This should work:
var B = C.OfType<string>().Select(o => o ?? " ").ToArray();

.OfType<string>() will filter out all non-string values from C.
.Select(o => o ?? " ") will select the value, or " " if the value was null.
and .ToArray() will take the IEnumerable and turn it into a string[].

How to Convert Array to String[] in C#


Back gesture in Flutter inAppWebView not working on Android

Question: My inAppWebView recognises the Back and Forward gestures (swipe in from left/right edge) fine on iOS and automatically performs the goBack/goForward accordingly (no code added for that).
But on Android it simply does nothing – it does not react to swiping in from left/right edge at all.
Is there anything one needs to do / set up to make this work also on Android?
My structure is: SafeArea -> Scaffold -> Container -> Expanded -> Container -> InAppWebView
No explicit or custom Gesture Recognizers anywhere.
I tried to use the inAppWebView property "gestureRecognizers" - but without any effect. Whatever gesture recognizers I drop in there, the inAppWebView behaves exactly the same. So that property to me seems to do nothing at all.
Comment: Please provide enough code so others can better understand or reproduce the problem.
Answer:
android:windowSwipeToDismiss="true"

In AndroidManifest.xml add the following attribute to your application tag:
Code:
<code>class MyInAppWebView extends StatefulWidget {
  @override
  _MyInAppWebViewState createState() => _MyInAppWebViewState();
}

class _MyInAppWebViewState extends State<MyInAppWebView> {
  late InAppWebViewController _webViewController;
  bool _canGoBack = false;

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () async {
        if (_canGoBack) {
          _webViewController.goBack();
          return false;
        }
        return true;
      },
      child: Scaffold(
        appBar: AppBar(title: Text('InAppWebView')),
        body: InAppWebView(
          initialUrlRequest: URLRequest(url: Uri.parse('https://www.youtube.com')),
          onWebViewCreated: (controller) {
            _webViewController = controller;
          },
          onLoadStop: (controller, url) {
            setState(() {
              _canGoBack = true;
            });
          },
        ),
      ),
    );
  }
}
</code>
Comment: Thank you for your reply!

I've seen this suggestion while searching for answers – but this deals with the Android back button, not the back gesture (swiping in from the left edge of the screen).

With your method (besides having to swap the two returns) it works fine when I tap the actual back button on Android. But the back gesture still does nothing.
Comment: @Johannes Tiefenbrunner
Kindly Check I will Update My Answer Hope So This Working Fine for you
Comment: Hey, many thanks for taking the time! Unfortunately this also does not solve the issue  As said, the back button works fine, it's the swipe that is my issue. And "windowSwipeToDismiss" unfortunately does nothing to change this. For one, "true" seams to be the default anyway (I only find lots of examples that set it to false to avoid this behaviour, especially on wear OS apps), but more so, according to Android Studio this flag is currently deprecated and does nothing ("@deprecated Swipe-to-dismiss isn't functional anymore."). I tried it anyway and it did not change anything.
Comment: I am so sorry: I was not aware that this feature (back gesture) is only available in Android API >=33. Once I ran the app in a simulator with that API level your solution worked fine! Thank you!
PS: The inAppWebView's controller actually has a method canGoBack()...


$.each only the last element is shown

Question: I'm trying to filter a list with AJAX, I have an issue where the html only shows the last element. I have read a lot of similar SO questions and to no avail. I have variables, so I don't know whats the issue.
$("#programme").change(function () {
        event.preventDefault();
        var selected_programme = $(this).val();
      $.ajax({
        url: '{% url "gps_list" %}',
        data: {
          "selected_programme": selected_programme,
        },
        dataType: 'json',
        success: function(response) {
          var json = $.parseJSON(response);
              $.each( json, function( key, values ) {

                  var valname = values.fields.name;
                  var valco = values.fields.country;
                  var valpro = values.fields.programme_type;
                  var valwhat = values.fields.what;

                  console.log(valname, key);
                  console.log(valco);
                  console.log(valpro);
                  console.log(valwhat);

                    $("#names").html(valname);
                    $("#country").html(valco);
                    $("#pro_types").html(valpro);
                    $("#whats").html(valwhat);
              });
          },
          error: function(response) {
            alert("oh no!");
          }
      });
    });

HTML

Answer: When you do this:
$("#names").html(valname);
$("#country").html(valco);
$("#pro_types").html(valpro);
$("#whats").html(valwhat);

you're overwriting whatever those elements had in them before. Since you're doing that in a loop, naturally you only see the result of the last write.
You'll need to either:

Write to different elements, or
Append rather than replacing (via append)

The specifics will depend on your HTML structure.

(Now that you've added your HTML.) I would structure it differently. Don't have any row at all (or have a placeholder "loading" row) to start with. Then build rows and append them when you have a response. Something along these lines:

var entryTemplate =
    '
' +
        '
' +
            '
' +
                '
' +
                    '' + // *** Made it a span inside the h2
                    '' +
                '
' +
            '
' +
        '
' +
        '
' +
            '
' +
                '
' +
                    '
' +
                        '

' +
                        '

' +
                    '
' +
                '
' +
            '
' +
        '
' +
    '
';

function success(response) {
    var json = $.parseJSON(response);
    var container = $("#container");
    container.empty(); // Removes any previous rows
    $.each( json, function( key, values ) {
        var fields = values.fields;
        var entry = $(entryTemplate);
        entry.find(".names").text(fields.name);
        entry.find(".country").text(fields.country);
        entry.find(".pro_types").text(fields.programme_type);
        entry.find(".whats").text(fields.what);
        container.append(entry.children());
    });
}

success(
    '[' +
        '{"fields": {' +
            '"name": "Name 1",' +
            '"country": "Country 1",' +
            '"programme_type": "PT 1",' +
            '"what": "What 1"' +
        '}},' +
        '{"fields": {' +
            '"name": "Name 2",' +
            '"country": "Country 2",' +
            '"programme_type": "PT 2",' +
            '"what": "What 2"' +
        '}},' +
        '{"fields": {' +
            '"name": "Name 3",' +
            '"country": "Country 3",' +
            '"programme_type": "PT 3",' +
            '"what": "What 3"' +
        '}}' +
    ']'
);

setTimeout(function() {
    success(
        '[' +
            '{"fields": {' +
                '"name": "Name 4",' +
                '"country": "Country 4",' +
                '"programme_type": "PT 4",' +
                '"what": "What 4"' +
            '}},' +
            '{"fields": {' +
                '"name": "Name 5",' +
                '"country": "Country 5",' +
                '"programme_type": "PT 5",' +
                '"what": "What 5"' +
            '}},' +
            '{"fields": {' +
                '"name": "Name 6",' +
                '"country": "Country 6",' +
                '"programme_type": "PT 6",' +
                '"what": "What 6"' +
            '}}' +
        ']'
    );
}, 2000);

Comment: @endormi - You'll need to change your structure, not least because `country` is **inside** `names`, so `$("#names").html(...)` will wipe out `country`. Same with `whats` and `pro_types`. Do you want to have a row for each result?
Comment: (Actually, `pro_types` and `whats` aren't a problem.)
Comment: @endormi - I've added an example.
Comment: Thanks, I will try this out
Comment: @endormi - I should point out that this sort of thing is exactly what MVC frameworks like React, Angular, Vue, Svelte, etc. help with. I used to do jQuery things like this all the time. Now it feels very awkward by comparison. :-) That is not criticism, you just said you were new, so I thought it was worth pointing you at another way to go. Happy coding!!
Comment: Thanks for the answer. Since my html code looks like that (I just edited) should I use append?
Comment: I tried .append, it worked in a way, but I want to display a new card everytime. Now all of them append into the same card
Comment: Yeah, I want to have a row for each result. `Country` was wiped, but `whats` and `pro_types` weren't.
Comment: How would I be able to get a new row for each result? I'm a beginner to these types of stuff
Comment: The issue with `.append` is that I don't want to add more content. I want to filter the list based on selection.
Comment: Thanks for the tip! however I need to use jQuery since I'm using Django.

$.each only the last element is shown


Show both radio button and checkbox based on database value

Question: I m working on radio button and checkbox button. The value 0 is for radio and 1 is for checkbox. Based on these values, I would like to display It on the screen. There might be both radio and checkboxes.
Right now, The value im getting as 0 and 1 from the database, it is just setting either radio button or checkbox for all attributes. It should display checkbox for value 1 and radio button for Value of 0.
Here is the code:
<code>                           if(multiSelect != null)
                                {
                                    RadioButton radioButton = new RadioButton(mMain);
                                    radioButton.setText(name_price);
                                    radioButton.setId(i + 6);
                                    radioButton.setTextSize(12);
                                    radioButton.setTag(attributes.get(num));
                                    radioButton.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
                                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
                                    {
                                        radioButton.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
                                    }
                                    setTextFont(radioButton, "Museo_Slab.otf");

                                    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                                            LinearLayout.LayoutParams.MATCH_PARENT,
                                            LinearLayout.LayoutParams.WRAP_CONTENT,
                                            1f);
                                    lp.setMargins(10, 10, 0, 10); // llp.setMargins(left, top, right, bottom);

                                    radioButton.setLayoutParams(lp);

                                    attr_layout[j].addView(radioButton);
                                    num++;

                                    radioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
                                    {
                                        @Override
                                        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
                                        {
                                            try
                                            {
                                                ItemAttributes itemAttributes = (ItemAttributes) buttonView.getTag();

                                                if (isChecked)
                                                {

                                                    float total_price = current_price + attr_price;

                                                    item.setItemPrice(total_price + "");

                                                    item_price_text.setText(priceStr);

                                                    selectedAttributes.add(itemAttributes);
                                                }
                                                // If the attributes are not checked

                                            } catch (Exception ex)
                                            {
                                                GSLogger.e(ex);
                                            }
                                        }
                                    });
                                }

                                else // if the multiSelect is 1
                                {
                                    CheckBox checkBox = new CheckBox(mMain);
                                    checkBox.setText(name_price);
                                    checkBox.setId(i + 6);
                                    checkBox.setTextSize(12);
                                    checkBox.setTag(attributes.get(num));
                                    checkBox.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
                                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
                                    {
                                        checkBox.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
                                    }
                                    setTextFont(checkBox, "Museo_Slab.otf");

                                    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                                            LinearLayout.LayoutParams.MATCH_PARENT,
                                            LinearLayout.LayoutParams.WRAP_CONTENT,
                                            1f);
                                    lp.setMargins(10, 10, 0, 10); // llp.setMargins(left, top, right, bottom);

                                    checkBox.setLayoutParams(lp);

                                    attr_layout[j].addView(checkBox);
                                    num++;

                                    // Reads the value depending on attribute User Selects
                                    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
                                    {
                                        @Override
                                        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
                                        {
                                            try
                                            {
                                                ItemAttributes itemAttributes = (ItemAttributes) buttonView.getTag();

                                                if (isChecked)
                                                {

                                                    float total_price = current_price + attr_price;

                                                    item.setItemPrice(total_price + "");

                                                    item_price_text.setText(priceStr);
                                                    selectedAttributes.add(itemAttributes);
                                                }

                                            } catch (Exception ex)
                                            {
                                                GSLogger.e(ex);
                                            }
                                        }
                                    });
                                }
                            }
                        }
                    }
</code>
Based on the items group defined say it is 0 or 1, it should display it on screen. If the group has both options, then the screen should display both radio for 0 value and checkbox for 1 value.
Comment: what issue you are facing?
Answer: Your if condition allows only either of these to be added. You should check if the value is 0 then add radio button and if value is 1 it should add checkbox. You have implemented if else block instead of 2 if blocks.
<code>   if(value == 0)
    {
        RadioButton radioButton = new RadioButton(mMain);
        radioButton.setText(name_price);
        radioButton.setId(i + 6);
        radioButton.setTextSize(12);
        radioButton.setTag(attributes.get(num));
        radioButton.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
        {
            radioButton.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
        }
        setTextFont(radioButton, "Museo_Slab.otf");

        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT,
                1f);
        lp.setMargins(10, 10, 0, 10); // llp.setMargins(left, top, right, bottom);

        radioButton.setLayoutParams(lp);

        attr_layout[j].addView(radioButton);
        num++;

        radioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
        {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
            {
                try
                {
                    ItemAttributes itemAttributes = (ItemAttributes) buttonView.getTag();

                    if (isChecked)
                    {

                        float total_price = current_price + attr_price;

                        item.setItemPrice(total_price + "");

                        item_price_text.setText(priceStr);

                        selectedAttributes.add(itemAttributes);
                    }
                    // If the attributes are not checked

                } catch (Exception ex)
                {
                    GSLogger.e(ex);
                }
            }
        });
    }

    if(value==1)
    {
        CheckBox checkBox = new CheckBox(mMain);
        checkBox.setText(name_price);
        checkBox.setId(i + 6);
        checkBox.setTextSize(12);
        checkBox.setTag(attributes.get(num));
        checkBox.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
        {
            checkBox.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
        }
        setTextFont(checkBox, "Museo_Slab.otf");

        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT,
                1f);
        lp.setMargins(10, 10, 0, 10); // llp.setMargins(left, top, right, bottom);

        checkBox.setLayoutParams(lp);

        attr_layout[j].addView(checkBox);
        num++;

        // Reads the value depending on attribute User Selects
        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
        {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
            {
                try
                {
                    ItemAttributes itemAttributes = (ItemAttributes) buttonView.getTag();

                    if (isChecked)
                    {

                        float total_price = current_price + attr_price;

                        item.setItemPrice(total_price + "");

                        item_price_text.setText(priceStr);
                        selectedAttributes.add(itemAttributes);
                    }

                } catch (Exception ex)
                {
                    GSLogger.e(ex);
                }
            }
        });
    }
</code>
Comment: Can you check on debugging what value you are getting from database and does the control goes in first if loop
Comment: I have both 0 and 1 value. Some groups should display only checkbox based on the value, and some radio button based on the user input
Comment: I have both 0 and 1 value for Multiselect
Comment: Then is control going into both if blocks?
Comment: It is going only to checkboxes. not going for the radio  even if the value is 0
Comment: That means value obtained from database is 1 only.
Comment: No. When i debug, i can see 0 and 1
Comment: attr_layout[j].addView(checkBox); This j value is a loop count?. Could you check if both radio and checkbox are added at same "j" element of the loop.
Comment: But, for items i want user to select only one item for radio. Right now, User can select multiple items in radio box
Comment: You need to use a radio group instead of radio button which allows single selection
Comment: When i use radio group, i do get lot of errors like setTEx]
Comment: Jacky google the use of radio group. It is a separate question.
Answer: change if condition when you get 0 from db then set radio button otherwise set checkbox
<code>  if(value == 0)
    {
                                RadioButton radioButton = new RadioButton(mMain);
                                radioButton.setText(name_price);
                                radioButton.setId(i + 6);
                                radioButton.setTextSize(12);
                                radioButton.setTag(attributes.get(num));
                                radioButton.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
                                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
                                {
                                    radioButton.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
                                }
                                setTextFont(radioButton, "Museo_Slab.otf");

                                LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                                        LinearLayout.LayoutParams.MATCH_PARENT,
                                        LinearLayout.LayoutParams.WRAP_CONTENT,
                                        1f);
                                lp.setMargins(10, 10, 0, 10); // llp.setMargins(left, top, right, bottom);

                                radioButton.setLayoutParams(lp);

                                attr_layout[j].addView(radioButton);
                                num++;

                                radioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
                                {
                                    @Override
                                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
                                    {
                                        try
                                        {
                                            ItemAttributes itemAttributes = (ItemAttributes) buttonView.getTag();

                                            if (isChecked)
                                            {

                                                float total_price = current_price + attr_price;

                                                item.setItemPrice(total_price + "");

                                                item_price_text.setText(priceStr);

                                                selectedAttributes.add(itemAttributes);
                                            }
                                            // If the attributes are not checked

                                        } catch (Exception ex)
                                        {
                                            GSLogger.e(ex);
                                        }
                                    }
                                });
                            }

                            else
                            {
                                CheckBox checkBox = new CheckBox(mMain);
                                checkBox.setText(name_price);
                                checkBox.setId(i + 6);
                                checkBox.setTextSize(12);
                                checkBox.setTag(attributes.get(num));
                                checkBox.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
                                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
                                {
                                    checkBox.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
                                }
                                setTextFont(checkBox, "Museo_Slab.otf");

                                LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                                        LinearLayout.LayoutParams.MATCH_PARENT,
                                        LinearLayout.LayoutParams.WRAP_CONTENT,
                                        1f);
                                lp.setMargins(10, 10, 0, 10); // llp.setMargins(left, top, right, bottom);

                                checkBox.setLayoutParams(lp);

                                attr_layout[j].addView(checkBox);
                                num++;

                                // Reads the value depending on attribute User Selects
                                checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
                                {
                                    @Override
                                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
                                    {
                                        try
                                        {
                                            ItemAttributes itemAttributes = (ItemAttributes) buttonView.getTag();

                                            if (isChecked)
                                            {

                                                float total_price = current_price + attr_price;

                                                item.setItemPrice(total_price + "");

                                                item_price_text.setText(priceStr);
                                                selectedAttributes.add(itemAttributes);
                                            }

                                        } catch (Exception ex)
                                        {
                                            GSLogger.e(ex);
                                        }
                                    }
                                });
                            }
                        }
                    }
                }
</code>


Angular Schematics Skip "implements OnInit"

Question: I've found plenty about how to setup my schematic file to skip certain things (like the spec file) when creating a component using ng generate but what I can't find anywhere is how to not include the implements OnInit when I use ng generate component.
I've looked everywhere. Anyone have an idea?
Comment: It doesn't seem to be an option.. https://angular.io/cli/generate#component-command
Answer: As of today, there is no option for this yet.
Answer: There is no official way to do this, but there is a trick that allows you to generate new components without implements OnInit or Constructor().
You just have to mismatch the node version. The Constructorand implements OnInit is not generated when using node 16.17.0 with Angular v15 in Windows, but it works fine in Linux Ubuntu. So you'll have to figure it out for yourself by changing only the minor version of the node.
Comment: This is interesting trivia, but sounds more like a bug. And possibly a bug only with those specific versions. I don't think this is something that should be relied on.
Comment: Yes, I also think that is more like a bug, but in recent days I have encountered this many times, and after searching on the internet, I didn't find any answers that helped me solve this. So if any person encounters that issue like I did and doesn't know what to do, they will get the idea from that answer.


how to get access to the default spring error JSON

Question: seems like by default Spring will return a message of:
<code>{
    "timestamp": "2019-01-17T16:12:45.977+0000",
    "status": 500,
    "error": "Internal Server Error",
    "message": "Error processing the request!",
    "path": "/my-endpoint-with-exceptions"
}
</code>
currently the app is using @RestControllerAdvice with an @ExceptionHandler on each exception. The in each method it uses a ResponseEntity
<code>@ExceptionHandler(GenericException.class)
public ResponseEntity<String> exceptionHandler(GenericException ex){
 return new ResponseEntity<>(ex.getMessage,HttpStatus.BAD_REQUEST)
}
</code>
additionally seems like over time there have been any number of classes which do about the same time as the default which are used.
So would rather use the default Spring JSON however of course do not want to impact currently running code. So my question is for just the GenericException to return the default Spring JSON?
I did try to use ResponseStatusException which did return the JSON but for whatever reason would only return a INTERNAL_SERVER_ERROR (500) status even when setting the value in the argument.
Answer: You can define your own error response and return it from the exception handler method.
Something like this:
Model:
<code>@Builder
public class ErrorResponse {

    private int status;

    private String error;

    private String message;

    private String path;

    private long timestamp;
}
</code>
Handler:
<code>@ExceptionHandler(GenericException.class)
public ResponseEntity<ErrorResponse> exceptionHandler(GenericException ex){
    ErrorResponse errorResponse = ErrorResponse.builder()
        .message(ex.getMessage())
        .status(HttpStatus.BAD_REQUEST.value())
        .error(HttpStatus.BAD_REQUEST.getReasonPhrase())
        .build();

    return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST);
}
</code>
Comment: Yes I did try that and certainly it would work. but a bit surprised it is such a pain to get to the Spring one
Comment: Yes, I faced the same problem and I found out that I can only customize the message.
But I think this option looks good.


Is Multi language support possible in Drupal?

Question: Am creating a website.Is support of other languages apart from English possible ?
Answer: Yes, you can either translate your content with the locale module, which is a part of Drupal core, or you can use the internationalization module to create a multi lingual Drupal site.
Comment: Thanks but where can i find the Internationalization module?
Comment: @Angel Try clicking the link I provided.
Answer: I'm not sure whether you're talking about the back end language or multi language output of pages. In the second case Google helps: Drupal > Locale
I'm sure the first is provided, too.
Answer: Of course, there is a lot of translation modules, etc. It can even translate on the fly if you;re using some of the more popular languages.


How to edit a QListwidgetItem by using custom context menu?

Question: I have a QListWidget named xml_scripts_textbox with some items in my UI, and when i right click on an item in my qlistwidget, a custom context menu appears, and one of the option of this context menu is "Edit the List item", so when this is clicked , i want that particular item in qlistwidget to be editable for once,
How can i do this ?
The code i have tried so far is
context menu code
void MainWindow::on_xml_scripts_textbox_customContextMenuRequested(const QPoint& pos)
{
    QMenu* rMenu = new QMenu(this);
    QAction* edit = new QAction(tr("Edit the List item"), this);

    rMenu->addAction(edit);
    connect(edit, SIGNAL(triggered()), this, SLOT(edithelp()));
    rMenu->exec(cursor().pos());

}

code for edithelp(), the slot function which will make the listitem editable
void MainWindow::edithelp()
{
    QListWidgetItem* item_1 = ui->xml_scripts_textbox->takeItem(ui->xml_scripts_textbox->currentRow());
    item_1->setFlags(Qt::ItemIsEditable);  // still not getting editable ?? why ??
}

Comment: I don't think QListiWidget::takeItem() is what you need. As the doc says QListiWidget::takeItem "Removes and returns the item from the given row in the list widget", so after that the item should no longer be inside the QListWidget. You should try QListiWidget::itemAt() instead.
Answer: Try this:
void MainWindow::edithelp()
{
    QListWidgetItem* item_1 = ui->xml_scripts_textbox->currentItem();
    if (item_1)
        ui->xml_scripts_textbox->editItem(item_1);
}

Comment: currently i am doing it with the help of a dialog box like this `QListWidgetItem* item_1 = ui->xml_scripts_textbox->takeItem(ui->xml_scripts_textbox->currentRow());
    QString custom_line = QInputDialog::getText(this, "Edit Command", "\nEnter the change:\n", QLineEdit::Normal, item_1->text());
    item_1->setText(custom_line);
    ui->xml_scripts_textbox->addItem(item_1);`
Answer: Did you set item is editable?
item->setFlags(item->flags() | Qt::ItemIsEditable)


I have error with getconnection about its parameters?

Question: Hello, I have a problem of compilation I have cannot what put in getconnection () to be able to connect me to my database.
 Netbeans say cannot find symbol about getconnection(). I don't know what I must to do for my problem. The code must compile in Java 1.5
public DeleteOutil(String outil, JButton toEnable) {
        this.outil = outil;
        this.toEnable = toEnable;
    }
    @Override
       public Void doInBackground() {
          PreparedStatement stmt=null;
            String wql = "DELETE  FROM outil WHERE id_outil=?";
            try {
                Connexion con = Connexion.getConnection();
                stmt = con.prepareStatement(wql);

                stmt.setString(1, "outil");
                stmt.executeUpdate();
          }
          catch (Exception e)
            }
         finally {
       if ( stmt!=null ) {
              // fermer/libérer la ressource
           try {
              stmt.close();
           }
           catch (Exception e) {
            }
       }
            }  return null;
        }

  **this my connect code:**

    public class Connexion  {
        String urlPilote="com.mysql.jdbc.Driver";//Direction pour charger le pilote
        String urlBasedonnees="jdbc:mysql://localhost:3306/bdboiteoutil";// Direction pour la connexion à la base de données
        Connection conn;
        public Connexion () {
        //On charge  notre pilote
        try{
           Class.forName(urlPilote);
           System.out.println("Le pilote est chargé");
          }
        catch(ClassNotFoundException ex){
          System.out.println(ex);
         }
        // On se connecte à la base de donnée
        try{
            conn=DriverManager.getConnection(urlBasedonnees,"root","");
            System.out.println("La Base de données est chargé");
        }
        catch(SQLException  ex){
            System.out.println(ex);
        }
            }
        Connection ObtenirConnexion(){
             return conn;
         }
    }

Answer: Note: Answer updated for Java 5,
You should not be needing to register the JDBC driver, as that should be done automatically by the JDBC driver .jar file.
Assuming that the main purpose of Connexion is to encapsulate the database connection string and the credentials, your code would be as follows:
public class Connexion {
    private static final String urlBasedonnees = "jdbc:mysql://localhost:3306/bdboiteoutil";

    public static Connection getConnection() throws SQLException {
        return DriverManager.getConnection(urlBasedonnees,"root","");
    }
}

public class DeleteOutil {
    // Constructor here

    public void doInBackground() {
        String sql = "DELETE FROM outil WHERE id_outil = ?";
        try {
            Connection con = Connexion.getConnection();
            try {
                PreparedStatement stmt = con.prepareStatement(sql);
                try {
                    stmt.setString(1, "outil");
                    stmt.executeUpdate();
                } finally {
                    stmt.close();
                }
            } finally {
                con.close();
            }
        } catch (SQLException e) {
            // Handle exception here
        }
    }
}

That code will create a new connection to the database every time doInBackground() is called. Since connecting to the database is a slow operation, you might want to keep the database connection alive between calls to doInBackground(), in which case you need to decide on where that connection is maintained, and how long the connection should stay alive.
Comment: I am really sorry I forget to tell you that the project is set to compile it in 1.5
Answer: Please check your code. As-is it will fail with NPE, because stmt is null when stmt.setString is executed.
Comment: I don't understand "As-is it will fail with NPE". I will put Connexion con = Connexion.getConnection(url,user,pwd);
            stmt = con.prepareStatement(wql);
  but url, usern pwd  cannot find symbol
Comment: In method `doInBackground` I see `stmt=null`, then `wql = "..."`, then `try {`, then two blank lines, then `stmt.setString`. I don't see any `Connexion.getConnection(...)` calls anywhere, and I don't see any implementation of such a method in your `Connexion` class (well, not one that takes 3 parameters anyway, if `ObtenirConnexion` is supposed to say `getConnection`).
Comment: now, I edit Connexion con = Connexion.getConnection();
            stmt = con.prepareStatement(wql); but I don't know what I must put in getconnection()?
Comment: `Connexion` doesn't declare a static method called `getConnection`, so I'm assuming that your issue is that `Connexion.getConnection()` fails to compile. Please clean up your code, pare it down to just show your issue, and then actually state what your issue is, e.g. error message and line number if compile error, stacktrace if runtime error.
Comment: I did it but I just know what are parameter to put in getconnection().
Comment: Your `Connexion` class has NO static methods, but `Connexion.getConnection()` is a static call. Do you know what static methods are?
Comment: Honestlyno, I just want to know what I must write, please.


How to screw drywall ceiling with furring

Question: I am adding a drywall ceiling to my basement, and it already has 1x3 furring spaced 12" apart. I am planning on using ½x4x8 drywall sheets.
When screwing my drywall, is it best to screw only in the furring using 1¼ (or longer?) screws, or also screw in the joists when possible using longer screws?
The current furring has only one nail per joist, should I add another to have two per joist or is one enough?
Comment: Are you using 1/2" xd or cd for fireproofing or just standard 1/2"?  1 1/4 should be fine after all unless you are marking the insection of the furring and joist you are likely going to only be hitting the furring most of the time.  I'd back the nail up with a screw are the current nails spiral, I am not sure I'd trust nails where the force is pulling inline with shaft of the nail.
Comment: I'm using standard 1/2. So if I understand correctly screwing only in the furring is enough?
Answer: You don't want to use too long a screw. Definitely do not screw into the joist. The joist expands and contracts as the humidity and temperature changes, but the screw stays relatively (to the wood it's embedded in) still.  The longer the screw is embedded in wood, the greater distance the wood can shrink away from the screw head.  This will cause screw pops, or dimples.  This is especially true if you use adhesive.  The adhesive will pull the drywall with the wood as the wood shrinks, but the screw head will stay stationary.  Use the shortest screw needed to fasten the drywall. 3/4" into wood is fine.
I would throw in an extra fastener or two to fasten the furring to the joist. As far as the weight of the drywall; I know it seems heavy, but you're using a lot of screws.  When you take the weight of the panel and divide by the number of screws you're using, it doesn't seem that heavy at all.
Comment: Thanks for the  answer! I would upvote if I could! Just one more quick question, my furring is 3/4 thick, If I use 1¼ screws with 1/2 drywall, they might go all the way through the furring is that bad? Should I go for 1" screws instead?
Comment: 1 1/4 inch is fine.  Don't want to go longer than that.  Of course, make sure you get the course threaded ones.  I know it sounds silly to have to say use the drywall screws meant for wood, but in one of my old homes, I found that the "pro" drywallers used fine-threaded screws meant for metal to fasten drywall to the wood trusses. Not cool.


Can Vent Flashing Nails Be Exposed On The Roof?

Question: I am buying a home and as part of the contract we asked for a number of fixes by a certified contractor. For this fix, securing the loose flashing, the home owner said his friend was a contractor so he has no receipt for this specific fix.
The fix entailed 4 exposed nails to secure the flashing. Is this proper/up-to-code/won't-leak?
Answer: They probably should be dabbed with roofing cement, but they tend to self-seal to some extent. It's unlikely that they'd leak significantly.
Also concerning is the fact that raw steel nails were used. They'll rust and stain the roof over time. Cement will mostly remedy that as well.
FYI, I don't consider those nails necessary anywhere short of a hurricane zone. Hidden nails and the sealing strips on the shingles hold it all down just fine.
Comment: Shiners are normally covered I like a product called black jack but I agree with isherwood + I normally would not nail the bottom edge.
Comment: I lift the shingle and nail under it then stick shingle back down with black jack
Comment: Thanks guys. Put Black Jack/roof cement on top of the nail? Or remove the nail and put some in the hole and renail?
Comment: You can just cap it with sealant. It may work loose over extended time, but it will either way.


error in your SQL syntax: when passing nested query in executeQuery() method

Question: Sorry for such a silly question.
below is the actual query:
SELECT  DATE_FORMAT(b.maxtime, "%H:%i") as ts, b.max_value-b.min_value as
diff FROM (SELECT max(Anzahl) as max_value ,min(Anzahl) as min_value,
greatest(max(ts),min(ts)) as maxtime
FROM customer where ts rlike '^2017-06-06' and Typ="B4A"
GROUP BY hour(ts)) b;

And when I am passing it in executeQuery() method using java like below:
resultset =statement.executeQuery("SELECT DATE_FORMAT(b.maxtime,\"%H:%i\")
as ts, b.max_value-b.min_value as diff(SELECT max(Anzahl) as max_value
,min(Anzahl) as min_value, max(ts) as maxtime from customer where Typ = " +
"\"" + selected_value+"\""+" "+"and ts RLIKE"+"'^"+cal_value+"'"+ "GROUP BY
hour(ts))b");

I am getting error in SQL syntax.
and Error is:

MySQL server version for the right syntax to use near '(SELECT max(Anzahl) as max_value ,min(Anzahl) as min_value, max(ts) as maxtime f' at line 1

Can someone help me out to figure out the problem.
Comment: Single quotes around B4A perhaps?
Comment: You have some missing spaces in there, which is probably what is causing the error.  But you should learn about prepared statements, which would help to avoid this problem.
Comment: @DawoodibnKareem I think MySQL will accept either single or double quotes.
Comment: It shouldn't.  Double quotes have a different meaning entirely.
Comment: @DawoodibnKareem they have no difference in my local mysql database(5.0),I think it might has something to do with the version
Comment: Oh, maybe.  It wouldn't surprise me if MySQL had some non-standard syntax.
Comment: @TimBiegeleisen No he hasn't missed any spaces. Highlight the query using your mouse and you'll see there are spaces at the end of the each line.
Comment: @RoshanaPitigala I missed the space before the `and`.  But for crying out loud, _use a statement_ please :-)
Answer: It's a typo. In the actual query there's a FROM after ...b.min_value as
diff. You have left it out in the String which you are parsing to executeQuery()
...diff FROM (SELECT max(Anzahl)...

So the complete statement would be
resultset = statement.executeQuery("SELECT DATE_FORMAT(b.maxtime,\"%H:%i\")
as ts, b.max_value-b.min_value as diff FROM (SELECT max(Anzahl) as max_value
,min(Anzahl) as min_value, max(ts) as maxtime from customer where Typ = " +
"\"" + selected_value+"\""+" "+"and ts RLIKE"+"'^"+cal_value+"'"+ "GROUP BY
hour(ts))b");

Comment: My pleasure... :)


(23.04) OS crashes after waking from suspend/reopening lid

Question: I recently bought Huawei MateBook d16 (on intel i5 12450H, LPDDR4x) and did clean install of Ubuntu 23.04.
Everything is great except when I resume from suspend or when I reopen the lid, the OS either freezes or it completely crashes.

Things I tried to fix this after googling:

Turning off Bluetooth in BIOS
Turning off Fingerprint Scanner in BIOS
Setting BIOS Setting "Other Wakeup Source" to Disabled
Setting BIOS Setting "Virtualization Technology" to Disabled
sudo apt-get dist-upgrade
Updating Intel graphics drivers
Following this post https://askubuntu.com/a/1009393/1705081

System-info
<code>Starting the Ubuntu Forums 'system-info' Report: 2023-06-15  13:07:31 MSK (+0300)
    Part of the Ama-gi Project
    Version: 02.00-08, Script Date: 2023.05.24

---------------------------------------------------------------
Main Complaint: Crash after suspend
Problem Description:  Laptop crashes after waking from suspend or reopening the lid
---------- General Computer Specifications:

  --- Computer/CPU Information from 'lshw -C cpu' ---
*-Cpu
    Description: CPU
    Product: 12th Gen Intel(R) Core(TM) i5-12450H
    Vendor: Intel Corp.
    Physical id: 4
    Bus info: cpu@0
    Version: 6.154.3
    Slot: CPU0
    Size: 4150MHz
    Capacity: 4400MHz
    Width: 64 bits
    Clock: 100MHz
    Capabilities: lm fpu fpu_exception wp vme de pse tsc msr pae mce cx8
        apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse
        sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp x86-64 constant_tsc art
        arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid
        aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx
        est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe
        popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm
        3dnowprefetch cpuid_fault epb invpcid_single ssbd ibrs ibpb stibp
        ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase
        tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt
        clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect
        avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
        hwp_pkg_req hfi umip pku ospke waitpkg gfni vaes vpclmulqdq rdpid
        movdiri movdir64b fsrm md_clear serialize arch_lbr ibt flush_l1d
        arch_capabilities cpufreq
    Configuration: cores=8 enabledcores=8 microcode=1065 threads=12

computer
    Description: Notebook
    Product: RLEF-XX (C170)
    Vendor: HUAWEI
    Version: M1010
    Serial: [REMOVED]
    Width: 64 bits
    Capabilities: smbios-3.4.0 dmi-3.4.0 smp vsyscall32
    Configuration:
        chassis=notebook
        family=MateBook D
        sku=C170
        uuid=[REMOVED]

------------------ SMBIOS Information from '/sys/class/dmi/id/'
Bios Vendor:         HUAWEI
Bios Version:        1.24
Bios Release:        1.24
Board Vendor:        HUAWEI
Board Name:          RLEF-XX-PCB
Board Version:       M1010
Board Serial:        PM04C02327000241
Board Asset Tag:     N/A

Current boot mode:   UEFI Firmware mode
   --- SecureBoot Status from 'mokutil':
SecureBoot disabled
Platform is in Setup Mode

---------- Memory Information:
               total        used        free      shared  buff/cache   available
Mem:           15703        2996       10981         701        2751       12707
Swap:           4095           0        4095

---------- Swap Information:
  --- Info from 'fstab'
/swap.img   none    swap    sw  0   0

  --- Info from '/proc/swaps'
Filename                Type        Size        Used        Priority
/swap.img                               file        4194300     0       -2

  --- System Swapiness Settings
Valid swappiness settings are from 10 - 60 .
Current setting in '/proc/sys/vm/swappiness': 60
Current configuration setting in '/etc/sysctl.conf file:

---------- IP Address Information:
  --- IP Address Information from 'ip addr' ---
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet [REMOVED]
    inet6 [REMOVED]
2: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    inet [REMOVED]
    inet6 [REMOVED]

  --- Internet Connection Status from 'ping [various addresses]' ---
Connected to Internet with DNS

  --- Network Device Status Summary from 'ip addr' ---
These Network Devices are up:
2: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000

For more detailed wireless information, get and run the script at https://github.com/UbuntuForums/wireless-info

  --- Hostname from 'hostname --fqdn' ---
The 'Hostname' of the computer system is: kostya-RLEF-XX

---------- Storage Controller Information From 'lspci':
01:00.0 Non-Volatile memory controller: Silicon Motion, Inc. Device 1001 (rev 03) (prog-if 02 [NVM Express])
    Subsystem: Silicon Motion, Inc. Device 2262
    Flags: bus master, fast devsel, latency 0, IRQ 16, NUMA node 0
    Memory at 80400000 (64-bit, non-prefetchable) [size=16K]
    Capabilities: [40] Power Management version 3
    Capabilities: [50] MSI: Enable- Count=1/8 Maskable+ 64bit+
    Capabilities: [70] Express Endpoint, MSI 00
    Capabilities: [b0] MSI-X: Enable+ Count=16 Masked-
    Capabilities: [100] Advanced Error Reporting
    Capabilities: [158] Secondary PCI Express
    Capabilities: [178] Latency Tolerance Reporting
    Capabilities: [180] L1 PM Substates
    Kernel driver in use: nvme
    Kernel modules: nvme

---------- File system specs from 'df -h':
Filesystem                        Type  Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-ubuntu--lv ext4  466G   31G  411G   7% /
/dev/nvme0n1p2                    ext4  2,0G  110M  1,7G   6% /boot
/dev/nvme0n1p1                    vfat  1,1G   18M  1,1G   2% /boot/efi

---------- Disk/Partition Information From 'fdisk':

Disk /dev/nvme0n1: 476,94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: PCIe-8 SSD 512GB
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 42DB227A-088A-3A4D-8BBB-3B847CA7CF92

Device           Start        End   Sectors   Size Type
/dev/nvme0n1p1    2048    2203647   2201600     1G EFI System
/dev/nvme0n1p2 2203648    6397951   4194304     2G Linux filesystem
/dev/nvme0n1p3 6397952 1000212479 993814528 473,9G Linux filesystem

Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 473,89 GiB, 508831989760 bytes, 993812480 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

---------- Disk/Partition Information From 'lsblk':
NAME                        SIZE FSTYPE      LABEL MOUNTPOINT                          MODEL
nvme0n1                   476,9G                                                       PCIe-8 SSD 512GB
|_nvme0n1p1                   1G vfat              /boot/efi
|_nvme0n1p2                   2G ext4              /boot
|_nvme0n1p3               473,9G LVM2_member
  `-ubuntu--vg-ubuntu--lv 473,9G ext4              /
   ------- 'lsblk' information continued ...
NAME                      HOTPLUG PARTUUID                             UUID
nvme0n1                         0
|_nvme0n1p1                     0 99abc21d-3f67-ef4f-ae10-e59f0df7b373 D6EC-709C
|_nvme0n1p2                     0 00a2e2a9-a300-674a-9a5a-5fcd329a48e6 d3f1a5bb-9ab6-45cb-9937-97d350568cd9
|_nvme0n1p3                     0 f2898fdb-4a1a-1e4c-a25a-10814eeed9df YaiNwF-7N5E-lW7X-08kH-3hDQ-Qv0S-VF9ePY
  `-ubuntu--vg-ubuntu--lv       0                                      f8ec66d3-dd3d-4363-b5cc-9cf6a5728c78

----------  BTRFS Information:
There are no BTRFS vdev's present.

----------  LVM2 Information:
LVM2 is installed.

  PV             VG        Fmt  Attr PSize    PFree DevSize  PV UUID
  /dev/nvme0n1p3 ubuntu-vg lvm2 a--  <473,89g    0  <473,89g YaiNwF-7N5E-lW7X-08kH-3hDQ-Qv0S-VF9ePY

  PV /dev/nvme0n1p3   VG ubuntu-vg       lvm2 [<473,89 GiB / 0    free]
  Total: 1 [<473,89 GiB] / in use: 1 [<473,89 GiB] / in no VG: 0 [0   ]

  --- Physical volume ---
  PV Name               /dev/nvme0n1p3
  VG Name               ubuntu-vg
  PV Size               <473,89 GiB / not usable 0
  Allocatable           yes (but full)
  PE Size               4,00 MiB
  Total PE              121315
  Free PE               0
  Allocated PE          121315
  PV UUID               YaiNwF-7N5E-lW7X-08kH-3hDQ-Qv0S-VF9ePY

  --- Physical Segments ---
  Physical extent 0 to 121314:
    Logical volume  /dev/ubuntu-vg/ubuntu-lv
    Logical extents 0 to 121314

  VG        Attr   Ext   #PV #LV #SN VSize    VFree VG UUID                                VProfile
  ubuntu-vg wz--n- 4,00m   1   1   0 <473,89g    0  LmjELv-n8Bh-eOxo-mUop-Mz8J-HIl9-TXIhO5

  Found volume group "ubuntu-vg" using metadata type lvm2

  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <473,89 GiB
  PE Size               4,00 MiB
  Total PE              121315
  Alloc PE / Size       121315 / <473,89 GiB
  Free  PE / Size       0 / 0
  VG UUID               LmjELv-n8Bh-eOxo-mUop-Mz8J-HIl9-TXIhO5

  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/ubuntu-lv
  LV Name                ubuntu-lv
  VG Name                ubuntu-vg
  LV UUID                turVcM-I8Rh-3lHj-eZxH-qI5b-gGnw-adsHoX
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2023-03-20 17:28:10 +0300
  LV Status              available
  # open                 1
  LV Size                <473,89 GiB
  Current LE             121315
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Physical volumes ---
  PV Name               /dev/nvme0n1p3
  PV UUID               YaiNwF-7N5E-lW7X-08kH-3hDQ-Qv0S-VF9ePY
  PV Status             allocatable
  Total PE / Free PE    121315 / 0

  LV        Type   Devices
  ubuntu-lv linear /dev/nvme0n1p3(0)

  ACTIVE            '/dev/ubuntu-vg/ubuntu-lv' [<473,89 GiB] inherit

  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/ubuntu-lv
  LV Name                ubuntu-lv
  VG Name                ubuntu-vg
  LV UUID                turVcM-I8Rh-3lHj-eZxH-qI5b-gGnw-adsHoX
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2023-03-20 17:28:10 +0300
  LV Status              available
  # open                 1
  LV Size                <473,89 GiB
  Current LE             121315
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

----------  mdadm RAID Information:
No active md devices present.
---------- Mount Details of '/etc/fstab':
/dev/disk/by-id/dm-uuid-LVM-LmjELvn8BheOxomUopMz8JHIl9TXIhO5turVcMI8Rh3lHjeZxHqI5bgGnwadsHoX / ext4 defaults 0 1
/dev/disk/by-uuid/d3f1a5bb-9ab6-45cb-9937-97d350568cd9 /boot ext4 defaults 0 1
/dev/disk/by-uuid/D6EC-709C /boot/efi vfat defaults 0 1
/swap.img   none    swap    sw  0   0

---------- Current Mount Details of 'mount':
/dev/mapper/ubuntu--vg-ubuntu--lv on / type ext4 (rw,relatime)
/dev/mapper/ubuntu--vg-ubuntu--lv on /var/snap/firefox/common/host-hunspell type ext4 (ro,noexec,noatime)
/dev/nvme0n1p1 on /boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/nvme0n1p2 on /boot type ext4 (rw,relatime)

For more detailed disk Information, please run the 'boot-info' script
from: (STABLE) https://launchpad.net/~yannubuntu/+archive/ubuntu/boot-repair

---------- USB Information from 'lsusb -t -v':
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 10000M
    ID 1d6b:0003 Linux Foundation 3.0 root hub
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/3p, 20000M/x2
    ID 1d6b:0003 Linux Foundation 3.0 root hub
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    |__ Port 1: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        ID 046d:c542 Logitech, Inc.
    |__ Port 7: Dev 3, If 1, Class=Video, Driver=uvcvideo, 480M
        ID 0408:1060 Quanta Computer, Inc.
    |__ Port 7: Dev 3, If 2, Class=Application Specific Interface, Driver=, 480M
        ID 0408:1060 Quanta Computer, Inc.
    |__ Port 7: Dev 3, If 0, Class=Video, Driver=uvcvideo, 480M
        ID 0408:1060 Quanta Computer, Inc.
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub

---------- Video Details from 'lshw':

  *-display
       description: VGA compatible controller
       product: Alder Lake-P GT1 [UHD Graphics]
       vendor: Intel Corporation
       physical id: 2
       bus info: pci@0000:00:02.0
       logical name: /dev/fb0
       version: 0c
       width: 64 bits
       clock: 33MHz
       capabilities: pciexpress msi pm vga_controller bus_master cap_list rom fb
       configuration: depth=32 driver=i915 latency=0 mode=1920x1200 resolution=1920,1200 visual=truecolor xres=1920 yres=1200
       resources:
           iomemory:600-5ff
           iomemory:400-3ff
           irq:155
           memory:6000000000-6000ffffff
           memory:4000000000-400fffffff
           ioport:3000(size=64)
           memory:c0000-dffff
           memory:4010000000-4016ffffff
           memory:4020000000-40ffffffff

   --- Graphics Environment Continued from 'various graphics ENVs' ----
The Current Configured Destop is: ubuntu:GNOME
The Current Desktop Session is: ubuntu
The Current X Desktop Information Details from 'xrandr' are:
Screen 0: minimum 16 x 16, current 1920 x 1200, maximum 32767 x 32767
XWAYLAND0 connected primary 1920x1200+0+0 (normal left inverted right x axis y axis) 350mm x 220mm
The Current Session Type is: wayland
The Current Display Manager is: gdm3
The Current Desktop Theme: 'Yaru-viridian'
The Current Virtual TTY's being used are:
    TTY#    Used By
    tty2    gdm-wayland-ses
    tty2    gnome-session-b
    pts/0   bash
    pts/1   system-info
    pts/1   system-info
    pts/1   sed
    pts/1   system-info
    pts/1   ps
    pts/1   awk

---------- Sound Device Information From 'lspci':
00:1f.3 Multimedia audio controller: Intel Corporation Alder Lake PCH-P High Definition Audio Controller (rev 01)
    Subsystem: Huawei Technologies Co., Ltd. Alder Lake PCH-P High Definition Audio Controller
    Flags: bus master, fast devsel, latency 32, IRQ 156
    Memory at 6001138000 (64-bit, non-prefetchable) [size=16K]
    Memory at 6001000000 (64-bit, non-prefetchable) [size=1M]
    Capabilities: [50] Power Management version 3
    Capabilities: [80] Vendor Specific Information: Len=14 <?>
    Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+
    Kernel driver in use: sof-audio-pci-intel-tgl
    Kernel modules: snd_hda_intel, snd_sof_pci_intel_tgl

For more detailed audio information, get and run the script at: http://www.alsa-project.org/alsa-info.sh

---------- Repository Information from '/etc/apt/sources.list and etc/apt/sources.list.d/':

Sources List:
deb http://archive.ubuntu.com/ubuntu lunar main restricted
deb http://archive.ubuntu.com/ubuntu lunar-updates main restricted
deb http://archive.ubuntu.com/ubuntu lunar universe
deb http://archive.ubuntu.com/ubuntu lunar-updates universe
deb http://archive.ubuntu.com/ubuntu lunar multiverse
deb http://archive.ubuntu.com/ubuntu lunar-updates multiverse
deb http://archive.ubuntu.com/ubuntu lunar-backports main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu lunar-security main restricted
deb http://archive.ubuntu.com/ubuntu lunar-security universe
deb http://archive.ubuntu.com/ubuntu lunar-security multiverse

Sources List from SourcesD:
/etc/apt/sources.list.d/steam-stable.list.save:
deb [arch=amd64,i386 signed-by=/usr/share/keyrings/steam.gpg] https://repo.steampowered.com/steam/ stable steam
deb-src [arch=amd64,i386 signed-by=/usr/share/keyrings/steam.gpg] https://repo.steampowered.com/steam/ stable steam
/etc/apt/sources.list.d/steam-beta.list.save:
File had no entries.
/etc/apt/sources.list.d/oibaf-ubuntu-graphics-drivers-lunar.list:
deb https://ppa.launchpadcontent.net/oibaf/graphics-drivers/ubuntu/ lunar main
/etc/apt/sources.list.d/steam-stable.list:
deb [arch=amd64,i386 signed-by=/usr/share/keyrings/steam.gpg] https://repo.steampowered.com/steam/ stable steam
deb-src [arch=amd64,i386 signed-by=/usr/share/keyrings/steam.gpg] https://repo.steampowered.com/steam/ stable steam
/etc/apt/sources.list.d/vscode.list.save:
deb [arch=amd64,arm64,armhf] http://packages.microsoft.com/repos/code stable main
/etc/apt/sources.list.d/google-chrome.list:
deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main
/etc/apt/sources.list.d/steam-beta.list:
File had no entries.
/etc/apt/sources.list.d/oibaf-ubuntu-graphics-drivers-lunar.list.save:
deb https://ppa.launchpadcontent.net/oibaf/graphics-drivers/ubuntu/ lunar main
/etc/apt/sources.list.d/google-chrome.list.save:
deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main
/etc/apt/sources.list.d/vscode.list:
deb [arch=amd64,arm64,armhf] http://packages.microsoft.com/repos/code stable main

---------- KeyMap and Locale Information from from various sources:
   --- Keymap Info from 'setxkbmap' ----
WARNING: Running setxkbmap against an XWayland server
rules:      evdev
model:      pc105
layout:     us

   --- Locale Info from 'localectl' ----
System Locale: LANG=en_US.UTF-8
               LANGUAGE=en
               LC_NUMERIC=ru_RU.UTF-8
               LC_TIME=ru_RU.UTF-8
               LC_MONETARY=ru_RU.UTF-8
               LC_PAPER=ru_RU.UTF-8
               LC_NAME=ru_RU.UTF-8
               LC_ADDRESS=ru_RU.UTF-8
               LC_TELEPHONE=ru_RU.UTF-8
               LC_MEASUREMENT=ru_RU.UTF-8
               LC_IDENTIFICATION=ru_RU.UTF-8
    VC Keymap: (unset)
   X11 Layout: gb
    X11 Model: pc105

---------- Other Details from 'Various':
The current kernel version is:       6.2.0-20-generic
    --- Operating System Release Description ---
The current release description is:  Ubuntu 23.04

Original Installation Date:          2023-03-20+17:21:47
Original Installation Media: Ubuntu 23.04 "Lunar Lobster" - Release amd64 (20230418)
Do-Release-Upgrade Date: This system may have not had a 'Release Upgrade' through 'do-release-upgrade'

   --- Hardware Enablement Stack (HWE) Informationt:
These are the current kernel ranges for HWE kernels for this release.
   --- HWE Kernel Reference from 'apt-cache show':
For HWE Package: linux-image-generic-hwe-22.04, Kernel Version: 126.96.36.199.20

   --- HWE Package Status from 'dpkg':
Package linux-generic-hwe-22.04 is installed.

   --- Certified Hardware Platform Status: (By the Ubuntu Wiki Standards)
Ubuntu Certified Hardware Platform. Safe to install
the Hardware Enablement Stack (HWE).

   --- User Installed Package List:
bsdutils
cloud-init
code
dash
diffutils
efibootmgr
findutils
fonts-indic
gnome-user-docs-ru
google-chrome-stable
grep
grub-efi-amd64
grub-efi-amd64-signed
gzip
hostname
hunspell-en-au
hunspell-en-ca
hunspell-en-gb
hunspell-en-za
hyphen-en-ca
hyphen-en-gb
hyphen-en-us
hyphen-ru
ibus-table-cangjie-big
ibus-table-cangjie3
ibus-table-cangjie5
init
language-pack-en
language-pack-en-base
language-pack-gnome-en
language-pack-gnome-en-base
language-pack-gnome-ru
language-pack-gnome-ru-base
language-pack-ru
language-pack-ru-base
libc6
libc6:i386
libchewing3
libchewing3-data
libegl1
libegl1:i386
libgbm1
libgbm1:i386
libgl1
libgl1-mesa-dri
libgl1-mesa-dri:i386
libgl1:i386
libm17n-0
libmarisa0
libopencc-data
libopencc1.1
libotf1
libpinyin-data
libpinyin15
libreoffice-help-common
libreoffice-help-en-gb
libreoffice-help-en-us
libreoffice-help-ru
libreoffice-l10n-en-gb
libreoffice-l10n-en-za
libreoffice-l10n-ru
linux-generic-hwe-22.04
login
lvm2
m17n-db
mythes-en-au
mythes-en-us
mythes-ru
ncurses-base
ncurses-bin
shim-signed
steam-launcher
steam-libs-amd64
steam-libs-i386:i386
thunderbird-locale-en
thunderbird-locale-en-gb
thunderbird-locale-en-us
thunderbird-locale-ru
thunderbird-locale-zh-hant
ubuntu-desktop
ubuntu-desktop-minimal
ubuntu-minimal
ubuntu-standard
ubuntu-wallpapers
util-linux
util-linux-extra
wbritish
wpasupplicant
zoom

   --- Installed Snap Package List:
bare
bovo
core18
core22
firefox
gnome-42-2204
gnome-extension-manager
gtk-common-themes
kf5-5-106-qt-5-15-9-core22
snap-store
snapd
snapd-desktop-integration
vlc

   --- Installed Flatpak Package List:
Flatpak is not installed

Currently logged in User(s):
NAME     LINE         TIME             COMMENT
kostya   seat0        2023-06-15 11:42 (login screen)
kostya   tty2         2023-06-15 11:42 (tty2)

The User running this script was: kostya
uid=1000(kostya)
gid=1000(kostya)
groups=1000(kostya),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),
100(users),118(lpadmin)

The 'system-info' script was booted from an installed system

The 'system-info' script seems to be running locally

The Linux Kernel Command Line use to boot was:
BOOT_IMAGE=/vmlinuz-6.2.0-20-generic root=/dev/mapper/ubuntu--vg-ubuntu--lv ro quiet splash vt.handoff=7

---- Required Programs For Report.
    --- Some Programs This Script Uses Were Missing ---
    pastebinit
</code>
Answer: I replaced the SSD and now suspend works!


Touchpad settings not found for LUbuntu 18.04

Question: I'm trying to find the control panel that will let me configure various things about my touch pad such as disabling it when other devices are active and what not.  I keep accidentally touching my touchpad while I am typing which causes the cursor to jump somewhere else and then text goes there until I realize what happens and have to try to undo it.  I want to be able to have the touchpad ignored when I am using the trackpoint on my computer somehow.  The only setting I can find at all related to my touchpad is Preferences -> Keyboard and Mouse, but it is very minimal and doesn't even touch on the touch pad.
In my research I found that there is a package called "gsynaptics" that I need to install after which I should run gpointing-device-settings.  However, when I try to install it, it says the package is not found, and when I try to run gpointing-device-settings it doesn't suggest any repositories I could find it in.  I have also noticed that most questions about this topic are several years old and in one place it suggested that gsynaptics is no longer used (but then they went on to indicate that they had, in fact, installed it, without saying how).
From what I have read, this package was in Universe, but under "Software and Updates" the "universe" setting is already checked.
Where can I find the package to let me configure my touch pad in LUbuntu 18.04 in this way?
Comment: Have you installed gnome tweak tools?
Answer: It appears that gpointing-device-settings was removed possibly due to never being finished and debugged.
In any case, I found touchpad-indicator (site is in Spanish, but Google translated it for me pretty good), also with the code here.
I installed it using:
<code>sudo add-apt-repository ppa:atareao/atareao
sudo apt-get update
sudo apt-get install touchpad-indicator
</code>
And then running touchpad-indicator I got an icon in the task bar.  Clicking on it brought up preferences.  Note that the icon was very light by default for me, but under the icon -> preferences -> theme you can make it darker if you like.  It also crashed on me the first time with something about a missing file, but the second time I ran it, it seemed to work fine.  It may be necessary to manually add it to the default apps for LXSession (under LUbuntu menu -> Preferences) so it will start whenever you log in.
Comment: yes it works, after logout and re-login :)


What is the Academy for, and how do I use it?

Question: I just bought the Academy Blueprints, and a new table has appeared on my Upgrades tab, but there's no indication of how to use it. It looks like I should be able to send my heroes there somehow, but there isn't a new profession option for them.
What is the Academy for and how do I use it?
Comment: @Batophobia Yeah, I got a hero to level 11, they appeared in the list with two options: worker or adventurer. I selected adventurer and they went away again. No idea what that did.
Comment: I can confirm that when a hero hits level 11, they become eligible for the Academy.  As for what it does, still not sure.
Comment: I just noticed that someone I set to be a "worker" is gaining experience from gathering.
Answer: When your hero hits level 11 they get plopped into the academy. They will still continue what they are currently tasked with, just also in the academy.
When in the academy you select 1 of 2 jobs (or leave them as "free").

Worker - they are permanent workers (you can't send them adventuring), but gain exp while working and are more efficient at it
Adventurer - they become permanent adventurers (can't employ them), and they gain boosted exp and are much better at adventuring.

EDIT: It seems there is a bug with the academy. heroes I "graduate" to workers would sometimes still be able to go adventuring, especially on refreshing the page... all but one heroes became "free".
Comment: I can still send workers adventuring and vice versa.
Comment: I can confirm that Workers get XP after Academy training.  Also, when I try to set a trained "Worker" to "Adventure", they are immediately sent back and flagged as "Gather".  However, a trained "Adventure" could still be employed into the workers.
Comment: Really? I trained a worker in the academy and whenever I would try send him adventuring he would instantly return to work. same went for trying to employ a dedicated adventurer


Infinite collection of homeophisms from $S^1\times S^1$ to $S^1\times S^1$ that are not homotopic.

Question: While studying for my topology exam I tried to come up with a solution of the following problem.
Let $X=S^1\times S^1$. Give (with proof) an infinite collection of homeomorphisms $f_i:X\to X$ such for all $i\neq j$ we have that $f_i$ and $f_j$ are not homotopic.
I was thinking about the identity map and the map that cuts the torus and twists the right part and put it together. Like

Can someone tell me if this is a good approach, if not give an example?
The next thing I really have a problem with is how to proof that these maps are not homotopic.
Thanks!
Comment: Do you know an infinite collection of automorphisms of the fundamental group of $S^1\times S^1$?
Comment: The problem is that my algebraic knowledge isn't that well. The fundamentalgroup of the torus is $\mathbb{Z}\times \mathbb{Z}$ right?
Comment: Indeed, it is. ${}$
Comment: The generators for $\mathbb{Z}$ are only -1 and 1 and $\mathbb{Z}\times\mathbb{Z}$ has 4 generators. So the cardinality of Aut($\mathbb{Z}\times\mathbb{Z}$) is at most that of $S_4$. It seems like there is only a finite collection of automorphisms.
Comment: there is no reason why an automorphism has to permute a fixed generating set...
Answer: First note that it is easy to distinguish selfmaps of the torus by means of the fundamental group.  Thus, rather than considering selfmaps of $X$, consider maps $S^1\to X$.  These are classified up to homotopy by $\pi_1(X)=\mathbb{Z}^2$, an infinite group.  Now to obtain infinitely many selfmaps of $X$, consider the projection to the first factor $X\to S^1$ and compose it with the maps $S^1\to X$ as above.
If you need specifically homeomorphisms, consider the action of $SL(2,\mathbb{Z})$ on the plane.  This defines a self-map of the torus by passing to the quotient $\mathbb{R}^2/\mathbb{Z}^2$.  By examining the action on the first factor, you can similarly show that there are infinitely many of these that are not homotopic.
Comment: Well, OP specifically asks for homeomorphism, so the first paragraph strikes me as unhelpful.
Comment: That won't get self-homeomorphisms, will it? Since $X\to S^1$ is not $1-1$...
Comment: I wasn't finished posting my comment :-)