问:
Is this a bug of Scala, when defining a list such as :
I want to define a list[Char] in scala, but made a mistake. I missed a single quote character following 'b'. However I got a List[Any] instance. Is it a bug of Scala or normal result?

scala> val list = List('a',**'b**,'c','d')
list: List[Any] = List(a, 'b, c, d)

答:
As woods already answered, the value of 'b' is a character, while 'b would be of type Symbol (a canonical string that is also a valid Scala identifier).

The List type has a very special feature that might be irritating at first: When adding to a list of type A, you are not restricted to adding instances of A. But if you add something else than an A to the list, you get a more general list as result. Example:

```<code>class A {}
class B extends A {}
class C extends A {}

val list1:List[B] = List(new B(), new B(), new B())
val list2:List[A] = new C() :: list1
</code>```

When you do something like this, Scala finds the more general supertype (in the example above, this is A), and returns a list of that type. This is only possible because lists of type List are immutable, and when you add an element to the list, you actually create a new list and leave the old list unaltered. And the new list can be of a more general type than the original one.

In your case, you accidentally stumbled over this feature, because the only common supertype for Char and Symbol is Any.

Body:
As woods already answered, the value of 'b' is a character, while 'b would be of type Symbol (a canonical string that is also a valid Scala identifier).

The List type has a very special feature that might be irritating at first: When adding to a list of type A, you are not restricted to adding instances of A. But if you add something else than an A to the list, you get a more general list as result. Example:

class A {}
class B extends A {}
class C extends A {}

val list1:List[B] = List(new B(), new B(), new B())
val list2:List[A] = new C() :: list1

When you do something like this, Scala finds the more general supertype (in the example above, this is A), and returns a list of that type. This is only possible because lists of type List are immutable, and when you add an element to the list, you actually create a new list and leave the old list unaltered. And the new list can be of a more general type than the original one.

In your case, you accidentally stumbled over this feature, because the only common supertype for Char and Symbol is Any.


来源: stackexchange

问:
SQL Order By Specific String in a Column
I was recently tasked to put a column in order base on a specific string. Bellow is the screenshot of my table:

How can I sort the picture column in the following order:

```<code>2017/June/06/169799_1_kYFJf.jpg
2017/February/18/169799_2_rkJ2d.jpg
2017/January/12/169799_3_23wKj.jpg
2017/March/18/169799_4_iMbw7.jpg
2017/May/18/169799_5_HwDBf.jpg
</code>```

I tried ORDER BY picture DESC but it didn't work.

Unfortunately I am not allowed to add a new column, like maybe column "sort", which will define the sort number of the image.

答:
In virtually all dialects of SQL, you could do the following:

```<code>order by
    to_number(
        substr(
            picture,
            instr(picture,'_',1,1)+1,
            instr(picture,'_',1,2) - instr(picture,'_',1,1) -1))
</code>```

Some dialects of SQL (not sure about mysql) offer a friendlier delimited-string parsing function, e.g. "split_part()", which would support the more compact:

```<code>order by to_number(split_part(picture,'_',2))
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I was recently tasked to put a column in order base on a specific string. Bellow is the screenshot of my table:

How can I sort the picture column in the following order:

2017/June/06/169799_1_kYFJf.jpg
2017/February/18/169799_2_rkJ2d.jpg
2017/January/12/169799_3_23wKj.jpg
2017/March/18/169799_4_iMbw7.jpg
2017/May/18/169799_5_HwDBf.jpg

I tried ORDER BY picture DESC but it didn't work.

Unfortunately I am not allowed to add a new column, like maybe column "sort", which will define the sort number of the image.

Body:
In virtually all dialects of SQL, you could do the following:

order by
    to_number(
        substr(
            picture,
            instr(picture,'_',1,1)+1,
            instr(picture,'_',1,2) - instr(picture,'_',1,1) -1))

Some dialects of SQL (not sure about mysql) offer a friendlier delimited-string parsing function, e.g. "split_part()", which would support the more compact:

order by to_number(split_part(picture,'_',2))


答:
You need to find video element first and assign to variable.
In video tag set id

```<code><video id="myVideo">...</video>
</code>```

then search for it in javascript

```<code>  function videoPlay() {
        var video =  document.getElementById("myVideo");
        video.play();
        var videoStatusText="状态：正在播放。";
        document.getElementById("videoStatus").innerHTML=videoStatusText
    }
</code>```

Title: Why the video.play() can't be resolved in <script> in HTML5

Body: That's all my code.I already have the <video>...</video> But still can't be resolved in

Body:
You need to find video element first and assign to variable.
In video tag set id

<video id="myVideo">...</video>

then search for it in javascript

  function videoPlay() {
        var video =  document.getElementById("myVideo");
        video.play();
        var videoStatusText="状态：正在播放。";
        document.getElementById("videoStatus").innerHTML=videoStatusText
    }


问:
Why is not presented the custoned widget
I want to present the left customed widget 3 times. Left, center and right.

I have trying to follow and mix some examples I have found, but I only get one widget presented.

I have added colout to get some clues, but I am not able to find what I am doing wrong.

This is the code:

```<code>import sys
import tkinter as tk
#import tkinter.ttk, Font, Label, Frame as tk
#import tkinter.ttk as tk

#https://stackoverflow.com/questions/27614037/python-3-tkinter-create-text-widget-covering-100-width-with-grid?rq=1
# https://stackoverflow.com/questions/7591294/how-to-create-a-self-resizing-grid-of-buttons-in-tkinter
# http://effbot.org/tkinterbook/grid.htm

# 02. Pruebo cambiando llamada de funcion de clase a metodo de instancia

class   Cuadro(tk.Frame):
    def __init__(self, parent, *args, **kargs):

        # super().__init__(root)
        tk.Frame.__init__(self, parent, *args, **kargs)

        #Create & Configure frame

        frame = tk.Frame(parent)
        frame.grid(row=0, column=0, sticky="NSEW")

        #Create a 3x3 (rows x columns) grid of labels inside the frame
        for row_index in range(3):
        #tk.Grid.rowconfigure(frame, row_index, weight=1)               # version 02
            frame.rowconfigure(row_index, weight=1)                     # version 02
            for col_index in range(3):
                #tk.Grid.columnconfigure(frame, col_index, weight=1)    # version 02
                frame.columnconfigure(col_index, weight=1)              # version 02
                lbl = tk.Label(frame, text = str((row_index *3) + col_index + 1)) #create a button inside frame
                #lbl.grid(row=row_index, column=col_index, sticky=N+S+E+W)
                lbl.grid(row=row_index, column=col_index, sticky="NSEW")

#Create & Configure root
class   Application(tk.Frame):
    def __init__(self, parent):

        tk.Grid.rowconfigure   (parent, 0, weight=1)
        tk.Grid.columnconfigure(parent, 0, weight=1)
        tk.Grid.columnconfigure(parent, 1, weight=1)
        tk.Grid.columnconfigure(parent, 2, weight=1)
        self.cuadro1 = Cuadro(parent)
        self.cuadro1.config(background="red")
        self.cuadro1.grid(row=0, column=0, sticky="NSEW")
        self.cuadro2 = Cuadro(parent)
        self.cuadro2.config(bg="green")
        self.cuadro2.grid(row=0, column=1, sticky="NSEW")
        self.cuadro3 = Cuadro(parent)
        self.cuadro3.config(bg="blue")
        self.cuadro3.grid(row=0, column=2, sticky="NSEW")

def main():
    root = tk.Tk()
    root.title(sys.argv[0])    # version 02

    myapp = Application(root)
    root.mainloop()

if __name__ == '__main__':
    main()
</code>```

And this is the result:

!http://imgur.com/XROp68R

What is wrong?

答:
Your three Cuadro objects have no contents at all - they're valid Frames, since you inherited from tk.Frame and called the superclass __init__(), but you did absolutely nothing with them.  Instead, each one created an entirely separate Frame, not connected to the Cuadro itself, and placed it at row=0, column=0 in the parent view.  Each of these overwrote the previous one, and the red Cuadro which was originally placed at row=0, column=0, so you ended up with a single visible copy of the 3x3 grid, and no red area.

You made the same mistake with Application - it's a valid Frame, but you added nothing to it, instead you created each Cuadro as a direct child of Application's parent (the Tk root window).

It's perfectly valid to have classes that merely create widgets like this, but they shouldn't derive from a Tk widget class if you aren't going to use them as widgets themselves.

Body:
I want to present the left customed widget 3 times. Left, center and right.

I have trying to follow and mix some examples I have found, but I only get one widget presented.

I have added colout to get some clues, but I am not able to find what I am doing wrong.

This is the code:

import sys
import tkinter as tk
#import tkinter.ttk, Font, Label, Frame as tk
#import tkinter.ttk as tk

#https://stackoverflow.com/questions/27614037/python-3-tkinter-create-text-widget-covering-100-width-with-grid?rq=1
# https://stackoverflow.com/questions/7591294/how-to-create-a-self-resizing-grid-of-buttons-in-tkinter
# http://effbot.org/tkinterbook/grid.htm

# 02. Pruebo cambiando llamada de funcion de clase a metodo de instancia

class   Cuadro(tk.Frame):
    def __init__(self, parent, *args, **kargs):

        # super().__init__(root)
        tk.Frame.__init__(self, parent, *args, **kargs)

        #Create & Configure frame

        frame = tk.Frame(parent)
        frame.grid(row=0, column=0, sticky="NSEW")

        #Create a 3x3 (rows x columns) grid of labels inside the frame
        for row_index in range(3):
        #tk.Grid.rowconfigure(frame, row_index, weight=1)               # version 02
            frame.rowconfigure(row_index, weight=1)                     # version 02
            for col_index in range(3):
                #tk.Grid.columnconfigure(frame, col_index, weight=1)    # version 02
                frame.columnconfigure(col_index, weight=1)              # version 02
                lbl = tk.Label(frame, text = str((row_index *3) + col_index + 1)) #create a button inside frame
                #lbl.grid(row=row_index, column=col_index, sticky=N+S+E+W)
                lbl.grid(row=row_index, column=col_index, sticky="NSEW")

#Create & Configure root
class   Application(tk.Frame):
    def __init__(self, parent):

        tk.Grid.rowconfigure   (parent, 0, weight=1)
        tk.Grid.columnconfigure(parent, 0, weight=1)
        tk.Grid.columnconfigure(parent, 1, weight=1)
        tk.Grid.columnconfigure(parent, 2, weight=1)
        self.cuadro1 = Cuadro(parent)
        self.cuadro1.config(background="red")
        self.cuadro1.grid(row=0, column=0, sticky="NSEW")
        self.cuadro2 = Cuadro(parent)
        self.cuadro2.config(bg="green")
        self.cuadro2.grid(row=0, column=1, sticky="NSEW")
        self.cuadro3 = Cuadro(parent)
        self.cuadro3.config(bg="blue")
        self.cuadro3.grid(row=0, column=2, sticky="NSEW")

def main():
    root = tk.Tk()
    root.title(sys.argv[0])    # version 02

    myapp = Application(root)
    root.mainloop()

if __name__ == '__main__':
    main()

And this is the result:

!http://imgur.com/XROp68R

What is wrong?


问:
java swing jpanel will not refresh
In my swing application, I have two panels in a frame.
First panel has a button. When I click this button, some data changes, and I want the contents of the second panel to change, too, showing the new data (via jlabel). repaint() does not work. I tried all kinds of updates (see comments in the code).

I have a reference to the second panel. I can change the second panel color by using that reference, but I cannot repaint it. I can also make a reference to the jlabel in the second panel and just change its text, but the main point of this question is to make panel2 refresh.

SSCCE is below.
Please, take a look.

```<code>import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.EtchedBorder;

public class Repaint_Test
{
    public static void main(String args[]){
        Frame frame = new Frame();
    }
}

class Frame extends JFrame
{
    public Frame()  {
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(500,250);
        this.setLocationRelativeTo(null);
        this.setLayout(new GridLayout(1,2));
        Panel1 p1 = new Panel1();
        Panel2 p2 = new Panel2();
        Data.panel2 = p2; // getting the reference of panel2
        this.add(p1);
        this.add(p2);
        this.setVisible(true);
    }
}

class Panel1 extends JPanel
{
    public Panel1(){
        this.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(),"Panel1:"));
        JButton button = new JButton("Push");
        button.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                Data.text = "text"; // changing commonly accessed data
                Data.panel2.setBackground(Color.PINK); // this works
                //Data.panel2.invalidate();
                //Data.panel2.validate();
                //Data.panel2.updateUI();
                //Data.panel2.revalidate();
                Data.panel2.repaint();                // this does not work
            }
        });
        this.add(button);
    }
}

