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 |
|---|---|---|---|---|---|
36,241,009 | What is coherent memory on GPU? | <p>I have stumbled not once into a term "non coherent" and "coherent" memory in the </p>
<p><a href="https://renderdoc.org/vulkan-in-30-minutes.html">tech papers</a> related to graphics programming.I have been searching for a simple and clear explanation,but found mostly 'hardcore' papers of <a href="https://www.ece.ubc.ca/~aamodt/papers/isingh.hpca2013.pdf">this</a> type.I would be glad to receive layman's style answer on what coherent memory actually is on GPU architectures and how it is compared to other (probably not-coherent) memory types. </p>
| <gpu><gpgpu><gpu-programming><vulkan> | 2016-03-26 21:17:43 | HQ |
36,241,674 | How can i solve this issue "show product quantity in stock respect to size" in WooCommerce | <p>i have install <strong>woocommerce plugin</strong> and wanted to show product quantity with respect to size in this way on product page like <strong>large:15 and small:13 in stock</strong>
wordpress version is 4.4.2
so please guide me how can i do this</p>
| <php><wordpress><woocommerce> | 2016-03-26 22:33:11 | LQ_CLOSE |
36,242,804 | Excel need to match and paste to an adjacent cell | <p>So the formula needs to look at column D IN SHEET 1, go over to sheet 2, if it finds a match in column A, then paste the coordinates in column B into sheet 1 column E.<a href="http://i.stack.imgur.com/rehLP.png" rel="nofollow">IMAGE</a></p>
| <excel><excel-formula> | 2016-03-27 01:14:20 | LQ_CLOSE |
36,243,930 | Download image from server and store it on SD card | <p>I'am developing an android application in which I want to download multiple images from server and store it on SD card.
Which is the best approach to perform this task.I want to perform this task in background of application.</p>
| <android> | 2016-03-27 04:45:46 | LQ_CLOSE |
36,244,811 | How do I remove grid lines from a Bokeh plot? | <p>I would like to remove the grid lines from a Bokeh plot. What is the best way to do this?</p>
| <python><bokeh> | 2016-03-27 07:12:27 | HQ |
36,245,387 | Type for parameter in TypeScript Arrow Function | <p>With </p>
<pre><code>"noImplicitAny": true
</code></pre>
<p>TypeScript will give the error:</p>
<p><em>Parameter 'x' implicitly has an 'any' type</em></p>
<p>for</p>
<pre><code>.do(x => console.log(x));
</code></pre>
<p>and error</p>
<p><em>',' expected</em></p>
<p>for:</p>
<pre><code>.do(x: any => console.log(x));
</code></pre>
| <typescript> | 2016-03-27 08:32:44 | HQ |
36,245,415 | How can I use 'watch' in my npm scripts? | <p>I have the following directory structure:</p>
<p><a href="https://i.stack.imgur.com/0yvkT.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/0yvkT.jpg" alt="enter image description here"></a></p>
<p>And my <code>package.json</code> looks like this:</p>
<pre><code>{
"name": "personal_site",
"version": "1.0.0",
"description": "My personal website.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"node-sass": "node-sass --output-style compressed --include-path node_modules/bourbon/app/assets/stylesheets/ --include-path node_modules/bourbon-neat/app/assets/stylesheets/ 'src/scss/styles.scss' 'dist/css/bundle.min.css'",
"html-minifier": "html-minifier --collapse-whitespace --remove-comments --remove-attribute-quotes -o 'dist/index.html' 'src/index.html'",
"imagemin": "imagemin src/images dist/images",
"serve": "http-server ./dist"
},
"author": "Dean Gibson",
"license": "ISC",
"dependencies": {
"bourbon": "^4.2.6",
"bourbon-neat": "^1.7.4",
"normalize-scss": "^4.0.3"
},
"devDependencies": {
"html-minifier": "^1.3.0",
"http-server": "^0.9.0",
"node-sass": "^3.4.2"
}
}
</code></pre>
<p>So firstly, I have to run each of these scripts individually e.g. <code>npm run node-sass</code> or <code>npm run html-minifier</code> etc. What I'd ideally want is to run <code>npm serve</code> which will do the following:</p>
<ol>
<li>run html-minifier </li>
<li>run node-sass </li>
<li>run run image-min </li>
<li>run http-server </li>
<li>Lastly, watch everything in my <code>src</code> folder and run
the respective scripts as files change e.g. <code>node-sass</code> etc..</li>
</ol>
<p>How can I best tackle this problem?</p>
| <javascript><node.js><npm> | 2016-03-27 08:36:28 | HQ |
36,246,144 | polymorphic functions in Haskell | <p>Have a parametrically polymorphic function <code>foo :: a -> a -> a</code>. Give four of the argument so that the resulting expression
<code>foo arg1 arg2 arg3 arg4</code> would have type <code>Bool</code>.</p>
<pre><code>-- foo :: a -> a -> a function is defined in a code
arg1 = undefined
arg2 = undefined
arg3 = undefined
arg4 = undefined
</code></pre>
| <haskell> | 2016-03-27 10:07:38 | LQ_CLOSE |
36,247,016 | Angular2 refreshing view on array push | <p>I can't seem to get angular2 view to be updated on an array.push function, called upon from a setInterval async operation.</p>
<p>the code is from this <a href="http://plnkr.co/edit/GC512b?p=preview" rel="noreferrer">angular plunkr example of setInterval</a>:</p>
<p>What i'm trying to do is as follows:</p>
<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>import {View, Component, bootstrap, Directive, ChangeDetectionStrategy, ChangeDetectorRef} from 'angular2/angular2'
@Component({selector: 'cmp', changeDetection: ChangeDetectionStrategy.OnPush})
@View({template: `Number of ticks: {{numberOfTicks}}`})
class Cmp {
numberOfTicks = [];
constructor(private ref: ChangeDetectorRef) {
setInterval(() => {
this.numberOfTicks.push(3);
this.ref.markForCheck();
}, 1000);
}
}
@Component({
selector: 'app',
changeDetection: ChangeDetectionStrategy.OnPush
})
@View({
template: `
<cmp><cmp>
`,
directives: [Cmp]
})
class App {
}
bootstrap(App);</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
<head>
<title>angular2 playground</title>
<script src="https://code.angularjs.org/tools/traceur-runtime.js"></script>
<script src="https://code.angularjs.org/tools/system.js"></script>
<script src="https://code.angularjs.org/tools/typescript.js"></script>
<script data-require="jasmine" data-semver="2.2.1" src="http://cdnjs.cloudflare.com/ajax/libs/jasmine/2.2.1/jasmine.js"></script>
<script data-require="jasmine" data-semver="2.2.1" src="http://cdnjs.cloudflare.com/ajax/libs/jasmine/2.2.1/jasmine-html.js"></script>
<script data-require="jasmine@*" data-semver="2.2.1" src="http://cdnjs.cloudflare.com/ajax/libs/jasmine/2.2.1/boot.js"></script>
<script src="config.js"></script>
<script src="https://code.angularjs.org/2.0.0-alpha.37/angular2.min.js"></script>
<script>
System.import('app')
.catch(console.error.bind(console));
</script>
</head>
<body>
<app></app>
</body>
</html></code></pre>
</div>
</div>
</p>
<p>The above code will work properly if "numberOfTicks" is just a number, (as the plunker original example shows) but once I change it to an array and push data, it won't update.</p>
<p>I can't seem to understand why is that.</p>
<p>The following behaviour is similar to an issue I have when trying to update a graph in angular2 with new data points when using setInterval / setTimeout.</p>
<p>Thanks for the help.</p>
| <javascript><arrays><asynchronous><angular><setinterval> | 2016-03-27 11:56:09 | HQ |
36,247,382 | Remove HTML tags from Strings on laravel blade | <p>I want remove HTML tags (all) from a string on laravel blade ...</p>
<p>code</p>
<pre><code>{!! \Illuminate\Support\Str::words($subject->body, 5,'...') !!}
</code></pre>
<p>output (example)</p>
<pre><code><p>hassen zouari</p>
</code></pre>
<p>I want that it be like this</p>
<pre><code>hassen zouari
</code></pre>
| <laravel><laravel-4><laravel-5> | 2016-03-27 12:34:36 | HQ |
36,247,714 | Difference between width & height and the style image attribute | <p>Why use a style image attribute rather than just coding width and height for each image? </p>
| <html><css><image><height><width> | 2016-03-27 13:11:00 | LQ_CLOSE |
36,248,622 | Password Verification in Ruby | I've been tasked with a very simple password verification, but for the life of me, I cannot seem to get this right. Here is the task:
> The user sends a numeric password of 6 characters through a form. In
> order to force secure passwords create a validation that the numbers
> cannot consecutively go up or down.
Here is what I have:
password = '246879'
new_password = password.split('').map { |s| s.to_i }
new_password.each_with_index do |val, index|
next_element = new_password[index + 1]
prev_element = new_password[index - 1]
if new_password[index] + 1 == next_element
puts 'next bad'
break
elsif
new_password[index] - 1 == prev_element
puts 'prev bad'
break
end
end
The password should fail on the 87 because 7 is one less than 8. Thank you for any help. | <ruby><string><validation><passwords><integer> | 2016-03-27 14:43:25 | LQ_EDIT |
36,248,728 | How to reset a php select form to default? | <p>I have this php code to generate a select form. What I'm looking for is create a "X" button at right side for resetting the form to default value [0] index. Here is a picture of what I want to accomplish. How can I do that?
Thanks
<a href="http://i.stack.imgur.com/rQfYz.jpg" rel="nofollow">This is where the X should be located</a></p>
<pre><code>echo '<li><div class="styled-select">' . tep_draw_form('sort',`
htmlentities($_SERVER['PHP_SELF']), 'get') . '';
$sort_list = array('0' => 'Sort By',
'1' => 'Product Name',
'2' => 'Price: Low to High',
'3' => 'Price: High to Low',
echo tep_draw_hidden_field('page', $page);
foreach($sort_list as $id=>$text) {
$sort_range[] = array('id' => $id, 'text' => $text);
}
echo tep_draw_pull_down_menu('sort', $sort_range, (isset($HTTP_GET_VARS['sort']) ?
$HTTP_GET_VARS['sort'] : ''), 'onchange="this.form.submit()"');
echo '</form></div></li>';
</code></pre>
| <php> | 2016-03-27 14:53:47 | LQ_CLOSE |
36,249,007 | how to save a string to the computer memory? | <p>I want to save a string to "copy" memory in computer (ctrl + c), after clicking a button.
how can I save that string to the computer memory (ctrl c) in c#?</p>
| <c#><string><visual-studio><copy><ctrl> | 2016-03-27 15:19:11 | LQ_CLOSE |
36,249,119 | passport deserializeUser method never called | <p>I have got 200 response for login request, but 401 for any futher auth check requests, because deserializeUser never called. I dived into passport source and noticed that passport checks whether req._passport.session.user exists, and if no it doesn't call deserializeUser. </p>
<p>I have searched through other questions on stackoverflow, it seems i have specific case. </p>
<p>There is single local strategy auth type, i use Ajax request to make login requests, CORS settings configured, <a href="http://localhost:8080">http://localhost:8080</a> - frontend, <a href="http://localhost:3000">http://localhost:3000</a> backend)</p>
<p>I use bodyParse, cookieParser, express session, passport initialize and passport sessions. Express session secure:false configured as i run auth requests through http.</p>
<p>You can find my project here (backend package.json is good to go, so you can use it, it has no missing dependencies, as for frontend not sure), at least you can check the code there.</p>
<p>Backend <a href="https://github.com/rantiev/template-api">https://github.com/rantiev/template-api</a>
Frontend <a href="https://github.com/rantiev/template-angular">https://github.com/rantiev/template-angular</a></p>
<p>Express session configuration and CORS is here <a href="https://github.com/rantiev/template-api/blob/master/modules/appConfigure.js">https://github.com/rantiev/template-api/blob/master/modules/appConfigure.js</a></p>
<pre><code>var path = require('path');
var bodyParser = require('body-parser');
var session = require('express-session');
var cookieParser = require('cookie-parser');
var MongoStore = require('connect-mongo')(session);
module.exports = function (app, express, config, mongoose) {
app.use(cookieParser());
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
app.use(function (req, res, next) {
// Website you wish to allow to connect
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:8080');
// Request methods you wish to allow
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
// Request headers you wish to allow
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With, X-AUTHENTICATION, X-IP, Content-Type, Origin, Accept, Cookie');
// Set to true if you need the website to include cookies in the requests sent
// to the API (e.g. in case you use sessions)
res.setHeader('Access-Control-Allow-Credentials', true);
// Pass to next layer of middleware
next();
});
/*app.use(function (req, res, next) {
console.log('coockie is:', req.cookies);
});*/
app.use(session({
saveUninitialized: false,
resave: false,
secret: config.sessionsSecretToken,
cookie: {
secure: false
},
store: new MongoStore({ mongooseConnection: mongoose.connection })
}));
app.use(express.static(path.join(__dirname, '..' , 'public')));
};
</code></pre>
<p>Passport configuration is here <a href="https://github.com/rantiev/template-api/blob/master/api/authentication/authenticationR.js">https://github.com/rantiev/template-api/blob/master/api/authentication/authenticationR.js</a></p>
<pre><code>var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var rememberMe = require('../../modules/rememberMe');
var createAccessToken = require('../../modules/createAccessToken');
var bcrypt = require('bcrypt-nodejs');
var UserM = require('../users/userM');
module.exports = function (app, mainRouter, role) {
passport.use(new LocalStrategy({
usernameField: 'email',
passwordField: 'password'
}, function (username, password, done) {
UserM.findOneQ({email: username})
.then(function(user){
if (user && bcrypt.compareSync(password, user.password)) {
done(null, user);
} else {
done(null, false);
}
})
.catch(function(err){
done(err);
});
}));
passport.serializeUser(function (user, done) {
console.log('serialize');
if (user) {
createAccessToken(user, done);
} else {
done(null, false);
}
});
passport.deserializeUser(function (token, done) {
console.log('deserialize');
UserM.findOneQ({accessToken: token})
.then(function(user){
if (user) {
done(null, user);
} else {
done(null, false);
}
})
.catch(function(err){
done(err);
});
});
app.use(passport.initialize());
app.use(passport.session());
mainRouter.post('/me', passport.authenticate('local'), function (req, res) {
res.status(200).send();
});
mainRouter.get('/logout', function (req, res) {
req.logout();
res.redirect('/');
});
mainRouter.get('/me', function (req, res) {
if (!req.user) {
res.status(401).send('Please Login!');
return;
}
var currentUser = {
id: req.user._id,
role: req.user.role
};
res.status(200).json(currentUser);
});
};
</code></pre>
| <express><passport.js> | 2016-03-27 15:30:27 | HQ |
36,250,802 | what does this line do flask.g.auth.logged_in? | <p>I was going through this piece of code:-</p>
<pre><code>def decorated_function(*args, **kwargs):
""" Decorated function, actually does the work. """
if not flask.g.auth.logged_in:
flask.flash('Login required', 'errors')
return flask.redirect(flask.url_for(
'login_fedora', next=flask.request.url))
return function(*args, **kwargs)
</code></pre>
<p>but i am not getting what this line <code>if not flask.g.auth.logged_in:</code> does?</p>
| <python><flask> | 2016-03-27 18:09:45 | LQ_CLOSE |
36,250,948 | Why is SQL Server Object Explorer in Visual Studio so slow? | <p>I just created a new SQL Server Database in Azure and then opened it in Visual Studio 2015 using the link in the Azure Portal. I had to add my IP to the firewall but otherwise the process went smoothly.</p>
<p>However, when I am trying to interact with the database server via SQL Server Object Explorer it is painfully slow. Expanding any of the folders in my Database (e.g., <code>Tables</code> folder) takes 10 to 30 seconds. The database is brand new, so the only things it has are whatever Azure creates when it instantiates a new DB.</p>
<p>This is the second Azure DB I have created and tried to view in Visual Studio and both have the same problem. With the first one I thought maybe I did something wrong during setup but this time I made sure to do everything by the book.</p>
<p>Running actual queries against the DB from within Visual Studio (right click the DB, <code>New Query ...</code>, <code>select * from INFORMATION_SCHEMA.TABLES;</code>) is very fast, so it doesn't appear to be a problem with my connection to Azure.</p>
<p>Why is it so painfully slow? What can I do to make it faster?</p>
<p>I am using Visual Studio 2015 Update 1 (<code>14.0.24720.00</code>) on Windows 10 (fully patched) and during database creation I checked the box to use the latest version.</p>
| <sql-server><visual-studio><azure><visual-studio-2015><azure-sql-database> | 2016-03-27 18:23:04 | HQ |
36,251,553 | Custom class extends AppCompatActivity: getResources() is recognized by IDE, but Context is not available | <p>Can't figure out why my following code is broken</p>
<p>I've got MainActivity class:</p>
<pre><code>public class MainActivity implements PresenterListener {
...
private Presenter presenter = new Presenter(this);
...
}
</code></pre>
<p>Presenter:</p>
<pre><code>public class Presenter extends PresenterUtils {
protected DateTimeFormatter dateFormat = DateTimeFormat.forPattern(getDateFormat());
}
</code></pre>
<p>PresenterUtils:</p>
<pre><code>public class PresenterUtils extends Utils {
public String getDateFormat() {
return getResources().getString(R.string.date_format);
}
}
</code></pre>
<p>Utils extends AppCompatActivity, so context has to be available for this class. But its not. I mean, IDE allows me to apply <code>getResources()</code> method, but I've got an exception right after launching:</p>
<blockquote>
<p>java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{...} java.lang.NullPointerException: Attempt to invoke
virtual method 'android.content.res.Resources
android.content.Context.getResources()' on a null object reference</p>
</blockquote>
<p>Exception points to <code>getResources().getString(R.string.date_format)</code></p>
<p>But! If I apply application context</p>
<pre><code>public class PresenterUtils extends Utils {
public String getDateFormat() {
return ContextProvider.getContext().getResources().getString(R.string.date_format);
}
}
</code></pre>
<p>where ContextProvider is</p>
<pre><code>public class ContextProvider extends Application {
private static ContextProvider instance;
public ContextProvider() {
instance = this;
}
public static Context getContext() {
return instance;
}
}
</code></pre>
<p>everything is fine</p>
<p>Why is that?</p>
| <java><android> | 2016-03-27 19:18:16 | LQ_CLOSE |
36,251,820 | Visual Studio Code: format is not using indent settings | <p>When using the <code>Format Code</code> command in Visual Studio Code, it is not honoring my indent settings (<code>"editor.tabSize": 2</code>). It is using a tab size of 4 instead. Any ideas why this is happening?</p>
<p>Thanks!</p>
| <visual-studio-code> | 2016-03-27 19:44:36 | HQ |
36,252,205 | search many min in java | <p>i'm newbie in java. i have problem search many min in java.
i have a big data. but example data like this.</p>
<pre><code> k[][] = [74 85 123
73 84 122
72 83 121
70 81 119
69 80 118
76 87 125
77 88 126
78 89 127];
</code></pre>
<p>and i want output like this.</p>
<pre><code>min1 = 69 min1 = 80 min1 = 118
min2 = 70 min2 = 81 min2 = 119
min3 = 72 min3 = 83 min3 = 121
</code></pre>
<p>i use sorting in this data but the results it's not eficient.
someone help me
thx</p>
| <java><arrays> | 2016-03-27 20:21:34 | LQ_CLOSE |
36,252,381 | Error on load image on React-native: Unexpected character | <p>I'm try display a image on a component on React-native, but I don't know why this error happens...</p>
<p>Example of code:</p>
<pre><code>render () {
let { convenience } = this.props
return (
<View style={{flexDirection: 'row', height: 50}}>
<Text style={{marginRight: 30}}>{convenience.name}</Text>
<Image source={require('./icons___favorito_ativo.png')} />
</View>
)
}
</code></pre>
<p>Printscreen:</p>
<p><a href="https://i.stack.imgur.com/FdZCI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FdZCI.png" alt="enter image description here"></a></p>
| <react-native> | 2016-03-27 20:39:10 | HQ |
36,252,434 | Predicting on new data using locally weighted regression (LOESS/LOWESS) | <p>How to fit a locally weighted regression in python so that it can be used to predict on new data?</p>
<p>There is <code>statsmodels.nonparametric.smoothers_lowess.lowess</code>, but it returns the estimates only for the original data set; so it seems to only do <code>fit</code> and <code>predict</code> together, rather than separately as I expected.</p>
<p><code>scikit-learn</code> always has a <code>fit</code> method that allows the object to be used later on new data with <code>predict</code>; but it doesn't implement <code>lowess</code>.</p>
| <python><python-3.x><pandas><statsmodels> | 2016-03-27 20:42:39 | HQ |
36,252,522 | Placeholder not working with angular2 (code attached in screenshot). My first post :) | [enter image description here][1]
[1]: http://i.stack.imgur.com/lDQWf.png
Plcaeholder not working with ANGULAR2. Please let me know if you require anything more? | <angular><angular2-forms> | 2016-03-27 20:52:32 | LQ_EDIT |
36,252,540 | Tensorflow apply op to each element of a 2d tensor | <p>What I'm after is the ability to apply a tensorflow op to each element of a 2d tensor e.g.</p>
<pre><code>input = tf.Variable([[1.0, 2.0], [3.0, 4.0])
myCustomOp = ... # some kind of custom op that operates on 1D tensors
finalResult = tf.[thing I'm after](input, myCustomOp)
# when run final result should look like: [myCustomOp([1.0, 2.0]), myCustomOp([3.0, 4.0)]
</code></pre>
<p>Any ideas?</p>
| <tensorflow> | 2016-03-27 20:54:03 | HQ |
36,253,818 | unexpected tidentifier expecting keyword_end | <p>I've got a problem in Ruby, "unexpected tidentifier expecting keyword_end", how Can I solve it?</p>
<pre><code>def riko(user)
if user.name.eql? 'Mia Khalifa Fan'
@client.send_msg 'Hola Mia <3 ¿Cómo te trato este dia, cosa guapa y sensual?',
else
if user.mame.eql? 'Skul Goy'
@client.send_msg 'Muerete. '
else
@client.send_msg "Hola #{user.name} o/ \ :v / "
end
end
</code></pre>
| <ruby><windows><syntax> | 2016-03-27 23:18:02 | LQ_CLOSE |
36,254,679 | How can I create a function to count the last n elements in a list in DrRacket (without list-ref)? | I know how to count the first elements in a list,
[(zero? n) '()]
[else (cons (first list) (function (rest list)))]
but how can I do something like this for the last n elements in a list **(without using list-ref)**? | <scheme><racket> | 2016-03-28 01:35:23 | LQ_EDIT |
36,254,789 | PHP performance difference conditions of if statement | <p>Hey quick question anyone knows if there is any performance difference between these 2 codes (PHP-7):</p>
<pre><code>public function isActive() : bool
{
if ($cond1) {
if ($cond2) {
return true;
}
}
return false;
}
</code></pre>
<p>and</p>
<pre><code>public function isActive() : bool
{
if ($cond1 && $cond2) {
return true;
}
return false;
}
</code></pre>
<p>(Yes I know the variables are not defined, question is about the if statements not the variables)</p>
<p>I ask this question because I'm focusing on readability of my code, but at same time maintaining my performance the best I can.</p>
<p>Even if it is just a very tiny performance difference (e.g 0.000000001%) I still like to know the answer.</p>
| <php><if-statement><conditional><conditional-statements><php-7> | 2016-03-28 01:50:19 | LQ_CLOSE |
36,254,914 | Error: Expected resource of type styleable [ResourceType] error | <p>Take a look at this code snippet.
I am getting an error with the last line, because I am passing an 'index' instead of a resource. I thought it was a lint issue and tried to suppress it.
Then I noticed I am getting this error only when I building for release. It works fine when building for debug. I am totally clueless. Can anyone throw some light into what I am doing wrong.</p>
<pre><code>//Get paddingLeft, paddingRight
int[] attrsArray = new int[]{
android.R.attr.paddingLeft, // 0
android.R.attr.paddingRight, // 1
};
TypedArray ta = context.obtainStyledAttributes(attrs, attrsArray);
if (ta == null) return;
mPaddingLeft = ta.getDimensionPixelSize(0, 0);
mPaddingRight = ta.getDimensionPixelSize(1/*error here*/, 0);
</code></pre>
| <android><android-studio><lint> | 2016-03-28 02:08:25 | HQ |
36,255,654 | how to add border around an image in opencv python | <p>If I have an image like below, how can I add border all around the image such that the overall height and width of the final image increases but the height and width of the original image stays as-is in the middle. </p>
<p><a href="https://i.stack.imgur.com/ZxORX.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/ZxORX.jpg" alt="enter image description here"></a></p>
| <python><opencv><computer-vision> | 2016-03-28 03:46:18 | HQ |
36,255,673 | I need to loop through the email addresses in a table within a SQL Database and All an Email | I was wondering if someone could help me. I've got a simple Suppliers table that has the Email Addresses for my Suppliers.
I need to loop through the email addresses 'SuppEmail' in the Suppliers table in the SQL Database 'SpecCars' and send them all the email below.
I've been at it for a few days now, looking on-line and trying many different variations, but no matter what I do, it only sends one email
to the first entry 'frontdesk@jacksauto.com.au' in the table and that's it. If you could help, that would be fantastic. It's an ASP.NET C# Solution.
// This is the Suppliers Table, it just has two record in there:
..................................................
use SpecCars
Go
CREATE table Suppliers(
SuppId INT IDENTITY(1,1) PRIMARY KEY,
SuppName NVARCHAR(60) NOT NULL,
SuppAddress NVARCHAR(150) NOT NULL,
SuppSuburb NVARCHAR(60) NOT NULL,
SuppState NVARCHAR(30) NOT NULL,
SuppPost NVARCHAR(10) NOT NULL,
SuppPhone NVARCHAR(10) NOT NULL,
SuppEmail NVARCHAR(100) NOT NULL,
SuppCode NVARCHAR(10) NOT NULL
)
Go
Command(s) completed successfully.
Insert into Suppliers (SuppName, SuppAddress, SuppSuburb, SuppState, SuppPost, SuppPhone, SuppEmail, SuppCode) values ('Jacks Auto', '2 Jill Street', 'Belgrade', 'VIC', '3299', '9555 4457', 'frontdesk@jacksauto.com.au', 'JACBLA')
Insert into Suppliers (SuppName, SuppAddress, SuppSuburb, SuppState, SuppPost, SuppPhone, SuppEmail, SuppCode) values ('Ultimate Lights', '205 Browns Road', 'Tullamarine', 'VIC', '3011', '9877 2255', 'orders@ultimatlights.com.au', 'ULTTUL')
(2 row(s) affected)
..................................................
//This is the code snippet :
SqlDataReader sqlData;
SqlConnection connection = new SqlConnection("Data Source=.;Initial Catalog=SpecCars;Integrated Security=True");
connection.Open();
sqlData = new SqlCommand("Select SuppEmail From Suppliers", connection).ExecuteReader();
int count = sqlData.FieldCount;
while (sqlData.Read())
{
for (int i = 0; i < count; i++)
{
string emailnew = sqlData[i].ToString();
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("myemail.com");
mailMessage.To.Add("myemail.com");
mailMessage.To.Add(emailnew);
//mailMessage.CC.Add(emailnew);
mailMessage.Subject = "Assembly Line Stop";
mailMessage.Priority = MailPriority.High;
mailMessage.Body = "Please be advised that the assembly line at Specialised Cars has STOPPED. You will be notified once the line has started again. Any Services between the LINE STOP and the LINE START will be carried out after 19:00 (7pm).";
mailMessage.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient("smtp-mail.myprovider.com", 587);
smtpClient.EnableSsl = true;
smtpClient.Credentials = new System.Net.NetworkCredential("myemail.com", "password");
smtpClient.Send(mailMessage);
}
}
connection.Close();
.................................................. | <asp.net><sql-server><smtpclient><sqldatareader> | 2016-03-28 03:48:22 | LQ_EDIT |
36,255,871 | How to open different websites in new tabs | I want to write small html/js code that when I open that file.html, 3 different websites open in 3 new tabs right away, can somebody help with the code? Im new in web development...thanks, much love | <javascript><html><desktop-application><desktop> | 2016-03-28 04:13:49 | LQ_EDIT |
36,256,336 | How to validate a textbox for a filepath entry? | <p>the cases are </p>
<ul>
<li>compulsory '\' char at the first</li>
<li>followed by alphanumeric </li>
<li>compulsory '\' char at the last</li>
</ul>
<p>eg:\abc\bvc\</p>
<p>\abc4\abc3\abc2\abc1\</p>
| <c#><regex><visual-studio-2015> | 2016-03-28 05:09:40 | LQ_CLOSE |
36,256,337 | CompletableFuture supplyAsync | <p>I've just started exploring some concurrency features of Java 8. One thing confused me a bit is these two static methods:</p>
<pre><code>CompletableFuture<Void> runAsync(Runnable runnable)
CompletableFuture<U> supplyAsync(Supplier<U> supplier)
</code></pre>
<p>Do anyone know why they choose to use interface Supplier? Isn't it more natural to use Callable, which is the analogy of Runnable that returns a value? Is that because Supplier doesn't throw an Exception that couldn't be handled?</p>
| <java><concurrency><java-8> | 2016-03-28 05:09:42 | HQ |
36,256,501 | Vector Drawable VS PNG | <p>What is Vector Drawable? How it differs from PNG? Is it possible to convert an PNG to vector Drawable in Android?</p>
<p>Below is the one vector Drawable, I have created in Studio.</p>
<pre><code><vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M22,16V4c0,-1.1 -0.9,-2 -2,-2H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2zm-11,-4l2.03,2.71L16,11l4,5H8l3,-4zM2,6v14c0,1.1 0.9,2 2,2h14v-2H4V6H2z" /> </vector>
</code></pre>
<p>What is the path data here?? How can I get that for PNG?</p>
| <android> | 2016-03-28 05:27:11 | LQ_CLOSE |
36,256,919 | How private and protected is implemented in C++ | <p>Internal mechanism of private and protected keywords in C++. How they restrict member variables accesses.</p>
| <c++> | 2016-03-28 06:09:24 | LQ_CLOSE |
36,257,056 | what is the best web designing source code editor? | <p>sublime text 2 is not supported output page,please tell me another best editor</p>
| <html><css> | 2016-03-28 06:21:28 | LQ_CLOSE |
36,257,370 | how can i declare pointer to different data types but they will occupy the same amount of space in memory | this is my code
int main()
{
char *pchar;
short *pshort;
int *pint;
long *plong;
float *pfloat;
double *pdouble;
pchar = pshort = pint = plong = pfloat = pdouble;
printf("sizeof *pchar is = %u\n",sizeof(pchar));
printf("sizeof *pshort is = %u\n",sizeof(pshort));
printf("sizeof *pint is = %u\n",sizeof(pint));
printf("sizeof *plong is = %u\n",sizeof(plong));
printf("sizeof *pfloat is = %u\n",sizeof(pfloat));
printf("sizeof *pdouble is = %u\n",sizeof(pdouble));
return 0;
}
/// i want Each of these pointer variables will point to different data types, but they will occupy the same amount of space in memory. how can i do that
---------- | <c> | 2016-03-28 06:47:38 | LQ_EDIT |
36,258,073 | I want to continus display of button in wpf | In my application I have 4 button. If user will click on a button, that will disappear and remaining 3 still display.
The problem is that I don't want a control (button) gap between button.
I want remaining 3 should rearrange itself.
Which control I should use or how I can implement that. I am using MVVM in my application. | <wpf><button><mvvm><responsive-design> | 2016-03-28 07:42:18 | LQ_EDIT |
36,258,201 | Is GT9800 supported compute_20? | I have NVIDIA GT9800 and CUDA-programm(sample). If I specify code generation as compute_20,sm_20 then the error "invalid device function" occured. With compute_11,sm_11 all correct. Why? | <cuda><nvidia> | 2016-03-28 07:53:25 | LQ_EDIT |
36,259,019 | How to get key and value of json array object in javascript? | I have below json array structure.. How can i get the key and value of each of the `records` json object?
{
"records": [{
"cfsub_2": "1",
"cf_7": "1/3/2016",
"cf_1": "Clinic San",
"cf_2": "Fever",
"cf_3": "56.60",
"cfe_8": "dsf4334"
}, {
"cfsub_2": "2",
"cf_7": "3/3/2016",
"cf_1": "Clinic Raju",
"cf_2": "braces",
"cf_3": "183.50",
"cfe_8": "fresr4"
}]
} | <javascript><json> | 2016-03-28 08:54:23 | LQ_EDIT |
36,259,054 | could someone explain how this code can be reversed? (recursion) | got code from Pierre Fourgeaud (internet) but i cant understand how it can be reversed?
void reverse( string& word )
{
if ( word.size() <= 1 ) return;
// Get the string without the first and the last char
string temp = word.substr( 1, word.size() - 2 );
// Reverse it
reverse( temp );
// Recompose the string
word = word.substr( word.size() - 1 ) + temp + word[0];
}
thanks. | <c++><visual-c++><recursion> | 2016-03-28 08:57:05 | LQ_EDIT |
36,259,227 | How to use Robot Frame Ride execute branch statement | I met a question with use Robot Framework Ride to test.
The test case structure as below:
----------------------------------
if A>B:
print 1
print 2
print 3
if C>D:
print 4
print 5
----------------------------------
I didn't find a way to execute multiples case below one "if". I found one keyword "Run Keyword if",but it can only execute one statement.
please tell me if you know how to resolve,thanks....
| <robotframework> | 2016-03-28 09:11:00 | LQ_EDIT |
36,259,947 | how to easily convert a java map to concurrentMap? | Is there any way to convert java8 `Map<K,V>` to `ConcurrentMap<K,V>` ?
other then iterating manually all entities?
| <java><dictionary><collections><concurrency> | 2016-03-28 09:59:44 | LQ_EDIT |
36,260,500 | How to register multiple beans using single @Bean-annotated method (or similar) in Spring? | <p>I have a class similar to the following:</p>
<pre><code>@Configuration
public class ApplicationConfiguration {
private <T> T createService(Class<T> serviceInterface) {
// implementation omitted
}
@Bean
public FooService fooService() {
return createService(FooService.class);
}
@Bean
public BarService barService() {
return createService(BarService.class);
}
...
}
</code></pre>
<p>The problem is that there are too many @Bean-annotated methods which differ only in their names, return types and arguments for the <code>crateService</code> method call.
I would like to make this class similar to the following:</p>
<pre><code>@Configuration
public class ApplicationConfiguration {
private static final Class<?>[] SERVICE_INTERFACES = {
FooSerivce.class, BarService.class, ...};
private <T> T createService(Class<T> serviceInterface) {
// implementation omitted
}
@Beans // whatever
public Map<String, Object> serviceBeans() {
Map<String, Object> result = ...
for (Class<?> serviceInterface : SERVICE_INTERFACES) {
result.put(/* calculated bean name */,
createService(serviceInterface));
}
return result;
}
}
</code></pre>
<p>Is it possible in Spring?</p>
| <java><spring><spring-java-config> | 2016-03-28 10:31:55 | HQ |
36,260,961 | how to automatically refresh the chat on receiving gcm notification | <p>i am developing chat application. I want to automatically refresh the chat on receiving notification. I have tried using timer but its not that good as it refreshes after certain time period.</p>
| <android><android-activity><google-cloud-messaging><chat> | 2016-03-28 11:01:41 | LQ_CLOSE |
36,261,051 | How to detect who is move white or black in python-chess library? | <p>I am created some chess program and want to detect who have move white or black. Which objects stores information which pieces will move <strong>Board</strong>, <strong>GameNode</strong>?</p>
<pre><code>import chess.pgn
import chess.uci
# ??? Board().is_white_move()?
# ??? GameNode.is_white_move()?
</code></pre>
<p>I analysed code but not found good explanation.</p>
| <python><chess><python-chess> | 2016-03-28 11:06:19 | LQ_CLOSE |
36,261,225 | Why Is `Export Default Const` invalid? | <p>I see that the following is fine:</p>
<pre><code>const Tab = connect( mapState, mapDispatch )( Tabs );
export default Tab;
</code></pre>
<p>However, this is incorrect:</p>
<pre><code>export default const Tab = connect( mapState, mapDispatch )( Tabs );
</code></pre>
<p>Yet this is fine:</p>
<pre><code>export default Tab = connect( mapState, mapDispatch )( Tabs );
</code></pre>
<p>Can this be explained please why <code>const</code> is invalid with <code>export default</code>? Is it an unnecessary addition & anything declared as <code>export default</code> is presumed a <code>const</code> or such? </p>
| <javascript><scope><export><constants><default> | 2016-03-28 11:16:20 | HQ |
36,261,407 | Do I need to delete this object? | <p>In MFC application using Direct2D I have very simple code:<br>
//in ctor: </p>
<pre><code>EnableD2DSupport();
m_pBlackBrush = new CD2DSolidColorBrush(GetRenderTarget(), D2D1::ColorF(D2D1::ColorF::Black));
</code></pre>
<p>Now the question is, am I supposed to call delete on m_pBlackBrush? If so where? I've tried to call delete on it in destructor but I'm getting error thrown in my face saying that there is write access violation. Anyone knows if am I supposed to delete this brush or simply leave it (which seems like rather odd idea)?</p>
| <c++><mfc> | 2016-03-28 11:28:44 | LQ_CLOSE |
36,261,710 | Map modify array of objects in Swift 2.2 (3.0) | <p>I want to be able to modify my array of objects using <code>map</code> in Swift of the fly, without looping through each element.</p>
<p>Before here were able to do something like this (Described in more details <a href="http://kelan.io/2016/mutating-arrays-of-structs-in-swift/" rel="noreferrer">here</a>:</p>
<pre><code>gnomes = gnomes.map { (var gnome: Gnome) -> Gnome in
gnome.age = 140
return gnome
}
</code></pre>
<p>Thanks for Erica Sadun and others, new proposals have gone through and we're now getting rid of C-style loops and using <code>var</code> inside the loop.</p>
<p>In my case I'm first getting a warning to remove the <code>var</code> in then an error my <code>gnome</code> is a constant (naturally)</p>
<p>My question is : How do we alter arrays inside a <code>map</code> or the new styled loops for that matter to be fully prepared for Swift 3.0?</p>
| <arrays><swift><map-function> | 2016-03-28 11:50:06 | HQ |
36,262,299 | Android Espresso testing 'Cannot resolve symbol 'InstrumentationRegistry'' | <p>I'm trying to import </p>
<pre><code> import android.support.test.InstrumentationRegistry;
</code></pre>
<p>my build.gradle file</p>
<pre><code>androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile 'com.android.support.test:rules:0.2'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
</code></pre>
<p>in default config:</p>
<pre><code>defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
</code></pre>
<p>Is there a library I'm missing here? I'm trying to import InstrumentationRegistry but it doesn't recognise it! </p>
| <android><unit-testing><junit><android-espresso> | 2016-03-28 12:27:18 | HQ |
36,262,912 | Where condition for joined table in Sequelize ORM | <p>I want to get query like this with sequelize ORM: </p>
<pre><code>SELECT "A".*,
FROM "A"
LEFT OUTER JOIN "B" ON "A"."bId" = "B"."id"
LEFT OUTER JOIN "C" ON "A"."cId" = "C"."id"
WHERE ("B"."userId" = '100'
OR "C"."userId" = '100')
</code></pre>
<p>The problem is that sequelise not letting me to reference "B" or "C" table in where clause. Following code</p>
<pre><code>A.findAll({
include: [{
model: B,
where: {
userId: 100
},
required: false
}, {
model: C,
where: {
userId: 100
},
required: false
}]
]
</code></pre>
<p>gives me</p>
<pre><code>SELECT "A".*,
FROM "A"
LEFT OUTER JOIN "B" ON "A"."bId" = "B"."id" AND "B"."userId" = 100
LEFT OUTER JOIN "C" ON "A"."cId" = "C"."id" AND "C"."userId" = 100
</code></pre>
<p>which is completely different query, and result of</p>
<pre><code>A.findAll({
where: {
$or: [
{'"B"."userId"' : 100},
{'"C"."userId"' : 100}
]
},
include: [{
model: B,
required: false
}, {
model: C,
required: false
}]
]
</code></pre>
<p>is no even a valid query:</p>
<pre><code>SELECT "A".*,
FROM "A"
LEFT OUTER JOIN "B" ON "A"."bId" = "B"."id"
LEFT OUTER JOIN "C" ON "A"."cId" = "C"."id"
WHERE ("A"."B.userId" = '100'
OR "A"."C.userId" = '100')
</code></pre>
<p>Is first query even possible with sequelize, or I should just stick to raw queries? </p>
| <javascript><sql><postgresql><orm><sequelize.js> | 2016-03-28 13:00:35 | HQ |
36,263,202 | How to fire browser back button event when I press a button inside the page? | <p>I want to load the previous page without postback when I click on a button in the current page.?</p>
<p>The same event should occur when we click on browser back button.</p>
| <javascript><asp.net><caching> | 2016-03-28 13:16:57 | LQ_CLOSE |
36,263,531 | Why any thread can unlock a semaphore? | I can not understand how Posix allows any thread to unlock (post) on a semaphore. Let's consider following example:
// sem1 and sem2 are a Posix semaphore,
// properly initialized for single process use
// at this point, sem2 is locked, sem1 is unlocked
// x and y are global (non-atomic, non-volatile) integer variables
// thread 1 - is executing right now
rc = sem_wait(&sem); // succeeded, semaphore is 0 now
x = 42;
y = 142;
sem_post(&sem2);
while (true);
// thread 2. waits for sem2 to be unlocked by thread1
sem_wait(&sem2);
sem_post(&sem1);
// thread 3
sem_wait(&sem1); // wakes up when sem1 is unlocked by thread2
#ifdef __cplusplus
std::cout << "x: " << x << ; y: " << y << "\n";
#else
printf("x: %d; y: %d\n", x, y);
#endif
Now, according to everything I've read, this code is 100% kosher for passover. In thread 3, we are guaranteed to see `x` as 42, `y` as 142. We are proteced from any race.
But this is what I can't understand. All those threads can potentially be executed on 3 different cores. And if the chip doesn't have internally strong memory ordering (ARM, PowerPC) or writes are not-atomic (x86 for unaligned data) how can thread2 on Core2 possibly request Core1 (busy with thread1) to properly release the data / complete writes / etc? As far as I know, there are no such commands!
What I am missing here?
| <c++><multithreading><posix><semaphore> | 2016-03-28 13:37:29 | LQ_EDIT |
36,264,093 | I want to show a data in my website which is form other website | <p>I am very new to this code world but I am really interested. Now I'm having a problem.</p>
<p>My Problems begins here-</p>
<p>This is an example. Imagine that I need a data form this website [Picture below]</p>
<p><a href="http://i.stack.imgur.com/h7trS.png" rel="nofollow">The Data I want form the website</a></p>
<p>You saw that there is <strong>Total Clicks: #Number#</strong></p>
<p>Now I want this <strong>Total Click: #Number#</strong> in my <strong>index.html</strong> which is located in my computer. Like this below [See Picture]</p>
<p><a href="http://i.stack.imgur.com/JEuXJ.png" rel="nofollow">What I really want</a></p>
<p>Please tell me is it possible. If yes please tell me the code should I use in it.</p>
<p>Thank you very much..</p>
| <php><html><web> | 2016-03-28 14:10:57 | LQ_CLOSE |
36,264,461 | C++ : How to arrange 4 values in an ascending order? | <p>Hello I know it may be a beginners question but I need help.
I need to compare between 4 values added by the user and arrange them in am ascending order by using a function that takes 2 inputs and return the smaller one. I know it can be done by arrays but I must not do it. I already have the function but I don't know how to use to do the trick without having a very long code. Thanks</p>
| <c++><function> | 2016-03-28 14:31:53 | LQ_CLOSE |
36,264,659 | How do I delete the last character in each line using vim | <p>I have a file:</p>
<pre><code>12345a
123456b
1234567c
12345678d
123456789e
</code></pre>
<p>How do I delete the last character in each line.<br>
And the file will be<br></p>
<pre><code>12345
123456
1234567
12345678
123456789
</code></pre>
| <vim><editor> | 2016-03-28 14:43:35 | HQ |
36,265,534 | Invoke-WebRequest SSL fails? | <p>When I try to use <code>Invoke-WebRequest</code> I'm getting some weird error:</p>
<pre><code>Invoke-WebRequest -Uri "https://idp.safenames.com/"
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
</code></pre>
<p>I'm not sure what's causing it, as the website itself seems fine.</p>
<p>Even with all the "ignore ssl errors" functions around stackoverflow, it's still not working, making me wonder if it's related to SSL at all.</p>
| <powershell><ssl> | 2016-03-28 15:32:43 | HQ |
36,265,630 | How to replace some characters in a string | <p>What is the best way to replace \n or \r or \r\n when they are between double quotes, with an empty string </p>
<p>using c#?</p>
<p>Example: "abc\ndef" should be "abcdef"</p>
| <c#> | 2016-03-28 15:38:04 | LQ_CLOSE |
36,265,639 | i aint getting why I m getting two outputs in place of a single one? | I m solving a simple program and i am getting 2 outputs of the same data with a single cout statement...probably something went wrong with my loop , which i am not able to find where is the problem...also...if possible please answer acc. to my code and my logic or if not then atleast specify why my logic is wrong...
My code:-
`
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n ;
cin >> n;
vector<int> arr(n);
vector<int> a(n);
for(int arr_i = 0;arr_i < n;arr_i++){
cin >> arr[arr_i];
a[arr_i]=1;
}
int i,least,flag,count=n;
do{
cout<<count<<endl;
count=0;
flag=1;
for(i=0;i<n;i++){ //for getting least number
if(a[i]){
if(flag){
least=arr[i];
flag=0;
}
if(arr[i]<least){
least=arr[i];
}
}
}
for(i=0;i<n;i++){ // for actual logic
if(arr[i]<=0||!a[i]){
a[i]=0;
//continue;
}
else{
arr[i]-=least;
count++;
}
}
}while(count);
return 0;
}
`
**Sample input:-**
`
6
5 4 4 2 2 8
`
**Sample output:- (Expected Output)**
6
4
2
1
`
**Output I 'm getting in this Sample input**:-
6
6
4
4
2
2
1
1
`
**Problem statement:-**
You are given N sticks, where the length of each stick is a positive integer. A cut operation is performed on the sticks such that all of them are reduced by the length of the smallest stick.
Suppose we have six sticks of the following lengths:
5 4 4 2 2 8
Then, in one cut operation we make a cut of length 2 from each of the six sticks. For the next cut operation four sticks are left (of non-zero length), whose lengths are the following:
3 2 2 6
The above step is repeated until no sticks are left.
Given the length of N sticks, print the number of sticks that are left before each subsequent cut operations.
**Note:** For each cut operation, you have to recalcuate the length of smallest sticks (excluding zero-length sticks). | <c++><algorithm> | 2016-03-28 15:38:26 | LQ_EDIT |
36,265,643 | Method Stubs in Java | <p>This is what I have to do:</p>
<p>Define stubs for the methods called by the below main(). Each stub should print "FIXME: Finish methodName()" followed by a newline, and should return -1. </p>
<p>FIXME: Finish getUserNum()</p>
<p>FIXME: Finish getUserNum()</p>
<p>FIXME: Finish computeAvg()</p>
<p>Avg: -1</p>
<p>Here is the code that I have written so far:</p>
<pre><code>import java.util.Scanner;
public class MthdStubsStatistics {
public static int methodName (int userNum1, int userNum2, int avgResult) {
System.out.println("FIXME: Finish getUserNum( )");
System.out.println("FIXME: Finish getUserNum( )");
System.out.println("FIXME: Finish computeAvg( )");
System.out.println("Avg: -1");
return 0;
}
public static void main() {
int userNum1 = 0;
int userNum2 = 0;
int avgResult = 0;
userNum1 = getUserNum();
userNum2 = getUserNum();
avgResult = computeAvg(userNum1, userNum2);
System.out.println("Avg: " + avgResult);
return;
}
}
</code></pre>
<p>I can only edit the public static int methodName section. I thought I knew how method stubs operated, but I guess not. I swear that I am doing something wrong that is simple, but if someone could please help me out, that would be great.</p>
| <java> | 2016-03-28 15:38:55 | LQ_CLOSE |
36,265,930 | How to sort in descending order with numpy? | <p>I have a numpy array like this:</p>
<pre><code>A = array([[1, 3, 2, 7],
[2, 4, 1, 3],
[6, 1, 2, 3]])
</code></pre>
<p>I would like to sort the rows of this matrix in descending order and get the arguments of the sorted matrix like this:</p>
<pre><code>As = array([[3, 1, 2, 0],
[1, 3, 0, 2],
[0, 3, 2, 1]])
</code></pre>
<p>I did the following:</p>
<pre><code>import numpy
A = numpy.array([[1, 3, 2, 7], [2, 4, 1, 3], [6, 1, 2, 3]])
As = numpy.argsort(A, axis=1)
</code></pre>
<p>But this gives me the sorting in ascending order. Also, after I spent some time looking for a solution in the internet, I expect that there must be an argument to <code>argsort</code> function from numpy that would reverse the order of sorting. But, apparently <strong>there is no such argument! Why!?</strong> </p>
<p>There is an argument called <code>order</code>. I tried, by guessing, <code>numpy.argsort(..., order=reverse)</code> but it does not work.</p>
<p>I looked for a solution in previous questions here and I found that I can do:</p>
<pre><code>import numpy
A = numpy.array([[1, 3, 2, 7], [2, 4, 1, 3], [6, 1, 2, 3]])
As = numpy.argsort(A, axis=1)
As = As[::-1]
</code></pre>
<p>For some reason, <code>As = As[::-1]</code> does not give me the desired output.</p>
<p>Well, I guess it must be simple but I am missing something.</p>
<p>How can I sort a numpy array in descending order?</p>
| <python><sorting><numpy> | 2016-03-28 15:55:40 | HQ |
36,266,389 | What is the average migrate time from SVN to GIT using Subgit | <p>I would like to use subgit to migrate all branches, tags and trunks from svn to git. What is average time it takes to import everything from svn to git using subgit?</p>
| <git><svn><migration><subgit> | 2016-03-28 16:23:34 | LQ_CLOSE |
36,266,404 | How to fix Error: this class is not key value coding-compliant for the key tableView.' | <p>I made an app with <code>Table View</code> and <code>Segmented Control</code>, and this is my first time. I'm using some code and some tutorials, but It's not working. When I run my app It's crashing and it's showing this Error in logs:</p>
<blockquote>
<p>MyApplication[4928:336085] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key tableView.'
* First throw call stack:
(
0 CoreFoundation 0x000000010516fd85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000105504deb objc_exception_throw + 48
2 CoreFoundation 0x000000010516f9c9 -[NSException raise] + 9
3 Foundation 0x000000010364e19b -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288
4 UIKit 0x0000000103c37d0c -[UIViewController setValue:forKey:] + 88
5 UIKit 0x0000000103e6e7fb -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x00000001050a9890 -[NSArray makeObjectsPerformSelector:] + 224
7 UIKit 0x0000000103e6d1de -[UINib instantiateWithOwner:options:] + 1864
8 UIKit 0x0000000103c3e8d6 -[UIViewController _loadViewFromNibNamed:bundle:] + 381
9 UIKit 0x0000000103c3f202 -[UIViewController loadView] + 178
10 UIKit 0x0000000103c3f560 -[UIViewController loadViewIfRequired] + 138
11 UIKit 0x0000000103c3fcd3 -[UIViewController view] + 27
12 UIKit 0x000000010440b024 -[_UIFullscreenPresentationController _setPresentedViewController:] + 87
13 UIKit 0x0000000103c0f5ca -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 133
14 UIKit 0x0000000103c525bb -[UIViewController _presentViewController:withAnimationController:completion:] + 4002
15 UIKit 0x0000000103c5585c -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 489
16 UIKit 0x0000000103c5536b -[UIViewController presentViewController:animated:completion:] + 179
17 UIKit 0x00000001041feb8d __67-[UIStoryboardModalSegueTemplate newDefaultPerformHandlerForSegue:]_block_invoke + 243
18 UIKit 0x00000001041ec630 -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 460
19 UIKit 0x00000001041ec433 -[UIStoryboardSegueTemplate _perform:] + 82
20 UIKit 0x00000001041ec6f7 -[UIStoryboardSegueTemplate perform:] + 156
21 UIKit 0x0000000103aa6a8d -[UIApplication sendAction:to:from:forEvent:] + 92
22 UIKit 0x0000000103c19e67 -[UIControl sendAction:to:forEvent:] + 67
23 UIKit 0x0000000103c1a143 -[UIControl _sendActionsForEvents:withEvent:] + 327
24 UIKit 0x0000000103c19263 -[UIControl touchesEnded:withEvent:] + 601
25 UIKit 0x0000000103b1999f -[UIWindow _sendTouchesForEvent:] + 835
26 UIKit 0x0000000103b1a6d4 -[UIWindow sendEvent:] + 865
27 UIKit 0x0000000103ac5dc6 -[UIApplication sendEvent:] + 263
28 UIKit 0x0000000103a9f553 _UIApplicationHandleEventQueue + 6660
29 CoreFoundation 0x0000000105095301 _CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION_ + 17
30 CoreFoundation 0x000000010508b22c __CFRunLoopDoSources0 + 556
31 CoreFoundation 0x000000010508a6e3 __CFRunLoopRun + 867
32 CoreFoundation 0x000000010508a0f8 CFRunLoopRunSpecific + 488
33 GraphicsServices 0x000000010726dad2 GSEventRunModal + 161
34 UIKit 0x0000000103aa4f09 UIApplicationMain + 171
35 Dhikr 0x0000000101f26282 main + 114
36 libdyld.dylib 0x00000001064c392d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException</p>
</blockquote>
<p>The code that I used is: </p>
<pre><code>class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
let foodList:[String] = ["Bread", "Meat", "Pizza", "Other"]
let drinkList:[String] = ["Water", "Soda", "Juice", "Other"]
@IBOutlet weak var mySegmentedControl: UISegmentedControl!
@IBOutlet weak var myTableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
var returnValue = 0
switch(mySegmentedControl.selectedSegmentIndex) {
case 0:
returnValue = foodList.count
break
case 1:
returnValue = drinkList.count
break
default:
break
}
return returnValue
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let myCell = tableView.dequeueReusableCellWithIdentifier("myCells", forIndexPath: indexPath)
switch(mySegmentedControl.selectedSegmentIndex) {
case 0:
myCell.textLabel!.text = foodList[indexPath.row]
break
case 1:
myCell.textLabel!.text = drinkList[indexPath.row]
break
default:
break
}
return myCell
}
@IBAction func segmentedControlActionChanged(sender: AnyObject) {
myTableView.reloadData()
}
</code></pre>
<p>Here is <strong>main.Storyboard</strong></p>
<p><a href="https://i.stack.imgur.com/Q1ig6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Q1ig6.png" alt="enter image description here"></a></p>
<p>I checked the code many times, but it's not working. First I had to use only <code>Table View</code>, watching this tutorial (<a href="https://www.youtube.com/watch?v=ABVLSF3Vqdg" rel="noreferrer">https://www.youtube.com/watch?v=ABVLSF3Vqdg</a>) I thought it will work to use <code>Segmented Control</code> as in tutorial. But still doesn't work. Same code, same error.
Can someone help me ?</p>
| <swift><uitableview><uisegmentedcontrol> | 2016-03-28 16:24:29 | HQ |
36,266,746 | ActionCable Not Receiving Data | <p>I created the following using ActionCable but not able to receive any data that is being broadcasted.</p>
<p><strong>Comments Channel</strong>:</p>
<pre><code>class CommentsChannel < ApplicationCable::Channel
def subscribed
comment = Comment.find(params[:id])
stream_for comment
end
end
</code></pre>
<p><strong>JavaScript</strong>:</p>
<pre><code>var cable = Cable.createConsumer('ws://localhost:3000/cable');
var subscription = cable.subscriptions.create({
channel: "CommentsChannel",
id: 1
},{
received: function(data) {
console.log("Received data")
}
});
</code></pre>
<p>It connects fine and I can see the following in the logs:</p>
<pre><code>CommentsChannel is streaming from comments:Z2lkOi8vdHJhZGUtc2hvdy9FdmVudC8x
</code></pre>
<p>I then broadcast to that stream:</p>
<pre><code>ActionCable.server.broadcast "comments:Z2lkOi8vdHJhZGUtc2hvdy9FdmVudC8x", { test: '123' }
</code></pre>
<p>The issue is that the <code>received</code> function is never called. Am I doing something wrong?</p>
<p>Note: I'm using the <code>actioncable</code> npm package to connect from a BackboneJS application.</p>
| <ruby-on-rails><actioncable> | 2016-03-28 16:44:40 | HQ |
36,267,203 | I have a list of URL's and I want to know to which html div each URL belongs in a HTML page | <p>I have a list of URL's and I want to know to which html div each URL belongs in a HTML page
I have to do it using java</p>
| <java><html><jsoup> | 2016-03-28 17:13:42 | LQ_CLOSE |
36,268,092 | How to use HttpClientBuilder with Http proxy? | <p>I am trying to set proxy for a request I am making using <code>HttpClientBuilder</code> as follows:</p>
<pre><code> CredentialsProvider credsProvider = new BasicCredentialsProvider();
UsernamePasswordCredentials usernamePasswordCredentials = new UsernamePasswordCredentials(proxyUser, proxyPassword);
credsProvider.setCredentials(new AuthScope(proxyHost, proxyPort), usernamePasswordCredentials);
builder.useSystemProperties();
builder.setProxy(new HttpHost(proxyHost, proxyPort));
builder.setDefaultCredentialsProvider(credsProvider);
builder.setProxyAuthenticationStrategy(new ProxyAuthenticationStrategy());
</code></pre>
<p>where builder is:</p>
<pre><code> HttpClientBuilder builder = HttpClientBuilder.create();
</code></pre>
<p>However, I get this exception when I execute this request:</p>
<pre><code>java.lang.RuntimeException: org.apache.http.conn.UnsupportedSchemeException: http protocol is not supported
Caused by: org.apache.http.conn.UnsupportedSchemeException: http protocol is not supported
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:108) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.conn.BasicHttpClientConnectionManager.connect(BasicHttpClientConnectionManager.java:338) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:388) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55) ~[httpclient-4.5.1.jar:4.5.1]
</code></pre>
<p>(exception shortened for brevity)</p>
<p>Since this is an HTTP proxy, I don't want to change the scheme to HTTPS, which anyways won't work. How do I get this working?</p>
| <java><http><proxy><squid> | 2016-03-28 18:03:06 | HQ |
36,268,111 | How lunch a html using angularJS | I want to make a button and when I click on it lunch a html page. How can I do it.
Here is the incomplete example:`<button ng-model="status" ng-init="status=true" ng-click="status=!status">
<span ng-show="status == true" >Activo</span>
<span ng-show="status == false">Desactivo</span>
</button>
`
Thanks for all. | <angularjs><button> | 2016-03-28 18:04:28 | LQ_EDIT |
36,268,272 | Nginx - Allowing origin IP | <p>Nginx supports <code>allow</code> and <code>deny</code> syntax to restrict IPs, e.g. <code>allow 192.168.1.1;</code>. But if traffic goes through a reverse proxy, the IP will refer to the proxy's IP. So how can it be configured to whitelist a specific origin IP and deny all other incoming requests?</p>
| <nginx><proxy><whitelist> | 2016-03-28 18:13:14 | HQ |
36,268,340 | Xcode: Cannot parse the debug map for .. is a directory | <p>I'm trying to link my iPhone simulator project and I'm getting the following error at link time:</p>
<pre><code>(null): error: cannot parse the debug map for "/Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app/TrainTracks": Is a directory
</code></pre>
<p>Here's the linker output:</p>
<pre><code>GenerateDSYMFile /Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app.dSYM /Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app/TrainTracks
cd /Work/TrainTracks/TrainTracks
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil /Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app/TrainTracks -o /Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app.dSYM
error: cannot parse the debug map for "/Users/admin/Library/Developer/Xcode/DerivedData/TrainTracks-agvvryrtufplkxecblncwedcelck/Build/Products/Debug-iphonesimulator/TrainTracks.app/TrainTracks": Is a directory
</code></pre>
<p>What would cause this problem?</p>
<p>I started off with a Game template (Xcode 7.2.1) and deleted the main story board and AppDelegate.* files since this is an SDL cross-platform project.</p>
| <ios><iphone><xcode><linker><ios-simulator> | 2016-03-28 18:16:10 | HQ |
36,268,348 | java buble sort code problems | Write a computer program that prompts the user for a number, creates an array for that number of random integers, and then uses the bubble sort to order the array. The program should print out the array prior to the call to the sorting algorithm and afterwards.
I have most of the buble sort working, it is just the implementation of the random integers and user input for the size of the array that I can't seem to figure out.
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Random;
class Test
{
public static void main (String[] args) throws java.lang.Exception
{
int n, c, d, swap;
Scanner in = new Scanner(System.in);
Random r = new Random();
System.out.println("enter number of elements to sort");
n = r.nextInt();
int array[] = new int[n];
for (c = 0; c < n; c++)
array[c] = r.nextInt();
for (c = 0; c < ( n - 1 ); c++) {
for (d = 0; d < n - c - 1; d++) {
if (array[d] > array[d+1]) {
swap = array[d];
array[d] = array[d+1];
array[d+1] = swap;
}
}
}
System.out.println("Sorted array :");
for (c = 0; c < n; c++)
System.out.println(array[c]);
}
} | <java><arrays><sorting> | 2016-03-28 18:16:36 | LQ_EDIT |
36,268,472 | Apply CSS to all but last element? | <p>I've got the following html:</p>
<pre><code><ul class="menu">
<li><a>list item 1</a></li>
<li><a>list item 2</a></li>
...
<li><a>list item 5</a></li>
</ul>
</code></pre>
<p>I want to apply a border to all the <code><a></code> elements except the last one. </p>
<p>I've been trying this:</p>
<pre><code>.menu a {
border-right: 1px dotted #ccc;
}
.menu a:last-of-type {
border-right: none;
}
</code></pre>
<p>but I end up with a border on none of the elements, I guess because the <code><a></code> in each case is the last of type. </p>
<p>How can I do this? I'd prefer to use only CSS if possible, and I'd like IE9 compatibility if possible. </p>
| <html><css> | 2016-03-28 18:22:20 | HQ |
36,268,490 | How to use ng-repeat in angularjs with using array? | myApp.controller("myctrl", function($scope) {
$scope.fullname = [
{ fname: 'Mohil', age: '25', city: 'San Jose', zip:'95112' },
{ fname: 'Darshit', age: '25', city: 'San Jose', zip:'95112'},
{ fname: 'Suchita', age: '25', city: 'Santa Clara', zip:'95182'} | <javascript><angularjs> | 2016-03-28 18:23:26 | LQ_EDIT |
36,268,668 | How can I find a particular string among a list of file names in Ruby? | Newb question here. I need to search through a list of files that all end in .feature and then look for certain words in each file (POST, GET, PUT, and DELETE) so I can later update each file. I have been able to isolate each .feature file but I can't seem to figure out yet how to find each file that has the above words.
featureLocation = puts Dir.glob "**/*.feature" # show all feature files
puts featureLocation
I used the above to show the feature files.
I tried numerous ways to iterate through each file to find the words but no luck yet. Total newb here!
Thanks | <ruby> | 2016-03-28 18:32:46 | LQ_EDIT |
36,268,720 | New to ruby --- getting the wrong count assigned to a variable | I am trying to store the highest count to a variable. I seem to show the right counts when I loop through my array but the assignment to the high count variable always seems to be the count of the last item checked in the array.
def calculate_word_frequency(content, line_number)
looper = 0
wordCounter = ""
#CREATE AN ARRAY FROM EACH LINE
myArray = content.split
#LOOP THROUGH ARRAY COUNTING INSTANCES OF WORDS
while looper < myArray.length
p myArray[looper]
wordCounter = myArray[looper]
puts myArray.count(wordCounter)
if highest_wf_count < myArray.count
highest_wf_count = myArray.count
end
looper +=1
end
puts highest_wf_count
end
Any help would be appreciated | <ruby> | 2016-03-28 18:36:26 | LQ_EDIT |
36,268,749 | Remove multiple items from a Python list in just one statement | <p>In python, I know how to remove items from a list.</p>
<pre><code>item_list = ['item', 5, 'foo', 3.14, True]
item_list.remove('item')
item_list.remove(5)
</code></pre>
<p>This above code removes the values 5 and 'item' from item_list.
But when there is a lot of stuff to remove, I have to write many lines of </p>
<pre><code>item_list.remove("something_to_remove")
</code></pre>
<p>If I know the index of what I am removing, I use:</p>
<pre><code>del item_list[x]
</code></pre>
<p>where x is the index of the item I want to remove.</p>
<p>If I know the index of all of the numbers that I want to remove, I'll use some sort of loop to <code>del</code> the items at the indices. </p>
<p>But what if I don't know the indices of the items I want to remove?</p>
<p>I tried <code>item_list.remove('item', 'foo')</code>, but I got an error saying that <code>remove</code> only takes one argument. </p>
<p>Is there a way to remove multiple items from a list in a single statement?</p>
<p>P.S. I've used <code>del</code> and <code>remove</code>. Can someone explain the difference between these two, or are they the same?</p>
<p>Thanks</p>
| <python> | 2016-03-28 18:38:13 | HQ |
36,269,488 | How do I make a Null character in Kotlin | <p>In Java, one can use the escape sequence <code>\0</code> to represent the <a href="https://en.wikipedia.org/wiki/Null_character" rel="noreferrer">Null character</a></p>
<p><code>\0</code> and <code>\0000</code> are not valid escape sequences in Kotlin, so I've been using a static java char and accessing that from Kotlin.</p>
<pre><code>public class StringUtils{
public static char escapeChar = '\0';
}
</code></pre>
<p>Is there a Null character literal, or a better way of doing this in Kotlin?</p>
| <java><kotlin> | 2016-03-28 19:19:46 | HQ |
36,269,689 | JavaScript get td from table | <p>I have a table with tbodies. I want to create a array with the values in the first td of with tbody. How can I do that?</p>
<p>My html:</p>
<pre><code><table id="myTable">
<thead>
<tr>
<th>Test1</th>
</tr>
</thead>
<tbody>
<tr>
<td>Val1</td>
<td></td>
<td></td>
</tr>
</tbody>
<tbody>
<tr>
<td>Val2</td>
<td></td>
<td></td>
</tr>
</tbody>
<tbody>
<tr>
<td>Val3</td>
<td></td>
<td></td>
</tr>
</tbody>
<tbody>
<tr>
<td>Val4</td>
<td></td>
<td></td>
</tr>
</tbody>
</code></pre>
<p></p>
<p>My array should have the values: Val1, Val2, Val3, Val4</p>
| <javascript><html> | 2016-03-28 19:33:05 | LQ_CLOSE |
36,269,742 | C command similar to "if x in list" of Python | <p>In Python we could use <code>if x in list:</code> so I was wondering if there's a similar command in C, so that we don't have to go through the whole thing using a <code>for</code>.</p>
| <python><c><if-statement><for-loop> | 2016-03-28 19:36:59 | LQ_CLOSE |
36,269,768 | java interface methods usage | <p>Hi I have been given the following interface and I need to implement bag using this interface, I'm a little confuse as how to use the methods, any help/hint would be appreciated. I need to add items to the bag and it should be able to accept duplicate items. Then I have remove an item and find an item.</p>
<pre><code>public interface Things<T> extends Iterable<T> {
public int size();
public boolean add(T x);
public T remove(T x);
public T find(T x);
public void clear();
}
//Implementing thing using bag
public class Bag<T> implements Things<T> {
@Override
public int size() {
// TODO Auto-generated method stub
return 0;
}
@Override
public String add(T x) {
// TODO Auto-generated method stub
return null;
}
@Override
public String remove(T x) {
// TODO Auto-generated method stub
return null;
}
@Override
public String find(T x) {
// TODO Auto-generated method stub
return null;
}
}
public class ThingsDemo {
public static void main(String args[])
{
How to I use add(), remove(), and find method here?
}
}
</code></pre>
| <java><interface><implementation> | 2016-03-28 19:38:36 | LQ_CLOSE |
36,270,212 | VBA Looping through a Collection | <p>I have a collection of files that I selected in the SelectManyFiles function and I want to run multiple private subs on each Drawing in the collection function. Here's my code:</p>
<pre><code>Sub Main()
Dim Drawing As Object
Dim Drawings As Collection
Set Drawings = SelectManyFiles()
For Each Drawing In Drawings
'Call multiple private subs to run on each drawing
Next Drawing
End Sub
</code></pre>
<p>I think there's something wrong with the loop but not sure exactly! Any help is appreciated.</p>
| <vba><loops><collections><autocad> | 2016-03-28 20:05:15 | HQ |
36,270,602 | How to access Kubernetes UI via browser? | <p>I have installed Kubernetes using <a href="https://github.com/kubernetes/contrib" rel="noreferrer">contrib/ansible</a> scripts.
When I run cluster-info:</p>
<pre><code>[osboxes@kube-master-def ~]$ kubectl cluster-info
Kubernetes master is running at http://localhost:8080
Elasticsearch is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/elasticsearch-logging
Heapster is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/heapster
Kibana is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/kibana-logging
KubeDNS is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/kube-dns
kubedash is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/kubedash
Grafana is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-grafana
InfluxDB is running at http://localhost:8080/api/v1/proxy/namespaces/kube-system/services/monitoring-influxdb
</code></pre>
<p>The cluster is exposed on localhost with insecure port, and exposed on secure port 443 via ssl</p>
<p><code>kube 18103 1 0 12:20 ? 00:02:57 /usr/bin/kube-controller-manager --logtostderr=true --v=0 --master=https://10.57.50.161:443 -- kubeconfig=/etc/kubernetes/controller-manager.kubeconfig --service-account-private-key-file=/etc/kubernetes/certs/server.key --root-ca-file=/etc/kubernetes/certs/ca.crt
kube 18217 1 0 12:20 ? 00:00:15 /usr/bin/kube-scheduler --logtostderr=true --v=0 --master=https://10.57.50.161:443 --kubeconfig=/etc/kubernetes/scheduler.kubeconfig
root 27094 1 0 12:21 ? 00:00:00 /bin/bash /usr/libexec/kubernetes/kube-addons.sh
kube 27300 1 1 12:21 ? 00:05:36 /usr/bin/kube-apiserver --logtostderr=true --v=0 --etcd-servers=http://10.57.50.161:2379 --insecure-bind-address=127.0.0.1 --secure-port=443 --allow-privileged=true --service-cluster-ip-range=10.254.0.0/16 --admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota --tls-cert-file=/etc/kubernetes/certs/server.crt --tls-private-key-file=/etc/kubernetes/certs/server.key --client-ca-file=/etc/kubernetes/certs/ca.crt --token-auth-file=/etc/kubernetes/tokens/known_tokens.csv --service-account-key-file=/etc/kubernetes/certs/server.crt
</code></p>
<p>I have copied the certificates from kube-master machine to my local machine, I have installed the ca root certificate. The chrome/safari browsers are accepting the ca root certificate.
When I'm trying to access the <a href="https://10.57.50.161/ui" rel="noreferrer">https://10.57.50.161/ui</a>
I'm getting the 'Unauthorized'</p>
<p>How can I access the kubernetes ui?</p>
| <ssl><https><kubernetes> | 2016-03-28 20:27:23 | HQ |
36,270,873 | AWS EC2 Auto Scaling Groups: I get Min and Max, but what's Desired instances limit for? | <p>When you setup an Auto Scaling groups in AWS EC2 <code>Min</code> and <code>Max</code> bounds seem to make sense:</p>
<ul>
<li>The minimum number of instances to scale down to based on policies</li>
<li>The maximum number of instances to scale up to based on policies</li>
</ul>
<p>However, I've never been able to wrap my head around what the heck <code>Desired</code> is intended to affect.</p>
<p>I've always just set <code>Desired</code> equal to <code>Min</code>, because generally, I want to pay Amazon the minimum tithe possible, and unless you need an instance to handle load it should be at the <code>Min</code> number of instances.</p>
<p>I know if you use <code>ElasticBeanstalk</code> and set a <code>Min</code> to 1 and <code>Max</code> to 2 it sets a <code>Desired</code> to 2 (of course!)--you can't choose a value for <code>Desired</code>.</p>
<p>What would be the use case for a different <code>Desired</code> number of instances and how does it differ? When you expect AWS to scale lower than your <code>Desired</code> if desired is larger than <code>Min</code>?</p>
| <amazon-web-services><amazon-ec2><amazon-elastic-beanstalk><autoscaling> | 2016-03-28 20:45:32 | HQ |
36,271,238 | Setting Background Color Of Button in WPF on runtime | <p>I am trying to set Background Color of Button(Names: b0,b1,b2,b3,b4,b5,b6,b7,b8,b9) in WPF on runtime. </p>
<p>Color Name is getting from Database that is Red right now. But it's giving me System.NullReferenceExceptionn: Object reference not set to an instance of an object</p>
<pre><code>private void ButtonBgColor()
{
string qryBgColor = "select Name from lookup where code in (select VALUE from qSettings where name='BUTTON_BG_COLOR') and type='BgColor'";
try
{
sqlConnection.Open();
sqlCommand = new SqlCommand(qryBgColor, sqlConnection);
sqlDataReader = sqlCommand.ExecuteReader();
if (sqlDataReader.Read())
{
string BUTTON_BG_COLOR = sqlDataReader["Name"].ToString();
Button[] b = new Button[9];
for (int i = 0; i < b.Length; i++)
{
var textBlock08 = (TextBlock)b[i].Template.FindName("myTextBlock", b[i]);
textBlock08.Background = (System.Windows.Media.SolidColorBrush)new System.Windows.Media.BrushConverter().ConvertFromString(BUTTON_BG_COLOR);
}
}
}
catch (Exception exp)
{
MessageBox.Show(exp.ToString(), "Button Background Color Exception");
}
</code></pre>
<p>Can anyone help me to resolve this problem ?</p>
<p>Thanks in advance</p>
| <c#><wpf><database><button><background> | 2016-03-28 21:08:59 | LQ_CLOSE |
36,271,413 | pandas - Merge nearly duplicate rows based on column value | <p>I have a <code>pandas</code> dataframe with several rows that are near duplicates of each other, except for one value. My goal is to merge or "coalesce" these rows into a single row, without summing the numerical values. </p>
<p>Here is an example of what I'm working with:</p>
<pre><code>Name Sid Use_Case Revenue
A xx01 Voice $10.00
A xx01 SMS $10.00
B xx02 Voice $5.00
C xx03 Voice $15.00
C xx03 SMS $15.00
C xx03 Video $15.00
</code></pre>
<p>And here is what I would like:</p>
<pre><code>Name Sid Use_Case Revenue
A xx01 Voice, SMS $10.00
B xx02 Voice $5.00
C xx03 Voice, SMS, Video $15.00
</code></pre>
<p>The reason I don't want to sum the "Revenue" column is because my table is the result of doing a pivot over several time periods where "Revenue" simply ends up getting listed multiple times instead of having a different value per "Use_Case". </p>
<p>What would be the best way to tackle this issue? I've looked into the <code>groupby()</code> function but I still don't understand it very well.</p>
| <python><pandas> | 2016-03-28 21:22:52 | HQ |
36,271,702 | C# Read (not write!) string from System.Net.Http.StringContent | <p>I have what seems like it should be a simple question, but I can't find an answer to it anywhere. Given the following code:</p>
<pre><code> using System.Net.Http;
...
StringContent sc = New StringContent("Hello!");
string myContent = ???;
</code></pre>
<p>What do I need to replace the <code>???</code> with in order to read the string value from <code>sc</code>, so that <code>myContent = "Hello!"</code>?</p>
<p><code>.ToString</code> just returns System.String, as does <code>.ReadAsStringAsync</code>. How do I read out what I've written in?</p>
| <c#><asp.net-web-api><system.net> | 2016-03-28 21:40:50 | HQ |
36,272,514 | The report definition has an invalid target namespace rsInvalidReportDefinition | <p>I have created a ReportProject with Visual Studio data tools 2015. When I create a report.rdl file using the report wizard, the rdl file has schema for 2016. My reporting server is of version 12.0.4213.0. </p>
<p>How can I create a report.rdl which is compatible with my reporting server. I tried changing the TargetServerVersion by right clicking the project -> properties and changing the targetserverversion to "Sql server 2008 R2, 2012 or 2014". But this doesn't work either.</p>
| <sql-server><visual-studio><reporting-services><ssrs-2012><sql-server-2012-datatools> | 2016-03-28 22:48:32 | HQ |
36,272,769 | bash print 10 odd numbers then 10 even numbers | <p>How can I print 10 odd numbers and then the 10 even numbers then the next 10 odd numbers then the next 10 even numbers and so on.
Something like this: </p>
<p>1
3
5
7
9
11
13
15
17
19
2
4
6
8
10
12
14
16
18
20</p>
<p>21
23
25
27
29
31
33
35
37
39
22
24
26
28
30
32
34
36
38
40
...</p>
<p>I know how to print each apart but combined I have no idea how to start.</p>
| <bash> | 2016-03-28 23:14:00 | LQ_CLOSE |
36,273,127 | Java remove duplicated array | how to remove the duplicated entry from this array code:
Iterator<IHTTPStreamerSession> iterHttp = httpSessions.iterator();
while(iterHttp.hasNext())
{
IHTTPStreamerSession httpSession = iterHttp.next();
if (httpSession == null)
continue;
ret.append("<HTTPSession>");
ret.append("<IpAddress>"+httpSession.getIpAddress()+"</IpAddress>");
ret.append("<TimeRunning>"+httpSession.getTimeRunningSeconds()+"</TimeRunning>");
ret.append("</HTTPSession>");
}
I need to generate only 1 entry for each < IpAddress > | <java><arrays> | 2016-03-28 23:50:15 | LQ_EDIT |
36,273,422 | C++: Binary Heap | <p>I'm working on a C++ implementation of a Binary Heap, but I'm having some issues getting started. Here's a snippet of my code:</p>
<pre><code>class binaryHeap {
public:
// Constructor
binaryHeap(int _capacity)
{
// initializes the binary heap with a capacity, size, and space in memory
_size = 0;
_n = ceil(pow(2, log10(_capacity)/log10(2)));
_heap = new int[_n];
}
~binaryHeap(void)
{
delete[] _heap;
}
/* Omitted: insert, remove, size, capacity functions
Not necessary to the issue I'm having */
private:
int _size;
int _capacity;
int _n;
int *_heap;
};
</code></pre>
<p>In the main.cpp file, when I write the following line:</p>
<pre><code>struct BinaryHeap heap(10);
</code></pre>
<p>I get the error: <em>Variable has incomplete type 'struct BinaryHeap'</em>. Any ideas what is causing this?</p>
| <c++> | 2016-03-29 00:24:39 | LQ_CLOSE |
36,273,933 | Disable the "a" attribute underline? | <p>I was wondering how you would disable to underline on the "a" attribute, for href's. I find it annoying, and I was wondering if there was a bit of code I could add to my .css to change it. Thank you.</p>
| <html><css> | 2016-03-29 01:35:48 | LQ_CLOSE |
36,273,983 | How do you sort a list of objects based on there properties? | #I'm trying to sort a list of objects based on their Ids.
When I create a funtion that compares the Id of to objects in a list, It gets the error: Severity Code Description Project File Line Suppression State
Error C3867 'BobControl::compareId': non-standard syntax; use '&' to create a pointer to member list.sort c:\users\wil\documents\visual studio 2015\projects\list.sort\list.sort\source.cpp 32
This code was used to test the issue.
#include <iostream>
#include <list>
#include <string>
using namespace std;
class Bob {
public:
Bob::Bob(int id) {
_id = id;
}
int getId() const { return _id; }
private:
int _id = 0;
};
//testing lists
class BobControl {
public:
bool compareId(const Bob& first, const Bob& second)
{
return (first.getId() < second.getId());
}
void testCompar() {
bobs.sort(compareId);
}
void controlBobs() {
list<Bob>::iterator lit;
bobs.push_back(Bob(0));
bobs.push_back(Bob(1));
bobs.push_back(Bob(5));
bobs.push_back(Bob(3));
testCompar();
for (lit = bobs.begin(); lit != bobs.end(); lit++) {
cout << (*lit).getId() << endl;
}
}
private:
list<Bob> bobs;
};
int main() {
BobControl bobc;
bobc.controlBobs();
system("PAUSE");
return 0;
} | <c++><sorting> | 2016-03-29 01:41:38 | LQ_EDIT |
36,274,037 | trying to write to python .txt file | <p>I am a new programmer, so be easy on me, I have watched a video on youtube, and understand most of it ( or so I thought). </p>
<p>I get an error when I try to run </p>
<pre><code>import logging
import csv
Date = input ('what date was it?')
fish = input ('what type of fish did you catch?')
fly = input ('what fly did you catch the fish on?')
water = input ('what was the water conditions?')
fileName = 'fish.txt'
WRITE = 'w' # write rebuilds the file, so nothing is in the file!
READ ='r'
APPEND = 'a'
ReadWrite = 'w+'
file = open('fileName', 'a')
file.write (Date + "\n")
file.write (fish + "\n")
file.write (fly + "\n")
file.write (water + "\n")
allFileContents = fileName.read()
print (allFileContents)
file.close()
</code></pre>
<p>does anything jump out at you that might be wrong? </p>
| <python> | 2016-03-29 01:49:36 | LQ_CLOSE |
36,274,260 | MVC5 Multiple types were found that match the controller named 'Home' | <p>I was trying to clone a project called IdentitySample but I wanted to rename it to RecreationalServicesTicketingSystem. I've followed a few guides as to how to rename everything but it seems the application is still picking up
<code>IdentitySample.Controllers.HomeController</code> . I've tried using the find function to look through codes to see if IdentitySample was still in our application but I've found none.</p>
<p>Can give me a few pointers as too where I might have missed renaming the solution?</p>
<blockquote>
<p>Multiple types were found that match the controller named 'Home'. This
can happen if the route that services this request
('{controller}/{action}/{id}') does not specify namespaces to search
for a controller that matches the request. If this is the case,
register this route by calling an overload of the 'MapRoute' method
that takes a 'namespaces' parameter.</p>
<p>The request for 'Home' has found the following matching controllers:
RecreationalServicesTicketingSystem.Controllers.HomeController
IdentitySample.Controllers.HomeController</p>
</blockquote>
<p><a href="https://i.stack.imgur.com/FF8kk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FF8kk.png" alt="enter image description here"></a></p>
<p>HomeController.cs</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Threading.Tasks;
using System.Net;
using System.Web;
using System.Web.Mvc;
using RecreationalServicesTicketingSystem.Models;
namespace RecreationalServicesTicketingSystem.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
[Authorize]
public ActionResult About()
{
ViewBag.Message = "Your app description page.";
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
}
}
</code></pre>
<p>View\Home\Index.cshtml</p>
<pre><code>@{
ViewBag.Title = "Home Page";
}
<div class="jumbotron">
<h1>ASP.NET Identity</h1>
<p class="lead">ASP.NET Identity is the membership system for ASP.NET apps. Following are the features of ASP.NET Identity in this sample application.</p>
<p><a href="http://www.asp.net/identity" class="btn btn-primary btn-large">Learn more &raquo;</a></p>
</div>
<div class="row">
<div class="col-md-4">
<dl>
<dt>Initialize ASP.NET Identity</dt>
<dd>
You can initialize ASP.NET Identity when the application starts. Since ASP.NET Identity is Entity Framework based in this sample,
you can create DatabaseInitializer which is configured to get called each time the app starts.
<strong>Please look in App_Start\IdentityConfig.cs</strong>
This code shows the following
<ul>
<li>When should the Initializer run and when should the database be created</li>
<li>Create Admin user</li>
<li>Create Admin role</li>
<li>Add Admin user to Admin role</li>
</ul>
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Add profile data for the user</dt>
<dd>
<a href="http://blogs.msdn.com/b/webdev/archive/2013/10/16/customizing-profile-information-in-asp-net-identity-in-vs-2013-templates.aspx">Please follow this tutorial.</a>
<ul>
<li>Add profile information in the Users Table</li>
<li>Look in Models\IdentityModels.cs for examples</li>
</ul>
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Validation</dt>
<dd>
When you create a User using a username or password, the Identity system performs validation on the username and password, and the passwords are hashed before they are
stored in the database. You can customize the validation by changing some of the properties of the validators such as Turn alphanumeric on/off, set minimum password length
or you can write your own custom validators and register them with the UserManager.
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Register a user and login</dt>
<dd>
Click @Html.ActionLink("Register", "Register", "Account") and see the code in AccountController.cs and Register Action.
Click @Html.ActionLink("Log in", "Login", "Account") and see the code in AccountController.cs and Login Action.
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Social Logins</dt>
<dd>
You can the support so that users can login using their Facebook, Google, Twitter, Microsoft Account and more.
</dd>
<dd>
<ul>
<li>
<a href="http://www.windowsazure.com/en-us/documentation/articles/web-sites-dotnet-deploy-aspnet-mvc-app-membership-oauth-sql-database/">Add Social Logins</a>
</li>
<li>
<a href="http://blogs.msdn.com/b/webdev/archive/2013/10/16/get-more-information-from-social-providers-used-in-the-vs-2013-project-templates.aspx">Get more data about the user when they login suing Facebook</a>
</li>
</ul>
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Basic User Management</dt>
<dd>
Do Create, Update, List and Delete Users.
Assign a Role to a User.
Only Users In Role Admin can access this page. This uses the [Authorize(Roles = "Admin")] on the UserAdmin controller.
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Basic Role Management</dt>
<dd>
Do Create, Update, List and Delete Roles.
Only Users In Role Admin can access this page. This authorization is doen by using the [Authorize(Roles = "Admin")] on the RolesAdmin controller.
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Account Confirmation</dt>
<dd>
When you register a new account, you will be sent an email confirmation.
You can use an email service such as <a href="http://www.windowsazure.com/en-us/documentation/articles/sendgrid-dotnet-how-to-send-email/">SendGrid</a> which integrate nicely with Windows Azure and requires no configuration or
set up an SMTP server to send email.
You can send email using the EmailService which is registered in App_Start\IdentityConfig.cs
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Two-Factor Authentication</dt>
<dd>
This sample shows how you can use Two-Factor authentication. This sample has a SMS and email service registered where you can send SMS or email for sending the security code.
You can add more two-factor authentication factors such as QR codes and plug them into ASP.NET Identity.
<ul>
<li>
You can use a SMS using <a href="https://www.twilio.com/">Twilio</a> or use any means of sending SMS. Please <a href="https://www.twilio.com/docs/quickstart/csharp/sms/sending-via-rest">read</a> for more details on using Twilio.
You can send SMS using the SmsService which is registered in App_Start\IdentityConfig.cs
</li>
<li>
You can use an email service such as <a href="http://www.windowsazure.com/en-us/documentation/articles/sendgrid-dotnet-how-to-send-email/">SendGrid</a> or
set up an SMTP server to send email.
You can send email using the EmailService which is registered in App_Start\IdentityConfig.cs
</li>
<li>
When you login, you can add a phone number by clicking the Manage page.
</li>
<li>
Once you add a phone number and have the Phone service hooked to send a SMS, you will get a code through SMS to confirm your phone number.
</li>
<li>
In the Manage page, you can turn on Two-Factor authentication.
</li>
<li>
When you logout and login, after you enter the username and password, you will get an option of how to get the security code to use for two-factor authentication.
</li>
<li>
You can copy the code from your SMS or email and enter in the form to login.
</li>
<li>
The sample also shows how to protect against Brute force attacks against two-factor codes. When you enter a code incorrectly for 5 times then you will be
lockedout for 5 min before you can enter a new code. These settings can be configured in App_Start\IdentityConfig.cs by setting DefaultAccountLockoutTimeSpan and MaxFailedAccessAttemptsBeforeLockout on the UserManager.
</li>
<li>
If the machine you are browsing this website is your own machine, you can choose to check the "Remember Me" option after you enter the code.
This option will remember you forever on this machine and will not ask you for the two-factor authentication, the next time when you login to the website.
You can change your "Remember Me" settings for two-factor authentication in the Manage page.
</li>
</ul>
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Account Lockout</dt>
<dd>
Provide a way to Lockout out the user if the user enters their password or two-factor codes incorrectly.
The number of invalid attempts and the timespan for the users are locked out can be configured.
A developer can optionally turn off Account Lockout for certain user accounts should they need to.
</dd>
<ul>
<li>Account LockOut settings can be configured in the UserManager in IdentityConfig.cs</li>
</ul>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Security Token provider</dt>
<dd>
Support a way to regenerate the Security Token for the user in cases when the User changes there password or any other security related information such as removing an associated login(such as Facebook, Google, Microsoft Account etc).
This is needed to ensure that any tokens generated with the old password are invalidated. In the sample project, if you change the users password then a new token is generated for the user and any previous tokens are invalidated.
This feature provides an extra layer of security to your application since when you change your password, you will be logged out from everywhere (all other browsers) where you have logged into this application.
</dd>
<dd>
<ul>
<li>The provider is registered when you add CookieAuthentication in StartupAuth to your application.</li>
</ul>
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Password Reset</dt>
<dd>
Allows the user to reset their passwords if they have forgotten their password. In this sample users need to confirm their email before they can reset their passwords.
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Custom Storage providers</dt>
<dd>
You can extend ASP.NET Identity to write your own custom storage provider for storing the ASP.NET Identity system and user data
in a persistance system of your choice such as MondoDb, RavenDb, Azure Table Storage etc.
</dd>
<dd>
<ul>
<li>
<a href="http://www.asp.net/identity/overview/extensibility/overview-of-custom-storage-providers-for-aspnet-identity">
learn more on how to implement your own storage provider
</a>
</li>
</ul>
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Documentation</dt>
<dd>
<ul>
<li>
Tutorials: <a href="www.asp.net/identity">www.asp.net/identity</a>
</li>
<li>
StackOverflow: <a href="http://stackoverflow.com/questions/tagged/asp.net-identity">http://stackoverflow.com/questions/tagged/asp.net-identity</a>
</li>
<li>
Twitter: #identity #aspnet
</li>
<li>
<a href="http://curah.microsoft.com/55636/aspnet-identity">ASP.NET Identity on curah</a>
</li>
<li>
Have bugs or suggestions for ASP.NET Identity <a href="http://aspnetidentity.codeplex.com/">http://aspnetidentity.codeplex.com/</a>
</li>
</ul>
</dd>
</dl>
</div>
</div>
</code></pre>
| <c#><asp.net-mvc><entity-framework><asp.net-identity> | 2016-03-29 02:18:28 | HQ |
36,275,685 | Trying to get property of non-object | <p>I'm getting "Trying to get property of non-object" while trying to this code.</p>
<pre><code><?php foreach($pages as $page=>$p): ?>
<h2 class="section-title text-center wow fadeInDown"><?php echo $page[0]->title; ?></h2>
<p class="text-center wow fadeInDown"><?php echo strip_tags(html_entity_decode($page[0]->description)); ?></p>
<?php endforeach; ?>
</code></pre>
| <php> | 2016-03-29 04:49:15 | LQ_CLOSE |
36,275,745 | JavaScript : Converting "Mon March 28 2016 23:59:59 GMT -0600 (CENTRAL DAYLIGHT TIME)" TO "2016-03-28 23:59:59" (YYYY-MM-DD HH:MM:SS) | <p>How do i convert "Mon March 28 2016 23:59:59 GMT -0600 (CENTRAL DAYLIGHT TIME)" TO "2016-03-28 23:59:59" (YYYY-MM-DD HH:MM:SS) in javascript?</p>
| <javascript><angularjs><date><datetime><javascript-events> | 2016-03-29 04:54:31 | LQ_CLOSE |
36,276,834 | Remove readonly attribute from all input box using jquery.? | I have multiple input text boxs all are by default read-only,So what i want is on-click on edit button remove read-only from all the text box.
**Html :**
<input type="text" name="fistname" readonly="true">
<input type="text" name="lastname" readonly="true">
<input type="text" name="emailaddres" readonly="true">
<input type="text" name="password" readonly="true">
<input type="button" name="edit" id="edit">
**Jquery :**
$(document).ready(function(e){
$(document).on("click","#edit",function(e){
// What should i do here..?
});
});
| <php><jquery> | 2016-03-29 06:19:34 | LQ_EDIT |
36,277,689 | how to see times wrong math in questions | <p>how do i print the number of times the question was answer wrong?</p>
<pre><code>while 1:
math = input("(1) What Is 8 x 4 : ")
if not math.isdigit():
print("It's not number")
elif math == "32":
print("You Got The Question Correct")
break
else:
print("Sorry You Got The Question Wrong Try Again")
</code></pre>
| <python> | 2016-03-29 07:10:28 | LQ_CLOSE |
36,277,772 | please help me for optimise sql function |
(@PaymentId int)
returns int
as
begin
Declare @viewedCount int
Select @viewedCount=Count(OtSrno) From OtTendersViewDetail
Where OTPaymentId=@PaymentId And OTPaymentId is not null
return (@viewedCount)
end | <sql><sql-server><sql-server-2008><sql-server-2012><sql-server-2014> | 2016-03-29 07:15:09 | LQ_EDIT |
36,278,239 | All about Context: How to Use context? | <p>As a newbie I am trying to make an app thorough watching some tutorials. I am approaching further and getting more and more confused about "Context". About its definition as well as its contribution. Most puzzling part is when to put the "context" as a parameter.</p>
<p>Which types of classes take "context" as parameter?
What can/should I suppose to do with it?</p>
| <android><android-studio> | 2016-03-29 07:38:41 | LQ_CLOSE |
36,278,900 | Converting OModel into JSON Model | Because of Problems with reading all lines of a UI5 common table and the getModel() method from table offers a model.
I thought I could use an JSONModel instead of my OModel the problem now is how to get the OModel too the Json Model.
Because JSON offers some Two Way Binding options which should be helpfull know what did I try.
I tried to read some Set and bind it to the JSONModel the problem is that i couldn't bind know the new Model two the View because it doesn't overs some set here is a snippet of my code hopefully this should be easyer too fix as the reading all table rows:
oModel2.read("/SEARCH_DLSet" + filterString, null, null, false, function (oData, oResponse) {
oODataJSONModelDLSet.setData(oData);
});
I saw that the table row binding has found the correct length of the data that it should get but the column binding want work here is snippet of code of row binding and then the column
<t:Table class="table0" id="table1" selectionMode="MultiToggle" rows="{jsonmodel>/oData/results}">
<t:columns>
<t:Column class="columns" width="105.27px">
<Label text="Kontrakt Nr." id="lKontrakt" >
</Label>
<t:template >
<commons:TextField id="Kontrakt" editable="false" value="{KontraktNr}" ></commons:TextField>
</t:template>
</t:Column>
too my model doesn't show the model propertys in the debuger.
So where is my failuer and how can i fix the convert?
I could too over some screens if it is helpfull of debugging and few | <json><odata><sapui5> | 2016-03-29 08:16:15 | LQ_EDIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.