问:
Calling a class based on the selected item in a listview in javafx
I have a ListView and every time the selection is changed, I want to call a class with that name. For example, if the item is called "Text String" then the class TextString should be called. The code that I currently have is giving me an error saying The method insert(ArrayList<Element>) is undefined for the type Object ... Eclipse gives me a suggestion to cast the object as Element, but that doesn't do anything.  The Element class is a superclass and TextString would implement that class.

Here is the code I have so far:

```<code>   elementList.itemsProperty().bind(listProperty);
        listProperty.set(FXCollections.observableArrayList(elementListItems));
        elementList.setOnMouseClicked(new EventHandler<MouseEvent>() {

            public String selectedElement = "Text String";
            @Override
            public void handle(MouseEvent event) {
                selectedElement  = (String)elementList.getSelectionModel().getSelectedItem();
                selectedElement = selectedElement.replace(" ", "");
                Class<?> clazz;
                try {
                    clazz = Class.forName("elements."+selectedElement);
                    Constructor<?> ctor = clazz.getConstructor();
                    Object object = ctor.newInstance();
                    Method meth = clazz.getClass().getMethod("insert", new Class<?>[] { Canvas.class, ArrayList.class, GraphicsContext.class });
                    meth.invoke(object, canvas, objects, gc);
                } catch (ClassNotFoundException e) {
                    e.printStackTrace();
                } catch (NoSuchMethodException e) {
                    e.printStackTrace();
                } catch (SecurityException e) {
                    e.printStackTrace();
                } catch (InstantiationException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                } catch (InvocationTargetException e) {
                    e.printStackTrace();
                }
            }
        });
</code>```

Element.java

```<code>   public abstract class Element {
    public String name;
    public String description;
    public Canvas canvas;
    public ArrayList<Element> objects;
    public GraphicsContext gc;

    void remove(){

    }
    void toggle(){

    }
    void setBounds(int x, int y, int w, int h){

    }
    public abstract void insert(Canvas canvas, ArrayList<Element> objects, GraphicsContext gc);
}
</code>```

TextString.java

```<code>   public class TextString extends Element {
    private GraphicsContext gc;

    TextString() {
        super();
        this.name = "Text String";
        this.description = "A literal readable string of text.";
    }
    @Override
    public void insert(Canvas canvas, ArrayList<Element> objects, GraphicsContext gc) {
        this.gc = gc;
        this.canvas = canvas;
        this.objects = objects;
        System.out.println("Text string created.");
    }

}
</code>```

How can I cast the object to whatever object is being selected by the listview?

答:
What you need to do is simply have an interface MyElement
with method execute
Implementation of which will call whatever you need inside the "execute()"

basically I suggest command pattern, which is basis for all UI operations when doing BE

my 2 cents, implemntation example from my old-old project

```<code>    CommandFactory factory = CommandFactory.getInstance();
    Command command = factory.createCommand(relativeURL);
    if(command != null){
        command.execute( /* Object */ input);
    }
}
</code>```

into factory

```<code>/**
 * Factory for commands
 *
 * @author andre
 */
public class CommandFactory {
// singleton instance
protected static CommandFactory instance = new CommandFactory();

//cache of objects
Map<String, Command> cache = new HashMap<>();

// protected constructor prevents creating object outside
protected CommandFactory(){
}

// return signleton instance of factory
public static CommandFactory getInstance(){
    return instance;
}

/**
 * create and return appropriate command
 *
 * @return found command
 * @throws exception if something bad happened
 */
public Command createCommand(String classname){
    try {
        Command com = cache.get(URL);
        if(com == null){
            Command temp = (Command) Class.forName(classname).newInstance();
            if(temp != null){
                cache.put(URL, temp);
                com = cache.get(URL);
            }
        }
        return com;
    } catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
        Logger.getLogger(getClass().getName()).error(ex);
        return new Error404();
    }
}

}
</code>```

into interface

```<code>public interface Command{

void execute(Object input);
}
</code>```

and implementation example

```<code>public class EditUserInfo implements Command {

@Override
public void execute(Object object) {
     callWhatever((String) object);
    }

private void callWhatever(String textFromField){
// inner logic example
}

}
</code>```

Body:
I have a ListView and every time the selection is changed, I want to call a class with that name. For example, if the item is called "Text String" then the class TextString should be called. The code that I currently have is giving me an error saying The method insert(ArrayList<Element>) is undefined for the type Object ... Eclipse gives me a suggestion to cast the object as Element, but that doesn't do anything.  The Element class is a superclass and TextString would implement that class.

Here is the code I have so far:

   elementList.itemsProperty().bind(listProperty);
        listProperty.set(FXCollections.observableArrayList(elementListItems));
        elementList.setOnMouseClicked(new EventHandler<MouseEvent>() {

            public String selectedElement = "Text String";
            @Override
            public void handle(MouseEvent event) {
                selectedElement  = (String)elementList.getSelectionModel().getSelectedItem();
                selectedElement = selectedElement.replace(" ", "");
                Class<?> clazz;
                try {
                    clazz = Class.forName("elements."+selectedElement);
                    Constructor<?> ctor = clazz.getConstructor();
                    Object object = ctor.newInstance();
                    Method meth = clazz.getClass().getMethod("insert", new Class<?>[] { Canvas.class, ArrayList.class, GraphicsContext.class });
                    meth.invoke(object, canvas, objects, gc);
                } catch (ClassNotFoundException e) {
                    e.printStackTrace();
                } catch (NoSuchMethodException e) {
                    e.printStackTrace();
                } catch (SecurityException e) {
                    e.printStackTrace();
                } catch (InstantiationException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                } catch (InvocationTargetException e) {
                    e.printStackTrace();
                }
            }
        });

Element.java

   public abstract class Element {
    public String name;
    public String description;
    public Canvas canvas;
    public ArrayList<Element> objects;
    public GraphicsContext gc;

    void remove(){

    }
    void toggle(){

    }
    void setBounds(int x, int y, int w, int h){

    }
    public abstract void insert(Canvas canvas, ArrayList<Element> objects, GraphicsContext gc);
}

TextString.java

   public class TextString extends Element {
    private GraphicsContext gc;

    TextString() {
        super();
        this.name = "Text String";
        this.description = "A literal readable string of text.";
    }
    @Override
    public void insert(Canvas canvas, ArrayList<Element> objects, GraphicsContext gc) {
        this.gc = gc;
        this.canvas = canvas;
        this.objects = objects;
        System.out.println("Text string created.");
    }

}

How can I cast the object to whatever object is being selected by the listview?

Body:
What you need to do is simply have an interface MyElement
with method execute
Implementation of which will call whatever you need inside the "execute()"

basically I suggest command pattern, which is basis for all UI operations when doing BE

my 2 cents, implemntation example from my old-old project

    CommandFactory factory = CommandFactory.getInstance();
    Command command = factory.createCommand(relativeURL);
    if(command != null){
        command.execute( /* Object */ input);
    }
}

into factory

/**
 * Factory for commands
 *
 * @author andre
 */
public class CommandFactory {
// singleton instance
protected static CommandFactory instance = new CommandFactory();

//cache of objects
Map<String, Command> cache = new HashMap<>();

// protected constructor prevents creating object outside
protected CommandFactory(){
}

// return signleton instance of factory
public static CommandFactory getInstance(){
    return instance;
}

/**
 * create and return appropriate command
 *
 * @return found command
 * @throws exception if something bad happened
 */
public Command createCommand(String classname){
    try {
        Command com = cache.get(URL);
        if(com == null){
            Command temp = (Command) Class.forName(classname).newInstance();
            if(temp != null){
                cache.put(URL, temp);
                com = cache.get(URL);
            }
        }
        return com;
    } catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
        Logger.getLogger(getClass().getName()).error(ex);
        return new Error404();
    }
}

}

into interface

public interface Command{

void execute(Object input);
}

and implementation example

public class EditUserInfo implements Command {

@Override
public void execute(Object object) {
     callWhatever((String) object);
    }

private void callWhatever(String textFromField){
// inner logic example
}

}


来源: stackexchange

问:
Why un-moduled JAR can access non exposes packaged of a moduled JAR?
I'm playing around with Java 9 in intelliJ:
I've created 4 modules (all modules depended on module1):

module1: exports packages pkg1 and exports pkg2 to module 2.

module2: requires module1 and able to access both packages

module3: requires module1 and able to access only pkg1

module4: does not have the module-info.class, able to access both packages of module1

I thought that automatic modules should require all exposed packaged but not the ones which are not exposed.

I don't understand what is the point of encapsulation, if it works only on explicitly moduled JARs.

What am I missing?

答:
In your example module4 will not be able to access pkg2. Automatic modules read all other modules (because they can not express dependencies), but the rules to access types are not changed, so only public types in exported packages are accessible.

Some background based on your quote:

I thought that automatic modules should require all exposed packaged but not the ones which are not exposed.

Explicit modules (i.e. not automatic modules) require other modules. At run time those requires directives are turned into readability edges. But they are not the only source for those edges: For automatic modules an edge is added to each module that was resolved (i.e. made it into the readability graph).

So when you say "automatic modules should require all exposed package[s]" there are a couple of mistakes, maybe lost in translation, but I still want to clarify. The sentence should instead say "automatic modules read all (resolved) modules".

At this stage nobody is talking about accessibility and packages yet. That's the next step and here automatic modules are not special, so they can not access internal APIs.

ContentLicense: CC BY-SA 3.0


问:
Manage.py sqlall doesn't create tables for models in my app
I want to create a table for my models in my app, apparently the "python manage.py sqlall myapp" doesn't work

I tried using the "python manage.py sqlmigrate myapp", i still get errors

what is the proper command to use?

i am using django 1.11.7
thanks

答:
The sqlmigrate command just prints out the SQL for the migration, it does not run it. You should run migrate to make the changes.

See the Migrations docs for more information about the migration commands.

The sqlall command was removed in Django 1.9 at the same time as syncdb was removed.


问:
Loops with return statements in a recursion
I have written a recursive function. Here's the pseudocode for that :

