text:
Q: lzw decompression in java i have written code for lzw algo in java. at the time of decompression it goes into infinite loop. the values above 255 are read in different manner. im giving ma code with an example.
import java.io.*;
import java.util.*;
public class test_decom {
  static  final int BUFFERSIZE  = 32;
static final int CHARSIZE     = 12;
static long buffer;        //32 bits of space, up to 16bit compression, only 24 bits used
static int bufferBits;     //How many bits are stored in the buffer
static int bits = 12;           //How many bits per code
static int lzwSize;       // have writen dis value at the end of compression file but this
                           //also not writing..... **plz help for this also**
static int getCode(InputStream fp)
{
 long temp;

while(bufferBits <=(BUFFERSIZE - CHARSIZE *2))//Never go over than size - or we loose data
{                                             //Also never use full 64 bits, to avoid issues
    //No point reading anymore, files done :p
    try
    {
            System.out.print("bufferBits : ");
    if(fp.available() <= 0)
          break;

       //test = fp.read();
       //buffer |= test << bufferBits;
       buffer |= fp.read() <<(bufferBits);
       bufferBits+= CHARSIZE; //Buffer now stores one more char.
           System.out.println(buffer);

    }

    catch(IOException e)
    {
    System.out.println("Error in getCode" + e.getMessage());
    }
}
    temp = (buffer << (64-bits)) >>> (64-bits); //We remove the excess bits
    buffer >>>= bits; //Remove the bits from buffer
    bufferBits -= bits;
        System.out.println("temp : "+temp);
    return (int)temp; //we return the correct code
}

public static void main(String arg[]) throws IOException
{
   // int prefix[] = new int[20];
    //int nextCode = 0;
   // String dict[] = new String [20];
    lzwSize =  (short)(1<<(bits)-1);
    BufferedInputStream fileIn = null;
    BufferedOutputStream fileOut = null;
try
{
    fileIn = new BufferedInputStream (new FileInputStream ("C:\\Documents and Settings\\project\\LzwTut\\test1_test.txt"));
    fileOut = new BufferedOutputStream(new FileOutputStream("C:\\Documents and Settings\\gauri\\project\\practice\\LzwTut\\test1_Test.txt"));
}
catch(IOException e)
{
    System.out.println("Unable to load file " + e.getMessage());
}
    ArrayList<Integer> input = new ArrayList<Integer>();
    Dictionary dic = new Hashtable();
    String val = null;

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int ab;
   while((ab=getCode(fileIn))!=lzwSize){ //i tried putting -1 but that is also not working
                                         //problem in this....
       //initialization
         input.add(ab);

   }
       // input.get(i) = Integer.parseInt(br.readLine());
    for(int i=0;i<input.size()-1;i++)
    //{
    try{

        if(input.get(i)<=255)
        {
            fileOut.write(input.get(i));
            //System.out.println("output : "+input.get(i));
            if(input.get(i+1)>255)
            {
                val = (String)dic.get(input.get(i+1)-256);
                dic.put(i, input.get(i)+" "+val);
             //   System.out.println("dic.put("+i+", "+input[i]+" "+val+")");
            }
            else
            {
                dic.put(i, input.get(i)+" "+input.get(i+1));
                //System.out.println("dic.put("+i+", "+input[i]+" "+input[i+1]+")");
            }

           // addDict(i,input[i],input[i+1]);//abhi tak out of bounds not solved

        }
        else
        {
           val = (String)dic.get(input.get(i)-256);
           //System.out.print("output : ");
           for(int k=0;k<val.length();k++)
           {
           if(val.charAt(k) == ' ')
               continue;
           else
           {
               fileOut.write(val.charAt(k));
             //  System.out.print(val.charAt(k));
           }
           }
         //  System.out.println();
            if(input.get(i+1)>255)
            {
                String val1 = (String)dic.get(input.get(i+1)-256);
                dic.put(i, val+" "+val1);
               // System.out.println("dic.put("+i+", "+val+" "+val1+")");

            }
            else
            {
                dic.put(i, val+" "+input.get(i+1));
               // System.out.println("dic.put("+i+", "+val+" "+input[i+1]+")");
            }

        }

    }
catch(Exception e)
{}
    if(input.get(input.size() - 1)>255)
    {
        //System.out.print("output : ");
           for(int k=0;k<val.length();k++)
           {
               if(val.charAt(k) == ' ')
                   continue;
               else
               {
                  // System.out.print(val.charAt(k));
                   fileOut.write(val.charAt(k));
               }
           }

    }
    else{
    //System.out.println("output : "+input.get(input.size() - 1));
    fileOut.write(input.get(input.size() - 1));
    }
    try{
        fileIn.close();
        fileOut.close();
    }
    catch(Exception e)
    {

    }
      //  System.out.println("output : "+input[9]);
}
}

example:
txt file test_test.txt contains:
stack overflow stack overflow..........
after compression:
input : 115
input : 116 output : 115
input : 97 output : 116
input : 99 output : 97
input : 107 output : 99
input : 32 output : 107
input : 111 output : 32
input : 118 output : 111
input : 101 output : 118
input : 114 output : 101
input : 102 output : 114
input : 108 output : 102
input : 111 output : 108
input : 119 output : 111
input : 32 output : 119
input : 105 output : 32
input : 115 output : 105
input : 32 output : 115
input : 98 output : 32
input : 101 utput : 98
input : 115 output : 101
input : 116
input : 32 output : 256
input : 102 output : 32
input : 111 output : 102
input : 114 output : 111
input : 117 output : 114
input : 109 output : 117
input : 46 output : 109
input : 32 output : 46
input : 115 output : 32
input : 116
input : 97 output : 256
input : 99
input : 107 output : 258
input : 32
input : 111
output : 260 input : 118
input : 101 output : 262
input : 114
input : 102 output : 264
input : 108
input : 111 output : 266
input : 119
input : 46 output : 268
BUILD SUCCESSFUL (total time: 0 seconds)//  it was supposed to write lzwSize but it is not writing
after decompression:
output : 115
output : 116
output : 97
output : 99
output : 107
output : 32
output : 111
output : 118
output : 101
output : 114
output : 102
output : 108
output : 111
output : 119
output : 32
output : 105
output : 115
output : 32
output : 98
output : 101

A: while((ab=getCode(fileIn))!=lzwSize)// I think here is the problem

should be
while((ab=getCode(fileIn))<=lzwSize)

Because may be getCode(fileIn) will never return lzSize and it will loops forever. I dont know lzw decompression just guessing by viewing your code.


text:
Q: How can you use a new toolbox in an older version of MATLAB? (no permissions to the older MATLAB) I'd like to use a function from MATLAB 2013b that does not exist in the version of MATLAB I need to use (on a cluster). I've tried re-implementing the function several different ways, but there are lots of dependencies, and when I seem to get passed these MATLAB crashes with a very long error message including this:
This error was detected while a MEX-file was running. If the MEX-file
is not an official MathWorks function, please examine its source code
for errors. Please consult the External Interfaces Guide for information
on debugging MEX-files

Unfortunately I know very little about C/MEX files.
Since I have MATLAB 2013b on my computer, I tried transferring the entire toolbox to the working directory on the cluster. This makes no difference if the toolbox is not expanded. When i put the most relevant files directly in the directory (rather than the subdirectories of the toolbox) I still get the same error as above.
Firstly, I am wondering if there is a neater way to make this toolbox override the original toolbox, rather than putting all subdirectories and .m files directly in the working directory.
Secondly, if I do override the old toolbox in this way, will this even work, or does MATLAB have some sort of block on using updated toolboxes in older versions?

A: MATLAB doesn't guarantee backward compatibility.  It's not just the functions in the toolbox - the toolbox functions might also be making assumptions about the required input or output of some non-toolbox functions which no longer apply.
However, if you're only moving only one version back, it might not be insurmountable with some tweaking.

*

*Put your new toolbox in it's own directory, make sure it is on the path.

*Rename/move/take off path the old version of the toolbox, so that
you're sure none of those are getting called.

*Check the 2013b release notes, particularly for anything marked
with a little warning triangle - that means "Compatibility
Considerations".  There are separate release notes for the toolboxes as well.

*If possible, and you didn't recompile when originally shifting the new toolbox to the cluster, recompile any MEX files belonging to the toolbox.

Without knowing which function/toolbox you're looking at, it's hard to be more specific.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Why are threads interrupted even when atexit or ConsoleHandler for SetConsoleCtrlhandler is executed? I have a multithreaded application under Windows 7.
I need to correctly finish jobs in threads which have an open descriptors, connections and so on when a user presses 'X' in the corner of command line, 'Ctrl+C', shuts down OS and so on.
I've set a handler for SetConsoleHandler which sets appropriate flags for other threads to correctly finish their job. But all of them are interrupted and the y exit with code 0xc000013a. SOmetimes even my handler doesn't have time to set flag.
The same problem remains when I try to do the same operations in atexit handler.
Why are all threads stopped even during interruption handler? How can I avoid this and let all my threads finish their job?

A:
sets appropriate flags for other threads to correctly finish their job

Usually it's not enough. You also must wait the threads to finish (thread.join(), or WaitForMultipleObjects, or something similar).

A: The problem in my case was that some of child-children thread used timed-waiting on system resources so each of them needed to wake from waiting to join thread. And all of them were stopping consecutively so they required too much time to stop.


text: Q: Implementing Dojo Widget I am new to Dojo and was asked to look at creating a widget. The widgets will be on different pages and has to read the page info using the meta data. Based on the meta data value it should pulls a list of content to display of the page from the database. I would get suggestion on where should I start first and how to proceed. Any samples or similar widget examples would be of help.