class Panel2 extends JPanel
{
    public Panel2(){
        this.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(),"Panel2:"));
        add(new JLabel(Data.text));
    }
}

class Data
{
    public static JPanel panel2 = null;
    public static String text = "ooooo";
}
</code>```

SOLUTION:

Thanks to Austin Patel's suggestion, I was able to achieve my goal and even refresh (repaint) panel2. For that purpose an update method was created inside Panel2 class. All panel2 alterations were made there and then revalidate() and repaint() methods were called from update to refresh panel2.

答:
The problem is a refresh/repaint issue, but rather you never actually change the JLabel's text.  Changing Data.text doesn't actually change the JLabel's text.  You have to call the setText method of the JLabel.  If you try printing out the text of the JLabel right after you change Data.text you will notice that the JLabel's text didn't change.  Here is my solution:

```<code>import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.EtchedBorder;

public class Repaint_Test
{
    public static void main(String args[]){
        Frame frame = new Frame();
    }
}

class Frame extends JFrame
{
    private static final long serialVersionUID = 1L;
    public Frame()  {
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(500,250);
        this.setLocationRelativeTo(null);
        this.setLayout(new GridLayout(1,2));
        Panel1 p1 = new Panel1();
        Panel2 p2 = new Panel2();
        Data.panel2 = p2; // getting the reference of panel2
        this.add(p1);
        this.add(p2);
        this.setVisible(true);
    }
}

class Panel1 extends JPanel
{
    private static final long serialVersionUID = 1L;
    public Panel1(){
        this.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(),"Panel1:"));
        JButton button = new JButton("Push");
        button.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                Data.text = "text"; // changing commonly accessed data
                Data.panel2.setBackground(Color.PINK); // this works
                //Data.panel2.invalidate();
                //Data.panel2.validate();
                //Data.panel2.updateUI();
                //Data.panel2.revalidate();
//                Data.panel2.repaint();                // this does not work
                Data.panel2.updateText(Data.text);
            }
        });
        this.add(button);
    }
}

class Panel2 extends JPanel
{
    private static final long serialVersionUID = 1L;
    private JLabel label;

    public Panel2(){
        this.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(),"Panel2:"));

        label = new JLabel("Initial Text");
        add(label);
    }

    public void updateText(String text) {
        label.setText(text);
    }
}

class Data
{
    public static Panel2 panel2 = null;
    public static String text = "ooooo";
}
</code>```

Title: java swing jpanel will not refresh

Body:
In my swing application, I have two panels in a frame.
First panel has a button. When I click this button, some data changes, and I want the contents of the second panel to change, too, showing the new data (via jlabel). repaint() does not work. I tried all kinds of updates (see comments in the code).

I have a reference to the second panel. I can change the second panel color by using that reference, but I cannot repaint it. I can also make a reference to the jlabel in the second panel and just change its text, but the main point of this question is to make panel2 refresh.

SSCCE is below.
Please, take a look.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.EtchedBorder;

public class Repaint_Test
{
    public static void main(String args[]){
        Frame frame = new Frame();
    }
}

class Frame extends JFrame
{
    public Frame()  {
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(500,250);
        this.setLocationRelativeTo(null);
        this.setLayout(new GridLayout(1,2));
        Panel1 p1 = new Panel1();
        Panel2 p2 = new Panel2();
        Data.panel2 = p2; // getting the reference of panel2
        this.add(p1);
        this.add(p2);
        this.setVisible(true);
    }
}

class Panel1 extends JPanel
{
    public Panel1(){
        this.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(),"Panel1:"));
        JButton button = new JButton("Push");
        button.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                Data.text = "text"; // changing commonly accessed data
                Data.panel2.setBackground(Color.PINK); // this works
                //Data.panel2.invalidate();
                //Data.panel2.validate();
                //Data.panel2.updateUI();
                //Data.panel2.revalidate();
                Data.panel2.repaint();                // this does not work
            }
        });
        this.add(button);
    }
}

class Panel2 extends JPanel
{
    public Panel2(){
        this.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(),"Panel2:"));
        add(new JLabel(Data.text));
    }
}

class Data
{
    public static JPanel panel2 = null;
    public static String text = "ooooo";
}

SOLUTION:

Thanks to Austin Patel's suggestion, I was able to achieve my goal and even refresh (repaint) panel2. For that purpose an update method was created inside Panel2 class. All panel2 alterations were made there and then revalidate() and repaint() methods were called from update to refresh panel2.

Body:
The problem is a refresh/repaint issue, but rather you never actually change the JLabel's text.  Changing Data.text doesn't actually change the JLabel's text.  You have to call the setText method of the JLabel.  If you try printing out the text of the JLabel right after you change Data.text you will notice that the JLabel's text didn't change.  Here is my solution:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.EtchedBorder;

public class Repaint_Test
{
    public static void main(String args[]){
        Frame frame = new Frame();
    }
}

class Frame extends JFrame
{
    private static final long serialVersionUID = 1L;
    public Frame()  {
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(500,250);
        this.setLocationRelativeTo(null);
        this.setLayout(new GridLayout(1,2));
        Panel1 p1 = new Panel1();
        Panel2 p2 = new Panel2();
        Data.panel2 = p2; // getting the reference of panel2
        this.add(p1);
        this.add(p2);
        this.setVisible(true);
    }
}

class Panel1 extends JPanel
{
    private static final long serialVersionUID = 1L;
    public Panel1(){
        this.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(),"Panel1:"));
        JButton button = new JButton("Push");
        button.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                Data.text = "text"; // changing commonly accessed data
                Data.panel2.setBackground(Color.PINK); // this works
                //Data.panel2.invalidate();
                //Data.panel2.validate();
                //Data.panel2.updateUI();
                //Data.panel2.revalidate();
//                Data.panel2.repaint();                // this does not work
                Data.panel2.updateText(Data.text);
            }
        });
        this.add(button);
    }
}

class Panel2 extends JPanel
{
    private static final long serialVersionUID = 1L;
    private JLabel label;

    public Panel2(){
        this.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(),"Panel2:"));

        label = new JLabel("Initial Text");
        add(label);
    }

    public void updateText(String text) {
        label.setText(text);
    }
}

class Data
{
    public static Panel2 panel2 = null;
    public static String text = "ooooo";
}


Title: SQL Order By Specific String in a Column

Body:
You can try something like this:

Example data:

select * from test;
+--------+----------------------------------------+
| pid    | picture                                |
+--------+----------------------------------------+
| 169799 | 2017/March/18/169799_4_iMbw7.jpg       |
| 169799 | 2017/February/18/169799_2_jadsflkjasdf |
| 169799 | 2017/June/06/169799_1_jasfd;ads        |
| 169799 | 2017/May/18/169799_5_jasfd;ads         |
| 169799 | 2017/June/12/169799_10_jasfd;ads       |
| 169799 | 2017/January/12/169799_3_iMbw7.jpg     |
+--------+----------------------------------------+

Sort by date

select * from test order by str_to_date(substring_index(picture,'/',3), '%Y/%M/%d') desc;
+--------+----------------------------------------+
| pid    | picture                                |
+--------+----------------------------------------+
| 169799 | 2017/June/12/169799_10_jasfd;ads       |
| 169799 | 2017/June/06/169799_1_jasfd;ads        |
| 169799 | 2017/May/18/169799_5_jasfd;ads         |
| 169799 | 2017/March/18/169799_4_iMbw7.jpg       |
| 169799 | 2017/February/18/169799_2_jadsflkjasdf |
| 169799 | 2017/January/12/169799_3_iMbw7.jpg     |
+--------+----------------------------------------+

Explanation:

substring_index(picture,'/',3) will split text by / and output the first 3 item

str_to_date(..., '%Y/%M/%d') converts the result to a date based on the given format. %M is month name

EDIT

Sort by number

select * from test
order by cast(
  substring_index(substring_index(picture, '_', 2), '_', -1)
  as unsigned
);
+--------+----------------------------------------+
| pid    | picture                                |
+--------+----------------------------------------+
| 169799 | 2017/June/06/169799_1_jasfd;ads        |
| 169799 | 2017/February/18/169799_2_jadsflkjasdf |
| 169799 | 2017/January/12/169799_3_iMbw7.jpg     |
| 169799 | 2017/March/18/169799_4_iMbw7.jpg       |
| 169799 | 2017/May/18/169799_5_jasfd;ads         |
| 169799 | 2017/June/12/169799_10_jasfd;ads       |
+--------+----------------------------------------+

Explanation:

substring_index(picture, '_', 2) will split text by _ and output the first 2 item

substring_index(..., '_', -1) picks the last item, which is the number

References:

https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_substring-index

https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_str-to-date

https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_date-format


问:
How to exclude print commands of python script in variable of shell script
I have a python script called spark.py. This scipt will be invoked using a shell script in Linux.

The spark.py is like below:

```<code>#!/usr/bin/env python

import sys
import os

if len(sys.argv) != 2:
     print "Invalid number of args......"
     print "Usage: spark-submit file.py Arguments"
     exit()

table=sys.argv[1]
hivedb=sys.argv[2]

from pyspark import SparkContext, SparkConf
conf = SparkConf()
sc = SparkContext(conf=conf)
from pyspark.sql import HiveContext
sqlContext = HiveContext(sc)
from datetime import datetime

df.registerTempTable('mytempTable')

date=datetime.now().strftime('%Y-%m-%d %H:%M:%S')

try:
    sqlContext.sql("create table {}.`{}` as select * from mytempTable".format(hivedb,table))
except Exception as e:
    status = 'fail'
    error_message = e
else:  # Executes only if no Exception.
    status = 'success'
    error_message = 'No error'
print error_message

print ("{},{},{},{},{}".format(hivedb,table,date,status,error_message))

if status != 'success': sys.exit(1)
sc.stop()
</code>```

The shell.sh is like below

```<code>#!/bin/bash

source /home/$USER/source.sh

