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 |
|---|---|---|---|---|---|
37,945,800 | Update kubernetes secrets doesn't update running container env vars | <p>Currenly when updating a kubernetes secrets file, in order to apply the changes, I need to run <code>kubectl apply -f my-secrets.yaml</code>. If there was a running container, it would still be using the old secrets. In order to apply the new secrets on the running container, I currently run the command <code>kubectl replace -f my-pod.yaml</code> .
I was wondering if this is the best way to update a running container secret, or am I missing something.</p>
<p>Thanks.</p>
| <kubernetes><kubectl> | 2016-06-21 13:27:15 | HQ |
37,945,859 | mutex.lock vs unique_lock | <p>When should I prefer the first piece of code to the second, and do they have fundamental differences</p>
<pre><code>std::mutex mtx;
mtx.lock();
... //protected stuff
mtx.unlock();
... //non-protected stuff
mtx.lock();
... //etc
</code></pre>
<p>and</p>
<pre><code>std::mutex mtx;
std::unique_lock<std::mutex> lck(mtx);
... //protected stuff
lck.unlock();
... //non-protected stuff
lck.lock();
... //etc
</code></pre>
<p>I do understand that lock_guard is basically a unique_lock without the lock and unlock functions, but I'm having hard time differentiating a mutex and a lock using a mutex. </p>
| <c++><concurrency><locking><mutex> | 2016-06-21 13:29:42 | HQ |
37,946,869 | Spliting a string between "," | This is my original string,
required:true,validType:'timegt['#timeofdaymeterslotonebegintime,#timeofdaymeterslotoneendtime']
I want to split into two. the output will be like
required:true
validType:'timegt['#timeofdaymeterslotonebegintime,#timeofdaymeterslotoneendtime']
Can someone help me out with this.
| <javascript><string><split> | 2016-06-21 14:14:23 | LQ_EDIT |
37,946,972 | store multiple items in a single table column in sql database | currently i have
public void bindgrid()
{
SqlConnection conn = new SqlConnection("Data Source = 'PAULO'; Initial Catalog=ShoppingCartDB;Integrated Security =True");
SqlCommand cmd = new SqlCommand("select p.[name], cd.CustomerName, cd.CustomerEmailID,cd.CustomerPhoneNo,cd.CustomerAddress,cd.TotalPrice,cd.OrderDateTime, cd.PaymentMethod FROM CustomerDetails cd Inner Join CustomerProducts cp ON cp.CustomerID = cd.Id Inner Join Products p ON cp.ProductID = p.ProductID", conn);
SqlDataAdapter da = new SqlDataAdapter("", conn);
da.SelectCommand = new SqlCommand("select p.[name], cd.CustomerName, cd.CustomerEmailID,cd.CustomerPhoneNo,cd.CustomerAddress,cd.TotalPrice,cd.OrderDateTime, cd.PaymentMethod FROM CustomerDetails cd Inner Join CustomerProducts cp ON cp.CustomerID = cd.Id Inner Join Products p ON cp.ProductID = p.ProductID", conn);
DataSet ds = new DataSet();
da.Fill(ds, "data");
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
}
and the [result][1]
what i want to happen is that since it is in the same ID (10), would it be possible if i can have multiple values inside my Name column? like lpg,oxygen,etc?
[1]: http://i.stack.imgur.com/2czOx.jpg | <asp.net><sql-server><grid> | 2016-06-21 14:19:08 | LQ_EDIT |
37,947,541 | What is the difference between Firebase push-notifications and FCM messages? | <p>Heloo, I am building an app where I am using push notifications via Firebase Console. I want to know what is a difference between simply push-notification and cloud message?
Is it that messages from cloud messaging are data messages(have key and value) and notifications are just text without key and value?Am I right?</p>
| <google-cloud-messaging><firebase-cloud-messaging><firebase-notifications> | 2016-06-21 14:42:05 | HQ |
37,948,764 | Laravel UUID generation | <p>I am trying to generate a UUID (not as primary key, just generate one) with the <a href="https://github.com/webpatser/laravel-uuid" rel="noreferrer">laravel-uuid</a> package. The docs are pretty straightforward, so according to the readme file a UUID should be generated just by calling <code>$uuid = Uuid::generate();</code>, but it returns an empty object. (I also tried <code>$uuid = Uuid::generate(1);</code>)</p>
<p>I followed the installation instructions as provided there (nothing out of the ordinary), the app doesn't throw any errors, so I guess everything is right.</p>
<p>Alternative packages for this are also welcome.</p>
| <php><laravel><uuid> | 2016-06-21 15:35:36 | HQ |
37,949,199 | How do I identify and label similar rows in a pandas data frame | I have a data set and I want to identify and label similar rows as such in python:
[1, 1000] [1]
[2, 10 ] [2]
[2, 100 ] [3]
[2, 10 ] -> [2]
[3, 1000] [4]
[2, 100 ] [3]
[2, 10 ] [2] | <python><pandas><dataframe> | 2016-06-21 15:55:52 | LQ_EDIT |
37,949,226 | how to print the value of a function-pointer from a structure | <p>The value contained in the function-pointer " *fun " from the structure below is wrong printed and i can not find the way to print it right. What's the right code for it? The code:</p>
<pre><code>struct t { //structure definition
int a;
int (*fun) (int a);};
int get_a (int a) { //function definition
a = a*2;
return a;}
int main () {
t test; //variable creation
get_a(5); //function activating
test.fun = &get_a; //assignation to the pointer function
printf ("%d\n",*(test.fun)); //THE NUMBER 4199360 IS WRITTEN INSTEAD OF '10'.
return 0;
}
</code></pre>
| <c> | 2016-06-21 15:56:45 | LQ_CLOSE |
37,949,245 | Extract multiple lines of text in xml case |
I have an xml case as given below .I want to extract text of message between <com.eds.travel.fares.ping.response></com.eds.travel.fares.ping.response>.The xml strat with com.eds.travel.fares.ping.response and end with com.eds.travel.fares.ping.response.
% handlertd -- log_message -- preprod.preprods3.1.server3.native1 msgcount=2721 Tue Jun 21 00:01:46 2016
<?xml version="1.0" encoding="UTF-8"?>^M
^M
<!--This is a Ping Response-->^M
<com.eds.travel.fares.ping.response xmlns="http://schemas.eds.com/transportation/message/ping/response" targetNamespace="http://schemas.eds.com/transportation/message/ping/response" EchoToken="00c0d1a" TimeStamp="2016-06-21T00:01:46.123" Target="Test" Version="1.07" SequenceNmbr="1466467306998" PrimaryLangID="en" RequestorCompanyCode="1y" RequestorNetworkID="as" SetLocation="zrh">^M
<Headers Trailers="n">^M
<Result xmlns="http://schemas.eds.com/transportation/message/fares/common" status="success" />^M
</Headers>^M
<DataArea>^M
<Pong Message="pong" ServerHostName="usclsefam922.clt.travel.eds.com" ServerPortNumber="8023" ServerMessageCount="0" RegionName="preprod" SystemName="preprods3.1" SystemDate="20160621" SystemTime="146" CodeVersion="$Name: build-2016-06-17-1338 $" />^M
</DataArea>^M
<Trailers />^M
</com.eds.travel.fares.ping.response>
% handlertd -- log_message -- preprod.preprods3.1.server3.native1 msgcount=2721 Tue Jun 21 00:01:46 2016
I tried with below command but no luck
cat file.txt | egrep "<com.eds.travel.fares.ping.response>.*</com.eds.travel.fares.ping.response>"
please advise
| <perl><unix> | 2016-06-21 15:57:31 | LQ_EDIT |
37,949,619 | Incorrect frame when dismissing modally presented view controller | <p>I am presenting a <code>UIViewController</code> using a custom transition and a custom <code>UIPresentationController</code>. The view controller's view does not cover the entire screen, so the presenting view controller is still visible.</p>
<p>Next, I present an instance of <code>UIImagePickerController</code> on top of this view controller. The problem is that when I dismiss the image picker, the presenting view controller's frame covers the entire screen instead of just the portion I want it to cover. The frame specified by <code>frameOfPresentedViewInContainerView</code> in my custom <code>UIPresentationController</code> seems to be completely ignored.</p>
<p>Only if present the image picker with a <code>modalPresentationStyle</code> of <code>UIModalPresentationOverCurrentContext</code> my frames remain intact (which makes sense since no views are removed from the view hierarchy in the first place). Unfortunately that's not what I want. I want the image picker to be presented full screen, which - for whatever reason - seems to mess up my layout. Anything that I might be doing wrong or forgetting here? Any suggestions?</p>
| <ios><objective-c><uiviewcontroller><presentviewcontroller><uipresentationcontroller> | 2016-06-21 16:17:50 | HQ |
37,949,833 | Dependencies not installed in Visual Studio | <p>I'm currently upgrading my ASP.Net RC1 to ASP.Net Core RC2. The Solution Explorer in Visual Studio is giving me a warning of "Dependencies - not installed" with subfolder "npm - not installed". </p>
<p>However, the dependencies do seem to be installed - I ran 'npm install' in the project directory and it ran fine without any errors, just some warnings. It added the dependency folders into a parent folder called node-modules which I can see clearly in Windows Explorer. The node-modules folder contains folders for angular2, bootstrap, copy-webpack-plugin, etc. </p>
<p>Does anyone know why Visual Studio is telling me they aren't installed? I've also tried running npm install from Package Manager Console and doing a 'right-click -> restore packages' on those folders giving me the warning in the Solution Explorer. </p>
<p><a href="https://i.stack.imgur.com/RZzYL.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RZzYL.png" alt="enter image description here"></a></p>
<p>Here's my package.json file:</p>
<pre><code>{
"name": "EmptyWebApp",
"version": "0.0.0",
"dependencies": {
"angular2": "2.0.0-beta.13",
"bootstrap": "^3.3.5",
"es6-promise": "^3.0.2",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.2",
"jquery": "^2.1.4",
"less": "^2.5.3",
"lodash": "^3.10.1",
"rxjs": "5.0.0-beta.2",
"systemjs": "0.19.22",
"ts-loader": "^0.7.2",
"zone.js": "0.6.6"
},
"devDependencies": {
"del": "^2.0.2",
"event-stream": "^3.3.1",
"copy-webpack-plugin": "^0.3.3",
"css-loader": "^0.23.0",
"exports-loader": "0.6.2",
"expose-loader": "^0.7.1",
"file-loader": "^0.8.4",
"gulp": "^3.9.0",
"html-webpack-plugin": "^1.7.0",
"http-server": "^0.8.5",
"imports-loader": "^0.6.4",
"istanbul-instrumenter-loader": "^0.1.3",
"json-loader": "^0.5.3",
"nodemon": "^1.8.1",
"phantomjs": "^1.9.18",
"phantomjs-polyfill": "0.0.1",
"protractor": "^3.0.0",
"raw-loader": "0.5.1",
"reflect-metadata": "0.1.2",
"remap-istanbul": "^0.5.1",
"rimraf": "^2.4.4",
"style-loader": "^0.13.0",
"ts-helper": "0.0.1",
"ts-loader": "^0.7.2",
"tsconfig-lint": "^0.4.3",
"tslint": "^3.2.0",
"tslint-loader": "^2.1.0",
"typedoc": "^0.3.12",
"typescript": "1.8.9",
"typings": "^0.6.1",
"url-loader": "^0.5.6",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.12.1",
"webpack-md5-hash": "0.0.4"
},
"scripts": {
"tsc": "tsc -p . -w",
"start": "nodemon --ignore htm,html --ext cs,js --exec \"dnx web\" -V",
"static": "nodemon --watch ./client --ext html,css --exec \"gulp deploy-client\" -V",
"pre-build": "gulp deploy-client",
"webpack": "webpack",
"webpack-watch": "webpack --watch",
"clean": "gulp cleanwww",
"build": "npm run pre-build && npm run webpack",
"dnx": "dnx web"
}
}
</code></pre>
| <asp.net><node.js><visual-studio><visual-studio-2015><npm> | 2016-06-21 16:27:41 | HQ |
37,950,413 | Angular2 Router error: cannot find primary outlet to load 'HomePage' | <p>I just started using the new routing library (@angular/router v3.0.0-alpha.7) but following the official <a href="https://angular.io/docs/ts/latest/guide/router.html">docs</a> leads to error below:</p>
<pre><code>browser_adapter.ts:74: EXCEPTION: Error: Uncaught (in promise): Error: Cannot find primary outlet to load 'HomePage'
</code></pre>
<p><strong>Question is - how do I get rid of the error and make the router behave as expected? Have I missed a setting?</strong></p>
<p>(Same error appears when using the alpha.6 version.)</p>
<p><em>app.component.ts</em></p>
<pre><code>import { Component } from '@angular/core';
import { ROUTER_DIRECTIVES } from '@angular/router';
@Component({
selector: 'app',
template: `
<p>Angular 2 is running...</p>
<!-- Routed views go here -->
<router-outlet></router-outlet>
`,
providers: [ROUTER_DIRECTIVES]
})
export class AppComponent {
}
</code></pre>
<p><em>app.routes.ts</em></p>
<pre><code>import { provideRouter, RouterConfig } from '@angular/router';
import { HomePage } from './pages/home/home';
export const routes: RouterConfig = [
{ path: '', component: HomePage }
];
export const APP_ROUTER_PROVIDERS = [
provideRouter(routes)
];
</code></pre>
<p><em>home.ts</em></p>
<pre><code>import { Component } from '@angular/core';
@Component({
template: '<h1>Home Page</h1>'
})
export class HomePage {
}
</code></pre>
<p><em>main.ts</em></p>
<pre><code>/* Avoid: 'error TS2304: Cannot find name <type>' during compilation */
///<reference path="../../typings/index.d.ts" />
import { bootstrap } from "@angular/platform-browser-dynamic";
import { APP_ROUTER_PROVIDERS } from './app.routes';
import { AppComponent } from "./app.component";
bootstrap(AppComponent, [
APP_ROUTER_PROVIDERS,
]).catch(err => console.error(err));
</code></pre>
| <angular><router> | 2016-06-21 16:59:38 | HQ |
37,950,525 | Using deep learning models from TensorFlow in other language environments | <p>I have a decent amount of experience with TensorFlow, and I am about to embark on a project which will ultimately culminate in using a TensorFlow trained model in a C# production environment. Essentially, I will have live data which will come into the C# environment, and I will ultimately need to output decisions / take certain actions based on the output of my model in TensorFlow. This is basically just a constraint of the existing infrastructure.</p>
<p>I can think of a couple of potentially bad ways to implement this, such as writing the data to disk and then calling the Python part of the application and then finally reading the result output by the Python application and taking some action based on it. This is slow, however.</p>
<p>Are there faster ways to accomplish this same integrated relationship between C# and the Python-based Tensorflow. I see that <a href="https://tensorflow.github.io/serving/serving_basic">there appear to be some ways</a> to do this with C++ and TensorFlow, but what about C#? </p>
| <c#><python><tensorflow><tensorflow-serving> | 2016-06-21 17:06:06 | HQ |
37,951,698 | Simple fap page with php and jquery | I am trying to create a faq page where questions and answers are saved in arrays. When the page is loaded the user only sees the questions and whenever he clicks on a question, the answer to that question will be shown. I found some jquery scripts online and combined it with arrays but the result is not what I expected. here is the code for the array part which is in a folder called "includes":
<?php
$faqArrays= array(
array(
"question" => "this is question 1",
"answer" => "this is the answer for the first question"
),
array(
"question" => "this is question 2",
"answer" => "this is the answer for the 2 question"
),
,array(
"question"=>"this is question 7",
"answer"=>"this is the answer for the 7 question"
)
);
?>
and here is the html+jqury code
<?php
include('includes/arrays.php');
?>
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$(document).ready(function() {
$('.faq_question').click(function() {
if ($(this).parent().is('.open')){
$(this).closest('.faq').find('.faq_answer_container').animate({'height':'0'},500);
$(this).closest('.faq').removeClass('open');
}else{
var newHeight =$(this).closest('.faq').find('.faq_answer').height() +'px';
$(this).closest('.faq').find('.faq_answer_container').animate({'height':newHeight},500);
$(this).closest('.faq').addClass('open');
}
});
});
</script>
<style>
/*FAQS*/
.faq_question {
margin: 0px;
padding: 0px 0px 5px 0px;
display: inline-block;
cursor: pointer;
font-weight: bold;
}
.faq_answer_container {
height: 0px;
overflow: hidden;
padding: 0px;
}
</style>
<div class="faq_container">
<div class="faq">
<div class="faq_question"> <?php
foreach($faqArrays as $faqArray){
echo "<h1>$faqArray[question]</h1>";
}
;?>
</div>
<div class="faq_answer_container">
<div class="faq_answer"><?php $faqArray[answer];?></div>
</div>
</div>
</div>
Thanks, | <php><jquery> | 2016-06-21 18:14:39 | LQ_EDIT |
37,952,019 | Assignment in lambda | <p>I'm looking at the following (presumably C++14) piece of code</p>
<pre><code>auto min_on = [](auto&& f) {
return [f=decltype(f)(f)](auto&& arg0, auto&&...args) {
// call your function here, using decltype(args)(args) to perfect forward
};
}
</code></pre>
<p>what is the weird assignment in the lambda capture list? I've never seen an assignment in a capture list</p>
<pre><code>f=decltype(f)(f)
</code></pre>
<p>How does this work?</p>
| <c++><lambda> | 2016-06-21 18:31:26 | HQ |
37,952,020 | Is it possible to wrap a flow type in an immutable container? | <p>For example, given the following record:</p>
<pre class="lang-js prettyprint-override"><code>type UserRecord = {
id: string;
name: ?string;
age: number;
}
</code></pre>
<p>Is there some way to do the equivalent of the following:</p>
<pre class="lang-js prettyprint-override"><code>/* @flow */
import { List, Map } from 'immutable'
const users: List<Map<UserRecord>> = List();
let user: Map<UserRecord>;
user = Map({ id: '666', age: 30 });
users.push(user);
</code></pre>
<p>Otherwise I end up simply using something like <code>Map<string, any></code> which I think takes away from using Immutable.js with the Flow type system.</p>
| <javascript><immutable.js><flowtype> | 2016-06-21 18:31:32 | HQ |
37,952,332 | JQuery 3 and SignalR 2.2.0 | <p>I use SignalR 2.2.0 in a MVC5 project. SignalR depends of JQuery in client-side.</p>
<p>JQuery recently released new version, I updated it from Nuget, specifically from version 2.2.4 to 3.0.0.1, but then SignalR stopped working. Startup command "$.connection.hub" in javascript fails.
After a long time head scratching, I downgrade JQuery to 2.2.4 and everything is fine again.</p>
<p>Am I the only one getting this problem? There is any workaround?</p>
<p>Thanks.</p>
| <jquery><asp.net-mvc><signalr> | 2016-06-21 18:48:38 | HQ |
37,952,845 | How do I use roxygen to document a R package that includes a function with the same name? | <p>I'm learning to use roxygen. I see that the <a href="https://cran.r-project.org/web/packages/roxygen2/vignettes/rd.html#documenting-packages" rel="noreferrer">rd vignette</a> advocates using "_PACKAGE" to indicate that I'm creating package documentation, and says "This also works if there’s already a function called pkgname()."</p>
<p>I've also seen the <a href="http://r-pkgs.had.co.nz/man.html#man-packages" rel="noreferrer">R packages book</a> approach of using</p>
<pre><code>NULL
</code></pre>
<p>with @docType and @name specified, but when I attempt to make a toy example with either approach, it doesn't work as I expect.</p>
<p>As a toy example, I'd like to make a "hello" package that includes a "hello()" function. </p>
<p>I expect to get documentation about my hello <strong>package</strong> with</p>
<pre><code>?hello
</code></pre>
<p>or perhaps something like</p>
<pre><code>package?hello
</code></pre>
<p>and I expect to get documentation about the included hello <strong>function</strong> with</p>
<pre><code>?hello()
</code></pre>
<p>Where am I going wrong? - implementation with roxygen, the way I'm attempting to query the documentation, incorrect expectations, or something else? </p>
<p>I've already looked at questions about <a href="https://stackoverflow.com/questions/34439970/inline-package-overview-documentation-using-roxygen">package documentation</a> and <a href="https://stackoverflow.com/questions/13339021/devtools-roxygen-package-creation-and-rd-documentation/13348872#13348872">function documentation</a>, but things remain unclear to me.</p>
<p>Here's some details about my toy example:</p>
<p>hello/DESCRIPTION file:</p>
<pre><code>Package: hello
Type: Package
Title: A mostly empty package
Version: 0.1
Date: 2016-06-21
Authors@R: person("Some", "Person", email = "fake@madeup.org", role = c("aut", "cre"))
Description: More about what it does (maybe more than one line)
License: MIT
LazyData: TRUE
RoxygenNote: 5.0.1.9000
</code></pre>
<p>hello/R/hello.R</p>
<pre><code>#' hello
#'
#' This is a mostly empty package to learn roxygen documentation.
#'
#' Hello allows me to learn how to write documentation in comment blocks
#' co-located with code.
#' @docType package
#' @name hello
"_PACKAGE"
#' hello
#'
#' This function returns "Hello, world!".
#' @export
#' @examples
#' hello()
hello <- function() {
print("Hello, world!")
}
</code></pre>
<p>With this, after I run <code>document()</code>, hello/man/hello.Rd is generated. It contains a combination of the descriptions I've written for the hello package and the hello() function. <code>?hello</code> and <code>?hello()</code> both return that .Rd file.</p>
<p>Here's what the .Rd looks like:</p>
<pre><code>% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hello.R
\docType{package}
\name{hello}
\alias{hello}
\alias{hello-package}
\title{hello}
\usage{
hello()
}
\description{
This is a mostly empty package to learn roxygen documentation.
This function returns "Hello, world!".
}
\details{
Hello allows me to learn how to write documentation in comment blocks
co-located with code.
}
\examples{
hello()
}
</code></pre>
| <r><roxygen2><roxygen> | 2016-06-21 19:18:00 | HQ |
37,953,019 | WRONGTYPE Operation against a key holding the wrong kind of value php | <p>Hi I am using Laravel with Redis .When I am trying to access a key by get method then get following error "WRONGTYPE Operation against a key holding the wrong kind of value"</p>
<p>I am using following code to access the key value -</p>
<p>i use this code for get data from redis </p>
<pre><code>$values = "l_messages";
$value = $redis->HGETALL($values);
print($value);
</code></pre>
| <php><redis> | 2016-06-21 19:28:14 | HQ |
37,953,128 | how do i fix this horriable working c# access code | I have multiple people connecting to my access database and if two people happen to be searching at the same time i get an error so i did this to fix it and it cut down on the error alot but i still get it some times is there a better way ?
public partial class Form2 : Form
{
private OleDbConnection connection = new OleDbConnection();
public Form2()
{
InitializeComponent();
connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=S:\Documents\2015\Db12.accdb";
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=S:\Documents\2015\Db12.accdb";
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_NCHITTEST)
m.Result = (IntPtr)(HT_CAPTION);
}
private const int WM_NCHITTEST = 0x84;
private const int HT_CLIENT = 0x1;
private const int HT_CAPTION = 0x2;
private void lRead(string query, ListBox lbox)
{
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = query;
OleDbDataReader reader = command.ExecuteReader();
try
{
while (reader.Read())
{
lbox.Items.Add(reader["UAS"].ToString());
}
}
catch (Exception ex)
{ MessageBox.Show("error LREAD" + ex); }
finally
{
if (reader != null)
{ reader.Dispose(); }
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
try
{
connection.Open();
listBox1.Items.Clear();
lRead($"select * from Table1 where UAS Like '%{textBox1.Text}%'", listBox1);
lRead($"select * from Table1 where Customer Like '%{textBox1.Text}%'", listBox1);
lRead($"select * from Table1 where Description Like '%{textBox1.Text}%'", listBox1);
lRead($"select * from Table1 where Detail Like '%{textBox1.Text}%'", listBox1);
//select * from SomeTable Where SomeColumn Like '* PARMA *' dont use * use %
connection.Close();
}
catch
{
System.Threading.Thread.Sleep(500);
try
{
connection.Open();
listBox1.Items.Clear();
lRead($"select * from Table1 where UAS Like '%{textBox1.Text}%'", listBox1);
lRead($"select * from Table1 where Customer Like '%{textBox1.Text}%'", listBox1);
lRead($"select * from Table1 where Description Like '%{textBox1.Text}%'", listBox1);
lRead($"select * from Table1 where Detail Like '%{textBox1.Text}%'", listBox1);
//select * from SomeTable Where SomeColumn Like '* PARMA *' dont use * use %
connection.Close();
}
catch
{
System.Threading.Thread.Sleep(500);
try
{
connection.Open();
listBox1.Items.Clear();
lRead($"select * from Table1 where UAS Like '%{textBox1.Text}%'", listBox1);
lRead($"select * from Table1 where Customer Like '%{textBox1.Text}%'", listBox1);
lRead($"select * from Table1 where Description Like '%{textBox1.Text}%'", listBox1);
lRead($"select * from Table1 where Detail Like '%{textBox1.Text}%'", listBox1);
//select * from SomeTable Where SomeColumn Like '* PARMA *' dont use * use %
connection.Close();
}
catch
{
MessageBox.Show("Error too many People Searching ");
}
}
}
| <c#><ms-access> | 2016-06-21 19:35:43 | LQ_EDIT |
37,953,196 | can i make android app using only html and css | <p>Please tell whether I can make an app using HTML and CSS only and <strong>NO</strong> javascript .
I am not aware of any programming languages but I have an idea of making an android application.
So I want to make it however and please also suggest for if I could make for ios application.
if yes then what are the features I could use in that app.
like my app notifies you like alarm-clock so is that possible??</p>
| <android><html><css> | 2016-06-21 19:39:33 | LQ_CLOSE |
37,953,216 | li padding not acting as it should | Can someone please explain why my padding is not acting as it should? My padding should be a perfect box, but for some reason it's coming out as some oblong rectangle. A padding of 30 all the way around the sides should be a perfect square. I have more rules for my other li and ul but that's for only in my '#nav' ID, so I don't see why there would be any conflict.
<!-- begin snippet: js hide: false console: true -->
<!-- language: lang-css -->
html {
height: 100%;
}
body{
height: 100%;
margin:0;
font-family: courier;
font-size: 22px;
color: white;
}
#wrapper{
position: relative;
margin-left: auto;
margin-right: auto;
width: 85%;
min-height: 100%;
margin-top: -130px;
}
#inner{
margin-top: 130px;
width: auto;
}
/*
#wrapper{
margin-left: auto;
margin-right: auto;
border: 1px solid blue;
width: 85%;
background-color: blue;
height: calc(100vh - 130px);
}
*/
#footer, #wrapper:after{
height: 130px;
}
.wrap {
margin: 0 auto;
width: 100%;
display: flex;
align-items: center;
flex-wrap: nowrap;
}
.sub {
padding: 12px;
width: 32%;
height: 100px;
color: white;
border-right: solid white 1px;
}
.sub:last-child{
border: 0px;
}
#nav {
list-style: none;
font-weight: bold;
width: 100%;
text-align: center;
background-color: #862d59;
height: 100px;
box-shadow: 0px 5px 8px grey;
}
#nav ul {
list-style-type: none;
margin: 0px;
padding: 0;
overflow: auto;
// background-color: #862d59;
}
#nav li {
margin: 0px;
display: inline-block;
}
#nav li a {
padding: 10px;
display: inline-block;
text-decoration: none;
font-weight: bold;
font-size: 30px;
color: white;
// background-color: #862d59;
}
#nav li a:hover {
color: white;
text-shadow: 2px 2px 4px white;
}
#footer {
display: flex;
height: 130px;
width: 100%;
background-color: #862d59;
clear: both;
}
li.middle{
background-color: #26004d;
padding: 10px 10px 10px 10px;
margin-right: 30px;
margin-top: 200px;
text-align: center;
color: white;
}
<!-- language: lang-html -->
<div id="wrapper">
<div id="inner">
<ul>
<li class="middle">some stuff</li>
</ul>
</div>
</div>
<div id="footer">
<div class="wrap">
<div class="sub"></div>
<div class="sub"></div>
<div class="sub"></div>
</div>
</div>
<!-- end snippet -->
| <html><css><console><padding> | 2016-06-21 19:40:45 | LQ_EDIT |
37,953,317 | Singleton with properties in Swift 3 | <p>In Apple's <a href="https://developer.apple.com/library/prerelease/content/documentation/Swift/Conceptual/BuildingCocoaApps/AdoptingCocoaDesignPatterns.html#//apple_ref/doc/uid/TP40014216-CH7-ID6">Using Swift with Cocoa and Objective-C document</a> (updated for Swift 3) they give the following example of the Singleton pattern:</p>
<pre><code>class Singleton {
static let sharedInstance: Singleton = {
let instance = Singleton()
// setup code
return instance
}()
}
</code></pre>
<p>Let's imagine that this singleton needs to manage a variable array of Strings. How/where would I declare that property and ensure it gets initialized properly to an empty <code>[String]</code> array?</p>
| <singleton><swift3> | 2016-06-21 19:47:02 | HQ |
37,953,319 | File Staged Content Different from HEAD | <p>When I attempt to use <code>git rm --cached</code> I receive the following error:</p>
<pre><code>error: the following file has staged content different from both the file and the HEAD:
</code></pre>
<p>I know that I can circumvent this error with <code>git rm --cached -f <filename></code>. But normally when I unstage files with <code>git rm --cached</code> I do not get this error. </p>
<p>My question is what does it mean that the file has different staged content from the <code>HEAD</code>.</p>
| <git> | 2016-06-21 19:47:12 | HQ |
37,953,448 | How do you switch between languages on local setups? | <p>On my local windows 8 setup I have Ruby on Rails env already set up. I'd like to install Java as well without removing RoR and be able to use either from the terminal depending on what project I'm working on. How do switch from one language environment to another and back again when I'm done working on any specific thing?</p>
| <java><ruby><installation><local> | 2016-06-21 19:54:12 | LQ_CLOSE |
37,953,476 | Android: How to get a content:// URI for a file in the external storage PUBLIC directory | <p>I've followed <a href="https://developer.android.com/training/camera/photobasics.html">this Google tutorial</a> to start an intent to capture an image with <code>new Intent(MediaStore.ACTION_IMAGE_CAPTURE)</code>. The tutorial recommends using the public directory with <code>getExternalStoragePublicDirectory</code> which would work great for my app. But then their example instead uses <code>getExternalFilesDir</code>. Then to pass the URI of the file to the intent with <code>MediaStore.EXTRA_OUTPUT</code> I <a href="https://commonsware.com/blog/2016/03/14/psa-file-scheme-ban-n-developer-preview.html">have to get a content URI</a> because I'd like to target Android N. Before targeting N I would just pass a file:// URI and everyone but Google was happy. Now on N I started getting the <code>FileUriExposedException</code> that seems to be <a href="https://code.google.com/p/android/issues/detail?id=203555#c10">not very favorable</a>.</p>
<p>So given that I have a File like this...</p>
<pre><code>private File createImageFile() throws IOException {
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
File storageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "MyAppFolder");
if (!storageDir.exists() && !storageDir.mkdir())
Log.w(TAG, "Couldn't create photo folder: " + storageDir.getAbsolutePath());
File image = new File(storageDir, timeStamp + ".jpg");
mCurrentPhotoPath = image.getAbsolutePath();
return image;
}
</code></pre>
<p>...can I use a built-in provider for the public pictures directory to get a content URI? If so how? </p>
<p>I've tried something like</p>
<pre><code>takePictureIntent.putExtra(
MediaStore.EXTRA_OUTPUT,
FileProvider.getUriForFile(this, MediaStore.AUTHORITY, createImageFile()));
</code></pre>
<p>but it just throws </p>
<blockquote>
<p>IllegalArgumentException: Missing android.support.FILE_PROVIDER_PATHS meta-data</p>
</blockquote>
<p>Is that Authority correct? If I must use my own provider to share the public file then what path can I specify in my FILE_PROVIDER_PATHS meta-data? All of the <a href="https://developer.android.com/reference/android/support/v4/content/FileProvider.html#SpecifyFiles">options I can find</a> are for private directories.</p>
| <android><android-intent><android-contentprovider><android-7.0-nougat> | 2016-06-21 19:56:14 | HQ |
37,953,826 | UIActivityViewController unable to set subject when sharing to Gmail app | <p>I see via sharing content from other apps that it is possible to set a different subject and body when using share sheet to share into the Gmail Mail app. I have implemented it and it works fine on the native mail app but not Gmail.</p>
<p>Going into Yelp and sharing a business then choosing gmail from the share sheet, I see that the subject and body are different. The subject contains the address of the business while the body contains the address + a link to the business on Yelp.</p>
<p>I have tried to replicate this logic with success on the native Mail app but not in the Gmail app.</p>
<p>I have tried the following:</p>
<p><strong>Implementing UIActivityItemSource methods</strong> </p>
<pre><code>UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[self] applicationActivities:nil];
- (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController {
return @"";
}
- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType {
return @"body";
}
- (NSString *)activityViewController:(UIActivityViewController *)activityViewController subjectForActivityType:(NSString *)activityType {
return @"subject";
}
</code></pre>
<p><strong>Result</strong></p>
<p>Apple Mail Subject set to "subject", Body set to "body"</p>
<p>Gmail Subject set to "body", Body set to "body"</p>
<pre><code>- (NSString *)activityViewController:(UIActivityViewController *)activityViewController subjectForActivityType:(NSString *)activityType
</code></pre>
<p>Is never called when sharing into the Gmail app.</p>
<p><strong>I then try the more hack way of doing it</strong></p>
<pre><code>UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[@"body"] applicationActivities:nil];
[activityViewController setValue:@"subject" forKey:@"subject"];
</code></pre>
<p><strong>Result</strong> </p>
<p>Apple Mail Subject set to "subject", Body set to "body"</p>
<p>Gmail Subject set to "body", Body set to "body"</p>
<p><strong>Any way to make Gmail Behave like Apple Mail?</strong></p>
<p>Again, I have seen that other applications like Yelp and Safari have gotten the proper behavior out of the Gmail app through share sheet. Any advice would be appreciated, thanks.</p>
| <ios><ios9><uiactivityviewcontroller> | 2016-06-21 20:18:14 | HQ |
37,954,008 | Proper way to install pip on Ubuntu | <p>I'm trying to install the latest version of pip (currently 8.1.2) on the official ubuntu/trusty64 Vagrant box. The box comes with Python 2.7.6 and 3.4.3 pre-installed with apt-get.</p>
<p>I read the <a href="https://pip.pypa.io/en/stable/installing/" rel="noreferrer">pip installation doc</a> and it contains the following warning:</p>
<blockquote>
<p>Be cautious if you're using a Python install that's managed by your
operating system or another package manager. get-pip.py does not
coordinate with those tools, and may leave your system in an
inconsistent state.</p>
</blockquote>
<p>Does that mean I cannot install pip using get-pip.py and I am limited to install an older version of it from apt-get?</p>
<p>If there is a better way of installing it, what would it be?</p>
<p>Thanks</p>
| <python><pip> | 2016-06-21 20:29:43 | HQ |
37,954,022 | Resize Bootstrap Modals window | <p>Looking for help with this bootstrap modal. </p>
<p>When you click on a package (the colored blocks), the modal opens full screen. I cant figure out how to make it open more in a window. </p>
<p>Not sure if this is a bootstrap or j query thing. </p>
<p>site: <a href="http://pegasusbus.com/ebrochure" rel="nofollow">http://pegasusbus.com/ebrochure</a></p>
| <html><css><twitter-bootstrap><modal-dialog><bootstrap-modal> | 2016-06-21 20:30:37 | LQ_CLOSE |
37,954,138 | Add portions of string that contains X to list | <p>I'm trying to learn Python and I have one question.</p>
<p>I want to take all html links from a webpage source file and append them to a list. For example I want to search the string for every instance of ../lyrics.*html and insert those instances in a list. The result would be a list of html links such as this:</p>
<pre><code>["../lyrics/steviewonder/lovesinneedoflovetoday.html", "../lyrics/steviewonder/haveatalkwithgod.html", "../lyrics/steviewonder/villageghettoland.html"]
</code></pre>
<p>Help is much appreciated! Thank you!</p>
| <python><string><search><append> | 2016-06-21 20:37:18 | LQ_CLOSE |
37,954,175 | How to access estimate values in lm? | <p>I have linear model I would like to run weekly with updated data, and then extract and print the Estimate coefficients along with the titles. For example:</p>
<pre><code>data <- mtcars
fit <- lm(mpg ~ cyl + disp + hp, data = data)
summary(fit)
Call:
lm(formula = mpg ~ cyl + disp + hp, data = data)
Residuals:
Min 1Q Median 3Q Max
-4.0888899 -2.0845357 -0.7744705 1.3971991 6.9183052
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 34.18491917 2.59077758 13.19485 0.00000000000015372 ***
cyl -1.22741994 0.79727631 -1.53952 0.134904
disp -0.01883809 0.01040369 -1.81071 0.080929 .
hp -0.01467933 0.01465087 -1.00194 0.324952
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 3.055261 on 28 degrees of freedom
Multiple R-squared: 0.7678877, Adjusted R-squared: 0.7430186
F-statistic: 30.8771 on 3 and 28 DF, p-value: 0.000000005053802
</code></pre>
<p>My ultimate goal would be to output something like below to a csv (or similar) file.</p>
<pre><code>(Intercept) 34.18491917
cyl -1.22741994
disp -0.01883809
hp -0.01467933
</code></pre>
<p>Is there any easy way to access the data in the fit, or would it have to be done manually?</p>
| <r><export-to-csv><lm> | 2016-06-21 20:39:39 | LQ_CLOSE |
37,954,284 | Sql result set value as Column header in SQL | I need to use result values in column header. Please see below script and the result of the script i need to use it as column headers.
select
convert(varchar,DATEADD(month, -12, dateadd(d,-day(convert(date,dateadd(d,-(day(getdate())),getdate()))),convert(date,dateadd(d,+1-(day(getdate())),getdate())))),107),
convert(varchar,convert(date,dateadd(d,-day(convert(date,dateadd(d,-(day(getdate())),getdate()))),convert(date,dateadd(d,+1-(day(getdate())),getdate())))),107)
I need the answer for my question as soon as possible. | <sql><alias> | 2016-06-21 20:46:04 | LQ_EDIT |
37,954,376 | Ignore [JsonIgnore] Attribute on Serialization / Deserialization | <p>Is there a way I can ignore Json.NET's <code>[JsonIgnore]</code> attribute on a class that I don't have permission to modify/extend?</p>
<pre><code>public sealed class CannotModify
{
public int Keep { get; set; }
// I want to ignore this attribute (and acknowledge the property)
[JsonIgnore]
public int Ignore { get; set; }
}
</code></pre>
<p>I need all properties in this class to be serialized/deserialized. I've tried subclassing Json.NET's <code>DefaultContractResolver</code> class and overriding what looks to be the relevant method:</p>
<pre><code>public class JsonIgnoreAttributeIgnorerContractResolver : DefaultContractResolver
{
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
{
JsonProperty property = base.CreateProperty(member, memberSerialization);
// Serialize all the properties
property.ShouldSerialize = _ => true;
return property;
}
}
</code></pre>
<p>but the attribute on the original class seems to always win:</p>
<pre><code>public static void Serialize()
{
string serialized = JsonConvert.SerializeObject(
new CannotModify { Keep = 1, Ignore = 2 },
new JsonSerializerSettings { ContractResolver = new JsonIgnoreAttributeIgnorerContractResolver() });
// Actual: {"Keep":1}
// Desired: {"Keep":1,"Ignore":2}
}
</code></pre>
<p>I dug deeper, and found an interface called <code>IAttributeProvider</code> that can be set (it had a value of "Ignore" for the <code>Ignore</code> property, so that was a clue this might be something that needs changing):</p>
<pre><code>...
property.ShouldSerialize = _ => true;
property.AttributeProvider = new IgnoreAllAttributesProvider();
...
public class IgnoreAllAttributesProvider : IAttributeProvider
{
public IList<Attribute> GetAttributes(bool inherit)
{
throw new NotImplementedException();
}
public IList<Attribute> GetAttributes(Type attributeType, bool inherit)
{
throw new NotImplementedException();
}
}
</code></pre>
<p>But the code isn't ever hit.</p>
| <c#><json.net> | 2016-06-21 20:52:51 | HQ |
37,954,379 | How can I measure pixels in Chrome without an extension? | <p>Due to security limitations at work, I am not allowed to install Chrome extensions. Chrome has a ruler built in to the developer tools, but I can't figure out how to define start and end points like a ruler would permit.</p>
<p>Are there any tools or techniques for measuring pixels that don't require installing a Chrome extension?</p>
| <google-chrome><google-chrome-devtools><pixel><measurement> | 2016-06-21 20:53:05 | HQ |
37,954,456 | need help on java swing frame | i'm VERY new to swing, i need to build a frame that:
-has an image on top.
-below the image has 16 little images divided in 4 groups (4 "panels"), on the same "row".
-below those 16 images i need 4 "panels"on the same "row". Every panel contains some horizontal scrollable images (of the same size).
-below those 4 "panels" i need two "panels" on the same "row". The left one contains some hoizontal scrollable images (of the same size), the right one a "JList" (or something like that:scrollable text rows).
-below those 2 "panel" i need 4 "panels" on the same "row". Everyone contains 4 rows of text.
How can I realize a frame like this? I tried using only BorderedLayouts and GridLayouts, but i don't know how to divide the "GridLayouts" in others "GridLayouts" (don't even know if it is possible). | <java><swing><panel><grid-layout><border-layout> | 2016-06-21 20:58:39 | LQ_EDIT |
37,955,797 | Java's instanceof scope | So, If I have four classes, Class A, Class B, Class C and Class D. Class B & C extend Class A and Class D extends Class C. Using java's instanceof operator will "Class B instanceof Class C" return true due to the fact that they have the same parent? | <java><class><instanceof> | 2016-06-21 22:44:48 | LQ_EDIT |
37,955,880 | Composer Fatal error: Declaration of Fxp... must be compatible with ...AbstractAssetsRepository.php on line 334 | <p>I updated composer</p>
<pre><code>composer self-update
</code></pre>
<p>I installed the newer version of the plugin</p>
<pre><code>composer global require "fxp/composer-asset-plugin:*"
</code></pre>
<p>I try to install Laravel</p>
<p><strong>composer global require "laravel/installer"</strong></p>
<pre><code>Changed current directory to C:/Users/Arthur/AppData/Roaming/Composer
Fatal error: Declaration of Fxp\Composer\AssetPlugin\Repository\AbstractAssetsRe
pository::search() must be compatible with Composer\Repository\RepositoryInterfa
ce::search($query, $mode = 0, $type = NULL) in C:\Users\Arthur\AppData\Roaming\C
omposer\vendor\fxp\composer-asset-plugin\Repository\AbstractAssetsRepository.php
on line 334
</code></pre>
<p>Now all commands in composer not working</p>
<pre><code>composer <any command>
</code></pre>
<p>Please help me to resolve it</p>
| <php><linux><laravel><command-line><composer-php> | 2016-06-21 22:54:27 | HQ |
37,956,378 | Parse SDK Android - Facebook Graph API v2.0 | <p>I'm using Parse SDK in my app (<a href="https://github.com/ParsePlatform/Parse-SDK-Android">https://github.com/ParsePlatform/Parse-SDK-Android</a>). </p>
<p>My app also uses the Facebook Utils in order to provide a login experience with Facebook (<a href="https://github.com/ParsePlatform/ParseFacebookUtils-Android">https://github.com/ParsePlatform/ParseFacebookUtils-Android</a>) </p>
<p>Recently I've received the following message from Facebook Developers regarding one of my app : "xxx has been making recent API calls to Graph API v2.0, which will reach the end of the 2-year deprecation window on Monday, August 8, 2016. Please migrate all calls to v2.1 or higher in order to avoid potential broken experiences."</p>
<p>How can I fix that problem? </p>
<p>This is my build.gradle file in the dependecies section : </p>
<pre><code>dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.parse:parse-android:1.13.1'
compile 'com.parse:parsefacebookutils-v4-android:1.10.4@aar'
compile 'com.parse.bolts:bolts-tasks:1.4.0'
compile 'com.parse.bolts:bolts-applinks:1.4.0'
compile 'com.jeremyfeinstein.slidingmenu:library:1.3@aar'
compile 'com.soundcloud.android:android-crop:1.0.0@aar'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile files('libs/universal-image-loader-1.9.3.jar')
}
</code></pre>
<p>and this is the only point in code where I use the Facebook SDK: </p>
<pre><code>ParseFacebookUtils.logInWithReadPermissionsInBackground(Login.this, permissions, new LogInCallback() {
@Override
public void done(final ParseUser user, ParseException err) {
fbdialog = new ProgressDialog(Login.this);
fbdialog.setTitle("Contacting Facebook");
fbdialog.setMessage("Please wait a moment. We are contacting Facebook to perform the registration");
fbdialog.show();
if (user == null) {
Log.d("MyApp", "Uh oh. The user cancelled the Facebook login.");
fbdialog.cancel();
} else if (user.isNew() || !user.isNew()) {
Log.d("MyApp", "User signed up and logged in through Facebook!" + AccessToken.getCurrentAccessToken());
GraphRequest request = GraphRequest.newMeRequest(
AccessToken.getCurrentAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
if(response!=null) {
try {
String nome = object.getString("name");
String email = object.getString("email");
String gender = object.getString("gender");
final String facebookid = object.getString("id");
ParseUser utente = ParseUser.getCurrentUser();
utente.put("namelastname", nome);
utente.put("email", email);
utente.put("gender", gender);
utente.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("idutente", user);
installation.saveInBackground();
//downloading the user profile image from facebook
AsyncTaskLoad as = new AsyncTaskLoad();
as.execute("https://graph.facebook.com/" + facebookid + "/picture?type=large");
fbdialog.cancel();
} else {
fbdialog.cancel();
e.printStackTrace();
}
}
});
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,link,email,age_range,gender,birthday");
request.setParameters(parameters);
request.executeAsync();
} else {
Log.d("MyApp", "User logged in through Facebook!");
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("idutente", user);
installation.saveInBackground();
fbdialog.cancel();
//here I start a new activity
}
}
});
}
});
</code></pre>
<p>this is the AsyncTask used to download the Facebook profile image: </p>
<pre><code>private class AsyncTaskLoad extends AsyncTask<String, Void, Void> {
@Override
protected void onPreExecute() {
pd = new ProgressDialog(Login.this);
pd.setTitle("Logging");
pd.show();
}
@Override
protected Void doInBackground(String... strings) {
try {
URL image_value = new URL(strings[0]);
SynchroHelper sync = new SynchroHelper(Login.this);
//simple http method to download an image and save it into a file in the external storage dir
sync.downloadImage(image_value.toString(), "myprof.jpg", Environment.getExternalStorageDirectory());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void params) {
//starting a new activity...
pd.dismiss();
}
}
</code></pre>
<p>How can I upgrade to Graph API v2.0? Should I wait an update from the Parse-SDK? </p>
| <android><facebook><facebook-graph-api><parse-platform><parsefacebookutils> | 2016-06-21 23:50:28 | HQ |
37,956,628 | Change mouse pointer in UWP app | <p>Is it possible to change or even hide the mouse-pointer in a UWP app?
The only thing I can find is this :</p>
<p>Windows.UI.Xaml.Window.Current.CoreWindow.PointerCursor = null;</p>
<p>But in UWP, this doesn't work.</p>
| <uwp><mouse-pointer> | 2016-06-22 00:17:10 | HQ |
37,957,286 | Why no exception when finally has return clause | <p>The code snap is like below: </p>
<pre><code>public static void main(String[] args) {
System.out.println(echo("jjj"));
}
public static String echo(String str) {
try {
int a = 1/0;
} catch (Exception e) {
throw e;
} finally {
return str;
}
}
</code></pre>
<p>Why can I get the output and no exception occurs?<br>
And if I put the return clause out of finally, then exception occurs.<br>
How could <code>return</code>(in <code>finally</code>) stop <code>exception</code>?</p>
| <java><try-catch-finally> | 2016-06-22 01:53:39 | LQ_CLOSE |
37,957,404 | Using TypeScript super() | <p>I am trying to extend a class in TypeScript. I keep receiving this error on compile: 'Supplied parameters do not match any signature of call target.' I have tried referencing the artist.name property in the super call as super(name) but is not working. </p>
<p>Any ideas and explanations you may have will be greatly appreciated. Thanks - Alex.</p>
<pre><code>class Artist {
constructor(
public name: string,
public age: number,
public style: string,
public location: string
){
console.log(`instantiated ${name}, whom is ${age} old, from ${location}, and heavily regarded in the ${style} community`);
}
}
class StreetArtist extends Artist {
constructor(
public medium: string,
public famous: boolean,
public arrested: boolean,
public art: Artist
){
super();
console.log(`instantiated ${this.name}. Are they famous? ${famous}. Are they locked up? ${arrested}`);
}
}
interface Human {
name: string,
age: number
}
function getArtist(artist: Human){
console.log(artist.name)
}
let Banksy = new Artist(
"Banksy",
40,
"Politcal Graffitti",
"England / Wolrd"
)
getArtist(Banksy);
</code></pre>
| <javascript><oop><typescript> | 2016-06-22 02:08:27 | HQ |
37,957,442 | Using material-ui with redux? | <p>I'm currently rendering main component this way: </p>
<pre><code> ReactDOM.render(
<Provider store = {store}>
{getRoutes(checkAuth)}
</Provider>,
document.getElementById('app')
)
</code></pre>
<p>the docs state to use MuiThemeProvider to wrap my app component. I am alrady using Provider to wrap, any suggestions as to how to use material-ui ina redux app. I am trying to add material-ui in a redux-form Field as below:</p>
<pre><code>import React, { PropTypes } from 'react'
import {default as ReactModal} from 'react-modal'
import {Field, reduxForm} from 'redux-form'
import {TextField} from 'material-ui'
const customStyles = {
overlay: {
position: 'fixed',
top: 0,
left: 0,
right: 0,
bottom: 0,
backgroundColor: 'rgba(0, 0, 0, 0.55)'
},
content: {
top: '50%',
left: '50%',
right: 'auto',
bottom: 'auto',
marginRight: '-50%',
transform: 'translate(-50%, -50%)'
}
}
const modalForm = (props) => {
// console.log(props)
const { handleSubmit, pristine, reset, submitting } = props
return (
<div>
<button onClick= {props.openModal}>Duck</button>
<ReactModal
isOpen={props.isOpen}
style={customStyles}
onRequestClose={props.closeModal}>
<h1>Compose New Duck</h1>
<form onSubmit= {handleSubmit}>
<label>duck</label>
<Field name ='duck' component = {(duck) =>
<TextField hintText = 'Enter Duck'
floatingLabelText = 'Enter Duck here'
{...duck} />} />
</form>
<button onClick= {props.closeModal}>Close Modal...</button>
</ReactModal>
</div>
)
}
export default reduxForm({
form: 'duckModal' // a unique identifier for this form
})(modalForm)
</code></pre>
| <reactjs><redux><material-ui><redux-form> | 2016-06-22 02:13:10 | HQ |
37,957,516 | Materialize css- Is it possibe to CENTER the navbar | I am using Materialize. My site has Navigation centered on top and the site Logo below that. Please see image:
[Webpage layout][1]
[1]: http://i.stack.imgur.com/VG5wg.png
I tried a lot but couldnt center it.
Kindly let me know how it is possible.. Thanks a lot. | <css><materialize> | 2016-06-22 02:25:43 | LQ_EDIT |
37,957,844 | set expandtab in .vimrc not taking effect | <p>For some reason the <code>set expandtab</code> command in my <code>.vimrc</code> file is not having any effect.</p>
<p>Here is my <code>.vimrc</code>:</p>
<pre><code>" tab settings
set expandtab
set smarttab
set softtabstop=2
set tabstop=2
set shiftwidth=2
set paste
</code></pre>
<p>However, when I run <code>vi</code> (no file name) the <code>:set</code> command emits:</p>
<pre><code>:set
--- Options ---
helplang=en shiftwidth=2 ttyfast
paste tabstop=2 ttymouse=xterm2
fileencodings=ucs-bom,utf-8,default,latin1
</code></pre>
<p>which indicates that the <code>expandtab</code> option is not set. This is further confirmed by executing <code>:set expandtab?</code> which returns with <code>noexpandtab</code>.</p>
<p>I'm on OSX 10.10, and <code>vi --help</code> returns:</p>
<pre><code>$ vi --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 20 2016 11:11:25)
MacOS X (unix) version
Included patches: 1-1847
Compiled by Homebrew
</code></pre>
<p>How come some settings in my .vimrc are being honored, but not <code>set expandtab</code>?</p>
| <vim> | 2016-06-22 03:07:17 | HQ |
37,957,853 | Append "%.2X" data in char array or string in C (preferably) or C++ | I have been trying to fix it for last 3 days, and tried many options, but didn't get to work.
I have the following code in C++.
#include <winsock2.h>
#include <iphlpapi.h>
#include<stdio.h>
#include <stdlib.h>
#include <typeinfo>
#include <string>
// Link with Iphlpapi.lib
#pragma comment(lib, "IPHLPAPI.lib")
#define _CRT_SECURE_NO_WARNINGS
#define WORKING_BUFFER_SIZE 15000
#define MAX_TRIES 3
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
/* Note: could also use malloc() and free() */
int __cdecl main(int argc, char **argv)
{
/* Declare and initialize variables */
DWORD dwSize = 0;
DWORD dwRetVal = 0;
unsigned int i = 0;
// Set the flags to pass to GetAdaptersAddresses
ULONG flags = GAA_FLAG_INCLUDE_PREFIX;
// default to unspecified address family (both)
ULONG family = AF_UNSPEC;
LPVOID lpMsgBuf = NULL;
PIP_ADAPTER_ADDRESSES pAddresses = NULL;
ULONG outBufLen = 0;
ULONG Iterations = 0;
PIP_ADAPTER_ADDRESSES pCurrAddresses = NULL;
PIP_ADAPTER_UNICAST_ADDRESS pUnicast = NULL;
PIP_ADAPTER_ANYCAST_ADDRESS pAnycast = NULL;
PIP_ADAPTER_MULTICAST_ADDRESS pMulticast = NULL;
IP_ADAPTER_DNS_SERVER_ADDRESS *pDnServer = NULL;
IP_ADAPTER_PREFIX *pPrefix = NULL;
// Allocate a 15 KB buffer to start with.
outBufLen = WORKING_BUFFER_SIZE;
std::string str;
char Buffer[255];
do {
pAddresses = (IP_ADAPTER_ADDRESSES *)MALLOC(outBufLen);
if (pAddresses == NULL) {
printf
("Memory allocation failed for IP_ADAPTER_ADDRESSES struct\n");
//exit(1);
}
dwRetVal =
GetAdaptersAddresses(family, flags, NULL, pAddresses, &outBufLen);
if (dwRetVal == ERROR_BUFFER_OVERFLOW) {
FREE(pAddresses);
pAddresses = NULL;
}
else {
break;
}
Iterations++;
} while ((dwRetVal == ERROR_BUFFER_OVERFLOW) && (Iterations < MAX_TRIES));
if (dwRetVal == NO_ERROR) {
// If successful, output some information from the data we received
pCurrAddresses = pAddresses;
while (pCurrAddresses) {
if (wcscmp(pCurrAddresses->FriendlyName, L"Ethernet") == 0) {
if (pCurrAddresses->PhysicalAddressLength != 0) {
printf("\tPhysical address: ");
for (i = 0; i < (int)pCurrAddresses- >PhysicalAddressLength;
i++) {
if (i == (pCurrAddresses->PhysicalAddressLength - 1)) {
printf("%.2X\n", (int)pCurrAddresses- >PhysicalAddress[i]);
//str.append(pCurrAddresses- >PhysicalAddress[i]);
// str += (int)pCurrAddresses- >PhysicalAddress[i];
//sprintf(Buffer + strlen(Buffer), "%.2X", (int)pCurrAddresses->PhysicalAddress[i]);
}
else {
printf("%.2X-", (int)pCurrAddresses- >PhysicalAddress[i]);
//str.append(pCurrAddresses- >PhysicalAddress[i]);
//str += (int)pCurrAddresses- >PhysicalAddress[i];
}
}
}
}
pCurrAddresses = pCurrAddresses->Next;
}
}
else {
printf("Call to GetAdaptersAddresses failed with error: %d\n",
dwRetVal);
if (dwRetVal == ERROR_NO_DATA)
printf("\tNo addresses were found for the requested parameters\n");
else {
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, dwRetVal, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
// Default language
(LPTSTR)& lpMsgBuf, 0, NULL)) {
printf("\tError: %s", lpMsgBuf);
LocalFree(lpMsgBuf);
if (pAddresses)
FREE(pAddresses);
//exit(1);
}
}
}
if (pAddresses) {
FREE(pAddresses);
}
MessageBoxA(NULL, str.c_str(), "testx", MB_OK);
system("pause");
return 0;
}
I want to print the mac address in MessageBox (winapi) using type LPCSTR at once, not in the loop, as it is happening now with `printf()`.
I then have to send the mac address in URL using `InternetOpenUrl()` which has the data type of LPCSTR or LPWCSTR, I'll do the rest, once I succeed in printing and storing mac address in `MessageBox` and LPCSTR format respectively.
| <c++><string><append> | 2016-06-22 03:08:20 | LQ_EDIT |
37,958,044 | Firebase Remote Config with Namespace | <p>The Firebase <a href="https://firebase.google.com/docs/reference/android/com/google/firebase/remoteconfig/FirebaseRemoteConfig.html#public-methods" rel="noreferrer">API for RemoteConfig</a> has several methods for assigning config values by namespace, eg (<code>setDefaults(R.xml.rc_defaults, "Namespace")</code>). I've got this to work in terms of separating config values by namespace on Android, but how to do I set those values by namespace on the Firebase Console for remote updating?</p>
<p><a href="https://i.stack.imgur.com/l0kT1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/l0kT1.png" alt="Where is the Namespace assigned?"></a></p>
| <android><firebase><namespaces><firebase-remote-config> | 2016-06-22 03:29:32 | HQ |
37,958,278 | Convert class 'pandas.indexes.numeric.Int64Index' to numpy | <p>I am isolating some row ids from a Pandas dataframe, like this: </p>
<pre><code>data = df.loc[df.cell == id]
rows = df.index
print(type(rows))
< class 'pandas.indexes.numeric.Int64Index'>
</code></pre>
<p>I want to convert rows to a numpy array so I can save it to a mat file using sio.savemat. This is returning an error though:</p>
<pre><code>row_mat = rows.as_matrix()
AttributeError: 'Int64Index' object has no attribute 'as_matrix'
</code></pre>
<p>What is the correct way, please? Thanks</p>
| <python><numpy><pandas><dataframe> | 2016-06-22 03:55:41 | HQ |
37,958,706 | In Tensorflow, what is the difference between a tensor that has a type ending in _ref and a tensor that does not? | <p>The docs say:</p>
<blockquote>
<p>In addition, variants of these types with the _ref suffix are defined
for reference-typed tensors.</p>
</blockquote>
<p>What exactly does this mean? What are reference-typed tensors and how do they differ from standard ones?</p>
| <tensorflow> | 2016-06-22 04:42:01 | HQ |
37,959,013 | why there is two interface comparable and comparator in java for sorting the collections? | <p>why there is two interface comparable and comparator in java for sorting the collections? </p>
<p>both are doing the same task it seems... confusion on this sorting technique? Please advise</p>
| <java><collections> | 2016-06-22 05:11:18 | LQ_CLOSE |
37,959,686 | On child hover change the css of Parent | <p>I want to change the css of parent on hover of Child element.</p>
<pre><code><ul id="main-menu">
<li>
<a href="#">
<i class="fa fa-building-o" aria-hidden="true"></i>
Private Limited
<i class="fa fa-caret-down"></i>
</a>
<ul class="submenu">
<li><a href="#0">Company</a></li>
<li><a href="#0">Contact</a></li>
<li><a href="#0">Industry</a></li>
</ul>
</li></ ul>
</code></pre>
<p>What i want is if i hover on li of <strong>submenu</strong>, li of <strong>main-menu</strong> get highlighted.</p>
| <html><css> | 2016-06-22 05:57:35 | HQ |
37,959,842 | how can i api control this? | **how can i API control this?**
i want use `ble`
problem is that in api lower than 21 i should use `startlescan()` and in API 21 i should use `startscan()` and its scan callback that is not for API less than 21.
how can i separate those code to have both in my app?
[this is error][1]
[1]: http://i.stack.imgur.com/r29WD.jpg
i want something like this:
if(api < 21) startlescan();
if(api >= 21) startscan();
| <android><android-studio><bluetooth-lowenergy> | 2016-06-22 06:08:03 | LQ_EDIT |
37,959,975 | How to read from stdin int using c++ skipping "," and "Space" till "\n" | <p>I want to read integers from STDIN,
1,2,3,4</p>
<pre><code>vector<int> r;
cin >> is;
stringstream iss(is);
int n;
while(iss >> n)
{
r.push_back(n);
}
</code></pre>
<p>but stops reading after "," is there a way other than splitting and directly read Integers only.</p>
| <c++> | 2016-06-22 06:16:57 | LQ_CLOSE |
37,960,128 | MS SQL 2014 help Creating Tables | I am new to mssql and my prof listed these steps to make a table help.
1. Create and populate (Insert Values) the following tables per Table Description and Data Values provided
• DEPARTMENT
• EMPLOYEE
• PROJECT
• ASSIGNMENT
2. Add a SQL Comment to include /* *** Your First Name_Your Last Name*** */ when inserting corresponding values for each table.
[table 1][1]
[table 2][2]
[1]: http://i.stack.imgur.com/mxXcw.png
[2]: http://i.stack.imgur.com/99kOW.png | <sql><sql-server><database><sql-server-2014> | 2016-06-22 06:25:00 | LQ_EDIT |
37,960,142 | How to break/split the content in a div tag in javascript | This div tag contains the following content ."Name Individual Branch" <html>`<div hidden name = "divT" id = "divT" >Hi</div> <html>`
I want Name in a separate div .
These are dynamic and are coming from the database
the following is my javascript code
<html>
function showName(Policy,Select)
{
//alert("Hi"+Select+Policy);
if (Policy == "") {
document.getElementById("divT").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
//alert("Hi");
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
//alert("Hi3" + xmlhttp.readyState + xmlhttp.status );
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
//alert(xmlhttp.responseText);
document.getElementById("divT").innerHTML = xmlhttp.responseText;
document.getElementById("divT").style.display ='block';
//document.getElementById("divT1").style.display ='block';
// alert(xmlhttp.responseText);
}
};
xmlhttp.open("GET","query.php?policy="+Policy+'&select='+Select,true);
xmlhttp.send();
}
}
<html> | <javascript><php><html> | 2016-06-22 06:25:46 | LQ_EDIT |
37,961,965 | IE8 - media query is not rendering | <p>I've got very curious case in IE8 where media query is not working on URL (mobile view shows on desktop) but If I use IP address than it works (desktop view shows). I tried a whole lot of things even several solutions from stackoverflow but couldn't succeed. It seems like respond.js issue but I'm not sure. Can anyone please help me on this. </p>
<p>URL: <a href="https://www.uhc.com/" rel="nofollow">https://www.uhc.com/</a></p>
<p>IP: 149.111.148.170</p>
<p>FYI: I'm using IE 11 developer Tool to check it on IE8.</p>
| <javascript><jquery><html><css><responsive-design> | 2016-06-22 08:00:16 | LQ_CLOSE |
37,962,559 | Using Webpack with React-router bundle.js Not Found | <p>I build a project with Webpack and react-rounter.
this is my code:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>ReactDOM.render(
<Provider store={store}>
<Router history={ browserHistory }>
<Route path='/' component={ App } >
<IndexRoute component={ Home } />
<Route path="purchase" component={ Purchase } />
<Route path="purchase/:id" component={ Purchase } />
</Route>
</Router>
</Provider>,
document.getElementById('example')
);</code></pre>
</div>
</div>
</p>
<p>When i request <code>"http://127.0.0.1:3001/purchase"</code>, it's work! but the address <code>"http://127.0.0.1:3001/purchase/a"</code> has error. look the error message:<a href="http://i.stack.imgur.com/UJuJ4.png" rel="noreferrer">enter image description here</a></p>
<p>My WebpackDevServer config is:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>new WebpackDevServer (webpack(config), {
publicPath: config.output.publicPath,
hot: true,
noInfo: false,
historyApiFallback: true
}).listen(3001, '127.0.0.1', function (err, result) {
if (err) {
console.log(err);
}
console.log('Listening at localhost:3001');
});</code></pre>
</div>
</div>
</p>
<p>I don't know what the matter, Help me!</p>
| <javascript><reactjs><webpack><react-router> | 2016-06-22 08:28:47 | HQ |
37,962,796 | How to create a thread pool in java ? | <p>What am I supposed to do if I am asked to create N threads to access N resource , is thread pooling the right solution?</p>
| <java><multithreading><threadpool> | 2016-06-22 08:41:02 | LQ_CLOSE |
37,963,165 | How to upload file from resources using selenium webdriver | <p>I want to upload a file with selenium webdriver. The file is in resources folder of my project, how can i do ?</p>
| <java><maven><selenium> | 2016-06-22 08:57:13 | LQ_CLOSE |
37,963,327 | What is a good alternative for static stored properties of generic types in swift? | <p>Since static stored properties are not (yet) supported for generic types in swift, I wonder what is a good alternative.</p>
<p>My specific use-case is that I want to build an ORM in swift. I have an <code>Entity</code> protocol which has an associatedtype for the primary key, since some entities will have an integer as their <code>id</code> and some will have a string etc. So that makes the <code>Entity</code> protocol generic.</p>
<p>Now I also have an <code>EntityCollection<T: Entity></code> type, which manages collections of entities and as you can see it is also generic. The goal of <code>EntityCollection</code> is that it lets you use collections of entities as if they were normal arrays without having to be aware that there's a database behind it. <code>EntityCollection</code> will take care of querying and caching and being as optimized as possible.</p>
<p>I wanted to use static properties on the <code>EntityCollection</code> to store all the entities that have already been fetched from the database. So that if two separate instances of <code>EntityCollection</code> want to fetch the same entity from the database, the database will be queried only once.</p>
<p>Do you guys have any idea how else I could achieve that?</p>
| <swift><generics><orm> | 2016-06-22 09:04:42 | HQ |
37,963,829 | Restrict Special and CNTRL+V character java script | How can we restrict, special characters and CNTRL+V from Javascript (Not JQUERY), but it should allow (-) hyphen. | <javascript> | 2016-06-22 09:25:18 | LQ_EDIT |
37,963,845 | having trouble using join function in sql | im trying to join two tables using the join function
workbench keeps coming up with error and dont understand why
please help
select city,cityid,countryid
from cities join countries
on cities.CountryID = countries.CountryID; | <sql><function><join><using> | 2016-06-22 09:25:47 | LQ_EDIT |
37,963,906 | How to get user attributes (username, email, etc.) using cognito identity id | <p>I have AWS Cognito Identity Pool that is configured with Cognito User Pool as an authentication provider.</p>
<p>Assume I have identity ID of an identity in Cognito Identity Pool (e.g. us-east-1:XXaXcXXa-XXXX-XXXX-XXX-XXXXXXXXXXXX) where this identity has a linked login to a user in Cognito User Pool.</p>
<p>Using identity ID, how can I get the linked user details (email, phone, username)?</p>
| <amazon-web-services><amazon-cognito> | 2016-06-22 09:28:24 | HQ |
37,964,763 | What does 'separate' in sequelize mean? | <p>I searched in the official docs of sequelize and couldn't find any entry about '<code>separate</code>'.<a href="https://readthedocs.org/search/?q=separate" rel="noreferrer">https://readthedocs.org/search/?q=separate</a></p>
<p>I also searched on google but in vain.</p>
<pre><code> db.fooTable.find({
where: {
id: id
},
include: [{
model: db.barTable1,
separate: true
}, {
model: db.barTable2,
separate: true
}, {
model: db.barTable3,
separate: true
}]
})
</code></pre>
<p>To find out what it means, I set '<code>separate</code>' to false, but the result of the query were the same as to when I put '<code>true</code>' instead.</p>
| <sequelize.js> | 2016-06-22 10:02:56 | HQ |
37,965,266 | How to get dinamic path in java | String s = "cmd /c " + GeneralMethods.getFilesPath()
+ "mysql-5.6.26-winx64/bin/mysqldump -u root -password database_name>" + GeneralMethods.getFilesPath()
+ "backup/backup.sql";
I dont want to static code
I want to chose dinamic path on java
can someone help me? | <java> | 2016-06-22 10:26:04 | LQ_EDIT |
37,966,100 | Erased all partitions and the partition table on the external hard disc | <p>How to create a partition on an external hard disc and mount it in linux when all the partitions and the partition table are erased?</p>
| <linux><mount><partition><guid-partition-table> | 2016-06-22 11:02:19 | LQ_CLOSE |
37,967,120 | ffmpeg convert from H.264 (High 4:4:4 Profile) to H.264 (Main Profile) | <p>How can I convert a video from H.264 (High 4:4:4 Profile) to H.264 (Main Profile) using ffmpeg? </p>
<p>I can't do that with this command: <code>ffmpeg -i 1/25359.mp4 -profile:v main out.mp4</code>. </p>
<p>That'd return an error:</p>
<pre><code>...
That'd return an error:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1/25359.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:06.08, start: 0.000000, bitrate: 1059 kb/s
Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 351x297, 1057 kb/s, 12.50 fps, 12.50 tbr, 12800 tbn, 25 tbc (default)
Metadata:
handler_name : VideoHandler
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
x264 [error]: main profile doesn't support 4:4:4
[libx264 @ 0x8fa9640] Error setting profile main.
[libx264 @ 0x8fa9640] Possible profiles: baseline main high high10 high422 high444
Output #0, mp4, to '1/24545.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Stream #0:0(und): Video: h264, none, q=2-31, 128 kb/s, 12.50 fps (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc56.60.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
</code></pre>
| <video><ffmpeg><converter><codec> | 2016-06-22 11:46:20 | HQ |
37,967,477 | Confused about how rounding floats work | **I'm trying to round the value that I gain through 'GetFloat()' (say .478 to .48) and then use it in the if statements but i'm somewhat confused regarding rounding floats and such. Will i also need to cast it to an int?
I'd greatly appreciate any help you can give with my code.**
----------
#include <stdio.h>
#include <math.h>
int main(void)
{
//declared variables
float change;
int num = 0;
float change_r;
// prompts for amount owed
{
printf("Please provide the amount owed: ");
change = GetFloat() * 100;
while (change > 0)
float change_r = roundf(change);
}
{
// if statements for calculating number of coins required
if (change >= 25)
{
change = change - 25;
num ++;
}
if (change >= 10 && change < 25)
{
change = change - 10;
num ++;
}
if (change >= 5 && change < 10)
{
change = change - 5;
num ++;
}
if (change >= 1 && change < 5)
{
change = change - 1;
num ++;
}
}
printf("%d\n", num);
}
| <c><floating-point><rounding><infinite-loop> | 2016-06-22 12:02:59 | LQ_EDIT |
37,967,892 | how to add a number to the array using php | i have an array and remainder is 4, how to add this number to the array.
Help me to split this one.
Array
(
[2] => 6
[3] => 6
[5] => 6
[6] => 6
[7] => 6
[9] => 6
)
Array
(
[2] => 6+1
[3] => 6+1
[5] => 6+1
[6] => 6+1
[7] => 6+0
[9] => 6+0
) | <php><arrays> | 2016-06-22 12:21:48 | LQ_EDIT |
37,967,986 | Integer fractorization in C language | I am making a program with C language to make the output look like this.
2 = 2
3 = 3
4 = 2 x 2
5 = 5
6 = 2 x 3
....
102 = 2 x 3 x 17
103 = 103
104 = 2 x 2 x 2 x 13
I wrote the integer fractorization code in this way.
#include <stdio.h>
#define MAXNUM 1000
int main(){
int num,numfordiv;
int div = 2;
for (num=2;num<MAXNUM;num++){
printf("%d=", num);
numfordiv = num;
if(num%div != 0){
div = div+1;
}
else{
numfordiv = numfordiv / div;
printf("%d x ",div);
if(numfordiv == 1){
div = 2;
}
}
}
return 0;
}
However, this does not work for unknown reason. Is there anything wrong with the loop? | <c> | 2016-06-22 12:26:23 | LQ_EDIT |
37,968,010 | nested scrollview + recyclerview, strange autoscroll behaviour | <p>In a view pager I have several fragments, one of them uses a nested scrollview with a header and a recyclerview : </p>
<pre><code><android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.m360.android.fragment.Members.MemberDetailsFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="20dp">
<header/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingTop="0dp" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</code></pre>
<p>The tag "header" represents a complex layout that I didn't want to post here as it stretches out the code a lot.</p>
<p>when I switch between the tabs, it scrolls strait to the recycler view. The header is hidden, I have to scroll up to see it.</p>
<p>Any ideas on what causes that ? I don't wanna use a type in my adapter if I can avoid it.</p>
| <android><android-recyclerview><android-nestedscrollview> | 2016-06-22 12:27:31 | HQ |
37,968,322 | XML comments file could not be found - Swagger | <p>This is certainly one of those that drives you nuts. As the title indicates all I'm simply trying to do is display comments pulled from an xml file using swagger.</p>
<p>I appear to have taken all steps according to the swagger documentation but to no avail. Hopefully you kind folk can point me in the right direction.</p>
<p><strong>Steps Taken:</strong>
<a href="https://i.stack.imgur.com/TbVwq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TbVwq.png" alt="enter image description here"></a></p>
<p><strong>Ensured file exists:</strong></p>
<p><a href="https://i.stack.imgur.com/kWraQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kWraQ.png" alt="enter image description here"></a></p>
<p>Configured <code>SwaggerConfig.cs</code></p>
<p><a href="https://i.stack.imgur.com/66a3h.png" rel="noreferrer"><img src="https://i.stack.imgur.com/66a3h.png" alt="enter image description here"></a></p>
<p>I've tried changing the path too: @"bin/....xml"</p>
<p>Nothing seems to work.</p>
<p>**The Error "Could not find file": **</p>
<p><a href="https://i.stack.imgur.com/RW2Mb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RW2Mb.png" alt="enter image description here"></a></p>
<p>Can anyone point me in the right direction please? </p>
<p>Regards,</p>
| <xml><visual-studio><swagger> | 2016-06-22 12:40:43 | HQ |
37,968,662 | Merge jquery selector [javascipt string concat] | I'm trying to make a jquery-selector generator for my two filters - the aim is just hidding some elements in a calendar -
If I filter on the group DB_ID 2 and on the personn DB_ID 1 I would like to generate the following selector :
`#mod_calendar .gid_2.pid_1`
If I filter on the group DB_ID 2 I would like to generate the following selector : `#mod_calendar .gid_2`
If I filter on the personn DB_ID 1 I would like to generate the following selector : `#mod_calendar .pid_1`
If I filter on the group DB_ID 2,5,6,8 and on the personn DB_ID 1 I would like to generate the following selector :
`#mod_calendar .gid_2.pid_1,#mod_calendar .gid_5.pid_1,#mod_calendar .gid_6.pid_1,#mod_calendar .gid_8.pid_1`
If I filter on the group DB_ID 2,5,6,8 and on the personn DB_ID 1,2 I would like to generate the following selector :
`#mod_calendar .gid_2.pid_1,#mod_calendar .gid_5.pid_1,#mod_calendar .gid_6.pid_1,#mod_calendar .gid_8.pid_1#mod_calendar .gid_2.pid_2,#mod_calendar .gid_5.pid_2,#mod_calendar .gid_6.pid_2,#mod_calendar .gid_8.pid_2`
And so one, I think you get the point...
this https://jsfiddle.net/5mr60f6p/ is what I tried so far but I'm kind of stuck at the moment.
| <javascript><jquery><selector><string-concatenation> | 2016-06-22 12:53:59 | LQ_EDIT |
37,968,696 | How to run code after constructor in a Lombok builder | <p>I have a class that I want to use Lombok.Builder and I need pre-process of some parameters. Something like this:</p>
<pre><code>@Builder
public class Foo {
public String val1;
public int val2;
public List<String> listValues;
public void init(){
// do some checks with the values.
}
}
</code></pre>
<p>normally I would just call <code>init()</code> on a NoArg constructor, but with the generated builder I'm unable to do so. Is there a way for this <code>init</code> be called by the generated builder? For example <code>build()</code> would generate a code like:</p>
<pre><code>public Foo build() {
Foo foo = Foo(params....)
foo.init();
return foo;
}
</code></pre>
<p>I'm aware that I can manually code the <code>all args</code> constructor, that the Builder will call through it and I can call <code>init</code> inside there.</p>
<p>But that is a sub-optimal solution as my class will likely have new fields added every once in a while which would mean changing the constructor too.</p>
| <java><lombok> | 2016-06-22 12:55:11 | HQ |
37,968,762 | Spin bottle with UIGestureRecognizer | <p>I am using this code now to spin bottle on button tap:</p>
<pre><code>@IBAction func spinButton(sender: AnyObject) {
let rotateView = CABasicAnimation()
let randonAngle = arc4random_uniform(360) + 720
rotateView.fromValue = 0
rotateView.toValue = Float(randonAngle) * Float(M_PI) / 180.0
rotateView.duration = 3
rotateView.delegate = self
rotateView.repeatCount = 0
rotateView.removedOnCompletion = false
rotateView.fillMode = kCAFillModeForwards
rotateView.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
bottleImageView.layer.addAnimation(rotateView, forKey: "transform.rotation.z")
}
</code></pre>
<p>But how can I rotate the button using gesture? So the harder/faster I move my finger, the faster the bottle will spin</p>
| <ios><xcode><swift><uiimageview><uigesturerecognizer> | 2016-06-22 12:58:21 | HQ |
37,968,866 | Convert SQL to Codeigniter Query | <p>I've got SQL from my last unswer here, but can't transform this to CodeIgniter Query, get an some errors, does anybody can help me with this? huge thanks!</p>
<pre><code>select topic_tags.slug_tag, t1.post_id, t1.post_url, t1.post_subject
from topic_tags
inner join user_topics on topic_tags.id_topic = user_topics.topic_id
left join
select max(topic_tags.slug_tag) as unique_slug_tag, posts.post_id, posts.post_url, posts.post_subject
from topic_tags
inner join user_topics on topic_tags.id_topic = user_topics.topic_id
inner join tags on tags.tag_slug = topic_tags.slug_tag
inner join posts_tags on tags.id_tag = posts_tags.tagid
inner join posts posts_tags.postid = posts.post_id AND posts_tags.creator_id =$u
where topic_tags.id_topic = $i
group by posts.post_id, posts.post_url, posts.post_subject) t1 on topic_tags.slug_tag = t1.unique_slug_tag
where topic_tags.id_topic = $i
</code></pre>
| <php><mysql><sql><codeigniter> | 2016-06-22 13:01:55 | LQ_CLOSE |
37,969,065 | Tensorflow, best way to save state in RNNs? | <p>I currently have the following code for a series of chained together RNNs in tensorflow. I am not using MultiRNN since I was to do something later on with the output of each layer.</p>
<pre><code> for r in range(RNNS):
with tf.variable_scope('recurent_%d' % r) as scope:
state = [tf.zeros((BATCH_SIZE, sz)) for sz in rnn_func.state_size]
time_outputs = [None] * TIME_STEPS
for t in range(TIME_STEPS):
rnn_input = getTimeStep(rnn_outputs[r - 1], t)
time_outputs[t], state = rnn_func(rnn_input, state)
time_outputs[t] = tf.reshape(time_outputs[t], (-1, 1, RNN_SIZE))
scope.reuse_variables()
rnn_outputs[r] = tf.concat(1, time_outputs)
</code></pre>
<p>Currently I have a fixed number of time steps. However I would like to change it to have only one timestep but remember the state between batches. I would therefore need to create a state variable for each layer and assign it the final state of each of the layers. Something like this.</p>
<pre><code>for r in range(RNNS):
with tf.variable_scope('recurent_%d' % r) as scope:
saved_state = tf.get_variable('saved_state', ...)
rnn_outputs[r], state = rnn_func(rnn_outputs[r - 1], saved_state)
saved_state = tf.assign(saved_state, state)
</code></pre>
<p>Then for each of the layers I would need to evaluate the saved state in my sess.run function as well as calling my training function. I would need to do this for every rnn layer. This seems like kind of a hassle. I would need to track every saved state and evaluate it in run. Also then run would need to copy the state from my GPU to host memory which would be inefficient and unnecessary. Is there a better way of doing this?</p>
| <python><tensorflow> | 2016-06-22 13:10:15 | HQ |
37,969,221 | Java printing patterns | <p>I'm new in Java.
I have next code:</p>
<pre><code>public static void main(String[] args) {
for(int k = 10; k > 0; k--)
{
for(int l=0; l < k-1; l++)
{
System.out.print(' ');
}
for(int n=10; n > k-1; n--)
{
System.out.print('*');
}
System.out.println();
}
}
</code></pre>
<p>It prints this:</p>
<pre><code> *
**
***
****
*****
******
*******
********
*********
**********
</code></pre>
<p>But I want to print it with empty inside like this:</p>
<pre><code> *
**
* *
* *
* *
* *
* *
* *
* *
**********
</code></pre>
<p>Can anyone to explane me how to do it.
I understand that this is not a place where solve homework tasks. But can somebody tell me the algorithm for solving the problem in words.
I do not need a ready solution because I want to understand and solve it by myself. So how I can put spaces inside?</p>
| <java><for-loop> | 2016-06-22 13:16:18 | LQ_CLOSE |
37,969,268 | How to interact with Java Scanner Class (Atom editor) | I am super newb with Java and I am trying simple codes with Atom editor (osx).
Please, someone can help me to understand how can I interact with code with Atom?
I use Script package (Atom) to run the code (cmd+i).
For example if I use the Scanner class:
import java.util.Scanner;
public class Les {
public static void main(String[] args) {
String s;
Scanner in = new Scanner(System.in);
System.out.println("Enter a string");
s = in.nextLine();
System.out.println("You entered string " + s);
}
}
the output will be "enter a string"
Where I can insert the Strings?
Thank you
| <java><java.util.scanner> | 2016-06-22 13:18:00 | LQ_EDIT |
37,969,287 | Android studio methods separator | <p>How to add line separator afer every method.</p>
<p>like this:</p>
<p><a href="https://i.stack.imgur.com/gp0Kr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gp0Kr.png" alt="Line separator android studio"></a></p>
| <android><android-studio> | 2016-06-22 13:18:35 | HQ |
37,969,502 | How to assign case statement that has alias to variable using sql server | In my code below I'm trying to assign the results of a CASE statement to a variable. I got that working but my problem is that my CASE statement has an alias for the column name but I'm getting an "incorrect syntax near 'AS'". I am needing to SUM my variables to get a GRAND TOTAL in that column as well. I am working in SQL Server 2014.
I could not find a solution and was hoping that someone can provide some direction/help. Thanks in advance.
Here is my SQL code:
SELECT DISTINCT a1.SCHYEAR, a1.LocationName as LOCATIONNAME, a1.GRADE, a1.[RACE/ETHNICITY],
@504Count=(
CASE
WHEN a1.StudentPermID IN (SELECT DISTINCT t4.Permnum FROM #504 t4) THEN COUNT(a1.StudentPermID)
END AS '504'),
@Non504SPEDCount =(
CASE
WHEN a1.STID NOT IN (SELECT DISTINCT t1.STID FROM #speds t1) THEN COUNT(a1.STID)
WHEN a1.StudentPermID NOT IN (SELECT DISTINCT t3.Permnum FROM #504 t3) THEN COUNT(a1.StudentPermID)
END AS 'Non-504/Non-SPED'),
@SPEDCount=(
CASE
WHEN a1.STID IN (SELECT DISTINCT t2.STID FROM #speds t2) THEN COUNT(a1.STID)
END AS 'SPED'),
a1.STID, a1.StudentPermID as PERMNUM, COUNT('504'), COUNT('Non-SPED'), COUNT('SPED'),
SUM(@504Count + @Non504SPEDCount + @SPEDCount) AS 'Grand Total'
FROM #allStudents a1
GROUP BY a1.SCHYEAR, a1.LocationName, a1.GRADE, a1.[RACE/ETHNICITY], a1.STID, a1.StudentPermID
ORDER BY a1.SCHYEAR, a1.LocationName, a1.GRADE, a1.[RACE/ETHNICITY], a1.STID, a1.StudentPermID
| <sql-server><case> | 2016-06-22 13:26:15 | LQ_EDIT |
37,969,703 | strptime format - Python | <p>I'm currently working with an API that returns date in the following format:</p>
<pre><code>d1 = '2015-06-25T18:45:24'
d2 = '2015-07-11T18:45:35'
</code></pre>
<p>So, to find the difference between two times, in days, I'm doing the following:</p>
<pre><code>import datetime
d1 = datetime.datetime.strptime(d1, "%Y-%m-%d %H:%M:%S.%f")
d2 = datetime.datetime.strptime(d2, "%Y-%m-%d %H:%M:%S.%f")
print abs((d2-d1).days)
</code></pre>
<p>However, I'm getting the following error:</p>
<pre><code>ValueError: time data '2015-06-25T18:45:24' does not match format '%Y-%m-%dT%H:%M:%S.%f'
</code></pre>
<p>I know I could just simply split the string in <code>'T'</code> and then convert, however is there an easy way to convert to such format to datetime object?</p>
| <python><datetime> | 2016-06-22 13:33:56 | LQ_CLOSE |
37,969,725 | Regular Experssion to exlude specific pattern in pattern | I want to select html attributes based on Regular expression
Follwing is the strings it is matching based on follwoing regular expression for below HTML markup.
colspan="2"
bgcolor="#FFFFFF"
height="28"
psdtyle="font-stretch: normal; font-size: 12px; line-height: 1.5;"
align="center"
style="word-wrap: break-word; margin: 5px 0px;"
size="2"
((\w+)="[a-zA-Z#-:0-9 ;]*")
Now the real question is i want to exclude colspan, i.e colspan="2" shold not match.Please suggest.Thanks in advance
<td colspan="2" bgcolor="#FFFFFF" height="28" psdtyle="font-stretch: normal; font-size: 12px; line-height: 1.5;">
<p align="center" style="word-wrap: break-word; margin: 5px 0px;"><font size="2">Shoulder</font></p>
</td
| <javascript><regex> | 2016-06-22 13:34:50 | LQ_EDIT |
37,970,187 | Elasticsearch cluster 'master_not_discovered_exception' | <p>i have installed elasticsearch 2.2.3 and configured in cluster of 2 nodes</p>
<p>Node 1 (elasticsearch.yml)</p>
<pre><code>cluster.name: my-cluster
node.name: node1
bootstrap.mlockall: true
discovery.zen.ping.unicast.hosts: ["ec2-xx-xx-xx-xx.eu-west-1.compute.amazonaws.com", "ec2-xx-xx-xx-xx.eu-west-1.compute.amazonaws.com"]
discovery.zen.minimum_master_nodes: 1
discovery.zen.ping.multicast.enabled: false
indices.fielddata.cache.size: "30%"
indices.cache.filter.size: "30%"
node.master: true
node.data: true
http.cors.enabled: true
script.inline: false
script.indexed: false
network.bind_host: 0.0.0.0
</code></pre>
<p>Node 2 (elasticsearch.yml)</p>
<pre><code>cluster.name: my-cluster
node.name: node2
bootstrap.mlockall: true
discovery.zen.ping.unicast.hosts: ["ec2-xx-xx-xx-xx.eu-west-1.compute.amazonaws.com", "ec2-xx-xx-xx-xx.eu-west-1.compute.amazonaws.com"]
discovery.zen.minimum_master_nodes: 1
discovery.zen.ping.multicast.enabled: false
indices.fielddata.cache.size: "30%"
indices.cache.filter.size: "30%"
node.master: false
node.data: true
http.cors.enabled: true
script.inline: false
script.indexed: false
network.bind_host: 0.0.0.0
</code></pre>
<p>If i get <code>curl -XGET 'http://localhost:9200/_cluster/state?pretty'</code> i have:</p>
<pre><code>{
"error" : {
"root_cause" : [ {
"type" : "master_not_discovered_exception",
"reason" : null
} ],
"type" : "master_not_discovered_exception",
"reason" : null
},
"status" : 503
}
</code></pre>
<p>Into log of node 1 have:</p>
<pre><code>[2016-06-22 13:33:56,167][INFO ][cluster.service ] [node1] new_master {node1}{Vwj4gI3STr6saeTxKkSqEw}{127.0.0.1}{127.0.0.1:9300}{master=true}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2016-06-22 13:33:56,210][INFO ][http ] [node1] publish_address {127.0.0.1:9200}, bound_addresses {[::]:9200}
[2016-06-22 13:33:56,210][INFO ][node ] [node1] started
[2016-06-22 13:33:56,221][INFO ][gateway ] [-node1] recovered [0] indices into cluster_state
</code></pre>
<p>Into log of node 2 instead:</p>
<pre><code>[2016-06-22 13:34:38,419][INFO ][discovery.zen ] [node2] failed to send join request to master [{node1}{Vwj4gI3STr6saeTxKkSqEw}{127.0.0.1}{127.0.0.1:9300}{master=true}], reason [RemoteTransportException[[node2][127.0.0.1:9300][internal:discovery/zen/join]]; nested: IllegalStateException[Node [{node2}{_YUbBNx9RUuw854PKFe1CA}{127.0.0.1}{127.0.0.1:9300}{master=false}] not master for join request]; ]
</code></pre>
<p>Where the error?</p>
| <elasticsearch> | 2016-06-22 13:54:28 | HQ |
37,970,424 | What is the difference between drawing plots using plot, axes or figure in matplotlib? | <p>I'm kind of confused what is going at the backend when I draw plots in matplotlib, tbh, I'm not clear with the hierarchy of plot, axes and figure. I read the documentation and it was helpful but I'm still confused...</p>
<p>The below code draws the same plot in three different ways - </p>
<pre><code>#creating the arrays for testing
x = np.arange(1, 100)
y = np.sqrt(x)
#1st way
plt.plot(x, y)
#2nd way
ax = plt.subplot()
ax.plot(x, y)
#3rd way
figure = plt.figure()
new_plot = figure.add_subplot(111)
new_plot.plot(x, y)
</code></pre>
<p>Now my question is -</p>
<ol>
<li><p>What is the difference between all the three, I mean what is going under the hood when any of the 3 methods are called? </p></li>
<li><p>Which method should be used when and what are the pros and cons of using any on those? </p></li>
</ol>
| <python><matplotlib> | 2016-06-22 14:04:10 | HQ |
37,970,677 | Scala | operator '=>' and other these types of operator | <p>can some help me to under stand this code and operator types used or may be used here</p>
<pre><code>def times [A](f: =>A): Unit={
def loop(current: Int): Unit=
if(current > 0){
f
loop(current - 1)
}
loop(x)
}
</code></pre>
| <scala> | 2016-06-22 14:14:01 | LQ_CLOSE |
37,971,066 | Parsing a string into multiple separate strings | <p>Hey guys I have a quick question. I am trying to parse a single string into multiple strings using a keyword. I can currently find a set of code that allows me to parse the single string but I need to store each of the new strings as a new variable/item.</p>
<pre><code>string full = "Hey//Please//Help";
</code></pre>
<p>parse into:</p>
<p>first string- Hey</p>
<p>Second string- Please</p>
<p>third string- Help</p>
<p>So for example I would like to manipulate the first string, Hey, by itself. Please let me know if any more explanation is necessary.</p>
| <c#><string><parsing> | 2016-06-22 14:29:18 | LQ_CLOSE |
37,971,262 | How can i "eliminate" a object name form a javascript object? | I want to get is the following thing.
Starting from a json like this:
{ "de"{ "errors.de.i18n.js": { "errors": { "addcreditcard":"Wir konnten diese Karte nicht verifizieren. Bitte überprüfe deine Angaben und versuche es noch einmal.",...
How can i get this ?:
{ "de"{ "errors": { "addcreditcard":"Wir konnten diese Karte nicht verifizieren. Bitte überprüfe deine Angaben und versuche es noch einmal.",
Thank you all | <javascript><jquery><json> | 2016-06-22 14:37:58 | LQ_EDIT |
37,971,916 | Ambiguity in pattern matching syntax | <p>I came across an oddity in the F# pattern matching syntax today, which can lead to apparent failures in the exhaustivity check.</p>
<pre><code>type Thing =
| This
| That
| Other
let useThing =
function
| This -> "A"
| That -> "A"
| That -> "B" // compiler complains
| Other -> "B"
</code></pre>
<p>In the above scenario the compiler helpfully tells me that the second That rule will never be matched. However, if I had tried to make the code a bit more compact and had written</p>
<pre><code>let useThing =
function
| This | That -> "A"
| That | Other -> "B"
</code></pre>
<p>I do not get any help from the compiler. I <em>think</em> the reason is that <code>| This | That ->. "A"</code> is not a shortcut for <code>| This -> "A" | That -> "A"</code>, even though it looks very much like it is (and I've seen many code samples that treat it as such). Instead, from what I can find, the pipe symbol is used both to separate individual patterns, and also as OR pattern.</p>
<p>This is not a big issue for most DUs, but I encountered the problem when mapping a DU with a large number of cases into another DU with a small number of cases. My attempt to use the shortcut syntax caused a bug.</p>
<p>So my questions are:</p>
<ol>
<li>Is my interpretation correct?</li>
<li>Is there any workaround apart from listing each pattern on a separate line?</li>
</ol>
| <f#> | 2016-06-22 15:06:55 | HQ |
37,971,961 | Docker Error bind: address already in use | <p>When I run <code>docker-compose up</code> in my Docker project it failes with the following message:</p>
<pre><code>Error starting userland proxy: listen tcp 0.0.0.0:3000: bind: address already in use
</code></pre>
<p><code>netstat -pna | grep 3000</code>
shows this:</p>
<pre><code>tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN -
</code></pre>
<p>I've already tried <code>docker-compose down</code>, but it doesn't help.</p>
| <ubuntu><docker><ubuntu-14.04><bind><docker-compose> | 2016-06-22 15:09:21 | HQ |
37,972,229 | glVertexAttribPointer and glVertexAttribFormat: What's the difference? | <p>OpenGL 4.3 and OpenGL ES 3.1 added several alternative functions for specifying vertex arrays: <code>glVertexAttribFormat</code>, <code>glBindVertexBuffers</code>, etc. But we already had functions for specifying vertex arrays. Namely <code>glVertexAttribPointer</code>.</p>
<ol>
<li><p>Why add new APIs that do the same thing as the old ones?</p></li>
<li><p>How do the new APIs work?</p></li>
</ol>
| <opengl><opengl-es><opengl-4> | 2016-06-22 15:21:14 | HQ |
37,972,728 | Swift 3 / Xcode 8 Upgrade - 100's of DerivedData files missing from working copy errors | <p>I have just upgraded to the latest Beta version of XCode and Swift but after using the converter my app project now has over 200 build time yellow errors all stating /"projectDirectoy"/DerivedData/XXXXXXXXX/XXXX/XXX/xXXX/xXX is missing from working copy... where by the XXXXX's represent various file paths in the DerivedData folder.</p>
<p>I have tried deleting the DerivedData folder from the location mentioned in the errors. </p>
<p>I have tried deleting everything in the DerivedData folder in ~/Library/.</p>
<p>I have tried multiple times to clean the project, reboot and do a fresh build.</p>
<p>I have tried turning off source control in preferences but I don't see why I should turn this off as it was on before I updated so I want it left on.</p>
<p>These errors just won't seem to go away.</p>
<p>Any ideas?</p>
| <ios><xcode><swift><swift3><xcode8> | 2016-06-22 15:42:08 | HQ |
37,972,753 | Git reset single file in feature branch to be the same as in master | <p>I'm trying to revert my changes in a <strong>single file</strong> in my feature branch and I want this file to be the same as in master.</p>
<p>I tried:</p>
<pre><code>git checkout -- filename
git checkout filename
git checkout HEAD -- filename
</code></pre>
<p>It seems that none of these made any changes to my feature branch. Any suggestions? </p>
| <git> | 2016-06-22 15:43:41 | HQ |
37,973,074 | Why will my addClass not target only current element? | when I add class "Icon" using the if statement, it adds it to the correct h3 but also to any h3's ABOVE the correct one also. Even if the h3 above is 0. Icon will either be 0 or 1.
{ $('#accordion') .append($('<h3>') .html(Agency));
if (Icon == 1) {
$('h3') .addClass('Icon');
}
AccordionChild = $('<div>');
}
AccordionChild.append("<div>") .html(ToolsList);
$('#accordion').append(AccordionChild);
});
}
[enter image description here][1]
[1]: http://i.stack.imgur.com/3gy0r.png | <jquery><if-statement><addclass> | 2016-06-22 15:59:27 | LQ_EDIT |
37,973,302 | Strange ArrayIndexOutOfBoundsException in android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback | <p>I received a strange out of bounds exception in the Play Store console relating to the <a href="https://developer.android.com/reference/android/support/v4/app/ActivityCompat.OnRequestPermissionsResultCallback.html" rel="noreferrer">android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback</a></p>
<pre><code>java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at com.example.MyFragmentActivity.onRequestPermissionsResult(MyFragmentActivity.java:2068)
at android.app.Activity.requestPermissions(Activity.java:4163)
at android.support.v4.app.ActivityCompatApi23.requestPermissions(ActivityCompat23.java:32)
at android.support.v4.app.ActivityCompat.requestPermissions(ActivityCompat.java:316)
at com.example.MyFragmentActivity.onConnected(MyFragmentActivity.java:2048)
at com.google.android.gms.common.internal.zzk.zzk(Unknown Source)
at com.google.android.gms.common.api.internal.zzj.zzi(Unknown Source)
at com.google.android.gms.common.api.internal.zzh.zzpx(Unknown Source)
at com.google.android.gms.common.api.internal.zzh.onConnected(Unknown Source)
at com.google.android.gms.common.api.internal.zzl.onConnected(Unknown Source)
at com.google.android.gms.common.api.internal.zzc.onConnected(Unknown Source)
at com.google.android.gms.common.internal.zzj$zzg.zzqL(Unknown Source)
at com.google.android.gms.common.internal.zzj$zza.zzc(Unknown Source)
at com.google.android.gms.common.internal.zzj$zza.zzw(Unknown Source)
at com.google.android.gms.common.internal.zzj$zzc.zzqN(Unknown Source)
at com.google.android.gms.common.internal.zzj$zzb.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
</code></pre>
<p>This is my onRequestPermissionsResult implementation</p>
<pre><code>@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
switch (requestCode) {
case REQUEST_CODE_ASK_LOCATION_PERMISSIONS:
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// Permission Granted
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
}
startLocationUpdates();
} else {
// Permission Denied
}
break;
default:
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
</code></pre>
<p>Line 2068 is this:</p>
<pre><code>if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
</code></pre>
<p>I believe it's claiming <code>grantResults</code> length is zero which is why the java.lang.ArrayIndexOutOfBoundsException is thrown. According to the <a href="https://developer.android.com/reference/android/support/v4/app/ActivityCompat.OnRequestPermissionsResultCallback.html" rel="noreferrer">documentation</a> </p>
<blockquote>
<p>int: The grant results for the corresponding permissions which is
either <strong>PERMISSION_GRANTED or PERMISSION_DENIED. Never null.</strong></p>
</blockquote>
<p><code>grantResults</code> will not be null, but doesn't say anything about it not containing a value either. Furthermore it seems like the callback will contain at least one value, either <code>PERMISSION_GRANTED</code> or <code>PERMISSION_DENIED</code>. Is this a bug or am I misunderstanding the documentation?</p>
| <android> | 2016-06-22 16:12:06 | HQ |
37,974,347 | Concatenate Column A depending on Value of Column B - SQL Server | <pre><code>I have a table that looks like the following
COLUMN_A|| COLUMN_B ||
======================
NAME1 || 1 ||
NAME2 || 1 ||
NAME3 || 1 ||
NAME4 || 2 ||
NAME5 || 2 ||
NAME6 || 3 ||
NAME7 || 3 ||
</code></pre>
<p>I want to concatenate COLUMN_A depending on COLUMN_B.
If values of COLUMN_B are same, then COLUMN_A should be concatenated seperated by a comma.</p>
<p>Expected result</p>
<pre><code>NAME1, NAME2, NAME3
NAME4, NAME5
NAME6, NAME7
</code></pre>
| <sql-server><tsql><sql-server-2012> | 2016-06-22 17:06:15 | LQ_CLOSE |
37,974,605 | Ruby Code. I am trying to learn Ruby and having trouble with this exercise | I am trying to learn ruby and I am working out of the book "Head First Ruby". So far I really like the book but I can not get one of the exercises to work. It is driving me crazy. I can not figure out what I have done wrong. Could someone please look over this code and tell me what is going wrong? The error I am getting is:
employee.rb:42:in `print_pay_stub': undefined method `*' for nil:NilClass (NoMethodError)
from employee.rb:56:in `<main>'
I can not seem to get the code up on this site in one box so here is also the gist link https://gist.github.com/jeffwolfram/cb72b4301feaf1adb55c7888ec2b3c6f#file-gistfile1-txt
Any help would be much appreciated.
```
class Employee
attr_reader :name
def name=(name)
end
def print_name
puts "Name: #{name}"
end
end
class SalariedEmployee < Employee
attr_reader :salary
def salary=(salary)
#code to validate and set @salary
end
def print_pay_stub
print_name
pay_for_period = (salary / 365.0) * 14
formatted_pay = format("$%.2f", pay_for_period)
puts "Pay this period: #{formatted_pay}"
end
end
class HourlyEmployee < Employee
attr_reader :hourly_wage, :hours_per_week
def hourly_wage=(hourly_wage)
#code to validate and set @hourly_wage
end
def hours_per_week=(hours_per_week)
#code to validate and set @hours_per_week
end
def print_pay_stub
print_name
pay_for_period = hourly_wage * hours_per_week * 2
formatted_pay = format("$%.2f", pay_for_period)
puts "pay This Period: #{formatted_pay}"
end
end
```
| <ruby> | 2016-06-22 17:23:21 | LQ_EDIT |
37,975,177 | How can i pass parameters in assembler x86 function call | <p>Look at this assembler code. It is designed for 32 bits x86 and will be compiled by nasm</p>
<pre><code> ...
my_function:
pop %eax
...
ret
main:
push 0x08
call my_function
</code></pre>
<p>I have learned a long time ago that we can use stack for passing parameters between main program and functions.
I would expect that eax contains 0x08, but this is false and i can not explain why.
How should i do for fetching my function parameters ?</p>
| <assembly><nasm> | 2016-06-22 17:58:10 | HQ |
37,975,358 | How to define swagger property that is an unknown name? | <p>I need to define a swagger property that doesn't have a known name.</p>
<pre><code>{
"type": "object",
"properties": {
"?????": {
"type": "array",
"items": { "$ref": "#/definitions/ModelRelease" }
}
}
</code></pre>
<p>The ????? portion of my definition is an integer of an unknown value. Any ideas?</p>
| <swagger> | 2016-06-22 18:08:38 | HQ |
37,975,605 | How do I download the Gson library? | <p>Should be simple question.</p>
<p>When I go to <a href="https://github.com/google/gson">https://github.com/google/gson</a> I can only download the library as a zip folder as opposed to a jar file.</p>
<p>Where can I get the jar file?</p>
| <github><jar><zip><gson> | 2016-06-22 18:22:31 | HQ |
37,975,819 | React: Use environment variables | <p>How can I use environment variables defined in <code>.bash_profile</code> in a React application? I have two React apps in production (they're the same project, so they have the same code), but they need to request to different API hosts, and I figured env variables could do the trick.</p>
| <reactjs> | 2016-06-22 18:34:42 | HQ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.