text:
Q: Open the ABPeoplePicker in a UIPopover I have a UIPopover with a button in it that opens the ABPeoplePicker. I have it opening in the popover but it shifts over. It doesn't stay in the same spot and the size changes how do I keep it the same size.
// code to call popover
- (IBAction) addPerson:(id) sender{
// create your view controller if it doesn't exist yet
if (addPersonViewController == nil){
    addPersonViewController = [[addPersonViewControllerPopover_iPad alloc] init];
}
pop = [[UIPopoverController alloc] initWithContentViewController:addPersonViewController];
// rest of your method...
addPersonViewController.delegate = self;
pop.popoverContentSize = CGSizeMake(320, 480);
CGRect rect = CGRectMake(790, 35, 175, 300);
[pop presentPopoverFromRect:rect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
[addPersonController retain];
NSLog(@"this one");
}

//popover code
- (IBAction) AddButtonAction:(id)sender {
picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
picker.navigationBar.tintColor = [UIColor brownColor];
   picker.contentSizeForViewInPopover = CGSizeMake(320, 480);

picker.modalPresentationStyle = UIModalPresentationCurrentContext;
picker.modalInPopover = YES;
// Display only a person's phone, email, and birthdate
NSArray *displayedItems = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonPhoneProperty],
                           [NSNumber numberWithInt:kABPersonEmailProperty],
                           [NSNumber numberWithInt:kABPersonBirthdayProperty], nil];

picker.displayedProperties = displayedItems;

//Show the picker
[self presentModalViewController:picker animated:YES];

[picker release];
}

A: You will need to do this
picker.modalPresentationStyle = UIModalPresentationCurrentContext;


text:
Q: How can I run multiple listeners in Spring Boot Java? I am continuously receiving data feed from third party and want to process around 100k messages in less than a minute. So thinking to implement a messaging queue through which I can offload the processing part and will push the message to a queue, where one worker out of 100 (or whatever number) picks the job and process it.
I've read about JMS and Redis based messaging, but I am not sure how to run multiple listeners. The single listener is already configured.

A: Spring JMS allows you to specify concurrency limits via a "lower-upper" String, e.g. "5-10", or a simple upper limit String, e.g. "10" (the lower limit will be 1 in this case).
The listener container will always hold on to the minimum number of consumers (setConcurrentConsumers(int)) and will slowly scale up to the maximum number of consumers
See:
[1] https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/jms/config/DefaultJmsListenerContainerFactory.html#setConcurrency-java.lang.String-
[2] https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/jms/listener/DefaultMessageListenerContainer.html#setConcurrency-java.lang.String-
An example in a Spring boot configuration bean:
@Configuration
@EnableJms
public class AppConfig {

    @Bean
    public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
        DefaultJmsListenerContainerFactory factory
          = new DefaultJmsListenerContainerFactory();
        factory.setConnectionFactory(connectionFactory());
        factory.setConcurrency("3-10");
        return factory;
    }
}


text:
Q: Javascript Code explaination
I am a javascript beginner, and I do not quite understand this code in the picture, can somebody explain a little ?
Thanks!!

A: The easiest way to explain the code is to fill in the values during each call.
The function plusGenerator is a function that takes an offset and then returns another function that returns the result of adding offset to another number. When you call plusGenerator(2), the function that is returned looks like:
var addTwo = function(x) { return x + 2; };

You then call addTwo(15) which returns 17.


text:
Q: Redshift query to combine result if the data are continous within a table I have a requirement in redshift where I need to combine result if the data are continuous. I have the following table, where user_id, product_id are varchar and login_time, log_out_time are timestamp.
user_id    product_id   login_time                log_out_time
----------------------------------------------------------------------
ashok      facebook     1/1/2017 1:00:00 AM       1/1/2017 2:00:00 AM
ashok      facebook     1/1/2017 2:00:00 AM       1/1/2017 3:00:00 AM
ashok      facebook     1/1/2017 3:00:00 AM       1/1/2017 4:00:00 AM
ashok      linked_in    1/1/2017 5:00:00 AM       1/1/2017 6:00:00 AM
ashok      linked_in    1/1/2017 6:00:00 AM       1/1/2017 7:00:00 AM
ashok      facebook     1/1/2017 8:00:00 AM       1/1/2017 9:00:00 AM
ram        facebook     1/1/2017 9:00:00 AM       1/1/2017 10:00:00 AM
ashok      linked_in    1/1/2017 7:00:00 AM       1/1/2017 8:00:00 AM

I need to combine the result if the data are continuous for a given user_id for each product. So my output should looks like,
user_id    product_id   login_time                log_out_time
----------------------------------------------------------------------
ashok      facebook     1/1/2017 1:00:00 AM       1/1/2017 4:00:00 AM
ashok      facebook     1/1/2017 8:00:00 AM       1/1/2017 9:00:00 AM
ashok      linked_in    1/1/2017 5:00:00 AM       1/1/2017 8:00:00 AM
ram        facebook     1/1/2017 9:00:00 AM       1/1/2017 10:00:00 AM

I tried with the following query but it doesn't helped me,
SELECT user_id, product_id, MIN(login_time), MAX(log_out_time) FROM TABLE_NAME GROUP BY user_id, product_id

Above query fails to give my required output since it doesn't have the logic to check the data are in continuous time. I need to have a query for this without using any custom function, but I am allowed to use any redshift in-built function.

A: You can use lag() to identify where groups start, then cumulative sum to identify the groups, then group by to aggregate the results:
select user_id, product_id, min(login_time), max(log_out_time)
from (select t.*,
             sum(case when prev_lt = login_time then 0 else 1 end) over
                 (partition by user_id, product_id
                  order by login_time
                  rows between unbounded preceding and current row
                 ) as grp
      from (select t.*,
                   lag(log_out_time) over (partition by user_id, product_id order by login_time) as prev_lt
            from t
           ) t
     ) t
group by user_id, product_id, grp;


text:
Q: How to remove a menu entry that has no executable How can I remove a menu entry that has been orphaned? The executable command tied to it has been deleted from the system.
I am looking at it with menulibre, but the entry doesn't show up. I am running Xubuntu 16.04 with the whisker menu.

A: The solution to this was to recreate the exact path structure and names that the missing menu entry was complaining about and from there it is possible to manually delete it with menulibre.


text:
Q: How to improve MySQL connection time in PHP? As testing performances on APIs, I found that 30% of response time for APIs are spent on connecting to MySQL. (Min. 500ms - Max. 600ms)
I assumed that it was because of MySQL settings, so I changed various settings to improve the connection time, but without luck.
I did not use any framework to test it. I wanted to compare with other languages, so I tested Python. Its result was around 50ms which is a lot better than 500-600ms of PHP.
What would be the reasons for such delay on PHP, but not on Python?
Here is the environment under which I tested:

*

*php version : 7.1.9-1+0~20170902060604.8+jessie~1.gbpebe5d6

*python version :  3.6.2

*platform : Linux(Ubuntu)

*mysql version : 5.7.2

A: Depending upon your use case, you may be able to dramatically increase your response time by using persistent connections.


text:
Q: Negative value validation in angularjs I am using input type="number" but I am getting the view as up and down value bars in the text box. How to avoid this?
How can I validate a negative value in the input text box?. If I enter a negative value as input then proper error message should display.

A:
but I am getting the view as up and down value bars in the text box. How to avoid this?