[ $# -ne 2 ] && { echo "Usage : $0 input file "; exit 1; }
table=$1
hivedb=$2

TIMESTAMP=`date "+%Y-%m-%d"`
touch /home/$USER/logs/${TIMESTAMP}.success_log
touch /home/$USER/logs/${TIMESTAMP}.fail_log
success_logs=/home/$USER/logs/${TIMESTAMP}.success_log
failed_logs=/home/$USER/logs/${TIMESTAMP}.fail_log

#Function to get the status of the job creation
function log_status
{
       status=$1
       message=$2
       if [ "$status" -ne 0 ]; then
                echo "$result" | tee -a "${failed_logs}"
                else
                    echo "$result" | tee -a "${success_logs}"
                fi
}

result=$(spark-submit --name "Spark" --master "yarn-client" /home/$USER/spark.py ${table} ${hivedb})
g_STATUS=$?
log_status $g_STATUS  "$result"
</code>```

In this shell script I am collecting the output of the spark.py as a variable. When I do so I am unable to see any print commands of the spark.py in the console logs in Linux.

How can I have all the print commands to be printed in the linux console logs.

And In my spark.py script I have

```<code>print error_message

print ("{},{},{},{},{}".format(hivedb,table,date,status,error_message))
</code>```

How can I exclude the print error_message while collecting the output as a variable in the shell.sh .

答: A simple way would be to add echo "$result" to your shell script. You could also revise the sub command to add a tee at the end: result=$(... | tee /dev/stderr ).

Body:
I have a python script called spark.py. This scipt will be invoked using a shell script in Linux.

The spark.py is like below:

#!/usr/bin/env python

import sys
import os

if len(sys.argv) != 2:
     print "Invalid number of args......"
     print "Usage: spark-submit file.py Arguments"
     exit()

table=sys.argv[1]
hivedb=sys.argv[2]

from pyspark import SparkContext, SparkConf
conf = SparkConf()
sc = SparkContext(conf=conf)
from pyspark.sql import HiveContext
sqlContext = HiveContext(sc)
from datetime import datetime

df.registerTempTable('mytempTable')

date=datetime.now().strftime('%Y-%m-%d %H:%M:%S')

try:
    sqlContext.sql("create table {}.`{}` as select * from mytempTable".format(hivedb,table))
except Exception as e:
    status = 'fail'
    error_message = e
else:  # Executes only if no Exception.
    status = 'success'
    error_message = 'No error'
print error_message

print ("{},{},{},{},{}".format(hivedb,table,date,status,error_message))

if status != 'success': sys.exit(1)
sc.stop()

The shell.sh is like below

#!/bin/bash

source /home/$USER/source.sh

[ $# -ne 2 ] && { echo "Usage : $0 input file "; exit 1; }
table=$1
hivedb=$2

TIMESTAMP=`date "+%Y-%m-%d"`
touch /home/$USER/logs/${TIMESTAMP}.success_log
touch /home/$USER/logs/${TIMESTAMP}.fail_log
success_logs=/home/$USER/logs/${TIMESTAMP}.success_log
failed_logs=/home/$USER/logs/${TIMESTAMP}.fail_log

#Function to get the status of the job creation
function log_status
{
       status=$1
       message=$2
       if [ "$status" -ne 0 ]; then
                echo "$result" | tee -a "${failed_logs}"
                else
                    echo "$result" | tee -a "${success_logs}"
                fi
}

result=$(spark-submit --name "Spark" --master "yarn-client" /home/$USER/spark.py ${table} ${hivedb})
g_STATUS=$?
log_status $g_STATUS  "$result"

In this shell script I am collecting the output of the spark.py as a variable. When I do so I am unable to see any print commands of the spark.py in the console logs in Linux.

How can I have all the print commands to be printed in the linux console logs.

And In my spark.py script I have

print error_message

print ("{},{},{},{},{}".format(hivedb,table,date,status,error_message))

How can I exclude the print error_message while collecting the output as a variable in the shell.sh .


问:
Subquery returns more than 1 row in group by clause - MySQL
I'm trying to get my expected result of my query with the correct sum of amount per date, however, the Amount keeps adding up when it detected the same ID. I want to get the group by date. Unfortunately, when I ran my query it's getting an error saying Subquery returns more than 1 row

Here's my query:

```<code> SELECT a.DOB as `DATE`, (CASE when f.INHOUR > 12 or f.INHour = 12 Then 'PM'
else 'AM' END) as Shift, concat(b.FIRSTNAME, ' ', b.LASTNAME) Fullname,
a.Amount as DECLARED, SUM(c.Amount) as CALCULATED,
a.AMOUNT as `NET OF SPECIAL SALES`,
d.Amount as `CASH OVER SHORT`,
a.AMOUNT as `CASH DEPOSIT`,
(SELECT SUM(gndrevn.AMOUNT) from gndrevn where gndrevn.ID= b.ID and
gndrevn.type = "4" group by gndrevn.DOB, gndrevn.ID) as `TRANSACTION COUNT (POS)`
FROM gndsale a
INNER JOIN emp b ON a.ID= b.ID
INNER JOIN gndsale c ON b.ID= c.ID
INNER JOIN gndsale d on b.ID = d.ID
INNER JOIN adjtime f on a.ID= f.ID
WHERE a.type = "22" AND c.type = "4" AND d.type = "42" and
STR_TO_DATE(a.DOB, '%m/%d/%Y') BETWEEN '2017-05-01' AND '2017-05-31' GROUP BY DECLARED
order by STR_TO_DATE(a.DOB, '%m/%d/%Y')
</code>```

It returns this error:

I tried to remove  gndrevn.DOB, gndrevn.ID  and this is my result

The Column Transaction Count POS just added because it detected similar ID's in the table.

What the result I want for my Transaction Count POS is this:

I ran this with a different query, but it also requires a group by in a select statement

Here's the query:

```<code>SELECT ID as `EMPLOYEE`, sum(AMOUNT) as AMOUNT, DOB as DATE from gndrevn
where ID in (select ID from gndsale) and type = "4" group by
DOB, ID order by STR_TO_DATE(DOB, '%m/%d/%Y')
</code>```

I think I have a problem with my group by statement to get the query. Anyone can help me on this? :(

答: I think what you want is to remove the gndrevn.DOB from the GROUP BY and add gndrevn.DOB = a.DOB in the WHERE.</p>

Body:
I'm trying to get my expected result of my query with the correct sum of amount per date, however, the Amount keeps adding up when it detected the same ID. I want to get the group by date. Unfortunately, when I ran my query it's getting an error saying Subquery returns more than 1 row

Here's my query:

 SELECT a.DOB as `DATE`, (CASE when f.INHOUR > 12 or f.INHour = 12 Then 'PM'
else 'AM' END) as Shift, concat(b.FIRSTNAME, ' ', b.LASTNAME) Fullname,
a.Amount as DECLARED, SUM(c.Amount) as CALCULATED,
a.AMOUNT as `NET OF SPECIAL SALES`,
d.Amount as `CASH OVER SHORT`,
a.AMOUNT as `CASH DEPOSIT`,
(SELECT SUM(gndrevn.AMOUNT) from gndrevn where gndrevn.ID= b.ID and
gndrevn.type = "4" group by gndrevn.DOB, gndrevn.ID) as `TRANSACTION COUNT (POS)`
FROM gndsale a
INNER JOIN emp b ON a.ID= b.ID
INNER JOIN gndsale c ON b.ID= c.ID
INNER JOIN gndsale d on b.ID = d.ID
INNER JOIN adjtime f on a.ID= f.ID
WHERE a.type = "22" AND c.type = "4" AND d.type = "42" and
STR_TO_DATE(a.DOB, '%m/%d/%Y') BETWEEN '2017-05-01' AND '2017-05-31' GROUP BY DECLARED
order by STR_TO_DATE(a.DOB, '%m/%d/%Y')

It returns this error:

I tried to remove  gndrevn.DOB, gndrevn.ID  and this is my result

The Column Transaction Count POS just added because it detected similar ID's in the table.

What the result I want for my Transaction Count POS is this:

I ran this with a different query, but it also requires a group by in a select statement

Here's the query:

SELECT ID as `EMPLOYEE`, sum(AMOUNT) as AMOUNT, DOB as DATE from gndrevn
where ID in (select ID from gndsale) and type = "4" group by
DOB, ID order by STR_TO_DATE(DOB, '%m/%d/%Y')

I think I have a problem with my group by statement to get the query. Anyone can help me on this? :(


问:
Issue with css and bootstrap grids
I'm kind of new at bootstrap, and I'm trying to practice this, I have a web is very simple I know, but I'm having troubles whith this, because The grid like It doesn't center the this, I already put the css, I don't know If you can tell me what it's going on, Be pacient with me I'm learning :(
If you be my guide I'll be so grateful

```<code><html>

<head>
    <meta charset="utf8"/>
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>Mountain at my Gates</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href='https://fonts.googleapis.com/css?family=Lato:400,300,700' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="css/normalize.css">
        <link rel="stylesheet" href="css/main.css">
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <link rel="stylesheet" href="css/font-awesome.min.css">
        <link rel="stylesheet" href="css/owl.carousel.css">
        <link rel="stylesheet" href="css/responsive.css">
        <link rel="stylesheet" href="css/style.css">

</head>

<body>
<header class="main_menu_sec navbar navbar-default navbar-fixed-top">
    <div class="container">
    <div class="row">
            <div class="col-lg-3 col-md-3 col-sm-12">
            <div class="lft_hd">
                    <a href="index.html"><img src="img/logo.png" alt=""/></a>
            </div>
            </div>

            <div class="col-lg-9 col-md-9 col-sm-12">
            <div class="rgt_hd">
            <div class="main_menu">
                <nav id="nav_menu">
                    <button aria-controls="navbar" aria-expanded="false" data-target="#navbar" data-toggle="collapse" class="navbar-toggle collapsed" type="button">
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                    </button>

                    <div id="navbar">
                            <ul>
                                <li><a class="page-scroll" href="index.html">Home</a></li>
                                <li><a class="page-scroll" href="#about">About</a></li>
                                <li><a class="page-scroll" href="#countsec">we</a></li>
                                <li><a class="page-scroll" href="#team">Team</a></li>
                                <li><a class="page-scroll" href="#contact">Contact Us</a></li>
                            </ul>
                        </div>
                </nav>
            </div>
            </div>
            </div>
    </div>
    </div>
</header>

<section id="slider_section">
<div class="container">
    <div class="row">
        <div class="slider">
            <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
            <ol class="carousel-indicators">
                    <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
                    <li data-target="#carousel-example-generic" data-slide-to="1"></li>
                    <li data-target="#carousel-example-generic" data-slide-to="2"></li>
                  </ol>

                  <!--- wrapper -->
                  <div class="carousel-inner" role="listbox">

                    <div class="item active">
                        <div class="wrap_caption">
                                 <div class="caption_carousel">
                                    <h1>I see a Mountain at my gates </h1>
                                    <p>I see more and more each day</p>
                                </div>
                        </div>
                </div>

                <div class="item">
                        <div class="wrap_caption">
                          <div class="caption_carousel">
                            <h1>What I give, it takes away</h1>
                            <p>Whether I go or when I stay</p>
                          </div>
                        </div>
                    </div>

                    <div class="item">
                        <div class="wrap_caption">
                          <div class="caption_carousel">
                            <h1>I see a mountain in my way</h1>
                            <p>It's looming larger by the day</p>
                          </div>
                        </div>
                    </div>

        </div>

        <a class="left left_crousel_btn" href="#carousel-example-generic" role="button" data-slide="prev">
                    <i class="fa fa-angle-left"></i>
                    <span class="sr-only">Previous</span>
                  </a>
                  <a class="right right_crousel_btn" href="#carousel-example-generic" role="button" data-slide="next">
                    <i class="fa fa-angle-right"></i>
                    <span class="sr-only">Next</span>
                  </a>

    </div>

</div>
</div>
</div>
</section>

<section id="about">
<div class="container">
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs12 ">
                <div class="title_sec">
                    <h1>ABOUT</h1>
                    <h2>Mountain at my gates</h2>
                </div>
            </div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs12 ">
                <div class="abt">
                    <p>I see it more and more each day What I give, it takes away Whether I go or when I stay </p>
                </div>
            </div>
        </div>
    </div>
</section>

<section id="countsec">
        <div class="container">
            <div class="row">

                <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">

                    <div class="count">
                    <i class="fa fa-user"></i>
                    <h2 class="counter">1994</h2>
                    <h4>I see a Mountain at my gates</h4>
                    </div>
                </div>

                <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                        <div class="count">
                        <i class="fa fa-desktop"></i>
                        <h2 class="counter">21</h2>
                        <h4>I see it more and more each day</h4>
                        </div>
                </div>

                <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                    <div class="count">
                        <i class="fa fa-ticket"></i>
                        <h2 class="counter">02</h2>
                        <h4>It takes away </h4>
                    </div>
                </div>

                <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                    <div class="count">
                        <i class="fa fa-clock-o"></i>
                        <h2 class="counter">05</h2>
                        <h4>My mountain</h4>
                    </div>
                </div>

            </div>
        </div>

</section>

<section id="serv">
    <div class="container">
        <div class="row">

            <div class="col-lg-12 col-md-12 col-sm-12 col-xs12 ">
                <div class="title_sec">
                    <h1>Mountain at my gates</h1>
                    <h2>I see it more and more each day</h2>
                </div>
            </div>

            <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <div class="service">
                    <i class="fa fa-globe"></i>
                    <h2>web Development</h2>
                    <div class="service_hoverly">
                        <i class="fa fa-globe"></i>
                        <h2>web Development</h2>
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ab odio quas  , voluptate aspernatur!</p>
                    </div>
                </div>
            </div>

            <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <div class="service">
                    <i class="fa fa-paper-plane"></i>
                    <h2>E-mail marketing</h2>
                    <div class="service_hoverly">
                        <i class="fa fa-paper-plane"></i>
                        <h2>E-mail marketing</h2>
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ab odio quas  , voluptate aspernatur!</p>
                    </div>
                </div>
            </div>

            <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <div class="service">
                    <i class="fa fa-wordpress"></i>
                    <h2>WordPress</h2>
                    <div class="service_hoverly">
                        <i class="fa fa-wordpress"></i>
                        <h2>WordPress</h2>
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ab odio quas  , voluptate aspernatur!</p>
                    </div>
                </div>
            </div>

            <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <div class="service">
                    <i class="fa fa-paint-brush"></i>
                    <h2>Graphic Design</h2>
                    <div class="service_hoverly">
                        <i class="fa fa-paint-brush"></i>
                        <h2>Graphic Design</h2>
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ab odio quas  , voluptate aspernatur!</p>
                    </div>
                </div>
            </div>
    </div>
</section>

<section id="team">
    <div class="container">
        <div class="row">
        <div class="col-lg-12 col-md-12 col-sm-12 col-xs12 ">
                <div class="title_sec">
                    <h1>Team</h1>
                    <h2>Mountain</h2>
                </div>
        </div>
        <div class="col-lg-12 col-md-12 col-sm-12 col-xs12">
                <div class="all_team">

                    <div class="sngl_team">
                        <img src="http://wedesignthemes.com/themes/dt-mountcool/wp-content/uploads/2015/10/img-1.png" alt=""/>
                        <h3> Jamie Catllahan <span>Designer</span></h3>
                        <p>Lorem ipsum dolor sit amet, consecttur adipisicing elit. Laudant</p>
                </div>
                    <div class="sngl_team">
                        <img src="http://wedesignthemes.com/themes/dt-mountcool/wp-content/uploads/2015/10/img-2.png" alt=""/>
                        <h3>Lisa Kudrow <span> Manager </span></h3>
                        <p>Lorem ipsum dolor sit amet, consecttur adipisicing elit. Laudant</p>
                    </div>
                    <div class="sngl_team">
                        <img src="http://wedesignthemes.com/themes/dt-mountcool/wp-content/uploads/2015/10/img-3.png" alt=""/>
                        <h3> John Clarance <span>   Senior Manager   </span></h3>
                        <p>Lorem ipsum dolor sit amet, consecttur adipisicing elit. Laudant</p>
                    </div>

        </div>
    </div>
</section>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
        <script src="js/vendor/jquery-1.11.2.min.js"></script>

<script src="js/isotope.pkgd.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery-ui.js"></script>
<script src="js/appear.js"></script>
<script src="js/jquery.counterup.min.js"></script>
<script src="js/waypoints.min.js"></script>
<script src="js/owl.carousel.min.js"></script>
<script src="js/showHide.js"></script>
<script src="js/jquery.nicescroll.min.js"></script>
<script src="js/jquery.easing.min.js"></script>
<script src="js/scrolling-nav.js"></script>
<script src="js/plugins.js"></script>

<script>
    jQuery(document).ready(function( $ ) {
        $('.counter').counterUp({
            delay: 10,
            time: 1000
        });
    });
</script>

</body>
</html>
</code>```

and my css

```<code>body {

background : #fff;
}

body p {
color : #666666;
font-family : "Lato", sans-serif;
font-size : 14px;
letter-spacing : 1px;
}
body h1, h2, h3, h4, h5, h6 {
color : #141414;
font-family : "Lato", sans-serif;
font-size : 18px;
text-transform : capitalize;
font-weight : 800;
text-transform : uppercase;
}

a:hover {
text-decoration : none;
}
.navbar {
padding : 10px 0;
transition : background 0.5s ease-in-out, padding 0.5s ease-in-out;
}

#nav_menu ul {
float : right;
list-style : none outside none;
margin : 0;
padding : 0;
position : relative;
}
#nav_menu ul a {
color : #ffffff;
display : block;
font-family : lato;
font-size : 14px;
font-weight : bold;
line-height : 32px;
padding : 25px 14px;
text-decoration : none;
text-transform : capitalize;
transition : all 0.4s 0s ease;
}
#nav_menu ul li {
float : left;
padding : 0;
position : relative;
}
#nav_menu ul li a:hover {
transition : all 0.4s 0s ease;
background : #0078BF;
}
#nav_menu ul ul {
background : none 0 0 repeat scroll #0078bf;
display : none;
left : 0;
padding : 0;
position : absolute;
top : 100%;
z-index : 9999;
padding : 10px;
}
#nav_menu ul ul li {
float : none;
width : 200px;
}
#nav_menu ul ul a {
line-height : 120%;
padding : 10px 29px;
}
#nav_menu ul ul li a:hover {
transition : all 0.4s 0s ease;
background : #333333;
}
#nav_menu ul ul ul {
top : 0;
left : 100%;
}
#nav_menu ul li:hover > ul {
display : block;
}
#nav_menu ul li a i {
margin-left : 6px;
}

