问:
Laravel 5.5 - multiple images upload
I have this function in my controller:

```<code>use File;
use Image; //image intervention library
...
public function upload(Request $request)
    {
        //make sure there is a folder in public with the username
        $username = Auth::user()->name;
        $folderpath = public_path('images/' . $username . '/');
        File::makeDirectory($folderpath, $mode = 0777, true, true);

        $files = $request->file;

        if(!empty($files)):
            foreach($files as $file):
                $filename = 'post_' . time() . '.' . $file->getClientOriginalExtension();
                $path = $folderpath . $filename;
                Image::make($file)->resize(800,400)->save($path);
            endforeach;
        endif;

        return 'success';
    }
</code>```

which only save the last image if I upload multiple.

and I tried:

```<code>public function upload(Request $request)
    {
        //make sure there is a folder in public with the username
        $username = Auth::user()->name;
        $folderpath = public_path('images/' . $username . '/');
        File::makeDirectory($folderpath, $mode = 0777, true, true);

        $files = $request->file;

        if(!empty($files)):
            foreach($files as $file):
                $filename = 'post_' . time() . '.' . $file->getClientOriginalExtension();
                $path = $folderpath . $filename;
                $file->save($path);
            endforeach;
        endif;

        return ''success;
    }
</code>```

which throw me error:

Method save does not exist.

I goggled and it seems like I did not instantiate it with model. But in this case, how can I instantiate it with model if it is just a direct file upload?

What is the best way for multiple images upload in laravel?

Update

After reading @kunal's answer, I managed to solve the issue by adding a unique number for the file name:

```<code>public function upload(Request $request)
    {
        //make sure there is a folder in public with the username
        $username = Auth::user()->name;
        $folderpath = public_path('images/' . $username . '/');
        File::makeDirectory($folderpath, $mode = 0777, true, true);

        $files = $request->file;
        $count = 0;//<-- add a counter
        if(!empty($files)):
            foreach($files as $file):
                $filename = 'post_' . time() . '_' . $count . '.' . $file->getClientOriginalExtension();//<-- add counter to the file name
                $path = $folderpath . $filename;
                Image::make($file)->resize(800,400)->save($path);
                $count ++;//<-- increase the value
            endforeach;
        endif;

        return 'success';
    }
</code>```

答:
try this code:

```<code>$files= Input::file('image');
$destinationPath= 'images';
$images=array();
foreach($files as $file){
    $fullname= $file->getClientOriginalName();
    $hashname  = $fullname;
    $upload_success   =$file->move($destinationPath, $hashname);
    $images[]=$fullname;
    $has= implode(",",$images);
}
$modelname= new Modelname;
$modelname->image_attachment    =  $has;
$modelname->save();
</code>```

and yout html page:

```<code><input type="file" id="image" name="image[]" />
</code>```

Title: Laravel 5.5 - multiple images upload

Body:
I have this function in my controller:

use File;
use Image; //image intervention library
...
public function upload(Request $request)
    {
        //make sure there is a folder in public with the username
        $username = Auth::user()->name;
        $folderpath = public_path('images/' . $username . '/');
        File::makeDirectory($folderpath, $mode = 0777, true, true);

        $files = $request->file;

        if(!empty($files)):
            foreach($files as $file):
                $filename = 'post_' . time() . '.' . $file->getClientOriginalExtension();
                $path = $folderpath . $filename;
                Image::make($file)->resize(800,400)->save($path);
            endforeach;
        endif;

        return 'success';
    }

which only save the last image if I upload multiple.

and I tried:

public function upload(Request $request)
    {
        //make sure there is a folder in public with the username
        $username = Auth::user()->name;
        $folderpath = public_path('images/' . $username . '/');
        File::makeDirectory($folderpath, $mode = 0777, true, true);

        $files = $request->file;

        if(!empty($files)):
            foreach($files as $file):
                $filename = 'post_' . time() . '.' . $file->getClientOriginalExtension();
                $path = $folderpath . $filename;
                $file->save($path);
            endforeach;
        endif;

        return ''success;
    }

which throw me error:

Method save does not exist.

I goggled and it seems like I did not instantiate it with model. But in this case, how can I instantiate it with model if it is just a direct file upload?

What is the best way for multiple images upload in laravel?

Update

After reading @kunal's answer, I managed to solve the issue by adding a unique number for the file name:

public function upload(Request $request)
    {
        //make sure there is a folder in public with the username
        $username = Auth::user()->name;
        $folderpath = public_path('images/' . $username . '/');
        File::makeDirectory($folderpath, $mode = 0777, true, true);

        $files = $request->file;
        $count = 0;//<-- add a counter
        if(!empty($files)):
            foreach($files as $file):
                $filename = 'post_' . time() . '_' . $count . '.' . $file->getClientOriginalExtension();//<-- add counter to the file name
                $path = $folderpath . $filename;
                Image::make($file)->resize(800,400)->save($path);
                $count ++;//<-- increase the value
            endforeach;
        endif;

        return 'success';
    }

Body:
try this code:

$files= Input::file('image');
$destinationPath= 'images';
$images=array();
foreach($files as $file){
    $fullname= $file->getClientOriginalName();
    $hashname  = $fullname;
    $upload_success   =$file->move($destinationPath, $hashname);
    $images[]=$fullname;
    $has= implode(",",$images);
}
$modelname= new Modelname;
$modelname->image_attachment    =  $has;
$modelname->save();

and yout html page:

<input type="file" id="image" name="image[]" />


来源: stackexchange

问:
How can I determine what architectures gcc supports?
GCC supports a -march switch that allows you to specify the architecture you are targeting - allowing it to tune instruction sequences for that platform as well as using instructions that might be available on the platform which aren't available on the "default" or base version of the architecture.

For example, -march=skylake will tell the compiler to target Skylake CPUs, including using instruction sets available on Skylake such as AVX2.

How can I tell what values for -march the local version of gcc supports? Newer versions helpfully list the valid arguments when an invalid argument is passed, but older versions do not.

答:
With gcc7 and later, gcc will print the values it supports as part of the error message.

```<code>$ gcc -E -march=help -xc /dev/null
# 1 "/dev/null"
cc1: error: bad value (‘help’) for ‘-march=’ switch
cc1: note: valid arguments to ‘-march=’ switch are: nocona core2 nehalem corei7 westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell skylake skylake-avx512 bonnell atom silvermont slm knl x86-64 eden-x2 nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 k8 k8-sse3 opteron opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 btver1 btver2
</code>```

I checked on Godbolt, and x86 gcc6.x and earlier just say  error: bad value (invalid) for -march= switch even with -v.

It also doesn't work with clang5.0 or ICC18.

This is target-specific: ARM gcc6.3 does produce a list of supported -march values, or -mcpu=.

ContentLicense: CC BY-SA 3.0

Body:
With gcc7 and later, gcc will print the values it supports as part of the error message.

$ gcc -E -march=help -xc /dev/null
# 1 "/dev/null"
cc1: error: bad value (‘help’) for ‘-march=’ switch
cc1: note: valid arguments to ‘-march=’ switch are: nocona core2 nehalem corei7 westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell skylake skylake-avx512 bonnell atom silvermont slm knl x86-64 eden-x2 nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 k8 k8-sse3 opteron opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 btver1 btver2

I checked <a href="https://gcc.godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAKxAEZSBnVAV2OUxAHIBSAJgGY8AO2QAbZlgDU3fgGE8AWwXCCxYQDoEM7NwAMAQRWSAZqlQQA%2BhYW8ArADZJxTA2aiCFgG6ZkRYgEppAHYAIT19Y1FUAEMCJxc3AgZuWxCADhSAERkwg2sbBwsGP0xmCwAHBghnV3cGUnjaj29fEn8c8PCjNGYhOJlMyV0Og1NiSQgjPHQAD2l%2BQeH%2BEMlpuZlZSQzl6V4wvbX2g25Q8Mlz1eMJmsTk1LWsyTAwAaGj/Qvglc%2Bf87Pf3b7EI9PojD4XE7ZY5BKH6ZwEVhCSQgghgyGcfykURcWycUhCLi6PGoLiyPhAyRMVjsXb8Wh4giEjGYgDWIH4tnUtHstF0uiCulsdiCvF0AE4sVwACx4hR0Pn4pmkEmcPEMEC6UiMzhEzFwWAwRAoVAKcp4USYMgUCBoU3my0gYD2fikYzmgiW9UQABGSu9wmixAAnlx6aRbQpMH0APJCUQhzhhrAKaJCYAWpX4Zy%2BPDedU6vGYGY%2BZge0N4lSYbEFrVqOWJjFYvDe9WQTGocoEPCoIT5gC0AHVoqJRJI%2B9H%2BGOU2wtAthJ5h9M1Sw2BxaJjq7jFTWVTM0vY%2B/YpZJgMhkJJ7OpJxBcIQSLT6JJZCazRbxnx%2BLx/Aymf5WezeHUXgpX4NJaA5MVaFscUxUFSVOBlUg5X4fguVoXhILFZ1%2BCCIIpVoIJtyJZUuDVDUtV/Uh9SNFgCHKUtyEoW1XwdXhSEwfA/DoDccTxAkdy4D9eEkAB3QgEEkPcDyPE8zwvK8fwLP9SAQTBoiwYhKB4hDZToS80jSAU0l0fh7HsXg7DSKUiOJUjGHI7VdSow0ICQZj7StJiXw8kBAwUJ1%2BE1N13E9ShfRrf0hEDBMwwjKMCFjeNy1IZNU3TDgayzHwuzzJUixLMsG3IPoqyVVRFHLDdm1bCB207btey4Qdh1HcdJz7adkFnTJ50XdBl2pNdtK3fjiJVfQACUAFlZPPS9UN0CZRGEZgZkCG9OPvD9H2fO03wfb8KKU7TELlYD1DFS6ruu677BskjVXszVHMbajXJAWj6IIRibW8t86HYzbNPXeCRqVFVttE8TJEmmbTzmq91EWiBlqEVbDpe5Tq1OkA7HulUyOe39/0/ICQLAiCoJguDq34PjwbszHnPgN63L%2By0fvc/68DPWg0ldd1Qp9P0A2DZK4pjOME2I1K0wzTK8GzHKXDy4tkFLDKw0ratiPK%2Bt6Sqlt4Dqrse37CcxyHEcp0DLqBl65b%2BsYFd2G40H6YEzgpMPY8efPPmJlvPwHwaXaWPfAR%2BAx4nSDZUndHw2wxV4fcxTSFDbBdbHdJTpGpVsNIk75XR7CsqUghdUbbMe9UiaU5nYCQT6GOtLmHRdDi72B4aPbGwTI6hggJO9mS/ckPnFN1TFVPUh1avgnHaDFK9eSlEz04wyDeTuquHsJo6nNZ409o51v2c0sQ0ugoLBeIL1wuIyLovFk1I0lpKitl9LM0V7LcxVms%2BV1aFS1iVHWDI6yVSbEbNsyp6pmyahbDqttuoOyXM7QabtNy92riPY8l80ySE5LoJGgcgYhyfOfWkUpo7HQXjnIIV5r5mVsHhewmEJS7wJk9A%2Br0XJN1LF9Tm58QDWU7lxEG2D8b934MeMSQ9JL7h9siUQaUiFIyRpPZk9CkK405BhUyAok7ck/FKfO0ia4ORjnHQCSdbAETFByYxxl6C0xwXvXhWMuC8HcdwzGmJvB3waqIoAA%3D" rel="noreferrer">on Godbolt, and x86 gcc6.x and earlier just say  error: bad value (invalid) for -march= switch even with -v.

