问:
display selected date in another activity using popup calendar
I want to display selected date from calendar in another activity so please help me, now in my application it displays current date but I don't know how to do this. I am using simple popup calendar in my application.Here is my code below.</p>

```<code>    sharedpreferences = getSharedPreferences(MyPREFERENCES, MODE_PRIVATE);

    Bundle b = getIntent().getExtras();

    txt_date = (TextView) findViewById(R.id.Date_Value);
    txt_week = (TextView) findViewById(R.id.Week_Value);
    txt_baby = (TextView) findViewById(R.id.Baby_Value);
    txt_mother = (TextView) findViewById(R.id.Mother_Value);
    txt_tremester = (TextView) findViewById(R.id.Tremester_Value);

    txt_baby.setText(b.getCharSequence("baby_name"));
    txt_mother.setText(b.getCharSequence("mother_name"));
    txt_tremester.setText(b.getCharSequence("tremester"));

    img_week = (ImageView) findViewById(R.id.image_week);
    img_slide = (ImageView) findViewById(R.id.image_slide);
    img_BMI = (ImageView) findViewById(R.id.image_BMI);
    img_setting = (ImageView) findViewById(R.id.image_setting);

    String dob = sharedpreferences.getString("dob", null);

    Calendar c = Calendar.getInstance();
    year = c.get(Calendar.YEAR);
    month = c.get(Calendar.MONTH);
    day = c.get(Calendar.DAY_OF_MONTH);

    txt_date.setText(new StringBuilder()
            // Month is 0 based, just add 1
            .append(year).append("-").append(month + 1).append("-").append(day));

    String current_dob = txt_date.getText().toString();

    StringTokenizer current_tokens = new StringTokenizer(current_dob, "-");
    current_year = current_tokens.nextToken();
    current_month = current_tokens.nextToken();
    current_date = current_tokens.nextToken();

    System.out.println("year==>" + Integer.parseInt(current_year));
    System.out.println("month==>" + Integer.parseInt(current_month));
    System.out.println("date==>" + Integer.parseInt(current_date));

    StringTokenizer tokens = new StringTokenizer(dob, "-");
    selected_year = tokens.nextToken();
    selected_month = tokens.nextToken();
    selected_date = tokens.nextToken();

    System.out.println("year==>" + Integer.parseInt(selected_year));
    System.out.println("month==>" + Integer.parseInt(selected_month));
    System.out.println("date==>" + Integer.parseInt(selected_date));
</code>```

答:
Use calendar view and set your selected date like this:

```<code>Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DAY_OF_MONTH, day);

long milliTime = calendar.getTimeInMillis();

mCalendarView.setDate (milliTime, true, true);
</code>```

Body:
I want to display selected date from calendar in another activity so please help me, now in my application it displays current date but I don't know how to do this. I am using simple popup calendar in my application.Here is my code below.

    sharedpreferences = getSharedPreferences(MyPREFERENCES, MODE_PRIVATE);

    Bundle b = getIntent().getExtras();

    txt_date = (TextView) findViewById(R.id.Date_Value);
    txt_week = (TextView) findViewById(R.id.Week_Value);
    txt_baby = (TextView) findViewById(R.id.Baby_Value);
    txt_mother = (TextView) findViewById(R.id.Mother_Value);
    txt_tremester = (TextView) findViewById(R.id.Tremester_Value);

    txt_baby.setText(b.getCharSequence("baby_name"));
    txt_mother.setText(b.getCharSequence("mother_name"));
    txt_tremester.setText(b.getCharSequence("tremester"));

    img_week = (ImageView) findViewById(R.id.image_week);
    img_slide = (ImageView) findViewById(R.id.image_slide);
    img_BMI = (ImageView) findViewById(R.id.image_BMI);
    img_setting = (ImageView) findViewById(R.id.image_setting);

    String dob = sharedpreferences.getString("dob", null);

    Calendar c = Calendar.getInstance();
    year = c.get(Calendar.YEAR);
    month = c.get(Calendar.MONTH);
    day = c.get(Calendar.DAY_OF_MONTH);

    txt_date.setText(new StringBuilder()
            // Month is 0 based, just add 1
            .append(year).append("-").append(month + 1).append("-").append(day));

    String current_dob = txt_date.getText().toString();

    StringTokenizer current_tokens = new StringTokenizer(current_dob, "-");
    current_year = current_tokens.nextToken();
    current_month = current_tokens.nextToken();
    current_date = current_tokens.nextToken();

    System.out.println("year==>" + Integer.parseInt(current_year));
    System.out.println("month==>" + Integer.parseInt(current_month));
    System.out.println("date==>" + Integer.parseInt(current_date));

    StringTokenizer tokens = new StringTokenizer(dob, "-");
    selected_year = tokens.nextToken();
    selected_month = tokens.nextToken();
    selected_date = tokens.nextToken();

    System.out.println("year==>" + Integer.parseInt(selected_year));
    System.out.println("month==>" + Integer.parseInt(selected_month));
    System.out.println("date==>" + Integer.parseInt(selected_date));

Body:
Use calendar view and set your selected date like this:

Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DAY_OF_MONTH, day);

long milliTime = calendar.getTimeInMillis();

mCalendarView.setDate (milliTime, true, true);


来源: stackexchange

问:
java regex problem
Suppose I have a string "July is busy". And I need the string without "July". How can I do it with using regex ?

Thanks.

答:
You can do something like this:</p>

```<code>import java.util.regex.*;
Matcher m = Pattern.compile("^July(.*)\$").matcher("July is busy");

// if you had a match, the extra would be here:
if (m.matches()) {

    // match count:
    m.groupCount();

    // ' is busy'
    String rightOfJuly = m.group(1);
}
</code>```

ContentLicense: CC BY-SA 2.5

Title: java regex problem

Body:
You can do something like this:

import java.util.regex.*;
Matcher m = Pattern.compile("^July(.*)\$").matcher("July is busy");

// if you had a match, the extra would be here:
if (m.matches()) {

    // match count:
    m.groupCount();

    // ' is busy'
    String rightOfJuly = m.group(1);
}


问:
SELECT data based on given pairs
I have little experience using SQL, and I am now using JDBC to connect to my database.
I am using sqlite, my schema looks as follows:

```<code>id1, id2, value1, value2
</code>```

I want to extract rows based on a list of given pairs of id1 and id2.
I know Postgresql can do

```<code>SELECT  *
FROM    table
WHERE   ("id1", "id2") IN (('1', '2'), ('3', '4'));
</code>```

But what about sqlite?

答:
You could use an OR-condition:

```<code>SELECT  *
FROM    table
WHERE   (id1='1' and id2='2') OR
        (id1='3' and id2='4')
</code>```

ContentLicense: CC BY-SA 3.0

Title: SELECT data based on given pairs

Body:
I have little experience using SQL, and I am now using JDBC to connect to my database.
I am using sqlite, my schema looks as follows:

id1, id2, value1, value2

I want to extract rows based on a list of given pairs of id1 and id2.
I know Postgresql can do

SELECT  *
FROM    table
WHERE   ("id1", "id2") IN (('1', '2'), ('3', '4'));

But what about sqlite?

Body:
You could use an OR-condition:

SELECT  *
FROM    table
WHERE   (id1='1' and id2='2') OR
        (id1='3' and id2='4')


问:
Haskell List of lists operations
I'm trying to traverse through a list of lists and perform an operation on each list.

If I have a list like

```<code>[[("vT",T),("vF",T)],[("vT",T),("vF",F)],[("vT",F),("vF",T)],[("vT",T),("vF",M)],[("vT",M),("vF",T)],[("vT",M),("vF",M)],[("vT",F),("vF",F)],[("vT",F),("vF",M)],[("vT",M),("vF",F)]]
</code>```

How can I create a function that sets an x = [("vT",T),("vF",T)], so that I can use this x to perform an operation, and then set x = [("vT",T),("vF",F)] and so on and then have the answer of each returned in a list?

答:
You can use map to apply a function to each element of a list - here's a complete example:

```<code>data Tribool = T | F | M deriving Show

my_data = [
    [("vT",T),("vF",T)],
    [("vT",T),("vF",F)],
    [("vT",F),("vF",T)],
    [("vT",T),("vF",M)],
    [("vT",M),("vF",T)],
    [("vT",M),("vF",M)],
    [("vT",F),("vF",F)],
    [("vT",F),("vF",M)],
    [("vT",M),("vF",F)]
  ]

f x = reverse x -- example function

processed_data = map f my_data
</code>```

Title: Haskell List of lists operations

Body:
I'm trying to traverse through a list of lists and perform an operation on each list.

If I have a list like

[[("vT",T),("vF",T)],[("vT",T),("vF",F)],[("vT",F),("vF",T)],[("vT",T),("vF",M)],[("vT",M),("vF",T)],[("vT",M),("vF",M)],[("vT",F),("vF",F)],[("vT",F),("vF",M)],[("vT",M),("vF",F)]]

How can I create a function that sets an x = [("vT",T),("vF",T)], so that I can use this x to perform an operation, and then set x = [("vT",T),("vF",F)] and so on and then have the answer of each returned in a list?

Body:
You can use map to apply a function to each element of a list - here's a complete example:

data Tribool = T | F | M deriving Show

my_data = [
    [("vT",T),("vF",T)],
    [("vT",T),("vF",F)],
    [("vT",F),("vF",T)],
    [("vT",T),("vF",M)],
    [("vT",M),("vF",T)],
    [("vT",M),("vF",M)],
    [("vT",F),("vF",F)],
    [("vT",F),("vF",M)],
    [("vT",M),("vF",F)]
  ]

f x = reverse x -- example function

processed_data = map f my_data


答:
You could do something like this:</p>

```<code>SELECT  *
FROM    table
WHERE   (id1 = '1' AND id2= '2') OR (id1='3' AND id2='4');
</code>```

Title: SELECT data based on given pairs

Body:
You could do something like this:

SELECT  *
FROM    table
WHERE   (id1 = '1' AND id2= '2') OR (id1='3' AND id2='4');