```<code>    public recFunction(Node node) {
        for(int i=0; i<node.childCount(); i++){
            Node child = node.child(i);
            if(child.satisfies condition)
                return true;
            else
                return recFunction (child)
        }
        return false
    }
</code>```

Now, the node has a structure like:

```<code>               a
              /  \
             b    c
            / \  / \
           d  e  f  g
</code>```

here, the condition is true only in case of "f". But when the function moves to d and e and they return false, the function doesn't even bother to move to "c". What is the reason behind this. I have always been a little foggy about recursive functions especially when they include loops with return statements. Could someone explain what happens in a case such as this?

答:
Your for loop is written as if it is supposed to iterate through all the node's children, but it always returns on the first iteration.

```<code>if (child.satisfies condition)
    return true;
else
    return recFunction (child);
</code>```

If you want to look through all the children until you get a match, you might try this:

```<code>if (child.satisfies condition)
    return true;
else if (recFunction(child))
    return true;
</code>```

or more simply

```<code>if (child.satisfies condition || recFunction(child))
    return true;
</code>```

Then it will be possible for your for loop to continue and look at other children until it finds a positive result.

Body:
I have written a recursive function. Here's the pseudocode for that :

    public recFunction(Node node) {
        for(int i=0; i<node.childCount(); i++){
            Node child = node.child(i);
            if(child.satisfies condition)
                return true;
            else
                return recFunction (child)
        }
        return false
    }

Now, the node has a structure like:

               a
              /  \
             b    c
            / \  / \
           d  e  f  g

here, the condition is true only in case of "f". But when the function moves to d and e and they return false, the function doesn't even bother to move to "c". What is the reason behind this. I have always been a little foggy about recursive functions especially when they include loops with return statements. Could someone explain what happens in a case such as this?

Body:
Your for loop is written as if it is supposed to iterate through all the node's children, but it always returns on the first iteration.

if (child.satisfies condition)
    return true;
else
    return recFunction (child);

If you want to look through all the children until you get a match, you might try this:

if (child.satisfies condition)
    return true;
else if (recFunction(child))
    return true;

or more simply

if (child.satisfies condition || recFunction(child))
    return true;

Then it will be possible for your for loop to continue and look at other children until it finds a positive result.