It also doesn't work with clang5.0 or ICC18.

This is target-specific: ARM gcc6.3 does produce a list of supported -march values, or -mcpu=.


问:
MPAndroidChart - Remove Top and Bottom Spaces
I am using MPAndroidChart library.

I implement a PieChart in my application. Everything works fine, but there is a blank space at the top and at the end of the Chart.
I need to remove this space to properly visualize my activity layout

My question is:

Is possible to remove them programmatically?

P.D. In my layout, there is non marginTop or marginBottom.

Layout xml:

```<code><com.github.mikephil.charting.charts.PieChart
   android:id="@+id/pieChart"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_below="@id/_home_consumed" >
</com.github.mikephil.charting.charts.PieChart>
</code>```

答:
Try this...</p>

```<code>pieChart.setExtraOffsets(-10,-10,-10,-10);
</code>```

Body:
I am using MPAndroidChart library.

I implement a PieChart in my application. Everything works fine, but there is a blank space at the top and at the end of the Chart.
I need to remove this space to properly visualize my activity layout

My question is:

Is possible to remove them programmatically?

P.D. In my layout, there is non marginTop or marginBottom.

Layout xml:

<com.github.mikephil.charting.charts.PieChart
   android:id="@+id/pieChart"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_below="@id/_home_consumed" >
</com.github.mikephil.charting.charts.PieChart>

Body:
Try this...

pieChart.setExtraOffsets(-10,-10,-10,-10);


问:
How can I combine several rows into one using SQL Server
I have a table punches that looks like this

```<code>EMP_ID    INpunchDATETIME     OUTpunchDATETIME
-----------------------------------------------
1         2017-11-10 11:59    2017-11-10 13:30
1         2017-11-10 9:00     2017-11-10 10:30
</code>```

I need to create a table @temptable from the previous table that looks like this

```<code>Emp_ID InPunch1         InPunch2          OUTpunch1         OUTpunch2
----------------------------------------------------------------------------
1      2017-11-10 9:00  2017-11-10 11:59  2017-11-10 10:30  2017-11-10 13:30
</code>```

I'm trying to use PIVOT but if that's wrong I can change

```<code>DECLARE @temptable Table (
        EMP_ID int,
        InPunch1 datetime,
        InPunch2 datetime,
        OutPunch1 datetime,
        OutPunch2 datetime);

SELECT
    Emp_ID, InPunch1, InPunch2, Outpunch1, Outpunch2
INTO
    @temptable
FROM
    (SELECT
         EMP_ID, INPunchDATETIME, OUTpunchDATETIME
     FROM
         punches) AS p
PIVOT
    (
</code>```

That's as far as I've got.

答:
Sample Data Setup

```<code>create table dbo.punches
    (
        emp_id int
        , INpunchDATETIME datetime
        , OUTpunchDATETIME datetime
    )

insert into dbo.punches
values (1, '2017-11-10 11:59','2017-11-10 13:30')
    , (1, '2017-11-10 9:00','2017-11-10 10:30')
</code>```

Answer

The punches tables has the in/out punches in two separate column, and the inner most query moves both types of punches into one column to allow all of the data to be pivoted at once. The next query puts them in chronological order, and creates values in punch_ind that will be the eventual column names. Last step is to pivot the data and select the final output.

```<code>select post.emp_id
, post.InPunch1
, post.InPunch2
, post.OutPunch1
, post.OutPunch2
from (
    --decide which punch is in1/in2/etc.
    select sub.emp_id
    , sub.punch_type + 'Punch' + cast(row_number() over (partition by sub.emp_id, sub.punch_type order by sub.punch_ts) as varchar(10)) as punch_ind --punch indicator
    , sub.punch_ts
    from (
        --get all of the data in one column to enable pivot
        select p.emp_id
        , 'In' as punch_type
        , p.INpunchDATETIME as punch_ts
        from dbo.punches as p
        union all
        select p.emp_id
        , 'Out' as punch_type
        , p.OUTpunchDATETIME as punch_ts
        from dbo.punches as p
        ) as sub
    ) as pre --before the pivot
pivot (max(pre.punch_ts) for pre.punch_ind in ([InPunch1], [InPunch2], [OutPunch1], [OutPunch2])) as post --after the pivot
</code>```

Just take this final output and insert the records into the temp table/table variable of your choice.

Body:
I have a table punches that looks like this

EMP_ID    INpunchDATETIME     OUTpunchDATETIME
-----------------------------------------------
1         2017-11-10 11:59    2017-11-10 13:30
1         2017-11-10 9:00     2017-11-10 10:30

I need to create a table @temptable from the previous table that looks like this

Emp_ID InPunch1         InPunch2          OUTpunch1         OUTpunch2
----------------------------------------------------------------------------
1      2017-11-10 9:00  2017-11-10 11:59  2017-11-10 10:30  2017-11-10 13:30

I'm trying to use PIVOT but if that's wrong I can change

DECLARE @temptable Table (
        EMP_ID int,
        InPunch1 datetime,
        InPunch2 datetime,
        OutPunch1 datetime,
        OutPunch2 datetime);

SELECT
    Emp_ID, InPunch1, InPunch2, Outpunch1, Outpunch2
INTO
    @temptable
FROM
    (SELECT
         EMP_ID, INPunchDATETIME, OUTpunchDATETIME
     FROM
         punches) AS p