问:
How to create Dialog Box with Radio Buttons and return Value
I have a List of Objects. What I want to do:

Build a Dialog Box which shows a Radio Button for each element in the given List and returning the selected element/value by clicking on OK-Button.

Thanks in Advance.

答:
OOps! I came back just to see there are already 2 answers! How ever, I want to post my version, which can build controls according to list of strings:</p>

```<code>//dialog form
public partial class frmDialogcs : Form
{
    public string selectedString;

    //keep default constructor or not is fine
    public frmDialogcs()
    {
        InitializeComponent();
    }

    public frmDialogcs(IList<string> lst)
    {
        InitializeComponent();
        for (int i = 0; i < lst.Count; i++)
        {
            RadioButton rdb = new RadioButton();
            rdb.Text = lst[i];
            rdb.Size = new Size(100, 30);
            this.Controls.Add(rdb);
            rdb.Location = new Point(20, 20 + 35 * i);
            rdb.CheckedChanged += (s, ee) =>
            {
                var r = s as RadioButton;
                if (r.Checked)
                    this.selectedString = r.Text;
            };
        }
    }
    private void btnOK_Click(object sender, EventArgs e)
    {
        this.DialogResult = DialogResult.OK;
    }
}
    //in main form
    private void button1_Click(object sender, EventArgs e)
    {
        var lst = new List<string>() { "a", "b", "c" };
        frmDialogcs dlg = new frmDialogcs(lst);
        if (dlg.ShowDialog() == DialogResult.OK)
        {
            string selected = dlg.selectedString;
            MessageBox.Show(selected);
        }
    }
</code>```

Body:
OOps! I came back just to see there are already 2 answers! How ever, I want to post my version, which can build controls according to list of strings:

//dialog form
public partial class frmDialogcs : Form
{
    public string selectedString;

    //keep default constructor or not is fine
    public frmDialogcs()
    {
        InitializeComponent();
    }

    public frmDialogcs(IList<string> lst)
    {
        InitializeComponent();
        for (int i = 0; i < lst.Count; i++)
        {
            RadioButton rdb = new RadioButton();
            rdb.Text = lst[i];
            rdb.Size = new Size(100, 30);
            this.Controls.Add(rdb);
            rdb.Location = new Point(20, 20 + 35 * i);
            rdb.CheckedChanged += (s, ee) =>
            {
                var r = s as RadioButton;
                if (r.Checked)
                    this.selectedString = r.Text;
            };
        }
    }
    private void btnOK_Click(object sender, EventArgs e)
    {
        this.DialogResult = DialogResult.OK;
    }
}
    //in main form
    private void button1_Click(object sender, EventArgs e)
    {
        var lst = new List<string>() { "a", "b", "c" };
        frmDialogcs dlg = new frmDialogcs(lst);
        if (dlg.ShowDialog() == DialogResult.OK)
        {
            string selected = dlg.selectedString;
            MessageBox.Show(selected);
        }
    }


问:
How SCDF stream diagram reflect multiple source channel?
If a have a source app(named A-Source)  which has multiple channels to emit messages, eg.
channelA.destination=b-topic, channelB.destination=c-topic.
The receiver for b-topic is B-Sink,   for c-topic is C-Sink.
How can i construct my stream,  describe them like:   A|B  and A|C? And if so, i think just part of my A-Source code is useful in every stream.

So my question is: how SCDF stream DSL deal with multiple tap for single source app.

答:
You can use named channel destinations in the Stream DSL.

For example:

dataflow:>stream create tap1 --definition ":b-topic > B-SInk"
dataflow:>stream create tap2 --definition ":c-topic > C-SInk"


问:
Dropwizard Counter Not Retaining value in Spring Boot App
I am trying to register the # of spring boot apps I've in my pvt cloud environment. Logic is to use Counter metric to increment during startUp and decrement during shut down. All the different deployments will publish to the same metricPreFix(--assumption).
Following is the graph I get in Graphite:

```<code>#application.properties
spring.metrics.export.delay-millis=100
</code>```

Why do I see the value to come down to 0 even when the app is running? I have tried with 2 different implementations with same result. Can someone please point out the gap in my understanding? PFB the code

```<code>@Component
public class AppStartupBean implements CommandLineRunner {

private static final String appMetricName = "MyApp.currentCount.GraphOne";
private static final String metricName = "MyApp.currentCount.GraphTwo";

@Autowired
DropwizardMetricServices dwMetricService;

@Autowired
private MetricRegistry registry;

@Override
public void run(String... arg0) throws Exception {
    dwMetricService.increment(appMetricName);

    Counter counter = registry.counter(metricName);
    counter.inc();
}
}
</code>```

答:
The configuration for DropwizardMetricServices was wrong. I was using

```<code>@Bean
public DropwizardMetricServices dwMetricService(MetricRegistry registry) {
     return new DropwizardMetricServices(registry);
}
</code>```

Instead we should just @Autowire DropwizardMetricServices as needed. PFB

When Dropwizard metrics are in use, the default CounterService and
  GaugeService are replaced with a DropwizardMetricServices, which is a
  wrapper around the MetricRegistry (so you can @Autowired one of those
  services and use it as normal).

Body:
I am trying to register the # of spring boot apps I've in my pvt cloud environment. Logic is to use Counter metric to increment during startUp and decrement during shut down. All the different deployments will publish to the same metricPreFix(--assumption).
Following is the graph I get in Graphite:

#application.properties
spring.metrics.export.delay-millis=100

Why do I see the value to come down to 0 even when the app is running? I have tried with 2 different implementations with same result. Can someone please point out the gap in my understanding? PFB the code

@Component
public class AppStartupBean implements CommandLineRunner {

private static final String appMetricName = "MyApp.currentCount.GraphOne";
private static final String metricName = "MyApp.currentCount.GraphTwo";

@Autowired
DropwizardMetricServices dwMetricService;

@Autowired
private MetricRegistry registry;

@Override
public void run(String... arg0) throws Exception {
    dwMetricService.increment(appMetricName);

    Counter counter = registry.counter(metricName);
    counter.inc();
}
}

Body:
The configuration for DropwizardMetricServices was wrong. I was using

@Bean
public DropwizardMetricServices dwMetricService(MetricRegistry registry) {
     return new DropwizardMetricServices(registry);
}

Instead we should just @Autowire DropwizardMetricServices as needed. PFB

When Dropwizard metrics are in use, the default CounterService and
  GaugeService are replaced with a DropwizardMetricServices, which is a
  wrapper around the MetricRegistry (so you can @Autowired one of those
  services and use it as normal).


问:
Where to see the xml file after "adb shell uiautomator dump view.xml"
I use command

```<code>adb shell uiautomator dump view.xml
</code>```

to dump the UI hierarchy of current Android screen. Then, I try to see the view.xml, I tried command:

```<code>adb shell cat view.xml
</code>```

but get error:

```<code>/system/bin/sh: cat: view.xml: No such file or directory
</code>```

How/Where can I see the dumped view.xml file?

答:
Why don't you do the following:

```<code>adb shell uiautomator dump

adb pull /sdcard/window_dump.xml
</code>```

If you directly want to read out from shell  you can execute following command from adb shell after dumping the XML

```<code>adb shell cat /sdcard/window_dump.xml
</code>```

Body:
I use command

adb shell uiautomator dump view.xml

to dump the UI hierarchy of current Android screen. Then, I try to see the view.xml, I tried command:

adb shell cat view.xml

but get error:

/system/bin/sh: cat: view.xml: No such file or directory

How/Where can I see the dumped view.xml file?

Body:
Why don't you do the following:

adb shell uiautomator dump

adb pull /sdcard/window_dump.xml

If you directly want to read out from shell  you can execute following command from adb shell after dumping the XML

adb shell cat /sdcard/window_dump.xml


问:
How to convert date string into date in swift 3
I have formatted date in string format like "07/06/2017 11:23 AM" so I want to convert it into again date format. How to do this?.</p>

答:
Use this string class extension

```<code>   extension String {
    func date(format: String) -> Date? {
            let dateFormatter = DateFormatter()
            dateFormatter.dateFormat = format
            dateFormatter.timeZone =TimeZone.current
            let date = dateFormatter.date(from: self)
            return date
        }
    }
</code>```

use above function like this

```<code>let date = "07/06/2017 11:23 AM".date(format:"MM/dd/yyyy HH:mm a")
</code>```

Body:
Use this string class extension

   extension String {
    func date(format: String) -> Date? {
            let dateFormatter = DateFormatter()
            dateFormatter.dateFormat = format
            dateFormatter.timeZone =TimeZone.current
            let date = dateFormatter.date(from: self)
            return date
        }
    }

use above function like this

let date = "07/06/2017 11:23 AM".date(format:"MM/dd/yyyy HH:mm a")


问:
find the sum of all the numbers in the Fibonacci series that are smaller or equal to that number
The Fibonacci numbers are the numbers in the following integer sequence.

```<code>0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 . . .
</code>```

Given a specific number in this series Fn, your program needs to find the sum of all the numbers in the Fibonacci series that are smaller or equal to that number.

Input Format
Your program will be provided a number in the Fibonacci series on STDIN.

Constraints

```<code>0<<Fn<100000
</code>```

Sample Input

```<code>8
</code>```

Sample Output

```<code>The output for above input (8) should be 0 + 1 + 1 + 2 + 3 + 5 + 8
20
</code>```

To solve above problem I write a code like

```<code>import java.util.*;
import java.lang.*;
import java.io.*;

class MyTest{
    public static Integer solveProblem(int n) {
        if (n>=0 || n<100000) {
        int fibo[] = new int[n+1];
        fibo[0] = 0; fibo[1] = 1;
        int sum = fibo[0] + fibo[1];
        for (int i=2; i<=n; i++) {
            fibo[i] = fibo[i-1]+fibo[i-2];
            if(n >= fibo[i]) {
                sum += fibo[i];
            } else {
                break;
            }
        }
        return sum;
        } else {
            return 0;
        }
    }

    public static void main (String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);
        int sum = MyTest.solveProblem(in.nextInt());
        System.out.println("This is the output:"+sum);
    }
}
</code>```