You can remove those spinner buttons in some browsers with simple CSS:
input[type='number'] {
    -moz-appearance:textfield;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

(credits to this answer). It will not work in IE though.
Now real question, how to validate user input? Angular solution in this case would be creating additional validation directive. Here is the simple one I recently wrote:

angular.module('demo', []).directive('positive', [function() {
    return {
        require: 'ngModel',
        link: function(scope, elem, attrs, ctrl) {
            if (!ctrl) return;
            ctrl.$validators.positive = function(value) {
                return value && value >= 0;
            };
        }
    };
}]);
input[type='number'] {
    -moz-appearance:textfield;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.error {color: brown;}

    <form name="paymentForm">
        <input type="number" name="amount" ng-model="amount" positive />
    </form>

Amount should be positive number.


text:
Q: How to have searchlogic initialize with no records I'm using Searchlogic in a model with tens of thousands of records and don't want to initially display them all the first time the search page loads. How do I get an empty search object from searchlogic if there are no :search params?

  def search
    @products = []
    if params[:search] && !params[:search].blank?
      @search = Product.searchlogic(params[:search])
    else
      @search = Product.searchlogic(....What goes here to get an empty searchlogic object?...)
    end
    @products = @search.all
  end

A: Change your logic to this:
def search
    @products = []
    @search = params[:search] && !params[:search].blank? ?
        Product.searchlogic(params[:search]) : nil
    @products = @search.all unless @search.nil?
end

Granted you could keep your if statement like so:
def search
    @products = []
    @search = nil
    if params[:search] && !params[:search].blank?
        Product.searchlogic(params[:search])
    end
    @products = @search.all unless @search.nil?
end


text:
Q: How to treat encoding when reading .dta-files into R from Stata-files prior to version 14? How can one dodge the encoding problems when reading Stata-data into R?
The dataset I wish to read is a .dta in either Stata 12 or Stata 13 (before Stata introduced support for utf-8 in version 14). Text-variables with Swedish and German letters å, ä, ö, ß, as well as other characters do not import well.
I have tried these answers, read.dta in foreign, the haven package (with no encoding-parameters), and now read_stata13, which informs me that it expects Stata files to be encoded in CP1252. But alas, the encoding doesn't work. Should I give up and and use a .csv-export as a bridge instead, or is it actually possible to read .dta-files in R?
Minimal example:
This code downloads the first few lines of my dataset, and illustrates the problem, for example in the variable vocation which contain Scandinavian languages.
setwd("~/Downloads/")
system("curl -O http://www.lilljegren.com/stackoverflow/example.stata13.dta", intern=F)

library(foreign)
?read_dta
df1 <- read_dta('example.stata13.dta', encoding="latin1")
df2 <- read_dta('example.stata13.dta', encoding="CP1252")
library(readstata13)
df3 <- read.dta13('example.stata13.dta', fromEncoding="latin1")
df4 <- read.dta13('example.stata13.dta', fromEncoding="CP1252")
df5 <- read.dta13('example.stata13.dta', fromEncoding="utf-8")

vocation <- c("Brandkorpral","Sömmerska","Jungfru","Timmerman","Skomakare","Skräddare","Föreståndare","Platsförsäljare","Sömmerska")
df4$vocation == vocation
# [1]  TRUE FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE

A: The correct encoding to read files generated by Stata prior to version 14 on Macs is "macroman"
df <- read.dta13('example.stata13.dta', fromEncoding="macroman")

On my Mac, both .dta-files in stata13 and stata12 formats (saved by saveold in Stata 13) imported nicely like this.
Supposedly, the manual of read_stata13, correctly assumes "CP1252" on other platforms. To me, "macroman", however, did the trick, (also for the .csv-files that Stata 13 generated with export delimited).


text:
Q: configure default command line arguments for remote debugging in IntelliJ when debugging a Run Configuration of Type "Spring Boot" in IntelliJ, the JVM is started with the following command line arguments: -agentlib:jdwp=transport=dt_socket,address=*:12345,suspend=y,server=y
how can i change these values?
more details
i am running a Maven-based Spring Boot application in IntelliJ and WSL2. When i try to debug the Run Configuration of Type "Spring Boot", the jvm never gets past this line: Listening for transport dt_socket at address: 12345
i think it is related to the fact that WSL2 is running in a sort of virtual machine, while IntelliJ is running in Windows.
my current workaround right now is to add a modified version of -agentlib command line argument to my JVM options and attach the debugger manually after running the Run Configuration. the only modification i do is changing address=*:12345 to address=12345
my understanding is that my modification causes the agent to listen on localhost:12345 and the debugger to connect to localhost:12345. And everything works because Windows and WSL2 somehow share localhost.
how did i find the workaround?
Fortunately you can see the command line arguments used by IntelliJ when running applications. The command line arguments for some of my projects is different. Sometimes it is address=*:12345 and sometimes address=12345.
UPDATE 2021-09-18 18:45
it looks like my problem is related to ipv6 vs ipv4. my workaround causes the jvm to listen on 127.0.0.1:12345, where without the workaround it uses ipv6.

UPDATE 2021-09-19 14:00
for now i settled with a new workaround suggested by Andrey in his comment. Adding -Djava.net.preferIPv4Stack=true to command line arguments makes the JVM use IPv4. Keep attention to preferIPv4Stack vs preferIPv6Stack, when reading Andreys comment ;)

A: Add -Djava.net.preferIPv4Stack=true and -Djava.net.preferIPv6Addresses=false into Help | Edit Custom VM Options file and restart IDE.


text:
Q: How to transpose html elements in Dart when user clicks I have one or more collections of html elements as follows:

    <input type="number" class="form-control" id="cost" />

Further up the page I have a TextInputElement that changes the text of any span.symbol to whatever is entered in it (ie. £, $ etc.). So far, so good.
What I want to do is, based on a user selection, swap any of these spans with the corresponding TextInputElement so that the span.symbol appears after the TextInputElement (or before if after is already selected).
How do I do this?
EDIT:
Sorry I forgot to add my current code (which works but assumes only 2 children in the Element):
<Element>
..onClick.listen((Event e) {
    querySelectorAll('div.symbol-group').forEach((DivElement e) {
        Element e1 = e.children.first;
        Element e2 = e.children.elementAt(1);

        e.children.clear();
        e.append(e2);
        e.append(e1);

    });
});

A: I have still troubles to understand what you try to accomplish.
Just have a look at my attempt and comment how it doesn't yet do what you need.
..onClick.listen((Event e) {
    querySelectorAll('div.symbol-group').forEach((DivElement e) {
        Element e1 = e.querySelector('span.input-group-addon.symbol');
        Element e2 = e.querySelector('input.form-control');
        int i1 = e.indexOf(e1);
        int i2 = e.indexOf(e2);

        if(i1 < i2) {
          e1.remove();
          e.insert(i1, e1);
        }
    });
});


text:
Q: Automatically restart a program or keep it running I have a program that should run all the time (it collects some statistics) after Xorg start. However, there can occur some exceptions in this program, or it can be unintentionally closed, and what I want is to automatically restart it. The first idea is to run every minute another script with cron, which will restart it, but this doesn't seem optimal, so what's the preferred method of doing this?

A: There are many ways of doing this and which one you choose depends on how the script is being run. An easy way that works for any command and does not require root access is to run something like this:
while true; do pgrep -f myscript.sh >/dev/null || myscript.sh; sleep 1; done

This will run for ever (while true) and launch myscript.sh if it is not already running.


text:
Q: android disable editText in a listview at particular position I have a listview in which I want to disable the editText at only first position. This is what I have done:
@Override
public View getView(final int position, View convertView, ViewGroup parent) {

    final PatientView patientView;

    if(convertView==null){
        LayoutInflater inflater=LayoutInflater.from(context);
        convertView=inflater.inflate(R.layout.lay_add_session_view,null);
        patientView=new PatientView();
        patientView.edtSessionDescription= (EditText) convertView.findViewById(R.id.edtSessionDescription);
        patientView.edtSessionNumber= (EditText) convertView.findViewById(R.id.edtSessionNumber);
        patientView.txtSessionTime= (TextView) convertView.findViewById(R.id.txtSessionTime);
        patientView.btnAdd= (Button) convertView.findViewById(R.id.btnAdd);
        patientView.btnDelete= (Button) convertView.findViewById(R.id.btnDelete);

        convertView.setTag(patientView);
    } else {
        patientView= (PatientView) convertView.getTag();
    }

    patientView.edtSessionNumber.setText(modelPatientArrayList.get(position).getSessionNumber());
    patientView.edtSessionNumber.setTag(position);
    patientView.edtSessionDescription.setText(modelPatientArrayList.get(position).getSessionDescription());
    patientView.txtSessionTime.setText(modelPatientArrayList.get(position).getTime());

    if(0==(Integer)patientView.edtSessionNumber.getTag()){
        patientView.edtSessionNumber.setEnabled(false);
    }

    patientView.btnAdd.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.e("tag position",(Integer) patientView.edtSessionNumber.getTag()+"");
            updateFirstSession(modelPatientArrayList.get(position), patientView.edtSessionDescription.getText().toString());

            modelPatientArrayList.clear();
            modelPatientArrayList.addAll(dbUtil.getPatientSession());
            patientView.btnAdd.setText("edit");
            patientView.btnAdd.setTag(position);
            notifyDataSetChanged();

        }
    });

    patientView.btnDelete.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            deleteFromDataBase(modelPatientArrayList.get(position));
            modelPatientArrayList.clear();
            modelPatientArrayList.addAll(dbUtil.getPatientSession());
            notifyDataSetInvalidated();
        }
    });

    return convertView;
}

But the problem is it is also disabling the edittext of other view after scrolling. Can anyone please tell what am I doing wrong.

A: Put this code , should solve your prolem.
if(position == 0)
patientView.edtSessionNumber.setEnabled(false);

A: As ListView re-uses the views so you need to write code for both cases
patientView.edtSessionNumber.setEnabled( (position == 0) ? false : true);


text:
Q: How to disassociate the Bluetooth connection for a Magic Trackpad 2 from macOS? I have a Magic Trackpad 2 that's been having some intermittent slowdown when connected normally. After turning off Bluetooth generally on macOS the Magic Trackpad 2 works great all of the time with no lag/slowdown.
Clearly the problem is with the Bluetooth connection having some kind of interference or such and so I'd like to operate it with the USB cable (as I already have it plugged in 100% of the time anyway) only.
How can I, therefore, permanently disassociate a Magic Trackpad 2 device once it's been paired with macOS?

A: *

*Go to System Preferences → Bluetooth

*Right click the Magic Trackpad

*Click Remove


text:
Q: multirow problem in table I wrote a code to produce a simple table and I use \multirow
I don't know why the output is like this: !

Here is my code:
\begin{document}
\lipsum[1]
\lipsum[1]
\lipsum[1]

\definecolor{lightgray}{HTML}{EFEFEF}

\begin{table}[H]
\small
\begin{tabular}{| p{0.05\linewidth} | p{0.3\linewidth} | p{0.1\linewidth} | p{0.1\linewidth} | p{0.1\linewidth} | p{0.2\linewidth} |}
\hline
\rowcolor{lightgray}
\multicolumn{2}{|p{0.4\linewidth}|}{\textbf{BLA}} & \textbf{BLA} & \textbf{BLA} & \textbf{BLA}
& \textbf{BLA}
\\ \hline
1a & BLA
&  ++ & ++ &  ++
& BLA BLA BLA BLA BLA BLA
\\ \hline
1b & Informal notations
&  ++ & + &  +
& \multirow{2}{1\linewidth}{BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA }
\\ \hline
1c & BLA BLA BLA BLA BLA BLA
&  ++ & ++ &  ++
&
\\ \hline
1d & BLA BLA BLA BLA BLA BLA
&  + & + &  +
& ANYTHING
\\ \hline
\end{tabular}%
\caption{\textbf{BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA}}
\label{Table:Table11}
\end{table}

\end{document}

Any help ?

A: I suspect that you are after something like this:

(red lines shows page layout)

*

*Please always provide MWE (Minimal Working Example), a small but complete document, which reproduce your problem. In preamble it should load only packages relevant to your problem, document content let be limited to problem only.

*Your problem is simple to solve by use of tabularray package. Its multi row cells, itd syntax is \SetCell[r=<number of spanned rows>˙] <cell content>.

*An example of MWE is:

\documentclass{article}
\usepackage[font=bf]{caption}
\usepackage{xcolor}
\usepackage{tabularray}

%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{table}[ht]
    \centering
    \small
\begin{tblr}{hlines, vlines,
             colspec = {c X[j] lll X[j]},
              row{1} = {font=\bfseries,bg=gray!30},
               vspan = even
             }
\SetCell[c=2]{l}    BLA
    & BLA   & BLA   & BLA   & BLA   & BLA                       \\
%
1a  & BLA   &  ++   & ++    &  ++   & BLA BLA BLA BLA BLA BLA   \\
1b  & Informal notations
            &  ++   & +     &  +    & \SetCell[r=2]{j}
                                    BLA BLA BLA BLA BLA BLA BLA
                                    BLA BLA BLA BLA BLA BLA BLA
                                    BLA BLA BLA BLA BLA BLA BLA
                                    BLA BLA BLA                 \\
1c  & BLA BLA BLA BLA BLA BLA
            &  ++   & ++    &  ++   &                           \\
1d  & BLA BLA BLA BLA BLA BLA
            &  +    & +     &  +    & ANYTHING                  \\
\end{tblr}
    \caption{BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA}
    \label{Table:Table11}
    \end{table}
\end{document}

For more details how to use tabularray package, last version today is 2021P, see package documentation.

A: First, you MWE is incomplete, so I had to make a few hypotheses. Here is the code:
\documentclass{article}

\usepackage{lipsum}
\usepackage{float}
\usepackage[table]{xcolor}
\usepackage{multirow}

\begin{document}
\lipsum[1]
\lipsum[1]
\lipsum[1]

\definecolor{lightgray}{HTML}{EFEFEF}

\begin{table}[H]
\small
\begin{tabular}{| p{0.05\linewidth} | p{0.3\linewidth} | p{0.1\linewidth} | p{0.1\linewidth} | p{0.1\linewidth} | p{0.2\linewidth} |}
\hline
\rowcolor{lightgray}
\multicolumn{2}{|p{0.4\linewidth}|}{\textbf{BLA}} & \textbf{BLA} & \textbf{BLA} & \textbf{BLA}
& \textbf{BLA}
\\ \hline
1a & BLA
&  ++ & ++ &  ++
& BLA BLA BLA BLA BLA BLA
\\ \hline
1b & Informal notations
&  ++ & + &  +
& \multirow{2}{1\linewidth}{BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA }
\\ \cline{1-5}
1c & BLA BLA BLA BLA BLA BLA
&  ++ & ++ &  ++
& \\
 & & & & & \\
 & & & & & \\
 & & & & & \\
 & & & & & \\
 & & & & & \\ \hline
1d & BLA BLA BLA BLA BLA BLA
&  + & + &  +
& ANYTHING
\\ \hline
\end{tabular}%
\caption{\textbf{BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA}}
\label{Table:Table11}
\end{table}

\end{document}

Here is the relevant output:

Discussion:
There might be a way for the rows to adjust themselves vertically in multirows, but I think that's an other question.


text:
Q: jQuery srollTop conundrum I am currently having difficulty with the scrollTop() function in jQuery. At the moment, the smooth scrolling feature is scrolling past the intended section, then bouncing back to it once the function has completed running. I have included a jsFiddle at the end of this, but here is my script at the moment:
html:

Baby Step 1

Baby Step 2

Baby Step 3

Baby Step 1

second-title

content

content

Baby Step 2

Pay off all debt using the Debt Snowball

content

content

Baby Step 3

second-title

content

content

Javascript:
$(document).ready(function() {
  $('a').on('click', function(e) {
    if(this.hash !== "") {
    e.preventDefault();

    const hash = this.hash;

    $('.content').animate({
      scrollTop: $(hash).offset().top
    }, 800, function() {
      window.location.hash = hash;
      })
    }
  })
})

I have tried the suggested $('html,body') instead of $('.content'), which only succeeded in scrolling the entire page, not the div with section elements that need to be scrolled.
jsFiddle: https://jsfiddle.net/hollisd09/wa67wLc1/

A: Change this line:
scrollTop: $(hash).offset().top

into this:
scrollTop: $(hash).offset().top - $('.content').offset().top + $('.content').scrollTop()


text:
Q: Error: Returned error: The method eth_sendTransaction does not exist/is not available - Error when sending Parameters to a smart contract using infura I am getting this error when trying to send data to a smart contract using infura.
Error: Returned error: The method eth_sendTransaction does not exist/is not available
    at Object.ErrorResponse (/home/pi/node_modules/web3-core-helpers/lib/errors.js:28:19)
    at /home/pi/node_modules/web3-core-requestmanager/lib/index.js:300:36
    at /home/pi/node_modules/web3-providers-http/lib/index.js:124:13
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  data: null
}

Smart contract -
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity ^0.8.7;

import "@openzeppelin/contracts/access/Ownable.sol";

// Represents any device connected to the Raspberry Pi that you want to control
struct Appliance {
    uint256 id;
    string name;
    bool status;
    bytes1 pin;
}

contract HomeAutomationDemo is Ownable {
    uint256 nextId = 1;
    uint256 count = 0;
    mapping(uint256 => Appliance) public appliances;

    // Add a new appliance to the list
    function addAppliance(string memory name, bytes1 pin) public onlyOwner {
        appliances[nextId] = Appliance(nextId, name, false, pin);
        nextId++;
        count++;
    }

    // Remove an appliance from the list
    function removeAppliance(uint256 id) public onlyOwner {
        delete appliances[id];
        count--;
    }

    // This is the function that will be called when the user
    // toggles the status of the appliance on the mobile app
    function toggleAppliance(uint256 id, bool status) public onlyOwner {
        appliances[id].status = !appliances[id].status;
    }

    // Update the details of an appliance
    function updateAppliance(uint256 id, string memory name, bytes1 pin) public onlyOwner {
        appliances[id].name = name;
        appliances[id].pin = pin;
    }

    // Get the details of an appliance
    function getAppliance(uint256 id) public view returns (Appliance memory) {
        return appliances[id];
    }

    // Get the list of appliances
    function getAppliances() public view returns (Appliance[] memory)  {
        Appliance[] memory result = new Appliance[](count);
        for (uint256 i = 0; i < nextId; i++) {
            if (appliances[i].id != 0) {
                result[i] = appliances[i];
            }
        }
        return result;
    }

    // Get the total number of appliances
    function getAppliancesCount() public view returns (uint256) {
        return count;
    }

}

Nodejs -
const web3 = require('web3');
const fs = require("fs");

const CONTRACT_ABI = `[
        {
                "anonymous": false,
                "inputs": [
                        {
                                "indexed": true,
                                "internalType": "address",
                                "name": "previousOwner",
                                "type": "address"
                        },
                        {
                                "indexed": true,
                                "internalType": "address",
                                "name": "newOwner",
                                "type": "address"
                        }
                ],
                "name": "OwnershipTransferred",
                "type": "event"
        },
        {
                "inputs": [
                        {
                                "internalType": "string",
                                "name": "name",
                                "type": "string"
                        },
                        {
                                "internalType": "bytes1",
                                "name": "pin",
                                "type": "bytes1"
                        }
                ],
                "name": "addAppliance",
                "outputs": [],
                "stateMutability": "nonpayable",
                "type": "function"
        },
        {
                "inputs": [
                        {
                                "internalType": "uint256",
                                "name": "",
                                "type": "uint256"
                        }
                ],
                "name": "appliances",
                "outputs": [
                        {
                                "internalType": "uint256",
                                "name": "id",
                                "type": "uint256"
                        },
                        {
                                "internalType": "string",
                                "name": "name",
                                "type": "string"
                        },
                        {
                                "internalType": "bool",
                                "name": "status",
                                "type": "bool"
                        },
                        {
                                "internalType": "bytes1",
                                "name": "pin",
                                "type": "bytes1"
                        }
                ],
                "stateMutability": "view",
                "type": "function"
        },
        {
                "inputs": [
                        {
                                "internalType": "uint256",
                                "name": "id",
                                "type": "uint256"
                        }
                ],
                "name": "getAppliance",
                "outputs": [
                        {
                                "components": [
                                        {
                                                "internalType": "uint256",
                                                "name": "id",
                                                "type": "uint256"
                                        },
                                        {
                                                "internalType": "string",
                                                "name": "name",
                                                "type": "string"
                                        },
                                        {
                                                "internalType": "bool",
                                                "name": "status",
                                                "type": "bool"
                                        },
                                        {
                                                "internalType": "bytes1",
                                                "name": "pin",
                                                "type": "bytes1"
                                        }
                                ],
                                "internalType": "struct Appliance",
                                "name": "",
                                "type": "tuple"
                        }
                ],
                "stateMutability": "view",
                "type": "function"
        },
        {
                "inputs": [],
                "name": "getAppliances",
                "outputs": [
                        {
                                "components": [
                                        {
                                                "internalType": "uint256",
                                                "name": "id",
                                                "type": "uint256"
                                        },
                                        {
                                                "internalType": "string",
                                                "name": "name",
                                                "type": "string"
                                        },
                                        {
                                                "internalType": "bool",
                                                "name": "status",
                                                "type": "bool"
                                        },
                                        {
                                                "internalType": "bytes1",
                                                "name": "pin",
                                                "type": "bytes1"
                                        }
                                ],
                                "internalType": "struct Appliance[]",
                                "name": "",
                                "type": "tuple[]"
                        }
                ],
                "stateMutability": "view",
                "type": "function"
        },
        {
                "inputs": [],
                "name": "getAppliancesCount",
                "outputs": [
                        {
                                "internalType": "uint256",
                                "name": "",
                                "type": "uint256"
                        }
                ],
                "stateMutability": "view",
                "type": "function"
        },
        {
                "inputs": [],
                "name": "owner",
                "outputs": [
                        {
                                "internalType": "address",
                                "name": "",
                                "type": "address"
                        }
                ],
                "stateMutability": "view",
                "type": "function"
        },
        {
                "inputs": [
                        {
                                "internalType": "uint256",
                                "name": "id",
                                "type": "uint256"
                        }
                ],
                "name": "removeAppliance",
                "outputs": [],
                "stateMutability": "nonpayable",
                "type": "function"
        },
        {
                "inputs": [],
                "name": "renounceOwnership",
                "outputs": [],
                "stateMutability": "nonpayable",
                "type": "function"
        },
        {
                "inputs": [
                        {
                                "internalType": "uint256",
                                "name": "id",
                                "type": "uint256"
                        },
                        {
                                "internalType": "bool",
                                "name": "status",
                                "type": "bool"
                        }
                ],
                "name": "toggleAppliance",
                "outputs": [],
                "stateMutability": "nonpayable",
                "type": "function"
        },
        {
                "inputs": [
                        {
                                "internalType": "address",
                                "name": "newOwner",
                                "type": "address"
                        }
                ],
                "name": "transferOwnership",
                "outputs": [],
                "stateMutability": "nonpayable",
                "type": "function"
        },
        {
                "inputs": [
                        {
                                "internalType": "uint256",
                                "name": "id",
                                "type": "uint256"
                        },
                        {
                                "internalType": "string",
                                "name": "name",
                                "type": "string"
                        },
                        {
                                "internalType": "bytes1",
                                "name": "pin",
                                "type": "bytes1"
                        }
                ],
                "name": "updateAppliance",
                "outputs": [],
                "stateMutability": "nonpayable",
                "type": "function"
        }
]`;
const CONTRACT_ADDRESS = "0x13d9FA79D364070510B410c2FaC1976F21E3e218";

