问:
django 405 method not allowed
The error occurs when I request via post method.

views.py

```<code>class ConceptForkView(ConceptBaseView, mixins.CreateModelMixin):
    print 'oclapi ConceptForkView111'

    def dispatch(self, request, *args, **kwargs):
        print 'oclapi ConceptForkView dispatch'
        return super(ConceptForkView, self).dispatch(request, *args, **kwargs)

    def post(self, request):
        print 'oclapi ConceptForkView post'
</code>```

urls.py

url(r'^forking/$', ConceptForkView.as_view(), name='concept-forking'),

ConceptBaseView

```<code>class ConceptBaseView(ChildResourceMixin):

    lookup_field = 'concept'
    pk_field = 'mnemonic'
    model = Concept
    permission_classes = (CanViewParentDictionary,)
    child_list_attribute = 'concepts'
</code>```

The command print 'oclapi ConceptForkView111' can run, but the method dispatch and post don't run. What is the reason?

I have searched many solutions, but they don't work to me. How can I solve  this problem? Thank you.

答:
try using

```<code>def create(request, *args, **kwargs)
    ...
</code>```

method instead of

```<code>def post(self, request):
    ...
</code>```

CreateModelMixin uses create method rather than post method

Title: django 405 method not allowed

Body:
The error occurs when I request via post method.

views.py

class ConceptForkView(ConceptBaseView, mixins.CreateModelMixin):
    print 'oclapi ConceptForkView111'

    def dispatch(self, request, *args, **kwargs):
        print 'oclapi ConceptForkView dispatch'
        return super(ConceptForkView, self).dispatch(request, *args, **kwargs)

    def post(self, request):
        print 'oclapi ConceptForkView post'

urls.py

url(r'^forking/$', ConceptForkView.as_view(), name='concept-forking'),

ConceptBaseView

class ConceptBaseView(ChildResourceMixin):

    lookup_field = 'concept'
    pk_field = 'mnemonic'
    model = Concept
    permission_classes = (CanViewParentDictionary,)
    child_list_attribute = 'concepts'

The command print 'oclapi ConceptForkView111' can run, but the method dispatch and post don't run. What is the reason?

I have searched many solutions, but they don't work to me. How can I solve  this problem? Thank you.

Body:
try using

def create(request, *args, **kwargs)
    ...

method instead of

def post(self, request):
    ...

CreateModelMixin uses create method rather than post method


来源: stackexchange

问:
what are pros and cons to define constant local variables as static ( c++)?
```<code>void Animation::playAnimation() const
{
    static const int index = 0;
    const std::string& animationFileName = m_animationContainer.getAnimationName(index);
    static const int zOrder = -1;
    static bool isLooping = false;

    AnimationBank::play(animationFileName,
                        zOrder,
                        isLooping);
}
</code>```

what are pros and cons to define constant local variables as static?
what is an overhead of defining index, zOrder, isLooping as static. Is there any benefit to do this?

答: Yes, you will have a little bit overhead when using static variables in function, since each time your program execute that function it has to check whether these static variables initialized.</p>

ContentLicense: CC BY-SA 3.0

Body:
void Animation::playAnimation() const
{
    static const int index = 0;
    const std::string& animationFileName = m_animationContainer.getAnimationName(index);
    static const int zOrder = -1;
    static bool isLooping = false;

    AnimationBank::play(animationFileName,
                        zOrder,
                        isLooping);
}

what are pros and cons to define constant local variables as static?
what is an overhead of defining index, zOrder, isLooping as static. Is there any benefit to do this?


问:
pytest -k flag with and statement
According to the pytest documentation I should be able to use the 'and' expression like this:

```<code>pytest -k stringexpr # only run tests with names that match the
                     # "string expression", e.g. "MyClass and not method"
                     # will select TestMyClass.test_something
                     # but not TestMyClass.test_method_simple
</code>```

What I tried out was this expression:

```<code>pytest -v test_file.py -k “TestTest and not test_bad”
</code>```

And the error I got was:

```<code>ERROR: file not found: and
</code>```

Other variations I have tried that ended in the same failure:

```<code>pytest -v -k “TestTest and not test_bad”
pytest -v -k “TestTest and not test_bad” test_file.py
</code>```

Finally my pytest version is: 3.0.3

答:
Your “ and ” are some weird typographical quotes, instead of the " ascii quote used to prevent terminal argument splitting, which means your pytest actually gets four arguments: “TestTest, and, not and test_bad”.

Your example works fine for me when using " instead.

Title: pytest -k flag with and statement

Body:
According to the pytest documentation I should be able to use the 'and' expression like this:

pytest -k stringexpr # only run tests with names that match the
                     # "string expression", e.g. "MyClass and not method"
                     # will select TestMyClass.test_something
                     # but not TestMyClass.test_method_simple

What I tried out was this expression:

pytest -v test_file.py -k “TestTest and not test_bad”

And the error I got was:

ERROR: file not found: and

Other variations I have tried that ended in the same failure:

pytest -v -k “TestTest and not test_bad”
pytest -v -k “TestTest and not test_bad” test_file.py

Finally my pytest version is: 3.0.3


问:
Select Data from Table and Insert into a different DB
I'm using python and psycopg2 to remotely query some psql databases, and I'm trying to figure out the best way to select the data I need from the remote table, and insert it into a table on a separate DB (local application server).

Most of the stuff I've read has directed me to avoid executemany and look toward COPY operations, but I'm unsure how to implement this on a specific select statement as opposed to the entire table. Should I be headed this way or am I completely off?

答:
but I'm unsure how to implement this on a specific select statement as opposed to the entire table

COPY isn't limited to tables, you can use a query as the source as well, check out the examples in the manual, it shows how to use COPY to create a text file based on a query:

http://www.postgresql.org/docs/current/static/sql-copy.html#AEN59055
(3rd example)

ContentLicense: CC BY-SA 2.5


问:
What is the length maximum for a string data type in MongoDB used with Ruby?
I wasn't able to find any information on the max length for a string data type in MongoDB on the main mongodb.org site.  I'm coming from a relational database background and there are usually max lengths.  Thank you!</p>

答:
See this:

The maximum BSON document size is 16 megabytes. The maximum document
  size helps ensure that a single document cannot use excessive amount
  of RAM or, during transmission, excessive amount of bandwidth. To
  store documents larger than the maximum size, MongoDB provides the
  GridFS API.


问:
Unable to inspect/debug Qualtrics Javascript code in Firefox
I have added a very simple javascript/jQuery code in Qualtrics.  It is working fine.  But, for my own understanding and since I might be integrating more complex jQuery codes with Qualtrics in the future, I wanted to examine the flow in Firefox.  I tried both Firebug as well as the browser's inbuilt Web Developer tools, but I am unable to see any navigation into the javascript code.  In fact, Firebug is saying there are no javascript codes.

Following are my firefox and firebug versions:
Firefox 53.0.3
Firebug 2.0.19

Any help will be appreciated.

PS:  My Qualtrics code:

```<code>Qualtrics.SurveyEngine.addOnload(function()
{
   /*Place Your JavaScript Here*/

   var txtItem =jQuery("#hiddentext");

   if (txtItem.length ) {
        //alert("jquery retrieval worked - DOM element found");

        txtItem.fadeIn(5000);
        txtItem.css({"background-color": "yellow", "font-size": "200%", "display": "inline"});

    } else {
        alert("jquery retrieval did not work - DOM element NOT found");
    }
});
</code>```

答:
Place a breakpoint within your script or add a debugger; statement where you want the script execution to stop.

If it doesn't stop at the expected line, this may have two reasons:

An exception thrown before the execution reaches your line. In that case you should check the console for JavaScript errors. Stopping the script execution on exceptions can be disabled via Debugger settings (little gear icon at the right side of the panel) > Pause on exceptions.

It is a bug in the Firefox DevTools. In that case you should first check whether this issue can be reproduced in Firefox Nightly (which has a new debugger UI). If it can be reproduced there, you should file a bug report for it.

Body:
I have added a very simple javascript/jQuery code in Qualtrics.  It is working fine.  But, for my own understanding and since I might be integrating more complex jQuery codes with Qualtrics in the future, I wanted to examine the flow in Firefox.  I tried both Firebug as well as the browser's inbuilt Web Developer tools, but I am unable to see any navigation into the javascript code.  In fact, Firebug is saying there are no javascript codes.

Following are my firefox and firebug versions:
Firefox 53.0.3
Firebug 2.0.19

Any help will be appreciated.

PS:  My Qualtrics code:

Qualtrics.SurveyEngine.addOnload(function()
{
   /*Place Your JavaScript Here*/

   var txtItem =jQuery("#hiddentext");

   if (txtItem.length ) {
        //alert("jquery retrieval worked - DOM element found");

        txtItem.fadeIn(5000);
        txtItem.css({"background-color": "yellow", "font-size": "200%", "display": "inline"});

    } else {
        alert("jquery retrieval did not work - DOM element NOT found");
    }
});


问:
Add two quotes in JavaScript
I have a code like this :

 var event = {
  "temperature" : 12.45,
  "humidite" : 45.78,
  "built" : "charone",
  "fire" : "chartwo",
  "topic" : "sk1_001/data"
 };

var keys = Object.keys(event);

 valeurs_d = "";
 for (var i = 0; i < keys.length -1 ; i++)
 valeurs_d += event[keys[i]] + ", ";
 var str5 = ",";
 var str6 = str5.concat(valeurs_d);
 var valeurs = str6.substring (0, str6.length - 2);  console.log(valeurs); ```
</div>
</div>
</p>

<p>I want to have everything between two quotes in variable <code>valeurs</code> like this:</p>

<pre class="lang-none prettyprint-override"><code>, '12 .45 ', '45 .78', 'charone', 'chartwo'
</code>```

Or, just have the character strings between two quotes:

, 12.45, 45.78, 'charone', 'chartwo'
```

I can have in my JSON other strings.

How can I do this in JavaScript?

答:
You could check the type and add some quotes around.

var event = { temperature : 12.45, humidite : 45.78, built : "charone", fire : "chartwo", topic : "sk1_001/data" },
    result = ',' + Object
        .keys(event)
        .slice(0, -1)
        .map(k => typeof event[k] === 'string' ? '\'' + event[k] + '\'' : event[k])
        .join(',');

console.log(result);```

Title: Add two quotes in JavaScript

Body:
I have a code like this :

 var event = {
  "temperature" : 12.45,
  "humidite" : 45.78,
  "built" : "charone",
  "fire" : "chartwo",
  "topic" : "sk1_001/data"
 };