I run the program it works fine with the sample test case as mentioned but when I submit this program on online test quiz then it run with their test case and it will fail.

Is something wrong in my program or I didn't understand the question properly. Please help me to find out exact answer of this problem.

答:
You should get the value from the Scanner

```<code>Scanner in = new Scanner(System.in);
int sum = MyTest.solveProblem(8);
</code>```

by using Scanner.nextInt()

```<code>Scanner in = new Scanner(System.in);
int sum = MyTest.solveProblem(in.nextInt());
</code>```

If you input a value of 0, it is accepted by your condition but you create an array of size 1, then try to access the second value -> ArrayIndexOutOfBoundsException

```<code>int fibo[] = new int[n+1];
fibo[0] = 0;
fibo[1] = 1; //HERE, exception as there is not `fibo[1]`
</code>```

Update the condition to

```<code>if ( n > 0 && n < 100000) //note the && to correct your logic error too
</code>```

NOTE : I don't think this is a good idea to use an array here since you are using a big array that is not necessary (not fully used), using two variables (last, current) would be simpler.

Body:
The Fibonacci numbers are the numbers in the following integer sequence.

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 . . .

Given a specific number in this series Fn, your program needs to find the sum of all the numbers in the Fibonacci series that are smaller or equal to that number.

Input Format
Your program will be provided a number in the Fibonacci series on STDIN.

Constraints

0<<Fn<100000

Sample Input

8

Sample Output

The output for above input (8) should be 0 + 1 + 1 + 2 + 3 + 5 + 8
20

To solve above problem I write a code like

import java.util.*;
import java.lang.*;
import java.io.*;

class MyTest{
    public static Integer solveProblem(int n) {
        if (n>=0 || n<100000) {
        int fibo[] = new int[n+1];
        fibo[0] = 0; fibo[1] = 1;
        int sum = fibo[0] + fibo[1];
        for (int i=2; i<=n; i++) {
            fibo[i] = fibo[i-1]+fibo[i-2];
            if(n >= fibo[i]) {
                sum += fibo[i];
            } else {
                break;
            }
        }
        return sum;
        } else {
            return 0;
        }
    }

    public static void main (String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);
        int sum = MyTest.solveProblem(in.nextInt());
        System.out.println("This is the output:"+sum);
    }
}

I run the program it works fine with the sample test case as mentioned but when I submit this program on online test quiz then it run with their test case and it will fail.

Is something wrong in my program or I didn't understand the question properly. Please help me to find out exact answer of this problem.

Body:
You should get the value from the Scanner

Scanner in = new Scanner(System.in);
int sum = MyTest.solveProblem(8);

by using Scanner.nextInt()

Scanner in = new Scanner(System.in);
int sum = MyTest.solveProblem(in.nextInt());

If you input a value of 0, it is accepted by your condition but you create an array of size 1, then try to access the second value -> ArrayIndexOutOfBoundsException

int fibo[] = new int[n+1];
fibo[0] = 0;
fibo[1] = 1; //HERE, exception as there is not `fibo[1]`

Update the condition to

if ( n > 0 && n < 100000) //note the && to correct your logic error too

NOTE : I don't think this is a good idea to use an array here since you are using a big array that is not necessary (not fully used), using two variables (last, current) would be simpler.


问:
I want to get keys names from hash which has same values in ruby
```<code>{"Amar"=>20,"Benton"=>14,"John"=>32,"Sunny"=>28,"Edward"=>19,"Leon"=>12,"Ram"=>19,"David"=>28}
</code>```

the above hash has name and age ,i want to get the names which has same age in ruby

答:
For your hash

```<code> names_hash = {"Amar"=>20,"Benton"=>14,
  "John"=>32,"Sunny"=>28,
  "Edward"=>19,"Leon"=>12,
  "Ram"=>19,"David"=>28}
</code>```

You can always define a method which gives the desired names for an age

```<code>def names_for_age(age, hash = {})
  hash.inject({}) do |container, (k,v)|
    container[v] ||= []
    container[v] << k
    container
  end[age]
end
</code>```

So, now you can get the names as

```<code>names_for_age(10, names_hash)
</code>```

Body:
{"Amar"=>20,"Benton"=>14,"John"=>32,"Sunny"=>28,"Edward"=>19,"Leon"=>12,"Ram"=>19,"David"=>28}

the above hash has name and age ,i want to get the names which has same age in ruby

Body:
For your hash

 names_hash = {"Amar"=>20,"Benton"=>14,
  "John"=>32,"Sunny"=>28,
  "Edward"=>19,"Leon"=>12,
  "Ram"=>19,"David"=>28}

You can always define a method which gives the desired names for an age

def names_for_age(age, hash = {})
  hash.inject({}) do |container, (k,v)|
    container[v] ||= []
    container[v] << k
    container
  end[age]
end

So, now you can get the names as

names_for_age(10, names_hash)


问:
how to convert folder into Zip file in codeigniter where folder contains some image file
i have some doubts in zipping the folder in codeigniter.Actually i have some image files in the folder and i was trying to zip this folder in codegiter. I have view file where i have written "Download all file" button. On clicking this button i have to take the folder and zip it.
My view file:
I have written the button "Download All Files" inside the anchor tag.

```<code><tr>
    <td align="right">
        <?php  if(isset($AppData) && !empty($AppData)) {
          $applicantNo = $AppData[0]['appid']; ?>
        <a href='<?php echo base_url("admin/downloadAllFileZip/$applicantNo");?>'><input type="submit" name="download" value="Download All Files" /></a>
         <?php } ?>

    </td>
   </tr>
</code>```

Controller code:
Inside admin.php controller file i have the below method

```<code>public function downloadAllFileZip($appId)
    {

        $path = file_get_contents(base_url().'files/'.$appId);
        $applicant_id = $appId;
        $this->zip->add_data($applicant_id,$path);
        $this->zip->archive('/files/'.$applicant_id);
        $this->zip->download($applicant_id);

    }
</code>```

But when I am clicking the " Download all file " button the popup window for zipping is comming and after downloading its showing 1kb file but there is no image on that file. I can able to zip single image file as a zip file but not able to zip the entire folder. Please help me how to do this.

答:
Zip library permits you to create Zip archives

```<code>$this->load->library('zip');
</code>```

Give path of your folder that you want to add in archive

```<code> $file_name='backup['.date('d-m-Y-H:i:s').'].zip';
 $this->zip->read_dir($_SERVER['DOCUMENT_ROOT']."/uploads/images",FALSE);
 $this->zip->download($file_name);
</code>```

I think give absolute path is better way for archived folder on specific folder

Body:
i have some doubts in zipping the folder in codeigniter.Actually i have some image files in the folder and i was trying to zip this folder in codegiter. I have view file where i have written "Download all file" button. On clicking this button i have to take the folder and zip it.
My view file:
I have written the button "Download All Files" inside the anchor tag.

        <?php  if(isset($AppData) && !empty($AppData)) {
          $applicantNo = $AppData[0]['appid']; ?>
        <a href='<?php echo base_url("admin/downloadAllFileZip/$applicantNo");?>'><input type="submit" name="download" value="Download All Files" />
         <?php } ?>

Controller code:
Inside admin.php controller file i have the below method

public function downloadAllFileZip($appId)
    {

        $path = file_get_contents(base_url().'files/'.$appId);
        $applicant_id = $appId;
        $this->zip->add_data($applicant_id,$path);
        $this->zip->archive('/files/'.$applicant_id);
        $this->zip->download($applicant_id);

    }

But when I am clicking the " Download all file " button the popup window for zipping is comming and after downloading its showing 1kb file but there is no image on that file. I can able to zip single image file as a zip file but not able to zip the entire folder. Please help me how to do this.

Body:
Zip library permits you to create Zip archives

$this->load->library('zip');

Give path of your folder that you want to add in archive

 $file_name='backup['.date('d-m-Y-H:i:s').'].zip';
 $this->zip->read_dir($_SERVER['DOCUMENT_ROOT']."/uploads/images",FALSE);
 $this->zip->download($file_name);

I think give absolute path is better way for archived folder on specific folder


问:
Unity open external link
By placing the unity file on the page I can not redirect the action to another page. What happens is that the new page is opened inside the frame intended for the unity file.</p>

```<code>using UnityEngine;
using System.Collections;

public class Urlazerecovelo : MonoBehaviour {

 void OnMouseDown ()

{

 Application.OpenURL("https://www.google.pt");

  }

}
</code>```

答:
```<code>public class OpenWebPage : MonoBehaviour, IPointerClickHandler
{
    public void OnPointerClick(PointerEventData eventData)
    {
        Application.ExternalEval("window.open('www.google.pl', '_blank');");
    }
}
</code>```

I assume from what you're saying you use WebGL as target platform. More about here

Title: Unity open external link

Body:
By placing the unity file on the page I can not redirect the action to another page. What happens is that the new page is opened inside the frame intended for the unity file.

using UnityEngine;
using System.Collections;

public class Urlazerecovelo : MonoBehaviour {

 void OnMouseDown ()

{

 Application.OpenURL("https://www.google.pt");

  }

}

Body:
public class OpenWebPage : MonoBehaviour, IPointerClickHandler
{
    public void OnPointerClick(PointerEventData eventData)
    {
        Application.ExternalEval("window.open('www.google.pl', '_blank');");
    }
}

I assume from what you're saying you use WebGL as target platform. More about here


问:
Authenticate with PHP and interact with JS in Firebase
I am having a PHP based application, that uses MySQL as the DB. I am currently trying to build a real-time messaging system for the users in the application. I have found Firebase to be a very good solution for building this. However, I am not sure if the architecture I am planning is compatible with the architecture am planning. Digging through the documentation didn't really get me the answers.

My Doubts are:

I don't want users to again login to use chat, so I want to
authenticated via the server (i.e from php).

I want, the further chat/messaging to happen from client to Firebase directly as I don't want to have unwanted overhead on my server, especially when a direct connection is not only supported but also efficient.

Can I authenticate via php and get some secret key or something and then use that to connect securely via Js?