问:
NSTimeInterval returning random values
I'm writing a caching system for an app I'm working on. It stores a key (NSString) and a last requested timestamp (NSDate) in Core Data, and I'm having trouble seeing whether it's expired or not (it's set to expire after 300 seconds).

```<code>NSTimeInterval interval = [lastRequested timeIntervalSinceNow];
NSLog(@"Interval: %d", interval);
// reload every 5 minutes
if (interval > 300) {
  NSLog(@"Last Requested: %d (older than 5 minutes)", interval);
  return YES;
} else {
  NSLog(@"Last Requested: %d (within 5 minutes)", interval);
  return NO;
}
</code>```

I've checked that lastRequested doesn't change - that's fine. But the interval produces a seemingly random number:

```<code>2011-01-19 11:31:03.770 App[2998:207] Interval: -830996480
2011-01-19 11:31:03.770 App[2998:207] Last Requested: -830996480 (within 5 minutes)
2011-01-19 11:30:57.634 App[2994:207] Interval: 1494482944
2011-01-19 11:30:57.634 App[2994:207] Last Requested: 1494482944 (within 5 minutes)
2011-01-19 11:30:51.219 App[2991:207] Interval: -1951399936
2011-01-19 11:30:51.219 App[2991:207] Last Requested: -1951399936 (within 5 minutes)
</code>```

And bizarrely, as you can see when checking whether the value is greater than 300, in the middle run of the app - it's still thinking it's less than 300 even though it's 1494482944.

Any ideas? Thanks.

答: When you log your interval, you log it as a integer (%d) but a time interval is a double (%f). Replace those instances in your NSLog(...)s and you should see the correct values.</p>

ContentLicense: CC BY-SA 2.5

Title: NSTimeInterval returning random values

Body:
I'm writing a caching system for an app I'm working on. It stores a key (NSString) and a last requested timestamp (NSDate) in Core Data, and I'm having trouble seeing whether it's expired or not (it's set to expire after 300 seconds).

NSTimeInterval interval = [lastRequested timeIntervalSinceNow];
NSLog(@"Interval: %d", interval);
// reload every 5 minutes
if (interval > 300) {
  NSLog(@"Last Requested: %d (older than 5 minutes)", interval);
  return YES;
} else {
  NSLog(@"Last Requested: %d (within 5 minutes)", interval);
  return NO;
}

I've checked that lastRequested doesn't change - that's fine. But the interval produces a seemingly random number:

2011-01-19 11:31:03.770 App[2998:207] Interval: -830996480
2011-01-19 11:31:03.770 App[2998:207] Last Requested: -830996480 (within 5 minutes)
2011-01-19 11:30:57.634 App[2994:207] Interval: 1494482944
2011-01-19 11:30:57.634 App[2994:207] Last Requested: 1494482944 (within 5 minutes)
2011-01-19 11:30:51.219 App[2991:207] Interval: -1951399936
2011-01-19 11:30:51.219 App[2991:207] Last Requested: -1951399936 (within 5 minutes)

And bizarrely, as you can see when checking whether the value is greater than 300, in the middle run of the app - it's still thinking it's less than 300 even though it's 1494482944.

Any ideas? Thanks.


问:
what happened when using the same variable in two layer loops in python?
I test the following code:

```<code>for i in range(3):
    for i in range(3,5):
        print "inner i: %d"%(i)
    print "outer i: %d"%(i)
</code>```

and the output is:

```<code>inner i: 3
inner i: 4
outer i: 4
inner i: 3
inner i: 4
outer i: 4
inner i: 3
inner i: 4
outer i: 4
</code>```

I don't understand why in the outer loop the i is 4 but the outer loop still runs for 3 times. It seems that the  the variable i in the print "outer i: %d"%(i) line is the i in the inner loop , but when goes to the for i in range(3) it uses the i in the outer loop.

Anyone can explain this? It's a little confusing to me now.

答:
In the inner loop you are assigning a different variable to i. Since it is the same variableit always prints 4 (the last value i was assigned in the inner loop.
However, when you go to the next iteration of outer loop it will be set to the next value (i.e. 2 for the second outer loop).
You should print outer loop before the inner loop to see the effect more clearly:</p>

```<code>for i in range(3):
    print "outer i before:%d"%(i)
    for i in range(3,5):
        print "inner i: %d"%(i)
    print "outer i after: %d"%(i)
</code>```

Body:
I test the following code:

for i in range(3):
    for i in range(3,5):
        print "inner i: %d"%(i)
    print "outer i: %d"%(i)

and the output is:

inner i: 3
inner i: 4
outer i: 4
inner i: 3
inner i: 4
outer i: 4
inner i: 3
inner i: 4
outer i: 4

I don't understand why in the outer loop the i is 4 but the outer loop still runs for 3 times. It seems that the  the variable i in the print "outer i: %d"%(i) line is the i in the inner loop , but when goes to the for i in range(3) it uses the i in the outer loop.

Anyone can explain this? It's a little confusing to me now.

Body:
In the inner loop you are assigning a different variable to i. Since it is the same variableit always prints 4 (the last value i was assigned in the inner loop.
However, when you go to the next iteration of outer loop it will be set to the next value (i.e. 2 for the second outer loop).
You should print outer loop before the inner loop to see the effect more clearly:

for i in range(3):
    print "outer i before:%d"%(i)
    for i in range(3,5):
        print "inner i: %d"%(i)
    print "outer i after: %d"%(i)


问:
Passing returned variables into a different method
I'm trying to pass the mark variable I returned into a different method so that it can be checked to determine the grade. When I try to run the program however it tells me that it can't find the symbol "mark" that I'm passing into the determineGrade method. I'm wondering how I'm supposed to pass mark into determineGrade so that the program can run?</p>

```<code>import java.util.Scanner;

public class GradeClassifier {

    public static void main(String[] args) {
        title();
        getMark();
        determineGrade(mark);
        displayGrade(mark, grade);
    }

    public static void title() {
        System.out.println("Grade Classifier\n****************");
    }

    public static int getMark() {
        Scanner in = new Scanner(System.in);
        System.out.println("Enter exam mark :> ");
        int mark = in.nextInt();

        return mark;
    }

    public static String determineGrade(int mark) {
        String grade;

        if (100 >= mark >= 70)
            grade = "Grade A (Pass)";
        else if (69 >= mark >= 60)
            grade = "Grade B (Pass)";
        else if (59 >= mark >= 50)
            grade = "Grade C (Pass)";
        else if (49 >= mark >= 40)
            grade = "Grade D (Pass)";
        else if (39 >= mark >= 0)
            grade = "Grade F (Fail)";
        else
            grade = "You did not input a valid number.";

        return grade;
    }

    public static void displayGrade(int mark, String grade) {
        if (100 >= mark >= 0)
            System.out.print("Congratulations, you are awarded a " + grade + ".");
        else
            System.out.print(grade);
    }

}
</code>```

答: Declare your mark variable inside main or class scope. The problem here is you have declared mark inside getMark(). So it is not accessible outside this method.</p>

Body:
I'm trying to pass the mark variable I returned into a different method so that it can be checked to determine the grade. When I try to run the program however it tells me that it can't find the symbol "mark" that I'm passing into the determineGrade method. I'm wondering how I'm supposed to pass mark into determineGrade so that the program can run?

import java.util.Scanner;

public class GradeClassifier {

    public static void main(String[] args) {
        title();
        getMark();
        determineGrade(mark);
        displayGrade(mark, grade);
    }

    public static void title() {
        System.out.println("Grade Classifier\n****************");
    }

    public static int getMark() {
        Scanner in = new Scanner(System.in);
        System.out.println("Enter exam mark :> ");
        int mark = in.nextInt();

        return mark;
    }

    public static String determineGrade(int mark) {
        String grade;

        if (100 >= mark >= 70)
            grade = "Grade A (Pass)";
        else if (69 >= mark >= 60)
            grade = "Grade B (Pass)";
        else if (59 >= mark >= 50)
            grade = "Grade C (Pass)";
        else if (49 >= mark >= 40)
            grade = "Grade D (Pass)";
        else if (39 >= mark >= 0)
            grade = "Grade F (Fail)";
        else
            grade = "You did not input a valid number.";

        return grade;
    }

    public static void displayGrade(int mark, String grade) {
        if (100 >= mark >= 0)
            System.out.print("Congratulations, you are awarded a " + grade + ".");
        else
            System.out.print(grade);
    }

}


答:
There's only one i, not two.  When the inner loop is entered, it changes i, and keeps changing it until the inner loop exits.  The next iteration of the outer loop then sets i to the next value in its range, but you never see it because you immediately enter the inner loop once more, again changing i.

This is of course very bad practice.  You should never modify the variable in a for loop while that loop is active.

Title: what happened when using the same variable in two layer loops in python?


问:
Add a Static Framework to Pod.
I have a pod in which I want to include a static framework. When I add a framework .dependency in .podspec:

s.dependency 'Static_Framework', '~> 1.0.0'

I get an error:

- ERROR | [iOS] unknown: Encountered an unknown error (The 'App' target has transitive dependencies that include static binaries: (/private/var/folders/bc/T/CocoaPods-Lint-20171010-28205/Pods/Static_Framework/Frameworks/Static_Framework.framework)) during validation.

Is it possible to add a static framework to a pod? If yes, what is the proper way to do it?

Or could I add that framework to the project together with my pod to make my pod working?

```<code>pod 'Static_Framework', '~> 1.0.0'
pod 'My_Pod', '~> 0.1.0'
</code>```

Because now when I add my pod to the project without describing a Static_Framework in s.dependency I get a build error No such module 'Static Framework' in my pod files.

答:
In a .podspec file, above the line:

```<code>s.dependency 'Static_Framework', '~> 1.0.0'
</code>```

Add:

```<code>s.static_framework = true
</code>```

when using CocoaPods version 1.4.0 and above everything should work fine!

Title: Add a Static Framework to Pod.

Body:
I have a pod in which I want to include a static framework. When I add a framework .dependency in .podspec:

s.dependency 'Static_Framework', '~> 1.0.0'

I get an error:

- ERROR | [iOS] unknown: Encountered an unknown error (The 'App' target has transitive dependencies that include static binaries: (/private/var/folders/bc/T/CocoaPods-Lint-20171010-28205/Pods/Static_Framework/Frameworks/Static_Framework.framework)) during validation.

Is it possible to add a static framework to a pod? If yes, what is the proper way to do it?

Or could I add that framework to the project together with my pod to make my pod working?

pod 'Static_Framework', '~> 1.0.0'
pod 'My_Pod', '~> 0.1.0'

Because now when I add my pod to the project without describing a Static_Framework in s.dependency I get a build error No such module 'Static Framework' in my pod files.

Body:
In a .podspec file, above the line:

s.dependency 'Static_Framework', '~> 1.0.0'

Add:

s.static_framework = true

when using CocoaPods version 1.4.0 and above everything should work fine!


问:
How to test/run last iteration of loop using enumerate on a list of strings
I have program in which I loop over a list of subfolders (dir_list) which is obtained using os.walk. Now, I loop over the full list using enumerate, as follows:

```<code>for day_index, day_folder in enumerate(dir_list[:]):
</code>```

Now, I'd like to test the code within this loop on the last element (without running the whole loop, because the program is quite large). So I do the following:

```<code>for day_index, day_folder in enumerate(dir_list[-1]):
</code>```

However, now that dir_list is a single element enumerate behaves differently and starts to iterate through the single element, which happens to be a string, resulting in day_folder becoming the first element of the string. This is of course not what I want to happen. But I understand why it is happening.

How can I run this loop - for testing purposes - just on the last element of the list (my last subfolder). I don't want to change my code by removing the for loop, and I need to retain the counter (day_index).

答:
How about that:

```<code>for day_index, day_folder in enumerate(dir_list[-1:]):
</code>```

This is simple list slicing.

ContentLicense: CC BY-SA 4.0

Body:
I have program in which I loop over a list of subfolders (dir_list) which is obtained using os.walk. Now, I loop over the full list using enumerate, as follows:

for day_index, day_folder in enumerate(dir_list[:]):

Now, I'd like to test the code within this loop on the last element (without running the whole loop, because the program is quite large). So I do the following:

for day_index, day_folder in enumerate(dir_list[-1]):

However, now that dir_list is a single element enumerate behaves differently and starts to iterate through the single element, which happens to be a string, resulting in day_folder becoming the first element of the string. This is of course not what I want to happen. But I understand why it is happening.

How can I run this loop - for testing purposes - just on the last element of the list (my last subfolder). I don't want to change my code by removing the for loop, and I need to retain the counter (day_index).

Body:
How about that:

for day_index, day_folder in enumerate(dir_list[-1:]):

This is simple list slicing.


问:
@HTML Dropdownlist selected value
I'm new to Razor and I don't get why my selected value is not working.

var listItems = (List<Categories>)ViewBag.Categories;

Used in

```<code>@for (var i = 0; i < Model.TagActivities.Count; i++)
{
    <tr>
        @Html.HiddenFor(modelItem => Model.TagActivities[i].TAGActivityId, new { htmlAttributes = new { @class = "form-control" } })
        @Html.HiddenFor(modelItem => Model.TagActivities[i].CategoryId, new { htmlAttributes = new { @class = "form-control"
         <td>
            @Html.EditorFor(modelItem => Model.TagActivities[i].ActivityName, new { htmlAttributes = new { @class = "form-control" } })
        </td>
        <td>
            @Html.EditorFor(modelItem => Model.TagActivities[i].ActivityDescription, new { htmlAttributes = new { @class = "form-control" } })
        </td>
        <td>
            @Html.DropDownListFor(modelItem => Model.TagActivities[i].Category.CategoryName, new SelectList(listItems, "CategoryId", "CategoryName", Model.TagActivities[i].Category.CategoryName), new { @class = "form-control" })
        </td>
        <td>
            @Html.EditorFor(modelItem => Model.TagActivities[i].AlertMinutes, new { htmlAttributes = new { @class = "form-control" } })
        </td>
        <td>
            @Html.EditorFor(modelItem => Model.TagActivities[i].IsDefault)
        </td>
    </tr>
}
</code>```

Help please. Thank you.

答:
It does not work because the selected value you pass is not of the same type at the objects in listItems. Once possible solution it would be to change the value you pass to the constructor of SelectList for the selected object:

```<code>new SelectList(listItems, "CategoryId", "CategoryName", Model.TagActivities[i].Category)
</code>```

The listItems is a list of objects of type Categories. So as a selected object you should pass an object of this type.

Title: @HTML Dropdownlist selected value

Body:
I'm new to Razor and I don't get why my selected value is not working.

var listItems = (List<Categories>)ViewBag.Categories;

Used in

@for (var i = 0; i < Model.TagActivities.Count; i++)
{

        @Html.HiddenFor(modelItem => Model.TagActivities[i].TAGActivityId, new { htmlAttributes = new { @class = "form-control" } })
        @Html.HiddenFor(modelItem => Model.TagActivities[i].CategoryId, new { htmlAttributes = new { @class = "form-control"

            @Html.EditorFor(modelItem => Model.TagActivities[i].ActivityName, new { htmlAttributes = new { @class = "form-control" } })

            @Html.EditorFor(modelItem => Model.TagActivities[i].ActivityDescription, new { htmlAttributes = new { @class = "form-control" } })

            @Html.DropDownListFor(modelItem => Model.TagActivities[i].Category.CategoryName, new SelectList(listItems, "CategoryId", "CategoryName", Model.TagActivities[i].Category.CategoryName), new { @class = "form-control" })

            @Html.EditorFor(modelItem => Model.TagActivities[i].AlertMinutes, new { htmlAttributes = new { @class = "form-control" } })

            @Html.EditorFor(modelItem => Model.TagActivities[i].IsDefault)

}

Help please. Thank you.

Body:
It does not work because the selected value you pass is not of the same type at the objects in listItems. Once possible solution it would be to change the value you pass to the constructor of SelectList for the selected object:

new SelectList(listItems, "CategoryId", "CategoryName", Model.TagActivities[i].Category)

The listItems is a list of objects of type Categories. So as a selected object you should pass an object of this type.


答: Its the same i being used in both loops. When the outer loops gets a chance to print i, it will always have the last assigned value from the inner loop.</p>


问:
Error in getting Total Events in a PredictionIO App
I am new to PredictionIO using version v0.11-incubating (spark - 2.6.1 , Hbase - 1.2.6 , ElasticSearch - 5.2.1) . Started the Prediction Server with ./pio-start-all and checked pio status these are working fine. Then I created an app 'testApp' and imported some events into that PredictionIO app. Now in order to verify the count of imported events, I ran the following commands:

pio-shell --with-spark

import org.apache.predictionio.data.store.PEventStore

val eventsRDD = PEventStore.find(appName="testApp")(sc)

I got the error:

```<code>ERROR Storage$: Error initializing storage client for source ELASTICSEARCH
java.lang.ClassNotFoundException: elasticsearch.StorageClient
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at org.apache.predictionio.data.storage.Storage$.getClient(Storage.scala:228)
    at org.apache.predictionio.data.storage.Storage$.org$apache$predictionio$data$storage$Storage$$updateS2CM(Storage.scala:254)
    at org.apache.predictionio.data.storage.Storage$$anonfun$sourcesToClientMeta$1.apply(Storage.scala:215)
    at org.apache.predictionio.data.storage.Storage$$anonfun$sourcesToClientMeta$1.apply(Storage.scala:215)
    at scala.collection.mutable.MapLike$class.getOrElseUpdate(MapLike.scala:189)
    at scala.collection.mutable.AbstractMap.getOrElseUpdate(Map.scala:91)
    at org.apache.predictionio.data.storage.Storage$.sourcesToClientMeta(Storage.scala:215)
    at org.apache.predictionio.data.storage.Storage$.getDataObject(Storage.scala:284)
    at org.apache.predictionio.data.storage.Storage$.getDataObjectFromRepo(Storage.scala:269)
    at org.apache.predictionio.data.storage.Storage$.getMetaDataApps(Storage.scala:387)
    at org.apache.predictionio.data.store.Common$.appsDb$lzycompute(Common.scala:27)
    at org.apache.predictionio.data.store.Common$.appsDb(Common.scala:27)
    at org.apache.predictionio.data.store.Common$.appNameToId(Common.scala:32)
    at org.apache.predictionio.data.store.PEventStore$.find(PEventStore.scala:71)
    at $line19.$read$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:28)
    at $line19.$read$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:33)
    at $line19.$read$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:35)
    at $line19.$read$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:37)
    at $line19.$read$$iwC$$iwC$$iwC$$iwC.<init>(<console>:39)
    at $line19.$read$$iwC$$iwC$$iwC.<init>(<console>:41)
    at $line19.$read$$iwC$$iwC.<init>(<console>:43)
    at $line19.$read$$iwC.<init>(<console>:45)
    at $line19.$read.<init>(<console>:47)
    at $line19.$read$.<init>(<console>:51)
    at $line19.$read$.<clinit>(<console>)
    at $line19.$eval$.<init>(<console>:7)
    at $line19.$eval$.<clinit>(<console>)
    at $line19.$eval.$print(<console>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.repl.SparkIMain$ReadEvalPrint.call(SparkIMain.scala:1065)
    at org.apache.spark.repl.SparkIMain$Request.loadAndRun(SparkIMain.scala:1346)
    at org.apache.spark.repl.SparkIMain.loadAndRunReq$1(SparkIMain.scala:840)
    at org.apache.spark.repl.SparkIMain.interpret(SparkIMain.scala:871)
    at org.apache.spark.repl.SparkIMain.interpret(SparkIMain.scala:819)
    at org.apache.spark.repl.SparkILoop.reallyInterpret$1(SparkILoop.scala:857)
    at org.apache.spark.repl.SparkILoop.interpretStartingWith(SparkILoop.scala:902)
    at org.apache.spark.repl.SparkILoop.command(SparkILoop.scala:814)
    at org.apache.spark.repl.SparkILoop.processLine$1(SparkILoop.scala:657)
    at org.apache.spark.repl.SparkILoop.innerLoop$1(SparkILoop.scala:665)
    at org.apache.spark.repl.SparkILoop.org$apache$spark$repl$SparkILoop$$loop(SparkILoop.scala:670)
    at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply$mcZ$sp(SparkILoop.scala:997)
    at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply(SparkILoop.scala:945)
    at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply(SparkILoop.scala:945)
    at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
    at org.apache.spark.repl.SparkILoop.org$apache$spark$repl$SparkILoop$$process(SparkILoop.scala:945)
    at org.apache.spark.repl.SparkILoop.process(SparkILoop.scala:1059)
    at org.apache.spark.repl.Main$.main(Main.scala:31)
    at org.apache.spark.repl.Main.main(Main.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:731)
    at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181)
    at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206)
    at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121)
    at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
org.apache.predictionio.data.storage.StorageClientException: Data source ELASTICSEARCH was not properly initialized.
    at org.apache.predictionio.data.storage.Storage$$anonfun$10.apply(Storage.scala:285)
    at org.apache.predictionio.data.storage.Storage$$anonfun$10.apply(Storage.scala:285)
    at scala.Option.getOrElse(Option.scala:120)
    at org.apache.predictionio.data.storage.Storage$.getDataObject(Storage.scala:284)
    at org.apache.predictionio.data.storage.Storage$.getDataObjectFromRepo(Storage.scala:269)
    at org.apache.predictionio.data.storage.Storage$.getMetaDataApps(Storage.scala:387)
    at org.apache.predictionio.data.store.Common$.appsDb$lzycompute(Common.scala:27)
    at org.apache.predictionio.data.store.Common$.appsDb(Common.scala:27)
    at org.apache.predictionio.data.store.Common$.appNameToId(Common.scala:32)
    at org.apache.predictionio.data.store.PEventStore$.find(PEventStore.scala:71)
    at $iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:28)
    at $iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:33)
    at $iwC$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:35)
    at $iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:37)
    at $iwC$$iwC$$iwC$$iwC.<init>(<console>:39)
    at $iwC$$iwC$$iwC.<init>(<console>:41)
    at $iwC$$iwC.<init>(<console>:43)
    at $iwC.<init>(<console>:45)
    at <init>(<console>:47)
    at .<init>(<console>:51)
    at .<clinit>(<console>)
    at .<init>(<console>:7)
    at .<clinit>(<console>)
    at $print(<console>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.repl.SparkIMain$ReadEvalPrint.call(SparkIMain.scala:1065)
    at org.apache.spark.repl.SparkIMain$Request.loadAndRun(SparkIMain.scala:1346)
    at org.apache.spark.repl.SparkIMain.loadAndRunReq$1(SparkIMain.scala:840)
    at org.apache.spark.repl.SparkIMain.interpret(SparkIMain.scala:871)
    at org.apache.spark.repl.SparkIMain.interpret(SparkIMain.scala:819)
    at org.apache.spark.repl.SparkILoop.reallyInterpret$1(SparkILoop.scala:857)
    at org.apache.spark.repl.SparkILoop.interpretStartingWith(SparkILoop.scala:902)
    at org.apache.spark.repl.SparkILoop.command(SparkILoop.scala:814)
    at org.apache.spark.repl.SparkILoop.processLine$1(SparkILoop.scala:657)
    at org.apache.spark.repl.SparkILoop.innerLoop$1(SparkILoop.scala:665)
    at org.apache.spark.repl.SparkILoop.org$apache$spark$repl$SparkILoop$$loop(SparkILoop.scala:670)
    at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply$mcZ$sp(SparkILoop.scala:997)
    at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply(SparkILoop.scala:945)
    at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply(SparkILoop.scala:945)
    at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
    at org.apache.spark.repl.SparkILoop.org$apache$spark$repl$SparkILoop$$process(SparkILoop.scala:945)
    at org.apache.spark.repl.SparkILoop.process(SparkILoop.scala:1059)
    at org.apache.spark.repl.Main$.main(Main.scala:31)
    at org.apache.spark.repl.Main.main(Main.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:731)
    at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181)
    at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206)
    at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121)
    at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
</code>```

I have verified through pio status and ElasticSearch health commands that the elastic search server is running. Can someone please tell me how to resolve this issue?

答: Resolved this issue by upgrading predictionIO version from 0.11.0 -> 0.12.0</p>

Body:
I am new to PredictionIO using version v0.11-incubating (spark - 2.6.1 , Hbase - 1.2.6 , ElasticSearch - 5.2.1) . Started the Prediction Server with ./pio-start-all and checked pio status these are working fine. Then I created an app 'testApp' and imported some events into that PredictionIO app. Now in order to verify the count of imported events, I ran the following commands:

pio-shell --with-spark

import org.apache.predictionio.data.store.PEventStore

val eventsRDD = PEventStore.find(appName="testApp")(sc)

I got the error:

ERROR Storage$: Error initializing storage client for source ELASTICSEARCH
java.lang.ClassNotFoundException: elasticsearch.StorageClient
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at org.apache.predictionio.data.storage.Storage$.getClient(Storage.scala:228)
    at org.apache.predictionio.data.storage.Storage$.org$apache$predictionio$data$storage$Storage$$updateS2CM(Storage.scala:254)
    at org.apache.predictionio.data.storage.Storage$$anonfun$sourcesToClientMeta$1.apply(Storage.scala:215)
    at org.apache.predictionio.data.storage.Storage$$anonfun$sourcesToClientMeta$1.apply(Storage.scala:215)
    at scala.collection.mutable.MapLike$class.getOrElseUpdate(MapLike.scala:189)
    at scala.collection.mutable.AbstractMap.getOrElseUpdate(Map.scala:91)
    at org.apache.predictionio.data.storage.Storage$.sourcesToClientMeta(Storage.scala:215)
    at org.apache.predictionio.data.storage.Storage$.getDataObject(Storage.scala:284)
    at org.apache.predictionio.data.storage.Storage$.getDataObjectFromRepo(Storage.scala:269)
    at org.apache.predictionio.data.storage.Storage$.getMetaDataApps(Storage.scala:387)
    at org.apache.predictionio.data.store.Common$.appsDb$lzycompute(Common.scala:27)
    at org.apache.predictionio.data.store.Common$.appsDb(Common.scala:27)
    at org.apache.predictionio.data.store.Common$.appNameToId(Common.scala:32)
    at org.apache.predictionio.data.store.PEventStore$.find(PEventStore.scala:71)
    at $line19.$read$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:28)
    at $line19.$read$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:33)
    at $line19.$read$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:35)
    at $line19.$read$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:37)
    at $line19.$read$$iwC$$iwC$$iwC$$iwC.<init>(<console>:39)
    at $line19.$read$$iwC$$iwC$$iwC.<init>(<console>:41)
    at $line19.$read$$iwC$$iwC.<init>(<console>:43)
    at $line19.$read$$iwC.<init>(<console>:45)
    at $line19.$read.<init>(<console>:47)
    at $line19.$read$.<init>(<console>:51)
    at $line19.$read$.<clinit>(<console>)
    at $line19.$eval$.<init>(<console>:7)
    at $line19.$eval$.<clinit>(<console>)
    at $line19.$eval.$print(<console>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.repl.SparkIMain$ReadEvalPrint.call(SparkIMain.scala:1065)
    at org.apache.spark.repl.SparkIMain$Request.loadAndRun(SparkIMain.scala:1346)
    at org.apache.spark.repl.SparkIMain.loadAndRunReq$1(SparkIMain.scala:840)
    at org.apache.spark.repl.SparkIMain.interpret(SparkIMain.scala:871)
    at org.apache.spark.repl.SparkIMain.interpret(SparkIMain.scala:819)
    at org.apache.spark.repl.SparkILoop.reallyInterpret$1(SparkILoop.scala:857)
    at org.apache.spark.repl.SparkILoop.interpretStartingWith(SparkILoop.scala:902)
    at org.apache.spark.repl.SparkILoop.command(SparkILoop.scala:814)
    at org.apache.spark.repl.SparkILoop.processLine$1(SparkILoop.scala:657)
    at org.apache.spark.repl.SparkILoop.innerLoop$1(SparkILoop.scala:665)
    at org.apache.spark.repl.SparkILoop.org$apache$spark$repl$SparkILoop$$loop(SparkILoop.scala:670)
    at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply$mcZ$sp(SparkILoop.scala:997)
    at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply(SparkILoop.scala:945)
    at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply(SparkILoop.scala:945)
    at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
    at org.apache.spark.repl.SparkILoop.org$apache$spark$repl$SparkILoop$$process(SparkILoop.scala:945)
    at org.apache.spark.repl.SparkILoop.process(SparkILoop.scala:1059)
    at org.apache.spark.repl.Main$.main(Main.scala:31)
    at org.apache.spark.repl.Main.main(Main.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:731)
    at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181)
    at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206)
    at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121)
    at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
org.apache.predictionio.data.storage.StorageClientException: Data source ELASTICSEARCH was not properly initialized.
    at org.apache.predictionio.data.storage.Storage$$anonfun$10.apply(Storage.scala:285)
    at org.apache.predictionio.data.storage.Storage$$anonfun$10.apply(Storage.scala:285)
    at scala.Option.getOrElse(Option.scala:120)
    at org.apache.predictionio.data.storage.Storage$.getDataObject(Storage.scala:284)
    at org.apache.predictionio.data.storage.Storage$.getDataObjectFromRepo(Storage.scala:269)
    at org.apache.predictionio.data.storage.Storage$.getMetaDataApps(Storage.scala:387)
    at org.apache.predictionio.data.store.Common$.appsDb$lzycompute(Common.scala:27)
    at org.apache.predictionio.data.store.Common$.appsDb(Common.scala:27)
    at org.apache.predictionio.data.store.Common$.appNameToId(Common.scala:32)
    at org.apache.predictionio.data.store.PEventStore$.find(PEventStore.scala:71)
    at $iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:28)
    at $iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:33)
    at $iwC$$iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:35)
    at $iwC$$iwC$$iwC$$iwC$$iwC.<init>(<console>:37)
    at $iwC$$iwC$$iwC$$iwC.<init>(<console>:39)
    at $iwC$$iwC$$iwC.<init>(<console>:41)
    at $iwC$$iwC.<init>(<console>:43)
    at $iwC.<init>(<console>:45)
    at <init>(<console>:47)
    at .<init>(<console>:51)
    at .<clinit>(<console>)
    at .<init>(<console>:7)
    at .<clinit>(<console>)
    at $print(<console>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.repl.SparkIMain$ReadEvalPrint.call(SparkIMain.scala:1065)
    at org.apache.spark.repl.SparkIMain$Request.loadAndRun(SparkIMain.scala:1346)
    at org.apache.spark.repl.SparkIMain.loadAndRunReq$1(SparkIMain.scala:840)
    at org.apache.spark.repl.SparkIMain.interpret(SparkIMain.scala:871)
    at org.apache.spark.repl.SparkIMain.interpret(SparkIMain.scala:819)
    at org.apache.spark.repl.SparkILoop.reallyInterpret$1(SparkILoop.scala:857)
    at org.apache.spark.repl.SparkILoop.interpretStartingWith(SparkILoop.scala:902)
    at org.apache.spark.repl.SparkILoop.command(SparkILoop.scala:814)
    at org.apache.spark.repl.SparkILoop.processLine$1(SparkILoop.scala:657)
    at org.apache.spark.repl.SparkILoop.innerLoop$1(SparkILoop.scala:665)
    at org.apache.spark.repl.SparkILoop.org$apache$spark$repl$SparkILoop$$loop(SparkILoop.scala:670)
    at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply$mcZ$sp(SparkILoop.scala:997)
    at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply(SparkILoop.scala:945)
    at org.apache.spark.repl.SparkILoop$$anonfun$org$apache$spark$repl$SparkILoop$$process$1.apply(SparkILoop.scala:945)
    at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
    at org.apache.spark.repl.SparkILoop.org$apache$spark$repl$SparkILoop$$process(SparkILoop.scala:945)
    at org.apache.spark.repl.SparkILoop.process(SparkILoop.scala:1059)
    at org.apache.spark.repl.Main$.main(Main.scala:31)
    at org.apache.spark.repl.Main.main(Main.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:731)
    at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181)
    at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206)
    at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121)
    at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)