const web3js = new web3(new web3.providers.HttpProvider("https://sepolia.infura.io/v3/9e644c118b7c44068674e2d12a776536"));

var myAddress = '0x46Be881Fa6935a8FC969A4ddDFC74d625c558996';
const privateKey = Buffer.from('82f98661ea7e05ac4bad0965da4b8a1fab93cf27e606d1185a275c91f96aac9b', 'hex')
var contractABI =JSON.parse(CONTRACT_ABI);
var contractAddress = CONTRACT_ADDRESS;

contract = new web3js.eth.Contract(contractABI,contractAddress);

// first populate an appliance

async function main () {

let setAppliance = await contract.methods.addAppliance("fan", web3.utils.numberToHex(1)).send({from: myAddress});
console.log(setAppliance);

let applianceOnOff = await contract.methods.getAppliances().call();
console.log(applianceOnOff);
}

main()
 .then(() => process.exit(0))
 .catch(error => {
        console.error(error);
        process.exit(1);
});

I searched online and it seems infura doesn't support signing transactions. I tried some other fixes but unfortunately it didn't work. But calling functions from the smart contract does work.

A: There are two problems, first you need to add your private key to the wallet to create a send transaction:
const privateKey = "82f98661ea7e05ac4bad0965da4b8a1fab93cf27e606d1185a275c91f96aac9b";
const account = web3js.eth.accounts.privateKeyToAccount('0x' + privateKey);
web3js.eth.accounts.wallet.add(account);

And you can't use await with contractInstance.method.send format.
So your final code should be:
const web3 = require('web3');
const fs = require("fs");

const CONTRACT_ABI = `[
        {
                "anonymous": false,
                "inputs": [
                        {
                                "indexed": true,
                                "internalType": "address",
                                "name": "previousOwner",
                                "type": "address"
                        },
                        {
                                "indexed": true,
                                "internalType": "address",
                                "name": "newOwner",
                                "type": "address"
                        }
                ],
                "name": "OwnershipTransferred",
                "type": "event"
        },
        {
                "inputs": [
                        {
                                "internalType": "string",
                                "name": "name",
                                "type": "string"
                        },
                        {
                                "internalType": "bytes1",
                                "name": "pin",
                                "type": "bytes1"
                        }
                ],
                "name": "addAppliance",
                "outputs": [],
                "stateMutability": "nonpayable",
                "type": "function"
        },
        {
                "inputs": [
                        {
                                "internalType": "uint256",
                                "name": "",
                                "type": "uint256"
                        }
                ],
                "name": "appliances",
                "outputs": [
                        {
                                "internalType": "uint256",
                                "name": "id",
                                "type": "uint256"
                        },
                        {
                                "internalType": "string",
                                "name": "name",
                                "type": "string"
                        },
                        {
                                "internalType": "bool",
                                "name": "status",
                                "type": "bool"
                        },
                        {
                                "internalType": "bytes1",
                                "name": "pin",
                                "type": "bytes1"
                        }
                ],
                "stateMutability": "view",
                "type": "function"
        },
        {
                "inputs": [
                        {
                                "internalType": "uint256",
                                "name": "id",
                                "type": "uint256"
                        }
                ],
                "name": "getAppliance",
                "outputs": [
                        {
                                "components": [
                                        {
                                                "internalType": "uint256",
                                                "name": "id",
                                                "type": "uint256"
                                        },
                                        {
                                                "internalType": "string",
                                                "name": "name",
                                                "type": "string"
                                        },
                                        {
                                                "internalType": "bool",
                                                "name": "status",
                                                "type": "bool"
                                        },
                                        {
                                                "internalType": "bytes1",
                                                "name": "pin",
                                                "type": "bytes1"
                                        }
                                ],
                                "internalType": "struct Appliance",
                                "name": "",
                                "type": "tuple"
                        }
                ],
                "stateMutability": "view",
                "type": "function"
        },
        {
                "inputs": [],
                "name": "getAppliances",
                "outputs": [
                        {
                                "components": [
                                        {
                                                "internalType": "uint256",
                                                "name": "id",
                                                "type": "uint256"
                                        },
                                        {
                                                "internalType": "string",
                                                "name": "name",
                                                "type": "string"
                                        },
                                        {
                                                "internalType": "bool",
                                                "name": "status",
                                                "type": "bool"
                                        },
                                        {
                                                "internalType": "bytes1",
                                                "name": "pin",
                                                "type": "bytes1"
                                        }
                                ],
                                "internalType": "struct Appliance[]",
                                "name": "",
                                "type": "tuple[]"
                        }
                ],
                "stateMutability": "view",
                "type": "function"
        },
        {
                "inputs": [],
                "name": "getAppliancesCount",
                "outputs": [
                        {
                                "internalType": "uint256",
                                "name": "",
                                "type": "uint256"
                        }
                ],
                "stateMutability": "view",
                "type": "function"
        },
        {
                "inputs": [],
                "name": "owner",
                "outputs": [
                        {
                                "internalType": "address",
                                "name": "",
                                "type": "address"
                        }
                ],
                "stateMutability": "view",
                "type": "function"
        },
        {
                "inputs": [
                        {
                                "internalType": "uint256",
                                "name": "id",
                                "type": "uint256"
                        }
                ],
                "name": "removeAppliance",
                "outputs": [],
                "stateMutability": "nonpayable",
                "type": "function"
        },
        {
                "inputs": [],
                "name": "renounceOwnership",
                "outputs": [],
                "stateMutability": "nonpayable",
                "type": "function"
        },
        {
                "inputs": [
                        {
                                "internalType": "uint256",
                                "name": "id",
                                "type": "uint256"
                        },
                        {
                                "internalType": "bool",
                                "name": "status",
                                "type": "bool"
                        }
                ],
                "name": "toggleAppliance",
                "outputs": [],
                "stateMutability": "nonpayable",
                "type": "function"
        },
        {
                "inputs": [
                        {
                                "internalType": "address",
                                "name": "newOwner",
                                "type": "address"
                        }
                ],
                "name": "transferOwnership",
                "outputs": [],
                "stateMutability": "nonpayable",
                "type": "function"
        },
        {
                "inputs": [
                        {
                                "internalType": "uint256",
                                "name": "id",
                                "type": "uint256"
                        },
                        {
                                "internalType": "string",
                                "name": "name",
                                "type": "string"
                        },
                        {
                                "internalType": "bytes1",
                                "name": "pin",
                                "type": "bytes1"
                        }
                ],
                "name": "updateAppliance",
                "outputs": [],
                "stateMutability": "nonpayable",
                "type": "function"
        }
]`;
const CONTRACT_ADDRESS = "0x13d9FA79D364070510B410c2FaC1976F21E3e218";

const web3js = new web3(new web3.providers.HttpProvider("https://sepolia.infura.io/v3/9e644c118b7c44068674e2d12a776536"));

var myAddress = '0x46Be881Fa6935a8FC969A4ddDFC74d625c558996';
const privateKey = "82f98661ea7e05ac4bad0965da4b8a1fab93cf27e606d1185a275c91f96aac9b";
const account = web3js.eth.accounts.privateKeyToAccount('0x' + privateKey);
web3js.eth.accounts.wallet.add(account);

console.log(privateKey);
var contractABI = JSON.parse(CONTRACT_ABI);
var contractAddress = CONTRACT_ADDRESS;
contract = new web3js.eth.Contract(contractABI, contractAddress);

// first populate an appliance

function main() {

    contract.methods.addAppliance("fan", web3.utils.numberToHex(1)).send({ from: myAddress, gas: 230000 })
        .on("receipt", (receipt) => {
            console.log("receipt:");
            console.log(receipt);
            contract.methods.getAppliances().call({ from: myAddress }).then(res => {
                console.log(res);
            });
        });
}

main()

P.S. there is a problem with the getAppliances method, you need to debug it and redeploy the contract, but addAppliance method would work.