I found this link which talks about custom authentication system. But am not sure, if this is what I have to use. And if the solution am planning is scalable and ok.

答:
Firebase Auth persists the session on the client via localStorage/indexedDB and is a headless API that doesn't require a hosted server. So you are not required to authenticate the user via your server.

You can definitely build the messaging app entirely on the client with real-time database without routing traffic to your server. Here is an example of a chat app built with Firebase: https://github.com/firebase/friendlychat

If you already have an existing authentication system, you can use custom auth which requires that you mint a custom token after you authenticate a user with your system, you then send that custom token to the client and then signInWithCustomToken. Here is some code to create a custom token with PHP: https://firebase.google.com/docs/auth/admin/create-custom-tokens#create_custom_tokens_using_the_firebase_admin_sdk
If you don't have an existing auth system, you can entirely run the authentication on the client side. Another good library for authentication that is built on top of Firebase is FirebaseUI: https://github.com/firebase/firebaseui-web


问:
Proper way to add text on top of navbar bootstrap
I tried to add this code after a ul tag:

```<code><p class="navbar-text pull-right">
    <strong>Toll Free Num: 1 300 22 6868</strong>
</p>
</code>```

but I got these results

bootstrap navbar.

What is the proper way to add the text below or on top of contact?

答:
Simply add the div tag before or after nav tag

See below.

```<code> <div class="text-right"><strong>Toll Free Num: 1 300 22 6868</strong></div>
</code>```

Body:
I tried to add this code after a ul tag:

    Toll Free Num: 1 300 22 6868

but I got these results

bootstrap navbar.

What is the proper way to add the text below or on top of contact?

Body:
Simply add the div tag before or after nav tag

See below.

 <div class="text-right"><strong>Toll Free Num: 1 300 22 6868</strong></div>


问:
Working in IE 11 but not working Google Chrome - excel file download using jquery
here is the fiddle

https://jsfiddle.net/ym4egje0/13/

File download is happening for IE (internet explorer) not working for google chrome .

I cant change the HTML and CSS part  .

Cant Use any external library

I Think i have to change the part

```<code> else {
                $('#test').attr('href', data_type + ', ' + encodeURIComponent(tab_text));
                $('#test').attr('download', 'Test file.xls');
            }
</code>```

But what to chnage so that it works for both google chrome and IE

HTML

```<code><input type="button" id="test" onClick="fnExcelReport();" value="download" />

<div id='MessageHolder'></div>
</code>```

JS

```<code>function CreateHiddenTable(ListOfMessages)
{
var ColumnHead = "Column Header Text";
var TableMarkUp='<table id="myModifiedTable" class="visibilityHide"><thead><tr><td><b>'+ColumnHead+'</b></td>  </tr></thead><tbody>';
console.log(ListOfMessages);
console.log(ListOfMessages.length);
for(i=0; i<ListOfMessages.length; i++){
    TableMarkUp += '<tr><td>' + ListOfMessages[i] +'</td></tr>';
}
TableMarkUp += "</tbody></table>";
$('#MessageHolder').append(TableMarkUp);
}

function fnExcelReport() {
var Messages = "\n message1.\n message2.";
var ListOfMessages = Messages.split(".");

CreateHiddenTable(ListOfMessages);

    var tab_text = '<html xmlns:x="urn:schemas-microsoft-com:office:excel">';
    tab_text = tab_text + '<head><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>';

    tab_text = tab_text + '<x:Name>Error Messages</x:Name>';

    tab_text = tab_text + '<x:WorksheetOptions><x:Panes></x:Panes></x:WorksheetOptions></x:ExcelWorksheet>';
    tab_text = tab_text + '</x:ExcelWorksheets></x:ExcelWorkbook></xml></head><body>';

    tab_text = tab_text + "<table border='1px'>";
    tab_text = tab_text + $('#myModifiedTable').html();;
    tab_text = tab_text + '</table></body></html>';

    var data_type = 'data:application/vnd.ms-excel';

    var ua = window.navigator.userAgent;
    var msie = ua.indexOf("MSIE ");

    if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
        if (window.navigator.msSaveBlob) {
            var blob = new Blob([tab_text], {
                type: "application/csv;charset=utf-8;"
            });
            navigator.msSaveBlob(blob, 'Test file.xls');
        }
    } else {
        $('#test').attr('href', data_type + ', ' + encodeURIComponent(tab_text));
        $('#test').attr('download', 'Test file.xls');
    }
$('

#MessageHolder').html("");
}
</code>```

CSS

```<code>.visibilityHide
{
  visibility:hidden;
}
</code>```

答:
check out this fiddle , now it will work for IE and google chrome .
https://jsfiddle.net/shaswatatripathy/fo4ugmLp/1/

so it can be treated as client side excel file creation solution . I just added one  element but if you want you can create it in jquery and add it to the same div

HTML

```<code><input type="button" id="test" onClick="fnExcelReport();" value="download" />

<div id='MessageHolder'></div>

<a href="#" id="testAnchor"></a>
</code>```

JS

```<code>var tab_text;
var data_type = 'data:application/vnd.ms-excel';

function CreateHiddenTable(ListOfMessages)
{
var ColumnHead = "Column Header Text";
var TableMarkUp='<table id="myModifiedTable" class="visibilityHide"><thead><tr><td><b>'+ColumnHead+'</b></td>  </tr></thead><tbody>';

for(i=0; i<ListOfMessages.length; i++){
    TableMarkUp += '<tr><td>' + ListOfMessages[i] +'</td></tr>';
}
TableMarkUp += "</tbody></table>";
$('#MessageHolder').append(TableMarkUp);
}

function fnExcelReport() {
var Messages = "\n message1.\n message2.";
var ListOfMessages = Messages.split(".");

CreateHiddenTable(ListOfMessages);

    tab_text = '<html xmlns:x="urn:schemas-microsoft-com:office:excel">';
    tab_text = tab_text + '<head><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>';

    tab_text = tab_text + '<x:Name>Error Messages</x:Name>';

    tab_text = tab_text + '<x:WorksheetOptions><x:Panes></x:Panes></x:WorksheetOptions></x:ExcelWorksheet>';
    tab_text = tab_text + '</x:ExcelWorksheets></x:ExcelWorkbook></xml></head><body>';

    tab_text = tab_text + "<table border='1px'>";
    tab_text = tab_text + $('#myModifiedTable').html();;
    tab_text = tab_text + '</table></body></html>';

    data_type = 'data:application/vnd.ms-excel';

    var ua = window.navigator.userAgent;
    var msie = ua.indexOf("MSIE ");

    if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
        if (window.navigator.msSaveBlob) {
            var blob = new Blob([tab_text], {
                type: "application/csv;charset=utf-8;"
            });
            navigator.msSaveBlob(blob, 'Test file.xls');
        }
    } else {
    console.log(data_type);
console.log(tab_text);
      $('#testAnchor')[0].click()
    }
$('#MessageHolder').html("");
}
$($("#testAnchor")[0]).click(function(){
console.log(data_type);
console.log(tab_text);
  $('#testAnchor').attr('href', data_type + ', ' + encodeURIComponent(tab_text));
        $('#testAnchor').attr('download', 'Test file.xls');
});
</code>```

CSS

```<code>.visibilityHide
{
  visibility:hidden;
}
</code>```

Body:
here is the fiddle

https://jsfiddle.net/ym4egje0/13/

File download is happening for IE (internet explorer) not working for google chrome .

I cant change the HTML and CSS part  .

Cant Use any external library

I Think i have to change the part

 else {
                $('#test').attr('href', data_type + ', ' + encodeURIComponent(tab_text));
                $('#test').attr('download', 'Test file.xls');
            }

But what to chnage so that it works for both google chrome and IE

HTML

<input type="button" id="test" onClick="fnExcelReport();" value="download" />

JS

function CreateHiddenTable(ListOfMessages)
{
var ColumnHead = "Column Header Text";
var TableMarkUp='

'+ColumnHead+'

';
console.log(ListOfMessages);
console.log(ListOfMessages.length);
for(i=0; i<ListOfMessages.length; i++){
    TableMarkUp += '
' + ListOfMessages[i] +'
';
}
TableMarkUp += "

";
$('#MessageHolder').append(TableMarkUp);
}

function fnExcelReport() {
var Messages = "\n message1.\n message2.";
var ListOfMessages = Messages.split(".");

CreateHiddenTable(ListOfMessages);

    var tab_text = '';
    tab_text = tab_text + '<xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>';

    tab_text = tab_text + '<x:Name>Error Messages</x:Name>';

    tab_text = tab_text + '<x:WorksheetOptions><x:Panes></x:Panes></x:WorksheetOptions></x:ExcelWorksheet>';
    tab_text = tab_text + '</x:ExcelWorksheets></x:ExcelWorkbook></xml>';

    tab_text = tab_text + "
";
    tab_text = tab_text + $('#myModifiedTable').html();;
    tab_text = tab_text + '
';

    var data_type = 'data:application/vnd.ms-excel';

    var ua = window.navigator.userAgent;
    var msie = ua.indexOf("MSIE ");

    if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
        if (window.navigator.msSaveBlob) {
            var blob = new Blob([tab_text], {
                type: "application/csv;charset=utf-8;"
            });
            navigator.msSaveBlob(blob, 'Test file.xls');
        }
    } else {
        $('#test').attr('href', data_type + ', ' + encodeURIComponent(tab_text));
        $('#test').attr('download', 'Test file.xls');
    }
$('

#MessageHolder').html("");
}

CSS

.visibilityHide
{
  visibility:hidden;
}

Body:
check out this fiddle , now it will work for IE and google chrome .
https://jsfiddle.net/shaswatatripathy/fo4ugmLp/1/

so it can be treated as client side excel file creation solution . I just added one  element but if you want you can create it in jquery and add it to the same div

HTML

<input type="button" id="test" onClick="fnExcelReport();" value="download" />

<div id='MessageHolder'></div>

<a href="#" id="testAnchor"></a>

JS

var tab_text;
var data_type = 'data:application/vnd.ms-excel';