.title_sec {
margin : 0 auto;
padding : 0 0 25px 0;
text-align : center;
}
.title_sec h2 {
color : #606060;
font-size : 12px;
text-transform : uppercase;
letter-spacing : 1px;
}

.wrap_caption {
padding : 190px 0;
}
.slider {
display : block;
text-align : center;
vertical-align : middle;
width : 100%;
}
#slider_sec {
background-image : url(".../img/fnd.jpg");
background-position : center center;
background-repeat : no-repeat;
background-size : 100% 100%;
height : 100%;
width : 100%;
}
.left_crousel_btn, .right_crousel_btn {
color : #fff;
height : 20px;
position : absolute;
text-align : center;
top : 50%;
width : 20px;
font-size : 25px;
font-weight : normal;
}
.caption_carousel h1 {
font-family : lato;
font-size : 60px;
text-transform : capitalize;
color : #fff;
}
.caption_carousel p {
font-family : lato;
font-size : 14px;
color : #f6f6f6;
border-top : 1px solid #fff;
border-bottom : 1px solid #fff;
display : inline;
line-height : 35px;
padding : 8px;
}
.caption_carousel {
display : table-cell;
text-align : center;
vertical-align : middle;
height : 100%;
width : 100%;
margin : 0 auto;
display : block;
}
.carousel-indicators li {
background-color : #363636;
border : none medium;
border-radius : 5px;
cursor : pointer;
display : inline-block;
height : 6px;
text-indent : 0;
width : 25px;
}
.carousel-indicators .active {
width : 25px;
height : 7px;
background-color : #00AFF0;
}

.wrap_caption {
padding : 190px 0;
}

#about {
padding : 70px 0;
}

#countsec {
background : none 0 0 repeat scroll #f0f0f0;
padding : 90px 0;
}
.count h2 {
color : #515050;
font-size : 48px;
}
.count h4 {
font-size : 18px;
color : #515050;
text-transform : uppercase;
font-weight : 300;
}
.count {
text-align : center;
}
.count i {
color : #515050;
float : left;
font-size : 35px;
margin-top : 10px;
}
#pr_sec {
padding : 70px 0;
}

#pr_sec {
padding : 70px 0;
}
.serv {

transition: all 1s ease 0s;
-moz-transition: all 1s ease 0s;
-webkit-transition: all 1s ease 0s;border :1px solid #eeeeee;
cursor : pointer;
text-align : center;
padding : 61px 0;

}
.service:hover .service_hoverly {
display : block;
}
.service > h2 {
color : #515050;
font-size : 14px;
font-weight : 400;
text-transform : uppercase;
}
.service_hoverly h2 {
color : #515050;
font-size : 14px;
font-weight : 400;
text-transform : uppercase;
margin : 0;
padding-bottom : 30px;
}
.service i {
font-size : 50px;
color : #03B0F0;
position : relative;
}
.service_hoverly {

transition: all 1s ease 0s;
    -moz-transition: all 1s ease 0s;
    -webkit-transition: all 1s ease 0s;border :1px solid #03B0F0;
display : none;
padding : 25px 5px;
position : absolute;
top : 0;
background : #fff;
}
.service_hoverly i {
background : none 0 0 repeat scroll #fff;
font-size : 50px;
position : relative;
top : -50px;
}