I have verified through pio status and ElasticSearch health commands that the elastic search server is running. Can someone please tell me how to resolve this issue?


问:
How to float image right without footer popping to the top and background colour disappearing
i know this is very basic but can't seem to wrap my head around it. I am trying to float an image to the right of the text, each time i do that, the image actually floats to the right but then, the footer pops to the top and the white background colour disappears. I have spend surprisingly two days trying to resolve this embarrassing error but no result. Here is my html code:

```<code><!DOCTYPE>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> Learninghub </title>
    <link rel="stylesheet" href="css/style.css" />
    <link rel="stylesheet" href="css/slide2.css">
    <link rel="stylesheet" href="css/simple-slideshow-styles.css">
</head>
<body>
        <div class = "body">
           <div class = "header">
                                <div class = "wrapper">

                                             <div class = "left">
                                                <a href ="http://pac-center.com/#/ms-23/1">
                                                        <img src = "images/learninghub.png" width = "406" height = "75" alt" The learninghub and paccenter logo ">
                                                </a>
                                             </div>

                                          <div class = "right">

                                            <img src = "images/call.png" width = "15" height = "15" alt " call icon">
                                            <div class = "today">
                                                 <small>Call us today</small></br>
                                                 <strong>09-2921465</strong>
                                            </div>
                                          </div>
                                          <div class = "right_2">

                                                 <img src = "images/location.png" width = "10" height = "15" alt " location icon">

                                                  <div class = " right_1">
                                                    <a href = "https://www.google.com.ng/maps">
                                                        <small>Suite 1, Capital Hub Mall, Plot 272 Ahmadu Bello Way</small></br>
                                                        <strong> Along Wuse-Gwarinpa-Next Express Way, F.C.T Abuja.</strong></small>
                                                    </a>
                                                  </div>

                                          </div>

                                </div>

                 </div>

                 <nav>
                                            <label for="drop" class="toggle">Menu</label>
                                        <input type="checkbox" id="drop" />
                                            <ul class="menu">
                                                <li><a href="index.php">Home</a></li>

                                                <li>
                                                    <!-- First Tier Drop Down -->
                                                    <label for="drop-1" class="toggle">About Us +</label>
                                                    <a href="About us.html">About Us</a>
                                                    <input type="checkbox" id="drop-1"/>
                                                    <ul>
                                                        <li><a href="methodology.html">Methodology</a></li>

                                                    </ul>

                                                </li>
                                                <li><a href="service.html">Services</a></li>
                                                <li>

                                                <!-- First Tier Drop Down -->
                                                <label for="drop-2" class="toggle">List of Courses +</label>
                                                <a href="#">List of Courses</a>
                                                <input type="checkbox" id="drop-2"/>
                                                <ul>
                                                    <li><a href="administration.html">Administration</a></li>
                                                    <li><a href="agriculture.html">Agriculture</a></li>

                                                </ul>
                                                </li>
                                                <li>

                                                <!-- First Tier Drop Down -->
                                                <label for="drop-2" class="toggle">Ongoing Courses +</label>
                                                <a href="#">Ongoing Courses</a>
                                                <input type="checkbox" id="drop-2"/>
                                                <ul>

                                                    <li><a href="creative.html">Creative</a></li>
                                                     <li><a href="enterprise.html">Enterprise</a></li>
                                                    <li><a href="excel.html">Microsoft Excel</a></li>
                                                    <li><a href="Hardware.html">Hardware</a></li>
                                                     <li><a href="management.html">MIS</a></li>
                                                    <li><a href="microsoft_office.html">Microsoft Office</a></li>
                                                    <li><a href="networking.html">Networking</a></li>
                                                     <li><a href="webdesign.html">Web Design</a></li>
                                                    <li><a href="webdev.html">Web Development</a></li>

                                                </ul>
                                                </li>
                                                <li><a href="gallery.html">Gallery</a></li>
                                                <li><a href="events.html">Events</a></li>
                                                <li><a href="contact.php">Contact</a></li>

                                                <li><a href="https://www.facebook.com/TheLearningHubNG/"><img src="images/soc/facebook1.png" height="32" width="32"></a></li>
                                                <li><a href="https://twitter.com/LearningHubNG"><img src="images/soc/twitter1.png" height="32" width="32"></a></li>
                                                <li><a href="https://www.instagram.com/thelearninghub_ng/"><img src="images/soc/instagram1.png" height="32" width="34"></a></li>
                                            </ul>
                                        </nav>

                        <div  class ="about_wrap">

                              <div class = "aboutus">
                                <header><h1>ABOUT US</h1></header>
                                <content>
                                    <p>
                                    The Learning Hub was established with the objective of developing and facilitating learning processes designed
                                         to maximise capacity building and self-development. We have extensive experience and appreciable competence
                                         in rendering quality services to our clients. The business and work environment changes quickly.

                                        The Learning Hub is an operating name and also the training and capacity building outfit of PACCENTER LTD. The
                                        Learning hub has been specifically dedicated as the Training and Consultancy services of PAC CENTER LTD.
                                        PAC CENTER LTD is accredited by the Centre for Management Development (CMD) and is duly registered with the
                                        Computer Professionals Registration Council of Nigeria (CPN).</p>
                                    </content>

                              </div>

                              <div class = "aboutus">
                                <header><h1>OUR MISSION</h1></header>
                                <content>
                                    <p>
                                    To deliver skills and knowledge that signiﬁcantly increase our course participants' on-the-job productivity,
                                    thereby enhancing their contributions to the goals of their organisation.
                                    </p>
                                    </content>

                              </div>

                              <div class = "aboutus">
                                <header><h1>OUR VISION</h1></header>
                                <content>
                                    <p>
                                    To become the preferred partner to organisations and individuals by providing the most comprehensive
                                    professional and personal growth training.
                                    </p>
                                    </content>

                              </div>

                              <div class = "aboutus">
                                        <header><h1>OUR CORE VALUES</h1></header>
                                        <content>
                                            <p>
                                            Through these values we create success:
                                            </p>
                                            <ul>
                                                <li><span>L: Listen with empathy to problems</span></li>
                                                <li><span>E: Examine various opinions critically</span></li>
                                                <li><span>A: Acknowledge and discuss the diﬀerences and similarities</span></li>
                                                <li><span>R: Recommend the best solution</span></li>
                                                <li><span>N: Nonstop implementation and evaluation</span></li>
                                            </ul>
                                            </content>

                              </div>

                              <a href="formpage.html" id = "button">Register Here</a>

                        </div>

                <div class ="right_image">
                      <img src = "images/gallery/about.png" width = "100%" alt "">
                </div>

                <div class = "bk">
                    <footer>
                           <div class = "footer_left">
                            <a>
                                <footer><p> &copy 2017 thelearningHub </p></footer>
                            </a>
                           </div>
                             <div class = "mobile_footer">
                                    <div class = "footer_right">
                                            <footer><p> We are social </p></footer>
                                    </div>
                                   <div class = "footer_social">
                                    <a href="https://www.facebook.com/TheLearningHubNG/"target="new" title="Facebook">
                                        <img class="socialicon" src="images/soc/facebook1.png" height="15" width="15">
                                    </a>
                                    <a href="https://twitter.com/LearningHubNG" target="new" title="Twitter">
                                        <img class="socialicon" src="images/soc/twitter1.png" height="15" width="15">
                                    </a>
                                    <a href="https://www.instagram.com/thelearninghub_ng/" target="new" title="Instagram">
                                        <img class="socialicon" src="images/soc/instagram1.png" height="15" width="15">
                                    </a>
                                    </div>

                             </div>
                    </footer>

                </div>

            </div>
</body>
</code>```