function CreateHiddenTable(ListOfMessages)
{
var ColumnHead = "Column Header Text";
var TableMarkUp='<table id="myModifiedTable" class="visibilityHide"><thead><tr><td><b>'+ColumnHead+'</b></td>  </tr></thead><tbody>';

for(i=0; i<ListOfMessages.length; i++){
    TableMarkUp += '<tr><td>' + ListOfMessages[i] +'</td></tr>';
}
TableMarkUp += "</tbody></table>";
$('#MessageHolder').append(TableMarkUp);
}

function fnExcelReport() {
var Messages = "\n message1.\n message2.";
var ListOfMessages = Messages.split(".");

CreateHiddenTable(ListOfMessages);

    tab_text = '<html xmlns:x="urn:schemas-microsoft-com:office:excel">';
    tab_text = tab_text + '<head><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>';

    tab_text = tab_text + '<x:Name>Error Messages</x:Name>';

    tab_text = tab_text + '<x:WorksheetOptions><x:Panes></x:Panes></x:WorksheetOptions></x:ExcelWorksheet>';
    tab_text = tab_text + '</x:ExcelWorksheets></x:ExcelWorkbook></xml></head><body>';

    tab_text = tab_text + "<table border='1px'>";
    tab_text = tab_text + $('#myModifiedTable').html();;
    tab_text = tab_text + '</table></body></html>';

    data_type = 'data:application/vnd.ms-excel';

    var ua = window.navigator.userAgent;
    var msie = ua.indexOf("MSIE ");

    if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
        if (window.navigator.msSaveBlob) {
            var blob = new Blob([tab_text], {
                type: "application/csv;charset=utf-8;"
            });
            navigator.msSaveBlob(blob, 'Test file.xls');
        }
    } else {
    console.log(data_type);
console.log(tab_text);
      $('#testAnchor')[0].click()
    }
$('#MessageHolder').html("");
}
$($("#testAnchor")[0]).click(function(){
console.log(data_type);
console.log(tab_text);
  $('#testAnchor').attr('href', data_type + ', ' + encodeURIComponent(tab_text));
        $('#testAnchor').attr('download', 'Test file.xls');
});

CSS

.visibilityHide
{
  visibility:hidden;
}


问:
Automapper - mapping an overriden property leads to casting Exception
We just upgraded from Automapper 3.3.0 to 6.0.2 and after upgrading our solution, one of the mappings does not seem to work anymore.

Consider this :

```<code>public class Source{
   public Decimal GrossAmount {get;set;}
}

public class DerivedSource : Source{
}

public class DestinationMaster{
   public virtual DestinationChild Child {get;set;}
}

public class DestinationChild{
   public decimal GrossAmount {get;set;}
}

public class DerivedDestinationMaster : DestinationMaster {
   private DerivedDestinationChild _destinationChild;

   public override DestinationChild Child {
      get{return _destinationChild;}
      set{_destinationChild = (DerivedDestinationChild)value;}
   }
}

public class DerivedDestinationChild : DestinationChild{
  public string OtherProperty {get;set;}
}
</code>```

And now for the mappings :

```<code>CreateMap<Source,DestinationMaster>()
  .Include<DerivedSource,DerivedDestinationMaster>();

CreateMap<DerivedSource,DerivedDestinationMaster>()
  .ForMember(dest => dest.Child, act=> act.MapFrom(src => new DerivedDestinationChild(){ GrossAmount = src.GrossAmount }));
</code>```

Now, if I try to map a "Source" object to a new"DerivedDestinationMaster" instance, I get an Exception telling that I cannot convert "DestinationChild" to "DerivedDestinationChild".

If I put a breakpoint in the "setter" accessor in the overriden property, I clearly see that the passed instance is of type "DestinationChild".  I can also see that there is two constructor calls for the "DestinactionChild" class.  The "GrossAmount" value is the good one from the "Source" object and not 0, as if, after creating and instance of "DerivedDestinationChild", it creates a new instance of "DestinationChild" to receive the information and automaps the two objects.

Our scenario is a bit more complex (we use a IValueResolver), but we tested with the "MapFrom", "UseValue" and a custom Resolver and in all cases, the final instance is not of the derived type.

If we put a "act.Ignore()" on the mapping, the Exception is not raised

Thank you for your help !

答:
As document here, the mapping follows a certain order for inheritance trees.  The way you can get it working is by duplicating some maps, is that a viable solution for you?

```<code>class Program
{
    static void Main(string[] args)
    {
        Mapper.Initialize(cfg =>
        {
            cfg.CreateMap<Source, DestinationMaster>().ForMember(dest => dest.Child, act => act.MapFrom(s => new DestinationChild { GrossAmount = s.GrossAmount}));
            cfg.CreateMap<DerivedSource, DerivedDestinationMaster>().IncludeBase<Source, DestinationMaster>().ForMember(dest => dest.Child, act => act.MapFrom(s => new DerivedDestinationChild { GrossAmount = s.GrossAmount }));
        });

        var source = new Source() {GrossAmount = 99};
        var destinationMaster = Mapper.Map<DestinationMaster>(source);
        Debug.Assert(destinationMaster.Child.GrossAmount == source.GrossAmount);
        Debug.Assert(destinationMaster.Child.GetType() == typeof(DestinationChild));

        var derivedSource = new DerivedSource() {GrossAmount = 10};
        var derivedDestinationMaster = Mapper.Map<DerivedDestinationMaster>(derivedSource);
        Debug.Assert(derivedDestinationMaster.Child.GrossAmount == derivedSource.GrossAmount);
        Debug.Assert(derivedDestinationMaster.Child.GetType() == typeof(DerivedDestinationChild));
    }
}
</code>```

Other than that I am not sure how you could return a specific derived type with the GrossAmount mapped from the base mapping.

Body:
We just upgraded from Automapper 3.3.0 to 6.0.2 and after upgrading our solution, one of the mappings does not seem to work anymore.

Consider this :

public class Source{
   public Decimal GrossAmount {get;set;}
}

public class DerivedSource : Source{
}

public class DestinationMaster{
   public virtual DestinationChild Child {get;set;}
}

public class DestinationChild{
   public decimal GrossAmount {get;set;}
}

public class DerivedDestinationMaster : DestinationMaster {
   private DerivedDestinationChild _destinationChild;

   public override DestinationChild Child {
      get{return _destinationChild;}
      set{_destinationChild = (DerivedDestinationChild)value;}
   }
}

public class DerivedDestinationChild : DestinationChild{
  public string OtherProperty {get;set;}
}

And now for the mappings :

CreateMap<Source,DestinationMaster>()
  .Include<DerivedSource,DerivedDestinationMaster>();

CreateMap<DerivedSource,DerivedDestinationMaster>()
  .ForMember(dest => dest.Child, act=> act.MapFrom(src => new DerivedDestinationChild(){ GrossAmount = src.GrossAmount }));

Now, if I try to map a "Source" object to a new"DerivedDestinationMaster" instance, I get an Exception telling that I cannot convert "DestinationChild" to "DerivedDestinationChild".

If I put a breakpoint in the "setter" accessor in the overriden property, I clearly see that the passed instance is of type "DestinationChild".  I can also see that there is two constructor calls for the "DestinactionChild" class.  The "GrossAmount" value is the good one from the "Source" object and not 0, as if, after creating and instance of "DerivedDestinationChild", it creates a new instance of "DestinationChild" to receive the information and automaps the two objects.

Our scenario is a bit more complex (we use a IValueResolver), but we tested with the "MapFrom", "UseValue" and a custom Resolver and in all cases, the final instance is not of the derived type.

If we put a "act.Ignore()" on the mapping, the Exception is not raised

Thank you for your help !

Body:
As document here, the mapping follows a certain order for inheritance trees.  The way you can get it working is by duplicating some maps, is that a viable solution for you?

class Program
{
    static void Main(string[] args)
    {
        Mapper.Initialize(cfg =>
        {
            cfg.CreateMap<Source, DestinationMaster>().ForMember(dest => dest.Child, act => act.MapFrom(s => new DestinationChild { GrossAmount = s.GrossAmount}));
            cfg.CreateMap<DerivedSource, DerivedDestinationMaster>().IncludeBase<Source, DestinationMaster>().ForMember(dest => dest.Child, act => act.MapFrom(s => new DerivedDestinationChild { GrossAmount = s.GrossAmount }));
        });

        var source = new Source() {GrossAmount = 99};
        var destinationMaster = Mapper.Map<DestinationMaster>(source);
        Debug.Assert(destinationMaster.Child.GrossAmount == source.GrossAmount);
        Debug.Assert(destinationMaster.Child.GetType() == typeof(DestinationChild));

        var derivedSource = new DerivedSource() {GrossAmount = 10};
        var derivedDestinationMaster = Mapper.Map<DerivedDestinationMaster>(derivedSource);
        Debug.Assert(derivedDestinationMaster.Child.GrossAmount == derivedSource.GrossAmount);
        Debug.Assert(derivedDestinationMaster.Child.GetType() == typeof(DerivedDestinationChild));
    }
}

Other than that I am not sure how you could return a specific derived type with the GrossAmount mapped from the base mapping.


问:
Not getting click event in jQuery
Thanks in advance.
My html contains:

```<code>    <div class="help-link">
       <a href="">WHY?</a>
   </div>
</code>```

and

```<code>    <div class="modal-container">
    <div data-id="modal1" class="status-modal modal">
        <div class="modal-body">
            <header>Status</header>
            <p><span class="fnt-wt-500"></span> Lorem Ipsum is simply
                      dummy text of the printing and typesetting industry.</p>
            <p><span class="fnt-wt-500"></span> Lorem Ipsum has been
                     the industry's standard dummy text ever since the 1500s.</p>
            <p><span class="fnt-wt-500"> </span>Various versions have
                     evolved over the years, sometimes by accident.</p>
            <div class="modal-footer clearfix">
                <a href="#" class="close">OK</a>
            </div>
        </div>
    </div>
  </div>
  <div class="modal-backdrop">
  </div>
</code>```

JQuery code is like

