text:
Q: Scrolling a view without lose data I have an Scrollview in my app that has quite a large amount of data to load, all of them are TextViews that load an object attribute, but when i scroll the view, it sometimes load the object content to be shown, sometimes not. So what can i do to make this happen?
Here's the ViewHolder class(it's kinda ugly):
Something i forgot to mention, this class extends BaseAdapter, so, there's no activity
private class ViewHolder {
    TextView txtName;
    TextView txtFaults;
    TextView txtA;
    TextView txtB;
    TextView txtC;
    TextView txtD;
    TextView txtE;
    TextView txtF;
    TextView txtG;
    TextView txtH;
    TextView txtI;
    TextView txtPFinal;
    TextView txtPart;
    TextView txtMF;
    TextView txtMP;
    TextView txtForm;
    TextView txtMN;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    LayoutInflater inflater = activity.getLayoutInflater();

    if (convertView == null) {
        convertView = inflater.inflate(R.layout.row, null);
        holder = new ViewHolder();
        holder.txtName = (TextView) convertView
                .findViewById(R.id.txtMateria);
        holder.txtFaults = (TextView) convertView
                .findViewById(R.id.txtFaults);
        holder.txtA = (TextView) convertView.findViewById(R.id.txtA);
        holder.txtB = (TextView) convertView.findViewById(R.id.txtB);
        holder.txtC = (TextView) convertView.findViewById(R.id.txtC);
        holder.txtD = (TextView) convertView.findViewById(R.id.txtD);
        holder.txtE = (TextView) convertView.findViewById(R.id.txtE);
        holder.txtF = (TextView) convertView.findViewById(R.id.txtF);
        holder.txtG = (TextView) convertView.findViewById(R.id.txtG);
        holder.txtH = (TextView) convertView.findViewById(R.id.txtH);
        holder.txtI = (TextView) convertView.findViewById(R.id.txtI);
        holder.txtPFinal = (TextView) convertView.findViewById(R.id.txtPFinal);
        holder.txtPart = (TextView) convertView
                .findViewById(R.id.txtPart);
        holder.txtMF = (TextView) convertView.findViewById(R.id.txtMF);
        holder.txtMP = (TextView) convertView.findViewById(R.id.txtMP);
        holder.txtForm = (TextView) convertView
                .findViewById(R.id.txtForm);
        holder.txtMN = (TextView) convertView
                .findViewById(R.id.txtMN);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    Materia materia = list.get(position);
    holder.txtName.setText(materia.getMateria());
    holder.txtName.setTypeface(null, Typeface.BOLD);
    holder.txtFaults.setText("Faults:"
            + Double.toString(materia.getFaltas()) + "%");

    holder.txtA.setText("A:" + Double.toString(materia.getA()));
    if (materia.getA() == 98.9)
        holder.txtA.setVisibility(View.GONE);

    holder.txtB.setText("B:" + Double.toString(materia.getB()));
    if (materia.getB() == 98.9)
        holder.txtB.setVisibility(View.GONE);

    holder.txtC.setText("C:" + Double.toString(materia.getC()));
    if (materia.getC() == 98.9)
        holder.txtC.setVisibility(View.GONE);

    holder.txtD.setText("D:" + Double.toString(materia.getD()));
    if (materia.getD() == 98.9)
        holder.txtD.setVisibility(View.GONE);

    holder.txtE.setText("E:" + Double.toString(materia.getE()));
    if (materia.getE() == 98.9)
        holder.txtE.setVisibility(View.GONE);

    holder.txtF.setText("F:" + Double.toString(materia.getF()));
    if (materia.getF() == 98.9)
        holder.txtF.setVisibility(View.GONE);

    holder.txtG.setText("G:" + Double.toString(materia.getG()));
    if (materia.getG() == 98.9)
        holder.txtG.setVisibility(View.GONE);

    holder.txtH.setText("H:" + Double.toString(materia.getH()));
    if (materia.getH() == 98.9)
        holder.txtH.setVisibility(View.GONE);

    holder.txtI.setText("I:" + Double.toString(materia.getI()));
    if (materia.getI() == 98.9)
        holder.txtI.setVisibility(View.GONE);

    holder.txtPFinal.setText("PF:" + Double.toString(materia.getPf()));
    if (materia.getPfinal() == 98.9)
        holder.txtPFinal.setVisibility(View.GONE);

    holder.txtPart.setText("Partic:"
            + Double.toString(materia.getPartic()));
    if (materia.getPart() == 98.9)
        holder.txtPart.setVisibility(View.GONE);

    holder.txtMF.setText("MF:" + Double.toString(materia.getMf()));
    if (materia.getMf() == 98.9)
        holder.txtMF.setVisibility(View.GONE);

    holder.txtMP.setVisibility(View.GONE);
    if (!materia.getForm().toLowerCase().contains("inform")) {
        holder.txtMP.setText("MP:"
                + String.format("%.2f", materia.getMP()));
        holder.txtMP.setVisibility(View.VISIBLE);
    }
    holder.txtMN.setText("MN:LongClick to simulate");
    holder.txtMN.setTextColor(Color.GRAY);
    if (materia.getFormula().toLowerCase().contains("inform"))
        holder.txtMN
                .setText("Form not avaiable");

    holder.txtForm.setText("Form not informed");
    if (!materia.getFormula().toLowerCase().contains("inform"))
        holder.txtForm.setText("Form:" + materia.getForm());

    return convertView;
}

Tks

A: Just realize that the lack of else on the logic were causing the trouble, thanks everyone who tried to help!

A: implementing the
    onSavedInstanceState(Bundle bundle);

method should fix this problem.  You can find the information about it here
http://developer.android.com/reference/android/app/Activity.html


text:
Q: What this error means and how to fix it? `Constructing a IO::Async::Stream with an encoding-enabled handle may not read correctly` When I do:
use IO::Async::Stream;
$tty =  IO::Async::Stream->new(
    read_handle  =>  \*STDIN,
    write_handle =>  \*STDOUT,
    on_read      =>  \&tty_read,
);

I get error: Constructing a IO::Async::Stream with an encoding-enabled handle may not read correctly
On other host same code works fine.
Why on this host I get this error and how to fix it?

A: Ok. This is different host and only environment could differ. So I did:
# env | grep PERL
PERL_UNICODE=SA
PERL5LIB=/usr/local/proj/lib:/usr/local/proj/local/lib/perl5:

Then I did $ unset PERL_UNICODE and my script works fine now.
See documentation here about PERL_UNICODE

A: It appears that IO::Async::Stream expects a "raw" file handle, but you are providing one with an encoding layer attached.
You might be using the following:
use open ':std', ':encoding(UTF-8)';

If so, replace it with the following:
use open ':encoding(UTF-8)';
BEGIN {
   binmode( STDERR, ':encoding(UTF-8)' );
}

To deal with decoded text, you'll also need to decode or encode the data received from and passed to $tty, say by using the encoding constructor parameter. You can't simply pass the text received by on_read to decode as it might contain a partial character.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Strange PulseAudio monitor device behaviour Faced strange PulseAudio monitor device (i.e. audio input device which plays sound sent to speaker) behaviour. I've reduced code from my real project to simple example based on code from PulseAudio docs https://freedesktop.org/software/pulseaudio/doxygen/parec-simple_8c-example.html, I've only added time limit and read bytes counting. It works for example 30 seconds and prints read bytes count. Problem is that bytes count vastly differs if something is played during program run. I've executed this program and in parallel executed bash for loop consisting aplay with short tada.wav file. Difference is 9%. To test it more, I tried to run 4 such loops in parallel with PulseAudio example and difference is even more - 34%. But if instead of several aplay with short wav I run mplayer with long mp3 file - there is no such difference, bytes count is similar to case when no sound is played.
Such behaviour causes failure of sound processing code in my real project, so if somebody could suggest how to solve it - I'll be very grateful.
Similar code on Windows, Qt based and using Stereo Mixer device as analog of PulseAudio monitor works without such problems.
Here is my code based on example from PulseAudio docs:
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <iostream>
#include <chrono>

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

#include <pulse/simple.h>
#include <pulse/error.h>

#define BUFSIZE 1024

using namespace std;
using namespace std::chrono;

int main(int argc, char *argv[])
{
    int duration = 30000;
    int64_t readBytesCounter = 0;
    milliseconds msStart = duration_cast< milliseconds >(system_clock::now().time_since_epoch());

    /* The sample type to use */
    static const pa_sample_spec ss = {
        .format = PA_SAMPLE_S16LE,
        .rate = 44100,
        .channels = 2
    };
    pa_simple *s = NULL;
    int ret = 1;
    int error;
    /* Create the recording stream */
    if (!(s = pa_simple_new(NULL, argv[0], PA_STREAM_RECORD, "alsa_output.pci-0000_00_1b.0.analog-stereo.monitor", "record", &ss, NULL, NULL, &error))) {
        fprintf(stderr, __FILE__": pa_simple_new() failed: %s\n", pa_strerror(error));
        goto finish;
    }
    for (;;) {
        uint8_t buf[BUFSIZE];
        /* Record some data ... */
        if (pa_simple_read(s, buf, sizeof(buf), &error) < 0) {
            fprintf(stderr, __FILE__": pa_simple_read() failed: %s\n", pa_strerror(error));
            goto finish;
        }
        readBytesCounter += BUFSIZE;

        milliseconds msCurrent = duration_cast< milliseconds >(system_clock::now().time_since_epoch());
        int elapsed = msCurrent.count() - msStart.count();
        if (elapsed > duration)
        {
            cerr << int(elapsed / 1000) << " seconds elapsed, terminating" << endl;
            cerr << readBytesCounter << " bytes read" << endl;
            goto finish;
        }
    }
    ret = 0;
finish:
    if (s)
        pa_simple_free(s);
    return ret;
}

It could be built with following command:
g++ -o main main.cpp -lpulse -lpulse-simple -std=c++11

Example wav file i've taken from http://d0.waper.ru/f/462151/23/HgDwimvX37CwxWqW38eywg%2C1485353628/7d74/9/462151.wav/tada.wav
And here are test results:
Test 1. No sound in speaker
$ time ./main
30 seconds elapsed, terminating
5323776 bytes read

real    0m30.028s
user    0m0.168s
sys     0m0.388s

Test 2. Bash for loop "for i in seq 1 22; do aplay tada.wav; done" with short wav files in background. Bytes count increase is 5798912 / 5323776 = 1.089 times.
$ time ./main
30 seconds elapsed, terminating
5798912 bytes read

real    0m30.023s
user    0m0.120s
sys     0m0.184s

Test 3. 4 Bash for loops with short wav files in background. Bytes count increase is 7129088 / 5323776 = 1.339 times.
$ time ./main
30 seconds elapsed, terminating
7129088 bytes read

real    0m30.019s
user    0m0.164s
sys     0m0.196s

Test 4. mplayer with long mp3 in background. 5288960 / 5323776 = 0.993, i.e. no significant bytes count difference.
$ time ./main
30 seconds elapsed, terminating
5288960 bytes read

real    0m30.024s
user    0m0.096s
sys     0m0.204s

Tried to execute a set of each test, averaged bytes count - similar difference.
P.S.: Configuration of my system:

*

*OS Ubuntu 16.04.1 amd64

*pulseaudio 1:8.0-0ubuntu3.2

*alsa-base 1.0.25+dfsg-0ubuntu5

A: Here is reply from Tanu Kaskinen from PulseAudio mailing list https://lists.freedesktop.org/archives/pulseaudio-discuss/2017-January/027412.html . Not a full answer, but a little explanation and workaround:

You're probably hitting a known bug we have with rewind handling in
  monitor sources ("known" means in this case that the symptoms are
  known, but not the exact cause). When a stream starts to play to the
  monitored sink, the sink will rewrite its playback buffer contents
  (this is called "rewinding"), and this causes a glitch in the monitor
  source (some extra audio apparently gets pushed to the recording
  stream, judging from your experiments). I hope to fix this some day,
  but it doesn't look like I'll have time for it in the near future. If
  you have the time and motivation to investigate and fix the bug, that
  would be awesome.
As a workaround, you can probably reduce the magnitude of the error by reducing the playback buffer size. To do that, pass
  tsched_buffer_size=X to module-udev-detect in /etc/pulse/default.pa
  (replace X with the buffer size in bytes)."


text:
Q: Using predict() with an interaction term between categorical variable and square root transform variable I'm trying to predict the value of a response variable using predict(). My regression includes a single interaction term between one categorical variable and one transformed variable (square root transform). I've used the mtcars data set below to make sure the example is reproducable, and I've annotated it so you know what my thinking was.
attach(mtcars)
#take square root of weight
sqrt_wt = sqrt(wt)
#create new data frame from desired variables
df=data.frame(sqrt_wt,mpg,cyl)
#eliminate NAs caused by square root transformation
df1=df[complete.cases(df),]
#fit a regression with an interaction term (square root of weight vs.   number of cylinders as a factor)
fit1=lm(mpg~as.factor(cyl)*sqrt_wt,data=df1)
#create data frame of desired inputs for sqrt_wt
new.cars <- data.frame(sqrt_wt=c(1.7, 2.4))
#try to predict
predict(fit1,new.cars)

But then I get this error.
#Error in model.frame.default(Terms, newdata, na.action = na.action, xlev = object$xlevels) :
#variable lengths differ (found for 'sqrt_wt')
#In addition: Warning message:#  'newdata' had 2 rows but variables found have 32 rows

Any ideas? Any help would be greatly appreciated.

A: When you are making your prediction, you need all the inputs you used in the model or it can't make a prediction. Since you have an interaction, the prediction will change for each combination of cyl and sqrt_wt. In your code, it looks like both values you are specifying are sqrt_wtand you are missing the companion cyl.
View(new.cars)

Just include a cyl in your testset. You can add as many observations as you want in your test set. Consider all combinations of sqrt_wt and cyl that you are interested in.
new.car <- data.frame(sqrt_wt = 1.7, cyl = 6)
predict(fit1,new.car)


text:
Q: Android Studio Hangs/Freezes After Building/Running Android Studio hangs after every build/run for at least a few minutes (sometimes it does not release).
Also Indexing occurs quite often and takes a very long time.
Have tried:

*

*Increasing HEAP

*working offline

*changing gradle versions (working with and without the wrapper)

*deleting cache/restarting

*reinstalling studio (and deleting everything using this guide

*syncing

*rebuilding project

*disabling unrelated plugins

*unplugging device/genymotion

I have a Macbook Pro (2015) with 16GB i7 (turbo boosted)
*Hangs/Freezes means scrolling/typing or any other action takes a while to react.


text:
Q: Use UISegmentedControl to build a menu like this? I'm trying to build a menu like this with Xcode 13 Swift 5.
Each item has different width, but the margin between two items are always the same. Additionally, the highlighting is also dynamic to text width. There will also views attached to each selected item.
Would it be possible to achieve it with UISegmentedControl?
thanks!

A: You can achieve this using UIStackview.
Look at the configuration that I have developed for you. Selected font color of the button is white and background color black otherwise font color black and bg blue. On selecting any button deselect the previous one, and boom: achieved.


text:
Q: how to solve No qualifying bean of type 'com.example.test.repository.ConfigRepository' available: expected at least 1 bean which qualifies autowire Following is my directory structure

*

*com.example

*com.example.common

*com.example.test

*com.example.test.repository

my main spring boot class is as follow
package com.example.test;

@Import({ AutoConfig.class })
@SpringBootApplication
public class testApplication {
  public static void main(String[] args) {
    SpringApplication.run(testApplication.class, args);
  }
}

my repository clas
package com.example.test.repository.ConfigRepository;

 @Repository
 public interface ConfigRepository extends MongoRepository<Config, String>, QuerydslPredicateExecutor<Config> {

}

This is the error i am getting in debug mode
DEBUG o.s.c.a.ClassPathBeanDefinitionScanner - Ignored because not a concrete top-level class: file [/opt/<folder_name>/<folder_name>/target/classes/com/example/test/repository/ConfigRepository.class]
AutoConfig class used in @import is as below
package com.example.common;

@Configuration
@EnableFeignClients
@ComponentScan({ "com.example.common" })
public class AutoConfig {

A: Your ConfigRepository class in in com.example.test.repository this package.
and while providing @ComponentScan, you are passing this path com.example.common.
So instead of that you just tried with this com.example.test path as below.
And also on your SpringBootApplication file or on your Config file you can provide EnableMongoRepositories and setting basePackages attributes.
package com.example.test;

@Import({ AutoConfig.class })
@EnableMongoRepositories(basePackages = {"com.example.test.repository"})
@SpringBootApplication
public class testApplication {
  public static void main(String[] args) {
    SpringApplication.run(testApplication.class, args);
  }
}

@Configuration
@EnableFeignClients
@ComponentScan({ "com.example.test" })
public class AutoConfig {

More about @EnableMongoRepositories you will get an idea from here.
This will help you.


text:
Q: Query builder that works with all major databases? I need to use a query builder that generates SQL statements containing placeholders.
It should:

*

*Generate SQL statements containing placeholders(:placeHolder or ?)

*Have no object mapping

*Return the query as a string or similar

*Work with all major databases(e.g. Oracle, MySQL)

I am thinking about something like this:
QueryBuilder::select(
    'db' => 'MySQL'
    'from' => 'users',
    'fields' => array(
         'user_id' => 'id'
    ),
    'where' => array(
        'AND' => array(
             /**
              * ...conditions...
              */
        )
    ),
    'ljoin' => array(
        'Group' => array(
            'from' => 'groups'
             /**
              * ...stuff...
              */
        )
    )
);

I looked into Doctrine2 but it needs object mapping. And a lot of initial configuration.
I looked into Doctrine2 DBAL and it does not handle INSERT queries.
Note: Queries are generated in development stage and saved as plain text for each supported database engine.
Thank you in advance.

A: Try the Doctrine 2 ORM Query builder very versatile and works with most DBMS systems more at http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/query-builder.html

A: An example is the Code Igniter Active Record, you can build querys like:
$this->db->select('field_one, field_two')
    ->from('mytable')
    ->where(array('field' => 'value', 'field' => 'value'))


text:
Q: Why is my jquery ajax giving a 406 What is causing this error? I believe it is an incorrect accept header.  Shouldn't the jquery ajax method set that to the correct value when datatype: 'json'?
406 Not Acceptable
Here's my Spring Controller mapping:
    @RequestMapping(value={"/{ID}"}, method=RequestMethod.GET)
public @ResponseBody Double getRating(@PathVariable(value="ID") final Long id,
        @RequestParam Long rating) {
    Double ratingResult = rate.get_rating(id);
    return ratingResult;
}

Here's my javascript:
    $.ajax({
    type:'GET',
    url: '/ratings/' + ID + '?rating=' + rating,
    datatype: 'json',
    success: function(data){
        var obj = jQuery.parseJSON( data );
        var ratingResult = obj.ratingResult;
    });

My accept header value is */*

A: Please verify the server side:
But if you have incorrect response content type it supposed to be application/json, remember what you need to add jackson to your /lib directory.
In your serlvet-name.xml file.
And please use firebug to see the json notation if you can catch the object response in your console.
Please verify the client side:
Examine your request headers:
...
dataType: 'json',
...

Accept  /
Accept: application/json, text/javascript, /; q=0.01
This will explicitly tell the server side that you are expecting JSON.
And... check this: http://www.checkupdown.com/status/E406.html

A: You can try with 'text/json'...

A: set you dataType to json and you dont need to do $.parseJSON jquery will parse it for you
$.ajax({
type:'GET',
url: '/ratings/' + ID + '?rating=' + rating,
dataType: 'json',
success: function(data){

    var ratingResult = data.ratingResult;
    //or sometimes you have to do data[0]
    var ratingresult = data[0].ratingResult;
});


text:
Q: Create new flow file for each attribute where key contains specific pattern I am struggling to figure how to split a flow file based on attributes.
Example of what I want to do:

*

*Generate a flow file with the following attributes

 - Attribute 1
 - ...
 - Attribute N
 - xyz 1
 - ...
 - xyz M

*Create one flow file for each attribute where the name contains xyz.
Flowfile j should have the following attributes:

 - Attribute 1
 - ...
 - Attribute N
 - xyz (which contains the value from xyz j from the inital flowfile)

How do I get the result described in the second step?

A: Take a look at the DuplicateFlowFile processor. Since you're the one generating the flow files and attributes, you should be able to use DuplicateFlowFile which adds the copy.index attribute for which copy (0-based) the flow file is. If you need to add 1 to it you can use UpdateAttribute downstream to set copy.index to the value ${copy.index:plus(1)}


text:
Q: SharePoint Deployment from Visual Studio 2010 Location So I have a web application in visual studio. I can right click on the project and click Deploy which will send the files live to the SharePoint server.
I accidentally reverted one of the pages to an older version in Visual Studio and was wondering if it's possible to get the version running live on the SharePoint server as that is the latest version.
I cannot currently deploy as this will then run and old version of the page I accidental reverted.
Where would the files be stored and how could I find them? visual Studio is running on the SharePoint server.
Thank you very much!

A: Visual Studio does compile your *.aspx.cs files to the *.dll file of your Solution/Project.
If you want to get the code of your old *.aspx.cs file you can use Reflector or ILSpy to decompile your *.dll (actually deployed to your SharePoint) and find the old code by namespace.


text:
Q: Swift Storing Appending multiple Dictionary into array I want to store multiple dictionary into an array so that the final results looks like so
(
   {
     id: 12,
     task : completed
   },
   {
     id: 15,
     task : error
   },
   {
     id: 17,
     task : pending
   },
)

I tried with code below but it does not give me what I want Please can someone help me out. Thanks
var FinalTaskData = [[String:AnyObject]]()
            for i in 0..<taskObj.count{
                let dict = ["id":taskObj[i].id!,"task":taskObj[i].task!] as [String : AnyObject]
                FinalTaskData.append(dict)
            }

And this gives me the output of
(
        {
        id = 190;
    },
        {
        task = "Task To Be Edited";
    },
        {
        id = 191;
    },
        {
        task = "Also To Be Edited";
    }
)

Which is not what I want. Thanks


text:
Q: Cannot add constraint to DataTable 'srgbClr' which is a child table in two nested relations I have below XML file. I am trying to read it in C# code using below function and it throws an error -
DataSet ds = new DataSet();
ds.ReadXml(FileName);
"Cannot add constraint to DataTable 'srgbClr' which is a child table in two nested relations".
Also note that the same code is working on another machines and it gives error on one specific machine. Database pointed to all the machines are same.
Also, there is no DataTable which has name assigned as 'srgbClr'.
Do this have any solution ?
<?xml version="1.0" standalone="yes"?>
<CaptainVesselDetails>
  <Header>
    <VesselId>236</VesselId>
    <ExportFileTypeId>8</ExportFileTypeId>
    <ExportDate>2016-04-15</ExportDate>
    <VersionNumber>1884</VersionNumber>
  </Header>
  <MST_Vessel_Captain>
    <CaptainId>1084</CaptainId>
    <TitleId>3</TitleId>
    <CaptainName>TEST</CaptainName>
    <NationalityId>25</NationalityId>
    <DateofBirth>1968-01-09</DateofBirth>
    <CreatedDate>2014-09-26</CreatedDate>
    <ModifiedBy>84</ModifiedBy>
    <ModifiedDate>2016-04-15</ModifiedDate>
  </MST_Vessel_Captain>
  <MST_Vessel_Captain_History>
    <CaptainHistoryId>3011</CaptainHistoryId>
    <SignIn>2016-03-31</SignIn>
    <SignOff>2016-07-29</SignOff>
    <RecruitmentOffice>Ukraine</RecruitmentOffice>
    <VesselId>236</VesselId>
    <CaptainId>1084</CaptainId>
  </MST_Vessel_Captain_History>
  <MAP_Vessel_Login>
    <VesselLoginId>2525</VesselLoginId>
    <CaptainId>1084</CaptainId>
  </MAP_Vessel_Login>
</CaptainVesselDetails>


text:
Q: eclipse: build path with other projects, how to prevent test src from being included? in eclipse, I have project A, which depends on another project B.
now I add B to the build path of A. but since separately I need to run junit tests on B, I have the src/test/java and src/test/resources of B in the build path for B too. so when B is included in A's path, these src/test code is also included into A's path. this causes a lot of conflicts: for example, I declare the beans with same names in both projects, they have conflicts.
I know I can use m2eclipse plugin, but in many cases, my pom has special pre-compile plugins, so m2eclipse does not recognize these, and fails. so I have to do mvn eclipse:eclipse and generate a "regular" eclipse project , and work from there.
thanks!
Yang

A: Source folders are automatically exported to dependent projects, so I think you're going to have to factor the B project test packages to another test project that depends on the original project B.
Ugly, but I can't think of another way to do it.


text:
Q: Is it bad to up-vote low-reputation posters more? I never planned this out, but I found myself more inclined to up-vote people with lower reputation. Is this something you guys experienced, and do you think it's unfair?

A: To drive up the quality of both questions and answers, it would be ideal for everyone to vote based on a cold appraisal of the question, and not for any other reason.
However...
As Bart pointed out in the comments, it was recently argued in a seperate question that up-voters might be more inclided to favour high-reputation users. (Indeed, I was one of those who posted an answer making the argument for that being likely.)
What's clear from these two questions, and from countless examples across SO where upvotes and downvotes are cast with seemingly no explicable reason, is that users can and do upvote for whatever reasons they like, (and this is not a comprehensive list, of course:)

*

*Some will favour a low-rep user's questions, whether to encourage them or out of sympathy for their low rep.

*Some will favour a high-rep user's contributions, maybe because their high-rep implies some experitse, or maybe because they are a famous name with "real" reputation outside of the concept of SO rep.

*Some will vote for questions and answers following a cold appraisal of their individual merits, regardless of who the OP is and his/her reputation. Surely this is what we should be aiming for in order to drive high quality standards.

*...and some will vote for whatever reason pops into their heads: because it's Tuesday; because they like the OP's gravatar; because they're voting tactically to bag some badge or other; or because they just do.

My point then, long though it's taken me to make it, is that there's really no telling why people vote the way they do unless they're willing to tell you; that we shouldn't read too much into voting patterns; and that in an ideal world, to keep quality standards high, a cold appraisal of any given question should be the only criteria used to vote.

A: I think it depends on what you are calling "new users". I think it's fair until ... well ... between 1 and 15 or 1 an 25. That lets them (us ? me at least ;)) discovering the happiness of being considered as "someone who is interesting". I got self caught up by the game.
Nevertheless, when I vote up, it's often because I'm interested in the thread, more than this is new posters.
When I posted for the first time on Meta StackOverflow, this was probably a duplicate. I was not sure of that, and I said that I would delete it, if true. But, peoples voted up for me, and I feel reasonably confident for future questions.
Don't mistake, I am not saying that whe should vote up for every questions of each begginers. I recently obtain vote down privilege, and I founded many situations in which I'd prefered vote down than up. But for new members who make some efforts (understandable english, explaination, reaseaches), I am also inclined to up-vote.
I don't want to give a straight range (1 to 25 for instance), especially since I am not registered for so long (6 monthes). However, until you obtain the privileges of voting up, I think this is fairly positive.

A: I hate pile-on downvoting.
Negatively scored posts aren't given the benefit of the doubt and are downvoted as an afterthought.
When posts get to be around -10, people are even more likely to downvote (especially if it is a question, since negative votes don't cost any reputation). This forms a pretty significant reputation-sink that is difficult to escape.
In these cases, given that downvotes are -2 and upvotes are +10 for answers and +5 for questions, I would say that this is behavior is perfectly reasonable. The "sympathy upvotes" are all that is preventing these users' reputation from going down the drain.

A: There's some value in encouraging participation early on.  I would say my standards for a good answer go up as the rep goes up.  An adequate answer from a 200 rep user will usually get an upvote from me; the same answer for a 10K+ user will not get an upvote without being complete.  At that point they should know better and hold themselves to a higher standard.

A: It's unfair, of course, by definition.
I'm also inclined to up-vote particularly good content from a newer or lower-rep users... this may be due more to surprise ("Look, somebody is paying attention and trying!") given their experience on SO.
All good, on-topic, reasonable content deserves upvoting, regardless of the user.
That said, an upvote for new users' content is likely more motivational than with higher-rep users.
Increasing the amount of well-maintained content while growing participation is what makes SO neat.

A: Upvotes encourage and denote good content. When a new user posts I am more inclided to remember to vote to encourage this behavior. There's absolutely nothing wrong with wanting to encourage new users in particular; this is why I'll often take a peek in Review and upvote good First Answers/Questions.
Don't just upvote people because they're new or if they clearly aren't contributing quality content, but there's nothing wrong with encouraging those who stand to gain the most from the encouragement. If you upvote Jon Skeet he won't even notice. If you upvote a brand new user who posted a good question/answer you might actually help encourage them to stay around and help the site for weeks/months/years to come.

A: I don't think is the best of the ideas, but it should not be big deal if you follow some kind of voting criteria.
My criteria for upvoting on posts that wouldn't normally vote up:
Questions:

*

*he is low rep (250 or less)

*he showed some effort to solve the problem before posting

*he took appropriate time to the esthetic of his post

*the post doesn't have many of votes like this

Answers:

*

*he is low rep (250 or less)

*answer works

*doesn't use notably bad practices

*there are notably better competing answers with tons of upvotes

*the post doesn't have many of votes like this

If it doesn't met with ALL points, I will then vote normally


text:
Q: PHP: Change the input type data based on the form in Edit profile I have an edit form in PHP where it populates the fields based on the user:
$pphone = $get_user_details_arr[0]->pphone;
<input type="text" maxlength="14" class="form-control <?php echo ((array_key_exists('pphone', $error)) ? $err_valid : '');?>" name="pphone" value="<?=$pphone?>" />

But when a user edits his/her profile, and makes a validation error, the field is highlighted but the value here is refreshed to the original one, not the one that the user entered.
What I'm trying to achieve is when a user edits a field and if makes a validation error, the value should be the cuurent one. Please suggest a way to achieve it in PHP.
EDIT
 <select name="enroll_status">
<?php $get_enroll_status = $wpdb->get_results("select enroll_status_id,enroll_status_name from  enroll_status where 1 order by enroll_status_id");
foreach($get_enroll_status as $e_status) {
?>
<option value="<?php echo $e_status->enroll_status_id;?>" <?php echo ($get_cust_details[0]->status==$e_status->enroll_status_id) ? 'selected="selected"': "";?>><?php echo $e_status->enroll_status_name; ?></option>
<?php } ?>
</select>

A: Put there condition if $_POST/$_GET data exists.
<input [...] value="<?php echo isset($_POST['pphone']) ? $_POST['pphone'] : $pphone ?>">


text:
Q: Add access date ahead of URL
*

*I want to add access date ahead of the url. How to modify the bibtex file?

*Could you tell me how to add [Online] as well?

Hawking, S. 2000. Professor Stephen Hawking's website. [Online]. [Accessed 25 August 2017]. Available from: http://www.hawking.org.uk/

The full .bst is available here which is made by makebst.
A MWE is
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\reff.bib}
@misc{hawking2000,
 author = {Hawking, S.},
 year = {2000},
 title = {{Professor Stephen Hawking's website}},
 urldate = {2017-08-25},
 url = {http://www.hawking.org.uk/}
}
\end{filecontents*}

\usepackage{natbib,url}
\begin{document}

As argued by \cite{hawking2000}, \dots

\bibliographystyle{myHarvard}
\bibliography{\reff}
\end{document}

The function of url format is
FUNCTION {format.url}
{
  url
  duplicate$ empty$
    { pop$ "" }
    {
       "\urlprefix\url{" swap$ * "}"  *  }
  if$
}

A: Add the following function solve the issue for me.
FUNCTION {format.urldate}
{ urldate duplicate$ empty$
    { pop$ "" }
    { "~[Accessed: " swap$ * "]" * "[Online]" add.period$ swap$ * }
  if$
}


text:
Q: Is the prefix "self" optional if the meaning wont change if it is removed?
I want to build my confidence.
I want to build my self-confidence.
He is not as conceited as you think.
He is not as self-conceited as you think.

I think "self" is not necessary here. I think only necessary for words like "self-centered" because the 'center' word has different meaning if you remove self. Please clarify my thinking. Am I correct?

A: I somewhat agree, though I think "self-confidence" is slightly different from "confidence" in that it generally means something like "confidence in one's own value or worth" or "confidence exhibited in one's general approach to life"... it's used specifically to refer to a character trait, whereas 'confidence' can refer to a disposition specific to a particular instance. One might be unreservedly confident of one's ability to pass a test, but that doesn't necessarily imply that one has a lot of self-confidence.
My guess is that "self-confidence" formed in a way similar to how "unravel" came to be a synonym of the older word "ravel"... because ravelling is a sort of "undoing", "un" seems a natural prefix, and eventually it became "correct" -- to the extent that one rarely hears the word "ravel" in contemporary usage.
"Self-conceited" is a phrase I'm not familiar with; at first blush, it sounds redundant and just wrong. I imagine that it results from a muddled conflation of 'conceited' with such terms as 'self-important', 'self-aggrandizing', etc. Offhand, I can't think of any situation where I would prefer 'self-conceited' to 'conceited'.


text:
Q: Bootstrap nested layout You can see from the jfiddle link below what I'm trying to do and what the problem is. On a large screen I get a big space at the bottom which I can't remove. On the mobile I'd like each of the four images to take up the full screen but can't get it to work. Been trying to sort this for a day and I'm just going in circles now.  Any help would be appreciated.
cheers
mike.
http://jsfiddle.net/batman13/wpnLjsuo/`

Jonny 5 Alive Big Screen

Jonny 5 Alive mobile

Jonny 5 Alive2 Big Screen

Jonny 5 Alive mobile

Jonny 5 Alive3 Big Screen

Jonny 5 Alive3 Mobile

Jonny 5 Alive Big Screen

Jonny 5 Alive Mobile

`

A: White space issue is because of this:

Jonny 5 Alive3 Mobile3

You are setting the height of the row and hiding the content, so the row is still showing.  You need to hide the row so move your .visible-xs and .hidden-xs to the rows.  After that wanting the full viewport height on the mobile is going to require you to set up a media query and move your inline height styling out into a CSS file.  For example:

Jonny 5 Alive3 Mobile3

CSS:
#test{
    height: 50%;
}

@media(max-width: 500px){
    #test{
       height: 100vh;
    }
}


text:
Q: How to create a timer on Button and save in SharedPreferences(android) I want to create a button that after clicking this button will be not clickable for 1 min, but after restarting a program, this button is clickable cuz i didn't understand - how to save this in sharedpreferences
btn.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        btn.setEnabled(false);

     new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
                btn.setEnabled(true);

        }
    },120000);
    }
});

But how I need to save that in sharedpreferences?

A: If you want to save your state in preference  then you can do it like below
public void write(String key, boolean value) {
    SharedPreferences.Editor editor =
    getSharedPreferences("Some Name",MODE_PRIVATE).edit();
    editor.putBoolean(key,value);
    editor.commit();
}

public Boolean read(String key, int defValue) {
    return getSharedPreferences("Some Name",MODE_PRIVATE).getBoolean(key, defValue);
}

On click of the button you can write your value to shared preference and when you are rendering your button you can get the value from preference and enable and disable it based on the value and also save the value as false when your time is finished.


text:
Q: How to order data based on the relative lag between two fields? I have a table containing id, dates, old_values, and new_values. This table was created such that the old_value in the current row corresponds to the new_value from the previous row. However, the date field is often duplicated, such that the old_values and new_values do not correspond to one another. How can I order this data such that for each id, the old_value matches the new_value from the previous row?
For instance...

id
index
date
old_value
new_value

A1
1
1/1/23
A
B

A1
2
1/2/23
C
D

A1
3
1/2/23
D
E

A1
4
1/2/23
B
C

A1
5
1/3/23
E
F

A1
6
1/4/23
F
D

A2
7
1/2/23
G
A

A2
8
1/3/23
W
C

A2
9
1/3/23
A
W

A2
12
1/3/23
C
Z

A2
13
1/4/23
Z
A

...should be reordered by index, such that the date order is preserved, and the order within each date is such that each old_value is equal to the new_value of the previous row. In this case, the resulting table should look like the following:

id
index
date
old_value
new_value

A1
1
1/1/23
A
B

A1
4
1/2/23
B
C

A1
2
1/2/23
C
D

A1
3
1/2/23
D
E

A1
5
1/3/23
E
F

A1
6
1/4/23
F
D

A2
7
1/2/23
G
A

A2
9
1/3/23
A
W

A2
8
1/3/23
W
C

A2
10
1/3/23
C
Z

A2
11
1/4/23
Z
A

I don't have a strong idea of how to approach this, so any advice would be welcomed. I am using an Oracle DBMS.
Edit: I have modified the example table with id=A2 to clarify my question. Whereas A1 can also be satisfied by sorting alphabetically, A2 can not. When A2 is properly sorted (such that the old_value proceeds from the previous row's new_value), it is not in alphabetical order.

A: You need a query that will walk through the data (hierarchical / recursive query), and from there you can define a new column to order by (the level in the recursion).
https://docs.oracle.com/cd/B12037_01/server.101/b10759/queries003.htm#:~:text=CONNECT%20BY%20specifies%20the%20relationship,which%20rows%20contain%20the%20loop.
SELECT
   id, index, date, old_value, new_value, LEVEL
FROM
   your_table
CONNECT BY
       PRIOR new_value = old_value
   AND PRIOR id        = id
   AND PRIOR date      = date
START WITH
   NOT EXISTS (
      SELECT *
        FROM your_table
       WHERE id = d.id
         AND date = d.date
         AND new_value = d.old_value
   )
ORDER BY
   id, date, LEVEL
;

Demo: https://dbfiddle.uk/j1epC3SC


text:
Q: filenotfoundexception on android using fileinputstream ok so, I am trying to access a text file and read the data and save it to a list (DSLL), but i keep getting a filenotfoundexception, here is the part of the code that calls for the file.
package com.example.student_lists;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Locale;

import com.resources.student_list.DSLL;
import com.resources.student_list.FileManager;
import com.resources.student_list.Student;

import android.app.ActionBar;
import android.app.FragmentTransaction;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.NavUtils;
import android.support.v4.view.ViewPager;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ListView;
import android.widget.TextView;

public class MainActivity extends FragmentActivity implements ActionBar.TabListener {

    SectionsPagerAdapter mSectionsPagerAdapter;
    ViewPager mViewPager;
    static EditText inputSearch;
    static DSLL<Student> studentList;
    FileManager file = new FileManager();
    FileInputStream fileInput;
    FileOutputStream fileOutput;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Set up the action bar.
        final ActionBar actionBar = getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

        // Create the adapter that will return a fragment for each of the three
        // primary sections of the app.
        mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

        // Set up the ViewPager with the sections adapter.
        mViewPager = (ViewPager) findViewById(R.id.pager);
        mViewPager.setAdapter(mSectionsPagerAdapter);

        // When swiping between different sections, select the corresponding
        // tab. We can also use ActionBar.Tab#select() to do this if we have
        // a reference to the Tab.
        mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {
                actionBar.setSelectedNavigationItem(position);
            }
        });

        // For each of the sections in the app, add a tab to the action bar.
        for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
            // Create a tab with text corresponding to the page title defined by
            // the adapter. Also specify this Activity object, which implements
            // the TabListener interface, as the callback (listener) for when
            // this tab is selected.
            actionBar.addTab(
                    actionBar.newTab()
                            .setText(mSectionsPagerAdapter.getPageTitle(i))
                            .setTabListener(this));
        }

        inputSearch = (EditText) this.findViewById(R.id.inputSearch);

        try {
            fileInput = openFileInput("student.txt");
            Log.e("FILE INPUT","FOUND!!");
            studentList = file.read(fileInput,getApplicationContext());
            Log.e("_____",studentList.toString());
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }

and here is the logcat:
as you will see, the first couple of errors are filenotfoundexceptions, then I get nullexception errors because I could not read anything from a file.
04-15 18:17:29.061: D/dalvikvm(4233): Late-enabling CheckJNI
04-15 18:17:29.081: D/OpenGLRenderer(445): Flushing caches (mode 1)
04-15 18:17:29.091: D/dalvikvm(4233): Debugger has detached; object registry had 1 entries
04-15 18:17:29.151: W/System.err(4233): java.io.FileNotFoundException: /data/data/com.example.student_lists/files/student.txt: open failed: ENOENT (No such file or directory)
04-15 18:17:29.151: W/System.err(4233):     at libcore.io.IoBridge.open(IoBridge.java:406)
04-15 18:17:29.151: W/System.err(4233):     at java.io.FileInputStream.<init>(FileInputStream.java:78)
04-15 18:17:29.151: W/System.err(4233):     at android.app.ContextImpl.openFileInput(ContextImpl.java:610)
04-15 18:17:29.151: W/System.err(4233):     at android.content.ContextWrapper.openFileInput(ContextWrapper.java:159)
04-15 18:17:29.151: W/System.err(4233):     at com.example.student_lists.MainActivity.onCreate(MainActivity.java:90)
04-15 18:17:29.151: W/System.err(4233):     at android.app.Activity.performCreate(Activity.java:4466)
04-15 18:17:29.151: W/System.err(4233):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1092)
04-15 18:17:29.151: W/System.err(4233):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1924)
04-15 18:17:29.151: W/System.err(4233):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1985)
04-15 18:17:29.151: W/System.err(4233):     at android.app.ActivityThread.access$600(ActivityThread.java:127)
04-15 18:17:29.151: W/System.err(4233):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1151)
04-15 18:17:29.151: W/System.err(4233):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-15 18:17:29.151: W/System.err(4233):     at android.os.Looper.loop(Looper.java:137)
04-15 18:17:29.151: W/System.err(4233):     at android.app.ActivityThread.main(ActivityThread.java:4447)
04-15 18:17:29.151: W/System.err(4233):     at java.lang.reflect.Method.invokeNative(Native Method)
04-15 18:17:29.151: W/System.err(4233):     at java.lang.reflect.Method.invoke(Method.java:511)
04-15 18:17:29.151: W/System.err(4233):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-15 18:17:29.151: W/System.err(4233):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-15 18:17:29.151: W/System.err(4233):     at dalvik.system.NativeStart.main(Native Method)
04-15 18:17:29.151: W/System.err(4233): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
04-15 18:17:29.151: W/System.err(4233):     at libcore.io.Posix.open(Native Method)
04-15 18:17:29.151: W/System.err(4233):     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
04-15 18:17:29.151: W/System.err(4233):     at libcore.io.IoBridge.open(IoBridge.java:390)
04-15 18:17:29.151: W/System.err(4233):     ... 18 more
04-15 18:17:29.171: D/OpenGLRenderer(445): Flushing caches (mode 0)
04-15 18:17:29.191: D/AndroidRuntime(4233): Shutting down VM
04-15 18:17:29.191: W/dalvikvm(4233): threadid=1: thread exiting with uncaught exception (group=0x40a631f8)
04-15 18:17:29.191: E/AndroidRuntime(4233): FATAL EXCEPTION: main
04-15 18:17:29.191: E/AndroidRuntime(4233): java.lang.NullPointerException
04-15 18:17:29.191: E/AndroidRuntime(4233):     at com.example.student_lists.MainActivity$DummySectionFragment.onCreateView(MainActivity.java:298)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:472)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.support.v4.view.ViewPager.populate(ViewPager.java:1068)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.support.v4.view.ViewPager.populate(ViewPager.java:914)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1436)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.view.View.measure(View.java:12728)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4704)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.view.View.measure(View.java:12728)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:812)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.view.View.measure(View.java:12728)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4704)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2129)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.view.View.measure(View.java:12728)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1096)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2474)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.os.Looper.loop(Looper.java:137)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at android.app.ActivityThread.main(ActivityThread.java:4447)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at java.lang.reflect.Method.invokeNative(Native Method)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at java.lang.reflect.Method.invoke(Method.java:511)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-15 18:17:29.191: E/AndroidRuntime(4233):     at dalvik.system.NativeStart.main(Native Method)


text:
Q: Setting a $_GET value and opening a new link on href click so in my website I'm trying to set up a little button where when you click it, it'll refresh the page to edit the url so a $_GET value will be set but the button will also open another page.
Here's the PHP code for getting the value:
<?php
if (isset($_GET['download'])) {
    $downloadingFile = true;
  }
?>

For the button I guessed and tried this but it didnt work:
download!

Does anyone know how to do this? I'd prefer to not mess too much with AJAX/Java and just stick with HTML/PHP but if that's not possible I'm open for taking the working solution

A: You can't really do that with just php that I can think of off the top of my head but it's fairly easy with jQuery / Javascript. I will notate so at least you know what things are doing:
// When page is finished loading
$(document).ready(function () {
    // When you click a link
    $('a').click(function(e) {
        // Take the event and stop it's natural action
        // (stops link from working)
        e.preventDefault();
        // assign the data attribute from the link
        var getData =   $(this).data('loadnew');
        // Open a new browser window
        window.open(getData,'_blank');
        // Reload this page using the href
        window.location =   $(this).attr("href");
    });
});
</script>

download!


text:
Q: ASP.NET MVC 1 or MVC 2 I recently recieved the ASP.NET MVC 1.0 Professional book by Wrox, and in the intervening time, I found out that ASP.NET MVC 2.0 is being released soon.
Questions

*

*Should I MVC 2.0? Are there any resources specifically for MVC 2.0?

*Should I learn MVC 1 and then unlearn concepts and then learn MVC 2?

A: MVC 2 is still in Beta (at least the last time I checked).
MVC 1 and MVC 2 use similar concepts...MVC 2 just adds features. Learn MVC 1 as a stepping stone, and then you can better utilize the new advanced features being released in MVC 2.

A: The difference between MVC 1 and MVC 2 are not like the difference between classic ASP and ASP.NET. What I mean is that if you learn MVC 1 you will be able to use everything in MVC 2. MVC 2 for the most part builds on top of MVC 1. So if you have an MVC 1 book I'd say read it and then read articles on what is new in MVC 2. Besides some blogs and articles I don't think there is much else on MVC 2 right now.

A: I had the same question. I recommend that you learn and focus on MVC 1, but also read some of the upcoming changes in MVC 2. This way, as you're working on your MVC 1 project, you can see how MVC 2 features could be applied.

A: It's not completely released yet but people are using it. Actually, you are fine to use MVC version 1 resources to learn it and read up on what's new. A lot of what's there is just to make things a little easier, like the new syntax changes for HTML encoding etc.


text:
Q: Addressing built-in groups and local policies in Windows independently of localized names Recently I saw an application failing to do certain check/manipulation with built-in groups/local policies on localized version of Windows Server 2012 R2 (French, German). In localized versions of Windows group names and policy names are translated into localization language. This lead me to a question: what options Microsoft provides to manipulate/address those objects without relying on localized names? Obviously there is some way of doing this otherwise there should be numerous problems with localized versions. Can somebody tell me what's available for addressing these groups irrespective of localized name? (RID? some API functions?)Looking at particular issue I saw with localized versions of Windows it seems that there could be some issues with languages which are using letters with diacritical symbols.

A: Windows is using SID for securable objects. Buit-in objects have predefinied SID = http://support.microsoft.com/kb/243330/en-us so you can use those while checking localized versions.
You may also use the following approach> https://msdn.microsoft.com/cs-cz/library/system.security.principal.windowsbuiltinrole(v=vs.110).aspx
Example in PS:
$currentUser = [Security.Principal.WindowsIdentity]::GetCurrent()
(New-Object Security.Principal.WindowsPrincipal $currentUser).IsInRole(`
[Security.Principal.WindowsBuiltinRole]::Administrator)

[http://blogs.technet.com/b/heyscriptingguy/archive/2010/08/19/use-powershell-to-add-domain-users-to-a-local-group.aspx]
Regarding the Policy names = can you please share an example of what you are actually trying to do?


text:
Q: Importing classes/functions with same name as module Say I use a python package with the following structure:
package/
   bar.py
   foo.py
   __init__.py

bar.py contains the class bar and foo.py contains the function foo.
When I want to import the function/class do I have to write
from package.bar import bar
from package.foo import foo

or can I write
from package import bar
from package import foo

More generally asked:
Can I always omit the class/function name, when I import a module with the same name as the class/function?

A: No, you can't omit the module or object name. There is no mechanism that'll implicitly do such imports.
From the Zen of Python:

Explicit is better than implicit.

Note that importing the module itself should always be a valid option too. If from package import bar imported the package.bar.bar object instead, then you'd have to go out of your way to get access to package.bar module itself.
Moreover, such implicit behaviour (auto-importing the object contained in a module rather than the module itself) leads to confusing inconsistencies.

*

*What does import package.bar add to your namespace? Would referencing package.bar be the module or the contained object?

*What should happen to code importing such a name, when you rename the contained object? Does from package import bar then give you the module instead? Some operations will still succeed, leading to weird, hard to debug errors, instead of a clear ImportError exception.

Generally speaking, Python modules rarely contain just one thing. Python is not Java, modules consist of closely related groups of objects, not just one class or function.
Now, there is an inherent namespace collision in packages; from package import foo can refer both to names set on the package module, or to a nested module name. Python will first look at the package namespace in that case.
This means you can make an explicit decision to provide the foo and bar objects at the package level, in package/__init__.py:
# in package/__init__.py
from .foo import foo
from .bar import bar

Now from package import foo and from package import bar will give you those objects, masking the nested modules.
The general mechanism of importing objects from submodules into the package namespace is a common method of composing your public API whilst still using internal modules to group your code logically. For example, the json.JSONDecodeError exception in the Python standard library is defined in the json.exceptions module, then imported into json/__init__.py. I generally would discourage masking submodules however; but foo and bar into a module with a different name.


text:
Q: Accessing string value of Enum bound using EnumBoolConverter : IValueConverter Firstly I hope the answer to my question is not already here. I have searched but can't seem to find what I need.
Secondly, I am still rather new to C# and Silverlight.
What I have is a group of Radio Buttons bound to an Enum using a Converter.
This is code I have found on stackoverflow.
What I can't figure out is how to access the value of the currently selected Radio Button in the code behind.
I have set the DataContext:
public pgThePage()
{
    InitializeComponent();
    DataContext = new ViewModel();
}

The binding is working fine. Selecting different Radio Button is reflected.
How do I then get the actual currently selected button value though?
Eg)
public enum List
{
    One,
    Two,
    Three,
    Four,
    Five,
}

How would I get the string value "Two" if the Two Radio Button was selected.
Kind regards,
Neill
Will add the Converter Code here, comment block is too small
public class EnumBoolConverter : IValueConverter
{

    public object Convert(object value, Type targetType, object parameter,  System.Globalization.CultureInfo culture)
    {
        if (value == null || parameter == null)
            return value;

        return value.ToString() == parameter.ToString();
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (value == null || parameter == null)
            return value;

        return Enum.Parse(targetType, (String)parameter, true);

    }
}

public enum ClientsList
{
    One,
    Two,
    Three,
    Four,
    Five,
}

public class ViewModel : INotifyPropertyChanged
{
    private ClientsList _clientsList;

    public ClientsList clientsList
    {
        get
        {
            return _clientsList;
        }
        set
        {
            if (_clientsList != value)
            {
                _clientsList = value;
                RaisePropertyChanged("clientsList");
            }
        }
    }

    public virtual void RaisePropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

}

Now I am completely missing the whole idea of using a converter and enums to access the actual value of the clicked radio button?
Should I just go the route of adding a click event to each Radio Button and setting a variable if that Radio Button is checked?
That would be fine for five Radio Buttons, but what about having a whole lot. There must be an easier way.
Kind regards
Neill

A: There is no single property for a group of RadioButtons. You need to check the IsChecked state of each RadioButton.
It should be possible to use a converter's ConvertBack to turn a selected button into an enum, but having multiple buttons bound to the same value will have some side-effects.
If you post the code for your current converter I will see about providing a suitable  ConvertBack method.

A: Enum.GetName(typeof(List), selectedValue)

Wow, hit that return key a bit too fast here :)
The above code helps retrieving the string value of your enum.

A: Build your own custom filter control.
First, get rid of the enum, use a custom class instead, that defines your available filter options. I choose a class named "FilterOption", which has a property named "ColumnCriteriaName". You would create a list of those somewhere in your application.
public class FilterOption
{
    public string ColumnNameCriteria { get; set; }
}

Now its time to create your custom silverlight control. The purpose of this control is the accept a list of FilterOptions and display a set of Radiobuttons. Each button will be a FilterOption value. When the user selects a value, you will get notified. This control will use the Commanding techniques i tried to describe.
Add a new control, name it "FilterOptionControl.xaml". The Xaml Code is as follows:
<UserControl x:Class="SilverlightApplication1.FilterOptionControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <StackPanel x:Name="stacker" />
    </Grid>
</UserControl>

Its just an empty control with a Stackpanel which will hold our RadioButtons which we will create at runtime. Also please note that i will not use MVVM for this custom control, because in this case it would be over-engineering. Of course, feel free to add MVVM to this control if you want to, but i really dont recommend it. You should however use MVVM in your more domain specific controls.
Enought talk, lets just paste  in the .cs code for your custom control
public partial class FilterOptionControl : UserControl
{
    public IEnumerable<FilterOption> AvailableOptions
    {
        get { return (IEnumerable<FilterOption>)GetValue(AvailableOptionsProperty); }
        set { SetValue(AvailableOptionsProperty, value); }
    }

    public static readonly DependencyProperty AvailableOptionsProperty = DependencyProperty.Register(
        "AvailableOptions",
        typeof(IEnumerable<FilterOption>),
        typeof(FilterOptionControl), new PropertyMetadata(OnPropertyChangedCallback));

    public FilterOption SelectedOption
    {
        get { return (FilterOption)GetValue(SelectedOptionProperty); }
        set { SetValue(SelectedOptionProperty, value); }
    }

    public static readonly DependencyProperty SelectedOptionProperty = DependencyProperty.Register(
        "SelectedOption",
        typeof(FilterOption),
        typeof(FilterOptionControl),
        new PropertyMetadata(OnPropertyChangedCallback));

    protected static void OnPropertyChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs args)
    {
        if (sender is FilterOptionControl)
            ((FilterOptionControl)sender).OnPropertyChanged(args);
    }

    private void OnPropertyChanged(DependencyPropertyChangedEventArgs args)
    {
        if (args.Property == AvailableOptionsProperty)
        {
            RebuildFilterOptions();
        }
    }

    public FilterOptionControl()
    {
        InitializeComponent();

        SelectedValueChangedCommand = new RelayCommand(
            new Action<object>(this.ChangeSelectedValue));
    }

    RelayCommand SelectedValueChangedCommand;
    void ChangeSelectedValue(object option)
    {
        SelectedOption = option as FilterOption;
    }

    private void RebuildFilterOptions()
    {
        stacker.Children.Clear();

        if (AvailableOptions != null)
        {
            foreach (FilterOption option in AvailableOptions)
            {
                RadioButton btt = new RadioButton();
                btt.Content = option.ColumnNameCriteria;
                btt.Command = SelectedValueChangedCommand;
                btt.CommandParameter = option;
                stacker.Children.Add(btt);
            }
        }
    }
}

As you can see we have two dependency properties which are both wired up with changed events so we get notified when they get set (this way you could set an initial value for the filter options - however i didnt implement it straight away, youll have to do this yourself).
If we get set any FilterOptions on the AvailableOptions Property, we will trigger our build mechanism. We clear the StackPanel and add a new RadioButton for every FilterOption. Additionally we wire up a RelayCommand with this RadioButtons (see http://msdn.microsoft.com/en-us/magazine/dd419663.aspx#id0090051 for command explanation) and set the CommandParameter to the respective FilterOption.
So if a RadioButton gets clicked, this command gets fired with the corresponding FilterOption set as the CommandParameter. We now set the SelectedOption of our control to this new value.
The code for the RelayCommand is here, but is taken (and slightly modified) from the msdn link i posted above
public class RelayCommand : ICommand
{
    readonly Action<object> _execute;
    readonly Predicate<object> _canExecute;

    public RelayCommand(Action<object> execute)
        : this(execute, null)
    {
    }

    public RelayCommand(Action<object> execute, Predicate<object> canExecute)
    {
        if (execute == null)
            throw new ArgumentNullException("execute");

        _execute = execute;
        _canExecute = canExecute;
    }

    public bool CanExecute(object parameter)
    {
        return _canExecute == null ? true : _canExecute(parameter);
    }

    public event EventHandler CanExecuteChanged;

    public void Execute(object parameter)
    {
        _execute(parameter);
    }
}

Now you are ready to use this control on a page as you like. I did it like so in the main page of my test app:
<UserControl x:Class="SilverlightApplication1.MainPage" *snip*
             x:Name="me">

    <Grid x:Name="LayoutRoot" Background="White">

        <StackPanel>
            <TextBlock  Text="{Binding ElementName=filter, Path=SelectedOption.ColumnNameCriteria, FallbackValue='none'}"/>
            <this:FilterOptionControl x:Name="filter"
                AvailableOptions="{Binding ElementName=me, Path=MyFilterOptions}" />

        </StackPanel>
    </Grid>
</UserControl>

and the code behind looks like this:
public partial class MainPage : UserControl
{
    public IEnumerable<FilterOption> MyFilterOptions
    {
        get { return (IEnumerable<FilterOption>)GetValue(MyFilterOptionsProperty); }
        set { SetValue(MyFilterOptionsProperty, value); }
    }

    public static readonly DependencyProperty MyFilterOptionsProperty =
        DependencyProperty.Register(
        "MyFilterOptions",
        typeof(IEnumerable<FilterOption>),
        typeof(MainPage),
        new PropertyMetadata(null));

    public MainPage()
    {
        InitializeComponent();

        MyFilterOptions = new List<FilterOption>
        {
            new FilterOption() { ColumnNameCriteria = "One"},
            new FilterOption() { ColumnNameCriteria = "Two"},
            new FilterOption() { ColumnNameCriteria = "Three"}
        };
    }
}

I hope that helped.
it: Of course, if you still want to use your enums, you can do so too using the FilterOption class, but this code should be a good start for your i hope.


text:
Q: retrieving boolean values from fireabase database with react js and display the value this is the pushing to DB code which works fine
 pushtoDB = () => {
    var ref = fire.database().ref("data");
    var newRef = ref.push();
    const rookie = this.props.userLevel1;
    const student = this.props.userLevel2;
    const intermediate = this.props.userLevel3 ? "intermediate" : null;
    const expert = this.props.userLevel4 ? "expert" : null;
    const master = this.props.userLevel5 ? "master" : null;

    newRef.set({
      ID: fire.auth().currentUser.uid,
      UserEmail: fire.auth().currentUser.email,
      Question: this.state.questions, //Send data to DB to track for analysis
      UserAnswer: this.state.userAns,
      Score: this.state.scores,
      UserLevel: rookie
      //  UserLevel: student
      // UserLevel: intermediate,
      // UserLevel: expert,
      //UserLevel: master
    });

    console.log("Sent to Database");
  };

here in the DB i can see value for Userlevel is "true" which is what i want
I want to display the true value as "rookie" in using this code..it looks right but its displaying "no data"
 return (

        <Card border="primary" style={{ width: "40rem", marginLeft: 50 }}>
          <Card.Header style={{ textAlign: "center" }}> Profile</Card.Header>
          <Card.Body>
            <Card.Title style={{ marginLeft: 230 }}>

            </Card.Title>
            <Card.Text style={{ marginLeft: 70 }}>

                <MdEmail /> Email :
                {this.props.email ? this.props.email : "No data for Email"}

                Score :
                {this.props.score ? this.props.score : "No data for Score"}

                Level : {this.props.level ? "rookie" : "no data"}

            </Card.Text>
          </Card.Body>
        </Card>

any help would be great thanks

A: rookie is just a local variable inside the pushtoDB method, and is not available in your render implementation.
You can either check the userLevel1 property in your rendering code:
return (

        <Card border="primary" style={{ width: "40rem", marginLeft: 50 }}>
          <Card.Header style={{ textAlign: "center" }}> Profile</Card.Header>
          <Card.Body>
            <Card.Title style={{ marginLeft: 230 }}>

            </Card.Title>
            <Card.Text style={{ marginLeft: 70 }}>

                <MdEmail /> Email :
                {this.props.email ? this.props.email : "No data for Email"}

                Score :
                {this.props.score ? this.props.score : "No data for Score"}

                Level : {this.props.userLevel1 ? "rookie" : "no data"}

            </Card.Text>
          </Card.Body>
        </Card>

Alternatively, you can set the rookie value in the state, and then use that in your rendering code:
pushtoDB = () => {
    var ref = fire.database().ref("data");
    var newRef = ref.push();
    const rookie = this.props.userLevel1;
    const student = this.props.userLevel2;
    const intermediate = this.props.userLevel3 ? "intermediate" : null;
    const expert = this.props.userLevel4 ? "expert" : null;
    const master = this.props.userLevel5 ? "master" : null;

    this.setState({ level: rookie });

    ...
}
...
                Level : {this.state.level ? "rookie" : "no data"}


text:
Q: Insert, display, min and max in array list in C# I'm new in C#. I have this program and I need to add the function for insert, function min, function max, and function display.
namespace unSortedArrayAssignment
{
    class unSortedArray
    {
        public int size;
        public int[] array;
        //Constructor for an empty unsorted array
        public unSortedArray(int MAX_SIZE)
        {
            array = new int[MAX_SIZE]; //Create a C# array of size MAX_SIZE
            size = 0; // Set size of unSortedArray to 0
        }
        //Append assuming array is not full
        public void Append(int value)
        {
            array[size] = value;
            size++;
        }
        //Remove the last item
        public void Remove()
        {
            if (size != 0)
                size--;
        }
        //Search for an item
        public int Search(int value)
        {
            for (int counter = 0; counter < size; counter++)
            {
                if (array[counter] == value)
                    return counter;
            }
            return -1;
        }
        //Delete an item
        public void Delete(int value)
        {
            int index = Search(value);
            if (index != 0)
            {
                for (int counter = index; counter < size; counter++)
                    array[counter] = array[counter + 1];
                size--;
            }
        }
    }
}

A: class unSortedArray
{
    public int size;
    public int[] array;

    public unSortedArray()
    {
       array = new int[int size here];
    }

    public int Min()
    {
       return array.Min();
    }

    public int Max()
    {
       return array.Max();
    }

    public void Insert(int value)
    {
        Array.Resize<int>(ref array, array.Count() + 1);
        array[array.Count() - 1] = value;
    }
}


text:
Q: fading images simple slideshow javascript/html I am extremely new to javascript and im trying to use fade out/fade in photo slide show and i am trying to use a code i have seen else where but it just doesnt seem to be working can someone have a look and just point out where i might be going wrong.
HTML

css
#media
{
    border-style:groove;
    border-width:5px;
    border-color:green;
    background-color:purple;
    height:34%;
    width:30%;
    margin-top:40px;
    margin-right:5%;
    margin-bottom:50px;
    margin-left:5%;
    float:left;
}
 #media img
{
    width:100%;
    height:100%;
}

script

     $('#media img:gt(0)').hide();
        setInterval(function () {
            $('#media :first-child').fadeOut(4000)
                                 .next('img')
                         .fadeIn(10)
                         .end()
                         .appendTo('#media');
        }, 4000); // 4 seconds
    </script>

any help would be great.
thank you for any help.

A: Using jQuery you could accomplish this. Maybe something like:
$(function() {
    var images = $(".images img").hide();
    var current = 0;
    setInterval(function() {
        var next = ((current + 1) % images.length);
        images.eq(current).fadeOut();
        images.eq(next).fadeIn();
        current = next;
    });
});

However, in your CSS page you'd also want to add:
.images
{
    position: relative;
}
.images img
{
    display: none;
    position: absolute;
}

This is great if you want some to fade into others?
Check out this page, has some other concepts very similar using jQuery: http://www.geeksucks.com/toolbox/23-jquery-fade-in-fade-out-effect.htm


text:
Q: How to calculate all by all set intersections using redis? Is there a standard approach for returning all by all set intersections using redis?
For example, using the data below I would like to return the number of members in common between all sets, 3 comparisons in total
HMSET cset_details:1 name 'set 1' description 'my first set' date 'today'
HMSET cset_details:2 name 'set 2' description 'my second set' date 'today'
HMSET cset_details:2 name 'set 3' description 'my third set' date 'today'
SADD cset_members:1 a b c d
SADD cset_members:2  c d e
SADD cset_members:3 d e f g

Thanks
Iain

A: I believe you're looking for the SINTER and SINTERSTORE commands (see http://redis.io/commands/sinter and http://redis.io/commands/sinterstore)
127.0.0.1:6379[1]> SADD cset_members:1 a b c d
(integer) 4
127.0.0.1:6379[1]> SADD cset_members:2 c d e
(integer) 3
127.0.0.1:6379[1]> SADD cset_members:3 d e f g
(integer) 4
127.0.0.1:6379[1]> SINTER cset_members:1 cset_members:2 cset_members:3
1) "d"
127.0.0.1:6379[1]> SINTERSTORE in_all_sets cset_members:1 cset_members:2 cset_members:3
(integer) 1
127.0.0.1:6379[1]> SMEMBERS in_all_sets
1) "d"
127.0.0.1:6379[1]>


text:
Q: Distinct cyclic permutation without Orbit-Stabilizer Theorem A previous question asks roughly the same as Dummit and Foote 2.3.9(e):
$S=\{(x_1,\ldots,x_p):x_i\in A\}$ for some set $A$ and $p$ prime. If $S$ has more than one distinct cyclic permutation, prove it has exactly p of them.
I believe the term cyclic permutation is meant to mean a cyclic shift of the whole tuple and not the more general meaning.
I understand the other solution that utilizes the Orbit-Stabilizer Theorem.  I don't see that D&F mention this important theorem explicitly so was wondering if there is a simpler solution.  There is a solution here but I don't follow his explanation either.


text:
Q: Removing first (default) column in pandas dataframe I am new to pandas, and I have a dataframe (which I get after processing) that looks like this:I was unable to find any help/info regarding how can I remove the first column (row_number/ index) to make it like this:
Any help would be appreciated.
Edit: additional question example:

A: If I understand everything correctly then your dataframe looks like this:
   row   fruit  color
0    0   apple    red
1    1   berry   blue
2    2  grapes  green

Now if you want to write dataframe to a csv file without first column indexing then use dataframe.to_csv("file.csv", index=False) so that the file.csv file will look like this:
row,fruit,color
0,apple,red
1,berry,blue
2,grapes,green

And to remove header or first row use header=False to dataframe.to_csv("file.csv", index=False, header=False). Then your file.csv will look like:
0,apple,red
1,berry,blue
2,grapes,green

Hope this helps!!! And keep up the work toward learning Pandas.

A: You can turn 'row' into your index, and remove the existing ("autonumbered" so to speak) index: df.set_index("row", inplace=True)
You can see all the options for set_index in the pandas docs:
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.set_index.html


text:
Q: Using Glide, ArrayLists repeats itself in a ViewPager? I am using Glide to load the images from Drawables into a Fragment containing ViewPager, everything works smooth but when I install the Application over again and again then the List of images start to repeat 2, 3 times in ViewPager i.e after last page of ArrayList it will start from first again for like 2, 3 times and repeat the list, and if i clear the application data by going to Settings>Apps then it gets fine, I tried skipping the DiskMemory but its still same.
Not important but here is the part of my PagerAdapter:
Glide.with(mContext)
            .load((Integer) data.get(position))
            .fitCenter()
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .into(mImageView);

What is the best approach to solve this issue? clearing cache on exit? or skipping both memory and disk cache?
Number of images is really large about 700, but size of images is not much i.e around 30kb to 50kb.

A: For anyone else having the same issue.
The drawable IDs may change on each compile, that's why we have the R class, and I was testing my debug build, and version code doesn't change between builds.
Glide uses VersionCodeSignature (see load(int) sources) to make sure what I experienced doesn't happen in real life, because Play Store forces you to change the version on each release.
So when we change the VersionCode Glide doesn't use the old cache and creates new cache for new build.
Hope it helps someone


text:
Q: What type of attack is this by adding /127.0.0.1/ in the URI request? I am hosting a website and I see a lot of request that include /127.0.0.1/127.0.0.1/ in the URI. Some times the /127.0.0.1/ is present multiple of time in the URI e.g /any/path//127.0.0.1/127.0.0.1/127.0.0.1/127.0.0.1/127.0.0.1/127.0.0.1/127.0.0.1/127.0.0.1/127.0.0.1/index.html
What is this type of attack?
Does any one know?
Thank you.


text:
Q: JavaScript failed to execute 'appendChild' on 'Node' parameter 1 is not of type 'Node' The idea is that when the screen gets under 800px the element thatare in the questLinks array go in the ul with the id of 'links'.

let isActivated = false;

var questLinks =[
document.createElement("li").textContent ="
Home
",
document.createElement("li").textContent ="
Quests
",
document.createElement("li").textContent ="
Battle arena
",
document.createElement("li").textContent ="
Rankings
",
document.createElement("li").textContent ="
Clan
",
document.createElement("li").textContent ="
Profile
",
document.createElement("li").textContent ="
About
",
document.createElement("li").textContent ="
Contact us
"
];

function move() {
 var headerList = document.getElementById('list');

 if (document.getElementById("bod").clientWidth <= 800 ) {
  console.log("Width < 800");
  if (isActivated == false) {
   console.log("isActivated = " + isActivated);
   for (link of questLinks) {
    console.log("There he is.");
    headerList.appendChild(link);
   }
   isActivated = true;
  }

 }
}

This code results in the error: " JavaScript failed to execute 'appendChild' on 'Node' parameter 1 is not of type 'Node' "

A: What you're building here is not what you think it is:
var questLinks =[
document.createElement("li").textContent ="
Home
",
document.createElement("li").textContent ="
Quests
",
document.createElement("li").textContent ="
Battle arena
",
document.createElement("li").textContent ="
Rankings
",
document.createElement("li").textContent ="
Clan
",
document.createElement("li").textContent ="
Profile
",
document.createElement("li").textContent ="
About
",
document.createElement("li").textContent ="
Contact us
"
];

That questLinks variable will end up being an array of strings, not an array of elements. An expression like this:
document.createElement("li").textContent ="
Home
"

has as its value the right-hand side of the = sign. Your code is creating elements, but because all that matters is the final value of the expression, the elements are all discarded and you're left with an array of the strings on the right-hand side of those assignments.
What you can do is create a function that creates and initializes your elements:
function makeLink(content) {
  var li = document.createElement("li");
  li.innerHTML = content;
  return li;
}

var questLinks = [
    makeLink("Home"),
    makeLink("Quests"),
    makeLink("Battle arena"),
    makeLink("Rankings"),
    makeLink("Clan"),
    makeLink("Profile"),
    makeLink("About"),
    makeLink("Contact us")
];

(Note that you really want to be setting the innerHTML property and not textContent because you're adding HTML markup, and that you don't need to include
 or
 in the content.)
Obviously you could refine the function and save yourself some typing by having the function also build the  links from the URL and the label.

A: Try this:
var questLinks =
[
    "
Home
",
    "
Quests
",
    "
Battle arena
",
    "
Rankings
",
    "
Clan
",
    "
Profile
",
    "
About
",
    "
Contact us
"
].map(function(x){
    var l=document.createElement("li")
    l.textContent=x
    return l
})


text:
Q: context2d.strokeText() strokes the path under FF3.6/4 I am facing a strange effect with strokeText under FF (3.6 and 4beta4) that I don't reproduce under Chrome or Safari.
If I draw a filled path shape (but not stroked), and then a stroked text, the path is stroked when strokeText() is called.
Here is my code:
            var el = document.getElementById('canvas'),
            ctx = el.getContext('2d');

        ctx.save();
        // draw Rect
        ctx.beginPath();
        ctx.moveTo(100, 100);
        ctx.lineTo(200, 100);
        ctx.lineTo(200, 200);
        ctx.lineTo(100, 200);
        ctx.lineTo(100, 100);
        ctx.closePath();
        ctx.fillStyle = 'red';
        ctx.fill();

                    // draw Text
        ctx.save();
        ctx.textAlign = 'start';
        ctx.fillStyle = "rgba(0,0,0,0.0)";
        ctx.strokeStyle = "blue";
        ctx.lineWidth = 2;
        ctx.font = "bold 35pt sans-serif";
        ctx.strokeText("Hello World !", 100, 280);

        ctx.restore();

If you run it, the rect is stroked in blue, while it should not.
Do you see something wrong with this code, or is it a bug in FF ?
Thanks !

A: It has been fixed in Firefox 4 beta 8. (just tested...).
I think the related bug is : https://bugzilla.mozilla.org/show_bug.cgi?id=499628

A: What about drawing the rect in this way?
var el = document.getElementById('canvas'),
ctx = el.getContext('2d');

ctx.save();
// draw Rect
ctx.fillStyle = 'red';
ctx.fillRect  (100, 100, 100, 100); // <===
// draw Text
ctx.save();
ctx.textAlign = 'start';
ctx.fillStyle = "rgba(0,0,0,0.0)";
ctx.strokeStyle = "blue";
ctx.lineWidth = 2;
ctx.font = "bold 35pt sans-serif";
ctx.strokeText("Hello World !", 100, 280);

ctx.restore();

EDIT below about strokeText problem, it seems that if you draw the text before drawing and filling the path fixes it
var el = document.getElementById('canvas'),
ctx = el.getContext('2d');

// draw Text -> at first
ctx.save();
ctx.textAlign = 'start';
ctx.fillStyle = "rgba(0,0,0,0.0)";
ctx.strokeStyle = "blue";
ctx.lineWidth = 2;
ctx.font = "bold 35pt sans-serif";
ctx.strokeText("Hello World !", 100, 280);

ctx.save();
// draw Rect
ctx.beginPath();
ctx.moveTo(100, 100);
ctx.lineTo(200, 100);
ctx.lineTo(200, 200);
ctx.lineTo(100, 200);
ctx.lineTo(100, 100);
ctx.closePath();
ctx.fillStyle = 'red';
ctx.fill();

ctx.restore();


text:
Q: Data from MySQL and SQL Server I have two databases one in MySQL and the other in SQL Server. I have a request table in MySQL with fields as requestid and requestdatetime. And in SQL Server I have a table named request desc with columns as requestid and request_description.
These tables are updated at different times throughout the day. How can I connect these two and get the details as requestid, reqest_description and requestdatetime based in the requestid taken from MySQL database?

A: If you can perform a read query to the MySQL database request table from the SQL Server database then, set up an SQL Server job that syncs data between MySQL request table and another table with similar schema (lets call this duplicate table) in SQL Server. If that is possible then you can connect the duplicate table and the SQL Server request desc table. Make sure that the duplicate table and request table both contains similar data.


text:
Q: ShapeableImageView doest show vector image hi I have following code, it shows png but fails to show vector images:
  <com.google.android.material.imageview.ShapeableImageView
    android:id="@+id/image_view_isurance_type"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="24dp"
    android:layout_marginBottom="12dp"
    android:padding="12dp"
    app:srcCompat="@drawable/ic_car_body"
    app:shapeAppearanceOverlay="@style/blue_round_outline"
    card_view:layout_constraintEnd_toEndOf="parent"
    card_view:layout_constraintStart_toStartOf="parent"
    card_view:layout_constraintTop_toTopOf="parent" />


text:
Q: Automatic margins when using css If i used CSS my div automatically margins left and right if i use inline style its works perfect,i don't understand whats going when i use CSS
i'm using React.js
I'm trying to style with CSS,its gives auto margin to left and right

hello

//CSS code

.container
    background-color: lightblue;
}

//i'm using inline style its works perfect
``

hello

``

A: I guess you have included bootstrap in your project and container is a bootstrap class, so it adds style from bootstrap library as well
Try using any other class name it will just work fine.

A: Please note, container is a bootstrap class, so it adds style from bootstrap library as and try using any other classes name it will be worked excellent.


text:
Q: Oracle Materialized View Not Supporting NVL I have created a simple Materialized View in Oracle with this query
SELECT p.registration_no, s.sponsor_no, s.sponsor_name, p.resignation_date
FROM nmr_registration_public p, lct_sponsor s
WHERE p.sponsor_no = s.sponsor_no;

I have set its refresh mode as FORCE ON COMMIT and it is working properly.
I have altered the query like this by just adding NVL(p.resignation_date, SYSDATE) statement like this
SELECT p.registration_no, s.sponsor_no, s.sponsor_name, NVL(p.resignation_date, SYSDATE)
FROM nmr_registration_public p, lct_sponsor s
WHERE p.sponsor_no = s.sponsor_no;

Then I am getting this error
ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view
Is NVL not supported in MViews if the refresh mode is set as ON COMMIT?
And are there any other statements that do not support ON COMMIT?

A: The problem is not with nvl but in sysdate

The defining query of the materialized view cannot contain any
  non-repeatable expressions (ROWNUM, SYSDATE, non-repeatable PL/SQL
  functions, and so on).


text:
Q: orWhereBetween condition seems to doesn't work properly Everything works good when i don't pass the orWhereBetween condition in my filter query but when i pass ->orWhereBetween the results of the query have no sense..
Hope someone could help me and can see where is the problem in my orWhereBetween , thanks a lot in advance.
$query = Amende::query();
        $filters = [
            'structure_id' => 'structure_id',
            'equipe_id' => 'equipe_id',
            'bareme_amende_id' => 'bareme_amende_id',
            'saison_id' => 'saison_id' ,
            'dt_min' => 'dt_amende' ,
            'dt_max' => 'dt_amende',
            'etat_paiement' => 'etat_paiement',
            'bl_comptabilite' => 'bl_comptabilite',

        ];

        $dt_min = $request->input('dt_min');
        $dt_min =  Carbon::parse($dt_min)->format('Y-m-d');
        $dt_max = $request->input('dt_max');
        $dt_max = Carbon::parse($dt_max)->format('Y-m-d');

        foreach ($filters as $key => $column) {
        $query->when($request->has($key), function ($query, $value) use ($column,$key, $request , $dt_min , $dt_max) {
            $query->where($column, $request->$key)
            ->orWhere(function ($query) use ($dt_min , $dt_max){
            $query->whereBetween('dt_amende' , [$dt_min , $dt_max]);
            });
        });
    }

        $amendes = $query->paginate(10);

A: try this one...
$dt = array($dt_min , $dt_max);
->orWhere(function ($query) use ($dt){
$query->whereBetween('dt_amende' , [$dt[0] , $dt[1]]);
});


text:
Q: Why does Django IntegerField converts unicode to str before converting to int? I looked at Django's code for IntegerField's to_python method. The type conversion part is
    try:
        value = int(str(value))
    except (ValueError, TypeError):
        raise ValidationError(self.error_messages['invalid'], code='invalid')

The code converts value (type unicode) to str first and then int. Why can't it be cast to int directly i.e.
    try:
        value = int(value)
    except...


text:
Q: NoReverseMatch at /reviews/ Reverse for 'reviews_detail' with arguments Have serious issues with the following.
have a reviews app in my project where people can read, leave, edit and delete views.
Was all working fine in gitpod on the local side but then when i pushed to Heroku i started getting errors. On Heroku I was gettings a null constraint error and on the local side I was getting "null value in column" error. I cleared my database, deleted users and created a new superuser after updating the models to use uuid instead. Now i'm getting a noreverse error on the local side (god only knows what's going to happen when i push it to Heroku but lets deal with one thing at a time).
Anyways I'll attach all relevant code below.
Have a project due tomorrow so any help would be massively appreciated.
reviews.html
{% extends "base.html" %}
{% load static %}

{% block content %}

        {% for review in object_list %}

Title: {{ review.title }}

            {% if request.user.is_authenticated %}
            {% if user.id == review.user.id %}
            Edit
            Delete

            {% endif %}
            {% endif %}
            {{ review.review|slice:":50" }}

            {{ review.user }}

            {{ review.rate }} Stars

            {{ review.created_at }}

        {% endfor %}

Leave a Review

{% endblock %}

models.py
import uuid

from django.db import models
from django.contrib.auth.models import User

RATINGS = (
    (1, '1'),
    (2, '2'),
    (3, '3'),
    (4, '4'),
    (5, '5'),
)

class UserReviews(models.Model):
    """ model for user reviews used to create and view reviews """
    title = models.CharField(max_length=50, blank=True)
    review = models.TextField(max_length=1000)
    user = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    rate = models.IntegerField(choices=RATINGS, blank=True)
    created_at = models.DateTimeField(auto_now_add=True)

urls.py
from django.urls import path
from .views import ReviewListView, ReviewDetailView, ReviewFormView, UpdateReviewView, DeleteReviewView

urlpatterns = [
    path('add_review/', ReviewFormView.as_view(), name='add_review'),
    path('', ReviewListView.as_view(), name='reviews'),
    path('reviews/<int:pk>', ReviewDetailView.as_view(),
         name='reviews_detail'),
    path('review/update/<int:pk>', UpdateReviewView.as_view(), name='update_review'),
    path('review/<int:pk>/delete/', DeleteReviewView.as_view(), name='delete_review'),
]

views.py
""" imports from django, models.py and forms.py """
from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView
from django.urls import reverse_lazy
from .models import UserReviews
from .forms import UserReviewForm

class ReviewListView(ListView):
    """ view for generating the review list """
    model = UserReviews
    template_name = "reviews/reviews.html"
    ordering = ['-created_at']

class ReviewDetailView(DetailView):
    """ view for generation Review Details """
    model = UserReviews
    template_name = "reviews/reviews_detail.html"

class ReviewFormView(CreateView):
    """ view for review form """
    model = UserReviews
    template_name = "reviews/add_review.html"
    form_class = UserReviewForm
    success_url = reverse_lazy('reviews')

class UpdateReviewView(UpdateView):
    """ view for updating review form """
    model = UserReviews
    template_name = "reviews/update_review.html"
    form_class = UserReviewForm

class DeleteReviewView(DeleteView):
    """ view for deleting review form """
    model = UserReviews
    template_name = "reviews/delete_review.html"
    success_url = reverse_lazy('reviews')

forms.py
from django import forms
from .models import UserReviews

class UserReviewForm(forms.ModelForm):
    """ meta data to generate contact us form """
    class Meta:
        """ form model, fields and widgets used"""
        model = UserReviews
        fields = [
            'title', 'review', 'rate'
            ]

    def form_valid(self, form):
        # if form is valid return to discussion
        form.instance.user = self.request.user
        return super().form_valid(form)


text:
Q: How to prevent manual input into a ComboBox in C# I have a form in C# that uses a ComboBox.
How do I prevent a user from manually inputting text in the ComboBox in C#?
this.comboBoxType.Font = new System.Drawing.Font("Arial", 15.75F);
this.comboBoxType.FormattingEnabled = true;
this.comboBoxType.Items.AddRange(new object[] {
            "a",
            "b",
            "c"});
this.comboBoxType.Location = new System.Drawing.Point(742, 364);
this.comboBoxType.Name = "comboBoxType";
this.comboBoxType.Size = new System.Drawing.Size(89, 32);
this.comboBoxType.TabIndex = 57;

I want A B C to be the only options.

A: You can suppress handling of the key press by adding e.Handled = true to the control's KeyPress event:
private void Combo1_KeyPress(object sender, KeyPressEventArgs e)
{
    e.Handled = true;
}

A: I believe you want to set the DropDownStyle to DropDownList.
this.comboBoxType.DropDownStyle =
    System.Windows.Forms.ComboBoxStyle.DropDownList;

Alternatively, you can do this from the WinForms designer by selecting the control, going to the Properties Window, and changing the "DropDownStyle" property to "DropDownList".

A: I like to keep the ability to manually insert stuff, but limit the selected items to what's in the list.
I'd add this event to the ComboBox. As long as you get the SelectedItem and not the Text, you get the correct predefined items; a, b and c.
private void cbx_LostFocus(object sender, EventArgs e)
{
  if (!(sender is ComboBox cbx)) return;
  int i;
  cbx.SelectedIndex = (i = cbx.FindString(cbx.Text)) >= 0 ? i : 0;
}

A: Just set your combo as a DropDownList:
this.comboBoxType.DropDownStyle = ComboBoxStyle.DropDownList;

A: Why use ComboBox then?
C# has a control called Listbox. Technically a ComboBox's difference on a Listbox is that a ComboBox can receive input, so if it's not the control you need then i suggest you use ListBox
Listbox Consumption guide here: C# ListBox