PIVOT
    (

That's as far as I've got.

Body:
Sample Data Setup

create table dbo.punches
    (
        emp_id int
        , INpunchDATETIME datetime
        , OUTpunchDATETIME datetime
    )

insert into dbo.punches
values (1, '2017-11-10 11:59','2017-11-10 13:30')
    , (1, '2017-11-10 9:00','2017-11-10 10:30')

Answer

The punches tables has the in/out punches in two separate column, and the inner most query moves both types of punches into one column to allow all of the data to be pivoted at once. The next query puts them in chronological order, and creates values in punch_ind that will be the eventual column names. Last step is to pivot the data and select the final output.

select post.emp_id
, post.InPunch1
, post.InPunch2
, post.OutPunch1
, post.OutPunch2
from (
    --decide which punch is in1/in2/etc.
    select sub.emp_id
    , sub.punch_type + 'Punch' + cast(row_number() over (partition by sub.emp_id, sub.punch_type order by sub.punch_ts) as varchar(10)) as punch_ind --punch indicator
    , sub.punch_ts
    from (
        --get all of the data in one column to enable pivot
        select p.emp_id
        , 'In' as punch_type
        , p.INpunchDATETIME as punch_ts
        from dbo.punches as p
        union all
        select p.emp_id
        , 'Out' as punch_type
        , p.OUTpunchDATETIME as punch_ts
        from dbo.punches as p
        ) as sub
    ) as pre --before the pivot
pivot (max(pre.punch_ts) for pre.punch_ind in ([InPunch1], [InPunch2], [OutPunch1], [OutPunch2])) as post --after the pivot

Just take this final output and insert the records into the temp table/table variable of your choice.


问:
Is there any way to prevent people from making my web game available offline?
It's not the type of game that really need a server to operate. I'm using javascript and html5 right now, and I cant think of a way to prevent the game from being rip off.

Using obsfucator is useless, the game would still work offline.

Implementing a validation scheme is not invincible either. Someone smart can just crack the script and remove the validation part.

答:
If you combine obfuscation and validation, you'll go a long way. Can someone crack and use it offline? Possibly. Is it really going to be worth the effort? I mean, even an installed game can be cracked. This is especially true if you make the validation extra obfuscated by hand by spreading it out over several methods.

I would avoid moving more logic to the server than you have to, because it would obviously slow the app way down, but you might be able to get away with moving tiny crucial pieces that only happen rarely like between levels (chapters?).

ContentLicense: CC BY-SA 2.5


问:
Setting up TeamCity with my own GIT Server over SSL
I have my own GIT server repository and can be connected via HTTPS protocol.

I am trying to setup TeamCity to connect to my GIT repo but I am unable to because of the HTTPS protocol.

In Eclipse, I have a setting that sets sslVerify=false and I can connect to my GIT repo and perform my task.

How can i achieve the same for TeamCity?

答:
We were using 32-bit version of git on teamcity server (64-bit). So removing 32-bit and installing 64-bit git bash and git cmd helped resolve the GIT and Teamcity connection problem for us.
I hope this help some users.</p>


问:
What boot() method do in laravel?
there is register() method in Service Provider which is used for bind the classes but i don't know what boot() method's do ? can you please explain it.</p>

答:
Interfaces by themselves are not very useful. But when implemented by concrete classes you see that it gives you the flexibility to have one or more implementations.

The bonus is that the object using the interface do not need to know how the details of the actual implementation go - that's called encapsulation...

Also It's difficult for me to imagine clean, object-oriented  code without the use of interfaces. You use them whenever you wish to enforce the availability of certain functionality without forcing classes to inherit from a specific base class, and this allows your code to have the relevant level of (low) coupling.

Title: What boot() method do in laravel?


答:
May be you are looking for this kind of stuff:-</p>

```<code>if ($request->hasFile('files')) {
$files = $request->file('files');
foreach($files as $file){
    $extension = $file->getClientOriginalExtension();
    $fileName = str_random(5)."-".date('his')."-".str_random(3).".".$extension;
    $folderpath  = 'images'.'/';
    $file->move($folderpath , $fileName);
}
}
<input type="file" id="gallery" name="files[]" multiple />
</code>```

Title: Laravel 5.5 - multiple images upload

Body:
May be you are looking for this kind of stuff:-

if ($request->hasFile('files')) {
$files = $request->file('files');
foreach($files as $file){
    $extension = $file->getClientOriginalExtension();
    $fileName = str_random(5)."-".date('his')."-".str_random(3).".".$extension;
    $folderpath  = 'images'.'/';
    $file->move($folderpath , $fileName);
}
}
<input type="file" id="gallery" name="files[]" multiple />


问:
hive shell is not starting in cloudera
I tried restarting my system, checked whether there is enough space or not and also made sure my hive server2 is running. But I'm getting these errors when given '$hive' in Cloudera.</p>

```<code>Logging initialized using configuration in
file:/etc/hive/conf.dist/hive-log4j.properties
WARN: The method class
org.apache.commons.logging.impl.SLF4JLogFactory#release() was invoked.

Exception in thread "main" java.lang.RuntimeException:
org.apache.hadoop.hive.ql.metadata.HiveException:
java.lang.RuntimeException:
org.apache.hadoop.hive.ql.metadata.HiveException:
java.lang.RuntimeException: Unable to instantiate
org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
</code>```

答:
The process of starting Hive2 is changed, as Hive got deprecated. Usage of Beeline is recommended.

Beeline was developed specifically to interact with the new server. Unlike Hive CLI, which is an Apache Thrift-based client, Beeline is a JDBC client based on the SQLLine CLI — although the JDBC driver used communicates with HiveServer2 using HiveServer2’s Thrift APIs.

As Hive development has shifted from the original Hive server (HiveServer1) to the new server (HiveServer2), users and developers accordingly need to switch to the new client tool. However, there’s more to this process than simply switching the executable name from “hive” to “beeline”.

More information provided over here

Use the below command to enter into interactive mode. Beeline supports same commands that Hive server does. You can execute same script in Beeline without any modifications.

```<code>beeline -u jdbc:hive2://
</code>```

To start the Hive metastore,

```<code>sudo service hive-metastore start
</code>```

Title: hive shell is not starting in cloudera

Body:
I tried restarting my system, checked whether there is enough space or not and also made sure my hive server2 is running. But I'm getting these errors when given '$hive' in Cloudera.

Logging initialized using configuration in
file:/etc/hive/conf.dist/hive-log4j.properties
WARN: The method class
org.apache.commons.logging.impl.SLF4JLogFactory#release() was invoked.

Exception in thread "main" java.lang.RuntimeException:
org.apache.hadoop.hive.ql.metadata.HiveException:
java.lang.RuntimeException:
org.apache.hadoop.hive.ql.metadata.HiveException:
java.lang.RuntimeException: Unable to instantiate
org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

Body:
The process of starting Hive2 is changed, as Hive got deprecated. Usage of Beeline is recommended.

Beeline was developed specifically to interact with the new server. Unlike Hive CLI, which is an Apache Thrift-based client, Beeline is a JDBC client based on the SQLLine CLI — although the JDBC driver used communicates with HiveServer2 using HiveServer2’s Thrift APIs.

As Hive development has shifted from the original Hive server (HiveServer1) to the new server (HiveServer2), users and developers accordingly need to switch to the new client tool. However, there’s more to this process than simply switching the executable name from “hive” to “beeline”.

More information provided over here

Use the below command to enter into interactive mode. Beeline supports same commands that Hive server does. You can execute same script in Beeline without any modifications.

beeline -u jdbc:hive2://

To start the Hive metastore,

sudo service hive-metastore start


问:
ReactJS - How to split table row into two rows to show more responsive way of data
I have a requirement to display table data in reactjs application. But the table having more fields so, am trying to split the table row into two rows. How can i split the row.

Here am getting data from MongoDB by using API to invoke JavaServlets.

I tried by placing two  tags but it is throwing error.

Please find the code that am showing my table data ( reactJS ).

```<code>class SearchResults extends React.Component {
    constructor(props) {
        super(props);
        this.state = { currentPage: 1 };
        this.handlePageChange=this.handlePageChange.bind(this);

    }
          handlePageChange(page, evt) {
            this.setState({ currentPage: page  } );
          }
    render() {

        const per_page = "10";
        const paginationData = this.props.results;
        let numPages = Math.ceil(paginationData.length / per_page);

        if (paginationData.length % per_page > 0) {
          numPages++;
        }

        return (
            <div className="panel panel-primary">
            <div className="panel-heading">ORDERS LIST</div>
            <table className="table table-hover" >
                <thead >
                <tr>
                <th>Order Number</th>
                <th>Customer Name</th>
                <th>Created By</th>
            </tr>
                </thead>

                <SearchResultsList items={ this.props.results } />

            </table>

                <Pagination id="content" className="users-pagination pull-right" bsSize="medium"
                     first last  next  prev  boundaryLinks items={numPages}
                activePage={ this.state.currentPage } onSelect={ this.handlePageChange } />
            </div>
        );
    }
}

class SearchResultsList extends React.Component {
    constructor(props) {
        super(props);
        this.state = { };
    }
    render() {
        return (<tbody>{ this.props.items
            .map((item, index) => {
                  if (index >= start_offset && start_count < per_page) {
                      start_count++;
                      return <SearchResultsItem key={item.id} item={item} />;

                  }
          })
      }
        </tbody>
         );

        }

}

class SearchResultsItem extends React.Component {
    constructor(props) {
        super(props);
        this.state = { };
    }
    render() {
         return(
                 <tr>
                    <td>{ this.props.item.order_number }</td>
                    <td>{ this.props.item.customer_name }</td>
                    <td>{ this.props.item.buyer_email }</td>
                </tr>
        );
    }
}
</code>```

In the last render() method i want to have two table row tags to some fields in next row.

Like the below code.

```<code>render() {
     return(
             <tr>
                <td>{ this.props.item.order_number }</td>
                <td>{ this.props.item.customer_name }</td>
                <td>{ this.props.item.buyer_email }</td>
            </tr>
            <tr>
                <td>{ this.props.item.buyer_id }</td>
                <td>{ this.props.item.buyer_city }</td>
                <td>{ this.props.item.buyer_state }</td>
            </tr>
    );
}
</code>```

But am getting error if i place one more table row tag in return. How i can split table row?

答:
if you are using  react < v16 , you have to make a small change in your render method.

```<code>    render() {
         return(  <tbody> <!-- wrapper element -->
                 <tr>
                    <td>{ this.props.item.order_number }</td>
                    <td>{ this.props.item.customer_name }</td>
                    <td>{ this.props.item.buyer_email }</td>
                </tr>
                <tr>
                    <td>{ this.props.item.buyer_id }</td>
                    <td>{ this.props.item.buyer_city }</td>
                    <td>{ this.props.item.buyer_state }</td>
                </tr>
</tbody>
        );
    }
</code>```

More details can be seen here in this SO Question

Body:
I have a requirement to display table data in reactjs application. But the table having more fields so, am trying to split the table row into two rows. How can i split the row.

Here am getting data from MongoDB by using API to invoke JavaServlets.

I tried by placing two  tags but it is throwing error.

Please find the code that am showing my table data ( reactJS ).

class SearchResults extends React.Component {
    constructor(props) {
        super(props);
        this.state = { currentPage: 1 };
        this.handlePageChange=this.handlePageChange.bind(this);

    }
          handlePageChange(page, evt) {
            this.setState({ currentPage: page  } );
          }
    render() {

        const per_page = "10";
        const paginationData = this.props.results;
        let numPages = Math.ceil(paginationData.length / per_page);

        if (paginationData.length % per_page > 0) {
          numPages++;
        }

        return (

ORDERS LIST

                Order Number
                Customer Name
                Created By

                <SearchResultsList items={ this.props.results } />

                <Pagination id="content" className="users-pagination pull-right" bsSize="medium"
                     first last  next  prev  boundaryLinks items={numPages}
                activePage={ this.state.currentPage } onSelect={ this.handlePageChange } />

        );
    }
}

class SearchResultsList extends React.Component {
    constructor(props) {
        super(props);
        this.state = { };
    }
    render() {
        return (
{ this.props.items
            .map((item, index) => {
                  if (index >= start_offset && start_count < per_page) {
                      start_count++;
                      return <SearchResultsItem key={item.id} item={item} />;

                  }
          })
      }

         );

        }

}

class SearchResultsItem extends React.Component {
    constructor(props) {
        super(props);
        this.state = { };
    }
    render() {
         return(

                    { this.props.item.order_number }
                    { this.props.item.customer_name }
                    { this.props.item.buyer_email }

        );
    }
}

In the last render() method i want to have two table row tags to some fields in next row.

Like the below code.

render() {
     return(

                { this.props.item.order_number }
                { this.props.item.customer_name }
                { this.props.item.buyer_email }

                { this.props.item.buyer_id }
                { this.props.item.buyer_city }
                { this.props.item.buyer_state }

    );
}

But am getting error if i place one more table row tag in return. How i can split table row?

Body:
if you are using  react < v16 , you have to make a small change in your render method.

    render() {
         return(  <tbody> <!-- wrapper element -->
                 <tr>
                    <td>{ this.props.item.order_number }</td>
                    <td>{ this.props.item.customer_name }</td>
                    <td>{ this.props.item.buyer_email }</td>
                </tr>
                <tr>
                    <td>{ this.props.item.buyer_id }</td>
                    <td>{ this.props.item.buyer_city }</td>
                    <td>{ this.props.item.buyer_state }</td>
                </tr>
</tbody>
        );
    }

More details can be seen here in this SO Question


问:
Google BigQuery case insensitive match
How would I run the following query, like I would again mysql:

```<code>SELECT * FROM [integrated-myth-15.testing_data_100k]
WHERE title='down in la'
</code>```

Now it will match if I have a perfect case-sensitive string match, but how would I do it case insensitive for "down in la"? I'm working from the Web console.

答:
The best way is to append "IGNORE CASE" at the end of your query.

```<code>SELECT * FROM [integrated-myth-15.testing_data_100k] WHERE title='down in la' IGNORE CASE
</code>```

Note: This will work only with legacy SQL

As mentioned in the official documentations:

String functions operate on string data. String constants must be enclosed with single or double quotes. String functions are case-sensitive by default. You can append IGNORE CASE to the end of a query to enable case- insensitive matching. IGNORE CASE works only on ASCII characters and only at the top level of the query.

Title: Google BigQuery case insensitive match

Body:
How would I run the following query, like I would again mysql:

SELECT * FROM [integrated-myth-15.testing_data_100k]
WHERE title='down in la'

Now it will match if I have a perfect case-sensitive string match, but how would I do it case insensitive for "down in la"? I'm working from the Web console.

Body:
The best way is to append "IGNORE CASE" at the end of your query.

SELECT * FROM [integrated-myth-15.testing_data_100k] WHERE title='down in la' IGNORE CASE

Note: This will work only with legacy SQL

As mentioned in the official documentations:

String functions operate on string data. String constants must be enclosed with single or double quotes. String functions are case-sensitive by default. You can append IGNORE CASE to the end of a query to enable case- insensitive matching. IGNORE CASE works only on ASCII characters and only at the top level of the query.


问:
momentjs and converting to unix gives wrong date
I am having a bit of trouble getting momentjs to convert a date to unix in the correct way:

```<code>var start = new Date(2013,11,2);
console.log('Start date: '+start);
console.log('Unix date: '+moment(start).unix());
console.log('Unix date 2: '+moment(start).add('hours', 1).unix());

Start date: Mon Dec 02 2013 00:00:00 GMT+0100 (CET)
Unix date: 1385938800
Unix date 2: 1385942400
</code>```

see http://jsfiddle.net/7Equ2/4/

But entering the converted unix date in http://www.onlineconversion.com/unix_time.htm returns Sun, 01 Dec 2013 23:00:00 GMT, whereas adding 1 hour returns the correct unix date. I guess it is because The start date is created in CET (my locale time zone). So I guess I need to pass the start date as UTC, but I have to keep the datevalues (ie. it should still be "Mon Dec 02 2013 00:00:00"). But I cannot figure out how.

I tried

```<code>moment(start).utc().unix(),
</code>```

but that doesn't seem to make any difference as it still returns Unix date: 1385938800

How do I make it return the correct unix date?

答:
Timestamps don't have timezones. They are all relative to UTC.

Sun, 01 Dec 2013 23:00:00 GMT is equal to Mon Dec 02 2013 00:00:00 GMT+0100 if you convert the second to UTC. The solution is including moment-timezone and selecting a default timezone for all moment objects.

```<code>moment.tz.setDefault("UTC");
</code>```

https://momentjs.com/timezone/

https://momentjs.com/timezone/docs/#/using-timezones/default-timezone/

Body:
I am having a bit of trouble getting momentjs to convert a date to unix in the correct way:

var start = new Date(2013,11,2);
console.log('Start date: '+start);
console.log('Unix date: '+moment(start).unix());
console.log('Unix date 2: '+moment(start).add('hours', 1).unix());

Start date: Mon Dec 02 2013 00:00:00 GMT+0100 (CET)
Unix date: 1385938800
Unix date 2: 1385942400

see http://jsfiddle.net/7Equ2/4/

But entering the converted unix date in http://www.onlineconversion.com/unix_time.htm returns Sun, 01 Dec 2013 23:00:00 GMT, whereas adding 1 hour returns the correct unix date. I guess it is because The start date is created in CET (my locale time zone). So I guess I need to pass the start date as UTC, but I have to keep the datevalues (ie. it should still be "Mon Dec 02 2013 00:00:00"). But I cannot figure out how.

I tried

moment(start).utc().unix(),

but that doesn't seem to make any difference as it still returns Unix date: 1385938800

How do I make it return the correct unix date?

Body:
Timestamps don't have timezones. They are all relative to UTC.

Sun, 01 Dec 2013 23:00:00 GMT is equal to Mon Dec 02 2013 00:00:00 GMT+0100 if you convert the second to UTC. The solution is including moment-timezone and selecting a default timezone for all moment objects.

moment.tz.setDefault("UTC");

https://momentjs.com/timezone/

https://momentjs.com/timezone/docs/#/using-timezones/default-timezone/


问:
MOODLE SQL only return results where user is in same group student
```<code>SELECT ra.id,
    DATE_FORMAT(FROM_UNIXTIME(ra.timemodified),'%d-%m-%Y') AS Enrolment_Date,
    c.fullname,
    IFNULL(cmc.completed, 0) as 'Activities Completed',
    u.firstname,
    u.lastname,
    DATE_FORMAT(FROM_UNIXTIME(cc.timecompleted),'%d-%m-%Y') AS complete_date,
    CONCAT('<a target="_new" href="%%WWWROOT%%/user/profile.php?id=',ra.userid,'">', u.firstname, ' ', u.lastname, '</a>') AS Username
FROM prefix_role_assignments AS ra
    JOIN prefix_user u ON ra.userid = u.id
    JOIN prefix_context AS ctx ON ctx.id = ra.contextid
    JOIN prefix_course c ON c.id = ctx.instanceid
    JOIN prefix_enrol e ON e.courseid = c.id
    JOIN prefix_user_enrolments ue ON ue.enrolid = e.id AND ue.userid = u.id
    LEFT JOIN prefix_course_completions cc ON cc.course = c.id AND cc.userid = u.id
    LEFT JOIN prefix_grade_items gi ON gi.courseid = c.id AND gi.itemtype = 'course'
    LEFT JOIN prefix_grade_grades g ON g.itemid = gi.id AND g.userid =u.id
    LEFT JOIN (SELECT cmc.userid, cm.course, COUNT(cmc.id) as completed FROM prefix_course_modules_completion cmc, prefix_course_modules cm WHERE cm.visible = 1 AND cmc.coursemoduleid = cm.id  AND cmc.completionstate IN ('1','2') GROUP BY cm.course, cmc.userid) cmc ON cmc.course = c.id AND cmc.userid = u.id
WHERE u.id > 0 AND (c.id IN(
        SELECT DISTINCT(ctx.instanceid) as id
        FROM prefix_role_assignments ra JOIN prefix_context ctx ON ra.contextid = ctx.id
        WHERE ra.userid = %%USERID%% AND ctx.contextlevel = 50 AND ra.roleid IN ('1','9','2','3','4','10'))
    OR c.id IN(
        SELECT distinct(c.id) as id FROM prefix_role_assignments ra
            JOIN prefix_context ctx ON ra.contextid = ctx.id
            JOIN prefix_course c ON c.category = ctx.instanceid
            WHERE ra.userid = %%USERID%% AND ctx.contextlevel = 40 AND ra.roleid IN ('1','9','2','3','4','10'))
        ) AND u.deleted = 0 AND u.suspended = 0 AND u.username <> 'guest' AND c.visible = 1 AND ue.status = 0 AND e.status = 0 AND ra.roleid = '5'
GROUP BY ra.userid, ctx.instanceid HAVING u.firstname LIKE 'student'  ESCAPE '\\'
</code>```

Hi all,
Im struggling here, I cant seem to get how to only return results from the above query where the user running the query (%%USERID%%) shares the same groups as the student. This is a query cobbled together from a number of other queries and works perfectly except for that one thing.

Ive tried to tack on the following in various ways into this but cant get it to work at all

```<code>SELECT g.name, gm.groupid, u.firstname
FROM mdl_groups as g
    JOIN mdl_groups_members as gm ON g.id = gm.groupid
    JOIN mdl_user as u ON u.id = gm.userid AND u.id = 'student', %%USERID%%'
</code>```

Any help at all even a point in the right direction would be great, this isnt my job role as such but Ive been tasked to make something like this happen.

Thanks for reading

答:
It seems that the subquery boils down to just some userids, but this needs to return rows.

```<code>        SELECT DISTINCT
             gms.userid
        FROM mdl_groups_members gms
        INNER JOIN mdl_groups_members AS gmu ON gms.groupid = gmu.groupid
        WHERE gmu.userid = %%USERID%%
        AND gms.userid LIKE 'student%'
</code>```

If it does then it needs to link to the correct place. Now his is quiet a leap, but  and it "might" be used this way: (select * is not recommended, just an abbreviation):

```<code>SELECT
      *
FROM prefix_role_assignments AS ra
INNER JOIN prefix_user u ON ra.userid = u.id
INNER JOIN (
        SELECT DISTINCT
             gms.userid
        FROM mdl_groups_members gms
        INNER JOIN mdl_groups_members AS gmu ON gms.groupid = gmu.groupid
        WHERE gmu.userid = %%USERID%%
        AND gms.userid LIKE 'student%'
           ) sg ON ra.userid = sg.userid
INNER JOIN prefix_context AS ctx ON ctx.id = ra.contextid
INNER JOIN prefix_course c ON c.id = ctx.instanceid
INNER JOIN prefix_enrol e ON e.courseid = c.id
INNER JOIN prefix_user_enrolments ue ON ue.enrolid = e.id AND ue.userid = u.id
LEFT JOIN prefix_course_completions cc ON cc.course = c.id AND cc.userid = u.id
LEFT JOIN prefix_grade_items gi ON gi.courseid = c.id AND gi.itemtype = 'course'
LEFT JOIN prefix_grade_grades g ON g.itemid = gi.id AND g.userid = u.id
LEFT JOIN (
      SELECT
            cmc.userid
          , cm.course
          , COUNT(cmc.id) AS completed
      FROM prefix_course_modules_completion cmc
         , prefix_course_modules cm
      WHERE cm.visible = 1
      AND cmc.coursemoduleid = cm.id
      AND cmc.completionstate IN ('1', '2')
      GROUP BY
            cm.course
          , cmc.userid
      ) cmc ON cmc.course = c.id AND cmc.userid = u.id
WHERE u.id > 0
AND (
c.id IN (
      SELECT DISTINCT
            (ctx.instanceid) AS id
      FROM prefix_role_assignments ra
      INNER JOIN prefix_context ctx ON ra.contextid = ctx.id
      WHERE ra.userid = %%USERID%% AND ctx.contextlevel = 50
      AND ra.roleid IN ('1', '9', '2', '3', '4', '10')
)
OR c.id IN (
      SELECT DISTINCT
            (c.id) AS id
      FROM prefix_role_assignments ra
      INNER JOIN prefix_context ctx ON ra.contextid = ctx.id
      INNER JOIN prefix_course c ON c.category = ctx.instanceid
      WHERE ra.userid = %%USERID%% AND ctx.contextlevel = 40
      AND ra.roleid IN ('1', '9', '2', '3', '4', '10')
)
)
AND u.deleted = 0
AND u.suspended = 0
AND u.username <> 'guest'
AND c.visible = 1
AND ue.STATUS = 0
AND e.STATUS = 0
AND ra.roleid = '5'
GROUP BY
      ra.userid
    , ctx.instanceid
HAVING u.firstname LIKE 'student%' ESCAPE '\\'
</code>```

Body:
SELECT ra.id,
    DATE_FORMAT(FROM_UNIXTIME(ra.timemodified),'%d-%m-%Y') AS Enrolment_Date,
    c.fullname,
    IFNULL(cmc.completed, 0) as 'Activities Completed',
    u.firstname,
    u.lastname,
    DATE_FORMAT(FROM_UNIXTIME(cc.timecompleted),'%d-%m-%Y') AS complete_date,
    CONCAT('', u.firstname, ' ', u.lastname, '') AS Username
FROM prefix_role_assignments AS ra
    JOIN prefix_user u ON ra.userid = u.id
    JOIN prefix_context AS ctx ON ctx.id = ra.contextid
    JOIN prefix_course c ON c.id = ctx.instanceid
    JOIN prefix_enrol e ON e.courseid = c.id
    JOIN prefix_user_enrolments ue ON ue.enrolid = e.id AND ue.userid = u.id
    LEFT JOIN prefix_course_completions cc ON cc.course = c.id AND cc.userid = u.id
    LEFT JOIN prefix_grade_items gi ON gi.courseid = c.id AND gi.itemtype = 'course'
    LEFT JOIN prefix_grade_grades g ON g.itemid = gi.id AND g.userid =u.id
    LEFT JOIN (SELECT cmc.userid, cm.course, COUNT(cmc.id) as completed FROM prefix_course_modules_completion cmc, prefix_course_modules cm WHERE cm.visible = 1 AND cmc.coursemoduleid = cm.id  AND cmc.completionstate IN ('1','2') GROUP BY cm.course, cmc.userid) cmc ON cmc.course = c.id AND cmc.userid = u.id
WHERE u.id > 0 AND (c.id IN(
        SELECT DISTINCT(ctx.instanceid) as id
        FROM prefix_role_assignments ra JOIN prefix_context ctx ON ra.contextid = ctx.id
        WHERE ra.userid = %%USERID%% AND ctx.contextlevel = 50 AND ra.roleid IN ('1','9','2','3','4','10'))
    OR c.id IN(
        SELECT distinct(c.id) as id FROM prefix_role_assignments ra
            JOIN prefix_context ctx ON ra.contextid = ctx.id
            JOIN prefix_course c ON c.category = ctx.instanceid
            WHERE ra.userid = %%USERID%% AND ctx.contextlevel = 40 AND ra.roleid IN ('1','9','2','3','4','10'))
        ) AND u.deleted = 0 AND u.suspended = 0 AND u.username <> 'guest' AND c.visible = 1 AND ue.status = 0 AND e.status = 0 AND ra.roleid = '5'
GROUP BY ra.userid, ctx.instanceid HAVING u.firstname LIKE 'student'  ESCAPE '\\'

Hi all,
Im struggling here, I cant seem to get how to only return results from the above query where the user running the query (%%USERID%%) shares the same groups as the student. This is a query cobbled together from a number of other queries and works perfectly except for that one thing.

Ive tried to tack on the following in various ways into this but cant get it to work at all

SELECT g.name, gm.groupid, u.firstname
FROM mdl_groups as g
    JOIN mdl_groups_members as gm ON g.id = gm.groupid
    JOIN mdl_user as u ON u.id = gm.userid AND u.id = 'student', %%USERID%%'

Any help at all even a point in the right direction would be great, this isnt my job role as such but Ive been tasked to make something like this happen.

Thanks for reading

Body:
It seems that the subquery boils down to just some userids, but this needs to return rows.

        SELECT DISTINCT
             gms.userid
        FROM mdl_groups_members gms
        INNER JOIN mdl_groups_members AS gmu ON gms.groupid = gmu.groupid
        WHERE gmu.userid = %%USERID%%
        AND gms.userid LIKE 'student%'

If it does then it needs to link to the correct place. Now his is quiet a leap, but  and it "might" be used this way: (select * is not recommended, just an abbreviation):

SELECT
      *
FROM prefix_role_assignments AS ra
INNER JOIN prefix_user u ON ra.userid = u.id
INNER JOIN (
        SELECT DISTINCT
             gms.userid
        FROM mdl_groups_members gms
        INNER JOIN mdl_groups_members AS gmu ON gms.groupid = gmu.groupid
        WHERE gmu.userid = %%USERID%%
        AND gms.userid LIKE 'student%'
           ) sg ON ra.userid = sg.userid
INNER JOIN prefix_context AS ctx ON ctx.id = ra.contextid
INNER JOIN prefix_course c ON c.id = ctx.instanceid
INNER JOIN prefix_enrol e ON e.courseid = c.id
INNER JOIN prefix_user_enrolments ue ON ue.enrolid = e.id AND ue.userid = u.id
LEFT JOIN prefix_course_completions cc ON cc.course = c.id AND cc.userid = u.id
LEFT JOIN prefix_grade_items gi ON gi.courseid = c.id AND gi.itemtype = 'course'
LEFT JOIN prefix_grade_grades g ON g.itemid = gi.id AND g.userid = u.id
LEFT JOIN (
      SELECT
            cmc.userid
          , cm.course
          , COUNT(cmc.id) AS completed
      FROM prefix_course_modules_completion cmc
         , prefix_course_modules cm
      WHERE cm.visible = 1
      AND cmc.coursemoduleid = cm.id
      AND cmc.completionstate IN ('1', '2')
      GROUP BY
            cm.course
          , cmc.userid
      ) cmc ON cmc.course = c.id AND cmc.userid = u.id
WHERE u.id > 0
AND (
c.id IN (
      SELECT DISTINCT
            (ctx.instanceid) AS id
      FROM prefix_role_assignments ra
      INNER JOIN prefix_context ctx ON ra.contextid = ctx.id
      WHERE ra.userid = %%USERID%% AND ctx.contextlevel = 50
      AND ra.roleid IN ('1', '9', '2', '3', '4', '10')
)
OR c.id IN (
      SELECT DISTINCT
            (c.id) AS id
      FROM prefix_role_assignments ra
      INNER JOIN prefix_context ctx ON ra.contextid = ctx.id
      INNER JOIN prefix_course c ON c.category = ctx.instanceid
      WHERE ra.userid = %%USERID%% AND ctx.contextlevel = 40
      AND ra.roleid IN ('1', '9', '2', '3', '4', '10')
)
)
AND u.deleted = 0
AND u.suspended = 0
AND u.username <> 'guest'
AND c.visible = 1
AND ue.STATUS = 0
AND e.STATUS = 0
AND ra.roleid = '5'
GROUP BY
      ra.userid
    , ctx.instanceid
HAVING u.firstname LIKE 'student%' ESCAPE '\\'


问:
InkWell and GestureDetector, how to make them work?
I'd like to use a GestureDetector for it's onTapDown callback but also have a nice InkWell splash effect.

Is it possible to use these two together?

答:
If you want to unconditionally handle the pointer down event with no gesture disambiguation, you can make the InkWell a child of a Listener, and set the onPointerDown handler.

For example:

```<code>new Listener(
  onPointerDown: (e) { print('onPointerDown'); },
  child: new InkWell(
    child: new Text('Tap me'),
    onTap: () { print('onTap'); }
  ),
),
</code>```

It might make sense to add an onTapDown handler to InkWell.

Body:
If you want to unconditionally handle the pointer down event with no gesture disambiguation, you can make the InkWell a child of a Listener, and set the onPointerDown handler.

For example:

new Listener(
  onPointerDown: (e) { print('onPointerDown'); },
  child: new InkWell(
    child: new Text('Tap me'),
    onTap: () { print('onTap'); }
  ),
),

It might make sense to add an onTapDown handler to InkWell.


问:
Text padding on UILabel not working
This post is to complete one I made a while ago titled Text padding on UILabel, left with no answer.

The screenshot below shows it all. The first label, though the shortest is truncated. The second and the third even more have far too wide spaces on the right side. I want to solve those 2 problems.

I made a tiny project and provide it on GitHub to simply illustrate the issu and give other people the opportunity to easily take a close look.

答:
Please update your NSLayoutConstraint like this

```<code>view.addConstraints([
                NSLayoutConstraint(item: label,
                                   attribute: .left,
                                   relatedBy: .lessThanOrEqual,
                                   toItem: view,
                                   attribute: .left,
                                   multiplier: 1.0,
                                   constant: sideMargin),
                NSLayoutConstraint(item: label,
                                   attribute: .right,
                                   relatedBy: .lessThanOrEqual,
                                   toItem: view,
                                   attribute: .right,
                                   multiplier: 1.0,
                                   constant: sideMargin * -2),
                NSLayoutConstraint(item: label,
                                   attribute: .top,
                                   relatedBy: .equal,
                                   toItem: topView,
                                   attribute: firstLoop ? .top : .bottom,
                                   multiplier: 1.0,
                                   constant: sideMargin),
                NSLayoutConstraint(item: label,
                                   attribute: .centerX,
                                   relatedBy: .equal,
                                   toItem: view,
                                   attribute: .centerX,
                                   multiplier: 1,
                                   constant: 0)
                ])
</code>```

Title: Text padding on UILabel not working

Body:
Please update your NSLayoutConstraint like this

view.addConstraints([
                NSLayoutConstraint(item: label,
                                   attribute: .left,
                                   relatedBy: .lessThanOrEqual,
                                   toItem: view,
                                   attribute: .left,
                                   multiplier: 1.0,
                                   constant: sideMargin),
                NSLayoutConstraint(item: label,
                                   attribute: .right,
                                   relatedBy: .lessThanOrEqual,
                                   toItem: view,
                                   attribute: .right,
                                   multiplier: 1.0,
                                   constant: sideMargin * -2),
                NSLayoutConstraint(item: label,
                                   attribute: .top,
                                   relatedBy: .equal,
                                   toItem: topView,
                                   attribute: firstLoop ? .top : .bottom,
                                   multiplier: 1.0,
                                   constant: sideMargin),
                NSLayoutConstraint(item: label,
                                   attribute: .centerX,
                                   relatedBy: .equal,
                                   toItem: view,
                                   attribute: .centerX,
                                   multiplier: 1,
                                   constant: 0)
                ])


问:
XPATH Multiple Element Filters
I have the following sample XML structure:

```<code><SavingAccounts>
    <SavingAccount>
       <ServiceOnline>yes</ServiceOnline>
       <ServiceViaPhone>no</ServiceViaPhone>
    </SavingAccount>
    <SavingAccount>
       <ServiceOnline>no</ServiceOnline>
       <ServiceViaPhone>yes</ServiceViaPhone>
    </SavingAccount>
</SavingAccounts>
</code>```

What I need to do is filter the 'SavingAccount' nodes using XPATH where the value of 'ServiceOnline' is 'yes' or the value of 'ServiceViaPhone' is yes.

The XPATH should return me two rows!! I can filter 'SavingAccount' nodes where both of the element values are yes like the following XPATH sample, but what I want to do is an or element value comparison???

```<code>/SavingAccounts/SavingAccount/ServiceOnline[text()='yes']/../ServiceViaPhone[text()='yes']/..
</code>```

答:
```<code>/SavingAccounts/SavingAccount[(ServiceOnLine='yes') or (ServiceViaPhone='yes')]
</code>```

OwnerDisplayName: CroweMan

LastEditorDisplayName: Dimitre Novatchev

Title: XPATH Multiple Element Filters

Body:
I have the following sample XML structure:

<SavingAccounts>
    <SavingAccount>
       <ServiceOnline>yes</ServiceOnline>
       <ServiceViaPhone>no</ServiceViaPhone>
    </SavingAccount>
    <SavingAccount>
       <ServiceOnline>no</ServiceOnline>
       <ServiceViaPhone>yes</ServiceViaPhone>
    </SavingAccount>
</SavingAccounts>

What I need to do is filter the 'SavingAccount' nodes using XPATH where the value of 'ServiceOnline' is 'yes' or the value of 'ServiceViaPhone' is yes.

The XPATH should return me two rows!! I can filter 'SavingAccount' nodes where both of the element values are yes like the following XPATH sample, but what I want to do is an or element value comparison???

/SavingAccounts/SavingAccount/ServiceOnline[text()='yes']/../ServiceViaPhone[text()='yes']/..

OwnerDisplayName: AnthonyWJones


问:
Heroku: Deploying rails application troubles
I'm trying to deploy my rails application with heroku (as shown here). I've created a very simple rails application (using ruby 1.9.2 and rails 3.0.3; i'm sure heroku supports these - see heroku docs), created and pushed github repo, created heroku repo and pushed it (all commiting is done). And when i'm trying to access my application controller, it throws 404 rails page like it's saying 'there is no such controller'. I've done heroku rake db:migrate but first time i ran it i got 'host not found' error. Running this again fixed that. Well, i'm not sure if i should run heroku addons add:postgresql - i though postgres is on by default, but heroku says i should pay in order to get DB (running command i've mentioned asks me to confirm billing it).

May be it sounds stupid, but how can i deploy my rails application (it's a very simple one) without paying any fees and such troubles as 404 pages like i mentioned in the beginning of my post? (and this is my question). Maybe i should choose other hosting (if it exists in our world) or am i doing something wrong with heroku?

答:
You forgot to push your quotes_controller.rb to git and heroku probably.

```<code>git add controllers/quotes_controller.rb
</code>```

it seems you forgot models also, and probably lot of files.

Body:
You forgot to push your quotes_controller.rb to git and heroku probably.

git add controllers/quotes_controller.rb

it seems you forgot models also, and probably lot of files.


问:
How to debug a facebook messenger bot that is already production without having to use a separate dummy test page?
I will name my first born after whoever answers this question!

How does one test / debug upcoming features for a facebook bot that is already production without having to use a separate dummy test page? (I need to keep it in the same page because user ids are page scoped).

In the facebook dev dashboard I created a test app, subscribed it to the same facebook page, changed its webhook to ngrok and added it some tester roles but the test bot is still receiving all webhooks from the production app instead of only from testers. I would like to have separated production / test bots but within the same fb page.

Please help!

答:
You can detect the test user PSID, then use the handover protocol to pass thread control to the test app.

https://developers.facebook.com/docs/messenger-platform/handover-protocol/


问:
how to scroll table horizontally in android
I am trying to implement table layout in android.I have table Header and row designed in one xml file and am passing data using adapter.So What is happening is I got scrolling horizontally but with multiple table header repeating on each row.
What I want to achieve is table header should be seen only once and all the rows below it should scroll along with table header.

Here's my xml file

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

<HorizontalScrollView  android:id="@+id/horizontalView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:scrollbars="horizontal|vertical"
xmlns:android="http://schemas.android.com/apk/res/android">

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="left"
    android:stretchColumns="*"
    android:divider="@color/black"
    android:showDividers="middle"
    >
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        >

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:text="Name"
            android:textAllCaps="false"
            android:textColor="@color/black"
            android:textSize="18sp"
            android:textStyle="bold|italic" />

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"

            android:text="Type"
            android:textAllCaps="false"
            android:textColor="@color/black"
            android:textSize="18sp"
            android:textStyle="bold|italic" />

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"

            android:text="Fare"
            android:textAllCaps="false"
            android:textColor="@color/black"
            android:textSize="18sp"
            android:textStyle="bold|italic" />

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"

            android:text="Tax"
            android:textAllCaps="false"
            android:textColor="@color/black"
            android:textSize="18sp"
            android:textStyle="bold|italic" />

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"

            android:text="Airline Pnr"
            android:textAllCaps="false"
            android:textColor="@color/black"
            android:textSize="18sp"
            android:textStyle="bold|italic" />

        <TextView
            android:layout_width="120dp"
            android:layout_height="wrap_content"

            android:text="Ticekt Numner"
            android:textAllCaps="false"
            android:textColor="@color/black"
            android:textSize="18sp"
            android:textStyle="bold|italic" />

        <TextView
            android:layout_width="120dp"
            android:layout_height="wrap_content"

            android:text="Cancel"
            android:textAllCaps="false"
            android:textColor="@color/black"
            android:textSize="18sp"
            android:textStyle="bold|italic" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        >

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"

            android:textColor="@color/black"
            android:textSize="18sp"
            android:id="@+id/name"/>
        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:id="@+id/type"
            android:textColor="@color/black"
            android:textSize="18sp" />

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:id="@+id/fare"
            android:textColor="@color/black"
            android:textSize="18sp" />

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:id="@+id/tax"
            android:textColor="@color/black"
            android:textSize="18sp" />
        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:id="@+id/air_pnr"
            android:textColor="@color/black"
            android:textSize="18sp" />

        <TextView
            android:layout_width="120dp"
            android:layout_height="wrap_content"
            android:id="@+id/ticket"
            android:textColor="@color/black"
            android:textSize="18sp" />

        <CheckBox
        android:id="@+id/check_bx"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:text="CANCEL" />
    </TableRow>

   </TableLayout>
   </HorizontalScrollView>
</code>```

And here's the image what it looks likescrolling table

UPDATE (2) HERE's Adapter Code

```<code>public class Flight_cancel_Adapter extends BaseAdapter {
Context context;
public static ArrayList<Flight_cancel_Details> rowItems;
public static int available_seats;
public static PolicyAdapter adapter;
int TOTAL;
public static ArrayList<String> arraySeat=new ArrayList<String>();

    Flight_cancel_Adapter(Context context,  ArrayList<Flight_cancel_Details> rowItems) {

    this.context = context;
    this.rowItems = rowItems;

}
@Override
public int getCount() {
    return rowItems.size();
}

@Override
public Object getItem(int position) {
    return rowItems.get(position);
}

@Override
public long getItemId(int position)
{
    return rowItems.indexOf(getItem(position));
}

/* private view holder class */
private class ViewHolder {
    TextView type;
    TextView fare;
    TextView tax;
    TextView air_pnr;
    TextView ticket;
    TextView namee;
    CheckBox box;

}

@Override
public View getView(int position, View convertView, ViewGroup parent)
{
    final ViewHolder holder;
    LayoutInflater mInflater = (LayoutInflater) context
            .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.test, null);
        holder = new ViewHolder();
    }
    else
    {
        holder = (ViewHolder) convertView.getTag();
    }

    holder.namee = (TextView) convertView.findViewById(R.id.name);
    holder.type = (TextView) convertView.findViewById(R.id.type);
    holder.fare = (TextView) convertView.findViewById(R.id.fare);
    holder.tax = (TextView) convertView.findViewById(R.id.tax);
    holder.air_pnr = (TextView) convertView.findViewById(R.id.air_pnr);
    holder.ticket = (TextView) convertView.findViewById(R.id.ticket);
    holder.box = (CheckBox) convertView.findViewById(R.id.check_bx);
    holder.box.setTag(position);

    try
    {
        final Flight_cancel_Details row_pos = rowItems.get(position);
        String name=String.valueOf(row_pos.getName());
        String typ=String.valueOf(row_pos.gettypes());
        String far=String.valueOf(row_pos.getfares());
        String tax=String.valueOf(row_pos.gettax());
        String pnr=String.valueOf(row_pos.getair_pnr());
        String ticket=String.valueOf(row_pos.getticket());

        System.out.print("ROW POS-"+row_pos.getStatus());
        if(row_pos.getStatus().equals("CANCELLED"))
        {
            holder.namee.setText(name);
            holder.type.setText(typ);
            holder.fare.setText(far);
            holder.tax.setText(tax);
            holder.air_pnr.setText(pnr);
            holder.ticket.setText(ticket);

            holder.box.setEnabled(false);
            holder.box.setText("CANCELLED");

        }else {

            holder.namee.setText(name);
            holder.type.setText(typ);
            holder.fare.setText(far);
            holder.tax.setText(tax);
            holder.air_pnr.setText(pnr);
            holder.ticket.setText(ticket);

            holder.box.setEnabled(true);
            holder.box.setText("CANCEL");
        }
        if(row_pos.getTarvel_Status().equals("TRAVELLED"))
        {
            holder.namee.setText(name);
            holder.type.setText(typ);
            holder.fare.setText(far);
            holder.tax.setText(tax);
            holder.air_pnr.setText(pnr);
            holder.ticket.setText(ticket);

        }

    }
    catch (Exception e)
    {
        Log.e("BUS_CANCEL_ADAP ERROR:", e.getMessage());
    }
    convertView.setTag(holder);

    holder.box.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
           if(isChecked) {
               int position = (int) buttonView.getTag();
               System.out.println("--CLICKED--" + position);
               String contactId = (holder.air_pnr.getText().toString());
               System.out.println("--VALUE--" + contactId);
               arraySeat.add(contactId);
           }
           else
               {
                   int position = (int) buttonView.getTag();
                   System.out.println("--UNCHEKED--" + position);
                   String contactId = (holder.air_pnr.getText().toString());
                   System.out.println("--UNCHEKED VALUE--" + contactId);
                   arraySeat.remove(contactId);
               }
        }
    });

    return convertView;

}
}
</code>```

答:
Here my XML file, you should put title for all row TableView (TextView) on LinearLayout.

```<code><?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView  android:id="@+id/horizontalView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="5dip"
    android:scrollbars="horizontal|vertical"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <!--Title for all row, once for all row -->
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TextView
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:text="Name"
                android:textAllCaps="false"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold|italic" />

            <TextView
                android:layout_width="100dp"
                android:layout_height="wrap_content"

                android:text="Type"
                android:textAllCaps="false"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold|italic" />

            <TextView
                android:layout_width="100dp"
                android:layout_height="wrap_content"

                android:text="Fare"
                android:textAllCaps="false"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold|italic" />

            <TextView
                android:layout_width="100dp"
                android:layout_height="wrap_content"

                android:text="Tax"
                android:textAllCaps="false"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold|italic" />

            <TextView
                android:layout_width="100dp"
                android:layout_height="wrap_content"

                android:text="Airline Pnr"
                android:textAllCaps="false"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold|italic" />

            <TextView
                android:layout_width="120dp"
                android:layout_height="wrap_content"

                android:text="Ticekt Numner"
                android:textAllCaps="false"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold|italic" />

            <TextView
                android:layout_width="120dp"
                android:layout_height="wrap_content"

                android:text="Cancel"
                android:textAllCaps="false"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold|italic" />
        </LinearLayout>

        <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="left"
            android:stretchColumns="*"
            android:divider="@color/black"
            android:showDividers="middle"
            >
            <TableRow
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                >

                <TextView
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:text="My Name"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    android:id="@+id/name"/>
                <TextView
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:id="@+id/type"
                    android:text="My Type"
                    android:textColor="@color/black"
                    android:textSize="18sp" />

                <TextView
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:id="@+id/fare"
                    android:textColor="@color/black"
                    android:textSize="18sp" />

                <TextView
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:id="@+id/tax"
                    android:textColor="@color/black"
                    android:textSize="18sp" />
                <TextView
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:id="@+id/air_pnr"
                    android:textColor="@color/black"
                    android:textSize="18sp" />

                <TextView
                    android:layout_width="120dp"
                    android:layout_height="wrap_content"
                    android:id="@+id/ticket"
                    android:textColor="@color/black"
                    android:textSize="18sp" />

                <CheckBox
                    android:id="@+id/check_bx"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"

                    android:text="CANCEL" />
            </TableRow>
        </TableLayout>
    </LinearLayout>