```<code>       $(document).ready(function() {

        $(".help-link a").click(function(e) {
            console.log("help link a clicked ");
            e.preventDefault();
            if (!$(".modal-backdrop, .modal-container").hasClass("open")) {
                $(".modal-backdrop, .modal-container").addClass("open");
            } else {
                $(".modal-backdrop, .modal-container").removeClass("open");
            }
             });
         });
       }
</code>```

But I am not able to log event for the click on help-link a. Please help.
Did I miss something in jquery?

答:
You have an extra curly braces at the end of this function

$(document).ready(function() {

```<code>    $(".help-link a").click(function(e) {
        console.log("help link a clicked ");
        e.preventDefault();
        if (!$(".modal-backdrop, .modal-container").hasClass("open")) {
            $(".modal-backdrop, .modal-container").addClass("open");
        } else {
            $(".modal-backdrop, .modal-container").removeClass("open");
        }
         });
     });
   **}**
</code>```

Remove it and it will work

Title: Not getting click event in jQuery

Body:
Thanks in advance.
My html contains:

       WHY?

and

            Status

 Lorem Ipsum is simply
                      dummy text of the printing and typesetting industry.

 Lorem Ipsum has been
                     the industry's standard dummy text ever since the 1500s.

 Various versions have
                     evolved over the years, sometimes by accident.

                OK

JQuery code is like

       $(document).ready(function() {

        $(".help-link a").click(function(e) {
            console.log("help link a clicked ");
            e.preventDefault();
            if (!$(".modal-backdrop, .modal-container").hasClass("open")) {
                $(".modal-backdrop, .modal-container").addClass("open");
            } else {
                $(".modal-backdrop, .modal-container").removeClass("open");
            }
             });
         });
       }

But I am not able to log event for the click on help-link a. Please help.
Did I miss something in jquery?

Body:
You have an extra curly braces at the end of this function

$(document).ready(function() {

    $(".help-link a").click(function(e) {
        console.log("help link a clicked ");
        e.preventDefault();
        if (!$(".modal-backdrop, .modal-container").hasClass("open")) {
            $(".modal-backdrop, .modal-container").addClass("open");
        } else {
            $(".modal-backdrop, .modal-container").removeClass("open");
        }
         });
     });
   **}**

Remove it and it will work


问:
CSS placing an absolute div beside another div (pure CSS popover)
I have a sidebar with a user profile picture (pink color). When the viewer hover on the image, a div (blue color) appears and it contains user details. Basically, I want an absolute positioned div appear next to its sibling.

It is functionally a popover, but I want to do it with pure CSS, is it possible?

I am using boostrap 4, it will be nice if the suggestion can co-exists with Bootstrap CSS. It will be awesome if the div can have an arrow associate with it.

My code is:

```<code><div>
    <div><figure class="figure"><img ... /></figure></div>
    //css-popover
    <div class="css-popover">User detail: ... bla bla bla ...</div>
</div>
</code>```

I tried to search in Stackoverflow, most of the question is related to float div and makes it beside, but I want something absolute positioned, and display on top of the body.

Update:

Most of the suggestions provided fulfill part of the requests. The suggested .css-popover width and height are bounded by the parents, but I wish the popover dimension be independent from the parent, i.e. just "popup" and it doesn't "change" the layout beneath.

And when the popup appear, it doesn't change the parent height too. I wish the sidebar "icon" (light pink icons) stay in place whenever a popup appear.

If it is not possible with CSS, then I just go for JS solution...

You can try your luck here. https://jsfiddle.net/byanjiong/nohno2bd/13/