#team {
padding : 70px 0;
}
.sngl_team h3 {
font-size : 14px;
text-transform : uppercase;
color : #333333;
}
.sngl_team {
text-align : center;
width : 100%;
}
.owl-item .sngl_team img {
margin : 0 auto;
text-align : center;
width : 130px;
}
.sngl_team span {
color : #00aff0;
font-family : lato;
font-size : 13px;
margin-left : 10px;
text-transform : uppercase;
}
.all_team .owl-controls .owl-prev i {
color : #3399ff;
font-size : 30px;
position : absolute;
top : 46%;
left : 0;
}
.all_team .owl-controls .owl-next i {
position : absolute;
top : 46%;
font-size : 30px;
color : #3399FF;
right : 0%;
}
.all_team .owl-controls .owl-dot {
background-color : #363636;
border : none medium;
border-radius : 5px;
cursor : pointer;
display : inline-block;
height : 6px;
text-indent : 0;
width : 25px;
margin-right : 5px;
}
.all_team .owl-controls .owl-dot.active {
background-color : #03B0F0;
}
.all_team .owl-controls {
display : inline-block;
width : 100%;
text-align : center;
}
</code>```

答:
If you use the
    col-offset-*

in Bootstrap it will offset the column. So if you want a col-md-8 centered you would do something like:

```<code><div class ="col-md-8 col-md-offset-2"></div>
</code>```

That should center you div. But you have to figure out based on the size of the div and size fo the viewport what the offset should be.

Note: it will offset the column on both sides this way.

Title: Issue with css and bootstrap grids

Body:
I'm kind of new at bootstrap, and I'm trying to practice this, I have a web is very simple I know, but I'm having troubles whith this, because The grid like It doesn't center the this, I already put the css, I don't know If you can tell me what it's going on, Be pacient with me I'm learning :(
If you be my guide I'll be so grateful

    <meta charset="utf8"/>
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>Mountain at my Gates</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href='https://fonts.googleapis.com/css?family=Lato:400,300,700' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="css/normalize.css">
        <link rel="stylesheet" href="css/main.css">
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <link rel="stylesheet" href="css/font-awesome.min.css">
        <link rel="stylesheet" href="css/owl.carousel.css">
        <link rel="stylesheet" href="css/responsive.css">
        <link rel="stylesheet" href="css/style.css">

                    <button aria-controls="navbar" aria-expanded="false" data-target="#navbar" data-toggle="collapse" class="navbar-toggle collapsed" type="button">

                    </button>

Home

About

we

Team

Contact Us

I see a Mountain at my gates

I see more and more each day

What I give, it takes away

Whether I go or when I stay

I see a mountain in my way

It's looming larger by the day

                    Previous

                    Next

ABOUT

Mountain at my gates

I see it more and more each day What I give, it takes away Whether I go or when I stay

1994

I see a Mountain at my gates

21

I see it more and more each day

02

It takes away

05

My mountain

Mountain at my gates

I see it more and more each day

web Development

web Development

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ab odio quas  , voluptate aspernatur!

E-mail marketing

E-mail marketing

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ab odio quas  , voluptate aspernatur!

WordPress

WordPress

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ab odio quas  , voluptate aspernatur!

Graphic Design

Graphic Design

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore ab odio quas  , voluptate aspernatur!

Team

Mountain

 Jamie Catllahan Designer

Lorem ipsum dolor sit amet, consecttur adipisicing elit. Laudant

Lisa Kudrow  Manager

Lorem ipsum dolor sit amet, consecttur adipisicing elit. Laudant

 John Clarance    Senior Manager

Lorem ipsum dolor sit amet, consecttur adipisicing elit. Laudant

and my css

body {

background : #fff;
}

body p {
color : #666666;
font-family : "Lato", sans-serif;
font-size : 14px;
letter-spacing : 1px;
}
body h1, h2, h3, h4, h5, h6 {
color : #141414;
font-family : "Lato", sans-serif;
font-size : 18px;
text-transform : capitalize;
font-weight : 800;
text-transform : uppercase;
}

a:hover {
text-decoration : none;
}
.navbar {
padding : 10px 0;
transition : background 0.5s ease-in-out, padding 0.5s ease-in-out;
}

#nav_menu ul {
float : right;
list-style : none outside none;
margin : 0;
padding : 0;
position : relative;
}
#nav_menu ul a {
color : #ffffff;
display : block;
font-family : lato;
font-size : 14px;
font-weight : bold;
line-height : 32px;
padding : 25px 14px;
text-decoration : none;
text-transform : capitalize;
transition : all 0.4s 0s ease;
}
#nav_menu ul li {
float : left;
padding : 0;
position : relative;
}
#nav_menu ul li a:hover {
transition : all 0.4s 0s ease;
background : #0078BF;
}
#nav_menu ul ul {
background : none 0 0 repeat scroll #0078bf;
display : none;
left : 0;
padding : 0;
position : absolute;
top : 100%;
z-index : 9999;
padding : 10px;
}
#nav_menu ul ul li {
float : none;
width : 200px;
}
#nav_menu ul ul a {
line-height : 120%;
padding : 10px 29px;
}
#nav_menu ul ul li a:hover {
transition : all 0.4s 0s ease;
background : #333333;
}
#nav_menu ul ul ul {
top : 0;
left : 100%;
}
#nav_menu ul li:hover > ul {
display : block;
}
#nav_menu ul li a i {
margin-left : 6px;
}

.title_sec {
margin : 0 auto;
padding : 0 0 25px 0;
text-align : center;
}
.title_sec h2 {
color : #606060;
font-size : 12px;
text-transform : uppercase;
letter-spacing : 1px;
}

.wrap_caption {
padding : 190px 0;
}
.slider {
display : block;
text-align : center;
vertical-align : middle;
width : 100%;
}
#slider_sec {
background-image : url(".../img/fnd.jpg");
background-position : center center;
background-repeat : no-repeat;
background-size : 100% 100%;
height : 100%;
width : 100%;
}
.left_crousel_btn, .right_crousel_btn {
color : #fff;
height : 20px;
position : absolute;
text-align : center;
top : 50%;
width : 20px;
font-size : 25px;
font-weight : normal;
}
.caption_carousel h1 {
font-family : lato;
font-size : 60px;
text-transform : capitalize;
color : #fff;
}
.caption_carousel p {
font-family : lato;
font-size : 14px;
color : #f6f6f6;
border-top : 1px solid #fff;
border-bottom : 1px solid #fff;
display : inline;
line-height : 35px;
padding : 8px;
}
.caption_carousel {
display : table-cell;
text-align : center;
vertical-align : middle;
height : 100%;
width : 100%;
margin : 0 auto;
display : block;
}
.carousel-indicators li {
background-color : #363636;
border : none medium;
border-radius : 5px;
cursor : pointer;
display : inline-block;
height : 6px;
text-indent : 0;
width : 25px;
}
.carousel-indicators .active {
width : 25px;
height : 7px;
background-color : #00AFF0;
}

.wrap_caption {
padding : 190px 0;
}

#about {
padding : 70px 0;
}

#countsec {
background : none 0 0 repeat scroll #f0f0f0;
padding : 90px 0;
}
.count h2 {
color : #515050;
font-size : 48px;
}
.count h4 {
font-size : 18px;
color : #515050;
text-transform : uppercase;
font-weight : 300;
}
.count {
text-align : center;
}
.count i {
color : #515050;
float : left;
font-size : 35px;
margin-top : 10px;
}
#pr_sec {
padding : 70px 0;
}

#pr_sec {
padding : 70px 0;
}
.serv {

transition: all 1s ease 0s;
-moz-transition: all 1s ease 0s;
-webkit-transition: all 1s ease 0s;border :1px solid #eeeeee;
cursor : pointer;
text-align : center;
padding : 61px 0;

}
.service:hover .service_hoverly {
display : block;
}
.service > h2 {
color : #515050;
font-size : 14px;
font-weight : 400;
text-transform : uppercase;
}
.service_hoverly h2 {
color : #515050;
font-size : 14px;
font-weight : 400;
text-transform : uppercase;
margin : 0;
padding-bottom : 30px;
}
.service i {
font-size : 50px;
color : #03B0F0;
position : relative;
}
.service_hoverly {

transition: all 1s ease 0s;
    -moz-transition: all 1s ease 0s;
    -webkit-transition: all 1s ease 0s;border :1px solid #03B0F0;
display : none;
padding : 25px 5px;
position : absolute;
top : 0;
background : #fff;
}
.service_hoverly i {
background : none 0 0 repeat scroll #fff;
font-size : 50px;
position : relative;
top : -50px;
}

#team {
padding : 70px 0;
}
.sngl_team h3 {
font-size : 14px;
text-transform : uppercase;
color : #333333;
}
.sngl_team {
text-align : center;
width : 100%;
}
.owl-item .sngl_team img {
margin : 0 auto;
text-align : center;
width : 130px;
}
.sngl_team span {
color : #00aff0;
font-family : lato;
font-size : 13px;
margin-left : 10px;
text-transform : uppercase;
}
.all_team .owl-controls .owl-prev i {
color : #3399ff;
font-size : 30px;
position : absolute;
top : 46%;
left : 0;
}
.all_team .owl-controls .owl-next i {
position : absolute;
top : 46%;
font-size : 30px;
color : #3399FF;
right : 0%;
}
.all_team .owl-controls .owl-dot {
background-color : #363636;
border : none medium;
border-radius : 5px;
cursor : pointer;
display : inline-block;
height : 6px;
text-indent : 0;
width : 25px;
margin-right : 5px;
}
.all_team .owl-controls .owl-dot.active {
background-color : #03B0F0;
}
.all_team .owl-controls {
display : inline-block;
width : 100%;
text-align : center;
}

Body:
If you use the
    col-offset-*

in Bootstrap it will offset the column. So if you want a col-md-8 centered you would do something like:

<div class ="col-md-8 col-md-offset-2"></div>

That should center you div. But you have to figure out based on the size of the div and size fo the viewport what the offset should be.

Note: it will offset the column on both sides this way.


问:
Attempting two pass two objects through @PathVariable in thymeleaf/spring-boot
I'm attempting to pull two parameters with the @PathVariable annotation but have been unsuccessful due to java throwing me an error about it referencing the item id (which I currently has as an Long) as a String.

Controller:

```<code>@PostMapping("/purchaseToner/{tid}/{bid}")
    public String buyToner(Model model, @PathVariable("tid") Long tid,
                           @PathVariable("bid") Long bid){

        //Grab info
        Buyer mBuyer = buyerService.findOne(bid);
        Toner mToner = tonerService.findOneToner(tid);

        //Updating qualities
        mToner.setTonerQuantity(mToner.getTonerQuantity() - 1);
        mBuyer.setBalance(mBuyer.getBalance() - mToner.getTonerPrice());

        Buyer iBuyer = new Buyer();
        iBuyer.getToners().add(mToner);

        return "redirect:/";
    }
</code>```

View:

```<code> <form th:action="@{/purchaseToner/{tid}(tid=${toner.id})/{bid}(bid=${buyer.buyerId})}" th:object="${buyer}" method="post">
                       <select th:object="${toner}">
                            <option>Select a Toner</option>
                            <option th:each="toner : ${toners}"
                                    th:text="${toner.tonerName}"
                                    th:value="${toner.id}">
                            </option>
                       </select>
                        <input type="hidden" name="buyerId"/>
                        <input type="submit" value="Purchase" onclick="return confirm('Are you sure you want to make this purchase?')"/>
                    </form>