</HorizontalScrollView>
</code>```

Body:
I am trying to implement table layout in android.I have table Header and row designed in one xml file and am passing data using adapter.So What is happening is I got scrolling horizontally but with multiple table header repeating on each row.
What I want to achieve is table header should be seen only once and all the rows below it should scroll along with table header.

Here's my xml file

<?xml version="1.0" encoding="utf-8"?>

<HorizontalScrollView  android:id="@+id/horizontalView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:scrollbars="horizontal|vertical"
xmlns:android="http://schemas.android.com/apk/res/android">

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="left"
    android:stretchColumns="*"
    android:divider="@color/black"
    android:showDividers="middle"
    >
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        >

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:text="Name"
            android:textAllCaps="false"
            android:textColor="@color/black"
            android:textSize="18sp"
            android:textStyle="bold|italic" />

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"

            android:text="Type"
            android:textAllCaps="false"
            android:textColor="@color/black"
            android:textSize="18sp"
            android:textStyle="bold|italic" />

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"

            android:text="Fare"
            android:textAllCaps="false"
            android:textColor="@color/black"
            android:textSize="18sp"
            android:textStyle="bold|italic" />

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"

            android:text="Tax"
            android:textAllCaps="false"
            android:textColor="@color/black"
            android:textSize="18sp"
            android:textStyle="bold|italic" />

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"

            android:text="Airline Pnr"
            android:textAllCaps="false"
            android:textColor="@color/black"
            android:textSize="18sp"
            android:textStyle="bold|italic" />

        <TextView
            android:layout_width="120dp"
            android:layout_height="wrap_content"

            android:text="Ticekt Numner"
            android:textAllCaps="false"
            android:textColor="@color/black"
            android:textSize="18sp"
            android:textStyle="bold|italic" />

        <TextView
            android:layout_width="120dp"
            android:layout_height="wrap_content"

            android:text="Cancel"
            android:textAllCaps="false"
            android:textColor="@color/black"
            android:textSize="18sp"
            android:textStyle="bold|italic" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        >

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"

            android:textColor="@color/black"
            android:textSize="18sp"
            android:id="@+id/name"/>
        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:id="@+id/type"
            android:textColor="@color/black"
            android:textSize="18sp" />

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:id="@+id/fare"
            android:textColor="@color/black"
            android:textSize="18sp" />

        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:id="@+id/tax"
            android:textColor="@color/black"
            android:textSize="18sp" />
        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:id="@+id/air_pnr"
            android:textColor="@color/black"
            android:textSize="18sp" />

        <TextView
            android:layout_width="120dp"
            android:layout_height="wrap_content"
            android:id="@+id/ticket"
            android:textColor="@color/black"
            android:textSize="18sp" />

        <CheckBox
        android:id="@+id/check_bx"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:text="CANCEL" />
    </TableRow>

   </TableLayout>
   </HorizontalScrollView>

And here's the image what it looks likescrolling table

UPDATE (2) HERE's Adapter Code

public class Flight_cancel_Adapter extends BaseAdapter {
Context context;
public static ArrayList<Flight_cancel_Details> rowItems;
public static int available_seats;
public static PolicyAdapter adapter;
int TOTAL;
public static ArrayList<String> arraySeat=new ArrayList<String>();

    Flight_cancel_Adapter(Context context,  ArrayList<Flight_cancel_Details> rowItems) {

    this.context = context;
    this.rowItems = rowItems;

}
@Override
public int getCount() {
    return rowItems.size();
}

@Override
public Object getItem(int position) {
    return rowItems.get(position);
}

@Override
public long getItemId(int position)
{
    return rowItems.indexOf(getItem(position));
}

/* private view holder class */
private class ViewHolder {
    TextView type;
    TextView fare;
    TextView tax;
    TextView air_pnr;
    TextView ticket;
    TextView namee;
    CheckBox box;

}

@Override
public View getView(int position, View convertView, ViewGroup parent)
{
    final ViewHolder holder;
    LayoutInflater mInflater = (LayoutInflater) context
            .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.test, null);
        holder = new ViewHolder();
    }
    else
    {
        holder = (ViewHolder) convertView.getTag();
    }

    holder.namee = (TextView) convertView.findViewById(R.id.name);
    holder.type = (TextView) convertView.findViewById(R.id.type);
    holder.fare = (TextView) convertView.findViewById(R.id.fare);
    holder.tax = (TextView) convertView.findViewById(R.id.tax);
    holder.air_pnr = (TextView) convertView.findViewById(R.id.air_pnr);
    holder.ticket = (TextView) convertView.findViewById(R.id.ticket);
    holder.box = (CheckBox) convertView.findViewById(R.id.check_bx);
    holder.box.setTag(position);

    try
    {
        final Flight_cancel_Details row_pos = rowItems.get(position);
        String name=String.valueOf(row_pos.getName());
        String typ=String.valueOf(row_pos.gettypes());
        String far=String.valueOf(row_pos.getfares());
        String tax=String.valueOf(row_pos.gettax());
        String pnr=String.valueOf(row_pos.getair_pnr());
        String ticket=String.valueOf(row_pos.getticket());

        System.out.print("ROW POS-"+row_pos.getStatus());
        if(row_pos.getStatus().equals("CANCELLED"))
        {
            holder.namee.setText(name);
            holder.type.setText(typ);
            holder.fare.setText(far);
            holder.tax.setText(tax);
            holder.air_pnr.setText(pnr);
            holder.ticket.setText(ticket);

            holder.box.setEnabled(false);
            holder.box.setText("CANCELLED");

        }else {

            holder.namee.setText(name);
            holder.type.setText(typ);
            holder.fare.setText(far);
            holder.tax.setText(tax);
            holder.air_pnr.setText(pnr);
            holder.ticket.setText(ticket);

            holder.box.setEnabled(true);
            holder.box.setText("CANCEL");
        }
        if(row_pos.getTarvel_Status().equals("TRAVELLED"))
        {
            holder.namee.setText(name);
            holder.type.setText(typ);
            holder.fare.setText(far);
            holder.tax.setText(tax);
            holder.air_pnr.setText(pnr);
            holder.ticket.setText(ticket);

        }

    }
    catch (Exception e)
    {
        Log.e("BUS_CANCEL_ADAP ERROR:", e.getMessage());
    }
    convertView.setTag(holder);

    holder.box.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
           if(isChecked) {
               int position = (int) buttonView.getTag();
               System.out.println("--CLICKED--" + position);
               String contactId = (holder.air_pnr.getText().toString());
               System.out.println("--VALUE--" + contactId);
               arraySeat.add(contactId);
           }
           else
               {
                   int position = (int) buttonView.getTag();
                   System.out.println("--UNCHEKED--" + position);
                   String contactId = (holder.air_pnr.getText().toString());
                   System.out.println("--UNCHEKED VALUE--" + contactId);
                   arraySeat.remove(contactId);
               }
        }
    });

    return convertView;

}
}

Body:
Here my XML file, you should put title for all row TableView (TextView) on LinearLayout.

<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView  android:id="@+id/horizontalView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="5dip"
    android:scrollbars="horizontal|vertical"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <!--Title for all row, once for all row -->
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TextView
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:text="Name"
                android:textAllCaps="false"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold|italic" />

            <TextView
                android:layout_width="100dp"
                android:layout_height="wrap_content"

                android:text="Type"
                android:textAllCaps="false"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold|italic" />

            <TextView
                android:layout_width="100dp"
                android:layout_height="wrap_content"

                android:text="Fare"
                android:textAllCaps="false"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold|italic" />

            <TextView
                android:layout_width="100dp"
                android:layout_height="wrap_content"

                android:text="Tax"
                android:textAllCaps="false"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold|italic" />

            <TextView
                android:layout_width="100dp"
                android:layout_height="wrap_content"

                android:text="Airline Pnr"
                android:textAllCaps="false"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold|italic" />

            <TextView
                android:layout_width="120dp"
                android:layout_height="wrap_content"

                android:text="Ticekt Numner"
                android:textAllCaps="false"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold|italic" />

            <TextView
                android:layout_width="120dp"
                android:layout_height="wrap_content"

                android:text="Cancel"
                android:textAllCaps="false"
                android:textColor="@color/black"
                android:textSize="18sp"
                android:textStyle="bold|italic" />
        </LinearLayout>

        <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="left"
            android:stretchColumns="*"
            android:divider="@color/black"
            android:showDividers="middle"
            >
            <TableRow
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                >

                <TextView
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:text="My Name"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    android:id="@+id/name"/>
                <TextView
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:id="@+id/type"
                    android:text="My Type"
                    android:textColor="@color/black"
                    android:textSize="18sp" />

                <TextView
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:id="@+id/fare"
                    android:textColor="@color/black"
                    android:textSize="18sp" />

                <TextView
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:id="@+id/tax"
                    android:textColor="@color/black"
                    android:textSize="18sp" />
                <TextView
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:id="@+id/air_pnr"
                    android:textColor="@color/black"
                    android:textSize="18sp" />

                <TextView
                    android:layout_width="120dp"
                    android:layout_height="wrap_content"
                    android:id="@+id/ticket"
                    android:textColor="@color/black"
                    android:textSize="18sp" />

                <CheckBox
                    android:id="@+id/check_bx"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"

                    android:text="CANCEL" />
            </TableRow>
        </TableLayout>
    </LinearLayout>

</HorizontalScrollView>


问:
Do These Extension Methods Look Correct?
In VB.NET, I am creating extension methods for the SqlParameterCollection class so that I can add "detailed" parameters in one line of code. I understand that the .AddWithValue method will cause SQL Server to re-evaluate an SQL Server execution plan each time a Stored Procedure is called via an SqlCommand with SqlParameter objects that do not specify the size of alphanumeric data types (i.e. VarChar or NVarChar). In other words, .AddWithValue is a bad idea except for types like INT data types where the size of the data type is constant.

I've never used Extension Methods before, so does this code appear to accomplish what I want? The code "works", but I'm looking for another set of eyes to make sure I'm not ending up with parameters that will force re-evaluation of an SQL Server execution plan.

EDIT: I had to actually add the parameter to the "params" collection, so I've updated the code. Now it "works" ;-)

```<code>Imports System.Runtime.CompilerServices