(Note: the user content is long, so it height usually will exceed the profile image's height)

Update 2:
Thanks to @Gezzasa, his solution is working. ^_^

Guy, this is the working example of pure CSS popover! Amazing!

https://jsfiddle.net/byanjiong/nohno2bd/15/

Thanks, guy...

答:
https://jsfiddle.net/dqwtvf1g/3/

hover set on the parent and set the child to display: block;

You'll need to add the absolute position etc but this is how I've done it before.

```<code>.figure {background-color: #fff; width: 100px; height: 100px;}
.css-popover {display: none; width: 50px; height: 50px; background-color: #fff;}
.parent:hover .css-popover{display: block;}
</code>```

UPDATE: Made the parent display: inline-block but you can always just add a width.

UPDATE2: I've added some css animation for you as well.

UPDATE3: Edited your fiddle https://jsfiddle.net/byanjiong/nohno2bd/15/

Body:
I have a sidebar with a user profile picture (pink color). When the viewer hover on the image, a div (blue color) appears and it contains user details. Basically, I want an absolute positioned div appear next to its sibling.

It is functionally a popover, but I want to do it with pure CSS, is it possible?

I am using boostrap 4, it will be nice if the suggestion can co-exists with Bootstrap CSS. It will be awesome if the div can have an arrow associate with it.

My code is:

    //css-popover

User detail: ... bla bla bla ...

I tried to search in Stackoverflow, most of the question is related to float div and makes it beside, but I want something absolute positioned, and display on top of the body.

Update:

Most of the suggestions provided fulfill part of the requests. The suggested .css-popover width and height are bounded by the parents, but I wish the popover dimension be independent from the parent, i.e. just "popup" and it doesn't "change" the layout beneath.

And when the popup appear, it doesn't change the parent height too. I wish the sidebar "icon" (light pink icons) stay in place whenever a popup appear.

If it is not possible with CSS, then I just go for JS solution...

You can try your luck here. https://jsfiddle.net/byanjiong/nohno2bd/13/

(Note: the user content is long, so it height usually will exceed the profile image's height)

Update 2:
Thanks to @Gezzasa, his solution is working. ^_^

Guy, this is the working example of pure CSS popover! Amazing!

https://jsfiddle.net/byanjiong/nohno2bd/15/

Thanks, guy...

Body:
https://jsfiddle.net/dqwtvf1g/3/

hover set on the parent and set the child to display: block;

You'll need to add the absolute position etc but this is how I've done it before.

.figure {background-color: #fff; width: 100px; height: 100px;}
.css-popover {display: none; width: 50px; height: 50px; background-color: #fff;}
.parent:hover .css-popover{display: block;}

UPDATE: Made the parent display: inline-block but you can always just add a width.

UPDATE2: I've added some css animation for you as well.

UPDATE3: Edited your fiddle https://jsfiddle.net/byanjiong/nohno2bd/15/


问:
Exclude Java Source using Spring Boot Maven Plugin at Build time
I have a requirement to exclude certain Java source files from being compiled as part of the final build when running the Maven build.

I am using Spring Boot Maven plugin in my Spring Boot based project.

I am looking for a way to exclude Java source files from being compiled and corresponding Junit test classes also need to be excluded from the final build at build time.

Is there a way to achieve the same using the Spring Boot Maven Plugin?

答:
I achieved this by configuring maven-compiler-plugin:

pom.xml

```<code>  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>com/example/compileexclude/ExcludedJavaClass.java</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
  ...
</code>```

For reference you can see all available config options here.

Body:
I achieved this by configuring maven-compiler-plugin:

pom.xml

  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>com/example/compileexclude/ExcludedJavaClass.java</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
  ...

For reference you can see all available config options here.


问:
SQL INSERT INTO VALUE statement using a SELECT statement with a variable
I have 2 tables:

Tbl_Task - Has all the tasks for a process (TaskNum is unique. TaskName is what i'm writing to Tbl_Proc)

Tbl_Proc - Will hold the status of each task for a customer

When a new customer is created, I'm using the forms on close event to write each task from Tbl_Task into Tbl_Proc. I'm using the customer name from the form to complete the record in the Tbl_Proc.

My thought is to use an integer to increment the TaskNum and assign that task numbers TaskName to the Tbl_Proc[ProcTaskName].  Then loop through all task numbers. As you can see, I'm stuck on the use of my integer variable.

Here is what I have. I can successfully write the Company name but I can't get the ProcTaskName:

```<code>Private Sub Form_Close()
    On Error GoTo Err_Form_Close

    Dim strCompany As String
    Dim sqls As String
    Dim x As Integer

    strCompany = Me![CoName]
    'MsgBox strCompany
    x = 1

    sqls = "INSERT INTO Tbl_Proc(ProcCo, ProcTaskName)" & _
                    "VALUES ('" & strCompany & "', SELECT TaskName FROM Tbl_Task WHERE TaskNum=""" & x & """)"
    DoCmd.RunSQL sqls
'This works - "VALUES ('" & strCompany & "', 'cat')"

Exit_Form_Close:
    Exit Sub

Err_Form_Close:
    MsgBox Err.Description
    Resume Exit_Form_Close

End Sub
</code>```

答:
Thanks for the input man of much desired pants...  :)
I added another column to Tbl_Tasks [TaskDefault] and made all values 1.
The following code works within Microsoft Access 2013 VBA module.</p>

```<code>sqls = "INSERT INTO Tbl_Proc(ProcCo, ProcTaskName)" & _
        "SELECT '" & strCompany & "', TaskName " & _
        "FROM Tbl_Task WHERE TaskDefault=1"
DoCmd.RunSQL sqls
</code>```

Body:
I have 2 tables:

Tbl_Task - Has all the tasks for a process (TaskNum is unique. TaskName is what i'm writing to Tbl_Proc)

Tbl_Proc - Will hold the status of each task for a customer

When a new customer is created, I'm using the forms on close event to write each task from Tbl_Task into Tbl_Proc. I'm using the customer name from the form to complete the record in the Tbl_Proc.

My thought is to use an integer to increment the TaskNum and assign that task numbers TaskName to the Tbl_Proc[ProcTaskName].  Then loop through all task numbers. As you can see, I'm stuck on the use of my integer variable.

Here is what I have. I can successfully write the Company name but I can't get the ProcTaskName:

Private Sub Form_Close()
    On Error GoTo Err_Form_Close

    Dim strCompany As String
    Dim sqls As String
    Dim x As Integer

    strCompany = Me![CoName]
    'MsgBox strCompany
    x = 1

    sqls = "INSERT INTO Tbl_Proc(ProcCo, ProcTaskName)" & _
                    "VALUES ('" & strCompany & "', SELECT TaskName FROM Tbl_Task WHERE TaskNum=""" & x & """)"
    DoCmd.RunSQL sqls
'This works - "VALUES ('" & strCompany & "', 'cat')"

Exit_Form_Close:
    Exit Sub

Err_Form_Close:
    MsgBox Err.Description
    Resume Exit_Form_Close

End Sub

Body:
Thanks for the input man of much desired pants...  :)
I added another column to Tbl_Tasks [TaskDefault] and made all values 1.
The following code works within Microsoft Access 2013 VBA module.

sqls = "INSERT INTO Tbl_Proc(ProcCo, ProcTaskName)" & _
        "SELECT '" & strCompany & "', TaskName " & _
        "FROM Tbl_Task WHERE TaskDefault=1"
DoCmd.RunSQL sqls


问:
Spring Boot with Logback + springProperty
I have configured my logback-spring.xml as per Spring Boot Documentation. Here is my logback-spring.xml file

```<code><configuration>

    <springProperty name="appName" source="spring.application.name" defaultValue="myLogFile" />

    <property name="log.date" value="%d{yyyy-MM-dd}" />
    <property name="log.path" value="/log" />
    <property name="log.file" value="${appName}" />
    <property name="log.live.path" value="${log.path}/${log.file}.log" />

    <appender name="myLogAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.live.path}</file>
        <append>true</append>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.path}/archive/${log.file}.${log.date}.log.gz</fileNamePattern>
            <maxHistory>1</maxHistory>
        </rollingPolicy>
    </appender>

    <logger name="com.log.logback" level="INFO" />
    <logger name="com.log.sample" level="INFO" />

    <root level="ERROR">
        <appender-ref ref="myLogAppender" />
    </root>
</configuration>
</code>```

application.properties

```<code>spring.application.name=mybootapp
</code>```

And while I start my spring boot application, I see 2 directories created under /log path which are myLogFile and bootstrap. From the logs, I could see bootstrap directory is created before logback could access the spring property. I have no clue why bootstrap directory is created. I didn't see this issue before using <springProperty> in logback xml. Is there any configuration that I am missing here? I couldn't find any relevant info online.

Logback logs for the reference.

```<code>15:54:02,085 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@610f7aa - URL [jar:file:/C:/projects/jars/logback-logging-17.2.2.INT.jar!/logback-spring.xml] is not of type file
15:54:02,132 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Will scan for changes in [jar:file:/C:/projects/jars/logback-logging-17.2.2.INT.jar!/logback-spring.xml]
15:54:02,132 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeTask scanning period to 5 minutes
15:54:02,132 |-WARN in Logger[org.springframework.core.env.PropertySourcesPropertyResolver] - No appenders present in context [default] for logger [org.springframework.core.env.PropertySourcesPropertyResolver].
15:54:02,274 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
15:54:02,274 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [myLogAppender]
15:54:02,305 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@867988177 - Will use gz compression
15:54:02,305 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@867988177 - Will use the pattern /log/archive/bootstrap.%d{yyyy-MM-dd}.log for the active file
15:54:02,305 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'yyyy-MM-dd' from file name pattern '/log/archive/bootstrap.%d{yyyy-MM-dd}.log.gz'.
15:54:02,305 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over at midnight.
15:54:02,305 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Tue Apr 18 15:45:05 EDT 2017
15:54:02,320 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[myLogAppender] - Active log file name: /log/bootstrap.log
15:54:02,320 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[myLogAppender] - File property is set to [/log/bootstrap.log]
15:54:02,336 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.log.logback] to INFO
15:54:02,336 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@48e1f6c7 - Propagating INFO level on Logger[com.log.logback] onto the JUL framework
15:54:02,336 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.log.sample] to INFO
15:54:02,336 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@48e1f6c7 - Propagating INFO level on Logger[com.log.sample] onto the JUL framework
15:54:02,336 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
15:54:02,336 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@48e1f6c7 - Propagating ERROR level on Logger[ROOT] onto the JUL framework
15:54:02,336 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [myLogAppender] to Logger[ROOT]
15:54:02,336 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
15:54:02,336 |-INFO in org.springframework.boot.logging.logback.SpringBootJoranConfigurator@26abb146 - Registering current configuration as safe fallback point
15:54:03,139 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@242aa8d9 - URL [jar:file:/C:/projects/jars/logback-logging-17.2.2.INT.jar!/logback-spring.xml] is not of type file
15:54:03,139 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Will scan for changes in [jar:file:/C:/projects/jars/logback-logging-17.2.2.INT.jar!/logback-spring.xml]
15:54:03,139 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeTask scanning period to 5 minutes
15:54:03,139 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
15:54:03,139 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [myLogAppender]
15:54:03,139 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@300604602 - Will use gz compression
15:54:03,139 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@300604602 - Will use the pattern /log/archive/mybootapp.%d{yyyy-MM-dd}.log for the active file
15:54:03,140 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'yyyy-MM-dd' from file name pattern '/log/archive/mybootapp.%d{yyyy-MM-dd}.log.gz'.
15:54:03,140 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over at midnight.
15:54:03,140 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Tue Apr 18 15:53:03 EDT 2017
15:54:03,140 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[myLogAppender] - Active log file name: /log/mybootapp.log
15:54:03,140 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[myLogAppender] - File property is set to [/log/mybootapp.log]
15:54:03,140 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.log.logback] to INFO
15:54:03,140 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1b065145 - Propagating INFO level on Logger[com.log.logback] onto the JUL framework
15:54:03,140 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.log.sample] to INFO
15:54:03,140 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1b065145 - Propagating INFO level on Logger[com.log.sample] onto the JUL framework
15:54:03,140 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
15:54:03,140 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1b065145 - Propagating ERROR level on Logger[ROOT] onto the JUL framework
15:54:03,140 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [myLogAppender] to Logger[ROOT]
15:54:03,140 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
15:54:03,140 |-INFO in org.springframework.boot.logging.logback.SpringBootJoranConfigurator@45cff11c - Registering current configuration as safe fallback point
</code>```

Can someone pls help.

答:
If you’re using a custom logback-spring.xml then you have to pass the spring.application.name in bootstrap instead of application property file. Otherwise your custom logback file won’t read the property properly.

you need to set up spring.application.name in bootstrap.yml

see: http://cloud.spring.io/spring-cloud-sleuth/spring-cloud-sleuth.html

Body:
I have configured my logback-spring.xml as per Spring Boot Documentation. Here is my logback-spring.xml file

<configuration>

    <springProperty name="appName" source="spring.application.name" defaultValue="myLogFile" />

    <property name="log.date" value="%d{yyyy-MM-dd}" />
    <property name="log.path" value="/log" />
    <property name="log.file" value="${appName}" />
    <property name="log.live.path" value="${log.path}/${log.file}.log" />

    <appender name="myLogAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.live.path}</file>
        <append>true</append>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.path}/archive/${log.file}.${log.date}.log.gz</fileNamePattern>
            <maxHistory>1</maxHistory>
        </rollingPolicy>
    </appender>

    <logger name="com.log.logback" level="INFO" />
    <logger name="com.log.sample" level="INFO" />

    <root level="ERROR">
        <appender-ref ref="myLogAppender" />
    </root>
</configuration>

application.properties

spring.application.name=mybootapp

And while I start my spring boot application, I see 2 directories created under /log path which are myLogFile and bootstrap. From the logs, I could see bootstrap directory is created before logback could access the spring property. I have no clue why bootstrap directory is created. I didn't see this issue before using <springProperty> in logback xml. Is there any configuration that I am missing here? I couldn't find any relevant info online.

Logback logs for the reference.

15:54:02,085 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@610f7aa - URL [jar:file:/C:/projects/jars/logback-logging-17.2.2.INT.jar!/logback-spring.xml] is not of type file
15:54:02,132 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Will scan for changes in [jar:file:/C:/projects/jars/logback-logging-17.2.2.INT.jar!/logback-spring.xml]
15:54:02,132 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeTask scanning period to 5 minutes
15:54:02,132 |-WARN in Logger[org.springframework.core.env.PropertySourcesPropertyResolver] - No appenders present in context [default] for logger [org.springframework.core.env.PropertySourcesPropertyResolver].
15:54:02,274 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
15:54:02,274 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [myLogAppender]
15:54:02,305 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@867988177 - Will use gz compression
15:54:02,305 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@867988177 - Will use the pattern /log/archive/bootstrap.%d{yyyy-MM-dd}.log for the active file
15:54:02,305 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'yyyy-MM-dd' from file name pattern '/log/archive/bootstrap.%d{yyyy-MM-dd}.log.gz'.
15:54:02,305 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over at midnight.
15:54:02,305 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Tue Apr 18 15:45:05 EDT 2017
15:54:02,320 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[myLogAppender] - Active log file name: /log/bootstrap.log
15:54:02,320 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[myLogAppender] - File property is set to [/log/bootstrap.log]
15:54:02,336 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.log.logback] to INFO
15:54:02,336 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@48e1f6c7 - Propagating INFO level on Logger[com.log.logback] onto the JUL framework
15:54:02,336 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.log.sample] to INFO
15:54:02,336 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@48e1f6c7 - Propagating INFO level on Logger[com.log.sample] onto the JUL framework
15:54:02,336 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
15:54:02,336 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@48e1f6c7 - Propagating ERROR level on Logger[ROOT] onto the JUL framework
15:54:02,336 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [myLogAppender] to Logger[ROOT]
15:54:02,336 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
15:54:02,336 |-INFO in org.springframework.boot.logging.logback.SpringBootJoranConfigurator@26abb146 - Registering current configuration as safe fallback point
15:54:03,139 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@242aa8d9 - URL [jar:file:/C:/projects/jars/logback-logging-17.2.2.INT.jar!/logback-spring.xml] is not of type file
15:54:03,139 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Will scan for changes in [jar:file:/C:/projects/jars/logback-logging-17.2.2.INT.jar!/logback-spring.xml]
15:54:03,139 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeTask scanning period to 5 minutes
15:54:03,139 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
15:54:03,139 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [myLogAppender]
15:54:03,139 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@300604602 - Will use gz compression
15:54:03,139 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@300604602 - Will use the pattern /log/archive/mybootapp.%d{yyyy-MM-dd}.log for the active file
15:54:03,140 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'yyyy-MM-dd' from file name pattern '/log/archive/mybootapp.%d{yyyy-MM-dd}.log.gz'.
15:54:03,140 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over at midnight.
15:54:03,140 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Tue Apr 18 15:53:03 EDT 2017
15:54:03,140 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[myLogAppender] - Active log file name: /log/mybootapp.log
15:54:03,140 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[myLogAppender] - File property is set to [/log/mybootapp.log]
15:54:03,140 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.log.logback] to INFO
15:54:03,140 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1b065145 - Propagating INFO level on Logger[com.log.logback] onto the JUL framework
15:54:03,140 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.log.sample] to INFO
15:54:03,140 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1b065145 - Propagating INFO level on Logger[com.log.sample] onto the JUL framework
15:54:03,140 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
15:54:03,140 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1b065145 - Propagating ERROR level on Logger[ROOT] onto the JUL framework
15:54:03,140 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [myLogAppender] to Logger[ROOT]
15:54:03,140 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
15:54:03,140 |-INFO in org.springframework.boot.logging.logback.SpringBootJoranConfigurator@45cff11c - Registering current configuration as safe fallback point

Can someone pls help.


问:
Detect airplane mode on iOS
How can I detect if the phone is in airplane mode? (It's not enough to detect there is no internet connection, I have to be able to distinguish these 2 cases)</p>

答:
For jailbroken tweaks/apps:</p>

```<code>@interface SBTelephonyManager : NSObject
+(id)sharedTelephonyManager;
-(BOOL)isInAirplaneMode;
@end

...

bool isInAirplaneMode = [[%c(SBTelephonyManager) sharedTelephonyManager] isInAirplaneMode];
</code>```

Title: Detect airplane mode on iOS

Body:
For jailbroken tweaks/apps:

@interface SBTelephonyManager : NSObject
+(id)sharedTelephonyManager;
-(BOOL)isInAirplaneMode;
@end

...

bool isInAirplaneMode = [[%c(SBTelephonyManager) sharedTelephonyManager] isInAirplaneMode];


答:
There is an extra curly bracket you should get rid off. The below link shows the console log:

https://codepen.io/anon/pen/rwOYqX?editors=1011

working jquery code:

```<code>    $(document).ready(function() {
    $(".help-link a").click(function(e) {
        console.log("help link a clicked ");
        e.preventDefault();
        if (!$(".modal-backdrop, .modal-container").hasClass("open")) {
            $(".modal-backdrop, .modal-container").addClass("open");
        } else {
            $(".modal-backdrop, .modal-container").removeClass("open");
        }
    });
 });
</code>```

Title: Not getting click event in jQuery

Body:
There is an extra curly bracket you should get rid off. The below link shows the console log:

https://codepen.io/anon/pen/rwOYqX?editors=1011

working jquery code:

    $(document).ready(function() {
    $(".help-link a").click(function(e) {
        console.log("help link a clicked ");
        e.preventDefault();
        if (!$(".modal-backdrop, .modal-container").hasClass("open")) {
            $(".modal-backdrop, .modal-container").addClass("open");
        } else {
            $(".modal-backdrop, .modal-container").removeClass("open");
        }
    });
 });


问:
Spring boot 1.5.2.RELEASE : Rolling File logging
I have the below config in application.yml

```<code>logging:
  path: logs/
  file: logs/service.log
  pattern:
      console: "%d %-5level %logger : %msg%n"
      file: "%d %-5level [%thread] %logger : %msg%n"
  level:
      com.demo.api: INFO
</code>```

below is my logback.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml" />
    <include resource="org/springframework/boot/logging/logback/console-appender.xml" />
    <root level="INFO">
        <appender-ref ref="CONSOLE" />
    </root>
    <logger name="com.demo" additivity="false" level="DEBUG">
        <appender-ref ref="CONSOLE"/>
    </logger>
</configuration>
</code>```

when I run the spring boot application its not logging to file but I see the below logging in console as below

```<code>2017-06-07 16:14:45.841  INFO 37084 --- [nio-8443-exec-8] c.d.api.Controller        : test msg 1
2017-06-07 16:14:45.854  INFO 37084 --- [nio-8443-exec-8] c.d.api.dao.Dao  : test msg 2
2017-06-07 16:14:49.188  INFO 37084 --- [nio-8443-exec-8] c.d.api.service.DigSigService   : test msg 3
2017-06-07 16:14:49.199  INFO 37084 --- [nio-8443-exec-8] c.d.api.service.DigSigService   : test msg 4
2017-06-07 16:14:49.200  INFO 37084 --- [nio-8443-exec-8] c.d.api.dao.Dao  : test msg 5
</code>```

I tried updating the logback.xml as below but still no lock with logging to file

```<code><?xml version="1.0" encoding="UTF-8"?>
<configuration>

<property name="DEV_HOME" value="c:/logs" />

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <layout class="ch.qos.logback.classic.PatternLayout">
        <Pattern>
            %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
        </Pattern>
    </layout>
</appender>

<appender name="FILE-AUDIT"
    class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${DEV_HOME}/debug.log</file>
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <Pattern>
            %d{yyyy-MM-dd HH:mm:ss} - %msg%n
        </Pattern>
    </encoder>

    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <!-- rollover daily -->
        <fileNamePattern>${DEV_HOME}/archived/debug.%d{yyyy-MM-dd}.%i.log
                    </fileNamePattern>
        <timeBasedFileNamingAndTriggeringPolicy
            class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <maxFileSize>10MB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>
    </rollingPolicy>

</appender>

<appender name="FILE-ERROR"
    class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${DEV_HOME}/error.log</file>
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <Pattern>
            %d{yyyy-MM-dd HH:mm:ss} - %msg%n
        </Pattern>
    </encoder>

    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <!-- rollover daily -->
        <fileNamePattern>${DEV_HOME}/archived/error.%d{yyyy-MM-dd}.%i.log
                    </fileNamePattern>
        <timeBasedFileNamingAndTriggeringPolicy
            class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <maxFileSize>10MB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>
    </rollingPolicy>

</appender>

<!-- Send logs to both console and file audit -->
<logger name="com.demo.api" level="debug"
    additivity="false">
    <appender-ref ref="FILE-AUDIT" />
    <appender-ref ref="STDOUT" />
</logger>

<root level="error">
    <appender-ref ref="FILE-ERROR" />
</root>

</configuration>
</code>```

can someone please help me with fixing the logging to rolling file?

答:
Where is your logback.xml located, directly in the resources folder? If so, this should work right away (just tested your config, it works). If not, you have to specify where it is located. E.g. if it is under ...resources/config, you have to add the following entry to the application.yml:

```<code>logging:
  config: classpath:config/logback.xml
</code>```

Body:
I have the below config in application.yml

logging:
  path: logs/
  file: logs/service.log
  pattern:
      console: "%d %-5level %logger : %msg%n"
      file: "%d %-5level [%thread] %logger : %msg%n"
  level:
      com.demo.api: INFO

below is my logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml" />
    <include resource="org/springframework/boot/logging/logback/console-appender.xml" />
    <root level="INFO">
        <appender-ref ref="CONSOLE" />
    </root>
    <logger name="com.demo" additivity="false" level="DEBUG">
        <appender-ref ref="CONSOLE"/>
    </logger>
</configuration>

when I run the spring boot application its not logging to file but I see the below logging in console as below

2017-06-07 16:14:45.841  INFO 37084 --- [nio-8443-exec-8] c.d.api.Controller        : test msg 1
2017-06-07 16:14:45.854  INFO 37084 --- [nio-8443-exec-8] c.d.api.dao.Dao  : test msg 2
2017-06-07 16:14:49.188  INFO 37084 --- [nio-8443-exec-8] c.d.api.service.DigSigService   : test msg 3
2017-06-07 16:14:49.199  INFO 37084 --- [nio-8443-exec-8] c.d.api.service.DigSigService   : test msg 4
2017-06-07 16:14:49.200  INFO 37084 --- [nio-8443-exec-8] c.d.api.dao.Dao  : test msg 5

I tried updating the logback.xml as below but still no lock with logging to file

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

<property name="DEV_HOME" value="c:/logs" />

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <layout class="ch.qos.logback.classic.PatternLayout">
        <Pattern>
            %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
        </Pattern>
    </layout>
</appender>

<appender name="FILE-AUDIT"
    class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${DEV_HOME}/debug.log</file>
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <Pattern>
            %d{yyyy-MM-dd HH:mm:ss} - %msg%n
        </Pattern>
    </encoder>

    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

        <fileNamePattern>${DEV_HOME}/archived/debug.%d{yyyy-MM-dd}.%i.log
                    </fileNamePattern>
        <timeBasedFileNamingAndTriggeringPolicy
            class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <maxFileSize>10MB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>
    </rollingPolicy>

</appender>

<appender name="FILE-ERROR"
    class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${DEV_HOME}/error.log</file>
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <Pattern>
            %d{yyyy-MM-dd HH:mm:ss} - %msg%n
        </Pattern>
    </encoder>

    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

        <fileNamePattern>${DEV_HOME}/archived/error.%d{yyyy-MM-dd}.%i.log
                    </fileNamePattern>
        <timeBasedFileNamingAndTriggeringPolicy
            class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <maxFileSize>10MB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>
    </rollingPolicy>

</appender>

<logger name="com.demo.api" level="debug"
    additivity="false">
    <appender-ref ref="FILE-AUDIT" />
    <appender-ref ref="STDOUT" />
</logger>

<root level="error">
    <appender-ref ref="FILE-ERROR" />
</root>

</configuration>

can someone please help me with fixing the logging to rolling file?

Body:
Where is your logback.xml located, directly in the resources folder? If so, this should work right away (just tested your config, it works). If not, you have to specify where it is located. E.g. if it is under ...resources/config, you have to add the following entry to the application.yml:

logging:
  config: classpath:config/logback.xml