</code>```

Print Trace:

```<code>2017-06-05 21:10:59.418  INFO 788 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-06-05 21:10:59.517  INFO 788 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-06-05 21:10:59.527  INFO 788 --- [           main] com.ronone.Application                   : Started Application in 18.596 seconds (JVM running for 19.548)
2017-06-05 21:11:06.438  INFO 788 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2017-06-05 21:11:06.439  INFO 788 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2017-06-05 21:11:06.470  INFO 788 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 31 ms
2017-06-05 21:11:09.673  INFO 788 --- [nio-8080-exec-2] o.h.h.i.QueryTranslatorFactoryInitiator  : HHH000397: Using ASTQueryTranslatorFactory
2017-06-05 21:11:15.837  WARN 788 --- [nio-8080-exec-3] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to bind request element: org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long'; nested exception is java.lang.NumberFormatException: For input string: "{tid}(tid=${toner.id})"
</code>```

答:
Change th:action to following

```<code><form th:action="@{/purchaseToner/{tid}/{bid}(tid=${toner.id},bid=${buyer.buyerId})}" th:object="${buyer}" method="post">
</code>```

Also, you need to add toner to spring model. In your code, It is not in the model

Body:
I'm attempting to pull two parameters with the @PathVariable annotation but have been unsuccessful due to java throwing me an error about it referencing the item id (which I currently has as an Long) as a String.

Controller:

@PostMapping("/purchaseToner/{tid}/{bid}")
    public String buyToner(Model model, @PathVariable("tid") Long tid,
                           @PathVariable("bid") Long bid){

        //Grab info
        Buyer mBuyer = buyerService.findOne(bid);
        Toner mToner = tonerService.findOneToner(tid);

        //Updating qualities
        mToner.setTonerQuantity(mToner.getTonerQuantity() - 1);
        mBuyer.setBalance(mBuyer.getBalance() - mToner.getTonerPrice());

        Buyer iBuyer = new Buyer();
        iBuyer.getToners().add(mToner);

        return "redirect:/";
    }

View:

 <form th:action="@{/purchaseToner/{tid}(tid=${toner.id})/{bid}(bid=${buyer.buyerId})}" th:object="${buyer}" method="post">
                       <select th:object="${toner}">
                            <option>Select a Toner</option>
                            <option th:each="toner : ${toners}"
                                    th:text="${toner.tonerName}"
                                    th:value="${toner.id}">
                            </option>
                       </select>
                        <input type="hidden" name="buyerId"/>
                        <input type="submit" value="Purchase" onclick="return confirm('Are you sure you want to make this purchase?')"/>
                    </form>

Print Trace:

2017-06-05 21:10:59.418  INFO 788 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-06-05 21:10:59.517  INFO 788 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-06-05 21:10:59.527  INFO 788 --- [           main] com.ronone.Application                   : Started Application in 18.596 seconds (JVM running for 19.548)
2017-06-05 21:11:06.438  INFO 788 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2017-06-05 21:11:06.439  INFO 788 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2017-06-05 21:11:06.470  INFO 788 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 31 ms
2017-06-05 21:11:09.673  INFO 788 --- [nio-8080-exec-2] o.h.h.i.QueryTranslatorFactoryInitiator  : HHH000397: Using ASTQueryTranslatorFactory
2017-06-05 21:11:15.837  WARN 788 --- [nio-8080-exec-3] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to bind request element: org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long'; nested exception is java.lang.NumberFormatException: For input string: "{tid}(tid=${toner.id})"

Body:
Change th:action to following

<form th:action="@{/purchaseToner/{tid}/{bid}(tid=${toner.id},bid=${buyer.buyerId})}" th:object="${buyer}" method="post">

Also, you need to add toner to spring model. In your code, It is not in the model


问:
How can I move the caption on top in a jQuery Mobile ListView
Given the example jquery mobile listview form

```<code><form>
    <ul data-role="listview" data-inset="true">
        <li data-role="fieldcontain">
            <label for="name2">Text Input:</label>
            <input type="text" name="name2" id="name2" value="" data-clear-btn="true">
        </li>
        <li data-role="fieldcontain">
            <label for="textarea2">Textarea:</label>
        <textarea cols="40" rows="8" name="textarea2" id="textarea2"></textarea>
        </li>
        <li data-role="fieldcontain">
            <label for="flip2">Flip switch:</label>
            <select name="flip2" id="flip2" data-role="slider">
                <option value="off">Off</option>
                <option value="on">On</option>
            </select>
        </li>
        <li data-role="fieldcontain">
            <label for="slider2">Slider:</label>
            <input type="range" name="slider2" id="slider2" value="0" min="0" max="100" data-highlight="true">
        </li>
        <li data-role="fieldcontain">
            <label for="select-choice-1" class="select">Choose shipping method:</label>
            <select name="select-choice-1" id="select-choice-1">
                <option value="standard">Standard: 7 day</option>
                <option value="rush">Rush: 3 days</option>
                <option value="express">Express: next day</option>
                <option value="overnight">Overnight</option>
            </select>
        </li>
        <li class="ui-body ui-body-b">
            <fieldset class="ui-grid-a">
                    <div class="ui-block-a"><button type="submit" data-theme="d">Cancel</button></div>
                    <div class="ui-block-b"><button type="submit" data-theme="a">Submit</button></div>
            </fieldset>
        </li>
    </ul>
</form>
</code>```

How can I move the captions above the form elements?

My reason is that I have a thin list view inside (what used to be) a jQuery panel. I'm avoiding using true jqm panels because of issues with having multiple panels open at once, on a desktop app.

I'm using listviews so I can add grouping lines to the form, to increase readability.

答: Remove data-role="fieldcontain" from your li elements

Body:
Given the example jquery mobile listview form

<form>

            Text Input:
            <input type="text" name="name2" id="name2" value="" data-clear-btn="true">

            Textarea:
        <textarea cols="40" rows="8" name="textarea2" id="textarea2"></textarea>

            Flip switch:
            <select name="flip2" id="flip2" data-role="slider">
                <option value="off">Off</option>
                <option value="on">On</option>
            </select>

            Slider:
            <input type="range" name="slider2" id="slider2" value="0" min="0" max="100" data-highlight="true">

            Choose shipping method:
            <select name="select-choice-1" id="select-choice-1">
                <option value="standard">Standard: 7 day</option>
                <option value="rush">Rush: 3 days</option>
                <option value="express">Express: next day</option>
                <option value="overnight">Overnight</option>
            </select>

            <fieldset class="ui-grid-a">

<button type="submit" data-theme="d">Cancel</button>

<button type="submit" data-theme="a">Submit</button>

            </fieldset>

</form>

How can I move the captions above the form elements?

My reason is that I have a thin list view inside (what used to be) a jQuery panel. I'm avoiding using true jqm panels because of issues with having multiple panels open at once, on a desktop app.

I'm using listviews so I can add grouping lines to the form, to increase readability.


问:
A script to copy files from folders with a specific file and folder names
First, I should mention that have a windows machine.

Now, I want to copy files that have until as some part of their file names.

I have a folder named my data. I have several folders in it where they have four digits in the end of their names, such as my_folder_0000. I would like to find these folders, and copy the file with until being some part of their file names into another folder.

To clarify, please see the following example to better understand the structure:

```<code>my data/
   |-- /my_folder_0000/my_file_until_2010.csv
   |-- /his_folder_0001/his_file_until_2011.csv
   |-- /test
   |-- /documents
</code>```

In the above example, I would like to go through the first two folders, copy the files into my folder on desktop.

I would like to have a script which works for windows. Thank you!

答:
This should give you an idea how to do it:

```<code>@echo off& setlocal
for /d %%d in ("%~1\*.*") do set dir=%%d& call :next_dir %2
exit /b

:next_dir
for /f "delims=0123456789" %%i in ("%dir:~-4%") do exit /b
copy /y "%dir%\*until*.*" %1 | find "until"
</code>```

At command line 1st arg is source directory (perhaps "\my data" in your case) and 2nd argument is destination directory for the copied files.

Existing/duplicate-named files are overwritten in destination without prompting.  Filenames are displayed as they are copied.

Body:
First, I should mention that have a windows machine.

Now, I want to copy files that have until as some part of their file names.

I have a folder named my data. I have several folders in it where they have four digits in the end of their names, such as my_folder_0000. I would like to find these folders, and copy the file with until being some part of their file names into another folder.

To clarify, please see the following example to better understand the structure:

my data/
   |-- /my_folder_0000/my_file_until_2010.csv
   |-- /his_folder_0001/his_file_until_2011.csv
   |-- /test
   |-- /documents

In the above example, I would like to go through the first two folders, copy the files into my folder on desktop.

I would like to have a script which works for windows. Thank you!

Body:
This should give you an idea how to do it:

@echo off& setlocal
for /d %%d in ("%~1\*.*") do set dir=%%d& call :next_dir %2
exit /b

:next_dir
for /f "delims=0123456789" %%i in ("%dir:~-4%") do exit /b
copy /y "%dir%\*until*.*" %1 | find "until"

At command line 1st arg is source directory (perhaps "\my data" in your case) and 2nd argument is destination directory for the copied files.

Existing/duplicate-named files are overwritten in destination without prompting.  Filenames are displayed as they are copied.


问:
Run Mozart/Oz system within GNU Emacs on OSX instead of Aquamacs
Is it possible to make Mozart/Oz system run within GNU Emacs on OSX instead of Aquamacs which I dislike? I tried copying /Applications/Emacs to /Applications/Aquamacs but had no luck.</p>

答:
The problem here is that the Mozart application uses shell scripts that are hard-coded to look for /Applications/Aquamacs Emacs.app. Some of these scripts also attempt to use /Applications/Aquamacs.app or /Applications/Emacs.app, but do not consistently use both. (This is why Tvaroh's answer works: the script located in /Applications/Mozart.app/Contents/Resources/bin/oz is able to use GNU Emacs. It's also why the attempt to change the name of Emacs.app to Aquamacs.app did not fix the issue. Renaming Emacs.app to Aquamacs Emacs.app should work, but I'd recommend using the solution written below instead.)

The fix is fairly simple: just modify the shell scripts so that they use Emacs rather than Aquamacs. Entering the following lines in Terminal appears to fix the issue for the latest build (1.4.0-2012-02-01-macosx):

```<code>$ sed -i '' -e "s/Aquamacs\\\ Emacs/Emacs/g" /Applications/Mozart.app/Contents/Resources/.script
$ sed -i '' -e "s/Aquamacs Emacs/Emacs/g" /Applications/Mozart.app/Contents/Resources/.script
$ sed -i '' -e "s/Aquamacs\\\ Emacs/Emacs/g" /Applications/Mozart.app/Contents/Resources/script
$ sed -i '' -e "s/Aquamacs Emacs/Emacs/g" /Applications/Mozart.app/Contents/Resources/script
</code>```

With that said, I'd encourage anyone who encounters this problem to search their distribution for other offending files ($ grep -ir aquamacs /Applications/Mozart.app) and modify those files as necessary to ensure that Mozart will use the correct Emacs.

A couple of notes about this answer for anyone else who comes across this issue:

For this to work there needs to be an Emacs.app in the Applications directory (e.g. just having a the copy of Emacs that comes with macOS/OS X is not sufficient for this solution to work, although it should be possible to edit the scripts within Mozart.app to run using that Emacs binary.)

This issue only exists in builds of Mozart 1.x for macOS/OS X. As of Mozart 2.0.0, the program runs as is, without having to install Aquamacs, as long as some form of Emacs is already located in /Applications/Emacs.app.

Body:
The problem here is that the Mozart application uses shell scripts that are hard-coded to look for /Applications/Aquamacs Emacs.app. Some of these scripts also attempt to use /Applications/Aquamacs.app or /Applications/Emacs.app, but do not consistently use both. (This is why Tvaroh's answer works: the script located in /Applications/Mozart.app/Contents/Resources/bin/oz is able to use GNU Emacs. It's also why the attempt to change the name of Emacs.app to Aquamacs.app did not fix the issue. Renaming Emacs.app to Aquamacs Emacs.app should work, but I'd recommend using the solution written below instead.)

The fix is fairly simple: just modify the shell scripts so that they use Emacs rather than Aquamacs. Entering the following lines in Terminal appears to fix the issue for the latest build (1.4.0-2012-02-01-macosx):

$ sed -i '' -e "s/Aquamacs\\\ Emacs/Emacs/g" /Applications/Mozart.app/Contents/Resources/.script
$ sed -i '' -e "s/Aquamacs Emacs/Emacs/g" /Applications/Mozart.app/Contents/Resources/.script
$ sed -i '' -e "s/Aquamacs\\\ Emacs/Emacs/g" /Applications/Mozart.app/Contents/Resources/script
$ sed -i '' -e "s/Aquamacs Emacs/Emacs/g" /Applications/Mozart.app/Contents/Resources/script

With that said, I'd encourage anyone who encounters this problem to search their distribution for other offending files ($ grep -ir aquamacs /Applications/Mozart.app) and modify those files as necessary to ensure that Mozart will use the correct Emacs.

A couple of notes about this answer for anyone else who comes across this issue:

For this to work there needs to be an Emacs.app in the Applications directory (e.g. just having a the copy of Emacs that comes with macOS/OS X is not sufficient for this solution to work, although it should be possible to edit the scripts within Mozart.app to run using that Emacs binary.)

This issue only exists in builds of Mozart 1.x for macOS/OS X. As of Mozart 2.0.0, the program runs as is, without having to install Aquamacs, as long as some form of Emacs is already located in /Applications/Emacs.app.


问:
Why isn't my SELECT tag's value being submitted via AJAX post request?
Here is a sample of my HTML:

```<code><form class="form-horizontal" action="#" id="sendstuff">
  <select name="some_name">
    <option value="somevalue1">test value1</option>
    <option value="somevalue2">test value2</option>
    <option value="somevalue3">test value3</option>
  </select>
  <button id="sb_btn"> Submit </button>