var keys = Object.keys(event);

 valeurs_d = "";
 for (var i = 0; i < keys.length -1 ; i++)
 valeurs_d += event[keys[i]] + ", ";
 var str5 = ",";
 var str6 = str5.concat(valeurs_d);
 var valeurs = str6.substring (0, str6.length - 2);  console.log(valeurs);

I want to have everything between two quotes in variable valeurs like this:

, '12 .45 ', '45 .78', 'charone', 'chartwo'

Or, just have the character strings between two quotes:

, 12.45, 45.78, 'charone', 'chartwo'

I can have in my JSON other strings.

How can I do this in JavaScript?


问:
how to combine many chart in one page on excel?
I have a assignment with statistic. And I have issue on chart. I want to combine many chart to one sheet.  let's say I have a three of chart then I want combine it to one page no need to separate 3 file excel. I want to combine to one file of excel. how can I do ?   </p>

答:
You can place charts on a regular Excel worksheet and arrange several charts so they print on the same page. You can use the page layout view on the View ribbon to help with sizing and positioning the charts on the page.

This screenshot shows the page layout view with three charts.


问:
Pseudoelement selector for inserting icon inside of another element
I would like to use some pseudo-element selector (:before, :after) for including a text or icon on :hover inside some other element. Is there a way how to do that only with pseudo-element selectors? I would like to NOT actually change the content of that element as it's content is loaded from localStorage.

My vision is to visually add some click-able icon (✗, ) when hovering over the header.

```<code><header contenteditable="true" id="title" onkeyup="store(this.id);"></header>
</code>```

Thank you for your suggestions.

答:
You can add your icon as background-image .

```<code> header{
 position:relative;
 }

 header:before{
 content:" ";
 position:absolute;
 top:0;
 left:0;
 width:5px;
 height:5px;
 background: url(icon.png) no-repeat ;

 }
</code>```

Body:
I would like to use some pseudo-element selector (:before, :after) for including a text or icon on :hover inside some other element. Is there a way how to do that only with pseudo-element selectors? I would like to NOT actually change the content of that element as it's content is loaded from localStorage.

My vision is to visually add some click-able icon (✗, ) when hovering over the header.

Thank you for your suggestions.

Body:
You can add your icon as background-image .

 header{
 position:relative;
 }

 header:before{
 content:" ";
 position:absolute;
 top:0;
 left:0;
 width:5px;
 height:5px;
 background: url(icon.png) no-repeat ;

 }


问:
Xib to ViewController
I have TableViewCell.xib file where in each cell there can be summary of data like name, contact etc. Now if I touch the cell it will go to another ViewController where there will be details of that cell's data.(it does not matter what this ViewController shows). I want to go to another ViewController from this xib file's cell touch. how can I do that.

Edit:

CallHistoryTableViewCell.h

```<code>@interface CallHistoryTableViewCell : UITableViewCell
    @property(nonatomic, strong) IBOutlet UILabel *contactName;
    @property(nonatomic, strong) IBOutlet UILabel *contactNumber;
@end
</code>```

this class has CallHistoryTableViewCell.xib file.

CallHistoryVC.h

```<code>@interface CallHistoryVC : UIViewController
@end
</code>```

CallHistoryVC.m

```<code>#import "CallHistoryVC.h"
#import "CallHistoryTableViewCell.h"

@interface CallHistoryVC ()<UITableViewDelegate, UITableViewDataSource,CallingViewControllerDelegate> {
AppDelegate *appDelegate;

}
@property (nonatomic, strong) NSMutableArray<RecentCall> *sortedEventArray;
@property (weak, nonatomic) IBOutlet UITableView *tView;

- (void)viewDidLoad {
[super viewDidLoad];
appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
//---add one contact---//
[self defaultViewSetting];
_tView.delegate = self;
_tView.dataSource = self;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}

 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 75;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _sortedEventArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CallHistoryTableViewCell";

return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
DetailsOfHistory *storyViewController = [mainStoryBoard instantiateViewControllerWithIdentifier:@"DetailsOfHistory"];
//[self presentViewController:storyViewController animated:YES completion:nil]; //  present it
[self.navigationController pushViewController:storyViewController animated:YES];// or push it

NSLog(@"%ld",(long)indexPath.row);
}
</code>```

Everything works fine but in didSelectRowAtIndexPath indexPath is not showing that means touch not working. By click on the cell I want to go to another viewcontroller in stroyboard.

答:
If you want to register custom cell as xib do the following in viewDidLoad

```<code>[self.tableView registerNib:@"YourNibName" forCellReuseIdentifier:@"YourCellId"];
</code>```

yourXibname:

YourCellid:

By the way, in your cellForRowAtIndexPath: do like this.

```<code>yourCustomCell *cell = (yourCustomCell *)[tableView dequeueReusableCellWithIdentifier:@"yourCellId"];
</code>```

Title: Xib to ViewController

Body:
I have TableViewCell.xib file where in each cell there can be summary of data like name, contact etc. Now if I touch the cell it will go to another ViewController where there will be details of that cell's data.(it does not matter what this ViewController shows). I want to go to another ViewController from this xib file's cell touch. how can I do that.

Edit:

CallHistoryTableViewCell.h

@interface CallHistoryTableViewCell : UITableViewCell
    @property(nonatomic, strong) IBOutlet UILabel *contactName;
    @property(nonatomic, strong) IBOutlet UILabel *contactNumber;
@end

this class has CallHistoryTableViewCell.xib file.

CallHistoryVC.h

@interface CallHistoryVC : UIViewController
@end

CallHistoryVC.m

#import "CallHistoryVC.h"
#import "CallHistoryTableViewCell.h"

@interface CallHistoryVC ()<UITableViewDelegate, UITableViewDataSource,CallingViewControllerDelegate> {
AppDelegate *appDelegate;

}
@property (nonatomic, strong) NSMutableArray<RecentCall> *sortedEventArray;
@property (weak, nonatomic) IBOutlet UITableView *tView;

- (void)viewDidLoad {
[super viewDidLoad];
appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
//---add one contact---//
[self defaultViewSetting];
_tView.delegate = self;
_tView.dataSource = self;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}

 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 75;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _sortedEventArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CallHistoryTableViewCell";

return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
DetailsOfHistory *storyViewController = [mainStoryBoard instantiateViewControllerWithIdentifier:@"DetailsOfHistory"];
//[self presentViewController:storyViewController animated:YES completion:nil]; //  present it
[self.navigationController pushViewController:storyViewController animated:YES];// or push it

NSLog(@"%ld",(long)indexPath.row);
}

Everything works fine but in didSelectRowAtIndexPath indexPath is not showing that means touch not working. By click on the cell I want to go to another viewcontroller in stroyboard.

Body:
If you want to register custom cell as xib do the following in viewDidLoad

[self.tableView registerNib:@"YourNibName" forCellReuseIdentifier:@"YourCellId"];

yourXibname:

YourCellid:

By the way, in your cellForRowAtIndexPath: do like this.

yourCustomCell *cell = (yourCustomCell *)[tableView dequeueReusableCellWithIdentifier:@"yourCellId"];


问:
How to make Excel VBA to ignore formula cells with if condition
I want to use if condition to perform ClearContents task. Please find my below code for the same. I written below 2 code's, but both are unsuccessful.

First Try

```<code>t = 1
Do While Cells(t, 1) <> ""
    If Cells(t, 1) <> "=" Then
        Cells(t, 1).ClearContents
    End If
    t = t + 1
Loop
</code>```

Second Try

```<code>t = 1
Do While Cells(t, 1) <> ""
    If Cells(t, 1) <> Formula Then
        Cells(t, 1).ClearContents
    End If
    t = t + 1
Loop
</code>```

Basically, I don't want to delete the cells contain where formulas are available but I want to delete the other data.

答:
Write something like this:

```<code>If Not Cells(t,1).HasFormula Then

End if
</code>```

It would work. Or try like this:

```<code>Sub TestMe()

    If Not Cells(1, 1).HasFormula Then
        Debug.Print "No Formula"
    Else
        Debug.Print "Has Formula"
    End If

End Sub
</code>```

Here is more info about the .HasFormula property:

https://msdn.microsoft.com/en-us/library/office/ff837123.aspx

Body:
I want to use if condition to perform ClearContents task. Please find my below code for the same. I written below 2 code's, but both are unsuccessful.

First Try

t = 1
Do While Cells(t, 1) <> ""
    If Cells(t, 1) <> "=" Then
        Cells(t, 1).ClearContents
    End If
    t = t + 1
Loop

Second Try

t = 1
Do While Cells(t, 1) <> ""
    If Cells(t, 1) <> Formula Then
        Cells(t, 1).ClearContents
    End If
    t = t + 1
Loop

Basically, I don't want to delete the cells contain where formulas are available but I want to delete the other data.

Body:
Write something like this:

If Not Cells(t,1).HasFormula Then

End if

It would work. Or try like this:

Sub TestMe()

    If Not Cells(1, 1).HasFormula Then
        Debug.Print "No Formula"
    Else
        Debug.Print "Has Formula"
    End If

End Sub

Here is more info about the .HasFormula property:

https://msdn.microsoft.com/en-us/library/office/ff837123.aspx

ContentLicense: CC BY-SA 4.0


问:
incompatible datasets[CaseClass] when loading from oracle and
We load data from oracle into a dataset: like this.

```<code>val dataset = sqlContext.read.format("jdbc").options(Map(
  "driver" -> applicationConfig.getString("oracle.driver"),
  "url" -> applicationConfig.getString("oracle.url"),
  "user" -> applicationConfig.getString("oracle.user"),
  "password" -> applicationConfig.getString("oracle.password"),
  "dbtable" -> query
)).load().as[CaseClass]
</code>```

CaseClass looks like:

```<code>case class CaseClass (
  RELNR: Long = null,
  INS_CONTACTHIST_DATE: Timestamp = null,
  CONTACTDATETIME: Timestamp = null,
  CONTACTSTATUSID: Long = null,
  ...
</code>```

I want to create a new DataSet[CaseClass]

```<code>import sqlContext.implicits._
val acc = sqlContext.createDataset[CaseClass](Seq())
</code>```

and fill it in a few iterations with filtered data from dataset:

```<code> val possibilities = dataset.filter(c => predicate(c))
 acc.union(possibilities)
</code>```

This fails with an error: unresolved operator 'Union; From SO I learned that this has to do with incompatible datasets, and doing a printSchema() on both datasets confirms that some columntypes are incompatible:

```<code>Oracle:
|-- RELNR: decimal(10,0) (nullable = true)
|-- INS_CONTACTHIST_DATE: date (nullable = true)
|-- CONTACTDATETIME: timestamp (nullable = true)
|-- CONTACTSTATUSID: decimal(19,0) (nullable = true)

empty dataset:
|-- RELNR: long (nullable = true)
|-- INS_CONTACTHIST_DATE: timestamp (nullable = true)
|-- CONTACTDATETIME: timestamp (nullable = true)
|-- CONTACTSTATUSID: long (nullable = true)
</code>```