text:
Q: Remove VIP mail box from sidebar in Mac Mail I accidentally set one of my contacts to be a VIP in Mac Mail, it then added this folder in the image below into the sidebar, when i removed the VIP status of that contact the VIP folder still remained in the sidebar.. any idea how i can remove it ?

A: I found what worked was:

*

*Remove all VIP contacts

*Close Mail

*Reboot the machine

Upon reopening Mail, the VIP section in the sidebar is now gone.
UPDATE - At the time of writing this initial post i was running OSX 10.9.

A: Got this working in OS X 10.10, Yosemite:

*

*Close Mail.app.

*Go to ~/Library/Mail/V2/MailData/.

*Edit VIPSenders.plist and remove all the senders.

*Save the file.

*Select the file and press Command + i to see information about the file.

*Check Locked under general info.

*Reopen Mail.app.

A: OS 10.11.6 Open the email in the VIPS folder. Click the star next to the "From" email. That removes it from the VIPS folder and the VIPS folder goes away. If you have more than one email in the VIPS folder, you will need to repeat for each email and then the VIPS folder goes away.

A: *

*close Mail app

*cd ~/Library/Mail/V5/MailData/

*rm VIPs.plist

*rm VIPMailboxes.plist

OS: 10.13.6

A: The way in which to remove a favourite from Mail is simple, highlight the account, for instance if John Smith was a favourite, highlight their name, click on the little settings bar below, thats next to the new mailbox icon, and then click 'Remove from VIP's'.

A: In Mojave 10.14.5:

*

*Remove stars from VIP contacts

*Select any inbox but VIPs

*Restart
Mail

A: What worked for me:

*

*Go to Library/Mail and (depending on your system, V2 or V3) one and find Data and then VPIs.plist and delete it.

*Create a new mailbox and rename it whatever then simply select that dummy mailbox and quit Mail.

*Reopen Mail and the VIPs mailbox should ne be there. Delete the dummy Mailbox.

A: Go to your VIP folder and open an email from the person you want to take off the VIP status.
Scroll over to the email on that person's name in the email heading, and it will be  highlight.
To the right of the person's name you will see an arrow. Click on it.
From here there will be an option to "Remove from VIP list".
If you have no more names in the VIP folder, then at this time the folder will disappear.
If you have other names in the VIP folder, then the folder will remain until it is empty of all names.


text:
Q: $C^{1}([0,1])$ is dense in $C([0,1])$ Consider the Banach space $C([0,1])$ with $\| . \|_{\infty}$ maximum norm. Consider the linear functional $F_{n} : C([0,1]) \to \mathbb{R}$, $ F_{n} (f) = f(1) - f\big(\frac{2n - 2}{2n - 1}\big) + f\big(\frac{2n-3}{2n-1}\big) - f\big(\frac{2n-4}{2n-1}\big) + ... - f(0)$
Show that $C^{1}([0,1])$ is dense in $C([0,1])$.
I would like to prove this using those functionals. My teacher gave me this hint: Weierstrass Approximation Theorem.
W.A. Theorem: If $f$ is continuous real-valued function on $[a,b]$ and if given any $\epsilon >0$ , then there exists a polynomial $p$ on $[a,b]$ such that $|f(x) - p(x)|< \epsilon \; \;\forall x \in \; [a,b]$ .
But I guess I'm needing another hint there. I know each one of there $F_n$'s are continuous real valued functions on $[0,1]$, then I can approximate by polynomials each one of them.
I know that in Baire spaces the enumerable intersection of open dense $G_{n}$ is dense. This is a Banach space, then it is complete, then this is true. Would $C^1 ([0,1])$ be an enumerable intersection of open dense $G_{n}$'s?
My problem is using these ideas for the start of the proof.
Any help would be appreciated.
It appear that it can be proven without the $F_n$. I actually need them to prove this:
$\forall f \in C^1 ( [0,1]), \lim_{n \to \infty} F_n (f) = \frac{ f(1) - f(0)}{2}$
Thanks.

A: Maybe it is sufficient to note that if A $\subset$ B then $\bar{A} \subset \bar{B}$ since polynomials are in $C^1([0, 1])$.


text:
Q: how to create a link element tag to about:config? I tried,
setup

element just shows up on the Firefox browser, but cannot open it (clicking won't work) or open it in a new tab.
Is there a way to create a link element to open up about:config page in Firefox using just HTML?
According to this it's imposible Anchor link to Firefox about:config?
right?
But, how about in Selenium with geckodriver?

A: I think this question answers your question: Anchor link to Firefox about:config?. Give it a try. Basically, you are not allowed to reference a local resource due to security issues (like the post says).

A: Sorry, it's not possible due to security concerns.
I'm not sure how useful this is, but if you can get the user to create a bookmark, it will work from a bookmark.


text:
Q: CSV to JSON with Specific format I Have csv file with  this data and using python i would like to convert in json Format.
I would like to convert in this format Json Format.Can you tell me the which library i should use or any suggestion for sudo code.
I am able to convert in standard json which has key value pair but i don't know how to convert below Json Format.
"T-shirt","Long-tshirt",18
"T-shirt","short-tshirt"19
"T-shirt","half-tshirt",20
"top","very-nice",45
"top","not-nice",56

{
"T-shirts":[
  {
  "name":"Long-tshirt",
  "size":"18"
  },
  {
  "name":"short-tshirt",
  "size":"19"
  },
  {
  "name":"half-tshirt",
  "size":"20"
  },
  ],
"top":[
  {
  "name":"very-nice"
  "size":45
  },
  {
  "name":"not-nice"
  "size":45
  },
  ]
}

A: In this code, I put your CSV into test.csv file: (as a heads up, the provided code was missing a comma before the 19).
"T-shirt","Long-tshirt",18
"T-shirt","short-tshirt",19
"T-shirt","half-tshirt",20
"top","very-nice",45
"top","not-nice",56

Then, using the built-in csv and json modules you can iterate over each row and add them to a dictionary. I used a defaultdict to save time, and write out that data to a json file.
import csv, json
from collections import defaultdict

my_data = defaultdict(list)

with open("test.csv") as csv_file:
    reader = csv.reader(csv_file)
    for row in reader:
        if row: # To ignore blank lines
            my_data[row[0]].append({"name": row[1], "size": row[2]})

with open("out.json", "w") as out_file:
    json.dump(my_data, out_file, indent=2)

Generated out file:
{
  "T-shirt": [
    {
      "name": "Long-tshirt",
      "size": "18"
    },
    {
      "name": "short-tshirt",
      "size": "19"
    },
    {
      "name": "half-tshirt",
      "size": "20"
    }
  ],
  "top": [
    {
      "name": "very-nice",
      "size": "45"
    },
    {
      "name": "not-nice",
      "size": "56"
    }
  ]
}

A: import json

json_string = json.dumps(your_dict)

You now have a string containing json formatted date from your original dictionary - is that what you wanted?


text:
Q: movenext and moveprevious navigation A dropdownlist with numerous items, movenext and moveprevious navigation buttons to display an image for each selected item. Each image is displayed in the same image control. The image data in the database is simply a path to the image file.
Using the DataReader and stored procedure for data, how do I move next and previous without having to access the database each time?
ASP.NET 4, C#, MS SQL Server 2008

A: DataReader by definition works only in connected mode, requires an open connection and in fact translates in a SQL Cursor so it does access the database every time you do a move next.
if you want to fetch all image paths at once and then work disconnected with no more roundtrips on the database use a DataSet instead.


text:
Q: How to link cell value as a filter in PowerPivot Pivot Table in Excel? I have two Pivot Table (PivotTable1 and PivotTable2) in Sheet PivotTables_Sheetand a cell that shows the year in Sheet YearInput. I tried to link the cell year (J4) in YearInput as a filter to all pivot tables in PivotTables Sheet.
But somehow my code doesn't work as expected. Anybody knows how to correct this code?
This is the code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Not Target.Address = Range("J4").Address Then Exit Sub
     Dim pt As PivotTable
     Dim ptItem As PivotItem
   On Error Resume Next
  For Each pt In Worksheets("PivotTables_Sheet").PivotTables
    With pt.PivotFields("Year for Sales")
        If .EnableMultiplePageItems = True Then
            .ClearAllFilters
        End If
        Set ptItem = .PivotItems(Target.Value)
        If Not ptItem Is Nothing Then
            .CurrentPage = Target.Value
         End If
      End With
  Next
End Sub

Note: I use Excel 2010 and built the pivot tables using PowerPivot.

A: One way to do this without VBA is to use a slicer which is common between all the pivots.  Then one year is changed on one, it will also update the other pivot tables.
This is by first clicking on the pivot, which will then show on the ribbon an Analyze option.  Under that there is an insert slicer, which you would do for year.
Afterwards you would go to your other pivots and instead do filter connection, and select your year slicer.
Note that the year slicer can then just be moved to a hidden sheet if you do not want the end user to see it, it will still do its job of propagating the year across all the pivots that are referencing it.


text:
Q: Difference between Logger.getLogger(className) and LogFactory.getLog(className )? I know its a package difference
1) org.apache.log4j.Logger logger = Logger.getLogger(clazz);
2) org.apache.commons.logging.Log log = LogFactory.getLog(clazz);
The first one uses loggers via log4j and the second one uses commons.logging. We have a huge project where in some classes loggers are configured using log4j and in some cases its commons.logging.
I did find a log4j property file though.Is there a similar property file for commons.logging ? Where do I configure for commons-logging ?. I am unable to see the logs generated by commons-logging.
Any help is appreciated.

A: Yes, commons-logging is a facade API that was suppose to abstract you from underlying logging framework (in practice there was a choice between log4j and java.util.logging) so that you could switch from one to another without touching the code - just by switching libraries available on the CLASSPATH.
Unfortunately due to some design mistakes it had issues with complex class-loading environments, like application servers. Currently it is effectively superseded by slf4j.
In your case I would recommend sticking with one API - either Log4J or commons-logging, even though commons-logging will (most likely) delegate to log4J. You can also migrate to using SLF4J and install bridging APIs, but this is slightly more advanced.