</form>
</code>```

Here is the AJAX code:

```<code>$('#sb_btn').on('click', function() {
  $.ajax({
      type: 'post',
      url: 'some_url',
      data: $('#sendstuff').serialize()
    })
    .done(function(data) {
      data = jQuery.parseJSON(data);
      alert(data.some_name);
    });
});
</code>```

Here is PHP script that gets called:

```<code>$data['some_name'] = $this->input->post('some_name')//i'm using codeigniter;
echo json_encode($data);
</code>```

Yet, I get a null value for the select input.

EDIT
Any help is greatly appreciated guys.  I still haven't figured out what is wrong.

EDIT
Not sure if there are any codeigniter experts on this post, BUT I solved it.  It was because for some reason codeigniter's '$this->input->post('somename')' method was not properly working.  As soon all the codeigniter's input commands to '$_POST['somename']', it solved the problem.  Here is the revised(WORKING) PHP script code:

```<code>$data['some_name'] = $_POST['some_name'];
    echo json_encode($data);
</code>```

答:
Home File

```<code><!DOCTYPE html>
<html>
<head>
    <title>Home Page</title>
    <script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>
<form class="form-horizontal" action="#" id="sendstuff">
  <select name="some_name">
    <option value="somevalue1">test value1</option>
    <option value="somevalue2">test value2</option>
    <option value="somevalue3">test value3</option>
  </select>
  <button id="sb_btn"> Submit </button>
</form>
<script type="text/javascript">
$('#sb_btn').on('click', function() {

  $.ajax({
      type: 'post',
      url: 'index.php',
      data: $('#sendstuff').serialize()
    })
    .done(function(data) {
      data = jQuery.parseJSON(data);
      alert(data.some_name);
    });
    return false;
});
</script>
</body>
</html>
</code>```

Ajax FIle

$data['some_name'] = $_POST['some_name'];

echo json_encode($data);

Body:
Here is a sample of my HTML:

<form class="form-horizontal" action="#" id="sendstuff">
  <select name="some_name">
    <option value="somevalue1">test value1</option>
    <option value="somevalue2">test value2</option>
    <option value="somevalue3">test value3</option>
  </select>
  <button id="sb_btn"> Submit </button>
</form>

Here is the AJAX code:

$('#sb_btn').on('click', function() {
  $.ajax({
      type: 'post',
      url: 'some_url',
      data: $('#sendstuff').serialize()
    })
    .done(function(data) {
      data = jQuery.parseJSON(data);
      alert(data.some_name);
    });
});

Here is PHP script that gets called:

$data['some_name'] = $this->input->post('some_name')//i'm using codeigniter;
echo json_encode($data);

Yet, I get a null value for the select input.

EDIT
Any help is greatly appreciated guys.  I still haven't figured out what is wrong.

EDIT
Not sure if there are any codeigniter experts on this post, BUT I solved it.  It was because for some reason codeigniter's '$this->input->post('somename')' method was not properly working.  As soon all the codeigniter's input commands to '$_POST['somename']', it solved the problem.  Here is the revised(WORKING) PHP script code:

$data['some_name'] = $_POST['some_name'];
    echo json_encode($data);

Body:
Home File

<!DOCTYPE html>
<html>
<head>
    <title>Home Page</title>
    <script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>
<form class="form-horizontal" action="#" id="sendstuff">
  <select name="some_name">
    <option value="somevalue1">test value1</option>
    <option value="somevalue2">test value2</option>
    <option value="somevalue3">test value3</option>
  </select>
  <button id="sb_btn"> Submit </button>
</form>
<script type="text/javascript">
$('#sb_btn').on('click', function() {

  $.ajax({
      type: 'post',
      url: 'index.php',
      data: $('#sendstuff').serialize()
    })
    .done(function(data) {
      data = jQuery.parseJSON(data);
      alert(data.some_name);
    });
    return false;
});
</script>
</body>
</html>

Ajax FIle

$data['some_name'] = $_POST['some_name'];

echo json_encode($data);


问:
XSLT1.0 with grouping or XPath
My Source File xml as follows:

```<code><root>
     <bp>
         <id>999</id>
         <role>FL01</role>
         <comp/>
     </bp>
     <bp>
         <id>999</id>
         <role>FL00</role>
         <comp>123</comp>
     </bp>
     <bp>
        <id>999</id>
        <role>FL02</role>
        <comp>456</comp>
    </bp>
    <bp>
         <id>888</id>
         <role>FL01</role>
         <comp/>
     </bp>
     <bp>
         <id>888</id>
         <role>FL00</role>
         <comp>123</comp>
     </bp>
     <bp>
        <id>888</id>
        <role>FL02</role>
        <comp>456</comp>
    </bp>
</root>
</code>```

I need to make final result as follows. It will split base on the <comp> and <id>. however, the <bp> without value <comp> the <role> require to add into each split.

```<code> <root>
     <bp>
            <id>999</id>
            <comp>123</role>
            <role>FL01</role>
             <role>FL00</role>
        </bp>
    <bp>
            <id>999</id>
            <comp>456</role>
            <role>FL01</role>
             <role>FL02</role>
        </bp>
    <bp>
            <id>888</id>
            <comp>123</role>
            <role>FL01</role>
             <role>FL00</role>
        </bp>
    <bp>
            <id>888</id>
            <comp>456</role>
            <role>FL01</role>
             <role>FL02</role>
        </bp>
    </root>
</code>```

Many thanks for any help.

答:
Edit 1: updated answer to reflect new requrements

(Note that I'm assuming you have your <bp> elements wrapped in a root-level element.)

If the order of each <bp>'s children isn't important, this XSLT:

```<code><?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
  <xsl:output method="xml" omit-xml-declaration="no" indent="yes"/>
  <xsl:strip-space elements="*"/>

  <xsl:key name="kBpByCompAndId" match="bp" use="concat(comp, '+', id)"/>

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="/*">
    <root>
      <xsl:apply-templates
        select="*[normalize-space(comp)][
          generate-id() = generate-id(
            key('kBpByCompAndId', concat(comp, '+', id))[1]
          )
        ]"/>
    </root>
  </xsl:template>

  <xsl:template match="bp">
    <bp>
      <xsl:apply-templates
        select="*|key('kBpByCompAndId', concat('+', id))/role"/>
    </bp>
  </xsl:template>

</xsl:stylesheet>
</code>```

...will produce a functionally equivalent result:

```<code><?xml version="1.0"?>
<root>
  <bp>
    <role>FL01</role>
    <id>999</id>
    <role>FL00</role>
    <comp>123</comp>
  </bp>
  <bp>
    <role>FL01</role>
    <id>999</id>
    <role>FL02</role>
    <comp>456</comp>
  </bp>
  <bp>
    <role>FL01</role>
    <id>888</id>
    <role>FL00</role>
    <comp>123</comp>
  </bp>
  <bp>
    <role>FL01</role>
    <id>888</id>
    <role>FL02</role>
    <comp>456</comp>
  </bp>
</root>
</code>```

For reference, this XSLT makes use of a grouping technique called Muenchian Grouping; since you are new to XSLT, this is a great technique to put in your toolkit.

Title: XSLT1.0 with grouping or XPath

Body:
My Source File xml as follows:

<root>
     <bp>
         <id>999</id>
         <role>FL01</role>
         <comp/>
     </bp>
     <bp>
         <id>999</id>
         <role>FL00</role>
         <comp>123</comp>
     </bp>
     <bp>
        <id>999</id>
        <role>FL02</role>
        <comp>456</comp>
    </bp>
    <bp>
         <id>888</id>
         <role>FL01</role>
         <comp/>
     </bp>
     <bp>
         <id>888</id>
         <role>FL00</role>
         <comp>123</comp>
     </bp>
     <bp>
        <id>888</id>
        <role>FL02</role>
        <comp>456</comp>
    </bp>
</root>

I need to make final result as follows. It will split base on the <comp> and <id>. however, the <bp> without value <comp> the <role> require to add into each split.

 <root>
     <bp>
            <id>999</id>
            <comp>123</role>
            <role>FL01</role>
             <role>FL00</role>
        </bp>
    <bp>
            <id>999</id>
            <comp>456</role>
            <role>FL01</role>
             <role>FL02</role>
        </bp>
    <bp>
            <id>888</id>
            <comp>123</role>
            <role>FL01</role>
             <role>FL00</role>
        </bp>
    <bp>
            <id>888</id>
            <comp>456</role>
            <role>FL01</role>
             <role>FL02</role>
        </bp>
    </root>

Many thanks for any help.

Body:
Edit 1: updated answer to reflect new requrements

(Note that I'm assuming you have your <bp> elements wrapped in a root-level element.)

If the order of each <bp>'s children isn't important, this XSLT:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
  <xsl:output method="xml" omit-xml-declaration="no" indent="yes"/>
  <xsl:strip-space elements="*"/>

  <xsl:key name="kBpByCompAndId" match="bp" use="concat(comp, '+', id)"/>

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="/*">
    <root>
      <xsl:apply-templates
        select="*[normalize-space(comp)][
          generate-id() = generate-id(
            key('kBpByCompAndId', concat(comp, '+', id))[1]
          )
        ]"/>
    </root>
  </xsl:template>

  <xsl:template match="bp">
    <bp>
      <xsl:apply-templates
        select="*|key('kBpByCompAndId', concat('+', id))/role"/>
    </bp>
  </xsl:template>

</xsl:stylesheet>

...will produce a functionally equivalent result:

<?xml version="1.0"?>
<root>
  <bp>
    <role>FL01</role>
    <id>999</id>
    <role>FL00</role>
    <comp>123</comp>
  </bp>
  <bp>
    <role>FL01</role>
    <id>999</id>
    <role>FL02</role>
    <comp>456</comp>
  </bp>
  <bp>
    <role>FL01</role>
    <id>888</id>
    <role>FL00</role>
    <comp>123</comp>
  </bp>
  <bp>
    <role>FL01</role>
    <id>888</id>
    <role>FL02</role>
    <comp>456</comp>
  </bp>
</root>

For reference, this XSLT makes use of a grouping technique called Muenchian Grouping; since you are new to XSLT, this is a great technique to put in your toolkit.


问:
How do I change to whole number instead of % in this codepen
Recently, I happen to come to this page.

I realise the change of the code happen in this function.

And it take data from
A	1
 .

 If the data in  is whole number, it does not have much effect like what % give.

How do I make it accept whole number and provide the effect similar to %?

```<code>function viewGraph() {
  $(".column").css("height", "0");
  $("table tr").each(function(index) {
    var ha = $(this).children("td").eq(1).text();
    $("#col" + index)
      .animate({ height: ha }, 1500)
      .html("<div>" + ha + "</div>");
  });
}
$(document).ready(function() {
  viewGraph();
});
</code>```

https://codepen.io/bobasdasd/pen/bRNzza

答:
This function take the text inside td and set column height equal that text. So, if the text have %, the column height will be setted in %. If the text is just a number, the column height will be setted in px. So, increasing your number (replace 1 by 100 or bigger), you will see the effect. If you want convert number to %, just do this:

```<code>if(ha.indexOf('%')==-1) ha+='%';
</code>```

Body:
Recently, I happen to come to this page.

I realise the change of the code happen in this function.

And it take data from
A	1
 .

 If the data in  is whole number, it does not have much effect like what % give.

How do I make it accept whole number and provide the effect similar to %?

function viewGraph() {
  $(".column").css("height", "0");
  $("table tr").each(function(index) {
    var ha = $(this).children("td").eq(1).text();
    $("#col" + index)
      .animate({ height: ha }, 1500)
      .html("
" + ha + "
");
  });
}
$(document).ready(function() {
  viewGraph();
});

https://codepen.io/bobasdasd/pen/bRNzza

Body:
This function take the text inside td and set column height equal that text. So, if the text have %, the column height will be setted in %. If the text is just a number, the column height will be setted in px. So, increasing your number (replace 1 by 100 or bigger), you will see the effect. If you want convert number to %, just do this:

if(ha.indexOf('%')==-1) ha+='%';


问:
Pass an extra param in simple_form
I need to pass an extra param to my controller because I use same update action for many edit forms (want to know which form was used).</p>

```<code><%= simple_form_for @order,
  url: order_path(@order),
  method: :put,
  remote: true do |f| %>
  <%= f.input :status,
    collection: @order.statuses %>
  <% #pass random hidden param here! %>
  <%= f.button :submit %>