Here is my css well commented:

The code responsible for the about us and right images is wrapped under a comment.

```<code>/***********About us************/
.about_wrap{
  width:40%;
  float:left;

}
.aboutus{
  padding-top: 20px;
  width:95%;

  padding-left:30px;
  font-size: 15px;
  margin-bottom: 20px;
}

.aboutus h1{
  margin-bottom: 20px;
  text-decoration: underline;
}

ul li {
    color: #FFC213;
    list-style-type: square;
    margin-left: 2em;
}

ul li span {
    color: black;
}

/******************Right images*****************/
.right_image{
  width:30%;

}

/******************event images*****************/

.imgitem{
width: 100%;
overflow:hidden;
}

.image1, .image2, .image3{
float:left;
width:31%;
height: auto;
margin: 1%;
}

/******************gallery*****************/

.imgitem{
width: 100%;
overflow:hidden;
padding-left: 25px;
}

.img1, .img2, .img3, .img4{
float:left;
width:20%;
height: auto;
margin: 2%;
}

/***************contact**********/
.backg{
  float:left;
  overflow: hidden;
  width:50%;
  background: white
}
.container{
  margin: 5%;
  padding:10%;
  background: #FFC213;
}
.container img{
  float:left;
  margin-right:6px;
}

.topcontent{
  padding-bottom: 20px;
}

.middlecontent{
  padding-bottom: 20px;
}

/**************form button*******************/

#container {
  background: white;
  width:50%;
  overflow:hidden;

}

#contact input[type="text"], #contact input[type="email"], #contact input[type="tel"], #contact input[type="url"], #contact textarea, #contact button[type="submit"] { font:400 12px/16px "Open Sans", Helvetica, Arial, sans-serif; }

#contact {
  background:#9B9B9B;
  padding:25px;
  margin:32px 35px;
}

fieldset {
  border: medium none !important;
  margin: 0 0 10px;
  min-width: 100%;
  padding: 0;
  width: 100%;
}

#contact input[type="text"], #contact input[type="email"], #contact input[type="tel"], #contact input[type="url"], #contact textarea {
  width:100%;
  border:1px solid #CCC;
  background:#FFF;
  margin:0 0 5px;
  padding:10px;
}

#contact input[type="text"]:hover, #contact input[type="email"]:hover, #contact input[type="tel"]:hover, #contact input[type="url"]:hover, #contact textarea:hover {
  -webkit-transition:border-color 0.3s ease-in-out;
  -moz-transition:border-color 0.3s ease-in-out;
  transition:border-color 0.3s ease-in-out;
  border:1px solid #AAA;
}

#contact textarea {
  height:100px;
  max-width:100%;
  resize:none;
}

#contact button[type="submit"] {
  cursor:pointer;
  width:100%;
  border:none;
  background:#FFf;
  color:#000000;
  margin:0 0 5px;
  padding:10px;
  font-size:15px;
}

#contact button[type="submit"]:hover {
  background:#FFC213;
  -webkit-transition:background 0.3s ease-in-out;
  -moz-transition:background 0.3s ease-in-out;
  transition:background-color 0.3s ease-in-out;
}

#contact button[type="submit"]:active { box-shadow:inset 0 1px 3px rgba(0, 0, 0, 0.5); }

#contact input:focus, #contact textarea:focus {
  outline:0;
  border:1px solid #999;
}
::-webkit-input-placeholder {
 color:#888;
}
:-moz-placeholder {
 color:#888;
}
::-moz-placeholder {
 color:#888;
}
:-ms-input-placeholder {
 color:#888;
}

.error {
    color: black;
}

.success {
    color: black;
    text-align: center;
    font-weight: bold;
    font-size: 14px;
}

/****************Newsletter********************/
#get_email button[type="submit"] {
  cursor:pointer;
  width:100px;
  border:none;
  background:#000;
  color:#fff;
  margin-top: -24px;
  padding:10px;
  font-size:15px;
  border-radius: 4px;
}

/****************Registration********************/
#reg {
  background: white;
  width:90%;
  overflow:hidden;

}

#Course {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    margin-top: 6px;
    margin-bottom: 16px;
    resize: vertical;
}

#reg_contact{
  padding:25px;
  margin:50px;
}

#reg input[type="text"], #reg_contact input[type="email"], #reg_contact input[type="tel"], #reg_contact input[type="url"], #reg_contact textarea, #reg_contact button[type="submit"] { font:400 12px/16px "Open Sans", Helvetica, Arial, sans-serif; }

#reg {

  background:#ADADAD;
  padding:25px;
  margin:32px 35px;
}

fieldset {
  border: medium none !important;
  margin: 0 0 10px;
  min-width: 100%;
  padding: 0;
  width: 100%;
}

#reg input[type="text"], #reg input[type="email"], #reg input[type="tel"], #reg input[type="url"], #reg textarea {
  width:100%;
  border:1px solid #CCC;
  background:#FFF;
  margin:0 0 5px;
  padding:10px;
}

#reg input[type="text"]:hover, #reg input[type="email"]:hover, #reg input[type="tel"]:hover, #reg input[type="url"]:hover, #reg textarea:hover {
  -webkit-transition:border-color 0.3s ease-in-out;
  -moz-transition:border-color 0.3s ease-in-out;
  transition:border-color 0.3s ease-in-out;
  border:1px solid #AAA;
}

#reg textarea {
  height:100px;
  max-width:100%;
  resize:none;
}

#reg button[type="submit"] {
  cursor:pointer;
  width:100%;
  border:none;
  background:black;
  color:white;
  margin:0 0 5px;
  padding:10px;
  font-size:15px;
}

#reg button[type="submit"]:hover {
  background:#FFC116;
  -webkit-transition:background 0.3s ease-in-out;
  -moz-transition:background 0.3s ease-in-out;
  transition:background-color 0.3s ease-in-out;
}

#reg button[type="submit"]:active { box-shadow:inset 0 1px 3px rgba(0, 0, 0, 0.5); }

#reg input:focus, #reg textarea:focus {
  outline:0;
  border:1px solid #999;
}
::-webkit-input-placeholder {
 color:#888;
}
:-moz-placeholder {
 color:#888;
}
::-moz-placeholder {
 color:#888;
}
:-ms-input-placeholder {
 color:#888;
}

/*****************Button*******************/

#button {
    background-color: #FFC213;
    border: none;
    color: black;
    padding: 8px 15px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
    margin-left: 40px;
}

/*****************Googlemap*******************/

.mymap{
  margin-left: 34px;
  margin-right: 35px;
  background-color: #FFC213;
}

/********* footer ***********/
.footer_left{
  margin-top: 20px;
  margin-bottom: 20px;
    float:left;
    margin-left: 30px;
  color: white;
}

.footer_right{
    float: left;
  color: white;
  margin-right: 8px;
}

.footer_social{
  padding-right: 30px;
}

.footer_social a{
  display: inline-block;
  margin-right: 5px;
}

.mobile_footer{

  float:right;
  margin-top: 18px;
  width :18%;
}

.bk{
    background:black;
  height: auto;
  margin: 0 auto;
  overflow:hidden;
}
</code>```

