Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
39,503,610 | index: true vs foreign_key: true (Rails) | <p>Following a guide, I ran the following command:</p>
<pre><code>rails g migration CreateSnippetsUsers snippet:belongs_to user:belongs_to
</code></pre>
<p>This created the following migration:</p>
<pre><code>class CreateSnippetsUsers < ActiveRecord::Migration[5.0]
def change
create_table :snippets_users do |t|
t.belongs_to :snippet, foreign_key: true
t.belongs_to :user, foreign_key: true
end
end
end
</code></pre>
<p>In the past I've seen the same thing, but with <code>index: true</code> instead of <code>foreign_key: true</code>. What's the difference between the two?</p>
| <ruby-on-rails><rails-activerecord><ruby-on-rails-5><rails-migrations> | 2016-09-15 05:20:23 | HQ |
39,503,661 | cornerRadius stopped working in Swift 2.3 / iOS 10 / Xcode 8 | <p>I have a <code>cornerRadius</code> set on a <code>UIView</code> and a <code>UIImageView</code> inside the same <code>UIView</code>. I am calculating the corner radius with <code>RockProfileView.frame.size.height / 2</code> but the UIView stopped showing in iOS 10. </p>
<p>After further checking i found the value of <code>RockProfileView.frame.size.height / 2</code> is coming out to be 1000.0 while the width and height constraint is set to 64.0</p>
<p>When I hardcoded the <code>RockProfileView.layer.cornerRadius = 32</code> to 64/2 it works just fine. </p>
<p>What could be the issue ?</p>
<p>Full code:</p>
<pre><code> RockProfileView.layer.cornerRadius = RockProfileView.frame.size.height / 2
RockProfileView.clipsToBounds = true
RockProgressView.layer.masksToBounds = true
</code></pre>
| <swift3><ios10><swift2.3> | 2016-09-15 05:24:48 | HQ |
39,503,714 | Bogus float inequality due to compiler optimization? | <p>I found that some straightforward code results in an unexpected (and incorrect) inequality comparison on GCC 4.6.1 vs Visual Studio (2008 & 2012) or Clang 7.3.0 on OSX.</p>
<p>Here's a reduced snippet:</p>
<pre><code>typedef float ftype;
struct Foo
{
ftype v;
Foo(): v(16.0f / 60.0f) {}
ftype val() const {return v * 60.0f;}
};
void bar()
{
Foo f;
ftype v = f.val();
if (v != f.val())
printf("inequal");
}
</code></pre>
<p>If ftype is typedef'd as double then the problem doesn't occur. Could this be something to do with compiler inlining? Perhaps actually returning a double instead of a float?</p>
| <c++><gcc> | 2016-09-15 05:30:19 | LQ_CLOSE |
39,504,178 | how to check checkbox when right click in jquary | [This is my working table][1]
[1]: http://i.stack.imgur.com/00gtd.jpg
There are check boxes in table.I want to check those row by row when right click on the row.
| <jquery><html><checkbox> | 2016-09-15 06:13:16 | LQ_EDIT |
39,504,522 | Create blank image in Imagemagick | <p>How to create a blank new image in Imagemagick via command line?</p>
<p>Using <code>-background</code> doesn't work:</p>
<pre><code>$ convert -size 800x800 -background white x.png
convert: no images defined `x.png' @ error/convert.c/ConvertImageCommand/3257.
</code></pre>
| <imagemagick> | 2016-09-15 06:39:52 | HQ |
39,504,562 | Invalid json_decode while decode number with two dots | <p>I have problem with json_decode function - when I try to decode json-string</p>
<pre><code>{"amount": 132..45}
</code></pre>
<p>I didn't receive any errors, I got array</p>
<pre><code>[
'amount => 132
]
</code></pre>
<p>But it doens't expected result - I expect receive error.
Could anyone help me, what's wrong with my json_decode?</p>
| <php><json> | 2016-09-15 06:42:52 | LQ_CLOSE |
39,504,565 | Angular 2: Disable input change not working | <p>Up until "final" 2.0 of Angular I have done this:</p>
<pre><code><input type="text" formControlName="name" [disabled]="!showName">
</code></pre>
<p>To dynamically disable/enable form inputs. </p>
<p>After upgrading from Rc7 to 2.0 I get this warning in the console window:</p>
<blockquote>
<p>It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true
when you set up this control in your component class, the disabled attribute will actually be set in the DOM for
you. We recommend using this approach to avoid 'changed after checked' errors.</p>
</blockquote>
<p>I have changed my code to follow these instructions like this:</p>
<pre><code>this._userGroupUsersForm = this._formBuilder.group({
'users': [{'', disabled: this.showName}, Validators.compose([Validators.required, Validators.minLength(3), Validators.maxLength(50), Validators.pattern("^[a-zA-ZåäöÅÄÖ 0-9_-]+$")])]
});
</code></pre>
<p>And that works fine for the initial page load, but I can no longer toggle the status like this:</p>
<pre><code>toggleName() : void { this.showName = !this.showName; }
</code></pre>
<p>How do I solve this?</p>
<p>Note: My "old" way of doing this (by setting [disabled]) doesn't work any more either. </p>
| <forms><angular> | 2016-09-15 06:43:04 | HQ |
39,504,790 | Is it safe to compile againts later JDK? | <p>I have some big projects running on Java 6. But I plan to start building them in Java 8 since a lot of build tools have moved away from Java 6.</p>
<p>Is it safe for me to simply compile them with Java 8 and then deploy them in a web container running Java 8? If not, what are the considerations?</p>
<p>FYI, they don't have a proper automated test suite in place.</p>
| <java> | 2016-09-15 06:57:30 | LQ_CLOSE |
39,504,877 | Welcome page in Visual Studio Code How to get it | <p>I just downloaded <a href="https://code.visualstudio.com/" rel="noreferrer">Visual Studio Code</a> and started playing with it. </p>
<p>The you tube <a href="https://youtu.be/DmbvejtiyNo?t=133" rel="noreferrer">video here</a> recommends Quick Tour Videos. </p>
<p>So the question is how can I see the welcome page on Visual Studio code. When ever I open now, I am not seeing it. Probably when you open for the first time, you are shown this. But once you close that how do I reopen it?</p>
| <visual-studio-code> | 2016-09-15 07:02:50 | HQ |
39,506,149 | Ubuntu 16.04 systemd redis issues with ulimit | <p>I have been having issues with our new redis server after swapping from Ubuntu 14.04 to 16.04. The configuration of the open files limit using all the guides says to change the /etc/security/limits.conf with the following settings</p>
<pre><code>* soft nofile 65535
* hard nofile 65535
root soft nofile 65535
root hard nofile 65535
</code></pre>
<p>And also to add to /etc/pam.d/common-session and /etc/pam.d/common-session-noninteractive</p>
<pre><code>session required pam_limits.so
</code></pre>
<p>I have made all of these changes but redis is still starting up with a file limit of 4096 which under production load we quickly reach max connections.</p>
| <ubuntu><redis><systemd><ubuntu-16.04><ulimit> | 2016-09-15 08:14:25 | HQ |
39,506,379 | Could not find method externalNativeBuild() for arguments | <p>i'm trying to integrate the ndkBuild functionality into an existing android studio project, using the new android studio 2.2 , in order to enable c++ debugging etc.
i have tried out one of the ndk example projects which android studio 2.2 offers, which works perfectly fine. However, when i try to run the gradle commands in my own project, i get this error message:</p>
<p><em>Error:(73, 0) Could not find method externalNativeBuild() for arguments [build_c6heui1f67l8o1c3ifgpntw6$_run_closure2$_closure9@4329c1c9] on project ':core' of type org.gradle.api.Project.</em> </p>
<p>By following this description
<a href="http://tools.android.com/tech-docs/external-c-builds">http://tools.android.com/tech-docs/external-c-builds</a>
i ended up with a gradle script which includes the following commands:</p>
<pre><code>externalNativeBuild{
ndkBuild{
path "$projectDir/jni/Android.mk"
}
}
externalNativeBuild {
ndkBuild {
arguments "NDK_APPLICATION_MK:=$projectDir/jni/Application.mk"
abiFilters "armeabi-v7a", "armeabi","arm64-v8a","x86"
cppFlags "-frtti -fexceptions"
}
}
</code></pre>
<p>Did i perhaps miss out on something here with the project setup?
I have set the <strong>Android NDK location</strong> properly under </p>
<p><em>File -> Project Structure ... -> SDK Location -> Android NDK location</em></p>
<p>in my android studio. </p>
<p>Anything else i might have forgotton?</p>
<p>Has anyone run into a similar problem before?</p>
<p>Advice would be much appreciated =)</p>
| <android-ndk><java-native-interface><build.gradle><ndk-build><android-studio-2.2> | 2016-09-15 08:27:21 | HQ |
39,507,443 | Change paypal shopping cart/checkout input labels, form name and remove quantity input | <p>how can I change the labels to the shopping cart?
<a href="https://www.paypal.com/webapps/shoppingcart" rel="noreferrer">https://www.paypal.com/webapps/shoppingcart</a></p>
<p>Getting to this page by sending this form</p>
<pre><code><div class="paypal_module">
<form id="paypal_form_1_buy_now_button" method="post" action="https://www.paypal.com/cgi-bin/webscr">
<div class="hiddenFields">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="nancy@somesite.com">
<input type="hidden" name="return" value="{homepage}advance-reservations/confirmation">
<input type="hidden" name="cancel_return" value="{homepage}">
<input type="hidden" name="item_name" value="">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="amount" value="">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="currency_code" value="">
<input type="hidden" name="custom" value="1">
<input type="hidden" name="site_id" value="1">
<INPUT TYPE="hidden" NAME="first_name" VALUE="">
<INPUT TYPE="hidden" NAME="last_name" VALUE="">
<INPUT TYPE="hidden" NAME="email" VALUE="">
<INPUT TYPE="hidden" NAME="night_phone_a" VALUE="">
<INPUT TYPE="hidden" NAME="city" VALUE="">
<INPUT TYPE="hidden" NAME="zip" VALUE="">
<INPUT TYPE="hidden" NAME="state" VALUE="">
<INPUT TYPE="hidden" NAME="address1" VALUE="">
<INPUT TYPE="hidden" NAME="address2" VALUE="">
<INPUT TYPE="hidden" NAME="undefined_quantity" VALUE="1">
</div>
<input type="submit" id="trip-booking-submit" name="submit" value="Submit" class="paypal_button button-sm-primary" style="float: right">
</form>
</code></pre>
<p>I would need to change the labels as in this pic. Is this possible?</p>
<p>Changes needed:</p>
<ul>
<li>Change the form name from "Purchase details" to "Deposit details"</li>
<li>Change input label from "Price per item" to "Deposit amount"</li>
<li>Remove the quantity input</li>
</ul>
<p><a href="https://i.stack.imgur.com/6FJnJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6FJnJ.png" alt="enter image description here"></a></p>
<p>Thanks in advance!</p>
<p>Helping links: <a href="https://www.paypal.com/cgi-bin/webscr?cmd=p/pdn/howto_checkout-outside" rel="noreferrer">https://www.paypal.com/cgi-bin/webscr?cmd=p/pdn/howto_checkout-outside</a></p>
<p><a href="https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECCustomizing/#setting-the-paypal-checkout-page-style" rel="noreferrer">https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECCustomizing/#setting-the-paypal-checkout-page-style</a></p>
| <php><paypal> | 2016-09-15 09:23:43 | HQ |
39,507,581 | Uncaught (in promise): Error: Cannot read property of undefined | <p>Component take user from service with params</p>
<pre><code>@Component({
selector: 'users',
providers: [UserService],
template: `
<p>{{user.id}}</p>
`
})
export class UserPageComponent implements OnInit {
constructor(
private userService: UserService,
private route: ActivatedRoute
) {};
ngOnInit(): void {
this.route.params.forEach((params: Params) => {
let id = +params['id'];
this.userService.getUser(id)
.then(user => {console.log(user.id);this.user = user})
});
}
</code></pre>
<p>Service :</p>
<pre><code>@Injectable()
export class UserService {
private postUrl = 'http://127.0.0.1:8000/user-detail/'; // URL to web api
constructor(private http: Http) {
}
getUser(id: number): Promise<User> {
return this.http.get(this.postUrl+id)
.toPromise()
.then(response => response.json() as User)
.catch(this.handleError);
};
</code></pre>
<p>And I get Error <code>Uncaught (in promise): Error: Error in ./UserPageComponent class UserPageComponent - inline template:1:7 caused by: Cannot read property 'id' of undefined</code></p>
<p>It looks as if the service does not send the promise, although it should.
How to solve this proble?</p>
| <javascript><angular> | 2016-09-15 09:30:07 | HQ |
39,507,712 | Mocking Bigquery for integration tests | <p>While other interfaces are relatively easy to mock in my Java integration tests, I couldn't find a proper way of mocking Bigquery.</p>
<p>One possibility is to mock the layer I wrote on top of Bigquery itself, but I prefer mocking Bigquery in a more natural way. I'm looking for a limited, lightweight implementation, which allows defining the table contents, and supports queries using the standard API.
Is there such a library? If not, what alternative approaches are recommended?</p>
| <java><google-bigquery><integration-testing> | 2016-09-15 09:35:35 | HQ |
39,508,155 | Can't add setOnClickListener on function showInputDialog | I write a function to handle showing dialog but I can't use on click Listeriner to it what wrong with my code can any one tell me?
Here is my function
private void showInputDialog() {
final Dialog dialog=new Dialog(MainDashboard.this);
dialog.setContentView(R.layout.frg_dialog_change_pass);
btn_save_password=(Button) findViewById(R.id.btn_save_password);
btn_cancel_pass=(Button) findViewById(R.id.btn_cancel_pass);
edtOldpass=(EditText) findViewById(R.id.edtOldpass);
edtNewpass=(EditText) findViewById(R.id.edtNewpass);
edtConfirmpass=(EditText)findViewById(R.id.edtConfirmpass);
dialog.show();///Show the dialog.
btn_save_password.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainDashboard.this, "Success", Toast.LENGTH_SHORT).show();
dialog.cancel();
}
}); | <java><android><function><android-alertdialog> | 2016-09-15 09:56:36 | LQ_EDIT |
39,508,387 | 1. CGPathMoveToPoint' is unavailable: Use move(to:transform:) 2. 'CGPathAddLineToPoint' is unavailable: Use addLine(to:transform:) | <p>I have created one of my application in <code>swift 2</code> in <code>Xcode 7.3.1</code>. But now I have open same application in <code>Xcode 8.0</code> and perform changes. Some automatic changes are done and some errors and suggestions shown I have corrected them. But I am facing issue that </p>
<pre><code>let path = CGMutablePath()
CGPathMoveToPoint(path, nil, lineFrame.midX, lineFrame.midY)
CGPathAddLineToPoint(path, nil, lineFrame.origin.x + lineFrame.width / 2, lineFrame.origin.y)
</code></pre>
<p>I tried to create <code>path</code>, but shows error that </p>
<blockquote>
<ol>
<li><code>CGPathMoveToPoint</code> is unavailable: Use move(to:transform:)</li>
<li><code>CGPathAddLineToPoint</code> is unavailable: Use addLine(to:transform:)</li>
</ol>
</blockquote>
<p>If anyone have solution, please let me know.</p>
| <swift3><xcode8><cgpath> | 2016-09-15 10:08:04 | HQ |
39,508,868 | completion handler's error in swift 3 and Xcode 8 | <p>I have working project in Xcode 7.3 with swift 2.2 version. Now I have updated Xcode 8 and migrated to swift 3. Now my project contains errors specially for blocks like success block of afnetworking.</p>
<p><a href="https://i.stack.imgur.com/NYIe1.png"><img src="https://i.stack.imgur.com/NYIe1.png" alt="Snapshot for error in afnetworking post method"></a></p>
<p>Which gives error as </p>
<pre><code>Cannot convert value of type '() -> ()' to expected argument type '((URLSessionDataTask, Any?) -> Void)?'
</code></pre>
<p>I don't understand how to solve this to work as per swift 3.</p>
<p>And there is also same like error in Facebook login.</p>
<p><a href="https://i.stack.imgur.com/uJ9uG.png"><img src="https://i.stack.imgur.com/uJ9uG.png" alt="Facebook Login error"></a></p>
<p>Which gives error as</p>
<pre><code>Cannot convert value of type '(FBSDKLoginManagerLoginResult!, NSError!) -> Void' to expected argument type 'FBSDKLoginManagerRequestTokenHandler!'
</code></pre>
<p>and </p>
<pre><code>Cannot convert value of type '(_, _, NSError!) -> Void' to expected argument type 'FBSDKGraphRequestHandler!'
</code></pre>
<p>This all errors are related to handler blocks in swift 3. I don't understand the errors and so that can't able to solve. Any help will be appreciated. Thanks in advance.</p>
| <ios><facebook><afnetworking><swift3><xcode8> | 2016-09-15 10:32:05 | HQ |
39,509,319 | error at opening another activity? | Simply Im trying to open another activity when I click to btnFemale button and btnMale button.Now btnfemale button is works well but btnMale button doesnt work.
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button BtnFemale = (Button)findViewById(R.id.btnFemale);
final Button BtnMale = (Button) findViewById(R.id.btnMale);
BtnFemale.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(),ActivityTwo.class);
startActivity(intent);
BtnMale.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v){
Intent intent = new Intent(getApplicationContext(),ActivityThree.class);
startActivity(intent);
}
});
;
}
});
}
}
| <android><android-activity> | 2016-09-15 10:55:57 | LQ_EDIT |
39,509,904 | Huge files in Docker containers | <p>I need to create a Docker image (and consequently containers from that image) that use large files (containing genomic data, thus reaching ~10GB in size).</p>
<p>How am I supposed to optimize their usage? Am I supposed to include them in the container (such as <code>COPY large_folder large_folder_in_container</code>)? Is there a better way of referencing such files? The point is that it sounds strange to me to push such container (which would be >10GB) in my private repository. I wonder if there is a way of attaching a sort of volume to the container, without packing all those GBs together.</p>
<p>Thank you.</p>
| <docker><dockerfile><docker-container> | 2016-09-15 11:25:06 | HQ |
39,511,067 | Missing comma error ,while inserting clob value in table | CREATE TABLE fcc_consistency_check
(cons_id VARCHAR2(30),
cons_desc VARCHAR2(4000),
cons_query CLOB,
module_id VARCHAR2(2),
main_tab_name VARCHAR2(30),
hist_tab_name VARCHAR2(30),
col_name VARCHAR2(4000),
col_type VARCHAR2(4000),
check_reqd VARCHAR2(1)
);
INSERT INTO fcc_consistency_check
VALUES ('CHK_BC003','Missing records in contract_event_log','select a.CONTRACT_REF_NO ,a.Latest_Event_Seq_No,
c.PREV_WORKING_DAY from cstb_contract A ,sttm_dates c
where module_code = 'BC'
and c.Branch_code='000'
and not exists (select * from cstb_contract_event_log B
where a.contract_ref_no = b.contract_ref_no
and latest_event_seq_no = event_seq_no);',
'BC','BCCC_EVENT_LOG_MISREC','BCCC_EVENT_LOG_MISREC_HISTORY','CONTRACT_REF_NO,LATEST_EVENT_SEQ_NO,EOD_DATE','VARCHAR2(16),NUMBER,DATE','Y');
Not able to insert clob value, getting error missing comma, when i try to insert individual column value then i found that ,error is throwing for column cons_query .
| <mysql><oracle11g><plsqldeveloper> | 2016-09-15 12:29:28 | LQ_EDIT |
39,511,088 | Navigationbar coloring in ViewWillAppear happens too late in iOS 10 | <p>I am facing a weird bug, that happens only on iOS 10.</p>
<p>I have a application with several screens, and each screen colors the <code>navigationBar</code> in <code>viewWillAppear</code>. So when you go to the next screen, it will be properly colored.</p>
<p>However, when testing on iOS 10 I suddenly see the following behaviour when going back to a previous screen:
When the previous screen appears the <code>navigationBar</code> still has the color of the previous screen and then flashes to the proper color.
It almost looks like <code>viewWillAppear</code> somehow behaves as <code>viewDidAppear</code>.</p>
<p>Relevant code:</p>
<p>ViewController:</p>
<pre><code>- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[ViewControllerPainter paint:self withBackground:[UIColor whiteColor] andForeground:[UIColor blackColor] andIsLight:true];
}
</code></pre>
<p>Painter:</p>
<pre><code>+ (void)paint:(UIViewController *)controller withBackground:(UIColor *)backgroundColor andForeground:(UIColor *)foregroundColor andIsLight:(bool)isLight
{
controller.navigationController.navigationBar.opaque = true;
controller.navigationController.navigationBar.translucent = false;
controller.navigationController.navigationBar.tintColor = foregroundColor;
controller.navigationController.navigationBar.barTintColor = backgroundColor;
controller.navigationController.navigationBar.backgroundColor = backgroundColor;
controller.navigationController.navigationBar.barStyle = isLight ? UIBarStyleDefault : UIBarStyleBlack;
controller.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: foregroundColor};
}
</code></pre>
<p>Is this a bug? Is there something I can do about to fix this? It's very frustrating.</p>
| <ios10><viewwillappear> | 2016-09-15 12:30:29 | HQ |
39,512,002 | Convert whole dataframe from lower case to upper case with Pandas | <p>I have a dataframe like the one displayed below: </p>
<pre><code># Create an example dataframe about a fictional army
raw_data = {'regiment': ['Nighthawks', 'Nighthawks', 'Nighthawks', 'Nighthawks'],
'company': ['1st', '1st', '2nd', '2nd'],
'deaths': ['kkk', 52, '25', 616],
'battles': [5, '42', 2, 2],
'size': ['l', 'll', 'l', 'm']}
df = pd.DataFrame(raw_data, columns = ['regiment', 'company', 'deaths', 'battles', 'size'])
</code></pre>
<p><a href="https://i.stack.imgur.com/fiOEt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fiOEt.png" alt="enter image description here"></a></p>
<p>My goal is to transform every single string inside of the dataframe to upper case so that it looks like this:</p>
<p><a href="https://i.stack.imgur.com/gprF6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gprF6.png" alt="enter image description here"></a></p>
<p>Notice: all data types are objects and must not be changed; the output must contain all objects. I want to avoid to convert every single column one by one... I would like to do it generally over the whole dataframe possibly.</p>
<p>What I tried so far is to do this but without success</p>
<pre><code>df.str.upper()
</code></pre>
| <python><pandas><type-conversion><uppercase><lowercase> | 2016-09-15 13:14:27 | HQ |
39,512,679 | Styleguide settings for Kotlin | <p>I've started to use Koltin heavily and struggling a bit with code formatting. </p>
<p>Although there is an official <a href="http://kotlinlang.org/docs/reference/coding-conventions.html" rel="noreferrer">coding conventions</a> guide, but I wonder if there is any public available styleguide settings for IntelliJ (such as <a href="https://github.com/google/styleguide" rel="noreferrer">google codestyle</a> for Java) which you can grab/import and use?</p>
| <intellij-idea><kotlin> | 2016-09-15 13:43:49 | HQ |
39,513,412 | Java program to find a pallindrome | <p>I am a beginner in Java programming.
I was a making a program to find if the entered word is a pallindrome or not can someone please tell me the logic i should use to make the given program?</p>
| <java><bluej> | 2016-09-15 14:14:55 | LQ_CLOSE |
39,513,872 | How display logo on each page on the print? | <p>I work on design of the report for my customer.
I need to display logo on each page when customer prints the report.</p>
<p>here is my html row that I want to put on the header of each page when I on print mode:</p>
<pre><code><img style="page-break-before:always" src="/somepath/Content/images/logo.png" class="visible-print" style="width:200px;height:100px" alt="" />
</code></pre>
<p>Is there any way to implement it?</p>
| <html><css><twitter-bootstrap-3><printing-web-page> | 2016-09-15 14:35:58 | LQ_CLOSE |
39,514,335 | How to float text around image in react native | <p>I am trying to achieve a very common effect in react native of having text wrap around an image. On the web you would assign a <code>float</code> property to the image and follow it with a <code>p</code> tag. <a href="https://i.stack.imgur.com/MWgnc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MWgnc.png" alt="Here is how I want my elements to flow"></a>. </p>
<p>Here is a <a href="https://rnplay.org/apps/_s6X_Q" rel="noreferrer">RNPlay example</a> I've been working on. I think the method I currently have is a bit hackish, and doesn't properly work since the text does not align with the top of the image and flow down. Is there a proper and clean way to accomplish this?</p>
| <css><react-native><flexbox> | 2016-09-15 14:59:21 | HQ |
39,514,347 | CSS Transform & Transition which prefixes (e.g. -o-) are necessary? | <p>Is there any up to date documentation that lists which out of the following prefixes are required for transforms and transitions and for which browser version? Or could anyone sum it up for me?</p>
<p>Do I need to use all of these for transform?</p>
<pre><code> -webkit-transform:
-moz-transform:
-ms-transform:
-o-transform:
transform:
</code></pre>
<p>And all of these for transition?</p>
<pre><code> -webkit-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
-ms-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
</code></pre>
<p>Just to be safe?</p>
| <css> | 2016-09-15 14:59:54 | LQ_CLOSE |
39,514,518 | Xamarin.Android Proguard - Unsupported class version number 52.0 | <p>I'm trying to use Proguard in my Xamarin.Android project, yet the compilation fails with the error <code>Unsupported class version number [52.0] (maximum 51.0, Java 1.7)</code></p>
<p>I saw from those <a href="https://stackoverflow.com/questions/23170502/proguard-says-unsupported-class-version-number-52-0-maximum-51-0-java-1-7-w">two</a> <a href="https://stackoverflow.com/questions/22670059/error-proguard-unsupported-class-version-number">questions</a> that it may be a mismatch between Java 7 and Java 8, more precisely some versions of proguard don't support Java 8. However in Xamarin Preferences -> SDK Location, Java SDK points to JDK 7 : <code>/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home</code></p>
<p>Is there any place where proguard can be configured more precisely ? Any other idea ?</p>
<p>Here's the failure log :</p>
<blockquote>
<p>java.io.IOException: Can't read
[/Library/Frameworks/Xamarin.Android.framework/Versions/7.0.0-18/lib/xbuild-frameworks/MonoAndroid/v7.0/mono.android.jar]
(Can't process class [android/app/ActivityTracker.class] (Unsupported
class version number [52.0] (maximum 51.0, Java 1.7))) at
proguard.InputReader.readInput(InputReader.java:230) at
proguard.InputReader.readInput(InputReader.java:200) at
proguard.InputReader.readInput(InputReader.java:178) at
proguard.InputReader.execute(InputReader.java:78) at
proguard.ProGuard.readInput(ProGuard.java:196) at
proguard.ProGuard.execute(ProGuard.java:78) at
proguard.ProGuard.main(ProGuard.java:492) Caused by:
java.io.IOException: Can't process class
[android/app/ActivityTracker.class] (Unsupported class version number
[52.0] (maximum 51.0, Java 1.7)) at
proguard.io.ClassReader.read(ClassReader.java:112) at
proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.JarReader.read(JarReader.java:65) at
proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65) at
proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53) at
proguard.InputReader.readInput(InputReader.java:226) ... 6 more
Caused by: java.lang.UnsupportedOperationException: Unsupported class
version number [52.0] (maximum 51.0, Java 1.7) at
proguard.classfile.util.ClassUtil.checkVersionNumbers(ClassUtil.java:140)
at
proguard.classfile.io.ProgramClassReader.visitProgramClass(ProgramClassReader.java:88)
at proguard.classfile.ProgramClass.accept(ProgramClass.java:346) at
proguard.io.ClassReader.read(ClassReader.java:91) ... 11 more</p>
<p>9 Warning(s) 1 Error(s)</p>
</blockquote>
| <xamarin><xamarin.android><android-proguard> | 2016-09-15 15:07:45 | HQ |
39,514,915 | Hitting Tab in Visual Studio selects block instead of adding indentation | <p>I am using Visual Studio 2015 and ReSharper 2016.2 and I have this strange behavior, that I probably activated (accidentally). When having the cursor in a line before the first word, hitting the Tab-key indents the line correctly:</p>
<p><a href="https://i.stack.imgur.com/PxgwF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PxgwF.png" alt="enter image description here"></a></p>
<p>When the cursor is inside of any word inside the line, hitting the Tab-key selects the word or block.</p>
<p><a href="https://i.stack.imgur.com/vR0Xe.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vR0Xe.png" alt="enter image description here"></a></p>
<p>But the desired behavior would be to indent at the cursor (e.g. split a word into two words, if the cursor was inside of the word Stream after the letter r):</p>
<p><a href="https://i.stack.imgur.com/lnhM3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lnhM3.png" alt="enter image description here"></a></p>
<p>Does anyone know how this 'feature' is called? Does it come from ReSharper? Where can it be enabled or disabled?</p>
| <visual-studio-2015><resharper><indentation><keyboard-events> | 2016-09-15 15:27:25 | HQ |
39,515,313 | Animate navigation bar barTintColor change in iOS10 not working | <p>I upgraded to XCode 8.0 / iOS 10 and now the color change animation of my navigation bar is not working anymore, it changes the color directly without any animation.</p>
<pre><code>UIView.animateWithDuration(0.2, animations: {
self.navigationController?.navigationBar.barTintColor = currentSection.color!
})
</code></pre>
<p>Anyone knows how to fix this?</p>
| <ios><swift2><ios10> | 2016-09-15 15:47:54 | HQ |
39,516,199 | Type 'Any' Has no Subscript Members in xcode 8 Swift 3 | <p>My App is supposed to go to a specific location to pull down the website it needs to load. In 2.3 it worked like a charm, but since I've updated xcode (which I don't have a ton of experience in) it is giving me the error "type 'Any' has no subscript members" and highlighting the "json" right before line three</p>
<pre><code>...Retriever = json["WEB"]...
</code></pre>
<p>this is the code related to it.</p>
<pre><code>let json = try JSONSerialization.jsonObject(with: data!, options:.allowFragments)
if let Retriever = json["WEB"] as? [[String: AnyObject]] {
for website in Retriever {
if let name = website["URL"] as? String {
self.loadAddressURL(name)
</code></pre>
<p>I feel like I am missing something small. If there is a better way to do this, I would love suggestions. The URL returns this JSON</p>
<pre><code>{
"WEB" : [
{
"URL" : "http://www.google.com"
}
]
}
</code></pre>
<p>but I would love it if I could simplify it to just</p>
<pre><code>{"URL":"http://www.google.com"}
</code></pre>
| <ios><json><swift><swift3><xcode8> | 2016-09-15 16:36:44 | HQ |
39,516,786 | Constructing the Fibonacci sequence in Haskell | <p>I'm a complete beginner with Haskell and just encountered the following terse expression for constructing the Fibonacci sequence:</p>
<pre><code>fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
</code></pre>
<p>I think I understand what each individual piece is doing (<code>:</code>, <code>zipWith</code>, <code>tail</code>), and I know some sort of recursion is happening, but am not quite sure how.</p>
| <haskell><recursion><fibonacci> | 2016-09-15 17:14:32 | LQ_CLOSE |
39,516,876 | How can I get a button click event to fire as soon as my page loads? | <p>I've got this jQuery:</p>
<pre><code>$(document).ready(function () {
$("body").on( "click", "#btnGetData", function() {
var _begdate = $("#datepickerFrom").val();
var _enddate = $("#datepickerTo").val();
var _unit = $("#unitName").text();
document.body.style.cursor = 'wait';
$.ajax({
. . .elided for brevity.
});
});
$("#btnGenData").trigger('click');
});
</code></pre>
<p>I need the click event to occur as soon as the page load; I tried calling it this way, after the click function:</p>
<pre><code>$("#btnGenData").trigger('click');
</code></pre>
<p>...but it doesn't work. What am I missing?</p>
| <javascript><jquery> | 2016-09-15 17:19:08 | LQ_CLOSE |
39,516,885 | Workaround for Chrome 53 printing table header twice on 2nd and later pages? | <p>Users of my website need to be able to print web pages consisting of content on the first printed page followed by a table on the second page. A stripped down version is (jsFiddle at <a href="https://jsfiddle.net/jaydeedub/n3qhvtvx/25/">https://jsfiddle.net/jaydeedub/n3qhvtvx/25/</a> ):</p>
<p>HTML:</p>
<pre><code><body>
<button class="button" onclick="window.print()">Print Me</button>
<div class="page1">
This is the page 1 content. Blah, blah, blah.
</div>
<table class="table">
<thead>
<tr>
<td>Page 2 table header prints twice</td>
</tr>
</thead>
<tbody>
<tr>
<td>Page 2 table body</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Page 2 table footer</td>
</tr>
</tfoot>
</table>
</body>
</code></pre>
<p>CSS:</p>
<pre><code>@media print {
div.page1 {
page-break-after: always;
}
}
.table {
border-collapse: collapse;
margin: 16px;
}
.table>thead>tr>td,
.table>tbody>tr>td,
.table>tfoot>tr>td {
border: 1px solid black;
}
.button {
width: 6em;
height: 2em;
margin: 10px 0px;
}
</code></pre>
<p>This prints as expected in Chrome 52 on Chrome OS, but in Chrome 53 on Windows 7 Home and Chrome 53 on Chrome OS, the table header prints twice on the second page: once by itself without the top margin, and once with the top margin, followed by the rest of the table. It used to print normally in Windows in an earlier version of Chrome, but I do not know if that was Chrome 52 (definitely within the last few versions). It also prints as expected in Firefox.</p>
<p>I found one workaround, which is to put an empty 'thead' element before the real 'thead' element, but this solution is very kludgy and makes me uncomfortable.</p>
<p>Is there a more robust workaround that would be likely not to have side-effects across browsers?</p>
| <google-chrome><printing><html-table> | 2016-09-15 17:19:52 | HQ |
39,517,394 | SafeValue must use [property]=binding: | <p>I got the following error inside my input:</p>
<pre><code>SafeValue must use [property]=binding: http://www.myurl.com (see http://g.co/ng/security#xss)
</code></pre>
<p>I did in my component: </p>
<pre><code>this.myInputURL = this.sanitizer.bypassSecurityTrustUrl('http://www.myurl.com');
</code></pre>
<p>And in my template:</p>
<pre><code>Share URL: <md-input [value]="myInputURL" type="text"></md-input>
</code></pre>
<p>What's wrong?</p>
| <angular> | 2016-09-15 17:52:25 | HQ |
39,517,404 | running total wih constant numbers TSQL | I have data looks like this
'
MILEAGE January February ........December
0 ` 0 0
2 0.066 0.052
3 0.081 0
5 0 0.062
6 0.080 0 .........
813 0 0 and so on
'
I want the data to look like this
Mileage January February ..... December
0 (Total of Mileage less and equal to zero for each month)
2000 Total of Mileage upto 2000 for each month
4000 Total of Mileage upto 4000 for each month
6000 Total of Mileage upto 6000 for each month
8000 and so on....
10000
12000
14000
2 thousand increment up till
50000
'
Thank you very much for your help.I am using sql 2008 R2 and not sure how to achieve this
| <tsql><sql-server-2008-r2> | 2016-09-15 17:52:55 | LQ_EDIT |
39,517,908 | Amazon CodeCommit Error: git: 'credential-aws' is not a git command | <p>I am new to AWS world and I am implementing Continuous Delivery to the company I work for.</p>
<p>I followed this instructions to configure CodeCommit Service: <a href="http://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-https-windows.html#setting-up-https-windows-account" rel="noreferrer">http://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-https-windows.html#setting-up-https-windows-account</a></p>
<p><b>Step 1: Initial Configuration for AWS CodeCommit</b></p>
<p><i>To create and configure an IAM user for accessing AWS CodeCommit</i>:
I created a new IAM user and gave him AWSCodeCommitFullAcess</p>
<p><i> To install and configure the AWS CLI </i>: I installed and configured the credentials doing <em>aws configure</em> (setting AWS Access Key ID, AWS Secret Access Key, Default region name to us-east-1 and de</p>
<p><b> Step 2: Install Git </b>
I installed GIT for windows making sure the Enable Git Credential Manager option was cleared.</p>
<p><b> Step 3: Set Up the Credential Helper </b>
I execute these commands:</p>
<pre><code>git config --global credential.helper "!aws codecommit credential-helper $@"
git config --global credential.UseHttpPath true
</code></pre>
<p>Executing:</p>
<pre><code>git config --global --edit
</code></pre>
<p>I have:<br>
[http]<br> sslVerify = false</p>
<p>[credential]<br> helper = "aws codecommit list-repositories codecommit credential-helper " <br>UseHttpPath = true</p>
<p><strong>Step 4: Connect to the AWS CodeCommit Console and Clone the Repository</strong></p>
<pre><code>$ git clone https://git-codecommit.us-east-1.amazonaws.com/v1/repos/teste-git-to-s3<br>
Cloning into 'teste-git-to-s3'...<br>
git: 'credential-aws' is not a git command. See 'git --help'.<br>
Username for 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/teste-git-to-s3': Lucas<br>
fatal: unable to access 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/teste-git-to-s3/': The requested URL returned error: 403
</code></pre>
<p>Looking for Troubleshooting solutions on aws, I found: <a href="http://docs.aws.amazon.com/codecommit/latest/userguide/troubleshooting.html#troubleshooting-ae1" rel="noreferrer">http://docs.aws.amazon.com/codecommit/latest/userguide/troubleshooting.html#troubleshooting-ae1</a> but I could'nt solve it.</p>
<p>Does any one know how to solve this? Pleeeeease, help!</p>
| <git><aws-codecommit> | 2016-09-15 18:23:14 | HQ |
39,517,942 | Chat App using Firebase: Get notification when new message received - Android | <p>I am developing a chat app using Firebase Realtime Database. I have been able to send and receive messages properly. Now, I want to implement notification whenever new message is received. For that, I have created a <code>Service</code> which listens to database changes using <code>ChildEventListener</code> and creates notification. The problem is that I am creating notification in <code>onChildAdded</code> method and this method fires both for existing node in database and new one. This is causing notification to be created multiple times for same message whenever user navigate back and forth from app. </p>
<p>Here is how I am implementing it:</p>
<pre><code>chatMsgsRef.orderByChild(FirebaseDBKeys.LOCATION_LAST_UPDATED).addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
ChatMessage message = dataSnapshot.getValue(ChatMessage.class);
if (!message.getSenderId().equals(currentUserId)) {
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(NotificationsService.this)
.setSmallIcon(R.drawable.message)
.setContentTitle("New Message from " + message.getReceipientName())
.setContentText(message.getMessage())
.setOnlyAlertOnce(true)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
mBuilder.setAutoCancel(true);
mBuilder.setLocalOnly(false);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
</code></pre>
<p>How can I implement notifications in the way it works in other chat applications like whatsapp, etc.??</p>
| <android><firebase><notifications><firebase-realtime-database> | 2016-09-15 18:25:00 | HQ |
39,517,961 | Php auto responder mail reverts fill all fields when i have filled them. Please help i cant seem to get where its is originating. | <div class="col-md-6">
<div class="contact-form-result"></div>
<!--START form-->
<form name="form" action="post.php" method="post">
<div>
<label>Name :</label>
<input type="text" id="name" name="name" required>
</div>
<div>
<label>Father's Name :</label>
<input type="text" id="fname" name="fname" >
</div>
<div>
<label>Age :</label>
<input type="text" id="age" name="age" required>
</div>
<div>
<label>Sex :</label>
<select name="sex" required>
<option value="">Select</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Other">Other</option>
</select>
</div>
<div>
<label>Phone :</label>
<input type="text" id="phone" name="phone" required>
</div>
<div>
<label>Email :</label>
<input type="email" id="email" name="email" required>
</div>
<div>
<label>Choose Course :</label>
<select name="course" required>
<option value="">Select</option>
<option value="Civil Engineering - Comprehensive Course">Civil Engineering - Comprehensive Course </option>
<option value="Civil Engineering - Comprehensive Course">Civil Engineering - Comprehensive Course</option>
<option value="Civil Engineering - Semester Preparatory Course">Civil Engineering - Semester Preparatory Course</option>
<option value="Civil Engineering - Crash Course">Civil Engineering - Crash Course</option>
<option value="Mechanical Engineering">Mechanical Engineering</option>
<option value="Electrical Engineering">Electrical Engineering</option>
</select>
</div>
<div>
<label>Current Semester :</label>
<select name="semester" required>
<option value="">Select</option>
<option value="Semester 1"> Semester-1 </option>
<option value="Semester-2"> Semester-2</option>
<option value="Semester-3"> Semester-3</option>
<option value="Semester-4"> Semester-4</option>
<option value="Semester-5"> Semester-5</option>
<option value="Semester-6"> Semester-6</option>
<option value="Semester-7"> Semester-7</option>
</select>
</div>
<div>
<label>Enter Query if Any?</label>
<textarea rows="6" cols="30" name="message"></textarea>
</div>
<!--<div class="col_full hidden">
<input type="text" id="template-contactform-botcheck" name="template-contactform-botcheck" value="" class="sm-form-control" />
</div>-->
<div>
<button value="submit" type="submit" >Submit</button>
</div>
</form>
<!--END form-->
</div>
<!-- Php Code -->
<?php
require_once('include/phpmailer/PHPMailerAutoload.php');
$toemails = array();
$toemails[] = array(
'email' => 'info@engineeringexpress.in, gabrielkoch72@gmail.com', // Your Email Address
'name' => 'Engineering Express' // Your Name
);
// Form Processing Messages
$message_success = 'We have <strong>successfully</strong> received your Message and will get Back to you as soon as possible.';
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
if( $_POST['form'] != '' ) {
$name = isset( $_POST['name'] ) ? $_POST['name'] : '';
$email = isset( $_POST['email'] ) ? $_POST['email'] : '';
$phone = isset( $_POST['phone'] ) ? $_POST['phone'] : '';
$fname = isset( $_POST['fname'] ) ? $_POST['fname'] : '';
$age = isset( $_POST['age'] ) ? $_POST['age'] : '';
$message = isset( $_POST['message'] ) ? $_POST['message'] : '';
$sex = isset( $_POST['sex'] ) ? $_POST['sex'] : '';
$semester = isset( $_POST['semester'] ) ? $_POST['semester'] : '';
$course = isset( $_POST['course'] ) ? $_POST['course'] : '';
$subject = isset($subject) ? $subject : 'New Message From Contact Form';
$botcheck = $_POST['template-contactform-botcheck'];
if( $botcheck == '' ) {
$mail->SetFrom( $email , $name );
$mail->AddReplyTo( $email , $name );
foreach( $toemails as $toemail ) {
$mail->AddAddress( $toemail['email'] , $toemail['name'] );
}
$mail->Subject = $subject;
// AutoResponder Settings
$autoresponder->SetFrom( $toemails[0]['email'] , $toemails[0]['name'] );
$autoresponder->AddReplyTo( $toemails[0]['email'] , $toemails[0]['name'] );
$autoresponder->AddAddress( $email , $name );
$autoresponder->Subject = 'We\'ve received your Email';
$name = isset($name) ? "Name: $name<br><br>" : '';
$email = isset($email) ? "Email: $email<br><br>" : '';
$phone = isset($phone) ? "Phone: $phone<br><br>" : '';
$fname = isset($fname) ? "Fathers Name: $fname<br><br>" : '';
$message = isset($message) ? "Message: $message<br><br>" : '';
$age = isset($age) ? "Age : $age <br><br>" : '';
$sex = isset($sex) ? "Sex : $sex <br><br>" : '';
$semester = isset($semester) ? "Semester : $semester <br><br>" : '' ;
$course = isset($course) ? "Course : $course <br><br> " : '' ;
$referrer = $_SERVER['HTTP_REFERER'] ? '<br><br><br>This Form was submitted from: ' . $_SERVER['HTTP_REFERER'] : '';
$body = "$name $email $phone $fname $message $age $sex $semester $course $referrer";
// AutoResponder Message
$ar_body = "Thank you for contacting us. We will reply within 24 hours.<br><br>Regards,<br>Engineering Express";
$mail->MsgHTML( $body );
$autoresponder->MsgHTML( $ar_body );
$sendEmail = $mail->Send();
if( $sendEmail == true ):
$send_arEmail = $autoresponder->Send();
echo '{ "alert": "success", "message": "' . $message_success . '" }';
else:
echo '{ "alert": "error", "message": "Email <strong>could not</strong> be sent due to some Unexpected Error. Please Try Again later.<br /><br /><strong>Reason:</strong><br />' . $mail->ErrorInfo . '" }';
endif;
} else {
echo '{ "alert": "error", "message": "Bot <strong>Detected</strong>.! Clean yourself Botster.!" }';
}
} else {
echo '{ "alert": "error", "message": "Please <strong>Fill up</strong> all the Fields and Try Again." }';
}
} else {
echo '{ "alert": "error", "message": "An <strong>unexpected error</strong> occured. Please Try Again later." }';
}
?>
| <php><html> | 2016-09-15 18:26:07 | LQ_EDIT |
39,518,088 | What is DYMTLInitPlatform platform initialization successful log when the application starts? | <p>I've just updated to Xcode 8/iOS 10 SDK and now when I compile and run my app, I'm getting <code>[DYMTLInitPlatform] platform initialization successful</code> before all the other logs in the output.</p>
<p>It's not harmful or anything, but I was wondering what that message is related to, which wasn't there with Xcode 7.3/iOS 9.3 SDK.</p>
| <ios><xcode><ios10><xcode8> | 2016-09-15 18:33:19 | HQ |
39,518,374 | SCSS variable class name | <p>On my website, I'm constantly doing style="font-size: #ofpx;". However, I was wondering if there's a way to do it with scss so that, when I declare a class, it would also change the font size. For example:</p>
<pre><code><div class='col-lg-4 font-20'>whatever here</div>
</code></pre>
<p>and this would change my font-size to 20. If I did font-30, it would change my font-size to 30 and etc...</p>
<p>What I have so far:</p>
<pre><code>.font-#{$fontsize} {
font-size: $fontsize;
}
</code></pre>
| <css><sass> | 2016-09-15 18:52:02 | HQ |
39,518,500 | How to add pug to angular-cli? | <p>Anyone having luck adding .pug to angular-cli?</p>
<p>I tried to do npm install pug --save, but I don't know where to change the .pug rendering instead of .html.</p>
<p>Link for the angular-cli is <a href="https://github.com/angular/angular-cli">here</a></p>
<p>Please share a short tutorial, that would help a lof of people :)</p>
| <angular><typescript><angular-cli><pug> | 2016-09-15 18:59:46 | HQ |
39,518,708 | PHP data validation | <p>I am trying to create data validation code in PHP and was wondering how to go about that. I understand that someone can Inject code or scripts through the input boxes on my website. I am preventing entrance of characters such as <code>< " / \</code> but I don't know what else to use. For example I am accepting data into a $var and if someone enters echo <code>"<div style = "position: fixed; height: 1000px; width: 100%" ></div>"</code> whatever this will do, it will still run if I accept it into my $var right and run the code? Unless the host has mechanisms to prevent that</p>
| <php> | 2016-09-15 19:15:22 | LQ_CLOSE |
39,519,440 | How to remove undefined values from array but keep 0 and null | <p>In javascript, I want to remove undefined values, but keep the values 0 and null from an array. </p>
<pre><code>[ 1, 2, 3, undefined, 0, null ]
</code></pre>
<p>How can I do it cleanly?</p>
| <lodash> | 2016-09-15 20:02:39 | HQ |
39,519,823 | Using Rollup for Angular 2's AoT compiler and importing Moment.js | <p>I'm trying to follow the <a href="https://angular.io/docs/ts/latest/cookbook/aot-compiler.html">official AoT guide</a> for Angular 2, and I'm using Moment.js in my application. Moment.js is on my <em>packages.json</em> file, and I'm using version 2.15.0. I've been importing it like this so far:</p>
<pre><code>import * as moment from 'moment';
</code></pre>
<p>But when I get to the part where I have to run rollup, I end up with the following error:</p>
<blockquote>
<p>Cannot call a namespace ('moment')</p>
</blockquote>
<p>Which appears to be related to the way I import moment according to <a href="https://github.com/rollup/rollup/issues/670">this</a>. So, how am I supposed to do this?
I can't seem to import moment any other way. If I use</p>
<pre><code>import moment from 'moment'
</code></pre>
<p>I get the compile error</p>
<blockquote>
<p>External module ''moment'' has no default export</p>
</blockquote>
| <angular><typescript><momentjs><rollupjs><angular2-aot> | 2016-09-15 20:28:51 | HQ |
39,520,534 | Autolayout issue Xcode 8 [_SwiftValue nsli_superitem] | <p>Converting my code to Swift 3 I found a weird issue.
Right now (15th September 2016) Xcode 8 (public version) is out, and after converting the code, my App crashes without an apparently reason.</p>
<p>There is something wrong with Auto Layout and the log says something like:</p>
<pre><code>[_SwiftValue nsli_superitem]: unrecognized selector sent to instance
</code></pre>
<p>How can I solve? Thanks</p>
| <ios><swift><xcode><swift3> | 2016-09-15 21:19:00 | HQ |
39,521,096 | How to add apostrophes in a dictionnary | <p>I was just wondering if it is possible to add an apostrophe in this situation.
I want the test key to have the value of "I don't know" not "I don". Is it possible to do so? If so how?</p>
<pre><code> my_dict = {
"test": 'I don't know'
}
</code></pre>
| <python><python-2.7> | 2016-09-15 22:11:30 | LQ_CLOSE |
39,521,122 | Javascript Regex for decimal | <p>I need a regex for a 5 digit integer number with 2 decimals.</p>
<p>These would be correct:</p>
<ul>
<li>12345.12</li>
<li>09856.99</li>
<li>45123.00</li>
</ul>
<p>These wouldn't:</p>
<ul>
<li>123.12</li>
<li>12345.6</li>
<li>98652</li>
</ul>
| <javascript><regex> | 2016-09-15 22:14:46 | LQ_CLOSE |
39,521,341 | pyspark error: AttributeError: 'SparkSession' object has no attribute 'parallelize' | <p>I am using pyspark on Jupyter notebook. Here is how Spark setup:</p>
<pre><code>import findspark
findspark.init(spark_home='/home/edamame/spark/spark-2.0.0-bin-spark-2.0.0-bin-hadoop2.6-hive', python_path='python2.7')
import pyspark
from pyspark.sql import *
sc = pyspark.sql.SparkSession.builder.master("yarn-client").config("spark.executor.memory", "2g").config('spark.driver.memory', '1g').config('spark.driver.cores', '4').enableHiveSupport().getOrCreate()
sqlContext = SQLContext(sc)
</code></pre>
<p>Then when I do:</p>
<pre><code>spark_df = sqlContext.createDataFrame(df_in)
</code></pre>
<p>where <code>df_in</code> is a pandas dataframe. I then got the following errors:</p>
<pre><code>---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-9-1db231ce21c9> in <module>()
----> 1 spark_df = sqlContext.createDataFrame(df_in)
/home/edamame/spark/spark-2.0.0-bin-spark-2.0.0-bin-hadoop2.6-hive/python/pyspark/sql/context.pyc in createDataFrame(self, data, schema, samplingRatio)
297 Py4JJavaError: ...
298 """
--> 299 return self.sparkSession.createDataFrame(data, schema, samplingRatio)
300
301 @since(1.3)
/home/edamame/spark/spark-2.0.0-bin-spark-2.0.0-bin-hadoop2.6-hive/python/pyspark/sql/session.pyc in createDataFrame(self, data, schema, samplingRatio)
520 rdd, schema = self._createFromRDD(data.map(prepare), schema, samplingRatio)
521 else:
--> 522 rdd, schema = self._createFromLocal(map(prepare, data), schema)
523 jrdd = self._jvm.SerDeUtil.toJavaArray(rdd._to_java_object_rdd())
524 jdf = self._jsparkSession.applySchemaToPythonRDD(jrdd.rdd(), schema.json())
/home/edamame/spark/spark-2.0.0-bin-spark-2.0.0-bin-hadoop2.6-hive/python/pyspark/sql/session.pyc in _createFromLocal(self, data, schema)
400 # convert python objects to sql data
401 data = [schema.toInternal(row) for row in data]
--> 402 return self._sc.parallelize(data), schema
403
404 @since(2.0)
AttributeError: 'SparkSession' object has no attribute 'parallelize'
</code></pre>
<p>Does anyone know what I did wrong? Thanks!</p>
| <python><hadoop><pandas><apache-spark><pyspark> | 2016-09-15 22:36:40 | HQ |
39,521,913 | Laravel 5.3 db:seed command simply doesn't work | <p>I do everything by-the-book: </p>
<ol>
<li><p>Installed fresh Laravel 5.3.9 app (all my non-fresh apps produce the same error)</p></li>
<li><p>run <code>php artisan make:auth</code></p></li>
<li><p>create migrations for a new table
`php artisan make:migration create_quotations_table --create=quotations</p>
<pre><code>Schema::create('quotations', function (Blueprint $table) {
$table->increments('id');
$table->string('text');
// my problem persists even with the below two columns commented out
$table->integer('creator_id')->unsigned()->index('creator_id');
$table->integer('updater_id')->unsigned()->index('updater_id');
$table->softDeletes();
$table->timestamps();
});
</code></pre></li>
<li><p>Then I run <code>php artisan migrate</code></p></li>
<li><p>Then I define a new seed <code>php artisan make:seeder QuotationsTableSeeder</code></p></li>
</ol>
<p>The complete content of the file, after I add a simple insert:</p>
<pre><code><?php
use Illuminate\Database\Seeder;
class QuotationsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('quotations')->insert([
'text' => str_random(10),
]);
}
}
</code></pre>
<ol start="6">
<li>Then I run <code>php artisan db:seed</code></li>
</ol>
<h2>problem</h2>
<p>it simply doesn't work. No feedback presented, no errors in log file.
The probem persists in both my local environment (Win7, newest WAMP server)
and my Digital Ocean VPS powered by Ubuntu 16.04.
All the above steps I took in several separate apps - for no result. Also under Laragon 2.0.5 server.</p>
<h2>what I have tried</h2>
<p><code>php artisan optimize</code> <a href="http://laravel.io/forum/04-22-2015-cant-seed-db-in-laravel-5" rel="noreferrer">as suggested here</a>.</p>
<p><code>composer dump-autoload</code> i <code>php artisan clear-compiled</code> also have brought no results</p>
<p>I also tried to seed just following the official docs example - failed.</p>
<p>I added <code>use DB;</code> to the seed file - still no result.</p>
<h2>to do</h2>
<p>help!!! How come they don't work?</p>
| <php><laravel><seeding><laravel-5.3><laravel-seeding> | 2016-09-15 23:46:41 | HQ |
39,521,966 | Why do I get the error object reference not set to instance of an ojbect while adding an object to a list in c# wpf? | <p>I have a C# WPF application with a form in it. The form is supposed to take two values(firstName and lastName) and then use the Instructor class to add it to my listview element. On the line <code>instList.Add(new Instructor...</code> I am getting the error <code>object reference not set to instance of an object</code>. Why does this happen?</p>
<p>This is my mainwindow.xaml.cs:</p>
<pre><code>namespace AssignmentTwoPartTwo
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public List<Instructor> instList;
public MainWindow()
{
InitializeComponent();
List<Instructor> instList = new List<Instructor> { };
lvInstructorList.ItemsSource = instList;
}
private void btnCreateInstructor_Click(object sender, RoutedEventArgs e)
{
spCreateInstructor.Visibility = (spCreateInstructor.Visibility == Visibility.Hidden) ? Visibility.Visible : Visibility.Hidden;
}
private void btnInstructorSubmit_Click(object sender, RoutedEventArgs e)
{
instList.Add(new Instructor() { firstName = txtInstructorFirstName.Text, lastName = txtInstructorLastName.Text });
lvInstructorList.ItemsSource = instList;
}
}
}
</code></pre>
<p>This is Instructor.cs</p>
<pre><code>namespace AssignmentTwoPartTwo
{
public class Instructor
{
public string firstName { set; get; }
public string lastName { set; get; }
}
}
</code></pre>
| <c#><wpf> | 2016-09-15 23:54:47 | LQ_CLOSE |
39,522,131 | Why are web apps going crazy with await / async nowadays? | <p>I come from a back end / thick client background, so maybe I'm missing something... but I recently looked at the source for an open source JWT token server and the authors went crazy with await / async. Like on every method and every line.</p>
<p>I get what the pattern is for... to run long running tasks in a separate thread. In my thick client days, I would use it if a method might take a few seconds, so as not to block the GUI thread... but definitely not on a method that takes a few ms.</p>
<p>Is this excessive use of await / async something you need for web dev or for something like Angular? This was in a JWT token server, so not even seeing what it has to do with any of those. It's just a REST end point.</p>
<p>How is making every single line async going to improve performace? To me, it'll kill performance from spinning up all those threads, no?</p>
| <c#><multithreading><asynchronous> | 2016-09-16 00:18:23 | HQ |
39,522,482 | How to share pdf and text through whatsapp in android? | <p>I tried with the following code but it is not attaching the pdf file.</p>
<pre><code>Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, message);
sendIntent.setType("text/plain");
if (isOnlyWhatsApp) {
sendIntent.setPackage("com.whatsapp");
}
Uri uri = Uri.fromFile(attachment);
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
activity.startActivity(sendIntent);
</code></pre>
| <android><pdf><share><whatsapp> | 2016-09-16 01:13:27 | HQ |
39,523,150 | AWS API Gateway - Remove Stage Name From URI | <p>The stage name is added to the url when I deploy the API. Let's say the stage name is "test", then the generated URL for the resource includes the stage name. Something like:
<a href="https://abcabc.execute-api.us-east-1.amazonaws.com/test/my/path" rel="noreferrer">https://abcabc.execute-api.us-east-1.amazonaws.com/test/my/path</a></p>
<p>I would like to remove the stage name in the URL. How can I do it?</p>
| <aws-api-gateway> | 2016-09-16 03:00:17 | HQ |
39,523,823 | What is .net alternative to jhipster | <p>Which framework provides similar features to .Net as jhipster does for Java. I understand that there are separate libraries that can be brought together to work as the solution, but is there something pre-packaged to make things as quick and smooth as jhipster does?</p>
| <.net><jhipster> | 2016-09-16 04:37:55 | HQ |
39,523,835 | How can I remain in a same line by pressing enter button in c++ | I am working on a programe but now I am stick with a problem and the problem is I want to enter two numbers but with the cursor in same line when ever I enter any number and press enter it moves to the next line but I want it on the same line.please help me!! | <c++> | 2016-09-16 04:39:12 | LQ_EDIT |
39,524,784 | require a SQL query to split a column into 3 columns | I have designed a table named as 'customeradd'. Till now no data has been entered into it.
Can anyone suggest me any SQL query to split 'customeradd'. column into 3 sub columns so that it looks like this in the schema:-
**customeradd**
| A | B | C |
| | | |
A,B,C are 3 sub columns of customeradd column
Thanks a lot. | <sql-server> | 2016-09-16 06:11:14 | LQ_EDIT |
39,524,855 | How to trigger off callback after updating state in Redux? | <p>In React, state is not be updated instantly, so we can use callback in <code>setState(state, callback)</code>. But how to do it in Redux?</p>
<p>After calling the <code>this.props.dispatch(updateState(key, value))</code>, I need to do something with the updated state immediately.</p>
<p>Is there any way I can call a callback with the latest state like what I do in React?</p>
| <javascript><reactjs><redux> | 2016-09-16 06:16:32 | HQ |
39,525,680 | What is going on with my nav bar and footer? | For some reason, my nav bar and footer are messed up. I don't want the user to have to scroll down at all, I want everything to fit on one page. Well for some reason the footer and the image are screwing that up. The biggest problem though is that my main content is not going in the middle of the page, but rather behind the nav bar.
Here is both CSS and HTML, and my website. Do you guys see any problems?
http://pastebin.com/Vzdascc1
http://pastebin.com/iVXQpJW9
http://ryfixit.tech/ | <html><css> | 2016-09-16 07:10:58 | LQ_EDIT |
39,525,960 | Method that returns Task<string> | <p>I need a method that returns a <code>Task<string></code> with empty string like</p>
<pre><code>public static Task<string> AsyncTest()
{
return new Task<string>(() => string.Empty); //problem here
// this method would work:
// return new WebClient().DownloadStringTaskAsync(@"http://www.google.de");
}
public static void Workdl(string input)
{
Console.Write("OUT: " + input.Substring(0, 100));
}
</code></pre>
<p>This snippet compiles but when I call it like</p>
<pre><code>Task<string> dlTask = AsyncTest();
Workdl(await dlTask);
await Task.WhenAll(dlTask); //Task never completes
</code></pre>
<p>it never determines.</p>
| <c#><task> | 2016-09-16 07:26:43 | HQ |
39,525,968 | Laravel's 5.3 passport and api routes | <p>I'm using Laravel Framework version 5.3.9, fresh download nothing added on via composer(except <code>"laravel/passport": "^1.0"</code>).</p>
<p>I did all the things suggested in the <a href="https://laravel.com/docs/master/passport">docs</a>. Tables are created, routes are up, everything works fine. However I need passport for an API.</p>
<p>My routes look like so:</p>
<pre><code>+--------+----------+-----------------------------------------+----------------------+----------------------------------------------------------------------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+-----------------------------------------+----------------------+----------------------------------------------------------------------------+------------+
| | GET|HEAD | / | | Closure | web |
| | GET|HEAD | api/v1/users/register | api::users::register | App\Http\Controllers\Api\V1\SocialController@register | api,auth |
| | POST | oauth/authorize | | \Laravel\Passport\Http\Controllers\ApproveAuthorizationController@approve | web,auth |
| | GET|HEAD | oauth/authorize | | \Laravel\Passport\Http\Controllers\AuthorizationController@authorize | web,auth |
| | DELETE | oauth/authorize | | \Laravel\Passport\Http\Controllers\DenyAuthorizationController@deny | web,auth |
| | GET|HEAD | oauth/clients | | \Laravel\Passport\Http\Controllers\ClientController@forUser | web,auth |
| | POST | oauth/clients | | \Laravel\Passport\Http\Controllers\ClientController@store | web,auth |
| | PUT | oauth/clients/{client_id} | | \Laravel\Passport\Http\Controllers\ClientController@update | web,auth |
| | DELETE | oauth/clients/{client_id} | | \Laravel\Passport\Http\Controllers\ClientController@destroy | web,auth |
| | GET|HEAD | oauth/personal-access-tokens | | \Laravel\Passport\Http\Controllers\PersonalAccessTokenController@forUser | web,auth |
| | POST | oauth/personal-access-tokens | | \Laravel\Passport\Http\Controllers\PersonalAccessTokenController@store | web,auth |
| | DELETE | oauth/personal-access-tokens/{token_id} | | \Laravel\Passport\Http\Controllers\PersonalAccessTokenController@destroy | web,auth |
| | GET|HEAD | oauth/scopes | | \Laravel\Passport\Http\Controllers\ScopeController@all | web,auth |
| | POST | oauth/token | | \Laravel\Passport\Http\Controllers\AccessTokenController@issueToken | |
| | POST | oauth/token/refresh | | \Laravel\Passport\Http\Controllers\TransientTokenController@refresh | web,auth |
| | GET|HEAD | oauth/tokens | | \Laravel\Passport\Http\Controllers\AuthorizedAccessTokenController@forUser | web,auth |
| | DELETE | oauth/tokens/{token_id} | | \Laravel\Passport\Http\Controllers\AuthorizedAccessTokenController@destroy | web,auth |
+--------+----------+-----------------------------------------+----------------------+----------------------------------------------------------------------------+------------+
</code></pre>
<p>All the <code>web</code> routes are there, there are no <code>api</code> related routes, since Passport doesn't provide anything of that sort out of the box.</p>
<p>The API itself is intended to be used by a trusted client, it's made for a mobile application that does require a login however, said login will bypass a few steps. </p>
<p>Once a user access the <code>/register</code> route, the registration process itself is quite simple: access the user's facebook account an grab a few fields - email, facebook id, name an profile picture and from that point onwards the users is considered registered. But the user will <strong>NOT</strong> login with facebook(this is a very important aspect). The consumer app will be issued a token and use that token to access various endpoints of the api(that require a token to use). </p>
<p>So it boils down to this. I need to issue an access token to the consumer app that access the API. The API itself will only have one client, that is the mobile app itself. Users that use the app are not considered clients of the API but clients of the mobile app itself.</p>
<p>So far Passport is a headache to work with when it comes to implementing API related stuff, either that or I can't figure out how to make it work properly.</p>
<p>I've created a test client in the <code>oauth_clients</code> table that looks like so:</p>
<p><a href="https://i.stack.imgur.com/4hYJh.png"><img src="https://i.stack.imgur.com/4hYJh.png" alt="enter image description here"></a></p>
<p>I'm using Postman to access <code>api/v1/users/register</code> route that has the <code>auth</code> middleware with the following <code>JSON application/json</code></p>
<pre><code>{
"grant_type" : "authorization_code",
"client_id" : 5,
"client_secet": "y5dvPIOxQJOjYn7w2zzg4c6TRrphsrNFWbG4gAUL"
}
</code></pre>
<p>Which of course will result in a </p>
<pre><code>{"error":"Unauthenticated."}
</code></pre>
<p>It makes perfect sense.
Out of pure curiosity I changed the <code>/register</code> route to this:</p>
<pre><code>Route::group([
'middleware' => [
],
], function ()
{
Route::group([
'prefix' => 'users',
'as' => 'users::',
], function ()
{
// Route::get('/register', ['as' => 'register', 'uses' => 'Api\V1\SocialController@register',]);
Route::post('/register', ['as' => 'register', 'uses' => '\Laravel\Passport\Http\Controllers\AccessTokenController@issueToken',]);
});
});
</code></pre>
<p>With the same <code>json</code> as before. That resulted in <code>{"error":"invalid_client","message":"Client authentication failed"}</code>. </p>
<p>I've tracked down the function that, I think, handles the <code>validateClient</code> part in <a href="https://github.com/thephpleague/oauth2-server/blob/master/src/Grant/AbstractGrant.php#L143"><code>vendor/league</code>oauth2-server/src/Grant/AbstractGrant`</a>.</p>
<p>The <code>$client</code> is null. Now this may or may not be related to Passport, since the documentation on it rather lacking and the thought of digging thru a monster of a package to track down the error that may be largely due to me not doing something right doesn't strike me as a good idea, I'm out of options. To be perfectly honest I don't even know what the problem is.</p>
<p>Really, at this point any sort pointing in the right direction is more than welcome.</p>
<p>The part in questions is </p>
| <php><laravel-5.3> | 2016-09-16 07:26:55 | HQ |
39,526,699 | Guzzle difference between 'connect_timeout' and 'timeout' | <p>What's the difference between 'connect_timeout' and 'timeout' request options in Guzzle.</p>
| <guzzle> | 2016-09-16 08:14:34 | HQ |
39,529,454 | NSUserActivity not getting indexed on osx | <p>I'm trying to add my own activity to Spotlight search results on osx 10.11. But after a lot of tries I couldn't got to be in Spotlight search results not by keywords search, not by title search.</p>
<pre><code>{
self.userActivity = [[NSUserActivity alloc] initWithActivityType:@"Reverse DNS keyword"];
self.userActivity.title = @"Some title";
self.userActivity.keywords = [NSSet setWithArray: @[@"Some keywords"]];
self.userActivity.eligibleForSearch = YES;
self.userActivity.eligibleForHandoff = YES;
self.userActivity.eligibleForPublicIndexing = YES;
self.userActivity.userInfo = @{@"name" : @"Some name"};
self.userActivity.delegate = self;
self.userActivity.requiredUserInfoKeys =[NSSet setWithArray: @[@"name"]];
self.userActivity.needsSave = YES;
[self.userActivity becomeCurrent];
NSApp.userActivity = self.userActivity;
}
- (void)userActivityWillSave:(NSUserActivity *)userActivity
{
userActivity.userInfo = @{@"name" : @"Some name"};
}
</code></pre>
<p>Also I've updated Info.plist with NSUserActivityTypes array and item from the initWithActivityType: argument</p>
<p>Also I've noticed that in Console sometime appears messages:</p>
<pre><code>16/09/2016 13:14:49.731 Caching encoded userInfo to use until we are marked dirty again (UAUserActivity.m #1567)
16/09/2016 13:14:49.731 Returning cached encoded userInfo (UAUserActivity.m #1508)
</code></pre>
| <ios><macos><cocoa><cocoa-touch><nsuseractivity> | 2016-09-16 10:39:57 | HQ |
39,529,725 | Can someone explain what this code? | lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position,long id) {
try {text.delete(position, position);
String item = strArr.get(position);
strArr.remove(item);
adapter = new ArrayAdapter<String (getApplicationContext(), android.R.layout.simple_list_item_1, strArr);
lv.setAdapter(adapter);
return true;
}
catch (Exception e) {
e.getMessage();
}
return true;
}
}
);
} | <android> | 2016-09-16 10:52:44 | LQ_EDIT |
39,529,870 | if(process.env.NODE_ENV === 'production') always false | <p>When trying to build an angular-webpack application by running the build command from this scripts list on the package.json:</p>
<pre><code>"scripts": {
"test": "NODE_ENV=test karma start",
"build": "if exist dist rd /s /q dist && mkdir dist && set NODE_ENV=production && webpack && cp app/index.html dist/index.html",
"start": "webpack-dev-server --content-base app"
},
</code></pre>
<p>this is the result on the console : </p>
<pre><code>$ npm run build
> webpack-ng-egg@1.0.0 build M:\Learning webpack\egghead.io - AngularJS - Angula
r and Webpack for Modular Applications\webpack-ng-egg
> if exist dist rd /s /q dist && mkdir dist && set NODE_ENV='production' && webp
ack && cp app/index.html dist/index.html
process.env.NODE_ENV : 'production'
process.env.NODE_ENV === 'production' ???? : false
Hash: c3136b0024cbd48ccb2e
Version: webpack 1.13.2
Time: 3185ms
Asset Size Chunks Chunk Names
bundle.js 1.23 MB 0 [emitted] main
+ 10 hidden modules
</code></pre>
<p>this is how looks like the webpack.config.js file :</p>
<pre><code> var webpack = require('webpack');
var path = require('path');
var config = {
context: path.resolve(__dirname, "app"),
entry:'./app.js',
output: {
path : __dirname + '/app',
filename:'bundle.js' // il ne sera pas généré dans le code, juste en mémoire
},
plugins:[
new webpack.DefinePlugin({
ON_TEST:process.env.NODE_ENV === 'test'
})
],
module:{
loaders: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel', // 'babel-loader' is also a legal name to reference
query: {
presets: ['es2015']
}
},
{ test: /\.css$/,
loader: "style-loader!css-loader",
exclude: /(node_modules|bower_components)/
},
{
test: /\.html$/,
exclude: /(node_modules|bower_components)/,
loader: 'raw', // 'babel-loader' is also a legal name to reference
},
{ test: /\.styl$/,
loader: 'style-loader!css-loader!stylus-loader',
exclude: /(node_modules|bower_components)/
}
]
},
devServer:{
//contentBase:path.join(__dirname, 'dist') // ceci est juste un exemple, si dist est l'endroit ou on aurait généré les fichiers
inline:true, // les mises à jour de style ne sont plus affichés instantnément avec cette option donc j'ai ajouté le watch:true et çà marché!!!
watch:true
}
/*resolve: {
extensions: ['', '.js', '.jsx', '.css']
},
resolveLoader: {
root: require('path').resolve(__dirname, "node_modules")
}*/
}
console.log("process.env.NODE_ENV : " + process.env.NODE_ENV);
console.log("process.env.NODE_ENV === 'production' ???? : " + (process.env.NODE_ENV == 'production'));
//config.output.path = path.resolve(__dirname, "dist");
//console.log("config.output.path : " + config.output.path);
if(process.env.NODE_ENV === 'production') {
console.log("this is the prod env!!!!!!!!!!");
config.output.path = path.resolve(__dirname, "dist");
}
module.exports = config;
</code></pre>
<p>the problem here is that when testing <code>(process.env.NODE_ENV === 'production')</code> it never returns true even that it's supposed to be (see what is logged on the console above). I have tried to chage to a simple equality instead the strict one but still get false all the time.</p>
| <angularjs><node.js><windows><webpack> | 2016-09-16 11:01:18 | HQ |
39,529,967 | How to compair NString when it is converted from NSArray in objective c | I am new in iOS. And I am facing a problem in a code
array=[[NSMutableArray alloc] init];
array =[responsedict valueForKey:@"Type"];
NSLog(@"Type Array =%@",array);
for (int i =0; i<[array count]; i++) {
if (array.count>0)
{
typeString = [NSMutableString stringWithFormat:@"%@", [array objectAtIndex:i]];
NSLog(@"Type String =%@",typeString);
}
}
I am getting the value in String as
Type String =1
Type String =2
Now I need to compair the String in cellForRowAtIndexPath
if ([typeString isEqual:@"1"]) {
cell.IBTiconlbl.textColor = [UIColor blueColor];
}
if ([typeString isEqual:@"2"]) {
cell.IBTiconlbl.textColor = [UIColor redColor];
}
But it convert the textcolour only in readColor not in blue colour.String contain both the value 1 and 2.I need to convert the text colour in blue when string value is 1 and in red when string value is 2.But it only perform the one operation. Please help!! | <ios><objective-c><nsstring><nsarray> | 2016-09-16 11:05:51 | LQ_EDIT |
39,529,976 | Shared element transition leaves a strange white background between first activity and second transparent activity | <p>Recently I faced up with a weird problem.
I have two activities. The first one contains a grid with a thumbnails. A kind of a gallery. And the second one contains a view pager with fragments and behaves like an image viewer where you can slide between images.
I use a shared element transition to start the second activity. Just like Google Photo app. On the second activity I can swipe to top or bottom to dismiss the activity with a fade away transition of the background. I made my second activity fully transparent: </p>
<pre><code><item name="android:windowBackground">@color/palette_transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
</code></pre>
<p>But the problem is when I swipe an image to top/bottom and the second activity's background fades I can see a white background but not the first activity. If I start the second activity without shared element transition everything is fine. </p>
<p>I made a research and found out that this white layer probably overlays the first activity. It is not a part of the second activity as I can see in Stetho view hierarchy. </p>
<p>Probably my explanation is not very good neither my English language so here a couple of videos too clarify my problem.</p>
<p>Video <a href="https://www.youtube.com/watch?v=VSfa9TgpHCk" rel="noreferrer">Without transition</a> and Video <a href="https://www.youtube.com/watch?v=RACj8tgTMqI" rel="noreferrer">With transition</a></p>
| <android><transparent><shared-element-transition> | 2016-09-16 11:06:31 | HQ |
39,530,207 | Unable to run this code can you plaese halp - JavaScript | for (i = 65; i < 99; i++) {
var str[]=String.fromCharCode(i);
$("#div1").html("str");
}
**please help me to print alphabets using javascript** | <javascript> | 2016-09-16 11:19:42 | LQ_EDIT |
39,530,337 | The program directly executes catch(Runtime error) | [The app executes only the RuntimeException catch][1]
[1]: http://i.stack.imgur.com/OWd8P.png | <android> | 2016-09-16 11:26:13 | LQ_EDIT |
39,530,369 | Object must implement IConvertible (InvalidCastException) while casting to interface | <p>I'm trying to cast an object of a certain type to an interface it implements using <code>Convert.ChangeType()</code>, however an <code>InvalidCastException</code> gets thrown because <em>the object must implement IConvertible</em>.</p>
<p>The types:</p>
<pre><code>public IDocumentSet : IQueryable {}
public IDocumentSet<TDocument> : IDocumentSet, IQueryable<TDocument> {}
public XmlDocumentSet<TDocument> : IDocumentSet<TDocument> {}
</code></pre>
<p>Excerpt from code where the error happens:</p>
<pre><code>private readonly ConcurrentDictionary<Type, IDocumentSet> _openDocumentSets = new ConcurrentDictionary<Type, IDocumentSet>();
public void Commit()
{
if (_isDisposed)
throw new ObjectDisposedException(nameof(IDocumentStore));
if (!_openDocumentSets.Any())
return;
foreach (var openDocumentSet in _openDocumentSets)
{
var documentType = openDocumentSet.Key;
var documentSet = openDocumentSet.Value;
var fileName = GetDocumentSetFileName(documentType);
var documentSetPath = Path.Combine(FolderPath, fileName);
using (var stream = new FileStream(documentSetPath, FileMode.Create, FileAccess.Write))
using (var writer = new StreamWriter(stream))
{
var documentSetType = typeof (IDocumentSet<>).MakeGenericType(documentType);
var writeMethod = typeof (FileSystemDocumentStoreBase)
.GetMethod(nameof(WriteDocumentSet), BindingFlags.Instance | BindingFlags.NonPublic)
.MakeGenericMethod(documentSetType);
var genericDocumentSet = Convert.ChangeType(documentSet, documentSetType); <-------
writeMethod.Invoke(this, new[] {writer, genericDocumentSet});
}
}
}
</code></pre>
<p>Now, I'm failing to understand why exactly this happens (as <code>XmlDocumentSet</code> is not a value type) and <code>XmlDocumentSet<'1></code> implements <code>IDocumentSet<'1></code>. Am I missing something? Or is there an easier way to achieve what I'm doing?</p>
| <c#><.net><xml><reflection><casting> | 2016-09-16 11:28:06 | HQ |
39,531,453 | Populating Dropdown in ASP.net Core | <p>Does anyone know how to deal with Dropdowns in Asp.net core. I think I made myself very complicated to understand the new Asp.net core concept. (I am new to Asp.net Core).</p>
<p>I have models called <code>Driver</code>, <code>Vehicle</code>. Basically one can create bunch of vehicles in the master then attach it to the Driver. So that the driver will be associated with a vehicle.</p>
<p>My problem is that I am also using viewmodel in some area to combine two different models.(understood little from default template)</p>
<p>My problem is I have no idea what is the next step since ASP.net Core is very latest, there are not a lot of tutorials and Q/As available.</p>
<p>Driver Model</p>
<pre><code>public class Driver
{
[Required]
public int Id { get; set; }
[Required]
public string ApplicationUserId { get; set; }
[Required]
public int VehicleId { get; set; }
[Required]
public string Status { get; set; }
public virtual ApplicationUser ApplicationUser { get; set; }
public virtual Vehicle Vehicle { get; set; }
}
</code></pre>
<p>Vehicle Model</p>
<pre><code>public class Vehicle
{
[Required]
public int Id { get; set; }
[Required]
public string Make { get; set; }
public string Model { get; set; }
[Required]
public string PlateNo { get; set; }
public string InsuranceNo { get; set; }
}
</code></pre>
<p>ViewModel of Driver</p>
<pre><code> public class DriverViewModel
{
[Required]
[Display(Name = "ID")]
public int ID { get; set; }
[Required]
[Display(Name = "User ID")]
public string ApplicationUserId { get; set; }
[Required]
[Display(Name = "Vehicle ID")]
public IEnumerable<Vehicle> VehicleId { get; set; }
//public string VehicleId { get; set; }
[Required]
[Display(Name = "Status")]
public string Status { get; set; }
}
</code></pre>
<p>Here is my View</p>
<pre><code><div class="col-md-10">
@*<input asp-for="VehicleId" class="form-control" />*@
@Html.DropDownList("VehicleId", null, htmlAttributes: new { @class = "form-control"})
<span asp-validation-for="VehicleId" class="text-danger" />
</div>
</code></pre>
| <asp.net><asp.net-core><asp.net-core-mvc><asp.net-core-1.0> | 2016-09-16 12:24:10 | HQ |
39,532,534 | why calls python both functions? | I have some problems to understand what happens here...
This is my source:
class Calc():
def __init__(self,Ideal,Limit,Value,Debug=None):
self.Ideal = Ideal
self.Limit = Limit
self.Value = Value
self.Debug = Debug
self.Grade = self.GetGrade()
self.LenGrade = self.GetLenGrade()
def GetGrade(self):
if self.Debug:
print('calling GetGrade')
return Grade
def GetLenGrade(self):
if self.Debug:
print('calling GetLenGrade')
return Grade
When calling it with
GradeMinLen += Calc(TargetLen, LimitMinLen, Length ,Debug=1).LenGrade
I get always the output
calling GetGrade
calling GetLenGrade
Why is python calling GetGrade? | <python> | 2016-09-16 13:18:58 | LQ_EDIT |
39,532,651 | Calculating operation count for Big Oh | `void G(....)
{`
`for ( int k = n/2; k > 0; k /= 2 )
{`
` for ( int m = 0; m < n; m++)`
a[(k+m)%n]=k+m; }
}
Ok guys, thanks in advance for your help. I'm unsure how to count the loop operations when the loop initiator and increment is like (n/2) and (k/=2) respectively..and so on. Running this code on a compiler for different values of n gave me interesting results, such as if n is 2^x then the iterations are n * x for values of n until 2^(x+1) -1. Now I'm stuck and don't know which Big Oh function to classify this as. Any answers/feedback/suggested learning methods/explanations welcome! Thank you! | <algorithm><big-o> | 2016-09-16 13:25:06 | LQ_EDIT |
39,532,953 | Push Notifications not being received on iOS 10, but working on iOS 9 and before | <p>I have several apps that were written in Swift 2.2, compiled with Xcode 7.3 and is live on the App Store. The apps utilize Push Notifications and is working fine in iOS 9.3 and earlier.</p>
<p>On devices that have been upgraded to iOS 10, however, my apps don't receive any Push Notifications. Devices that are still running iOS 9 are still receiving notifications.</p>
<p>Thinking it might be a certificate or entitlement issue, I have tried the following:
Upgraded one of my apps to Swift 2.3, added the APS Environment Entitlement and compiled it in Xcode 8 but this made no difference.</p>
<p>In my AppDelegate I still have the existing methods to register for push notifications that includes:</p>
<pre><code>let notificationSettings = UIUserNotificationSettings(forTypes: [.Badge, .Sound, .Alert], categories:nil)
application.registerUserNotificationSettings(notificationSettings)
</code></pre>
<p>This registration seems to be successful even on iOS 10 since <em>Application didRegisterForRemoteNotificationsWithDeviceToken</em> is then called, so I am receiving a token from APNS.</p>
<p>The problem is that when I send a push notification to this device, <em>Application didReceiveRemoteNotification</em> is never called.</p>
<p>Now, <a href="http://cleanswifter.com/ios-10-local-notifications/">here</a> it is said that the methods on UIApplicationDelegate is deprecated on iOS 10 and I should implement userNotificationCenter(<em>:didReceive:withCompletionHandler:) and userNotificationCenter(</em>:willPresent:withCompletionHandler:)</p>
<p>The problem is that I am not ONLY targeting iOS 10. I still need the app to work on iOS 8 and 9 so I doubt that it's the correct approach to implement those methods.</p>
<p>How do I get push notifications for an existing app to continue working on devices that have been upgraded to iOS 10? Do I need to rewrite code? Do I just need to update some certificates or entitlements and recompile in Xcode 8 with some "new" settings?</p>
| <ios><swift><push-notification><apple-push-notifications><xcode8> | 2016-09-16 13:38:41 | HQ |
39,533,291 | Angular2 router 2.0.0 not reloading components when same url loaded with different parameters? | <p>I have this in my .routing.ts file</p>
<pre><code>export const routing = RouterModule.forChild([
{
path: 'page/:id',
component: PageComponent
}]);
</code></pre>
<p>My <code>PageComponent</code> file checks the id parameter and loads the data accordingly. In previous versions of the router, if i went from /page/4 to /page/25, the page would "reload" and the components would update.</p>
<p>Now when i try navigating to /page/X where X is the id, it only ever loads the first time, then the url changes, but the components do not "reload" again.</p>
<p>Is there something that needs to be passed in to force my components to reload, and call the ngOnInit event?</p>
| <javascript><html><angular><angular2-routing> | 2016-09-16 13:55:17 | HQ |
39,533,484 | MySQL | Java -> How to get a String from a field | i've got a mysql question within java. I've got a mysql database with different tables. I would like for example to have a database called 'litebans' and a table called 'litebans_mutes'. Within that table there's a kinda-stringy thingy called reason and under that reason (let's say what's within reason) there's a string called 'This is a test'; how would i get the string 'This is a test' in java?
Thanks! | <java><mysql> | 2016-09-16 14:04:10 | LQ_EDIT |
39,533,532 | Ansible Timeout (12s) waiting for privilege escalation prompt | <p>I'm having trouble running my Ansible playbook on AWS instance. Here is my version:</p>
<pre><code>$ ansible --version
ansible 2.0.0.2
</code></pre>
<p>I created an inventory file as:</p>
<pre><code>[my_ec2_instance]
default ansible_host=MY_EC2_ADDRESS ansible_user='ubuntu' ansible_ssh_private_key_file='/home/MY_USER/MY_KEYS/MY_KEY.pem'
</code></pre>
<p>Testing connection to my server:</p>
<pre><code>$ ansible -i provisioner/inventory my_ec2_instance -m ping
default | SUCCESS => {
"changed": false,
"ping": "pong"
}
</code></pre>
<p>Now when running my playbook on this inventory I get the error <code>Timeout (12s) waiting for privilege escalation prompt</code> as follows:</p>
<pre><code>$ ansible-playbook -i provisioner/inventory -l my_ec2_instance provisioner/playbook.yml
PLAY [Ubuntu14/Python3/Postgres/Nginx/Gunicorn/Django stack] *****
TASK [setup] *******************************************************************
fatal: [default]: FAILED! => {"failed": true, "msg": "ERROR! Timeout (12s) waiting for privilege escalation prompt: "}
NO MORE HOSTS LEFT *************************************************************
PLAY RECAP *********************************************************************
default : ok=0 changed=0 unreachable=0 failed=1
</code></pre>
<p>If I run the same playbook using the <code>.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory</code> as the inventory parameter it works perfectly on my Vagrant instance.(I believe, proving there is nothing wrong in the playbook/roles itself)</p>
<p>Also, if I run it with an <code>-vvvv</code>, copy the <code>exec ssh</code> line and run it manually it indeed connects to AWS without problems.</p>
<p>Do I need to add any other parameter on my inventory file to connect an EC2 instance? What am I missing?</p>
| <amazon-ec2><ansible-playbook><ansible-2.x> | 2016-09-16 14:06:30 | HQ |
39,533,958 | What does 'fileprivate' keyword means in Swift? | <p>I'm starting in swift and opening a project created using swift2 from xcode 8 beta, the <code>private</code> modifier were changed to <code>fileprivate</code>. what does this keyword means? and how is different from <code>private</code> ?</p>
| <swift><private><access-modifiers> | 2016-09-16 14:26:46 | HQ |
39,534,200 | HTML - How do I reveal a checkbox group based on radio group? | <p>I want to have an html form with a required radio group.
If one particular option in this radio group is selected, it reveals a checkbox group. This checkbox group should only be required if it is revealed.
How could I do this?
Preferably in pure HTML, but javascript can be used too if absolutely necessary.</p>
<p>Thanks</p>
| <javascript><html><checkbox> | 2016-09-16 14:39:46 | LQ_CLOSE |
39,534,378 | How can install arm-linux-gcc-3.3.2.tar.bz2 on ubuntu | <p>I'm trying to make cross compiler. And I commend like tar xvjf arm-linux-gcc-3.3.2.tar.bz2. But when ls /usr/local/arm there is nothing. arm directory doesn't exsist.... I dont know what to do.....</p>
| <linux><ubuntu><arm><cross-compiling> | 2016-09-16 14:49:03 | LQ_CLOSE |
39,534,675 | How to go to very previous step while doing debugging in eclipse | <p>I tried to run an application but my application was stopped with error message (handled by exception) . I want to see the very previous step that caused the exception.
Is there any way through debugging we can find out the previous step that caused the exception.</p>
| <java><debugging><web-applications> | 2016-09-16 15:03:13 | LQ_CLOSE |
39,534,676 | TypeError: first argument must be an iterable of pandas objects, you passed an object of type "DataFrame" | <p>I have a big dataframe and I try to split that and after <code>concat</code> that.
I use</p>
<pre><code>df2 = pd.read_csv('et_users.csv', header=None, names=names2, chunksize=100000)
for chunk in df2:
chunk['ID'] = chunk.ID.map(rep.set_index('member_id')['panel_mm_id'])
df2 = pd.concat(chunk, ignore_index=True)
</code></pre>
<p>But it return an error</p>
<pre><code>TypeError: first argument must be an iterable of pandas objects, you passed an object of type "DataFrame"
</code></pre>
<p>How can I fix that?</p>
| <python><pandas> | 2016-09-16 15:03:14 | HQ |
39,534,935 | Is there a Python equivalent to the C# ?. and ?? operators? | <p>For instance, in C# (starting with v6) I can say:</p>
<pre><code>mass = (vehicle?.Mass / 10) ?? 150;
</code></pre>
<p>to set mass to a tenth of the vehicle's mass if there is a vehicle, but 150 if the vehicle is null (or has a null mass, if the Mass property is of a nullable type).</p>
<p>Is there an equivalent construction in Python (specifically IronPython) that I can use in scripts for my C# app?</p>
<p>This would be particularly useful for displaying defaults for values that can be modified by other values - for instance, I might have an armor component defined in script for my starship that is always consumes 10% of the space available on the ship it's installed on, and its other attributes scale as well, but I want to display defaults for the armor's size, hitpoints, cost, etc. so you can compare it with other ship components. Otherwise I might have to write a convoluted expression that does a null check or two, like I had to in C# before v6.</p>
| <python><ironpython> | 2016-09-16 15:16:18 | HQ |
39,535,278 | How to add new column in existing View in SQL-Server 2014 using Alter | <p>I have created a view that is based on another view and a table. I want to add new column of type varchar. I did like below, But getting syntax error?
I am new to SQL, So,could not understand</p>
<pre><code>ALTER VIEW [dbo].[MyView]
ADD New_Col varchar(10) null
GO
</code></pre>
| <sql><sql-server><view><alter> | 2016-09-16 15:34:51 | HQ |
39,536,144 | libsystem_symptoms.dylib missing in Xcode 8 | <p>I just updated to Xcode 8, and I can no longer build xml2-based applications. If I build a simple file and try to build it as follows:</p>
<pre><code>c++ myapp.cc `xml2-config --cflags` `xml2-config --libs`
</code></pre>
<p>...I get the following error message:</p>
<pre><code>ld: file not found: /usr/lib/system/libsystem_symptoms.dylib for architecture x86_64
</code></pre>
<p>It doesn't matter what's in myapp.cc (mine is just a main routine that returns 0). The root problem seems to be that Apple removed /usr/lib/system/libsystem_symptoms.dylib in Xcode 8, but many of the .tbd files in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/lib still point to it. Has anyone else run into a problem like this?</p>
| <xml><xcode><macos> | 2016-09-16 16:24:07 | HQ |
39,536,358 | Visual Studio: Tab key selects and highlights code | <p>If I place my cursor inside a multi-line comment:</p>
<pre><code>/*
* place cursor after the asterisk and before the word 'place'
*/
if (x == 0)
{
// some code
}
</code></pre>
<p>... and hit <kbd>tab</kbd>, Visual Studio doesn't add whitespace as usual. Instead, it highlights the entire comment (all three lines, in the example). If I hit <kbd>tab</kbd> again, it will select and highlight the next statement or block of statements. In my example, it highlights the entire <code>if</code>.</p>
<p>How do I fix this and make Visual Studio tab things over? I want <kbd>tab</kbd> to behave like a <kbd>tab</kbd>.</p>
<p>I'm using Visual Studio 2013 Ultimate with Resharper 9. It started doing this yesterday, and I have no idea why.</p>
| <visual-studio-2013><resharper><keyboard-shortcuts> | 2016-09-16 16:36:46 | HQ |
39,536,519 | java.lang.IllegalArgumentException: Rect should intersect with child's bounds | <p>In Android Studio after starting a new project, and selecting a Tabbed Activity, after the project is build, I get this error in the Android Monitor:</p>
<pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.app, PID: 23581
java.lang.IllegalArgumentException: Rect should intersect with child's bounds.
at android.support.design.widget.CoordinatorLayout.offsetChildByInset(CoordinatorLayout.java:1319)
at android.support.design.widget.CoordinatorLayout.onChildViewsChanged(CoordinatorLayout.java:1257)
at android.support.design.widget.CoordinatorLayout$OnPreDrawListener.onPreDraw(CoordinatorLayout.java:1805)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:847)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1867)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
</code></pre>
<p>What does this exception mean, and how to fix it? It is a completely new project, so I have <em>not</em> made any change.</p>
| <android><android-layout><dalvik> | 2016-09-16 16:48:50 | HQ |
39,537,103 | Is it possible to alias an import? | <p>In c# when pulling in a library that has a lot of name collisions with existing code, there's a way to alias the import so you don't need to fully clarify the namespace for each use. eg:</p>
<pre><code>using MyCompany.MyLibrary.Model as MMM
</code></pre>
<p>then you could do</p>
<pre><code>MMM.MyObject
</code></pre>
<p>instead of</p>
<pre><code>MyCompany.MyLibrary.Model.MyObject
</code></pre>
<p>With the recent update to swift 3.0, I've found some of my model objects are now colliding with the <code>Foundation</code> types, and I've been forced to prefix things that used to have an <code>NS</code> prefix in the class name with <code>Foundation.classname</code>. It would be great if I could type alias the import of my model library much like the c# example given above. Is this possible in swift 3.0? If not is there another strategy to avoid name collisions that would result in having to write the framework name in front of each type? I'm considering going back to prefixing my class names like we did in obj-c, but I'm trying to explore my options before I do that.</p>
| <swift><swift3> | 2016-09-16 17:27:11 | HQ |
39,537,171 | <No main classes found> in java program | <p>Hello I am writing a java program that converts Celsius to Fahrenheit. A custom method will calculate the conversion and pass it to the main method which called it.. In the main method a loop will be invoked as long as 0-100 and increment by 10.. I have tried some of the other suggestions I have seen with this error but with no luck.. Here is my code and thanks in advance</p>
<pre><code>package sknight_project10_orig;
public class SKnight_Project10_ORIG
{
public static double main(String[] args)
{
double Celsius = 0.0;
double Fahrenheit = 0.0;
//For loop to increment by 10 from 0-100
for (int i = 0; i < 100; i++)
{
convertTemp(Celsius);
System.out.println(Celsius + " = " + Fahrenheit);
i = i + 10;
}
return Celsius;
}
public static Double convertTemp(Double Celsius)
{
double Fahrenheit = Celsius * 1.8 + 32;
return Fahrenheit;
}
}
</code></pre>
| <java> | 2016-09-16 17:31:45 | LQ_CLOSE |
39,537,764 | how can I get the lattitude and longitude of someone in android as I just start working on android | actually I want to calculate distance between two user's coordinates .Is there anywhere that would be a good place for me to start with GPS feature on Android, or that has a good example of how to use GPS? I don't want anything deep, literally just how to retrieve and use current GPS coordinates. I'd like to start simple and build up from there. | <android><android-gps> | 2016-09-16 18:16:45 | LQ_EDIT |
39,538,473 | using setTimeout on promise chain | <p>Here i am trying to wrap my head around promises.Here on first request i fetch a set of links.and on next request i fetch the content of first link.But i want to make a delay before returning next promise object.So i use setTimeout on it.But it gives me the following JSON error (<strong><code>without setTimeout() it works just fine</code></strong>)</p>
<blockquote>
<p>SyntaxError: JSON.parse: unexpected character at line 1 column 1 of
the JSON data</p>
</blockquote>
<p><strong><em>i would like to know why it fails?</em></strong></p>
<pre><code>let globalObj={};
function getLinks(url){
return new Promise(function(resolve,reject){
let http = new XMLHttpRequest();
http.onreadystatechange = function(){
if(http.readyState == 4){
if(http.status == 200){
resolve(http.response);
}else{
reject(new Error());
}
}
}
http.open("GET",url,true);
http.send();
});
}
getLinks('links.txt').then(function(links){
let all_links = (JSON.parse(links));
globalObj=all_links;
return getLinks(globalObj["one"]+".txt");
}).then(function(topic){
writeToBody(topic);
setTimeout(function(){
return getLinks(globalObj["two"]+".txt"); // without setTimeout it works fine
},1000);
});
</code></pre>
| <javascript><json><promise> | 2016-09-16 18:59:55 | HQ |
39,538,534 | How to control md-select drop down position in Angular Material | <p>I need to customize a md-select so that the option list acts more like a traditional select. The options should show up below the select element instead of hovering over top of the element. Does anyone know of something like this that exists, or how to accomplish this?</p>
| <javascript><css><angularjs><angular-material> | 2016-09-16 19:04:17 | HQ |
39,538,765 | JavaScript - Split words into letters and save them to an array | <p>I have this code:</p>
<pre><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bad Grammar Generator</title>
</head>
<body>
<input type="text" id="userIn">
<input type="button" name="name" id="btn" value="Bad Grammar-ify" onclick="badgrammar()">
<span id="output"></span>
<script type="text/javascript">
var userIn = document.getElementById("userIn").value;
function badgrammar() {
var userIn = document.getElementById("userIn").value;
var output = document.getElementById("output");
var split = new Array();
split = userIn.split(" ");
output.innerText = split;
}
</script>
</body>
</html>
</code></pre>
<p>It works, but it splits user input into one word. How can I make it split user input down to the letter?</p>
<p>Example:</p>
<p>Input: <code>Hi there</code>
Output: <code>H,i,t,h,e,r,e</code></p>
| <javascript><arrays> | 2016-09-16 19:21:24 | LQ_CLOSE |
39,539,037 | are element id's avoided in modern web dev? | <p>I seem to remember reading or someone telling me that modern web dev practices tend to avoid assigning id's to elements in lieu of classes or data-attributes. Is this correct or am I possibly misinterpreting this practice based on my experience in one particular scenario?</p>
| <html><css><web> | 2016-09-16 19:41:23 | LQ_CLOSE |
39,540,095 | UITabbarController in Xcode 8 shows a blue rectangle inside a storyboard view | <p>How can I fix this ? I can't see anything at all.</p>
<p><a href="https://i.stack.imgur.com/TPmmU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TPmmU.png" alt="enter image description here"></a></p>
| <ios><xcode><uitabbarcontroller> | 2016-09-16 21:08:36 | HQ |
39,540,123 | muti output regression in xgboost | <p>Is it possible to train a model in Xgboost that have multiple continuous outputs (multi regression)?
What would be the objective to train such a model?</p>
<p>Thanks in advance for any suggestions</p>
| <machine-learning><random-forest><xgboost> | 2016-09-16 21:10:35 | HQ |
39,540,652 | inserting x rows after a date value excel vba | i am trying to insert x rows, x =12 after a cell value, i.e date, and my code does not work, please help,
Sub HHRowInserter()
Dim HHRw As Range
For Each HHRw In Range("A1:A2251")
If HHRw.Value Like #9/30/2017# Then 'mm/dd/yyyy '30-Sep-17
HHRw.Offset(12, 0).EntireRow.Insert
End If
Next HHRw
End Sub
| <vba><excel> | 2016-09-16 21:58:17 | LQ_EDIT |
39,540,759 | ANTLR 3 GRAMMAR | A Signed Even Number Grammar. Consider the following language description of a signed even number: A signed even number optionally has a “+” or “-“ to denote its sign followed by one more number of which the last number must be even.
Task 1. Define the legal lexical tokens in the grammar for this language. You will likely want to define separate lexical rules for the numbers 0-9 as well as the even numbers.
Task 2. Develop the parser rules for this grammar. As you develop/troubleshoot your grammar, be
sure to utilize the Syntax Diagram to visualize the rules you are defining.
this what I got so far but still out an error
NUMBER : '0'..'9';
EVEN_NUMBER : '0' | '2' | '4' | '6' | '8' ;
signedevennumber : ('+' | '-')? EVEN_NUMBER? NUMBER? NUMBER? EVEN_NUMBER;
ANY HELP PLEASE | <antlr><grammar> | 2016-09-16 22:07:44 | LQ_EDIT |
39,541,141 | c++ about while (!(cin>>x)) | i just start to learn C++. And there's my very first code. My question is that why i have to input the number twice when i run it ?
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int x;
int number;
cout << "Please enter a integer ." << endl;
cin >> number;
while (!(cin>>x))
{
cout << "Invalid value !" << endl;
system("pause");
return 0;
}
cout << "Your number is " << number << " ." << endl | <c++><while-loop> | 2016-09-16 22:56:31 | LQ_EDIT |
39,541,739 | Chromedriver error "Chrome version must be >= 52" using Nightwatch | <p>I'm trying to setup <a href="http://nightwatchjs.org/guide#guide" rel="noreferrer">Nightwatch</a>, and am using the <strong>latest chromedriver</strong> which says it <a href="http://chromedriver.storage.googleapis.com/2.24/notes.txt" rel="noreferrer">supports chrome v52-54</a>. BUT, when I try to run the tests, it says <strong><code>'Error: Chrome version must be >=52.0.2743.'</code></strong> Here's everything that I'm using:</p>
<ul>
<li><a href="https://sites.google.com/a/chromium.org/chromedriver/downloads" rel="noreferrer">ChromeDriver 2.24</a></li>
<li><a href="http://selenium-release.storage.googleapis.com/index.html" rel="noreferrer">Selenium 2.53.1</a></li>
<li><a href="http://nightwatchjs.org/guide#installation" rel="noreferrer">Nightwatch v0.9.8</a></li>
<li><a href="https://nodejs.org/en/" rel="noreferrer">Node v6.5.0</a></li>
<li><a href="http://openjdk.java.net/install/" rel="noreferrer">Java v1.7.0_111</a></li>
</ul>
<p><strong>Project Structure</strong></p>
<pre><code>|-- nightwatch.json
|-- bin/
| |-- chromedriver
| |-- selenium-server-standalone-2.53.1.jar
|-- tests/
| |-- sample.js
|-- results/
|-- screens/
|-- node_modules/
| |-- (lots of modules here)
</code></pre>
<p>And here is my <a href="http://nightwatchjs.org/guide#settings-file" rel="noreferrer">configuration file</a> for nightwatch:</p>
<p><strong>./nightwatch.json</strong></p>
<pre><code>{
"src_folders" : ["tests"],
"output_folder" : "results",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",
"selenium" : {
"start_process" : true,
"server_path" : "bin/selenium-server-standalone-2.53.1.jar",
"log_path" : "results",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "bin/chromedriver"
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : true,
"path" : "screens/"
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
"chrome" : {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
</code></pre>
<p><strong>Running Tests</strong></p>
<p>I run the tests like this:</p>
<pre><code>nightwatch tests/
</code></pre>
<p><strong>Error</strong></p>
<p>And I get the following output:</p>
<pre><code>Starting selenium server... started - PID: 3500
[Sample] Test Suite
=======================
Running: Demo test Google
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ sessionId: null,
status: 13,
state: 'unhandled error',
value:
{ message: 'unknown error: Chrome version must be >= 52.0.2743.0\n (Driver info: chromedriver=2.24.417424 (c5c5ea873213ee72e3d0929b47482681555340c3),platform=Linux 3.2.0-56-generic x86_64) (WARNING: The server did not provide any stacktrace information)\nCommand duration or timeout: 1.42 seconds\nBuild info: version: \'2.53.1\', revision: \'a36b8b1\', time: \'2016-06-30 17:37:03\'\nSystem info: host: \'N/A\', ip: \'N/A\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'3.2.0-56-generic\', java.version: \'1.7.0_111\'\nDriver info: org.openqa.selenium.chrome.ChromeDriver',
suppressed: [],
localizedMessage: 'unknown error: Chrome version must be >= 52.0.2743.0\n (Driver info: chromedriver=2.24.417424 (c5c5ea873213ee72e3d0929b47482681555340c3),platform=Linux 3.2.0-56-generic x86_64) (WARNING: The server did not provide any stacktrace information)\nCommand duration or timeout: 1.42 seconds\nBuild info: version: \'2.53.1\', revision: \'a36b8b1\', time: \'2016-06-30 17:37:03\'\nSystem info: host: \'N/A\', ip: \'N/A\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'3.2.0-56-generic\', java.version: \'1.7.0_111\'\nDriver info: org.openqa.selenium.chrome.ChromeDriver',
buildInformation:
{ releaseLabel: '2.53.1',
buildTime: '2016-06-30 17:37:03',
class: 'org.openqa.selenium.internal.BuildInfo',
buildRevision: 'a36b8b1',
hCode: 1900167016 },
cause: null,
systemInformation: 'System info: host: \'N/A\', ip: \'N/A\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'3.2.0-56-generic\', java.version: \'1.7.0_111\'',
supportUrl: null,
class: 'org.openqa.selenium.WebDriverException',
additionalInformation: '\nDriver info: org.openqa.selenium.chrome.ChromeDriver',
hCode: 1299270263,
screen: null },
class: 'org.openqa.selenium.remote.Response',
hCode: 1144687147 }
</code></pre>
<p>Anyone know how to resolve this error?</p>
<p><strong><code>Chrome version must be >= 52.0.2743.0</code></strong></p>
<p>Does chromedriver use my local copy of chrome? Do I need to update my actual chrome?</p>
| <selenium><selenium-webdriver><selenium-chromedriver><nightwatch.js> | 2016-09-17 00:33:39 | HQ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.