Public Module AdoParameterExtensions

    <System.Runtime.CompilerServices.Extension()> _
    Public Sub AddWithNumericValue(ByVal params As System.Data.SqlClient.SqlParameterCollection, ByVal parameterName As String, ByVal parameterType As SqlDbType, ByVal value As Object)

        Dim newParam As New System.Data.SqlClient.SqlParameter

        With newParam

            .ParameterName = parameterName
            .SqlDbType = parameterType
            .Value = value

        End With

        params.Add(newParam)

    End Sub

    <System.Runtime.CompilerServices.Extension()> _
    Public Sub AddWithStringValue(ByVal params As System.Data.SqlClient.SqlParameterCollection, ByVal parameterName As String, ByVal parameterType As SqlDbType, ByVal size As Integer, ByVal value As Object)

        Dim newParam As New System.Data.SqlClient.SqlParameter

        With newParam

            .ParameterName = parameterName
            .SqlDbType = parameterType
            .Size = size
            .Value = value

        End With

        params.Add(newParam)

    End Sub

End Module
</code>```

Thanks for your feedback.

答:
Your extensions look fine.  Whether or not the SQL Server execution plan well be re-evaluated won't be affected by using an Extension method.

One recommendation I'd make is to return the SqlParameterCollection instead of void (Sub).  Parameters can then be added fluently.

Instead of

```<code>params.AddWithNumericValue(...)
params.AddWithNumericValue(...)
params.AddWithNumericValue(...)
</code>```

you write as

```<code>params.AddWithNumericValue(...).AddWithNumericValue(...).AddWithNumericValue(...)
</code>```

It's a preference, but with extensions like this I've come to appreciate the style.

Body:
In VB.NET, I am creating extension methods for the SqlParameterCollection class so that I can add "detailed" parameters in one line of code. I understand that the .AddWithValue method will cause SQL Server to re-evaluate an SQL Server execution plan each time a Stored Procedure is called via an SqlCommand with SqlParameter objects that do not specify the size of alphanumeric data types (i.e. VarChar or NVarChar). In other words, .AddWithValue is a bad idea except for types like INT data types where the size of the data type is constant.

I've never used Extension Methods before, so does this code appear to accomplish what I want? The code "works", but I'm looking for another set of eyes to make sure I'm not ending up with parameters that will force re-evaluation of an SQL Server execution plan.

EDIT: I had to actually add the parameter to the "params" collection, so I've updated the code. Now it "works" ;-)

Imports System.Runtime.CompilerServices

Public Module AdoParameterExtensions

    <System.Runtime.CompilerServices.Extension()> _
    Public Sub AddWithNumericValue(ByVal params As System.Data.SqlClient.SqlParameterCollection, ByVal parameterName As String, ByVal parameterType As SqlDbType, ByVal value As Object)

        Dim newParam As New System.Data.SqlClient.SqlParameter

        With newParam

            .ParameterName = parameterName
            .SqlDbType = parameterType
            .Value = value

        End With

        params.Add(newParam)

    End Sub

    <System.Runtime.CompilerServices.Extension()> _
    Public Sub AddWithStringValue(ByVal params As System.Data.SqlClient.SqlParameterCollection, ByVal parameterName As String, ByVal parameterType As SqlDbType, ByVal size As Integer, ByVal value As Object)

        Dim newParam As New System.Data.SqlClient.SqlParameter

        With newParam

            .ParameterName = parameterName
            .SqlDbType = parameterType
            .Size = size
            .Value = value

        End With

        params.Add(newParam)

    End Sub

End Module

Thanks for your feedback.

Body:
Your extensions look fine.  Whether or not the SQL Server execution plan well be re-evaluated won't be affected by using an Extension method.

One recommendation I'd make is to return the SqlParameterCollection instead of void (Sub).  Parameters can then be added fluently.

Instead of

params.AddWithNumericValue(...)
params.AddWithNumericValue(...)
params.AddWithNumericValue(...)

you write as

params.AddWithNumericValue(...).AddWithNumericValue(...).AddWithNumericValue(...)

It's a preference, but with extensions like this I've come to appreciate the style.


问:
How to center two letters inside this css drawn circle?
Using this Codepen example and additional CSS, how would I center the letters "AB" within the circle?
https://codepen.io/joseph-mueller/pen/bNEeGw
This is what I want:

.referral-credit-outer-circle {
  background: #fff;
  width: 92px;
  height: 92px;
  border-radius: 90px;
  box-shadow: 0 0 0 2px #fff, 0 0 0 6px #666;
  margin: 20px;
  position: absolute;
}

.mask-referral-credit-inner-circle {
  transform: rotate(180deg);
  width: 100%;
  height: 50%;
  overflow: hidden;
  position: absolute;
  bottom: 0;
}

.referral-credit-inner-circle {
  width: 80px;
  height: 80px;
  border-radius: 80px;
  border: solid 6px #7aaeda;
  background: #95bee1;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="referral-credit-outer-circle">
  <span class="referral-credit-inner-icon" data-icon="H" style="color:"></span>
  <div class="mask-referral-credit-inner-circle" style="height: 70%">
    <div class="referral-credit-inner-circle"></div>
  </div>
</div></code>```