答:
Thanks everyone for the effort. I finally resolved it. What i did was to go to my footer and apply a width of 100% and float to left, this is to force it to the bottom of the page. Here are my edited code:

```<code>.bk{
  width: 100%;................apply width 100%...............
    background:black;
  float:left;.....................float left..............
  margin: 0 auto;
  overflow:hidden;
}
</code>```

float the first div to the left and apply a width in %

```<code>/******************Left images*****************/
.left_image{
  margin-top: 30px;
  float:left;
  width:50%;
}
</code>```

float the second div to the right and give it a width.

```<code>.about_wrap{
  float:right;
  width: 50%;
}
</code>```

Body:
i know this is very basic but can't seem to wrap my head around it. I am trying to float an image to the right of the text, each time i do that, the image actually floats to the right but then, the footer pops to the top and the white background colour disappears. I have spend surprisingly two days trying to resolve this embarrassing error but no result. Here is my html code:

<!DOCTYPE>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> Learninghub </title>
    <link rel="stylesheet" href="css/style.css" />
    <link rel="stylesheet" href="css/slide2.css">
    <link rel="stylesheet" href="css/simple-slideshow-styles.css">

                                                 Call us today

                                                 09-2921465

                                                        Suite 1, Capital Hub Mall, Plot 272 Ahmadu Bello Way

                                                         Along Wuse-Gwarinpa-Next Express Way, F.C.T Abuja.

                                            Menu
                                        <input type="checkbox" id="drop" />