<% end %>
</code>```

答:
Try with a hidden_field_tag:

```<code><%= simple_form_for @order,
  url: order_path(@order),
  method: :put,
  remote: true do |f| %>
  <%= f.input :status, collection: @order.statuses %>
  <%= hidden_field_tag 'name', 'value' %>
  <%= f.button :submit %>
<% end %>
</code>```

Title: Pass an extra param in simple_form

Body:
I need to pass an extra param to my controller because I use same update action for many edit forms (want to know which form was used).

<%= simple_form_for @order,
  url: order_path(@order),
  method: :put,
  remote: true do |f| %>
  <%= f.input :status,
    collection: @order.statuses %>
  <% #pass random hidden param here! %>
  <%= f.button :submit %>
<% end %>

Body:
Try with a hidden_field_tag:

<%= simple_form_for @order,
  url: order_path(@order),
  method: :put,
  remote: true do |f| %>
  <%= f.input :status, collection: @order.statuses %>
  <%= hidden_field_tag 'name', 'value' %>
  <%= f.button :submit %>
<% end %>


问:
Trouble displaying code on screen
This might sound like a simple thing for you programmers out there but i can't seem to figure it out. I'm making a program that converts Decimal Numbers into Roman Numerals. I've got the core code working but i can't seem to think how i can display the results on the screen. I would like it so that when the user types a number into a text box the result appears in another text box at the press of a button. Thanks for your time & help. </p>

```<code>function convertToRoman(num) {
var romans = {
    M:  1000,
    CM: 900,
    D:  500,
    CD: 400,
    C:  100,
    XC: 90,
    L:  50,
    XL: 40,
    X:  10,
    IX: 9,
    V:  5,
    IV: 4,
    I:  1,
};

var result = '';

for (var key in romans) {
    if (num >= romans[key]) {
        result += key.repeat(Math.trunc(num / romans[key]));
        num -= romans[key] * Math.trunc(num / romans[key]);
    }
}

return result;

}
</code>```

答:
If you add a div element and give it an id like "output", you can do something like this.</p>

```<code>document.getElementById("output").innerHTML = result;
</code>```

Title: Trouble displaying code on screen

Body:
This might sound like a simple thing for you programmers out there but i can't seem to figure it out. I'm making a program that converts Decimal Numbers into Roman Numerals. I've got the core code working but i can't seem to think how i can display the results on the screen. I would like it so that when the user types a number into a text box the result appears in another text box at the press of a button. Thanks for your time & help.

function convertToRoman(num) {
var romans = {
    M:  1000,
    CM: 900,
    D:  500,
    CD: 400,
    C:  100,
    XC: 90,
    L:  50,
    XL: 40,
    X:  10,
    IX: 9,
    V:  5,
    IV: 4,
    I:  1,
};

var result = '';

for (var key in romans) {
    if (num >= romans[key]) {
        result += key.repeat(Math.trunc(num / romans[key]));
        num -= romans[key] * Math.trunc(num / romans[key]);
    }
}

return result;

}

Body:
If you add a div element and give it an id like "output", you can do something like this.

document.getElementById("output").innerHTML = result;


问:
How to address Port names (PORTB etc) in an array (arduino uno)
Is it possible to put the names of ports in an array?

I'm looking something like:

```<code>const ??? my_ports_config[8]= { PORTB, PORTD, PORTB, PORTB, PORTD, PORTB, PORTB, PORTD };
</code>```

So to do (direct register bit set):

```<code>my_ports_config[i] |= _BV(7);
</code>```

Is it possible?

答:
```<code>volatile byte* const my_ports_config[8]= { &PORTB, &PORTD, &PORTB, &PORTB, &PORTD, &PORTB, &PORTB, &PORTD };
</code>```

Body:
Is it possible to put the names of ports in an array?

I'm looking something like:

const ??? my_ports_config[8]= { PORTB, PORTD, PORTB, PORTB, PORTD, PORTB, PORTB, PORTD };

So to do (direct register bit set):

my_ports_config[i] |= _BV(7);

Is it possible?


问:
Determining if a number is prime
I have perused a lot of code on this topic, but most of them produce the numbers that are prime all the way up to the input number.  However, I need code which only checks whether the given input number is prime.

Here is what I was able to write, but it does not work:

```<code>void primenumber(int number)
{
    if(number%2!=0)
      cout<<"Number is prime:"<<endl;
    else
      cout<<"number is NOt prime"<<endl;
}
</code>```

I would appreciate if someone could give me advice on how to make this work properly.

Update

I modified it to check on all the numbers in a for loop.

```<code>void primenumber(int number)
{
    for(int i=1; i<number; i++)
    {
       if(number%i!=0)
          cout<<"Number is prime:"<<endl;
       else
          cout<<"number is NOt prime"<<endl;
    }
}
</code>```

答:
I follow same algorithm but different implementation that loop to sqrt(n) with step 2 only odd numbers because I check that if it is divisible by 2 or 2*k it is false. Here is my code </p>

```<code>public class PrimeTest {

    public static boolean isPrime(int i) {
        if (i < 2) {
            return false;
        } else if (i % 2 == 0 && i != 2) {
            return false;
        } else {
            for (int j = 3; j <= Math.sqrt(i); j = j + 2) {
                if (i % j == 0) {
                    return false;
                }
            }
            return true;
        }
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        for (int i = 1; i < 100; i++) {
            if (isPrime(i)) {
                System.out.println(i);
            }
        }
    }

}
</code>```

Title: Determining if a number is prime

Body:
I have perused a lot of code on this topic, but most of them produce the numbers that are prime all the way up to the input number.  However, I need code which only checks whether the given input number is prime.

Here is what I was able to write, but it does not work:

void primenumber(int number)
{
    if(number%2!=0)
      cout<<"Number is prime:"<<endl;
    else
      cout<<"number is NOt prime"<<endl;
}

I would appreciate if someone could give me advice on how to make this work properly.

Update

I modified it to check on all the numbers in a for loop.

void primenumber(int number)
{
    for(int i=1; i<number; i++)
    {
       if(number%i!=0)
          cout<<"Number is prime:"<<endl;
       else
          cout<<"number is NOt prime"<<endl;
    }
}

Body:
I follow same algorithm but different implementation that loop to sqrt(n) with step 2 only odd numbers because I check that if it is divisible by 2 or 2*k it is false. Here is my code

public class PrimeTest {

    public static boolean isPrime(int i) {
        if (i < 2) {
            return false;
        } else if (i % 2 == 0 && i != 2) {
            return false;
        } else {
            for (int j = 3; j <= Math.sqrt(i); j = j + 2) {
                if (i % j == 0) {
                    return false;
                }
            }
            return true;
        }
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        for (int i = 1; i < 100; i++) {
            if (isPrime(i)) {
                System.out.println(i);
            }
        }
    }

}

ContentLicense: CC BY-SA 2.5


问:
How to Index child object properties and writing search queries in YDN DB from JSON file data
I have gone through many sites but couldn't able to find any solution. here is my question. I want to index the both child and parent properties from YDN DB.

My Sample JSON data :

```<code>"dataList":[
    {
        "id":1,
        "code":"TN",
        "name":"TestName",
        "city":{
            "cityCode":"ABC",
            "cityName":"ABC City"
        },"country":{
            "countryCode":"NG",
            "countryName":"Nigeria"
        },
        "isOnline":true
    }
]
</code>```

YDB Schema and Store :

```<code>"schema":
{
  "stores":
  [
    {
      "name": "airlineList",
      "keyPath": "airportName",
        "indexes": [
        {
          "keyPath": "airportCode"
        },
        {
          "keyPath": "cityCode"
        }
      ]
    }
  ]
}
</code>```

I am trying store the JSON data into  Indexed DB by indexing the parent and child properties when i try to index the child object (city) properties I couldn't able to filter it.

Thanks in advance

答: You can use keyPath as an array, for example ['city', 'cityCode'].

Body:
I have gone through many sites but couldn't able to find any solution. here is my question. I want to index the both child and parent properties from YDN DB.

My Sample JSON data :

"dataList":[
    {
        "id":1,
        "code":"TN",
        "name":"TestName",
        "city":{
            "cityCode":"ABC",
            "cityName":"ABC City"
        },"country":{
            "countryCode":"NG",
            "countryName":"Nigeria"
        },
        "isOnline":true
    }
]

YDB Schema and Store :

"schema":
{
  "stores":
  [
    {
      "name": "airlineList",
      "keyPath": "airportName",
        "indexes": [
        {
          "keyPath": "airportCode"
        },
        {
          "keyPath": "cityCode"
        }
      ]
    }
  ]
}

I am trying store the JSON data into  Indexed DB by indexing the parent and child properties when i try to index the child object (city) properties I couldn't able to filter it.

Thanks in advance