text:
Q: Does it make sense to quantize perfect fluid? Wikipedia (see here) says perfect fluid may be quantized. I do find an article (arXiv 1011.6396) about this, and the procedure is straight forward. What I do not understand is whether this quantization really makes sense, i.e. whether the quantized liquid dynamics corresponds to actual systems.
For example, can a quantum many-body system - like electrons in a metal - be described using a quantized version fluid dynamics? Does this give a universal scheme of bosonization?

A: Liquid helium can be described as superfluid.

the first liquid in which superfluidity was recognized was helium-4 back in 1938. It loses its viscosity below 2.12  K. At the time Fritz London suggested that the phenomenon was associated with Bose-Einstein condensation (BEC), which occurs when an assembly of bosons (particles with zero or integer "spin") is cooled below a critical temperature. In Bose-Einstein condensation a large fraction of all the particles in the assembly congregate in the zero-momentum ground state.

....

Although it is generally agreed that there is a close association between Bose-Einstein condensation and superfluidity, the exact relationship has yet to be established.

The review starts with"

Recent work at Göttingen has revealed convincing evidence for superfluidity in liquid hydrogen, the only liquid other than helium to exhibit this quantum behaviour.

and ends with:

How does this result relate to more conventional types of experiment? It should be emphasized that superfluidity in a shell containing about 15 hydrogen molecules does not necessarily mean that the phenomenon will ever be observed in bulk liquid. Indeed, it probably will not, due to the difficulty of maintaining the liquid state at low enough temperatures. .....

So it seems there is research going on.


text:
Q: App working on Nougat+ versions but crashing on Marshmallow and Lollipop This is the error report whenever I launch the app it crashes and says

Unfortunately, {app-name} has stopped

java.lang.RuntimeException:
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2339)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2413)
  at android.app.ActivityThread.access$800 (ActivityThread.java:155)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1317)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:135)
  at android.app.ActivityThread.main (ActivityThread.java:5343)
  at java.lang.reflect.Method.invoke (Native Method)
  at java.lang.reflect.Method.invoke (Method.java:372)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:905)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:700)

Caused by: android.view.InflateException:
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:763)
  at android.view.LayoutInflater.rInflate (LayoutInflater.java:806)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:504)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:414)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:365)
  at android.support.v7.app.AppCompatDelegateImplV9.setContentView (AppCompatDelegateImplV9.java:287)
  at android.support.v7.app.AppCompatActivity.setContentView (AppCompatActivity.java:139)
  at com.khokhar.yousaf.cipher.Splash.onCreate (Splash.java:15)
  at android.app.Activity.performCreate (Activity.java:6010)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1129)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2292)

Caused by: android.content.res.Resources$NotFoundException:
  at android.content.res.Resources.loadDrawableForCookie (Resources.java:2444)
  at android.content.res.Resources.loadDrawable (Resources.java:2384)
  at android.content.res.TypedArray.getDrawable (TypedArray.java:749)
  at android.view.View.<init> (View.java:3742)
  at android.widget.ImageView.<init> (ImageView.java:149)
  at android.widget.ImageView.<init> (ImageView.java:145)
  at android.support.v7.widget.AppCompatImageView.<init> (AppCompatImageView.java:71)
  at android.support.v7.widget.AppCompatImageView.<init> (AppCompatImageView.java:67)
  at android.support.v7.app.AppCompatViewInflater.createImageView (AppCompatViewInflater.java:181)
  at android.support.v7.app.AppCompatViewInflater.createView (AppCompatViewInflater.java:105)
  at android.support.v7.app.AppCompatDelegateImplV9.createView (AppCompatDelegateImplV9.java:1035)
  at android.support.v7.app.AppCompatDelegateImplV9.onCreateView (AppCompatDelegateImplV9.java:1092)
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:725)

This is my Splash Screen coding
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Window;

public class Splash extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_splash);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        //thread for splash screen running
        Thread logoTimer = new Thread() {
            public void run() {
                try {
                    sleep(2500);
                } catch (InterruptedException e) {
                    Log.d("Exception", "Exception" + e);
                } finally {
                    startActivity(new Intent(Splash.this, MainActivity.class));
                }
                finish();
            }
        };
        logoTimer.start();
    }

}

And this XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/splashScreen"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/colorPrimary"
    android:orientation="vertical"
    tools:context="com.khokhar.yousaf.cipher.Splash">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:background="@drawable/ic_launcher_foreground"
        android:contentDescription="@string/app_name"
        android:scaleType="fitXY"
        android:src="@drawable/mediumload" />

</RelativeLayout>

The drawable image I used is 600x1024 PNG
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.khokhar.yousaf.cipher">

    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:fullBackupContent="true"
        android:hardwareAccelerated="true"
        android:icon="@drawable/cee"
        android:label="@string/app_name"
        android:roundIcon="@drawable/cee"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity"
            android:theme="@style/AppTheme">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <!-- Accepts URIs that begin with "java-lang-programming://android-app-google-plus-demo"-->
                <data
                    android:host="cipherengineers"
                    android:scheme="android-app-cipher-engineers" />
            </intent-filter>
        </activity>

        <activity android:name=".Splash"
            android:theme="@style/AppTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

    </application>

</manifest>

My MainActivity is basically webview
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Message;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.CookieManager;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    ProgressBar progressBar;
    WebView webView;
    String url="https://website/";
    TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        progressBar = (ProgressBar) findViewById(R.id.progressBar1);
        webView = (WebView) findViewById(R.id.webView);
        textView = (TextView) findViewById(R.id.textView1212);

        webView.setWebChromeClient(new WebChromeClient() {
            public void onProgressChanged(WebView view, int progress) {

                progressBar.setProgress(progress);
                textView.setText(progress + "");
            }
            @Override
            public boolean onCreateWindow(WebView view, boolean isDialog,
                                          boolean isUserGesture, Message resultMsg) {

                WebView newWebView = new WebView(MainActivity.this);
                newWebView.getSettings().setJavaScriptEnabled(true);
                newWebView.getSettings().setSupportZoom(true);
                newWebView.getSettings().setBuiltInZoomControls(true);
                newWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
                newWebView.getSettings().setSupportMultipleWindows(true);
                view.addView(newWebView);
                WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
                transport.setWebView(newWebView);
                resultMsg.sendToTarget();

                newWebView.setWebViewClient(new WebViewClient() {
                    @Override
                    public boolean shouldOverrideUrlLoading(WebView view, String url) {
                        view.loadUrl(url);
                        return true;
                    }
                });

                return true;
            }

});

        webView.setWebViewClient(new MyWebViewClient());
        WebSettings browserSetting = webView.getSettings();
        webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setAcceptCookie(true);
        browserSetting.setJavaScriptCanOpenWindowsAutomatically(true);
        browserSetting.setJavaScriptEnabled(true);
        browserSetting.setLoadWithOverviewMode(true);
        browserSetting.setSupportMultipleWindows(true);
        browserSetting.setDatabaseEnabled(true);
        browserSetting.setAppCacheEnabled(true);
        browserSetting.setDomStorageEnabled(true);
        browserSetting.setDomStorageEnabled(true);
        browserSetting.setGeolocationEnabled(true);
        browserSetting.setSaveFormData(false);
        browserSetting.setUseWideViewPort(true);
        browserSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        browserSetting.setCacheMode(WebSettings.LOAD_NO_CACHE);
        browserSetting.setDomStorageEnabled(true);
        if (android.os.Build.VERSION.SDK_INT >= 21) {
            CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
        }else {
            CookieManager.getInstance().setAcceptCookie(true);
        }
        webView.loadUrl(url);
    }

    private class MyWebViewClient extends WebViewClient {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            progressBar.setVisibility(View.INVISIBLE);
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            progressBar.setVisibility(View.GONE);
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // Check if the key event was the Back button and if there's history
        if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
            webView.goBack();
            return true;
        }
        // If it wasn't the Back key or there's no web page history, bubble up to the default
        // system behavior (probably exit the activity)
        return super.onKeyDown(keyCode, event);
    }
    public void onBackPressed() {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                MainActivity.this);

        // set title
        alertDialogBuilder.setTitle("Exit");

        // set dialog message
        alertDialogBuilder
                .setMessage("Are You Sure?")
                .setCancelable(false)
                .setPositiveButton("Yes",new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog,int id) {
                        // if this button is clicked, close
                        // current activity
                        MainActivity.this.finish();
                    }
                })
                .setNegativeButton("No",new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        // if this button is clicked, just close
                        // the dialog box and do nothing
                        dialog.cancel();
                    }
                });

        // create alert dialog
        AlertDialog alertDialog = alertDialogBuilder.create();

        // show it
        alertDialog.show();
        alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.GRAY));

    }
}

I removed background from Splash Screen XML and nothing worked
MainActivity XML
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@drawable/loading_screen"

    android:orientation="vertical"
    tools:context="com.khokhar.yousaf.cipher.MainActivity">

    <ProgressBar
        android:id="@+id/progressBar1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_gravity="center_vertical|center_horizontal"
        android:layout_marginTop="218dp"
        android:progressTint="?android:attr/fastScrollTextColor"
        android:visibility="invisible" />

    <TextView
        android:id="@+id/textView1212"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="23dp"
        android:textColor="@android:color/holo_red_dark"
        android:textSize="13sp"
        android:textStyle="bold|italic" />

    <WebView
        android:id="@+id/webView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:animationCache="true"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="41dp" />
</RelativeLayout>

I can't figure it out.

A: Removing the background from ImageView
The reason is lower versions are not able to find ic_launcher_foreground in the drawable directory which actually exists in drawable-v24.