Home

                                                    About Us +
                                                    About Us
                                                    <input type="checkbox" id="drop-1"/>

Methodology

Services

                                                List of Courses +
                                                List of Courses
                                                <input type="checkbox" id="drop-2"/>

Administration

Agriculture

                                                Ongoing Courses +
                                                Ongoing Courses
                                                <input type="checkbox" id="drop-2"/>

Creative

Enterprise

Microsoft Excel

Hardware

MIS

Microsoft Office

Networking

Web Design

Web Development

Gallery

Events

Contact

ABOUT US

                                <content>

                                    The Learning Hub was established with the objective of developing and facilitating learning processes designed
                                         to maximise capacity building and self-development. We have extensive experience and appreciable competence
                                         in rendering quality services to our clients. The business and work environment changes quickly.

                                        The Learning Hub is an operating name and also the training and capacity building outfit of PACCENTER LTD. The
                                        Learning hub has been specifically dedicated as the Training and Consultancy services of PAC CENTER LTD.
                                        PAC CENTER LTD is accredited by the Centre for Management Development (CMD) and is duly registered with the
                                        Computer Professionals Registration Council of Nigeria (CPN).

                                    </content>

OUR MISSION

                                <content>

                                    To deliver skills and knowledge that signiﬁcantly increase our course participants' on-the-job productivity,
                                    thereby enhancing their contributions to the goals of their organisation.

                                    </content>

OUR VISION

                                <content>

                                    To become the preferred partner to organisations and individuals by providing the most comprehensive
                                    professional and personal growth training.

                                    </content>

OUR CORE VALUES

                                        <content>

                                            Through these values we create success:

L: Listen with empathy to problems

E: Examine various opinions critically

A: Acknowledge and discuss the diﬀerences and similarities

R: Recommend the best solution

N: Nonstop implementation and evaluation

                                            </content>

                              Register Here

 &copy 2017 thelearningHub

 We are social

Here is my css well commented:

The code responsible for the about us and right images is wrapped under a comment.

/***********About us************/
.about_wrap{
  width:40%;
  float:left;

}
.aboutus{
  padding-top: 20px;
  width:95%;

  padding-left:30px;
  font-size: 15px;
  margin-bottom: 20px;
}

.aboutus h1{
  margin-bottom: 20px;
  text-decoration: underline;
}

ul li {
    color: #FFC213;
    list-style-type: square;
    margin-left: 2em;
}

ul li span {
    color: black;
}

/******************Right images*****************/
.right_image{
  width:30%;

}

/******************event images*****************/

.imgitem{
width: 100%;
overflow:hidden;
}

.image1, .image2, .image3{
float:left;
width:31%;
height: auto;
margin: 1%;
}

/******************gallery*****************/

.imgitem{
width: 100%;
overflow:hidden;
padding-left: 25px;
}

.img1, .img2, .img3, .img4{
float:left;
width:20%;
height: auto;
margin: 2%;
}

/***************contact**********/
.backg{
  float:left;
  overflow: hidden;
  width:50%;
  background: white
}
.container{
  margin: 5%;
  padding:10%;
  background: #FFC213;
}
.container img{
  float:left;
  margin-right:6px;
}

.topcontent{
  padding-bottom: 20px;
}

.middlecontent{
  padding-bottom: 20px;
}

/**************form button*******************/

#container {
  background: white;
  width:50%;
  overflow:hidden;

}

#contact input[type="text"], #contact input[type="email"], #contact input[type="tel"], #contact input[type="url"], #contact textarea, #contact button[type="submit"] { font:400 12px/16px "Open Sans", Helvetica, Arial, sans-serif; }

#contact {
  background:#9B9B9B;
  padding:25px;
  margin:32px 35px;
}

fieldset {
  border: medium none !important;
  margin: 0 0 10px;
  min-width: 100%;
  padding: 0;
  width: 100%;
}

#contact input[type="text"], #contact input[type="email"], #contact input[type="tel"], #contact input[type="url"], #contact textarea {
  width:100%;
  border:1px solid #CCC;
  background:#FFF;
  margin:0 0 5px;
  padding:10px;
}

#contact input[type="text"]:hover, #contact input[type="email"]:hover, #contact input[type="tel"]:hover, #contact input[type="url"]:hover, #contact textarea:hover {
  -webkit-transition:border-color 0.3s ease-in-out;
  -moz-transition:border-color 0.3s ease-in-out;
  transition:border-color 0.3s ease-in-out;
  border:1px solid #AAA;
}

#contact textarea {
  height:100px;
  max-width:100%;
  resize:none;
}

#contact button[type="submit"] {
  cursor:pointer;
  width:100%;
  border:none;
  background:#FFf;
  color:#000000;
  margin:0 0 5px;
  padding:10px;
  font-size:15px;
}

#contact button[type="submit"]:hover {
  background:#FFC213;
  -webkit-transition:background 0.3s ease-in-out;
  -moz-transition:background 0.3s ease-in-out;
  transition:background-color 0.3s ease-in-out;
}

#contact button[type="submit"]:active { box-shadow:inset 0 1px 3px rgba(0, 0, 0, 0.5); }

#contact input:focus, #contact textarea:focus {
  outline:0;
  border:1px solid #999;
}
::-webkit-input-placeholder {
 color:#888;
}
:-moz-placeholder {
 color:#888;
}
::-moz-placeholder {
 color:#888;
}
:-ms-input-placeholder {
 color:#888;
}

.error {
    color: black;
}

.success {
    color: black;
    text-align: center;
    font-weight: bold;
    font-size: 14px;
}

/****************Newsletter********************/
#get_email button[type="submit"] {
  cursor:pointer;
  width:100px;
  border:none;
  background:#000;
  color:#fff;
  margin-top: -24px;
  padding:10px;
  font-size:15px;
  border-radius: 4px;
}

/****************Registration********************/
#reg {
  background: white;
  width:90%;
  overflow:hidden;

}

#Course {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    margin-top: 6px;
    margin-bottom: 16px;
    resize: vertical;
}

#reg_contact{
  padding:25px;
  margin:50px;
}

#reg input[type="text"], #reg_contact input[type="email"], #reg_contact input[type="tel"], #reg_contact input[type="url"], #reg_contact textarea, #reg_contact button[type="submit"] { font:400 12px/16px "Open Sans", Helvetica, Arial, sans-serif; }

#reg {

  background:#ADADAD;
  padding:25px;
  margin:32px 35px;
}

fieldset {
  border: medium none !important;
  margin: 0 0 10px;
  min-width: 100%;
  padding: 0;
  width: 100%;
}

#reg input[type="text"], #reg input[type="email"], #reg input[type="tel"], #reg input[type="url"], #reg textarea {
  width:100%;
  border:1px solid #CCC;
  background:#FFF;
  margin:0 0 5px;
  padding:10px;
}

#reg input[type="text"]:hover, #reg input[type="email"]:hover, #reg input[type="tel"]:hover, #reg input[type="url"]:hover, #reg textarea:hover {
  -webkit-transition:border-color 0.3s ease-in-out;
  -moz-transition:border-color 0.3s ease-in-out;
  transition:border-color 0.3s ease-in-out;
  border:1px solid #AAA;
}

#reg textarea {
  height:100px;
  max-width:100%;
  resize:none;
}

#reg button[type="submit"] {
  cursor:pointer;
  width:100%;
  border:none;
  background:black;
  color:white;
  margin:0 0 5px;
  padding:10px;
  font-size:15px;
}

#reg button[type="submit"]:hover {
  background:#FFC116;
  -webkit-transition:background 0.3s ease-in-out;
  -moz-transition:background 0.3s ease-in-out;
  transition:background-color 0.3s ease-in-out;
}

#reg button[type="submit"]:active { box-shadow:inset 0 1px 3px rgba(0, 0, 0, 0.5); }

#reg input:focus, #reg textarea:focus {
  outline:0;
  border:1px solid #999;
}
::-webkit-input-placeholder {
 color:#888;
}
:-moz-placeholder {
 color:#888;
}
::-moz-placeholder {
 color:#888;
}
:-ms-input-placeholder {
 color:#888;
}

/*****************Button*******************/

#button {
    background-color: #FFC213;
    border: none;
    color: black;
    padding: 8px 15px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
    margin-left: 40px;
}

/*****************Googlemap*******************/

.mymap{
  margin-left: 34px;
  margin-right: 35px;
  background-color: #FFC213;
}

/********* footer ***********/
.footer_left{
  margin-top: 20px;
  margin-bottom: 20px;
    float:left;
    margin-left: 30px;
  color: white;
}

.footer_right{
    float: left;
  color: white;
  margin-right: 8px;
}

.footer_social{
  padding-right: 30px;
}

.footer_social a{
  display: inline-block;
  margin-right: 5px;
}

.mobile_footer{

  float:right;
  margin-top: 18px;
  width :18%;
}

.bk{
    background:black;
  height: auto;
  margin: 0 auto;
  overflow:hidden;
}

Body:
Thanks everyone for the effort. I finally resolved it. What i did was to go to my footer and apply a width of 100% and float to left, this is to force it to the bottom of the page. Here are my edited code:

.bk{
  width: 100%;................apply width 100%...............
    background:black;
  float:left;.....................float left..............
  margin: 0 auto;
  overflow:hidden;
}

float the first div to the left and apply a width in %

/******************Left images*****************/
.left_image{
  margin-top: 30px;
  float:left;
  width:50%;
}

float the second div to the right and give it a width.

.about_wrap{
  float:right;
  width: 50%;
}


问:
Extract version number from a comment
I have a CSS (or HTML or JS) file with a comment /* Version: 1.2.1 */ near the beginning of the file.