答:
.referral-credit-outer-circle {
  background: #fff;
  width: 92px;
  height: 92px;
  border-radius: 90px;
  box-shadow: 0 0 0 2px #fff, 0 0 0 6px #666;
  margin: 20px;
  position: absolute;
}

/* Added CSS style */

.referral-credit-outer-circle::after {
  content: 'AB';
  position: absolute;
  left: 0;
  right: 0;
  margin: auto;
  text-align: center;
  font-size: 32px;
  font-weight: bold;
  margin-top: 20px;
}

.mask-referral-credit-inner-circle {
  transform: rotate(180deg);
  width: 100%;
  height: 50%;
  overflow: hidden;
  position: absolute;
  bottom: 0;
}

.referral-credit-inner-circle {
  width: 80px;
  height: 80px;
  border-radius: 80px;
  border: solid 6px #7aaeda;
  background: #95bee1;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="referral-credit-outer-circle">
  <span class="referral-credit-inner-icon" data-icon="H" style="color:"></span>
  <div class="mask-referral-credit-inner-circle" style="height: 70%">
    <div class="referral-credit-inner-circle"></div>
  </div>
</div></code>```

Try this.

Body:
.referral-credit-outer-circle {
  background: #fff;
  width: 92px;
  height: 92px;
  border-radius: 90px;
  box-shadow: 0 0 0 2px #fff, 0 0 0 6px #666;
  margin: 20px;
  position: absolute;
}

/* Added CSS style */

.referral-credit-outer-circle::after {
  content: 'AB';
  position: absolute;
  left: 0;
  right: 0;
  margin: auto;
  text-align: center;
  font-size: 32px;
  font-weight: bold;
  margin-top: 20px;
}

.mask-referral-credit-inner-circle {
  transform: rotate(180deg);
  width: 100%;
  height: 50%;
  overflow: hidden;
  position: absolute;
  bottom: 0;
}

.referral-credit-inner-circle {
  width: 80px;
  height: 80px;
  border-radius: 80px;
  border: solid 6px #7aaeda;
  background: #95bee1;
}

<div class="referral-credit-outer-circle">
  <span class="referral-credit-inner-icon" data-icon="H" style="color:"></span>
  <div class="mask-referral-credit-inner-circle" style="height: 70%">
    <div class="referral-credit-inner-circle"></div>
  </div>
</div>

Try this.


答:
Change your css</p>

```<code>.referral-credit-outer-circle{
  background: #fff;
  width: 92px;
  height:92px;
  border-radius:90px;
    box-shadow: 0 0 0 2px #fff, 0 0 0 6px #666;
  margin: 20px;
  position: absolute;

}

.mask-referral-credit-inner-circle{
  transform: rotate(180deg);
  width: 100%;
  height: 50%;
  overflow: hidden;
  position: absolute;
  bottom: 0;

}

.referral-credit-inner-circle{
  width: 80px;
  height:80px;
  border-radius:80px;
  border: solid 6px #7aaeda;
  background: #95bee1;
  line-height:80px;
  text-align:center;
  transform: rotate(180deg);
}
</code>```

Title: How to center two letters inside this css drawn circle?

Body:
Using this Codepen example and additional CSS, how would I center the letters "AB" within the circle?
https://codepen.io/joseph-mueller/pen/bNEeGw
This is what I want:

.referral-credit-outer-circle {
  background: #fff;
  width: 92px;
  height: 92px;
  border-radius: 90px;
  box-shadow: 0 0 0 2px #fff, 0 0 0 6px #666;
  margin: 20px;
  position: absolute;
}

.mask-referral-credit-inner-circle {
  transform: rotate(180deg);
  width: 100%;
  height: 50%;
  overflow: hidden;
  position: absolute;
  bottom: 0;
}

.referral-credit-inner-circle {
  width: 80px;
  height: 80px;
  border-radius: 80px;
  border: solid 6px #7aaeda;
  background: #95bee1;
}

Body:
Change your css

.referral-credit-outer-circle{
  background: #fff;
  width: 92px;
  height:92px;
  border-radius:90px;
    box-shadow: 0 0 0 2px #fff, 0 0 0 6px #666;
  margin: 20px;
  position: absolute;

}

.mask-referral-credit-inner-circle{
  transform: rotate(180deg);
  width: 100%;
  height: 50%;
  overflow: hidden;
  position: absolute;
  bottom: 0;

}

.referral-credit-inner-circle{
  width: 80px;
  height:80px;
  border-radius:80px;
  border: solid 6px #7aaeda;
  background: #95bee1;
  line-height:80px;
  text-align:center;
  transform: rotate(180deg);
}


问:
Compile .java files or .class files in eclipse
I have done some changes in my .java files in eclipse...ie. I have passed one more parameter in a method..
but how to compile it so that the changes will be seen in .class files</p>

答:
It's simple follow below steps::
* Goto Project in menu bar

select clean from submenu. And select project you want to clean then ok.

In above image you can configure some build options, before ok.

if you have checked build automatically in project menu, then project build automatically. Otherwise select 'build project'.