A: Remove the background image and write your ImageView like this
 <ImageView
    android:id="@+id/imageView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:contentDescription="@string/app_name"
    android:scaleType="fitXY"
    android:src="@drawable/mediumload" />

A: you cant start a new Activity on Background Thread.. since you run new Thread and inside you start a new Activity it will crash..
2 solutions : declare Handler outside the Thread
Handler handler = new Handler();

inside the thread run
   handler.post(new Runnable() { public void run() { startActivity(..) } });
or use function :
RunOnUiThread(new Runnable() { public void run() { startActivity(...) } );


text:
Q: How do I demonstrate a Second Order SQL Injection? So I've been trying to replicate a second order SQL Injection. Here's an example template of two php based sites that I've prepared. Let's just call it a voter registration form. A user can register and then you can check if you're a registered voter or not.
insert.php
<?php

$db_selected = mysql_select_db('canada',$conn);
if (!db_selected)
    die("can't use mysql: ". mysql_error());

$sql_statement = "INSERT into canada (UserID,FirstName,LastName,Age,State,Town)
                    values ('".mysql_real_escape_string($_REQUEST["UserID"])."',
                    '".mysql_real_escape_string($_REQUEST["FirstName"])."',
                    '".mysql_real_escape_string($_REQUEST["LastName"])."',
                    ".intval($_REQUEST["Age"]).",
                    '".mysql_real_escape_string($_REQUEST["State"])."',
                    '".mysql_real_escape_string($_REQUEST["Town"])."')";

echo "You ran the sql query=".$sql_statement."
";
$qry = mysql_query($sql_statement,$conn) || die (mysql_error());
mysql_close($conn);
Echo "Data inserted successfully";
}
?>

select.php
<?php

$db_selected = mysql_select_db('canada', $conn);
if(!db_selected)
    die('Can\'t use mysql:' . mysql_error());
$sql = "SELECT * FROM canada WHERE UserID='".addslashes($_POST["UserID"])."'";
echo "You ran the sql query=".$sql."
";
$result = mysql_query($sql,$conn);
$row=mysql_fetch_row($result);

$sql1 = "SELECT * FROM canada WHERE FirstName = '".$row[1]."'";
echo "The web application ran the sql query internally=" .$sql1. "
";
$result1 = mysql_query($sql1, $conn);
$row1 = mysql_fetch_row($result1);

mysql_close($conn);
echo "
Database Output

";

echo "
$row1[1] $row1[2] , you are a voter!
";

echo "VoterID: $row[0]
First Name: $row[1]
Last Name: $row[2]

Age: $row[3]
Town: $row[4]
State: $row[5]

";
}
?>

So I purposely made this vulnerable to show how second order SQL Injection works, a user can type in a code into the first name section (where I am currently stuck, I've tried many different ways but it seems that I can't get it to do anything).
Then when a person wants to activate the code that he has inserted in the first name section, all he needs to do is just type in the userID and the code will be inserted.
For example:
I will type into the insert.php page as:
userid = 17
firstname = (I need to inject something here)
lastname = ..
age = ..
town = ..
state = ..
Then when I check for my details, and type in 17, the SQL script injected will be activated.
Can I get few examples on what sort of vulnerabilities I can show through this?

A: What is there to demonstrate?
Second order SQL injection is nothing more than SQL injection, but the unsafe code isn't the first line.
So, to demonstrate:
1) Create a SQL injection string that would do something unwanted when executed without escaping.
2) Store that string safely in your DB (with escaping).
3) Let some other piece of your code FETCH that string, and use it elsewhere without escaping.
EDIT: Added some examplecode:
A table:
CREATE TABLE tblUsers (
  userId serial PRIMARY KEY,
  firstName TEXT
)

Suppose you have some SAFE code like this, receiving firstname from a form:
$firstname = someEscapeFunction($_POST["firstname"]);

$SQL = "INSERT INTO tblUsers (firstname) VALUES ('{$firstname }');";
someConnection->execute($SQL);

So far, so good, assuming that someEscapeFunction() does a fine job. It isn't possible to inject SQL.
If I would send as a value for firstname the following line, you wouldn't mind:
bla'); DELETE FROM tblUsers; //
Now, suppose somebody on the same system wants to transport firstName from tblUsers to tblWhatever, and does that like this:
$userid = 42;
$SQL = "SELECT firstname FROM tblUsers WHERE (userId={$userid})";
$RS = con->fetchAll($SQL);
$firstName = $RS[0]["firstName"];

And then inserts it into tblWhatever without escaping:
$SQL = "INSERT INTO tblWhatever (firstName) VALUES ('{$firstName}');";

Now, if firstname contains some deletecommand it will still be executed.

A: Using a first name of:
' OR 1 OR '

This will produce a where clause in the second SQL of

WHERE FirstName = '' OR 1 OR ''

Therefore the result will be the first record in the table.
By adding a LIMIT clause, you can extract all rows from the table with:

' OR 1 ORDER BY UserID ASC LIMIT 0, 1 --

Obviously it will only extract 1 row at a time, so you would need to repeat that and increment the 0 in the LIMIT. This example uses a comment -- to terminate the remaining SQL which would otherwise cause the query to fail because it would add a single quote after your LIMIT.
The above is a simple example, a more complex attack would be to use a UNION SELECT which would give you access to the entire DB through the use of information_schema.
Also you are using addslashes() in one of your queries. That is not as secure as mysql_real_escape_string() and in turn: escaping quotes with either is not as secure as using prepared statements or parameterised queries for example in PDO or MySQLi.


text:
Q: How to stop on_message() in discord.py by using another function? I want to stop a function using another function.
def on_message(message):
    #DO WHAT I WANT
    terminate_function(#if condition met)
def terminate_function():
    #terminate_function code

What should I put for #terminate_function code ?

A: To exit out of a function you can use the return keyword.
def on_message(message):
    # do what you want

    if "condition met":
        return

    print("this is not printed if the condition is met")

A: You can't make a function return from another function. What you could do to solve this is make the terminate function return a bool & check that.
def on_message(message):
    #DO WHAT I WANT
    if should_terminate():
        return

def should_terminate() -> bool:
    #DO SOMETHING
    return condition_met  # True if on_message should terminate, False if not

Alternatively, if you really want the other function to break the first one, an ugly solution is to throw an error.
def on_message(message):
    #DO WHAT I WANT
    terminate_function()

def terminate_function():
    # Raising an exception here will make on_message stop as well
    raise RuntimeError()


text:
Q: border-image had a other behavior on firefox I'm currently using border-image on a website to display a better looking textbox.
But the border-image property has a different behavior using firefox than in chrome, edge and safari.
.home_nopic {
padding: 15px;
min-height: 120px;
border-style: solid;
border-width: 5px 12px;
-moz-border-image: url('../img/content-body.png') 5 12 stretch stretch;
-webkit-border-image: url('../img/content-body.png') 5 12 stretch stretch;
-o-border-image: url('../img/content-body.png') 5 12 stretch stretch;
border-image: url('../img/content-body.png') 5 12 fill stretch stretch;
color: rgba(0, 0, 0,0.75);
font-family: 'Germania One', cursive;
font-size: 1.4em}

For testing purposes a small code to show the error I'm getting.

<html>

    <body>

    <div class="home_nopic" style="min-width=80%; font-size: 1.7em; text-shadow: 1px 1px 1px rgba(255, 217, 179, 0.6); padding: 15px; min-height: 120px;  border-style: solid; border-width: 5px 12px; border-image: url('https://i.stack.imgur.com/mod4j.png') 5 12 fill stretch stretch; color: rgba(0, 0, 0,0.75); font-family: 'Germania One', cursive; font-size: 1.4em">
        Lorem ipsum text
    </div>

    </body>

</html>

On chrome it looks like that
And in firefox I got this
content-body
What did I do wrong?
Thanks for you help ;)


text:
Q: How to get file path in node js selected in the input type file I am new to the node js. I have and html form which is having file input like -
  <form action="importlist_action" method="post" enctype="multipart/form-data">
  Select File:
  <input type="file" name="file" id="file" tabindex="1" />
  </form>

Now, I have redirected this post request to the following method of controller.
 exports.doImport = function(req, res) {
     console.log('Post values: ' + JSON.stringify(req.body));
     console.log("File path : " +  req.body.file);
 }

The result I am getting here is -
  Post values: {}
  File path : undefined

I want the path of the file which is selected on the form above in the controller. can some one please correct me what I am doing wrong here?
Any help will be really appreciated.

A: You have to be careful that node.js does not upload files in a folder by default like PHP would.
What you are probably looking for is a middleware to do this for you:
http://www.senchalabs.org/connect/bodyParser.html

A: If you're using Express 3.x and the bodyParser() middleware, then you should look under req.files for files.
If you're using Express 4.x, then you have to use a separate module to read a multipart request. Examples of such modules are: busboy(/connect-busboy/multer/reformed) and formidable.
As @adeneo mentioned, not all browsers provide the actual file path, but most will at least supply a filename. Both Busboy and Formidable make the filename available to you.


text:
Q: I want to store component.ts data in to another variable and i want to convert into Global Variable get_update(id:any): Observable<any[]>{

      let headers = new Headers({ 'Content-Type': 'application/json'});
      let options = new RequestOptions({ headers: headers });
      return this.http.get('http://localhost:8000/vendor/'+id,options)
                        .map(response => response.json())
                        .catch(error => Observable.throw(error.statusText));

}

component.ts
ngOnInit()
{ this.service.get_update(this.user).subscribe(data => console.log(data));
}

component.ts datas to be stored in another variable

A: Declare a data member in your class and use it, and for sharing data you can use @input() decorator @outputdecorator or use a service.
    export class AppComponent {
      constructor(){}
      public data=[];//

    ngOnInit()
    { this.service.get_update(this.user).subscribe(data => this.data=data);
}