Using PHP/regex, how do I get a string containing '1.2.1'?

I apologise for not RTFM but I can't find an answer on the Google. Any direction on learning regex would be great!

答:
To begin with regex learning, I strongly recommend these two sites:

RexEgg

Regular-Expression.info

To test your regex regex101 is particularly usefull.

That being said, you have two options to consider:

You want to work with a capture group.

You want to get only a match.

If you can work with a capture group, simple regex will work:

```<code>^\s*\/\* Version: (\d\.\d\.\d) \*\/
</code>```

This will capture the version number in group 1 (demo).

When you want to only get the matching version number but don't want to bother with a capture group, you have to work with lookarounds:

A lookbehind allows you to check for text preceding the match. In your case: (?<=\/\* Version: ).

A lookafter to check for the comment end: (?= \/\*).

Assembled with version number matching (demo):

```<code>(?<=\/\* Version: )\d\.\d\.\d(?= \*\/)
</code>```

Title: Extract version number from a comment

Body:
To begin with regex learning, I strongly recommend these two sites:

RexEgg

Regular-Expression.info

To test your regex regex101 is particularly usefull.

That being said, you have two options to consider:

You want to work with a capture group.

You want to get only a match.

If you can work with a capture group, simple regex will work:

^\s*\/\* Version: (\d\.\d\.\d) \*\/

This will capture the version number in group 1 (demo).

When you want to only get the matching version number but don't want to bother with a capture group, you have to work with lookarounds:

A lookbehind allows you to check for text preceding the match. In your case: (?<=\/\* Version: ).

A lookafter to check for the comment end: (?= \/\*).

Assembled with version number matching (demo):

(?<=\/\* Version: )\d\.\d\.\d(?= \*\/)


问:
Merge 16 lines into one line
A file contains ASCII characters to represent hex value.
(each line ends in ", ")

```<code>cat temp.txt
    0x6A,
    0xF2,
    0x44,
    .....
    0xF8,
    0x1A,
</code>```

I try to combines each 16 words/lines into one line like this

```<code>cat hex_result.txt
0x6A, 0xF2, 0x44, 0xF8, 0x45, 0x41, 0x88, 0xD1,0x4E, 0x8B, 0xA3, 0xB1, 0x8C, 0xE0, 0x37, 0x2D,
....
0xE2, 0x1C, 0x06, 0x8A, 0x75, 0x2B, 0xBC, 0x3C, 0xC5, 0x08, 0xB7, 0x4E, 0xB0, 0xE4, 0xF8, 0x1A,
</code>```

Is any bash commands to accomplish it ?

Title: Merge 16 lines into one line

Body:
A file contains ASCII characters to represent hex value.
(each line ends in ", ")

cat temp.txt
    0x6A,
    0xF2,
    0x44,
    .....
    0xF8,
    0x1A,

I try to combines each 16 words/lines into one line like this

cat hex_result.txt
0x6A, 0xF2, 0x44, 0xF8, 0x45, 0x41, 0x88, 0xD1,0x4E, 0x8B, 0xA3, 0xB1, 0x8C, 0xE0, 0x37, 0x2D,
....
0xE2, 0x1C, 0x06, 0x8A, 0x75, 0x2B, 0xBC, 0x3C, 0xC5, 0x08, 0xB7, 0x4E, 0xB0, 0xE4, 0xF8, 0x1A,

Is any bash commands to accomplish it ?

Body:
Benchmarking six different merging methods,

for merging specific number of lines.

Basicaly, there are many commands:

pr - convert text files for printing

pr -at16 <file

Try:

pr -a -t -16 < <(seq 1 42)
1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16
17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32
33  34  35  36  37  38  39  40  41  42

xargs - build and execute command lines from standard input

... and  executes the  command (default is /bin/echo) ...

xargs -n 16 <file

Try:

xargs -n 16 < <(seq 1 42)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40 41 42

paste - merge lines of files

printf -v pasteargs %*s 16
paste -d\  ${pasteargs// /- } < <(seq 1 42)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40 41 42

sed - stream editor for filtering and transforming text

printf -v sedstr 'N;s/\\n/ /;%.0s' {2..16};
sed -e "$sedstr" < <(seq 1 42)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40 41 42

awk - pattern scanning and processing language

awk 'NR%16{printf "%s ",$0;next;}1'  < <(seq 1 42)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40 41 42

But, you could use pure bash:

group=()
while read -r line;do
    group+=("$line")
    (( ${#group[@]} > 15 ))&&{
        echo "${group[*]}"
        group=()
    }
  done < <(seq 1 42) ; echo "${group[*]}"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40 41 42

or as a function:

lgrp () {
    local group=() line
    while read -r line; do
        group+=("$line")
        ((${#group[@]}>=$1)) && {
            echo "${group[*]}"
            group=()
        }
    done
    [ "$group" ] && echo "${group[*]}"
}

or

lgrp () { local g=() l;while read -r l;do g+=("$l");((${#g[@]}>=$1))&&{
          echo "${g[*]}";g=();};done;[ "$g" ] && echo "${g[*]}";}

then

lgrp 16 < <(seq 1 42)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40 41 42

( Note: All this tests was arbitrarily done over 42 values, don't ask my why! ;-)

Other languages

Of course, by using any language, you could do same:

perl -ne 'chomp;$r.=$_." ";( 15 < ++$cnt) && do {
    printf "%s\n", $1 if $r =~ /^(.*) $/;$r="";$cnt=0;
  };END{print $r."\n"}' < <(seq 1 42)

Like python, ruby, lisp, C, ...

Comparison of execution time.

Ok, there are more than 3 simple ways, let do a little bench.
How I do it:

lgrp () { local g=() l;while read -r l;do g+=("$l");((${#g[@]}>=
 $1))&&{ echo "${g[*]}";g=();};done;[ "$g" ] && echo "${g[*]}";}
export -f lgrp
printf -v sedcmd '%*s' 15
sedcmd=${sedcmd// /N;s/\\n/ /;}
export sedcmd
{
    printf "%-12s\n" Method
    printf %7s\\n count real user system count real user system

    for cmd in 'paste -d " " -{,,,}{,,,}' 'pr -at16' \
        'sed -e "$sedcmd"' \
        $'awk \47NR%16{printf "%s ",$0;next;}1;END{print ""}\47'\
        $'perl -ne \47chomp;$r.=$_." ";( 15 < ++$cnt) && do {
           printf "%s\n", $1 if $r =~ /^(.*) $/;$r="";$cnt=0;
           };END{print $r."\n"}\47' 'lgrp 16' 'xargs -n 16'
    do
        printf %-12s\\n ${cmd%% *}
        for length in 5042 50042; do
            printf %7s\\n $(bash -c "TIMEFORMAT=$'%R %U %S';
                time $cmd < <(seq 1 $length) | wc -l" 2>&1)
        done
    done
} | paste -d $'\t' -{,,,,,,,,}

(This could be cut'n paste in a bash terminal). Produce, on my computer:

Method        count    real    user  system   count    real    user  system
paste           316   0.002   0.002   0.000    3128   0.003   0.003   0.000
pr              316   0.003   0.000   0.003    3128   0.008   0.005   0.002
sed             316   0.005   0.001   0.003    3128   0.018   0.019   0.000
awk             316   0.003   0.001   0.003    3128   0.017   0.017   0.002
perl            316   0.008   0.002   0.004    3128   0.017   0.014   0.004
lgrp            316   0.058   0.042   0.021    3128   0.733   0.568   0.307
xargs           316   0.232   0.178   0.058    3128   2.249   1.730   0.555

There is same bench on my raspberry pi:

Method        count    real    user  system   count    real    user  system
paste           316   0.149   0.032   0.012    3128   0.204   0.014   0.054
pr              316   0.163   0.017   0.038    3128   0.418   0.069   0.096
sed             316   0.275   0.088   0.031    3128   1.586   0.697   0.045
awk             316   0.440   0.146   0.049    3128   2.809   1.305   0.050
perl            316   0.421   0.122   0.040    3128   2.042   0.902   0.067
lgrp            316   7.261   3.159   0.446    3128  71.733  31.223   3.558
xargs           316   9.464   3.038   1.066    3128  93.607  32.035   9.177

Hopefully all line count are same, then paste are clearly the quicker, followed by pr. Pure bash function is not slower than xargs (I'm surprised about poor performance of xargs!).


问:
How to cause the component to re-render after an ajax request
Rerendering same component inside one function in ReactJs. I'm adding comment and now after that I want to rerender the same component. Can anyone help?</p>

```<code>commentPost() {...
    axios.defaults.headers.common['Authorization'] = getToken;
        axios.post(apiBaseUrl+'v1/comments/post-comment',input)
        .then(function (response) {
          console.log("Comment Post",response);
          //here I want to rerender this component itself
        })
        .catch(function (error) {
          console.log(error);
        });...
</code>```

答:
There are two things that you can do to cause the same component to render

First: Update a state of the current component using the setState method.

setState() will always lead to a re-render unless
  shouldComponentUpdate() returns false. If mutable objects are being
  used and conditional rendering logic cannot be implemented in
  shouldComponentUpdate(), calling setState() only when the new
  state differs from the previous state will avoid unnecessary
  re-renders.

Second: You can call forceUpdate in case you do not want to update any state of the current component. You can call it like this.forceUpdate().

Calling forceUpdate() will cause render() to be called on the
  component, skipping shouldComponentUpdate(). This will trigger the
  normal lifecycle methods for child components, including the
  shouldComponentUpdate() method of each child. React will still only
  update the DOM if the markup changes.

Assuming that you are performing an async request from which you are getting a response you would want to update the component's state with the data that you got and hence setState would be the way forward for you

Body:
Rerendering same component inside one function in ReactJs. I'm adding comment and now after that I want to rerender the same component. Can anyone help?

commentPost() {...
    axios.defaults.headers.common['Authorization'] = getToken;
        axios.post(apiBaseUrl+'v1/comments/post-comment',input)
        .then(function (response) {
          console.log("Comment Post",response);
          //here I want to rerender this component itself
        })
        .catch(function (error) {
          console.log(error);
        });...