How can I make the union work? or how can I force the population by the sqlcontext.read(..) to use the CaseClass' property types?

答:
This SO answer basically nails it down. I modified the creation of the empty dataset like:</p>

```<code>sqlContext.createDataset[CaseClass](Seq()).selectExpr(
  "ROW_ID",
  "cast (RELNR as Decimal(10,0)) RELNR",
  ...
).as[CaseClass]
</code>```

Body:
We load data from oracle into a dataset: like this.

val dataset = sqlContext.read.format("jdbc").options(Map(
  "driver" -> applicationConfig.getString("oracle.driver"),
  "url" -> applicationConfig.getString("oracle.url"),
  "user" -> applicationConfig.getString("oracle.user"),
  "password" -> applicationConfig.getString("oracle.password"),
  "dbtable" -> query
)).load().as[CaseClass]

CaseClass looks like:

case class CaseClass (
  RELNR: Long = null,
  INS_CONTACTHIST_DATE: Timestamp = null,
  CONTACTDATETIME: Timestamp = null,
  CONTACTSTATUSID: Long = null,
  ...

I want to create a new DataSet[CaseClass]

import sqlContext.implicits._
val acc = sqlContext.createDataset[CaseClass](Seq())

and fill it in a few iterations with filtered data from dataset:

 val possibilities = dataset.filter(c => predicate(c))
 acc.union(possibilities)

This fails with an error: unresolved operator 'Union; From SO I learned that this has to do with incompatible datasets, and doing a printSchema() on both datasets confirms that some columntypes are incompatible:

Oracle:
|-- RELNR: decimal(10,0) (nullable = true)
|-- INS_CONTACTHIST_DATE: date (nullable = true)
|-- CONTACTDATETIME: timestamp (nullable = true)
|-- CONTACTSTATUSID: decimal(19,0) (nullable = true)

empty dataset:
|-- RELNR: long (nullable = true)
|-- INS_CONTACTHIST_DATE: timestamp (nullable = true)
|-- CONTACTDATETIME: timestamp (nullable = true)
|-- CONTACTSTATUSID: long (nullable = true)

How can I make the union work? or how can I force the population by the sqlcontext.read(..) to use the CaseClass' property types?

Body:
This SO answer basically nails it down. I modified the creation of the empty dataset like:

sqlContext.createDataset[CaseClass](Seq()).selectExpr(
  "ROW_ID",
  "cast (RELNR as Decimal(10,0)) RELNR",
  ...
).as[CaseClass]


问:
How to run Tomcat using ansible
I have been stuck on this problem for a while now. In my Ansible playbook, when I try to do the following:

```<code>- name: Start tomcat
  command: "/tomcat/bin/startup.sh"
</code>```

On running playbook I see it running the task successfully, but when I try to check on target machine:

```<code>  ps -ef | grep tomcat
</code>```

Tomcat is not running.

I have looked up SO questions like https://superuser.com/questions/870871/run-a-remote-script-application-in-detached-mode-in-ansible but not sure as to how it will work. I also get the script from https://github.com/ansible/ansible-examples/blob/master/tomcat-standalone/roles/tomcat/files/tomcat-initscript.sh and try to run it as

```<code>- name: Start Tomcat
  script: /tmp/tomcat-initscript.sh
</code>```

but doesnt help. Any pointers will be appreciated. Thanks.

答:
I tried several options on a couple of Ubuntu VMs. Using the startup.sh works for me.

Here's a snippet of the task from my playbook

```<code> - name: Start Tomcat
   command: "nohup /Path_To_Catalina_Home/bin/startup.sh"
   tags: startTomcat
</code>```

Title: How to run Tomcat using ansible

Body:
I have been stuck on this problem for a while now. In my Ansible playbook, when I try to do the following:

- name: Start tomcat
  command: "/tomcat/bin/startup.sh"

On running playbook I see it running the task successfully, but when I try to check on target machine:

  ps -ef | grep tomcat

Tomcat is not running.

I have looked up SO questions like https://superuser.com/questions/870871/run-a-remote-script-application-in-detached-mode-in-ansible but not sure as to how it will work. I also get the script from https://github.com/ansible/ansible-examples/blob/master/tomcat-standalone/roles/tomcat/files/tomcat-initscript.sh and try to run it as

- name: Start Tomcat
  script: /tmp/tomcat-initscript.sh

but doesnt help. Any pointers will be appreciated. Thanks.

Body:
I tried several options on a couple of Ubuntu VMs. Using the startup.sh works for me.

Here's a snippet of the task from my playbook

 - name: Start Tomcat
   command: "nohup /Path_To_Catalina_Home/bin/startup.sh"
   tags: startTomcat


问:
Using get() and set() in Java
I have seen several get() and set() methods used for private fields. And I also understand why its being used.

But what I dont understand is that, I have my Student class with private fields in them. So why is it when I remove the get() and set(), it still works (for example, method to print).

Or is it still working because its in the same file class? but say if I try calling the private field without defining the get() and set() method from an external class. It wont work?

This is my code with the get() and set()

```<code>public class Student {
    private String name;
    private String address;
    private String degreeName;
    private String department;
    private String yearCommence;
    private long studentID;
    private static int nextID = 901000 ;

    public String getName() {
        return name;
    }
    public String getAddress() {
        return address;
    }
    public String getDegreeName() {
        return degreeName;
    }
    public String getDepartment() {
        return department;
    }
    public String getYearCommence() {
        return yearCommence;
    }
    public void setName(String name) {
        this.name = name;
    }
    public void setAddress(String address) {
        this.name = address;
    }
    public void setDegreeName(String degreeName) {
        this.degreeName = degreeName;
    }
    public void setDepartment(String department) {
        this.department = department;
    }
    public void setYearCommence(String yearCommence) {
        this.department = yearCommence;
    }

    public Student(String name, String address, String degreeName, String department, String yearCommence, long StudentID) {
        this.name = name;
        this.address = address;
        this.degreeName = degreeName;
        this.department = department;
        this.yearCommence = yearCommence;
        this.studentID = nextID++;
    }

    public Student(String name, String address, String degreeName, String department, long studentID) {
        this(name, address, degreeName, department, null, studentID);
    }
    public Student(String name, String address, String degreeName, long studentID) {
        this(name, address, degreeName, null, null, studentID);
    }
    public Student(String name, String address, long studentID) {
        this(name, address, null, null, null, studentID);
    }
    public Student(String name, long studentID) {
        this(name, null, null, null, null, studentID);
    }
    public Student(long studentID) {
        this(null, null, null, null, null, studentID);
    }

    @Override
    public String toString() {
        return "StudentInfo {" + "name=" + name + ", address=" + address + ", degreeName=" + degreeName + ", department=" + department + ", commence = " + yearCommence +", "+ " "+ "studentID = " + studentID+ "}";
    }

    public static void main(String[] args) {
        ArrayList<Student> students = new ArrayList<>();

        Student student1 = new Student("Yusuf", "jl.ANU", "IT", "CECS", null, Student.nextID);
        students.add(student1);
        System.out.println(student1);

        Student student2 = new Student("Ning", "jl.Cikini","IT", null, null, Student.nextID);
        students.add(student2);
        System.out.println(student2);

        Student student3 = new Student("Boris", "jl.Babi", Student.nextID);
        students.add(student3);
        System.out.println(student3);

        Student student4 = new Student(null, null, null, null, null, Student.nextID);
        students.add(student4);
        System.out.println(student4);
    }
}
</code>```

答:
It work mostly because you never used those getter/setter.

You create the instances and call toString on it (not directly, but System.out.println will do it)

But, let say you had another class where you build an instance Student student = new Student.... And you have :

```<code>student.name = name; //This is directly accessing the private field "name"
stuendt.setName(name); //This is using the setter of "name"
</code>```

Java will not translate a direct access of the variable into a call of the getter/setter by itself, you have to do it. You can't expect the JVM to call setName if you write the first line.

For the scope where those values are accessible, I let you read the others answers. Don't need to say it one more time.

Please note that you are note using the parameter for the ID

```<code>public Student(String name, String address, String degreeName, String department, String yearCommence, long StudentID) {
    this.name = name;
    this.address = address;
    this.degreeName = degreeName;
    this.department = department;
    this.yearCommence = yearCommence;
    this.studentID = nextID++;
}
</code>```

You still use nextID insteand of StudentID. Personnaly, I would not ask for that parameter if I am using a static value directly. You could simply remove it from the parameters list.

Title: Using get() and set() in Java

Body:
I have seen several get() and set() methods used for private fields. And I also understand why its being used.

But what I dont understand is that, I have my Student class with private fields in them. So why is it when I remove the get() and set(), it still works (for example, method to print).

Or is it still working because its in the same file class? but say if I try calling the private field without defining the get() and set() method from an external class. It wont work?

This is my code with the get() and set()

public class Student {
    private String name;
    private String address;
    private String degreeName;
    private String department;
    private String yearCommence;
    private long studentID;
    private static int nextID = 901000 ;

    public String getName() {
        return name;
    }
    public String getAddress() {
        return address;
    }
    public String getDegreeName() {
        return degreeName;
    }
    public String getDepartment() {
        return department;
    }
    public String getYearCommence() {
        return yearCommence;
    }
    public void setName(String name) {
        this.name = name;
    }
    public void setAddress(String address) {
        this.name = address;
    }
    public void setDegreeName(String degreeName) {
        this.degreeName = degreeName;
    }
    public void setDepartment(String department) {
        this.department = department;
    }
    public void setYearCommence(String yearCommence) {
        this.department = yearCommence;
    }

    public Student(String name, String address, String degreeName, String department, String yearCommence, long StudentID) {
        this.name = name;
        this.address = address;
        this.degreeName = degreeName;
        this.department = department;
        this.yearCommence = yearCommence;
        this.studentID = nextID++;
    }

    public Student(String name, String address, String degreeName, String department, long studentID) {
        this(name, address, degreeName, department, null, studentID);
    }
    public Student(String name, String address, String degreeName, long studentID) {
        this(name, address, degreeName, null, null, studentID);
    }
    public Student(String name, String address, long studentID) {
        this(name, address, null, null, null, studentID);
    }
    public Student(String name, long studentID) {
        this(name, null, null, null, null, studentID);
    }
    public Student(long studentID) {
        this(null, null, null, null, null, studentID);
    }

    @Override
    public String toString() {
        return "StudentInfo {" + "name=" + name + ", address=" + address + ", degreeName=" + degreeName + ", department=" + department + ", commence = " + yearCommence +", "+ " "+ "studentID = " + studentID+ "}";
    }

    public static void main(String[] args) {
        ArrayList<Student> students = new ArrayList<>();

        Student student1 = new Student("Yusuf", "jl.ANU", "IT", "CECS", null, Student.nextID);
        students.add(student1);
        System.out.println(student1);

        Student student2 = new Student("Ning", "jl.Cikini","IT", null, null, Student.nextID);
        students.add(student2);
        System.out.println(student2);

        Student student3 = new Student("Boris", "jl.Babi", Student.nextID);
        students.add(student3);
        System.out.println(student3);

        Student student4 = new Student(null, null, null, null, null, Student.nextID);
        students.add(student4);
        System.out.println(student4);
    }
}

Body:
It work mostly because you never used those getter/setter.

You create the instances and call toString on it (not directly, but System.out.println will do it)

But, let say you had another class where you build an instance Student student = new Student.... And you have :

student.name = name; //This is directly accessing the private field "name"
stuendt.setName(name); //This is using the setter of "name"

Java will not translate a direct access of the variable into a call of the getter/setter by itself, you have to do it. You can't expect the JVM to call setName if you write the first line.

For the scope where those values are accessible, I let you read the others answers. Don't need to say it one more time.

Please note that you are note using the parameter for the ID

public Student(String name, String address, String degreeName, String department, String yearCommence, long StudentID) {
    this.name = name;
    this.address = address;
    this.degreeName = degreeName;
    this.department = department;
    this.yearCommence = yearCommence;
    this.studentID = nextID++;
}

You still use nextID insteand of StudentID. Personnaly, I would not ask for that parameter if I am using a static value directly. You could simply remove it from the parameters list.


问:
Can't install packages in Atom, in app or cmd
I'm trying to install linter for atom, however both in the app and in cmd I get:

INFO: Could not find files for the given pattern(s).

\Java\jre7\bin";C:\Program Files
  (x86)\QuickTime\QTSystem\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\AMD\ATI.ACE\Core-Static;C:\Program Files (x86)\Brackets\command;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files (x86)\GtkSharp\2.12\bin;" was unexpected at this time.

And I honestly don't know what that means, but I've tried searching for an answer and I can't find it. "atom -v" returns the version (1.10.0), "apm -v" returns the above, as well as any apm command. "where apm" returns

C:\Users\JM\AppData\Local\atom\bin\apm

C:\Users\JM\AppData\Local\atom\bin\apm.cmd

答:
There is other solution:

got to folder with packages

git clone https://github.com/developer/some_pack.git

cd some_pack

npm install

apm link

it works fine


问:
getting PLSQL numeric or value error for below code
```<code>    Declare
            TYPE cur_type IS REF CURSOR;
            v_owner varchar2(40);
             v_table_name varchar2(40);
             v_column_name varchar2(100);
            ln_col_variable VARCHAR2(20000) := Null;
            sql_fetch       VARCHAR2(30000) := Null;
             l_xmltype XMLTYPE;
             col_var  varchar2(2000);

               enquiry_cur cur_type;

              /* First cursor */
                  CURSOR get_tables IS
                  SELECT DISTINCT  tbl.table_name
                   FROM user_tab_columns tbl
                   WHERE tbl.column_name='ENQUIRY_NO';

              /* Second cursor */
                        CURSOR get_columns IS
                         SELECT DISTINCT col.column_name
                         FROM user_tab_columns col
                          -- WHERE col.owner = v_owner
                        WHERE col.table_name = v_table_name;

                  BEGIN
                      dbms_output.enable(1000000);
                    -- Open first cursor
                          OPEN get_tables;

                   LOOP
                 FETCH get_tables INTO  v_table_name;
                 exit when  get_tables%notfound;
                 DBMS_OUTPUT.PUT_LINE(v_table_name);
                 dbms_output.put_line('----------------------');

                         -- Open second cursor
                  OPEN get_columns;
                  LOOP
               FETCH get_columns INTO v_column_name;
                exit when get_columns%notfound;
               dbms_output.put_line(v_column_name);
               ln_col_variable :=ln_col_variable||','||v_column_name;

               col_var:=replace(substr(ln_col_variable,1,1),',','*');

               --dbms_output.put_line(col_var);
                 /*  Loop
         ln_col_variable :=ln_col_variable||','||v_column_name;

                      End Loop;*/
         -- ln_col_variable :=ln_col_variable||sysdate;
         --  sql_fetch       := 'Select '||ln_col_variable||'           From '||v_table_name;
             -- dbms_output.put_line(sql_fetch);
                          END LOOP;
                sql_fetch := 'Select '||col_var||' From '||v_table_name;

           OPEN enquiry_cur FOR sql_fetch ;

                  l_xmltype := XMLTYPE(enquiry_cur);
                 dbms_output.put_line(l_xmltype.getClobVal);
                  CLOSE get_columns;

   END LOOP;

   CLOSE get_tables;

         EXCEPTION
           WHEN OTHERS THEN  raise_application_error(-20001,'An              encountered  '||SQLCODE||'        -ERROR- '||SQLERRM);
                   end ;
</code>```

<p>I m getting Plsql  numeric or value error for line 74 . want to get the xml output for sql_fetch   string .  used utl_files  but  couldn't get the xml output  .The tables  are only  dynamically  known .the  table structure also  is known at compile time </p>

答:
There are a few errors to your code. You need to correct that before you could solve your actual error. Your cursor get_columns is parameterised and you are not passing any value to it. See below:

```<code>DECLARE
   TYPE cur_type IS REF CURSOR;

   v_owner           VARCHAR2 (40);
   v_table_name      VARCHAR2 (40);
   v_column_name     VARCHAR2 (100);
   ln_col_variable   VARCHAR2 (20000) := NULL;
   sql_fetch         VARCHAR2 (30000) := NULL;
   l_xmltype         XMLTYPE;
   col_var           VARCHAR2 (2000);

   enquiry_cur       cur_type;

   /* First cursor */
   CURSOR get_tables
   IS
      SELECT DISTINCT tbl.table_name
        FROM user_tab_columns tbl
       WHERE tbl.column_name = 'COL1';

   /* Second cursor */
   CURSOR get_columns(v_table_name varchar)
   IS
      SELECT DISTINCT col.column_name
        FROM user_tab_columns col
       -- WHERE col.owner = v_owner
       WHERE col.table_name = v_table_name; --<--using a variable here
BEGIN
   --DBMS_OUTPUT.enable (1000000);

   -- Open first cursor
   OPEN get_tables;

   LOOP
      FETCH get_tables INTO v_table_name;

      EXIT WHEN get_tables%NOTFOUND;
      DBMS_OUTPUT.PUT_LINE (v_table_name);
      DBMS_OUTPUT.put_line ('----------------------');

      -- Open second cursor
      OPEN get_columns(v_table_name); --<--You need to pass parameter to cursor

      LOOP

         FETCH get_columns INTO v_column_name;

         EXIT WHEN get_columns%NOTFOUND;
         DBMS_OUTPUT.put_line (v_column_name);
         ln_col_variable := ln_col_variable || ',' || v_column_name;

         col_var := REPLACE (SUBSTR (ln_col_variable, 1, 1), ',', '*');
      --dbms_output.put_line(col_var);
        /*  Loop
             ln_col_variable :=ln_col_variable||','||v_column_name;

             End Loop;*/
      -- ln_col_variable :=ln_col_variable||sysdate;
      --  sql_fetch       := 'Select '||ln_col_variable||'           From '||v_table_name;
      -- dbms_output.put_line(sql_fetch);
      END LOOP;

      sql_fetch := 'Select ' || col_var || ' From ' || v_table_name;

      OPEN enquiry_cur FOR sql_fetch;

      l_xmltype := XMLTYPE (enquiry_cur);

      DBMS_OUTPUT.put_line (l_xmltype.getClobVal);

      CLOSE get_columns;
   END LOOP;

   CLOSE get_tables;
EXCEPTION
   WHEN OTHERS
   THEN
      raise_application_error (
         -20001,
            'An              encountered  '
         || SQLCODE
         || '        -ERROR- '
         || SQLERRM);
END;
</code>```

Once the code is corrected, you need to make sure that all the tables you are referring in cursor get_tables should have at least 1 row else you will get PL/SQL: numeric or value error.

Output:

```<code>SQL> set serverout on
SQL> /
TABL1
----------------------
COL1
<?xml version="1.0"?>
<ROWSET>
 <ROW>
  <COL1>1</COL1>
 </ROW>
 <ROW>

<COL1>2</COL1>
 </ROW>
 <ROW>
  <COL1>A</COL1>
 </ROW>
 <ROW>
  <COL1>B2</COL1>

</ROW>
</ROWSET>

TABL2
----------------------
COL1
<?xml version="1.0"?>
<ROWSET>
 <ROW>
  <COL1>1</COL1>
 </ROW>
</ROWSET>
</code>```

Body:
    Declare
            TYPE cur_type IS REF CURSOR;
            v_owner varchar2(40);
             v_table_name varchar2(40);
             v_column_name varchar2(100);
            ln_col_variable VARCHAR2(20000) := Null;
            sql_fetch       VARCHAR2(30000) := Null;
             l_xmltype XMLTYPE;
             col_var  varchar2(2000);

               enquiry_cur cur_type;

              /* First cursor */
                  CURSOR get_tables IS
                  SELECT DISTINCT  tbl.table_name
                   FROM user_tab_columns tbl
                   WHERE tbl.column_name='ENQUIRY_NO';

              /* Second cursor */
                        CURSOR get_columns IS
                         SELECT DISTINCT col.column_name
                         FROM user_tab_columns col
                          -- WHERE col.owner = v_owner
                        WHERE col.table_name = v_table_name;

                  BEGIN
                      dbms_output.enable(1000000);
                    -- Open first cursor
                          OPEN get_tables;

                   LOOP
                 FETCH get_tables INTO  v_table_name;
                 exit when  get_tables%notfound;
                 DBMS_OUTPUT.PUT_LINE(v_table_name);
                 dbms_output.put_line('----------------------');

                         -- Open second cursor
                  OPEN get_columns;
                  LOOP
               FETCH get_columns INTO v_column_name;
                exit when get_columns%notfound;
               dbms_output.put_line(v_column_name);
               ln_col_variable :=ln_col_variable||','||v_column_name;

               col_var:=replace(substr(ln_col_variable,1,1),',','*');

               --dbms_output.put_line(col_var);
                 /*  Loop
         ln_col_variable :=ln_col_variable||','||v_column_name;

                      End Loop;*/
         -- ln_col_variable :=ln_col_variable||sysdate;
         --  sql_fetch       := 'Select '||ln_col_variable||'           From '||v_table_name;
             -- dbms_output.put_line(sql_fetch);
                          END LOOP;
                sql_fetch := 'Select '||col_var||' From '||v_table_name;

           OPEN enquiry_cur FOR sql_fetch ;

                  l_xmltype := XMLTYPE(enquiry_cur);
                 dbms_output.put_line(l_xmltype.getClobVal);
                  CLOSE get_columns;

   END LOOP;

   CLOSE get_tables;

         EXCEPTION
           WHEN OTHERS THEN  raise_application_error(-20001,'An              encountered  '||SQLCODE||'        -ERROR- '||SQLERRM);
                   end ;

I m getting Plsql  numeric or value error for line 74 . want to get the xml output for sql_fetch   string .  used utl_files  but  couldn't get the xml output  .The tables  are only  dynamically  known .the  table structure also  is known at compile time

Body:
There are a few errors to your code. You need to correct that before you could solve your actual error. Your cursor get_columns is parameterised and you are not passing any value to it. See below:

DECLARE
   TYPE cur_type IS REF CURSOR;

   v_owner           VARCHAR2 (40);
   v_table_name      VARCHAR2 (40);
   v_column_name     VARCHAR2 (100);
   ln_col_variable   VARCHAR2 (20000) := NULL;
   sql_fetch         VARCHAR2 (30000) := NULL;
   l_xmltype         XMLTYPE;
   col_var           VARCHAR2 (2000);

   enquiry_cur       cur_type;

   /* First cursor */
   CURSOR get_tables
   IS
      SELECT DISTINCT tbl.table_name
        FROM user_tab_columns tbl
       WHERE tbl.column_name = 'COL1';

   /* Second cursor */
   CURSOR get_columns(v_table_name varchar)
   IS
      SELECT DISTINCT col.column_name
        FROM user_tab_columns col
       -- WHERE col.owner = v_owner
       WHERE col.table_name = v_table_name; --<--using a variable here
BEGIN
   --DBMS_OUTPUT.enable (1000000);

   -- Open first cursor
   OPEN get_tables;

   LOOP
      FETCH get_tables INTO v_table_name;

      EXIT WHEN get_tables%NOTFOUND;
      DBMS_OUTPUT.PUT_LINE (v_table_name);
      DBMS_OUTPUT.put_line ('----------------------');

      -- Open second cursor
      OPEN get_columns(v_table_name); --<--You need to pass parameter to cursor

      LOOP

         FETCH get_columns INTO v_column_name;

         EXIT WHEN get_columns%NOTFOUND;
         DBMS_OUTPUT.put_line (v_column_name);
         ln_col_variable := ln_col_variable || ',' || v_column_name;

         col_var := REPLACE (SUBSTR (ln_col_variable, 1, 1), ',', '*');
      --dbms_output.put_line(col_var);
        /*  Loop
             ln_col_variable :=ln_col_variable||','||v_column_name;

             End Loop;*/
      -- ln_col_variable :=ln_col_variable||sysdate;
      --  sql_fetch       := 'Select '||ln_col_variable||'           From '||v_table_name;
      -- dbms_output.put_line(sql_fetch);
      END LOOP;

      sql_fetch := 'Select ' || col_var || ' From ' || v_table_name;

      OPEN enquiry_cur FOR sql_fetch;

      l_xmltype := XMLTYPE (enquiry_cur);

      DBMS_OUTPUT.put_line (l_xmltype.getClobVal);

      CLOSE get_columns;
   END LOOP;

   CLOSE get_tables;
EXCEPTION
   WHEN OTHERS
   THEN
      raise_application_error (
         -20001,
            'An              encountered  '
         || SQLCODE
         || '        -ERROR- '
         || SQLERRM);
END;

Once the code is corrected, you need to make sure that all the tables you are referring in cursor get_tables should have at least 1 row else you will get PL/SQL: numeric or value error.

Output:

SQL> set serverout on
SQL> /
TABL1
----------------------
COL1
<?xml version="1.0"?>
<ROWSET>
 <ROW>
  <COL1>1</COL1>
 </ROW>
 <ROW>

<COL1>2</COL1>
 </ROW>
 <ROW>
  <COL1>A</COL1>
 </ROW>
 <ROW>
  <COL1>B2</COL1>

</ROW>
</ROWSET>

TABL2
----------------------
COL1
<?xml version="1.0"?>
<ROWSET>
 <ROW>
  <COL1>1</COL1>
 </ROW>
</ROWSET>


问:
Intelij php autocomplete not working for custom class
I develop Android, but now I lean PHP. Because I know Intelij I'd like to develope PHP in Intelij.
My problem is autocomplete for  custom classes doesn't work.
I mean e.g. I have a class called customer, and if I'd like to include it, it offers automatically to include customers.php when I write the first few letters of the class name.
But after if I'd like to write

```<code>$customer = new customer($name);
</code>```

even I press ctrl+spance Intelij doesn't offers any suggestions and ctrl+p at params doesn't works either.
Anyway for other classes both of them are works. I searched for plugins and forums to find out how to solve it, but I didn't find any solution.

答:
If you already have the PHP plugin installed, you need to create the Web module in your project:
File | New | Module | PHP.
Code completion and full PHP support is only available within a web module.</p>

Body:
I develop Android, but now I lean PHP. Because I know Intelij I'd like to develope PHP in Intelij.
My problem is autocomplete for  custom classes doesn't work.
I mean e.g. I have a class called customer, and if I'd like to include it, it offers automatically to include customers.php when I write the first few letters of the class name.
But after if I'd like to write

$customer = new customer($name);

even I press ctrl+spance Intelij doesn't offers any suggestions and ctrl+p at params doesn't works either.
Anyway for other classes both of them are works. I searched for plugins and forums to find out how to solve it, but I didn't find any solution.


问:
Replace part of a string (column name) in Python or Pandas?
How to replace a part of a string in Python or Pandas?

```<code>"xxsffsfdewetczxCATINTHEHATxxxxxxxxDrSeussfggfhgfh"
</code>```

anything like the excel function (CATINTHEHATDrSeuss) to replace the whole string and just keep those two sentences,
Thanks

答:
As mentioned here: https://www.tutorialspoint.com/python/string_replace.htm</p>

```<code>str.replace(old, new[, max])
</code>```

Body:
How to replace a part of a string in Python or Pandas?

"xxsffsfdewetczxCATINTHEHATxxxxxxxxDrSeussfggfhgfh"

anything like the excel function (CATINTHEHATDrSeuss) to replace the whole string and just keep those two sentences,
Thanks

Body:
As mentioned here: https://www.tutorialspoint.com/python/string_replace.htm

str.replace(old, new[, max])


问:
/root/.bash_profile: line 16: syntax error: unexpected end of file
I'm trying to set java path. i am getting an error in .bash_profile. I don't know why. It seems everything good.</p>

```<code># .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
  . ~/.bashrc
fi

# User specific environment and startup programs

JAVA_HOME=/apps/erp/java/jdk1.7.0_71

PATH=$PATH:$HOME/bin:$JAVA_HOME:$JAVA_HOME/bin:$JAVA_HOME/lib/dt.jar:
\$JAVA_HOME/lib/tools.jar

export PATH
</code>```

答:
The problem is probably this here:

```<code>PATH=$PATH:$HOME/bin:$JAVA_HOME:$JAVA_HOME/bin:$JAVA_HOME/lib/dt.jar:
\$JAVA_HOME/lib/tools.jar
</code>```

The continuation backslash should be on the previous line, the line you want to be continued:

```<code>PATH=$PATH:$HOME/bin:$JAVA_HOME:$JAVA_HOME/bin:$JAVA_HOME/lib/dt.jar:\
$JAVA_HOME/lib/tools.jar
</code>```

Or just keep it on a single line:

```<code>PATH=$PATH:$HOME/bin:$JAVA_HOME:$JAVA_HOME/bin:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
</code>```

Body:
I'm trying to set java path. i am getting an error in .bash_profile. I don't know why. It seems everything good.

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
  . ~/.bashrc
fi

# User specific environment and startup programs

JAVA_HOME=/apps/erp/java/jdk1.7.0_71

PATH=$PATH:$HOME/bin:$JAVA_HOME:$JAVA_HOME/bin:$JAVA_HOME/lib/dt.jar:
\$JAVA_HOME/lib/tools.jar

export PATH

Body:
The problem is probably this here:

PATH=$PATH:$HOME/bin:$JAVA_HOME:$JAVA_HOME/bin:$JAVA_HOME/lib/dt.jar:
\$JAVA_HOME/lib/tools.jar

The continuation backslash should be on the previous line, the line you want to be continued:

PATH=$PATH:$HOME/bin:$JAVA_HOME:$JAVA_HOME/bin:$JAVA_HOME/lib/dt.jar:\
$JAVA_HOME/lib/tools.jar

Or just keep it on a single line:

PATH=$PATH:$HOME/bin:$JAVA_HOME:$JAVA_HOME/bin:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar


答: try using the content attribute in the pseudo selectors or add it as a background image</p>

Title: Pseudoelement selector for inserting icon inside of another element

Body:
I would like to use some pseudo-element selector (:before, :after) for including a text or icon on :hover inside some other element. Is there a way how to do that only with pseudo-element selectors? I would like to NOT actually change the content of that element as it's content is loaded from localStorage.

My vision is to visually add some click-able icon (✗, ) when hovering over the header.

Thank you for your suggestions.


问:
Find angularjs version
I tried in browser console:

```<code>angular.version
</code>```

And I got below

codeName : "foam-acceleration" dot : 3 full : "1.4.3" major : 1 minor
  : 4

So what angular version is used? Is it angular2 or 4 or any other?

Thanks

答: You can console 'angular.version.full' for getting version of angular being used on that webpage.

Title: Find angularjs version

Body:
I tried in browser console:

angular.version

And I got below

codeName : "foam-acceleration" dot : 3 full : "1.4.3" major : 1 minor
  : 4

So what angular version is used? Is it angular2 or 4 or any other?

Thanks


问:
ZPL code for barcode withd
How can I control the width of the barcode? I use the ^BY3 command but its too small when I try ^BY4 the width is too narrow. Is there any way to control the width without adding another character?</p>

答: What I usually end up doing in such scenarios is to use some kind of label design software (for example: Zebra Designer), Design the barcode as needed and use the print to file option to inspect how the barcode was generated. That way you can make your changes and compare the output.</p>

Title: ZPL code for barcode withd


问:
How to overlap layouts/views within LinearLayout?
I would like to create layout that looks like this:

Layout1and Layout2 are some layouts of any kind, nested in a parent LinearLayout. The LinearLayout is necessary to give both child layouts a 50% height by using layout_weight.

The red squares should be Buttons which overlap both Layout1and Layout2 and are centered between the two layouts.

Of course this could achived by using RelativeLayout as parent instead but then I would loose the possibility to use layout_weight...

If I keep using LinearLayout, it seems to be impossible to let the buttons overlap the two other layouts.

Furthermore the buttons cannot be siblings of the two layouts but need to be nested inside a common container layout that takes care of the horizontal positioning (e.g. a LinearLayout with horizontal orientation).

Any idea how to solve this?

I already tried to place the buttons inside Layout1 (or Layout2), place them below the bottom and use android:clipChildren=false, but this had no effect. The button where simple cut in half.

Edit:
Splitting the height between the two layouts 50/50 is just one version. Another view uses the same basic layout but splits the height 70/30 between the two layouts. The buttons should always be centered between the two layouts. Sorry for not pointing this out earlier.

Layout Code:

```<code><!-- parent/root layout -->
<LinearLayout
    ...
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    ... >

    <!-- Layout1 -->
    <LinearLayout
        android:layout_weight="1"
        ... />

    <!-- Buttons -->
    <LinearLayout
        android:orientation="horizontal"
        ... >

        <Button ... />
        <Button ... />
        <Button ... />

    </LinearLayout>

    <!-- Layout2 -->
    <LinearLayout
        android:layout_weight="1"
        ... />

</LinearLayout>
</code>```

答:
50% linearOne 50% linearTwo

```<code>    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/activity_test"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="@color/colorAccent">

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="@color/colorPrimary">

    </LinearLayout>

</LinearLayout>

    <LinearLayout
        android:layout_centerInParent="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <View
            android:layout_weight="1"
            android:layout_width="50dp"
            android:layout_height="50dp"
             />
        <View
            android:layout_weight="1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:background="#000" />
        <View
            android:layout_weight="1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            />
        <View
            android:layout_weight="1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:background="#000" />
        <View
            android:layout_weight="1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            />
        <View
            android:layout_weight="1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:background="#000" />
        <View
            android:layout_weight="1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            />

    </LinearLayout>

</RelativeLayout>
</code>```

============================================================================

70% linearOne 30% linearTwo

Just close your eyes Copy and paste

```<code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="10"
    tools:context="com.ncrypted.myapplication.MainActivity">

    <LinearLayout
        android:layout_weight="6"
        android:id="@+id/linear1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@color/colorAccent"
        android:orientation="vertical">

    </LinearLayout>

    <RelativeLayout
        android:layout_weight="2"
        android:id="@+id/relative1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@color/colorAccent">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <View
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:background="@color/colorAccent"
                android:layout_weight="1" />
            <View
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:background="@color/colorPrimary"
                android:layout_weight="1" />

        </LinearLayout>
        <LinearLayout
            android:layout_centerInParent="true"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <View
                android:layout_weight="1"
                android:layout_width="50dp"
                android:layout_height="50dp"
                 />
            <View
                android:layout_weight="1"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:background="#000" />
            <View
                android:layout_weight="1"
                android:layout_width="50dp"
                android:layout_height="50dp"
                />
            <View
                android:layout_weight="1"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:background="#000" />
            <View
                android:layout_weight="1"
                android:layout_width="50dp"
                android:layout_height="50dp"
                />
            <View
                android:layout_weight="1"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:background="#000" />
            <View
                android:layout_weight="1"
                android:layout_width="50dp"
                android:layout_height="50dp"
                />
        </LinearLayout>

    </RelativeLayout>

    <LinearLayout
        android:layout_weight="2"
        android:id="@+id/linear2"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@color/colorPrimary"
        android:orientation="vertical">

    </LinearLayout>

</LinearLayout>
</code>```

Body:
I would like to create layout that looks like this:

Layout1and Layout2 are some layouts of any kind, nested in a parent LinearLayout. The LinearLayout is necessary to give both child layouts a 50% height by using layout_weight.

The red squares should be Buttons which overlap both Layout1and Layout2 and are centered between the two layouts.

Of course this could achived by using RelativeLayout as parent instead but then I would loose the possibility to use layout_weight...

If I keep using LinearLayout, it seems to be impossible to let the buttons overlap the two other layouts.

Furthermore the buttons cannot be siblings of the two layouts but need to be nested inside a common container layout that takes care of the horizontal positioning (e.g. a LinearLayout with horizontal orientation).

Any idea how to solve this?

I already tried to place the buttons inside Layout1 (or Layout2), place them below the bottom and use android:clipChildren=false, but this had no effect. The button where simple cut in half.

Edit:
Splitting the height between the two layouts 50/50 is just one version. Another view uses the same basic layout but splits the height 70/30 between the two layouts. The buttons should always be centered between the two layouts. Sorry for not pointing this out earlier.

Layout Code:

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

    <LinearLayout
        android:layout_weight="1"
        ... />

    <LinearLayout
        android:orientation="horizontal"
        ... >

        <Button ... />
        <Button ... />
        <Button ... />

    </LinearLayout>

    <LinearLayout
        android:layout_weight="1"
        ... />

</LinearLayout>

Body:
50% linearOne 50% linearTwo

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/activity_test"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="@color/colorAccent">

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="@color/colorPrimary">

    </LinearLayout>

</LinearLayout>

    <LinearLayout
        android:layout_centerInParent="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <View
            android:layout_weight="1"
            android:layout_width="50dp"
            android:layout_height="50dp"
             />
        <View
            android:layout_weight="1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:background="#000" />
        <View
            android:layout_weight="1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            />
        <View
            android:layout_weight="1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:background="#000" />
        <View
            android:layout_weight="1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            />
        <View
            android:layout_weight="1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:background="#000" />
        <View
            android:layout_weight="1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            />

    </LinearLayout>

</RelativeLayout>

============================================================================

70% linearOne 30% linearTwo

Just close your eyes Copy and paste

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="10"
    tools:context="com.ncrypted.myapplication.MainActivity">

    <LinearLayout
        android:layout_weight="6"
        android:id="@+id/linear1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@color/colorAccent"
        android:orientation="vertical">

    </LinearLayout>

    <RelativeLayout
        android:layout_weight="2"
        android:id="@+id/relative1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@color/colorAccent">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <View
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:background="@color/colorAccent"
                android:layout_weight="1" />
            <View
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:background="@color/colorPrimary"
                android:layout_weight="1" />

        </LinearLayout>
        <LinearLayout
            android:layout_centerInParent="true"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <View
                android:layout_weight="1"
                android:layout_width="50dp"
                android:layout_height="50dp"
                 />
            <View
                android:layout_weight="1"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:background="#000" />
            <View
                android:layout_weight="1"
                android:layout_width="50dp"
                android:layout_height="50dp"
                />
            <View
                android:layout_weight="1"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:background="#000" />
            <View
                android:layout_weight="1"
                android:layout_width="50dp"
                android:layout_height="50dp"
                />
            <View
                android:layout_weight="1"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:background="#000" />
            <View
                android:layout_weight="1"
                android:layout_width="50dp"
                android:layout_height="50dp"
                />
        </LinearLayout>

    </RelativeLayout>

    <LinearLayout
        android:layout_weight="2"
        android:id="@+id/linear2"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@color/colorPrimary"
        android:orientation="vertical">

    </LinearLayout>

</LinearLayout>


问:
Unable to open file with qt app on mac
I am trying to associate custom files with an osx app. I have a plist that associates files with the app, but double clicking a file opens the app with no data inside.

Calling

someapp.app/Contents/MacOs/someapp somefile.abc

from the terminal opens the file correctly inside the app.

```<code>MyApp::MyApp(int& argc, char**argv): QApplication(argc, argv)
{
  ...
  m_MainWindow = new MainWindows();
  m_MainWindow->show();
  if(argc > 1 && argv[1])
      m_MainWindow->openFile(QString(argv[1]);
  else
      m_MainWindow->showStartupDialog();  // to create a new document
}
</code>```

Searching around I found that I should somehow implement QFileOpenEvent... how ?
 This example looks good... but I don't understand how to combine the constructor and the event...

How do I make this work ?

(OS X 10.6-10.9, app created using Qt 4.8)

答:
i'm using a QApplication derived class that emits a signal when file is ready:

```<code>#ifndef OPENWITHAPPLICATION_H
#define OPENWITHAPPLICATION_H

#include <QApplication>
#include <QFileOpenEvent>
#include <QMessageBox>

class OpenWithApplication : public QApplication
{
    Q_OBJECT

public:
    QString fileName;

    OpenWithApplication(int &argc, char **argv)
        : QApplication(argc, argv)
    {
    }
signals:

    void fileReady(QString fn);

protected:

    bool event(QEvent *event)
    {
        if (event->type() == QEvent::FileOpen) {
            QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(event);
            fileName = openEvent->file();

            emit fileReady(fileName); //  the file is ready
        }

        return QApplication::event(event);
    }
};

#endif // OPENWITHAPPLICATION_H
</code>```

main.cpp connects created OpenWindowApplication with the MainWindow object so once the file is ready, the signal is emitted and received by it for processing

```<code>#include "mainwindow.h"
#include <openwithapplication.h>

int main(int argc, char *argv[])
{
    OpenWithApplication a(argc, argv);
    MainWindow w;

    w.connectOpenWithApp(&a);
    w.show();

    return a.exec();
}
</code>```

and MainWindow connects fileReady signal with a lambda func that opens the file and updates widget

```<code>void MainWindow::connectOpenWithApp(OpenWithApplication*app) {
    connect(app, &OpenWithApplication::fileReady, [this](QString fileName){
        bw->open(fileName);
        bw->update();
    });
}
</code>```

here's the result:

Title: Unable to open file with qt app on mac

Body:
I am trying to associate custom files with an osx app. I have a plist that associates files with the app, but double clicking a file opens the app with no data inside.

Calling

someapp.app/Contents/MacOs/someapp somefile.abc

from the terminal opens the file correctly inside the app.

MyApp::MyApp(int& argc, char**argv): QApplication(argc, argv)
{
  ...
  m_MainWindow = new MainWindows();
  m_MainWindow->show();
  if(argc > 1 && argv[1])
      m_MainWindow->openFile(QString(argv[1]);
  else
      m_MainWindow->showStartupDialog();  // to create a new document
}

Searching around I found that I should somehow implement QFileOpenEvent... how ?
 This example looks good... but I don't understand how to combine the constructor and the event...

How do I make this work ?

(OS X 10.6-10.9, app created using Qt 4.8)

Body:
i'm using a QApplication derived class that emits a signal when file is ready:

#ifndef OPENWITHAPPLICATION_H
#define OPENWITHAPPLICATION_H

#include <QApplication>
#include <QFileOpenEvent>
#include <QMessageBox>

class OpenWithApplication : public QApplication
{
    Q_OBJECT

public:
    QString fileName;

    OpenWithApplication(int &argc, char **argv)
        : QApplication(argc, argv)
    {
    }
signals:

    void fileReady(QString fn);

protected:

    bool event(QEvent *event)
    {
        if (event->type() == QEvent::FileOpen) {
            QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(event);
            fileName = openEvent->file();

            emit fileReady(fileName); //  the file is ready
        }

        return QApplication::event(event);
    }
};

#endif // OPENWITHAPPLICATION_H

main.cpp connects created OpenWindowApplication with the MainWindow object so once the file is ready, the signal is emitted and received by it for processing

#include "mainwindow.h"
#include <openwithapplication.h>

int main(int argc, char *argv[])
{
    OpenWithApplication a(argc, argv);
    MainWindow w;

    w.connectOpenWithApp(&a);
    w.show();

    return a.exec();
}

and MainWindow connects fileReady signal with a lambda func that opens the file and updates widget

void MainWindow::connectOpenWithApp(OpenWithApplication*app) {
    connect(app, &OpenWithApplication::fileReady, [this](QString fileName){
        bw->open(fileName);
        bw->update();
    });
}

here's the result:


问:
Writing a new column in csv file based on if condition
I want to add a new column which adds two existing columns on basis of if condition that tweet is a Retweet or not.
I have following csv output from my python code : csv image

Now, i want to implement condition that if tweet is a retweet, ie;

```<code>   file1 = open(string.csv, 'rb')
reader = csv.reader(file1)
for r in rows :
   if Tweet[r]!="RT @***" :
        new_col=[col[3],col[4]]
        newcol.append(new_col)
    else :
        new_col=0
file1.close()

file2 = open(file.csv, 'wb')
writer = csv.writer(file2)
writer.writerows(newcol)
file2.close()
</code>```

I'm having trouble implementing it. Kindly help.

答:
Please try to change this syntax file2 = open(file.csv, 'wb')
To file2 = open(file.csv, 'a')

Thanks

Body:
I want to add a new column which adds two existing columns on basis of if condition that tweet is a Retweet or not.
I have following csv output from my python code : csv image

Now, i want to implement condition that if tweet is a retweet, ie;

   file1 = open(string.csv, 'rb')
reader = csv.reader(file1)
for r in rows :
   if Tweet[r]!="RT @***" :
        new_col=[col[3],col[4]]
        newcol.append(new_col)
    else :
        new_col=0
file1.close()

file2 = open(file.csv, 'wb')
writer = csv.writer(file2)
writer.writerows(newcol)
file2.close()

I'm having trouble implementing it. Kindly help.


问:
Add a single dot below each character using CSS
I am looking for a way to create the following effect with CSS.

I found some solutions for putting dots below the text (white dots below HTML text), but I don't want "dotted underlining", I want every character to have just a single dot below it. Also the dot should increase with the font-size of the text (although if needed, I could mess with JS to fix that).

How could I achieve that?

答:
Just a summary of both solutions above:

1. Using modern CSS that sets a dot below each letter

HTML:

```<code>0,<span class="dotunderletter">1</span> =
<br>
0,<span class="dotunderletter">01</span> =
<br>
0,001 = 1 · 1/1.000 =
</code>```

CSS:

```<code>.dotunderletter {
    text-emphasis-style: dot;
    text-emphasis-position: under left;
    -webkit-text-emphasis-style: dot;
    -webkit-text-emphasis-position: under;
}
</code>```

Result:

Issue: The line height changes.

2. Using a CSS before element for each single char

HTML:

```<code>0,<span class="char">1</span> =
<br>
0,<span class="char">0</span><span class="char">1</span> =
<br>
0,001 = 1 · 1/1.000 =
</code>```

CSS:

```<code>.char {
    display: inline-block;
    position: relative;
}
.char::before {
    content: '.';
    display: inline-block;
    position: absolute;
    bottom: -0.5em;
    left: 0;
    text-align: center;
    width: 100%;
}
</code>```

Result:

Issue: Each char needs to be put into a span element. But the line height does not change and it works in most of the browsers.

Thanks to hon2a and Oriol for their helpful answers!

Body:
Just a summary of both solutions above:

1. Using modern CSS that sets a dot below each letter

HTML:

0,<span class="dotunderletter">1</span> =
<br>
0,<span class="dotunderletter">01</span> =
<br>
0,001 = 1 · 1/1.000 =

CSS:

.dotunderletter {
    text-emphasis-style: dot;
    text-emphasis-position: under left;
    -webkit-text-emphasis-style: dot;
    -webkit-text-emphasis-position: under;
}

Result:

Issue: The line height changes.

2. Using a CSS before element for each single char

HTML:

0,<span class="char">1</span> =
<br>
0,<span class="char">0</span><span class="char">1</span> =
<br>
0,001 = 1 · 1/1.000 =

CSS:

.char {
    display: inline-block;
    position: relative;
}
.char::before {
    content: '.';
    display: inline-block;
    position: absolute;
    bottom: -0.5em;
    left: 0;
    text-align: center;
    width: 100%;
}

Result:

Issue: Each char needs to be put into a span element. But the line height does not change and it works in most of the browsers.

Thanks to hon2a and Oriol for their helpful answers!


问:
Refreshing a particular div with reloading the whole page in php
I need to reload a particular div without reloading the whole page.

```<code><div class="">
                        <div class="contactpagecaptchas">
                            <img src="/captcha.php?rand=<?php echo rand();?>" class="contactpagecaptchass" id='captchaimg'/>
                            <p class="change"><a href="javascript: refreshCaptcha();" class="clickto">Click to change</a></p>
                        </div>

                        <div class="contactcaptcha">
                            <input type="text" class="form-control" name="captcha" placeholder="Captcha" style="background-color: #f4f4f4;border: none;">
                        </div>
                    </div>
</code>```

Once i click on refresh captcha text box should get cleared.

答:
Try onclick method of javascript</p>

```<code><div id="abc" ><?php echo rand(); ?></div>
<button onclick="refcaptcha()" >
<script>
function refcaptcha(){
    var x = document.getElementById("abc")
    x.innerHTML = Math.floor((Math.random() * 1000000) + 1);
    //if you want to clear the captcha code than assign '' to that id
    //x.innerHTML = '';
}
</script>
</code>```

Body:
I need to reload a particular div without reloading the whole page.

                            <img src="/captcha.php?rand=<?php echo rand();?>" class="contactpagecaptchass" id='captchaimg'/>

Click to change

                            <input type="text" class="form-control" name="captcha" placeholder="Captcha" style="background-color: #f4f4f4;border: none;">

Once i click on refresh captcha text box should get cleared.

Body:
Try onclick method of javascript

<div id="abc" ><?php echo rand(); ?></div>
<button onclick="refcaptcha()" >
<script>
function refcaptcha(){
    var x = document.getElementById("abc")
    x.innerHTML = Math.floor((Math.random() * 1000000) + 1);
    //if you want to clear the captcha code than assign '' to that id
    //x.innerHTML = '';
}
</script>


问:
ImportError: No module named werkzeug.test [Installation on Windows]

CKAN Version

CKan 2.5.2

```<code>git clone https://github.com/ckan/ckan.git
git checkout tags/ckan-2.5.2
</code>```

I follow https://github.com/ckan/ckan/wiki/How-to-Install-CKAN-2.5.2-on-Windows-7
From the beginning to the step "Create database tables"
    (ckan2.5.2env) D:\src\ckan>paster db init -c development.ini

Error Occurs:

```<code>  File "d:\users\administrator.user1-pc\envs\ckan2.5.2env\lib\site-packages\pkg_
resources\__init__.py", line 2303, in load
    return self.resolve()
  File "d:\users\administrator.user1-pc\envs\ckan2.5.2env\lib\site-packages\pkg_
resources\__init__.py", line 2309, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "D:\src\ckan\ckan\config\middleware\__init__.py", line 7, in <module>
    from werkzeug.test import create_environ, run_wsgi_app
</code>```

ImportError: No module named werkzeug.test

After running >easy_install werkzeug
The error changed to :

ImportError: No module named flask

After running >easy_install flask
The error changed to :

ImportError: No module name config
  and this cannot be resolved.

Referening to line #6 on ..\ckan\config\middleware__init__.py
It imports the following

```<code>import webob from werkzeug.test import create_environ, run_wsgi_app
from ckan.config.environment import load_environment from
ckan.config.middleware.flask_app import make_flask_stack from
ckan.config.middleware.pylons_app import make_pylons_stack
</code>```

Try to correct requiremnets.txt

```<code>File"D:\ckan\config\middleware\flask_app.py", line 6, in <module>
ImportError: cannot import name config
(ckan2.5.2env) D:\src\ckan>pip install -r requirements.txt
Collecting bleach==1.4.2 (from -r requirements.txt (line 10))  Using cached bleach-1.4.2-py2.py3-none-any.whl
Installing collected packages: bleach  Found existing installation: bleach 2.0.0    Uninstalling bleach-2.0.0:
Successfully uninstalled bleach-2.0.0Successfully installed bleach-1.4.2(ckan2.5.2env)
D:\src\ckan>paster db init -c development.ini
File"d:\ckan2.5.2env\lib\site-packages\bleach\__init__.py", line 8, in <module>    from html5lib.sanitizer import HTMLSanitizer
ImportError: No module named sanitizer
(ckan2.5.2env) D:\src\ckan>pip install --upgrade bleach
Successfully uninstalled bleach-1.4.2Successfully installed bleach-2.0.0
(ckan2.5.2env) D:\src\ckan>paster db init -c development.ini
File"D:\ckan\config\middleware\flask_app.py", line 6, in <module>
ImportError: cannot import name config
</code>```

Try to change from ckan2.5.2 to 2.5.4

The init.py seems to be fixed.
Therefore, a further Locale problem is shown

(ckan2.5.4env) d:\src\ckan>paster --plugin=ckan user list -c development.ini

```<code>import i18n
File "d:\ckan2.5.4env\lib\site-packages\ckan-2.6.1-py2.7.egg\ckan\lib\i18n.py",
</code>```

line 46, in
      from babel.core import (LOCALE_ALIASES,
      ImportError: cannot import name get_locale_identifier

i18n.py, line 46,
from babel import Locale
from babel.core import (LOCALE_ALIASES, get_locale_identifier, UnknownLocaleError)

答:
ImportError suggests you didn't complete this step pip install -r requirements.txt successfully. Try enabling your virtualenv and doing that step again, and make sure it completes successfully.

Please also ensure you're using the latest patch release. 2.5.2 has been superceded by 2.5.4 and you should always use one of the latest. This will likely fix for the sanitizer/bleach/html5 versioning problem.

Body:
CKAN Version

CKan 2.5.2

git clone https://github.com/ckan/ckan.git
git checkout tags/ckan-2.5.2

I follow https://github.com/ckan/ckan/wiki/How-to-Install-CKAN-2.5.2-on-Windows-7
From the beginning to the step "Create database tables"
    (ckan2.5.2env) D:\src\ckan>paster db init -c development.ini

Error Occurs:

  File "d:\users\administrator.user1-pc\envs\ckan2.5.2env\lib\site-packages\pkg_
resources\__init__.py", line 2303, in load
    return self.resolve()
  File "d:\users\administrator.user1-pc\envs\ckan2.5.2env\lib\site-packages\pkg_
resources\__init__.py", line 2309, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "D:\src\ckan\ckan\config\middleware\__init__.py", line 7, in <module>
    from werkzeug.test import create_environ, run_wsgi_app

ImportError: No module named werkzeug.test

After running >easy_install werkzeug
The error changed to :

ImportError: No module named flask

After running >easy_install flask
The error changed to :

ImportError: No module name config
  and this cannot be resolved.

Referening to line #6 on ..\ckan\config\middleware__init__.py
It imports the following

import webob from werkzeug.test import create_environ, run_wsgi_app
from ckan.config.environment import load_environment from
ckan.config.middleware.flask_app import make_flask_stack from
ckan.config.middleware.pylons_app import make_pylons_stack

Try to correct requiremnets.txt

File"D:\ckan\config\middleware\flask_app.py", line 6, in <module>
ImportError: cannot import name config
(ckan2.5.2env) D:\src\ckan>pip install -r requirements.txt
Collecting bleach==1.4.2 (from -r requirements.txt (line 10))  Using cached bleach-1.4.2-py2.py3-none-any.whl
Installing collected packages: bleach  Found existing installation: bleach 2.0.0    Uninstalling bleach-2.0.0:
Successfully uninstalled bleach-2.0.0Successfully installed bleach-1.4.2(ckan2.5.2env)
D:\src\ckan>paster db init -c development.ini
File"d:\ckan2.5.2env\lib\site-packages\bleach\__init__.py", line 8, in <module>    from html5lib.sanitizer import HTMLSanitizer
ImportError: No module named sanitizer
(ckan2.5.2env) D:\src\ckan>pip install --upgrade bleach
Successfully uninstalled bleach-1.4.2Successfully installed bleach-2.0.0
(ckan2.5.2env) D:\src\ckan>paster db init -c development.ini
File"D:\ckan\config\middleware\flask_app.py", line 6, in <module>
ImportError: cannot import name config

Try to change from ckan2.5.2 to 2.5.4

The init.py seems to be fixed.
Therefore, a further Locale problem is shown

(ckan2.5.4env) d:\src\ckan>paster --plugin=ckan user list -c development.ini

import i18n
File "d:\ckan2.5.4env\lib\site-packages\ckan-2.6.1-py2.7.egg\ckan\lib\i18n.py",

line 46, in
      from babel.core import (LOCALE_ALIASES,
      ImportError: cannot import name get_locale_identifier

i18n.py, line 46,
from babel import Locale
from babel.core import (LOCALE_ALIASES, get_locale_identifier, UnknownLocaleError)


问:
SAMP PHP API Integration

I want to show the number of players in the server instead of that UNKNOWN thing, I haven't enabled the API yet, can I get help that, I want to integrate the progress bar to the total players in game like
if players are 50/100
= 50% of the bar will be filled.
Like the bar should work as the api updates.

```<code><div class="is-clearfix"></div>
<section class="section dark-grey has-text-centered">
    <div class="container">
        <div class="heading">
            <h1 class="title">Our Servers</h1>
            <br>
        </div>
        <div class="columns is-gapless">
            <div class="column">
                <div class="card card-server">
                    <div class="card-image">
                        <figure class="image is-2by1">
                            <img src="./OutBreak Gaming_files/sfcnr_card1.png">
                        </figure></div> <div class="card-content">
                        <div class="title" style="font-size: 1.25em; color: rgb(119, 119, 119); margin-top: 0.5em;">87.98.241.207:7775</div>
                        <div class="players is-marginless">
                            <div class="content playersOnline">
                                Unknown PLAYERS ONLINE
                            </div>
                            <progress value="0" max="100" class="progress is-success"></progress>
                            <br></div> <a class="button is-info is-medium is-fullwidth">Play Now</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
</div>
</code>```

答:
Just use the SACNR monitor API, and

```<code><div class="columns is-gapless">
<div class="column"><div class="card card-server">
<div class="card-image">
<figure class="image is-2by1">
<img src="./OutBreak Gaming_files/sfcnr_card1.png"></figure></div>
<div class="card-content">
<div class="title" style="font-size: 1.25em; color: rgb(119, 119, 119); margin-top: 0.5em;">87.98.241.207:7775</div> Hostname:
<div class="hosting"></div>Gamemode:
<div class="game-mode"></div>Map:
<div class="language"></div> Players:
<div class="players is-marginless"><div class="content playersOnline">
    FETCHING PLAYERS ONLINE
  </div>
<progress value="0" max="100" class="progress is-success"></progress><br></div>
<a href="samp://87.98.241.207:7775"><a class="button is-info is-medium is-fullwidth">Play Now</a></a></div></div></div></div></div></section></div>
</code>```

Where We fetch from API the following things

```<code><?php
require_once("sampsvr.php");
$monitor = new SACNR\Monitor;
//$obj = $monitor->get_info_by_id(1790345);
$obj = $monitor->get_info_by_ip('87.98.241.207','7775');
$players = $obj->Players;
$hostName = $obj->Hostname;
$Gamemode = $obj->Gamemode;
$Mapname = $obj ->Language;
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){

  $('.progress').val(<?php echo $players;?>);
  $('.playersOnline').html(<?php echo $players;?> +' PLAYERS ONLINE' );
  $('.hosting').html("<?php echo $hostName;?>");
  $('.game-mode').html("<?php echo $Gamemode;?>");
  $('.language').html("<?php echo $Mapname;?>");
});
</script>
</code>```

You may find the API at http://monitor.sacnr.com/api.html

Title: SAMP PHP API Integration

Body:
I want to show the number of players in the server instead of that UNKNOWN thing, I haven't enabled the API yet, can I get help that, I want to integrate the progress bar to the total players in game like
if players are 50/100
= 50% of the bar will be filled.
Like the bar should work as the api updates.

Our Servers

87.98.241.207:7775

                                Unknown PLAYERS ONLINE

                            <progress value="0" max="100" class="progress is-success"></progress>

 Play Now

Body:
Just use the SACNR monitor API, and

<div class="columns is-gapless">
<div class="column"><div class="card card-server">
<div class="card-image">
<figure class="image is-2by1">
<img src="./OutBreak Gaming_files/sfcnr_card1.png"></figure></div>
<div class="card-content">
<div class="title" style="font-size: 1.25em; color: rgb(119, 119, 119); margin-top: 0.5em;">87.98.241.207:7775</div> Hostname:
<div class="hosting"></div>Gamemode:
<div class="game-mode"></div>Map:
<div class="language"></div> Players:
<div class="players is-marginless"><div class="content playersOnline">
    FETCHING PLAYERS ONLINE
  </div>
<progress value="0" max="100" class="progress is-success"></progress><br></div>
<a href="samp://87.98.241.207:7775"><a class="button is-info is-medium is-fullwidth">Play Now</a></a></div></div></div></div></div></section></div>

Where We fetch from API the following things

<?php
require_once("sampsvr.php");
$monitor = new SACNR\Monitor;
//$obj = $monitor->get_info_by_id(1790345);
$obj = $monitor->get_info_by_ip('87.98.241.207','7775');
$players = $obj->Players;
$hostName = $obj->Hostname;
$Gamemode = $obj->Gamemode;
$Mapname = $obj ->Language;
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){

  $('.progress').val(<?php echo $players;?>);
  $('.playersOnline').html(<?php echo $players;?> +' PLAYERS ONLINE' );
  $('.hosting').html("<?php echo $hostName;?>");
  $('.game-mode').html("<?php echo $Gamemode;?>");
  $('.language').html("<?php echo $Mapname;?>");
});
</script>

You may find the API at http://monitor.sacnr.com/api.html


问:
How to make Excel VBA to ignore formula cells with if condition
I want to use if condition to perform ClearContents task. Please find my below code for the same. I written below 2 code's, but both are unsuccessful.

First Try

```<code>t = 1
Do While Cells(t, 1) <> ""
    If Cells(t, 1) <> "=" Then
        Cells(t, 1).ClearContents
    End If
    t = t + 1
Loop
</code>```

Second Try

```<code>t = 1
Do While Cells(t, 1) <> ""
    If Cells(t, 1) <> Formula Then
        Cells(t, 1).ClearContents
    End If
    t = t + 1
Loop
</code>```

Basically, I don't want to delete the cells contain where formulas are available but I want to delete the other data.

答:
As an alternative, there is a method to select all the cells containing constant (non-formula) values.

```<code>Cells.SpecialCells(xlCellTypeConstants, 23).ClearContents
</code>```

Faster than iterating all the cells.

Or to do this only on a specific range or the current selection, replace Cells with Range("A1:A100") or Selection.

(In Excel, you can find this under Home -> Editing -> Find & Select -> Go to Special. Here you can have Excel automatically select only the Constants or the Formulas inside the existing selection.)

Body:
I want to use if condition to perform ClearContents task. Please find my below code for the same. I written below 2 code's, but both are unsuccessful.

First Try

t = 1
Do While Cells(t, 1) <> ""
    If Cells(t, 1) <> "=" Then
        Cells(t, 1).ClearContents
    End If
    t = t + 1
Loop

Second Try

t = 1
Do While Cells(t, 1) <> ""
    If Cells(t, 1) <> Formula Then
        Cells(t, 1).ClearContents
    End If
    t = t + 1
Loop

Basically, I don't want to delete the cells contain where formulas are available but I want to delete the other data.

Body:
As an alternative, there is a method to select all the cells containing constant (non-formula) values.

Cells.SpecialCells(xlCellTypeConstants, 23).ClearContents

Faster than iterating all the cells.

Or to do this only on a specific range or the current selection, replace Cells with Range("A1:A100") or Selection.

(In Excel, you can find this under Home -> Editing -> Find & Select -> Go to Special. Here you can have Excel automatically select only the Constants or the Formulas inside the existing selection.)