Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
37,112,321 | Can we have search widget other than toolbar in android | <p>i understand we can have search widget in activity toolbar. As per my requirement we can't use tool bar for search widget, Is that possible we can have search widget as a separate entity in activity just below tool bar or some any where we want (just like Text View or button)?</p>
| <android> | 2016-05-09 09:36:17 | LQ_CLOSE |
37,112,367 | Size of the request headers is too long | <p>I'm currently working on an ASP.NET MVC website and it works fine. </p>
<p>But I have a problem that I don't understand at all... When I launch my website on Visual Studio with Chrome for example no problem, but when I stop it and try to launch an other test with Firefox for example, my url is growing and then I get this error : </p>
<blockquote>
<p>HTTP 400. The size of the request headers is too long.</p>
</blockquote>
<p>Can someone explain me why this is happening ? Is it something with my code or does it come from IIS express or anything else ?</p>
<p>Thanks in advance</p>
| <asp.net> | 2016-05-09 09:39:02 | HQ |
37,112,565 | jspm or npm to install packages? | <p>I'm new to jspm, transitioning from npm-only. I have one fundamental question. I have some dependencies in the package.json, and I runned jspm init, which created a nice jspm config.js file. My question is, what it the point of installing these packages from jspm (via <code>jspm install ...</code>)? Why not just install them through npm?</p>
<p>More specifically, in my package.json, what's the difference between putting these packages inside <code>dependencies: {} vs inside jspm.dependencies: {}</code></p>
| <npm><jspm> | 2016-05-09 09:48:12 | HQ |
37,112,804 | An unhandled lowlevel error occurred. The application logs may have details | <p>I'm tyring to deploy a rails app to a digital ocean droplet and all seems to be configured ok but I get this error:</p>
<pre><code>An unhandled lowlevel error occurred. The application logs may have details.
</code></pre>
<p>I'm not sure what to do as the logs are empty.</p>
<p>Here's the nginx config:</p>
<pre><code>upstream puma {
server unix:///home/yourcv.rocks/shared/tmp/sockets/yourcv.rocks-puma.sock;
}
server {
listen 80 default_server deferred;
server_name 127.0.0.1;
root /home/yourcv.rocks/current/public;
access_log /home/yourcv.rocks/current/log/nginx.access.log;
error_log /home/yourcv.rocks/current/log/nginx.error.log info;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @puma;
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://puma;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 10M;
keepalive_timeout 10;
}
</code></pre>
<p>Thank you! :) </p>
| <ruby-on-rails><nginx><capistrano><digital-ocean><puma> | 2016-05-09 09:58:56 | HQ |
37,112,986 | Spark SQL: How to consume json data from a REST service as DataFrame | <p>I need to read some JSON data from a web service thats providing REST interfaces to query the data from my SPARK SQL code for analysis. I am able to read a JSON stored in the blob store and use it.</p>
<p>I was wondering what is the best way to read the data from a REST service and use it like a any other <code>DataFrame</code>. </p>
<p>BTW I am using <code>SPARK 1.6 of Linux cluster on HD insight</code> if that helps. Also would appreciate if someone can share any code snippets for the same as I am still very new to SPARK environment.</p>
| <apache-spark-sql><spark-dataframe><hdinsight> | 2016-05-09 10:06:52 | HQ |
37,113,648 | i want that more files like ppt,docx,txt using directory.getfiles() method | it does work but not complete my need. i want that more files like ppt,docx,txt using directory.getfiles() method.
private void button2_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
if (textBox1.Text != "")
{
List<string> files = new List<string>();
files = Directory.GetFiles(textBox1.Text, "*.txt,*.ppt").ToList();
progressBar1.Maximum = files.Count;
progressBar1.Value = 0;
ListViewItem it;
foreach (var file in files)
{
it = new ListViewItem(file.ToString());
it.SubItems.Add(System.IO.Path.GetFileName(file.ToString()));
it.SubItems.Add(System.IO.Path.GetExtension(file.ToString()));
listView1.Items.Add(it);
progressBar1.Increment(1);
}
}
else
MessageBox.Show("Select diroctery first");
} | <c#><io> | 2016-05-09 10:39:09 | LQ_EDIT |
37,113,721 | Reading or Writing Excel (xlsx) file from java | <p>What is the best api or library to read Excel (xlsx) files from java?</p>
| <java><excel><xlsx> | 2016-05-09 10:42:29 | LQ_CLOSE |
37,115,441 | Sequelize instance methods not working | <p>I am trying to use Sequelize's instance method to validate a password on login attempt.
I have defined the User model as :</p>
<pre><code>var User = sequelize.define('User',{
id:{
type:DataTypes.BIGINT,
autoIncrement: true,
allowNull: false,
primaryKey:true
},
username:{
type:DataTypes.STRING,
unique:true
},
password:{
type: DataTypes.STRING
},
...
},
{
classMethods:{
associate:function(models){
...
}
}
},
{
instanceMethods:{
validatePassword:function(password){
return bcrypt.compareSync(password, this.password);
}
}
}
);
return User;
}
</code></pre>
<p>In my login route I do the following :</p>
<ul>
<li>1) Retrieve username & password from request body </li>
<li>2) Check if username exists in database </li>
<li>3) If user exists, get user object and compare sent password with hashed password in database using validatePassword method.</li>
</ul>
<p>Here is the relevant code</p>
<pre><code>var username = req.body.username || "";
var password = req.body.password || "";
models.User.findOne({ where: {username: username} }).
then(
function(user) {
if(user){
console.log(user.validatePassword(password));
}
....
</code></pre>
<p>Each time I try to login I get the following error</p>
<pre><code>[TypeError: user.validatePassword is not a function]
</code></pre>
<p>What am I doing wrong? </p>
| <node.js><sequelize.js> | 2016-05-09 12:08:01 | HQ |
37,116,619 | Angular 2 setinterval() keep running on other component | <p>I have the following method in one component:</p>
<pre><code>ngOnInit()
{
this.battleInit();
setInterval(() => {
this.battleInit();
}, 5000);
}
</code></pre>
<p>Now, I need to run this interval only if the user is in this specific component, that means that when the user navigate away from this component the interval will stop.</p>
<p>Currently, <code>this.battleInit()</code> is executed every 5 seconds, even after the user navigates away from this page.</p>
<p>Short question: How do I stop <code>setInterval()</code> when user navigate away (by routing) to another component?</p>
| <angular> | 2016-05-09 13:06:43 | HQ |
37,117,675 | i need to convert array value to json in jquery | <p>i have array value. need to convert this array value into json format. example is given bleow</p>
<p>Sample Array</p>
<pre><code>[Management Portal!@!@Production Issue Handling!@!@/IONSWeb/refDataManagement/searchDynamicScripts.do, Management Portal!@!@ Event Browser!@!@/IONSWeb/orderManagement/eventBrowser.do, Management Portal!@!@ Order Workflow!@!@/IONSWeb/orderManagement/SearchOrdersWorkflow.do, ADMINISTRATION!@!@Admin Message!@!@/IONSWeb/userManagement/getMessageForBroadcast.do, ADMINISTRATION!@!@Audit!@!@/IONSWeb/userManagement/auditManagement.do, ADMINISTRATION!@!@Locks!@!@/IONSWeb/userManagement/lockSearch.do, ADMINISTRATION!@!@Queue!@!@/IONSWeb/GroupManagement/begin.do, ADMINISTRATION!@!@Role!@!@/IONSWeb/userManagement/goToRolePage.do, ADMINISTRATION!@!@Routing Rule!@!@/IONSWeb/ruleManagement/showRules.do, ADMINISTRATION!@!@Task Code!@!@/IONSWeb/ManageTaskCode/begin.do, ADMINISTRATION!@!@Trigger OutEvent!@!@/IONSWeb/triggerOutEvent.jsp, ADMINISTRATION!@!@User!@!@/IONSWeb/userManagement/begin.do, ADMINISTRATION!@!@Refresh Application Cache!@!@/IONSWeb/userManagement/refreshApplnCache.do]
</code></pre>
<p>sample Json</p>
<pre><code>{
"name": "Administration",
"sub": [
{
"name": "Add Order",
"url": "/IONSWeb/userManagement/auditManagement.do"
},
{
"name": "Infrastructure sonet Add Order ",
"url": "/IONSWeb/userManagement/auditManagement.do"
},
{
"name": "fGNS Add Order",
"url": "/IONSWeb/userManagement/auditManagement.do"
}
]
}
</code></pre>
<p>Please anyone help on this</p>
| <javascript><jquery><arrays><json> | 2016-05-09 13:56:50 | LQ_CLOSE |
37,117,933 | Service Workers not updating | <p>I have a service worker installed in my website, everything works fine, except when I push an update to the cached files, in fact; they stay catched forever and I seem to be unable to invalidate the cache unless I unsubscribe the worker from the `chrome://serviceworker-internals/</p>
<pre><code>const STATIC_CACHE_NAME = 'static-cache-v1';
const APP_CACHE_NAME = 'app-cache-#VERSION';
const CACHE_APP = [
'/',
'/app/app.js'
]
const CACHE_STATIC = [
'https://fonts.googleapis.com/css?family=Roboto:400,300,500,700',
'https://cdnjs.cloudflare.com/ajax/libs/normalize/4.1.1/normalize.min.css'
]
self.addEventListener('install',function(e){
e.waitUntil(
Promise.all([caches.open(STATIC_CACHE_NAME),caches.open(APP_CACHE_NAME)]).then(function(storage){
var static_cache = storage[0];
var app_cache = storage[1];
return Promise.all([static_cache.addAll(CACHE_STATIC),app_cache.addAll(CACHE_APP)]);
})
);
});
self.addEventListener('activate', function(e) {
e.waitUntil(
caches.keys().then(function(cacheNames) {
return Promise.all(
cacheNames.map(function(cacheName) {
if (cacheName !== APP_CACHE_NAME && cacheName !== STATIC_CACHE_NAME) {
console.log('deleting',cacheName);
return caches.delete(cacheName);
}
})
);
})
);
});
self.addEventListener('fetch',function(e){
const url = new URL(e.request.url);
if (url.hostname === 'static.mysite.co' || url.hostname === 'cdnjs.cloudflare.com' || url.hostname === 'fonts.googleapis.com'){
e.respondWith(
caches.match(e.request).then(function(response){
if (response) {
return response;
}
var fetchRequest = e.request.clone();
return fetch(fetchRequest).then(function(response) {
if (!response || response.status !== 200 || response.type !== 'basic') {
return response;
}
var responseToCache = response.clone();
caches.open(STATIC_CACHE_NAME).then(function(cache) {
cache.put(e.request, responseToCache);
});
return response;
});
})
);
} else if (CACHE_APP.indexOf(url.pathname) !== -1){
e.respondWith(caches.match(e.request));
}
});
</code></pre>
<p>where #VERSION is a version that is appended to the cache name at compile time; note that STATIC_CACHE_NAME never changes, as the files are thought to be static forever.</p>
<p>Also the behavior is erratic, I've been checking the delete function (the part where it logs) and it keeps logging about the deleting caches that have already been deleted (supposedly). when I run <code>caches.keys().then(function(k){console.log(k)})</code> I get a whole bunch of old caches that should've been removed.</p>
| <javascript><web-worker><service-worker> | 2016-05-09 14:09:05 | HQ |
37,118,047 | how to show query while using query annotations with MongoRepository with spring data | <p>I'm using MongoRepository in spring boot to access mongo:</p>
<pre><code>public interface MongoReadRepository extends MongoRepository<User, String> {
@Query(value = "{$where: 'this.name == ?0'}", count = true)
public Long countName(String name);
}
</code></pre>
<p>and it could work, but i wonder know the exactly query it accessing mongo</p>
<p>how to do that?</p>
<p>i try to adding some config at properties like below:</p>
<pre><code>logging.level.org.springframework.data.mongodb.core.MongoTemplate=DEBUG
logging.level.org.springframework.data.mongodb.repository.Query=DEBUG
</code></pre>
<p>and don't work.</p>
<p>could somebody help?</p>
| <java><spring><mongodb><spring-data><mongorepository> | 2016-05-09 14:13:59 | HQ |
37,118,049 | Replicating messages from one Kafka topic to another kafka topic | <p>I want to make a flow from a Kafka cluster/topic in thr prod cluster into another Kafka cluster in the dev environment for scalability and regrrssion testing. </p>
<p>For the duck-tape solution, I cascade a Kafka consumer and producer, but my instinct tells me that there should be a better way. But, I couldn't find any good solution yet. Can anyone help me?</p>
| <apache-kafka> | 2016-05-09 14:14:11 | HQ |
37,118,262 | How to print char value in int array | <p>I have an array board[3][3] of type int. I want to show 8 numbers and on the last place "_" must be shown. I don't know how to do that. Please help</p>
| <c><arrays><arraylist> | 2016-05-09 14:23:53 | LQ_CLOSE |
37,118,385 | Styling ionic 2 toast | <p>Is there any way to style the text message within an ionic 2 toast?</p>
<p>I have tried this:</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> let toast = Toast.create({
message: "Some text on one line. <br /><br /> Some text on another line.",
duration: 15000,
showCloseButton: true,
closeButtonText: 'Got it!',
dismissOnPageChange: true
});
toast.onDismiss(() => {
console.log('Dismissed toast');
});
this.nav.present(toast);
}</code></pre>
</div>
</div>
</p>
<p>But clearly you can't use html in the text so I am guessing the answer to my question is no?</p>
| <toast><ionic2> | 2016-05-09 14:29:06 | HQ |
37,118,889 | How to make a dictionary in python and save data in a file | <p>I am iterating over grouped items and based on item,user combination I am extracting user features, by using following code:</p>
<pre><code>for counter in grouped.iterrows():
user_id = counter[1]['user_id']
item_id = counter[1]['item_id']
career_level = get_value(users, user_id, 'career_level')
industry_id = get_value(users, user_id, 'industry_id')
country = get_value(users, user_id, 'country')
career_level = 'CL_' + str(career_level)
industry_id = 'IND_' + str(industry_id)
print(item_id, user_id, country, career_level, industry_id)
</code></pre>
<p>In output what I got is:</p>
<pre><code>5 797978 JO_4092133 ch CL_0 IND_1
12 1524899 JO_524518 JO_2169794 JO_2905196 de CL_2 IND_0
12 2703661 JO_1210814 JO_2573697 de CL_3 IND_0
14 1054241 JO_2804344 JO_1072229 de CL_3 IND_14
14 1297953 JO_3482421 de CL_6 IND_0
14 1548532 JO_425546 de CL_2 IND_0
14 1609264 JO_4438218 JO_1151866 de CL_3 IND_9
</code></pre>
<p>Now my desired output is something like this:</p>
<pre><code>5 797978 JO_4092133 ch CL_0 IND_1
12 1524899 JO_524518 JO_2169794 JO_2905196 de CL_2 IND_0, 2703661 JO_1210814 JO_2573697 de CL_3 IND_0
14 1054241 JO_2804344 JO_1072229 de CL_3 IND_14, 1297953 JO_3482421 de CL_6 IND_0, 1548532 JO_425546 de CL_2 IND_0, 1609264 JO_4438218 JO_1151866 de CL_3 IND_9
</code></pre>
<p>That means if some user1 has interacted with item1 and another user2 has also interacted with item1, then user1 and user2's features should be in single row. </p>
<p>Could anyone suggest me how could I achieve this goal?</p>
<p>My second question is:
How can I write this data into a file?</p>
<p>I am a beginner to python. I appreciate your help.
Thanks</p>
| <python><pandas> | 2016-05-09 14:52:52 | LQ_CLOSE |
37,118,912 | How to assert the regular expression against my output using selenium java | This is my regex value
/(\u20AC|\u00A3)[\d,]*/?(week|wk|month|mth|year|yr)?/
Can I please know how to verify this regular expression against my output using selenium. | <java><selenium><selenium-webdriver> | 2016-05-09 14:53:46 | LQ_EDIT |
37,119,519 | xml parseing using Swift (IOS) Help me | <p>I have this XML By URL : </p>
<pre><code><NewDataSet>
<Table>
<ID>1</ID>
<SongName>AYA LIV LIVOKIM PEL?STANKTV</SongName>
<SongPath>http://jo.sms2tv.com/PelistankApp/Songs/song1.mp3</SongPath>
<SongImagePath>http:\\jo.sms2tv.com\PelistankApp\Images\logo1.png</SongImagePath>
</Table>
<Table>
<ID>2</ID>
<SongName>DîLAN PPP PELISTANK</SongName>
<SongPath>http://jo.sms2tv.com/PelistankApp/Songs/song2.mp3</SongPath>
<SongImagePath>http:\\jo.sms2tv.com\PelistankApp\Images\logo2.png</SongImagePath>
</Table>
<Table>
<ID>3</ID>
<SongName>KARIN BAL DAGRIM</SongName>
<SongPath>http://jo.sms2tv.com/PelistankApp/Songs/song3.mp3</SongPath>
<SongImagePath>http:\\jo.sms2tv.com\PelistankApp\Images\logo3.png</SongImagePath>
</Table>
<Table>
<ID>4</ID>
<SongName>RUKEN WERE CANE</SongName>
<SongPath>http://jo.sms2tv.com/PelistankApp/Songs/song4.mp3</SongPath>
<SongImagePath>http:\\jo.sms2tv.com\PelistankApp\Images\logo4.png</SongImagePath>
</Table>
</NewDataSet>
</code></pre>
<p>I want Show the Song Name in the table and i maked it no problem ,
now i want when i clicked in a cell on the Table Give me the Song Path And Put it in NSURL , because i want use it to PLAY Song .
1 - I Show the SongName in the Table no problem .
2 - I know how make AVPlayer To PLAY Song
Just i want when clicked on the CELL Give me the SongPath and put it in NSURL </p>
<p>And This is my Swift Code :</p>
<pre><code>class ViewController: UIViewController, NSXMLParserDelegate, UITableViewDataSource, UITableViewDelegate
{
@IBOutlet var tbData : UITableView?
var parser = NSXMLParser()
var posts = NSMutableArray()
var elements = NSMutableDictionary()
var element = NSString()
var title1 = NSMutableString()
var date = NSMutableString()
override func viewDidLoad()
{
// Do any additional setup after loading the view, typically from a nib.
super.viewDidLoad()
self.beginParsing()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func beginParsing()
{
posts = []
parser = NSXMLParser(contentsOfURL:(NSURL(string:"http://jo.sms2tv.com/PelistankApp2/getsongs.aspx"))!)!
parser.delegate = self
parser.parse()
tbData?.reloadData()
}
//////////////////////////////////////XMLParser Methods
func parser(parser: NSXMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String])
{
element = elementName
if (elementName as NSString).isEqualToString("Table")
{
elements = NSMutableDictionary()
elements = [:]
title1 = NSMutableString()
title1 = ""
date = NSMutableString()
date = ""
}
}
func parser(parser: NSXMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?)
{
if (elementName as NSString).isEqualToString("Table") {
if !title1.isEqual(nil) {
elements.setObject(title1, forKey: "title")
}
if !date.isEqual(nil) {
elements.setObject(date, forKey: "date")
}
posts.addObject(elements)
}
}
func parser(parser: NSXMLParser, foundCharacters string: String)
{
if element.isEqualToString("SongName") {
title1.appendString(string)
} else if element.isEqualToString("SongPath") {
date.appendString(string)
}
}
///////////////////////////////////////////XMLParser Methods
//////////////////////////////Tableview Methods
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return posts.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell : UITableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell")!
if(cell.isEqual(NSNull)) {
cell = NSBundle.mainBundle().loadNibNamed("Cell", owner: self, options: nil) [0] as! UITableViewCell
}
cell.textLabel?.text = posts.objectAtIndex(indexPath.row).valueForKey("title") as! NSString as String
cell.detailTextLabel?.text = posts.objectAtIndex(indexPath.row).valueForKey("date") as! NSString as String
return cell as UITableViewCell
}
//////////////////////////////////////Tableview Methods
/////// Table Action ( Cell clicked ) ///////
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
tableView.deselectRowAtIndexPath(indexPath, animated: true)
let row = indexPath.row
print("Row: \(row)")
}
/////// Table Action ( Cell clicked ) ///////
@IBAction func Song(sender: UIButton) {
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("ViewSong")
self.presentViewController(nextViewController, animated:true, completion:nil)
}
@IBAction func BackTableToHome(sender: UIBarButtonItem) {
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("Home")
self.presentViewController(nextViewController, animated:true, completion:nil)
}
//////////Button SecandViewController ////
@IBAction func SecondViewController(sender: AnyObject) {
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("ViewSong")
self.presentViewController(nextViewController, animated:true, completion:nil)
}
}
</code></pre>
<p>And This is my Table </p>
<p><a href="http://i.stack.imgur.com/CUEvL.png" rel="nofollow">enter image description here</a></p>
<p>Any advice for this issue
Thank's </p>
| <ios><xml><swift> | 2016-05-09 15:21:25 | LQ_CLOSE |
37,119,692 | How to setup game to be multiplayer? | <p>I am developing a game for android, and I am wondering how multiplayer networking would work. I don't need the specifics (eg... how to send data back and forth). I'm curious, for instance, in my game I have a sun in the background (sprite) that I move programmaticly across the sky. In a multiplayer game, would I calculate that on both machines? Or just 1, then send the sun location to the other? Also, would it be a bunch of if statements in my code to see if the current game if multiplayer, if so do this, if not do this? Or would I have separate classes, 1 for single player, and a different one for multiplayer? Thanks in advance! </p>
| <java><android><libgdx><box2d> | 2016-05-09 15:30:45 | LQ_CLOSE |
37,120,240 | Timeout in async/await | <p>I'm with Node.js and TypeScript and I'm using <code>async/await</code>.
This is my test case:</p>
<pre><code>async function doSomethingInSeries() {
const res1 = await callApi();
const res2 = await persistInDB(res1);
const res3 = await doHeavyComputation(res1);
return 'simle';
}
</code></pre>
<p>I'd like to set a timeout for the overall function. I.e. if <code>res1</code> takes 2 seconds, <code>res2</code> takes 0.5 seconds, <code>res3</code> takes 5 seconds I'd like to have a timeout that after 3 seconds let me throw an error.</p>
<p>With a normal <code>setTimeout</code> call is a problem because the scope is lost:</p>
<pre><code>async function doSomethingInSeries() {
const timerId = setTimeout(function() {
throw new Error('timeout');
});
const res1 = await callApi();
const res2 = await persistInDB(res1);
const res3 = await doHeavyComputation(res1);
clearTimeout(timerId);
return 'simle';
}
</code></pre>
<p>And I cannot catch it with normal <code>Promise.catch</code>:</p>
<pre><code>doSomethingInSeries().catch(function(err) {
// errors in res1, res2, res3 will be catched here
// but the setTimeout thing is not!!
});
</code></pre>
<p>Any ideas on how to resolve?</p>
| <node.js><typescript><timeout><promise><async-await> | 2016-05-09 15:55:15 | HQ |
37,120,260 | Configure docker-compose override to ignore / hide some containers | <p>If I have (simplified), the following <em>docker-compose.yml</em>:</p>
<pre><code>parent:
image: parent
links:
- child
child:
image: child
</code></pre>
<p>Can I construct a <em>docker-compose.override.yml</em> file that will <strong>not</strong> create or start the <code>child</code> image?</p>
<hr>
<p>An undesirable (for me) solution, would be to reverse the files, such that the default yml file would create only the <code>parent</code>, and the override would create both.</p>
<p>However, I would like the <em>master</em> configuration file to contain the most common usage scenario.</p>
| <docker><docker-compose> | 2016-05-09 15:56:05 | HQ |
37,121,134 | How to deal with double submit in Angular2 | <p>If I click fast on my submit-button the form is submitted two or more times. My thought was to prevent this with the disabled attribute, but I need variable <code>disableButon</code> in every form like this:</p>
<pre><code>@Component({
selector: 'example',
template: `
<form (submit)="submit()" >
<--! Some Inputs -->
<button [disabled]="disableButton" type="submit">Submit<button>
</form>
`
})
export class ExampleComponent {
private disableButton: boolean = false;
.......
submit(){
this.disableButton = true;
/*
* API call
*/
this.disableButton = false;
}
}
</code></pre>
<p>Am I doing this right or is there a more efficent/elegant way to do it?</p>
| <angular> | 2016-05-09 16:43:44 | HQ |
37,122,158 | Date Formatting Returns Nil | <p>I'm getting nil when trying to create a date from a string. What am I doing wrong?</p>
<pre><code>let createdAt = passesDictionary["createdAt"] as? String
print(createdAt)
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
let createdDate = dateFormatter.dateFromString(createdAt!)
print(createdDate)
</code></pre>
<p>createdAt is Optional("2016-05-03T19:17:00.434Z"), but createdDate is nil.</p>
| <ios><swift><nsdateformatter> | 2016-05-09 17:43:57 | LQ_CLOSE |
37,122,484 | Chart.js: Bar Chart Click Events | <p>I've just started working with Chart.js, and I am getting very frustrated very quickly. I have my stacked bar chart working, but I can't get the click "events" to work.</p>
<p>I have found a <a href="https://github.com/chartjs/Chart.js/issues/577#issuecomment-55897221">comment on GitHub by <code>nnnick</code></a> from Chart.js stating to use the function <code>getBarsAtEvent</code>, even though this function cannot be found in the <a href="http://www.chartjs.org/docs/#bar-chart-chart-options">Chart.js documentation</a> at all (go ahead, do a search for it). The documentation does mention the <code>getElementsAtEvent</code> function of the <code>chart</code> reference, but that is for Line Charts only.</p>
<p>I set an event listener (the right way) on my canvas element:</p>
<pre><code>canv.addEventListener('click', handleClick, false);
</code></pre>
<p>...yet in my <code>handleClick</code> function, <code>chart.getBarsAtEvent</code> is undefined!</p>
<p>Now, in the Chart.js document, there is a statement about a different way to register the click event for the bar chart. It is much different than <code>nnnick</code>'s comment on GitHub from 2 years ago.</p>
<p>In the <a href="http://www.chartjs.org/docs/#getting-started-global-chart-configuration">Global Chart Defaults</a> you can set an <code>onClick</code> function for your chart. I added an <code>onClick</code> function to my chart configuration, and it did nothing...</p>
<p>So, how the heck do I get the on-click-callback to work for my bar chart?!</p>
<p>Any help would be greatly appreciated. Thanks!</p>
<p><strong>P.S.:</strong> I am not using the master build from GitHub. I tried, but it kept screaming that <code>require is undefined</code> and I was not ready to include CommonJS just so that I could use this chart library. I would rather write my own dang charts. Instead, I downloaded and am using the <a href="https://raw.githubusercontent.com/nnnick/Chart.js/v2.0-dev/dist/Chart.js"><strong>Standard Build</strong></a> version that I downloaded straight from the link at the top of the <a href="http://www.chartjs.org/docs/">documentation page</a>.</p>
<p><strong>EXAMPLE:</strong> Here is an example of the configuration I am using:</p>
<pre><code>var chart_config = {
type: 'bar',
data: {
labels: ['One', 'Two', 'Three'],
datasets: [
{
label: 'Dataset 1',
backgroundColor: '#848484',
data: [4, 2, 6]
},
{
label: 'Dataset 2',
backgroundColor: '#848484',
data: [1, 6, 3]
},
{
label: 'Dataset 3',
backgroundColor: '#848484',
data: [7, 5, 2]
}
]
},
options: {
title: {
display: false,
text: 'Stacked Bars'
},
tooltips: {
mode: 'label'
},
responsive: true,
maintainAspectRatio: false,
scales: {
xAxes: [
{
stacked: true
}
],
yAxes: [
{
stacked: true
}
]
},
onClick: handleClick
}
};
</code></pre>
| <javascript><chart.js> | 2016-05-09 18:03:11 | HQ |
37,122,908 | drupal 8 get taxonomy term value in node | <p>Drupal\node\Entity\Node Object
(
[in_preview] =>
[values:protected] => Array
(
[vid] => Array
(
[x-default] => 1
)</p>
<pre><code> [langcode] => Array
(
[x-default] => en
)
[field_destination] => Array
(
[x-default] => Array
(
[0] => Array
(
[target_id] => 2
)
)
)
</code></pre>
<p>Not able to get field_destination value directly. It's a taxonomy term attached with the content type. Any help appriciated.</p>
| <drupal-8> | 2016-05-09 18:26:30 | HQ |
37,123,010 | Run program B from program A only? | <p>I have a program named A, which is responsible for telling the user about the news and updates of my program, then it should run program B which is the main program. How would I make program B openable only from program A??</p>
| <c#> | 2016-05-09 18:34:14 | LQ_CLOSE |
37,123,111 | Maximum execution time of 120 seconds exceeded in yii2 | <p>I upload an excel file with 1000 rows, by default I have just 2 min in execution time, with that time I can upload 400 records.
I get this error <code>Maximum execution time of 120 seconds exceeded</code></p>
<p>How i can modify this period in yii2 framework ?</p>
| <php><yii2><execution-time> | 2016-05-09 18:39:49 | HQ |
37,123,113 | Can't listen my new button with javascript | <p>I'm load a button from script template:</p>
<pre><code><script type="text/html" id="addButton">
<button class="btn btn-default" id="element-empty">
ELEMENT
</button>
</script>
</code></pre>
<p>this button already loaded to the page by "load" button. now i want to listener this button ("element-empty") from javascript and use jquery</p>
<pre><code>$( '#element-empty' ).click(function() {
$(this).attr('class','myClass');
});
</code></pre>
<p>the problem, button "element-empty" can't detect from javascript. anyone know the solution???</p>
| <javascript><jquery> | 2016-05-09 18:39:51 | LQ_CLOSE |
37,124,375 | How to api-query for the default vhost | <p>The RabbitMQ <a href="https://www.rabbitmq.com/access-control.html" rel="noreferrer">documentation</a> states:</p>
<pre><code>Default Virtual Host and User
When the server first starts running, and detects that its database is uninitialised or has been deleted, it initialises a fresh database with the following resources:
a virtual host named /
</code></pre>
<p>The <a href="http://hg.rabbitmq.com/rabbitmq-management/raw-file/3646dee55e02/priv/www-api/help.html" rel="noreferrer">api</a> has things like:</p>
<pre><code>/api/exchanges/#vhost#/?name?/bindings
</code></pre>
<p>where "?name?" is a specific exchange-name.</p>
<p>However, what does one put in for the <strong>#vhost#</strong> for the <strong><em>default</em></strong>-vhost?</p>
| <rabbitmq> | 2016-05-09 19:55:40 | HQ |
37,124,649 | How to get last item from array of object? | <p>I have JSON object from server and requirement is to always display last item from the array <code>items</code>. how can i achieve that task using AngularJs or native JavaScript ?</p>
<p>Below case i have to display text <code>Chief Administrative Officer</code>.</p>
<p>main.js</p>
<pre><code> angular.forEach($scope.rcsaErhTreeData, function(val) {
angular.forEach(val, function(val) {
console.log('this is the array value', val[0].text);
});
});
</code></pre>
<p>json.js</p>
<pre><code>[{
"uid": null,
"index": 0,
"selected": null,
"expanded": null,
"id": 2701,
"text": "BAC Enterprise Wide",
"parentId": 0,
"items": [{
"uid": null,
"index": 0,
"selected": null,
"expanded": null,
"id": 4114,
"text": "Chief Administrative Officer",
"parentId": 2701,
"items": []
}]
}]
</code></pre>
| <javascript><angularjs> | 2016-05-09 20:13:30 | LQ_CLOSE |
37,124,868 | A confusion i have about HTML "classes" | <p>Hello and thanks in advance. In HTML I know that a "class" will not really have an effect unless it is related to something in CSS or JS. At the same time, I find some "classes" that do affect the structure of a documents even without an associated CSS, such as "class="col-md-12" for example. Can someone explain why some classes work independent of CSS? And how to know them.</p>
| <html><css><class> | 2016-05-09 20:27:40 | LQ_CLOSE |
37,125,435 | Can't make this work | <p>How can i change variable value?, i tried using "Promises" but it doesn't work it gaves me an error, i'm trying to load a data on a table</p>
<pre><code> /* Formating function for row details */
function fnFormatDetails(oTable, nTr) {
var aData = oTable.fnGetData(nTr);
var sOut ='';
$.post("http://localhost:3000/almuerzo/findIng", {
nombre: aData[1]},
function(data, status){
sOut = '<ul>';
sOut += data.nombre;
sOut += '</ul>';
});
return sOut;
}
</code></pre>
<p>As i said when i try to use promises de "datable.tabletools plugin" fails, said that there's an error on "show"</p>
| <javascript><jquery><datatables> | 2016-05-09 21:05:28 | LQ_CLOSE |
37,125,496 | Cordova build changes distributionUrl in gradle-wrapper.properties file | <p>I keep getting the following build exception when I run </p>
<pre><code> cordova run android --verbose
</code></pre>
<ul>
<li>What went wrong:
A problem occurred evaluating root project 'android'.
<blockquote>
<p>Failed to apply plugin [id 'android']
Gradle version 2.10 is required. Current version is 2.2.1. If using the gradle wrapper, try editing the distributionUrl in C:\Users\Project\gradle\wrapper\gradle-wrapper.properties to gradle-2.10-all.zip</p>
</blockquote></li>
</ul>
<p>The reason for this is the line being changed when I run the cordova build command from; </p>
<pre><code>distributionUrl=http\://services.gradle.org/distributions/gradle-2.1.0-all.zip
</code></pre>
<p>to</p>
<pre><code>distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
</code></pre>
<p>Any way to prevent this ?</p>
| <cordova><gradle><android-gradle-plugin> | 2016-05-09 21:08:52 | HQ |
37,125,703 | Completely blown away at how to write scripts in linux | So i started today taking a look at scripting using vim and im just so very lost and was looking for some help in a few areas. First is when something says that it wants me to process a file as a command line argument and if a file isnt included when the user executes this script then a usage message is displayed followed by exiting the program. I have no clue where to even start with that, will i need and if then statement or what? | <bash><shell> | 2016-05-09 21:22:00 | LQ_EDIT |
37,126,108 | How to read data into TensorFlow batches from example queue? | <p>How do I get TensorFlow example queues into proper batches for training?</p>
<p>I've got some images and labels:</p>
<pre><code>IMG_6642.JPG 1
IMG_6643.JPG 2
</code></pre>
<p>(feel free to suggest another label format; I think I may need another dense to sparse step...)</p>
<p>I've read through quite a few tutorials but don't quite have it all together yet.
Here's what I have, with comments indicating the steps required from TensorFlow's <a href="https://www.tensorflow.org/versions/r0.8/how_tos/reading_data/index.html#reading-from-files" rel="noreferrer">Reading Data</a> page.</p>
<ol>
<li>The list of filenames
(optional steps removed for the sake of simplicity)</li>
<li>Filename queue</li>
<li>A Reader for the file format</li>
<li>A decoder for a record read by the reader</li>
<li>Example queue</li>
</ol>
<p>And after the example queue I need to get this queue into batches for training; that's where I'm stuck...</p>
<p><strong>1. List of filenames</strong></p>
<p><code>files = tf.train.match_filenames_once('*.JPG')</code></p>
<p><strong>4. Filename queue</strong></p>
<p><code>filename_queue = tf.train.string_input_producer(files, num_epochs=None, shuffle=True, seed=None, shared_name=None, name=None)</code></p>
<p><strong>5. A reader</strong></p>
<p><code>reader = tf.TextLineReader()
key, value = reader.read(filename_queue)</code></p>
<p><strong>6. A decoder</strong></p>
<p><code>record_defaults = [[""], [1]]
col1, col2 = tf.decode_csv(value, record_defaults=record_defaults)
</code>
(I don't think I need this step below because I already have my label in a tensor but I include it anyways)</p>
<p><code>features = tf.pack([col2])</code></p>
<p>The documentation page has an example to run one image, not get the images and labels into batches:</p>
<p><code>
for i in range(1200):
# Retrieve a single instance:
example, label = sess.run([features, col5])
</code></p>
<p>And then below it has a batching section:</p>
<pre><code>def read_my_file_format(filename_queue):
reader = tf.SomeReader()
key, record_string = reader.read(filename_queue)
example, label = tf.some_decoder(record_string)
processed_example = some_processing(example)
return processed_example, label
def input_pipeline(filenames, batch_size, num_epochs=None):
filename_queue = tf.train.string_input_producer(
filenames, num_epochs=num_epochs, shuffle=True)
example, label = read_my_file_format(filename_queue)
# min_after_dequeue defines how big a buffer we will randomly sample
# from -- bigger means better shuffling but slower start up and more
# memory used.
# capacity must be larger than min_after_dequeue and the amount larger
# determines the maximum we will prefetch. Recommendation:
# min_after_dequeue + (num_threads + a small safety margin) * batch_size
min_after_dequeue = 10000
capacity = min_after_dequeue + 3 * batch_size
example_batch, label_batch = tf.train.shuffle_batch(
[example, label], batch_size=batch_size, capacity=capacity,
min_after_dequeue=min_after_dequeue)
return example_batch, label_batch
</code></pre>
<p>My question is: <strong>how do I use the above example code with the code I have above?</strong> I need <em>batches</em> to work with, and most of the tutorials come with mnist batches already.</p>
<pre><code>with tf.Session() as sess:
sess.run(init)
# Training cycle
for epoch in range(training_epochs):
total_batch = int(mnist.train.num_examples/batch_size)
# Loop over all batches
for i in range(total_batch):
batch_xs, batch_ys = mnist.train.next_batch(batch_size)
</code></pre>
| <python><numpy><classification><tensorflow> | 2016-05-09 21:57:09 | HQ |
37,126,171 | T-SQL Allow users to only execute stored procdures | For my database assignment I have to allow users to only execute stored procedures, I know how to allow a user to only execute a single stored procedure but not all within the database. | <sql-server><tsql><ssms> | 2016-05-09 22:03:31 | LQ_EDIT |
37,126,257 | Swift full date with milliseconds | <p>Is any way to print full date with milliseconds?</p>
<p>For example, I'm doing this:</p>
<pre><code>print("\(NSDate())")
</code></pre>
<p>But I'm just get this:</p>
<pre><code>2016-05-09 22:07:19 +0000
</code></pre>
<p>How can I get the milliseconds too in the full date?</p>
| <ios><swift> | 2016-05-09 22:11:28 | HQ |
37,126,374 | Starting Node.js Thread Pool for Parallelism | <p>Yes hello. I recently came to learn that Node.js is single-threaded. I would like to use my application faster (MongoDB/Express app) so I have written the following script (I want it to use 8 processors)</p>
<pre><code>#!/bin/bash
node app.js &
node app.js &
node app.js &
node app.js &
node app.js &
node app.js &
node app.js &
node app.js &
</code></pre>
<p>When I try to run the script, I get many errors about ports being used, but I know that TCP allows for 65536 ports and it should only try to use 8. Do I need to update my Node.js to a new version?</p>
<p>I am running on Amazon Linux.</p>
<p>Thank you.</p>
| <javascript><node.js><multithreading><mongodb><parallel-processing> | 2016-05-09 22:21:46 | LQ_CLOSE |
37,126,912 | Why does my App start incredibly slow (10s+) at first run, showing only white screen on android 5.0? | <p>I have a freshly created app (built in android studio 2.0), having a few activities.</p>
<p>When I test it on my Android 4.3 (note 2) device it starts nicely and fast after a clean install, in turn the same app on my samsung galaxy S4 with android 5.0, hangs for about 10-15 seconds while showing a white screen only.</p>
<p>To be sure I have unplugged it from android studio and commented out almost every method that was in my MainActivity, but it makes no difference, I get the same 10 seconds startup after install or after clearing the app's cache.</p>
<p>I am really concerned about this issue, this could really hurt my app's user experience.</p>
<p>What could be wrong?</p>
<p>Logcat:</p>
<pre><code>05-10 02:07:14.266 26036-26631/com.cerculdivelor I/GMPM: App measurement is starting up
05-10 02:07:14.747 26036-26036/com.cerculdivelor W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
05-10 02:07:14.867 26036-26036/com.cerculdivelor D/Activity: performCreate Call secproduct feature valuefalse
05-10 02:07:14.867 26036-26036/com.cerculdivelor D/Activity: performCreate Call debug elastic valuetrue
05-10 02:07:14.907 26036-26036/com.cerculdivelor I/LOGTAG: Table has been created!
05-10 02:07:14.967 26036-26650/com.cerculdivelor D/OpenGLRenderer: Render dirty regions requested: true
05-10 02:07:15.007 26036-26649/com.cerculdivelor I/Timeline: Timeline: Activity_launch_request id:com.cerculdivelor time:111211793
05-10 02:07:15.127 26036-26645/com.cerculdivelor I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
05-10 02:07:15.127 26036-26645/com.cerculdivelor I/System.out: (HTTPLog)-Static: isShipBuild true
05-10 02:07:15.127 26036-26645/com.cerculdivelor I/System.out: (HTTPLog)-Thread-62285-755755249: SmartBonding Enabling is false, SHIP_BUILD is true, log to file is false, DBG is false
05-10 02:07:15.127 26036-26645/com.cerculdivelor I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
05-10 02:07:15.137 26036-26645/com.cerculdivelor I/System.out: KnoxVpnUidStorageknoxVpnSupported API value returned is false
05-10 02:07:15.147 26036-26650/com.cerculdivelor I/Adreno-EGL: <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: ()
OpenGL ES Shader Compiler Version: E031.25.03.06
Build Date: 01/24/15 Sat
Local Branch: AF11_RB1_AU15
Remote Branch:
Local Patches:
Reconstruct Branch:
05-10 02:07:15.147 26036-26650/com.cerculdivelor I/OpenGLRenderer: Initialized EGL, version 1.4
05-10 02:07:15.197 26036-26650/com.cerculdivelor D/OpenGLRenderer: Enabling debug mode 0
05-10 02:07:15.417 26036-26036/com.cerculdivelor I/LOGTAG: Returned0rows
05-10 02:07:15.417 26036-26036/com.cerculdivelor I/LOGTAG: Returned0rows
05-10 02:07:15.988 26036-26051/com.cerculdivelor I/art: Background sticky concurrent mark sweep GC freed 40699(4MB) AllocSpace objects, 12(383KB) LOS objects, 0% free, 49MB/49MB, paused 1.007ms total 161.285ms
05-10 02:07:16.168 26036-26043/com.cerculdivelor W/art: Suspending all threads took: 5.249ms
05-10 02:07:16.228 26036-26036/com.cerculdivelor D/Activity: performCreate Call secproduct feature valuefalse
05-10 02:07:16.228 26036-26036/com.cerculdivelor D/Activity: performCreate Call debug elastic valuetrue
05-10 02:07:16.238 26036-26036/com.cerculdivelor I/Choreographer: Skipped 44 frames! The application may be doing too much work on its main thread.
05-10 02:07:17.349 26036-26036/com.cerculdivelor I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@4e1915e time:111214133
05-10 02:07:17.349 26036-26036/com.cerculdivelor I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@2d342603 time:111214133
05-10 02:07:17.369 26036-26036/com.cerculdivelor V/ActivityThread: updateVisibility : ActivityRecord{10b472f8 token=android.os.BinderProxy@2d342603 {com.cerculdivelor/com.cerculdivelor.MainActivity}} show : false
05-10 02:07:30.622 26036-26036/com.cerculdivelor I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@4e1915e time:111227400
05-10 02:08:36.286 26036-26036/com.cerculdivelor V/ActivityThread: updateVisibility : ActivityRecord{1e1f9137 token=android.os.BinderProxy@4e1915e {com.cerculdivelor/com.cerculdivelor.SplashActivity}} show : true
</code></pre>
<p>Main Activity:</p>
<pre><code>public class MainActivity extends AppCompatActivity implements View.OnClickListener, HttpConActivity.downloadListener {
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
private BroadcastReceiver mRegistrationBroadcastReceiver;
private boolean isReceiverRegistered;
CallbackManager callbackManager;
private AccessTokenTracker accessTokenTracker;
private List<ProductsGetterSetter> products;
private SQLiteDataSource datasource;
private TextView toolbarTitle;
private String fbId;
private String name;
private TextView notifBubbleText;
private TextView inboxBubbleText;
private ArrayList<NotificationSetter> notifications;
private SharedPreferences preferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
toolbarTitle = (TextView) findViewById(R.id.toolbar_title);
setSupportActionBar(toolbar);
/****
TextView title = (TextView) findViewById(R.id.toolbar_title);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Baron.otf");
title.setTypeface(tf);
TextView feedTv = (TextView) findViewById(R.id.feedTv);
feedTv.setOnClickListener(this);
TextView shopTv = (TextView) findViewById(R.id.shopTv);
shopTv.setOnClickListener(this);
TextView sellTv = (TextView) findViewById(R.id.sellTv);
sellTv.setOnClickListener(this);
TextView likesTv = (TextView) findViewById(R.id.likesTv);
likesTv.setOnClickListener(this);
TextView myShopTv = (TextView) findViewById(R.id.myShopTv);
myShopTv.setOnClickListener(this);
// Send crash report if exists
if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler)) {
Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(this));
}
****/
}
@Override
protected void onResume() {
super.onResume();
/****
datasource = new SQLiteDataSource(this);
datasource.open();
preferences = getSharedPreferences("user", MODE_PRIVATE);
if (preferences.getString("fbId", "").equals("")) {
promtForLogin();
} else {
initialiseApp();
}
this.invalidateOptionsMenu();
****/
}
</code></pre>
<p>Gradle</p>
<pre><code>apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.cerculdivelor"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile "com.google.android.gms:play-services-gcm:8.3.0"
}
</code></pre>
| <android><performance><android-studio><android-gradle-plugin><android-5.0-lollipop> | 2016-05-09 23:18:45 | HQ |
37,127,095 | Facing some errors in c++ | <p>I am writing a program in c++11 and I have faced some problems. I am new to c++11 programming, while I used to develop in c earlier, but I want to be familiar with the new facilities of c++. </p>
<p>I will present you below the contentious part of code explaining where are the errors and what kind of them I get.</p>
<pre><code>#include <iostream>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
// A struct describing a product.
typedef struct Products
{
string category;
string name;
float price;
} Product;
inline void scenario1(int num_cashiers)
{
extern vector<Product> products; // It is a vector(a pseudo-second dimension) of products which will be used for each customer
extern vector<vector<Product> products> customers; // A vector containing all customers
vector<vector<vector<Product> products> customers> cashiers(num_cashiers); // A vector describing the supermarket cashiers declaring a queue of customers for each cashier
...
}
</code></pre>
<p>Error 1: At the second line of the function scenario1(int num_cashiers): template argument 1 is invalid</p>
<p>Error 2: At the second line of the function scenario1(int num_cashiers): template argument 2 is invalid</p>
<p>Error 3: At the second line of the function scenario1(int num_cashiers): invalid type in declaration before ';' token</p>
<p>Error 4: At the third line of the function scenario1(int num_cashiers): template argument 1 is invalid</p>
<p>Error 5: At the third line of the function scenario1(int num_cashiers): template argument 2 is invalid</p>
<p>Error 6: At the third line of the function scenario1(int num_cashiers): template argument 1 is invalid //Same error again</p>
<p>Error 7: At the third line of the function scenario1(int num_cashiers): template argument 2 is invalid //Same error again</p>
<p>Error 8: At the third line of the function scenario1(int num_cashiers): invalid type in declaration before '(' token</p>
<p>So, where am I wrong and what do I have to do to fix the errors?</p>
<p>I would appreciate any help!</p>
| <c++><templates><c++11> | 2016-05-09 23:38:40 | LQ_CLOSE |
37,127,159 | Live regular expression highlighting | <p>I am attempting to use JavaScript to highlight regular expression matches in real time. Similar to sites such as <a href="http://regexr.com/" rel="nofollow">http://regexr.com/</a></p>
<pre><code><p id="haystack"> Sample text Sample Text Sample Text Sample Text </p>
<form>
<input id="needle" onkeyup="highlight('haystack')" onkeydown="highlight('haystack')" type="text" placeholder="Enter Pattern" autofocus>
</form>
function highlight(e){
var pattern = document.getElementById('needle');
var consoleText = document.getElementById('haystack').innerHTML;
consoleText = consoleText.replace(pattern.value,"replaced");
document.getElementById('haystack').innerHTML = consoleText;
</code></pre>
<p>I'm very new to JavaScript. How can I achieve the desired effect?</p>
| <javascript> | 2016-05-09 23:47:44 | LQ_CLOSE |
37,127,221 | How to link thumbnail to a video on a new page | <p>When I click on a thumbnail, I want to have another web page open up with the video of that thumbnail. How would I do that? Thank you for your time.</p>
| <javascript><php><jquery><html> | 2016-05-09 23:55:56 | LQ_CLOSE |
37,127,223 | Translate Message to Morse Code | <p>I am trying to translate a message into morse code. I am wondering how I can do this without typing a replace line (message = message.replace('a', '.-') for every single letter. Our instructor has provided us with this list of morse code to use. </p>
<pre><code>code = [["a", ".-"],["b","-..."],["c","-.-."],["d","-.."],
["e","."],["f","..-."],["g","--."],["h","...."],
["i",".."],["j",".---"],["k","-.-"],["l",".-.."],
["m","--"],["n","-."],["o","---"],["p",".--."],
["q","--.-"],["r",".-."],["s","..."],["t","-"],
["u","..-"],["v","...-"],["w",".--"],["x","-..-"],
["y","-.--"],["z","--.."]]
</code></pre>
<p>Thanks!</p>
| <python> | 2016-05-09 23:56:11 | LQ_CLOSE |
37,127,330 | Unrecognized manifest key 'applications'. warning for Google Chrome | <p>I have created my Web Extension for Firefox which uses Chrome Extension API.</p>
<p>But Firefox requires <code>application</code> key in <code>manifest.json</code></p>
<p><a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json" rel="noreferrer">https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json</a></p>
<p>If I load the same extension for Google Chrome, Chrome warns as:</p>
<pre><code>There were warnings when trying to install this extension:
Unrecognized manifest key 'applications'.
</code></pre>
<p>Although the extension works, I am not sure if I can send a Firefox Web Extension to Google Chrome Store with this manifest file.</p>
<p>I can create another project for Google Chrome but I want to keep a single folder that may work for both Firefox and Google Chrome without any warnings.</p>
<p>How I am suppose to fix this warning while keeping Firefox requirements?</p>
| <google-chrome><firefox><google-chrome-extension><chrome-web-store><firefox-webextensions> | 2016-05-10 00:09:07 | HQ |
37,127,386 | lex/yacc multiples outputs files | I am working with lex and yacc, and I need to create two output files. What do I need to do (if there is any function to make multiple files), and how do I name each file?
If someone could provide a simple example of how to generate two output files. | <bison><flex-lexer><yacc><lex> | 2016-05-10 00:16:54 | LQ_EDIT |
37,127,422 | How to split a string by uppercase and lowercase in JavaScript? | <p>Is it possible to split Strings in JavaScript by case such that the following string below (myString) would be converted into the array (myArray) below:</p>
<pre><code>var myString = "HOWtoDOthis";
var myArray = ["HOW", "to", "DO", "this"];
</code></pre>
<p>I have tried the regex below, but it only splits for camelCase:</p>
<pre><code>.match(/[A-Z]*[^A-Z]+/g);
</code></pre>
| <javascript><regex> | 2016-05-10 00:21:55 | HQ |
37,127,441 | Can an object belong to two classes? | <p>Just started learning Java, through the "hello world" app, k learned about the object System.out.</p>
<p>Out is an object, but to use it, we have to write system in front of it. It's obvious and my book says that out belongs to system class.</p>
<p>But later in the book, my book says out also belongs to PrintStream class. That is what enable us to use println methods because they both belong to PrintStream class. </p>
<p>I am confused what class does out belong to?</p>
<p>Also, is it just a convention that for objects like out, we have to write the class as well whenever we use it. For something like;</p>
<blockquote>
<p>String greeting = "Hello, World!";
If we want to use .length() method which I guess also belongs to string class, we DONT write:
int n=String.greeting.length()</p>
</blockquote>
<p>Instead, it's just:
int n=greeting.();</p>
| <java> | 2016-05-10 00:24:47 | LQ_CLOSE |
37,127,817 | Display series of images like a gif in Swift | <p>I'm trying to show 100 images frame by frame similar to how a gif would work in my Swift app. Since gifs are not supported in UIImageView, I've read that its best to just switch the images rapidly with code. I've tried doing what some other tutorials say but it all comes up with errors. I'm pretty new to Swift, so I'm quite confused. I know I need to store them in an array of some sort but would some one be able to tell me the exact syntax? And also whatever I need to do in the actual storyboard along with the code.
Thanks!</p>
| <ios><xcode><swift> | 2016-05-10 01:20:22 | LQ_CLOSE |
37,128,262 | nginx unexpected end of file, expecting ";" or "}" in /etc/nginx/sites-enabled/default:20 over Raspbian | <p>I'm new at nginx and Raspberry.</p>
<p>I installed nginx using </p>
<blockquote>
<p>sudo apt-get install</p>
</blockquote>
<p>And everything was fine at that point. The problem came when I tried to restart nginx, It threw this error</p>
<blockquote>
<p>Job for nginx.service failed. See 'systemctl status ngins.service' and 'journaldtl -xn' for details</p>
</blockquote>
<p>After an investigation I found that the problem is the next error:</p>
<blockquote>
<p>unexpected end of file, expecting ";" or "}" in /etc/nginx/sites-enabled/default:20</p>
</blockquote>
<p>My default file is:</p>
<pre><code># Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
listen 80;
server_name $domain_name;
root /var/www;
index index.html index.htm;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# Make site accessible from http://localhost/
server_name localhost;
location /
</code></pre>
<p>I hope you can help me :)</p>
| <nginx><raspbian><raspberry-pi3> | 2016-05-10 02:20:05 | HQ |
37,128,554 | Android Layouting Inquiry | Hi I would like to know ho to make this layout in android I will be adding an image on the 2 columns below that is clickable. This is my first time doing android development
[![enter image description here][1]][1]
[1]: http://i.stack.imgur.com/RUEDg.jpg | <android><android-layout> | 2016-05-10 02:59:50 | LQ_EDIT |
37,129,020 | AWS S3 integration yields undefined method `match' | <p>I'm working on a simple project using Paperclip to upload images. Everything has been working just fine until I attempted to integrate S3 with Paperclip. Upon 'uploading' a user's image I get a <code>NoMethodError (undefined method 'match' for nil:NilClass):</code> error. This only happens when I have my S3 configuration running - if I comment it out the file uploads perfectly. </p>
<p>My configuration:</p>
<pre><code>development.rb:
....
....
config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => ENV['AWS_BUCKET_ID'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
</code></pre>
<p>My Model:</p>
<pre><code> class User < ActiveRecord::Base
has_attached_file :image_file, default_url: "/myapp/images/:style/missing.png"
validates_attachment_file_name :image_file, matches: [/png\Z/, /jpeg\Z/, /tiff\Z/, /bmp\Z/, /jpg\Z/]
</code></pre>
<p>entire error output from console:</p>
<pre><code>NoMethodError (undefined method `match' for nil:NilClass):
app/controllers/images_controller.rb:33:in `block in create'
app/controllers/images_controller.rb:32:in `create'
</code></pre>
<p>Things I tried:</p>
<ul>
<li><p>I added the AWS keys and bucket name directly into the code instead
of as an environmental variable.</p></li>
<li><p>As mentioned above, I commented out the AWS configuration in my environment file and it seemed to work perfectly.</p></li>
</ul>
<p>It's probably worth mentioning that I installed the <code>fog</code> gem earlier to start configuring for Google Cloud Storage, but decided to stick with S3 instead. I used <code>gem uninstall fog</code> to remove the gem but it appears some dependencies stayed behind. </p>
| <ruby-on-rails><amazon-s3><paperclip> | 2016-05-10 03:56:50 | HQ |
37,130,469 | display images in asp.net c#? | How to display images in different formats?
I tried this.
context.Response.ContentType = "image/jpeg";
This will display only jpeg images.But I need to display images in different formats.
| <c#><asp.net> | 2016-05-10 06:08:09 | LQ_EDIT |
37,131,462 | Comparing logical values to NaN in pandas/numpy | <p>I want to do an element-wise OR operation on two pandas Series of boolean values. <code>np.nan</code>s are also included.</p>
<p>I have tried three approaches and realized that the expression "<code>np.nan</code> or <code>False</code>" can be evaluted to <code>True</code>, <code>False</code>, and <code>np.nan</code> depending on the approach.</p>
<p>These are my example Series: </p>
<pre><code>series_1 = pd.Series([True, False, np.nan])
series_2 = pd.Series([False, False, False])
</code></pre>
<h3>Approach #1</h3>
<p>Using the <code>|</code> operator of pandas: </p>
<pre><code>In [5]: series_1 | series_2
Out[5]:
0 True
1 False
2 False
dtype: bool
</code></pre>
<h3>Approach #2</h3>
<p>Using the <code>logical_or</code> function from numpy:</p>
<pre><code>In [6]: np.logical_or(series_1, series_2)
Out[6]:
0 True
1 False
2 NaN
dtype: object
</code></pre>
<h3>Approach #3</h3>
<p>I define a vectorized version of <code>logical_or</code> which is supposed to be evaluated row-by-row over the arrays:</p>
<pre><code>@np.vectorize
def vectorized_or(a, b):
return np.logical_or(a, b)
</code></pre>
<p>I use <code>vectorized_or</code> on the two series and convert its output (which is a numpy array) into a pandas Series:</p>
<pre><code>In [8]: pd.Series(vectorized_or(series_1, series_2))
Out[8]:
0 True
1 False
2 True
dtype: bool
</code></pre>
<h3>Question</h3>
<p>I am wondering about the reasons for these results.<br>
<a href="https://stackoverflow.com/a/17274707/6295616">This answer</a> explains <code>np.logical_or</code> and says <code>np.logical_or(np.nan, False)</code> is be <code>True</code> but why does this only works when vectorized and not in Approach #2? And how can the results of Approach #1 be explained? </p>
| <python><numpy><pandas> | 2016-05-10 07:03:56 | HQ |
37,132,040 | duplicate entry: com/android/volley/AuthFailureError.class while compiling project in android studio | <p>I am using external libraries payu money sdk and linkedin-sdk, both uses volley libraries, which while compiling project gives duplicate entry of AuthFailureError.class</p>
<p>Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.</p>
<blockquote>
<p>java.util.zip.ZipException: duplicate entry: com/android/volley/AuthFailureError.class"</p>
</blockquote>
<p>i have also added following code to exclude module, but still same error</p>
<p><code>configurations{
all*.exclude module: 'com.android.volley'
}</code></p>
<p>please help</p>
| <android><android-studio><android-build> | 2016-05-10 07:35:12 | HQ |
37,132,917 | Grunt-eslint & enabling `--fix` flag to auto fix violations | <p>I know <code>eslint</code> CLI itself has a <code>--fix</code> flag, but I can't tell from the documentation how to use this via <code>eslintConfig</code> (in <code>package.json</code>) or in the grunt-eslint configuration in my Gruntfile.</p>
<p>I have the following config in <code>package.json</code>:</p>
<pre><code>"env": {
"browser": true,
"amd": true
},
"extends": "eslint:recommended",
</code></pre>
<p>and invoke it via a <code>lint</code> task using this Grunt config:</p>
<pre><code> eslint: {
target: [
'src/app/**/*.js'
],
format: 'checkstyle'
},
</code></pre>
<p>How can I enable the <code>--fix</code> flag in this scenario?</p>
| <javascript><gruntjs><eslint><grunt-eslint> | 2016-05-10 08:21:33 | HQ |
37,133,114 | How do I update a Kubernetes autoscaler? | <p>I have created a <a href="http://kubernetes.io/v1.1/docs/user-guide/horizontal-pod-autoscaler.html" rel="noreferrer">Kubernetes autoscaler</a>, but I need to change its parameters. How do I update it?</p>
<p>I've tried the following, but it fails:</p>
<pre><code>✗ kubectl autoscale -f docker/production/web-controller.yaml --min=2 --max=6
Error from server: horizontalpodautoscalers.extensions "web" already exists
</code></pre>
| <kubernetes><autoscaling> | 2016-05-10 08:31:30 | HQ |
37,133,200 | Is DMARC the end of email forwarding? | <p>I'm using a fair bit of email forwarding on a number of domains and the latest p=reject policy of AOL is causing me some problems and also a lot of confusion. My understanding of DMARC is that it's based on DKIM & SPF with a reporting layer. I understand that SPF is a problem with forwarding but as long as the SPF is set to ~all soft fail then that isn't a show stopper. I also thought DKIM could pass through forwarding without problems as long as you don't mess with the headers much. However I'm finding that certain emails from AOL being forwarded by MailGun are failing DMARC when they land at GMail. MailGun say its due to a sender/from mismatch error. Can anyone elaborate on whether email forwarding is doomed as DMARC takes hold or are MailGun just not forwarding properly?</p>
| <email><mailgun><forwarding><email-forwarding><dmarc> | 2016-05-10 08:35:14 | HQ |
37,133,678 | Why do we use HTTP? | <p>I understand the use of HTTP and how it works but i couldn't find a simple and precise answer that why we use HTTP to access any website?</p>
<p>PS: I am aware about it power .i.e. client server model, connection-less, stateless, SSL/TLS etc but that doesn't justify me why to use it.</p>
| <http> | 2016-05-10 08:57:55 | LQ_CLOSE |
37,134,652 | How to change the assembly code in this shell for make it work with any IP and port? | I have read this blog: https://www.rcesecurity.com/2014/07/slae-shell-reverse-tcp-shellcode-linux-x86/, In the complete shellcode, As you read it, I ask the guy who created that blog, he say: "keep in mind that your port or ip should not contain a \x00, which could break it. If your IP contains a zero like 192.168.0.1 or your port contains a zero like 80, the shellcode will likely fail when you use it with a remote exploit". and I ask what IP and port can work with this shell code,he say:"all IPs and ports that do not contain a zero in their network byte-order representation. So 0x0101017f which is the network-byte order representation of 127.1.1.1 is fine. 0x100007f which would be 127.0.0.1 is not working". So can anyone help me how to edit just one thing :
`push 0x0101017f ;sin_addr=127.1.1.1 (network byte order)
push word 0x3905 ;sin_port=1337 (network byte order)
inc ebx
push word bx ;sin_family=AF_INET (0x2)
mov ecx, esp ;save pointer to sockaddr struct`
To make the the shell work with any ip address and port number.???
| <c><linux><shell><sockets><networking> | 2016-05-10 09:39:26 | LQ_EDIT |
37,134,911 | how to compare string without case sensitive using c#? | <p>What is the best way to compare two string without case sensitive using c#?
Am using the below codes. </p>
<pre><code>string b = "b";
int c = string.Compare(a, b);
</code></pre>
| <c#> | 2016-05-10 09:49:55 | LQ_CLOSE |
37,135,041 | change navigation drawer selected item on fragment backstack change | <p>I have two fragments <code>FragmentHome</code> and <code>FragmentAbout</code>, I have added <code>NavigationDrawer</code> to app when I click <code>Home</code> it opens <code>FragmentHome</code> and <code>About</code> opens <code>FragmentAbout</code>, when I open <code>FragmentAbout</code> I am also adding it to backstack. This is working fine.</p>
<p>Now the problem is when I click on <code>About</code> and press back button it goes to the <code>FragmentHome</code> but the <code>NavigationDrawer</code> still shows the <code>About</code> as selected item, I want to change this selected item to <code>Home</code> when I press back button from <code>FragmentAbout</code></p>
<p>Home Activity:</p>
<pre><code>public class ActivityHome extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
Toolbar toolbar;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
// Toolbar
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Drawer layout
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.nav_drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.nav_drawer_open, R.string.nav_drawer_close);
assert drawer != null;
drawer.setDrawerListener(toggle);
toggle.syncState();
// Navigation view
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
assert navigationView != null;
navigationView.setNavigationItemSelectedListener(this);
// Open first menu item
navigationView.getMenu().performIdentifierAction(R.id.nav_home, 0);
// Set first item checked
navigationView.setCheckedItem(R.id.nav_home);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
final MenuItem menuItem = item;
// Check if menu item is selected
if (item.isChecked())
item.setChecked(false);
else
item.setChecked(true);
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_home) {
// Open home fragment
getSupportFragmentManager().beginTransaction()
.replace(R.id.frame_layout, new FragmentHome())
.commit();
} else if (id == R.id.nav_about) {
toolbar.setTitle("About");
// Open home fragment
getSupportFragmentManager().beginTransaction()
.replace(R.id.frame_layout, new FragmentAbout())
.addToBackStack(null)
.commit();
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.nav_drawer_layout);
assert drawer != null;
drawer.closeDrawer(GravityCompat.START);
return true;
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.nav_drawer_layout);
assert drawer != null;
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}}
</code></pre>
<p>FragmentHome</p>
<pre><code>public class FragmentHome extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_home, container, false);
}
@Override
public void onResume() {
super.onResume();
((AppCompatActivity)getActivity()).getSupportActionBar().setTitle(R.string.fragment_home_title);
}
}
</code></pre>
<p><code>FragmentAbout</code> code is same as <code>FragmentHome</code> just layout change.</p>
<p>I have searched a lot on stackoverflow but didn't find any solution yet, so if someone know how to do this please tell me.</p>
| <android><android-fragments><navigation-drawer><fragmenttransaction><fragment-backstack> | 2016-05-10 09:55:09 | HQ |
37,135,452 | parse a csv file in C# , any help appreciated | String[] values = File.ReadAllText(@"C:/Users/state.csv").Split(',');
Console.WriteLine(values);
Console.ReadLine();
it just prints out :
System.String[] onto console and the program is running for a long time | <c#> | 2016-05-10 10:11:34 | LQ_EDIT |
37,136,613 | How can i write to a csv file? | <p>I need to update a stock list, how can I write to a CSV file in this way. How do you write to a CSV file please? i have tried searching this but nothing really explains why they have done this.</p>
| <python><csv> | 2016-05-10 11:00:57 | LQ_CLOSE |
37,136,634 | I wanna replace the % mark to - this mark of url | <p>I wanna replace the % mark to - this mark of url </p>
<p>from </p>
<blockquote>
<p>`<a href="http://localhost/news/news/6/1/my%news%of%bangla" rel="nofollow">http://localhost/news/news/6/1/my%news%of%bangla</a>
to</p>
<p><a href="http://localhost/news/news/6/1/my-news-of-bangla" rel="nofollow">http://localhost/news/news/6/1/my-news-of-bangla</a></p>
</blockquote>
| <php><.htaccess> | 2016-05-10 11:01:51 | LQ_CLOSE |
37,136,985 | import { * } from "@angular" instead of "angular2" | <p>I am little confused here in angular2. Many example show like</p>
<pre><code>import { Component } from "@angular/core"
</code></pre>
<p>But actually in <code>node_module</code> there is <code>angular2</code>directory exists. So logically it should be</p>
<pre><code>import { Component } from "angular2/core"
</code></pre>
<p>What is the difference between this two ?</p>
| <typescript><angular><commonjs> | 2016-05-10 11:17:33 | HQ |
37,137,008 | On button tapping how to back on previous app IOS (Swift)? | On tapping push notification my app launched, now i want go back on previous app on tapping button from my app in (Swift). How do i achieve?
Thanks,
Sanjay | <ios><swift> | 2016-05-10 11:18:53 | LQ_EDIT |
37,137,521 | What happens when you run ng serve? | <p>I've been using <a href="https://github.com/angular/angular-cli">Angular-CLI</a> for the last little while. It comes with a number of commands including <code>ng serve</code> which spins up a server at <code>localhost:4200</code>.</p>
<p>I'm used to using Grunt and Gulp which can be configured to suit my needs. I wanted to configure Angular-CLI's server but then I realized I didn't know what it was or how to configure it. Grepping the project for <code>serve</code> hasn't unearthed anything that seems useful.</p>
<p>So, what exactly does <code>ng serve</code> do?</p>
| <angular><angular-cli> | 2016-05-10 11:42:39 | HQ |
37,137,799 | JQuery: sort td values on multiple tables | I'd need to sort the first td elements of a 3 html tables. I must use Jquery to do it. Not pure javascript.
Exemple:
<table>
<tr>
<td>cx</td>
<td>xx</td>
</tr>
</table>
<table>
<tr>
<td>bx</td>
<td>xx</td>
</tr>
</table>
<table>
<tr>
<td>ax</td>
<td>xx</td>
</tr>
</table>
The result I would like to get is:
<table>
<tr>
<td>ax</td>
<td>xx</td>
</tr>
</table>
<table>
<tr>
<td>cx</td>
<td>xx</td>
</tr>
</table>
<table>
<tr>
<td>ex</td>
<td>xx</td>
</tr>
</table>
I have tried to use $.each loop to | <javascript><jquery><jquery-selectors> | 2016-05-10 11:54:41 | LQ_EDIT |
37,138,544 | How to copy A1:A3 to B1,C1,D1.Then Copy A4:A6 to B2,C2,D2,Then copy A7:A9 to B3,C3,D3 | I need to edit my excel worksheet in such a way as shown:
A1,A2,A3 needs to be copied to B1,C1,D1
A4,A5,A6 needs to be copied to B2,C2,D2
A7,A8,A9 needs to be copied to B3,C3,D3
How do I achieve this if I have data upto A100 ?
| <excel><vba> | 2016-05-10 12:26:49 | LQ_EDIT |
37,139,053 | Difference between ToCharArray and ToArray | <p>What is the difference between <code>ToCharArray</code> and <code>ToArray</code></p>
<pre><code>string mystring = "abcdef";
char[] items1 = mystring.ToCharArray();
char[] items2 = mystring.ToArray();
</code></pre>
<p>The result seems to be the same.</p>
| <c#><arrays><string> | 2016-05-10 12:48:50 | HQ |
37,139,196 | Error in printing the elements of vector | in the following code, I have a 2D vector,in each index of vector each pair contains int and string. I am trying to access the each element after taking the values in the vector. Suggestions will be very much appreciated.
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,string>> aye[100001];
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; ++i)
{
cin >> x;
cin >> a >> b;
aye[a].push_back(make_pair(-b,x));
cout<<aye[a].first<<aye[a].second;//this is not working
cout<<aye[a][0]<<aye[a][1]<<endl;//this is not working
}
} | <c++><vector><std-pair> | 2016-05-10 12:54:46 | LQ_EDIT |
37,140,038 | How can I make my program work | So today I made this program that is supposed to encrypt a password that you put into it. But when ever I run it it comes up with this:
Password = float(input('Enter Password: '))
ValueError: could not convert string to float: 'Banana' (the word I chose for this test)
I have asked some of my friends but they don't know. Any suggestions on how I could fix this.
Please keep in mind that I am a noob at this so I might have made some mistakes.
#Macchiat0
#10 May 2016
#This program will encrypt and decrypt user passwords.
#init
encryptionlist = (('a','q'), ('b','w'), ('c','e'), ('d','r'), ('e','t'), ('f','y'), ('g','u'), ('h','i'), ('i','o'), ('j','p'), ('k','a'), ('l','s'), ('m','d'), ('n','f'), ('o','g'), ('p','h'), ('q','j'), ('r','k'), ('s','l'), ('t','z'), ('u','x'), ('v','c'), ('w','v'), ('x','b'), ('y','n'), ('z','m'))
print('This program will encrypt and decrypt user passwords')
#Program Menu
ans=True
while True:
print('1. Enter 1 to encrypt a password: ')
print('2. Enter 2 to decrypt a password: ')
print('3. Exit/Quit')
ans = input('What do you want to do? ')
if ans=="1":
print("\n Enter 1 to encrypt a password: ")
Password = float(input('Enter Password: '))
print('Your new encryptid password is:',Password,'')
if ans=="2":
print("\n Enter 2 to decrypt a password: ")
Password = float(input('Enter Password: '))
print('Your new decryptid password is:',Password,'')
elif ans=="3":
print("\n Goodbye")
break
else:
print("\n Not Valid Choice Try Again")
| <python><encryption><password-storage> | 2016-05-10 13:29:11 | LQ_EDIT |
37,140,485 | Why you would choose ASP.NET MVC over SPA + ASP.NET WebAPI? | <p>I'm asking this just to see experiences from others.
For most of the cases having ASP MVC web site is an overhead. At least for me it's much cleaner and easier to have WebAPI which responds with JSON and then you can attach either SPA application or Mobile app or whatever.</p>
<p>I have a feeling that if you are using ASP MVC controllers will not be controllers, but controllers full of the if conditions and some session bags which are hanging around. Views are combination of HTML and Razor which in most cases looks really ugly and full of "TODOs" ;) </p>
<p>I can understand if it's used in older projects and now we just need to maintain them. But when you are starting a new one, why you would choose ASP.NET MVC or any other similar framework?</p>
| <c#><.net><asp.net-mvc><asp.net-web-api> | 2016-05-10 13:48:49 | LQ_CLOSE |
37,140,503 | Wordpress best learning path | <p>Guys I am very good in <strong>PHP, Sql, HTML, CSS, Bootstrap, jQuery</strong> and others plus I know how to work with <strong>Laravel Frameword</strong>.
I decided to start learning <strong>Wordpress</strong> because it is easy and fast in web development.</p>
<p>The question is what is the best path or tutorial should I start learning while I have all those web design and development background.</p>
<p>I found many tutorials on Youtube but I am very dispersed and don't know from where to start and what is the best tutorial I should start with.</p>
<p>Thanks</p>
| <php><html><wordpress> | 2016-05-10 13:49:32 | LQ_CLOSE |
37,140,877 | How i can access to JSON data? | <p>i have created a dynamic array and then, i convert it to json object. The code is the follows:</p>
<pre><code>$array_D1[]="";
$array_D2[]="";
$array_to_send[]="";
$array_D1[$CapaEnviar][] = $fila['test_name'];
$array_D2[]=$seleccio_content;
$array_D2[]=$id_capa;
$array_D2[]=$pagina;
$array_D2[]=$idtest;
$array_D2[]=$valor_org;
$array_D2[]=$valor_eval;
$array_D2[]=$valor_test;
$array_to_send=array('data1' => $array_D1, 'data2' => $array_D2);
echo json_encode($array_to_send,true);
</code></pre>
<p>This code is a AJAX response for an AJAX request. I don't know how i can access JSON data from jquery.</p>
<p>i need to acces the values from "data1" and "data2"</p>
| <jquery><ajax> | 2016-05-10 14:04:42 | LQ_CLOSE |
37,141,289 | Standart deviation for each column | [Example][1]
I need to find sd of Norm for each column value in a row, e.g sd(c(4,2) for 1 May
[1]: http://i.stack.imgur.com/0hK68.png
| <r> | 2016-05-10 14:21:38 | LQ_EDIT |
37,141,309 | name 'A' is not defined | <p>I am trying to learn opencv using python, when I try to define a variable, I got the same error. </p>
<p>this is my code </p>
<pre><code>import numpy as np
import cv2
img = cv2. imread('love.jpg', 1)
cv2. imshow('image', img)
A == cv2.waitkey(0) & 0xFF
if A == 27:
cv2.destroyAllWindows()
elif A == ord('s'):
cv2.imwrite('love.png', img)
cv2.destroyAllWindows()
</code></pre>
<p>and this is the result </p>
<pre><code>NameError: name 'A' is not defined
</code></pre>
<p>I thing the problem in installing python in my device ( windows 10, 64 bit) </p>
| <python><opencv> | 2016-05-10 14:22:31 | LQ_CLOSE |
37,142,064 | null object reference error in action script | used resize handler to resize my component/. But it is throwing error:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
resize="application2_resizeHandler(event)" >
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.events.ResizeEvent;
private var employeeName:String = 'ravi';
protected function application2_resizeHandler(event:ResizeEvent):void
{
mainGroup.width = stage.width - 10;
mainGroup.x = 5;
}
]]>
</fx:Script>
<s:Group width="100%" height="100%">
<s:VGroup id="mainGroup" >
<s:Label id="employeeNameLabel" text="{employeeName}" />
<s:Label id="departmentLabel" />
</s:VGroup>
<s:Button id="getData" />
</s:Group>
</s:Application>
| <actionscript-3><flash><apache-flex><flex4> | 2016-05-10 14:52:44 | LQ_EDIT |
37,142,379 | javascript array: make object property into array key | I have an array of objects like so:
arr[0] = {name: 'name1', attribute1: 'a1Value1', attribute2: 'a2Value1'}
arr[1] = {name: 'name2', attribute1: 'a1Value2', attribute2: 'a2Value2'}
what I want to achive is to create second array with name attribute as array key so it looks like this:
arr2[name1] = {attribute1: 'a1Value1', attribute2: 'a2Value1'}
arr2[name2] = {attribute1: 'a1Value2', attribute2: 'a2Value2'}
Is there an easy and efficient way to do it with underscoreJS or plain JS? | <javascript> | 2016-05-10 15:06:31 | LQ_EDIT |
37,143,612 | What is an Enterprise architecture? | <p>I am a web developer, I want to become software architect, and I learn everyday about it, but when I am learning software architecture I see TOGAF framework for enterprise architecture, I want to get solid understand in an <strong>enterprise architecture</strong>.</p>
| <architecture><enterprise><solution> | 2016-05-10 16:00:20 | LQ_CLOSE |
37,145,638 | Do C++ developers commonly count on automatic casting? | I've been given the task of porting a Windows program to OS X. Originally written in C++, I'm enjoying it because I don't often work with the C family of languages, and have enjoyed making use of Objective C++ in the port.
However, the Windows source code does something strange, and I'm wondering if it's a standard practice. The API we're working with on both Windows and OS X expects a particular object method to be passed an unsigned short. The original Windows developer created the following function to calculate this value:
static unsigned short hashcode ( const char* value ) {
int h = 0 ;
unsigned long length = strlen ( value ) ;
for ( int i = 0 ; i < length ; i++ ) {
h = ( 31 * h ) + value[i] ;
}
return h ;
}
Note that while the function returns an `unsigned short`, the variable it's returning is declared as an `int`. I've checked the documentation, and both OS X and Windows define an `unsigned short` as 2 bytes and an `int` as 4.
The value being passed to this function, if the data type isn't taken into account, results in the function returning very large numbers, dozens of digits in some cases. In one case, where I duplicated the algorithm in another language with less strict types, I got a value of `2081357292912430390912`. When I wraped the above function in a command line utility, the same string returned a value of `40576`, I'm guessing because that's the truncated version of the longer value.
So I have two questions. First of all, why, if `hashcode` is declared to return an `unsigned short` and it's in fact returning and `int` doesn't the compiler complain? Isn't that what strict data type declarations are for in the first place? To make sure that functions and methods receive and return the data types expected?
And second, is this truncation a standard practice? It seems very strange to me, first of all to take advantage of the automatic casting, but also there's no commenting to call out to someone that that's what's happening (and I don't have access to the original developer to ask). Since it isn't commented as being something "special," perhaps it's simply a standard idiom in C/C++? | <c++><standards> | 2016-05-10 17:50:18 | LQ_EDIT |
37,146,397 | Python performance | <p>I have a question regarding the performance of my python program. The part which is written down is very essential and I already increased the performance with numpy. I would like to know if it is possible to make this part even faster? A 10x speed up would already be nice.. </p>
<pre><code>u = numpy.zeros((a**l, a**l))
re = numpy.zeros((a**l, a**l, a**l))
wp = numpy.zeros((a**l, 2))
...Some code which edits u,re and wp...
for x in range(N):
wavg = numpy.dot(wp[:, 0], wp[:, 1])
wp[:, 0] = 1.0/wavg*numpy.dot(u, numpy.multiply(wp[:, 0], wp[:, 1]))
wp[:, 0] = numpy.tensordot(numpy.tensordot(re, wp[:, 0], axes=1), wp[:, 0],
axes=1)
</code></pre>
| <python><performance><numpy><numba> | 2016-05-10 18:36:34 | LQ_CLOSE |
37,146,474 | what I need to know to create an animated hover with javascript | <p>what I need to know to create an animated hover like this in <a href="http://www.webdesignerdepot.com/" rel="nofollow">http://www.webdesignerdepot.com/</a> menu? I know this menu is done with javascript, I have no doubt about where I should look for icons like these.</p>
| <javascript><css><hover> | 2016-05-10 18:40:09 | LQ_CLOSE |
37,148,269 | Understanding the math behind the code in C | I don't know this question is legal or not but i think every programmer can help me. It is a really basic and simple question but i have problem with understanding.
#define POLYNOMIAL(x) (((((3.0 * (x) + 2.0) * (x) - 5.0) * (x) - 1.0) *
(x) + 7.0) * (x) - 6.0)
This defination is for this polynom : (3x^5)+(2x^4)-(5x^3)-(x^2)+7x-6
How can I convert this polynom into form of the one which i have written after define. Are there any trick for this ?
| <c><math> | 2016-05-10 20:23:31 | LQ_EDIT |
37,150,815 | Adding a class to an ArrayList, but got NullPointerException | <p>So, I was trying to add a class to an ArrayList, but when I do it gives me a Null Pointer Exception. I'm sure I am just overlooking a variable that I thought was initialized, but I can't figure it out. </p>
<p>This is the class:</p>
<pre><code>enum WebType { GoogleResult, Webpage };
public class Webpage {
WebType type;
String pageName;
String content;
String url;
String MLA = "";
public Webpage(String pageName, String content, String url, WebType type){
this.type = type;
this.pageName = pageName;
this.content = content;
this.url = url;
this.MLA = ""; // Temp
}
// TODO: Make Citation Maker
</code></pre>
<p>}</p>
<p>This is where I add the class to the ArrayList:</p>
<pre><code> public void Start(){
for(Integer i = 0; i < tags.size(); i++){
if(tags.get(i) == null)
return;
Webpage page = Google(tags.get(i));
parseList.add(page); // The Error is on this line!
log.append("Added " + page.url + " to parse list");
}
for(Integer i = 0; i < parseList.size(); i++){
ParsePageCode(parseList.get(i));
}
}
</code></pre>
<p>Here is the Google function, it googles whatever you tell it to and returns the page information:</p>
<pre><code> public Webpage Google(String search){
String url = "https://www.google.com/search?q=" + search;
String content = "";
try {
URLEncoder.encode(url, "UTF-8");
} catch (UnsupportedEncodingException e) {
log.append("\n Unsupported Encoding Contacting Google");
}
try {
content = GetPageCode(url);
} catch (IOException e) {
log.append("\n Unable To Reach Google");
log.append(e.getMessage());
}
Webpage w = new Webpage("Google Result For " + search, content, url, WebType.GoogleResult);
// System.out.println(search + url + WebType.GoogleResult);
return w;
}
</code></pre>
<p>Any Ideas?</p>
| <java><arraylist><nullpointerexception> | 2016-05-10 23:53:51 | LQ_CLOSE |
37,151,509 | How to read data from an xml? | <p>I am using a web service which returns the following xml.
in c # and I made the connection and returns an object of type XmlNode</p>
<p>I need to extract these values primarily TIME_PERIOD = "2010" OBS_VALUE = " 4796580 "
I would appreciate help me</p>
<p>This is the XML</p>
<pre><code><CompactData xmlns="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message" xmlns:inegi="urn:sdmx:org.sdmx.infomodel.keyfamily.KeyFamily=inegi:TIPO_B_DSD:compact" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message SDMXMessage.xsd urn:estat:sdmx.infomodel.keyfamily.KeyFamily=inegi:DSD_TIPO_B:1.0:compact inegi:DSD_TIPO_B_Compact.xsd">
<Header>
<ID>BISE</ID>
<Prepared>2016-05-10T20:00:51</Prepared>
<Sender id="INEGI">
<Name xml:lang="en">Instituto Nacional de Estadística y Geografía</Name>
<Contact>
<Name xml:lang="en">Atención a usuarios</Name>
<Email>
http://www.inegi.org.mx/inegi/contacto/default.aspx
</Email>
</Contact>
</Sender>
</Header>
<inegi:DataSet>
<inegi:Series INDICADOR="1002000001" COBER_GEO="07000 " FREQ="V" DECIMALS="0" TOPIC="000400010001" NOTE="9,49,115,422,425">
<inegi:Obs TIME_PERIOD="2010" OBS_VALUE="4796580" OBS_STATUS="D" OBS_UNIT="Número de personas" OBS_SOURCE="487" OBS_NOTE="115,425"/>
</inegi:Series>
</inegi:DataSet>
</CompactData>
</code></pre>
| <c#><xml><web><xmlnode> | 2016-05-11 01:16:53 | LQ_CLOSE |
37,153,298 | I have a device specific issue in my android app. image icon onclick a new fragment should get loaded but instead it navigates to Dashboard . | @Override
public void onClick(View v)
{
switch (v.getId())
{
case R.id.add_deal:
Intent addDealIntent = new Intent(mContext, BaseFragmentActivity.class);
addDealIntent.putExtra("Merchant", merchantInfo);
addDealIntent.putExtra("FragmentClassName", AddDealFragment.class.getName());
addDealIntent.putExtra("toolbarTitle", "Add Deal");
mContext.startActivity(addDealIntent);
break;
case R.id.add_product:
Intent addProductIntent = new Intent(mContext, BaseFragmentActivity.class);
addProductIntent.putExtra("Merchant", merchantInfo);
addProductIntent.putExtra("Categories", mMerchantCategories);
addProductIntent.putExtra("SubCategories", mMerchantSubCategories);
addProductIntent.putExtra("SubSubCategories", mMerchantSubSubCategories);
addProductIntent.putExtra("SuperSubCategories", mMerchantSuperSubCategories);
addProductIntent.putExtra("FragmentClassName", AddProductFragment.class.getName());
addProductIntent.putExtra("toolbarTitle", "Add Product");
mContext.startActivity(addProductIntent);
break;
case R.id.dialog_button_cancel:
dismiss();
break;
default:
break;
}
dismiss();
} | <android> | 2016-05-11 04:46:42 | LQ_EDIT |
37,154,100 | Unable to call object properties from functions in JavaScript | <p>I am new to JavaScript and wanted to create a simple game of pong for practice.
I can easily draw the gaming area on the canvas but now there is some problem when I try to draw the bat.</p>
<p>I created a playerBat object with some properties.</p>
<pre><code>var playerBat = {
batWidth:20,
batHeight:100,
x:10,
y:(height/2)-(batHeight/2),
spdY:10
};
</code></pre>
<p>Then in the function "drawPlayerBat" I simply drew a rectangle with these properties as parameters.</p>
<pre><code>function drawPlayerBat() {
ctx.fillStyle = "white";
ctx.fillRect(playerBat.x, playerBat.y, playerBat.x+playerBat.batWidth, playerBat.y+playerBat.batHeight);
};
</code></pre>
<p>But its not working ! The console says "Unable to get property 'x' of undefined or null reference". Have I made any mistake in syntax or doing this is just not possible ?</p>
<p>Here is the entire code... <a href="http://codepen.io/anon/pen/YqgVog?editors=1010" rel="nofollow">http://codepen.io/anon/pen/YqgVog?editors=1010</a></p>
<p>Any help will be appreciated.
Thanks.</p>
| <javascript><function><object> | 2016-05-11 05:54:17 | LQ_CLOSE |
37,155,247 | Android which library should i use in non blocking socket programming | <p>I want to write and read data from multiple <code>sockets</code>.so i don't want to make it blocking <code>UI thread</code>.I know i can use <code>thread</code> for each connection.but before proceeding wanted to check if any good <code>3rd party library</code> is there which is useful in these kind of Application. </p>
| <android><multithreading><sockets> | 2016-05-11 06:58:00 | LQ_CLOSE |
37,157,217 | `require': cannot load such file -- nokogiri/2.1/nokogiri (LoadError) | I see many answers for this error when ruby version is =>2.2, but in my computer installed ruby version is [ruby 2.1.8p440]
I get this error when starting a server ( rails server ). | <ruby-on-rails><ruby><nokogiri> | 2016-05-11 08:36:46 | LQ_EDIT |
37,157,557 | I need an algorithm to create vouchers based on date and amount of time | <p>I need an algorithm that creates vouchers that is based on an internet kiosk timer. Basically, voucher should have the amount of time allowed encrypted into it. I was thinking of having the amount of time in hex at the start with a few random chars after it then a checksum at the end. However any other ideas are welcome</p>
| <c#><algorithm> | 2016-05-11 08:52:40 | LQ_CLOSE |
37,157,878 | Alternative for full outer join SQL | I want to display records from two tables.
It should return all the matching records from both the tables.
If a record is present in first table and not present in second table it should return null from the Second table and records from the First table
If a record is present in Second table and not present in First table it should return null from the First table and records from the second table
I don't want to use Full outer join for the same.
Is there any better solution for this scenario. | <sql><sql-server><join> | 2016-05-11 09:06:39 | LQ_EDIT |
37,158,445 | Program to print following pattern in C++ | <p>How can I produce the following pattern in C++ considering the input has odd digits.</p>
<pre><code>P M
R A
O R
G
O R
R A
P M
</code></pre>
<p>I tried the following code but I don't know how to proceed with it.</p>
<pre><code>#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char word[100];
int len, temp;
cout << "Input word with odd letters: \n";
cin >> word;
len = strlen(word);
cout << "Entered word was : "<< word << " and of size: " << strlen(word) << "\n";
if(len % 2==0)
{
cout << "Please enter a word with odd number of letters!";
}
else
{
int mid;
mid = (len - 1)/2;
cout << "The middle number is : " << mid+1 << " and character is " << word[mid] << "\n";
temp = len - 1;
for(int i=0; i<len; i++)
{
// Some logic to display it just like above
}
cout << "done" << endl;
}
}
</code></pre>
| <c++> | 2016-05-11 09:29:57 | LQ_CLOSE |
37,158,594 | What is .Net equivavelnt for Visual FoxPro Trace window while debugging | I started coding in C# and debugging is smooth if my code trows an error. But I have a code where there is no error and I miss the FoxPro Trace window to see the execution line by line.
Is there something similar in .NET IDE? | <c#><debugging> | 2016-05-11 09:36:21 | LQ_EDIT |
37,163,669 | How do i display the output of a "while loop" in a table? | I don't even have an idea of where to start for this. I need to display 100 numbers in a table and would like to use a while loop to do so. is there a "shortcut" to doing this? | <php><html><loops><tabular> | 2016-05-11 13:08:07 | LQ_EDIT |
37,165,979 | Find PinCode in file of various letters/numbers | <p><strong><em>Given a file of seemingly meaningless letters called “data.txt”, write a function findPin(inFile) that returns a four-number pin code within file. (All other characters are letters except for the pin code)</em></strong></p>
<p>I know I'm supposed to open the data file and then iterate through it until I come across a number, but I'm not sure how to go about doing this. The data.txt file is...</p>
<pre><code>loremipsumdolorsitametconsecteturadipiscingelit
seddoeiusmodtemporincididuntutlaboreetdoloremag
naaliquautenimadminimveniamquisnostrudexercitat
ionullamcolaborisnisiutaliquipexeacommodoconseq
uatduisauteiruredolorinrepre7269henderitinvolup
tatevelitessecillumdoloreeufugiatnullapariature
xcepteursintoccaecatcupidatatnonproidentsuntinc
ulpaquiofficiadeseruntmollitanimidestlaborumqwe
</code></pre>
<p>So obviously the pin number is 7269, but I need helping getting there. Sorry I'm just a beginner in python and this is really tripping me up.</p>
| <python><for-loop> | 2016-05-11 14:40:04 | LQ_CLOSE |
37,166,878 | I can't ever get Regex Right | <p>I have a query string I'm trying to remove a query string parameter. What I currently have is</p>
<p><code>date=(.*)&</code></p>
<p>But this will remove anything to the last &. I only want to remove to the first occurance of the &.</p>
<p>So this is how it should work:</p>
<p><code>date=5%2F13%2F16&tab=1&a=b</code> = <code>tab=1&a=b</code></p>
<p>But mine is doing this:</p>
<p><code>date=5%2F13%2F16&tab=1&a=b</code> = <code>a=b</code></p>
<p>I think I probably need something around the & but I read the regex stuff and I just get more confused.</p>
| <regex> | 2016-05-11 15:16:59 | LQ_CLOSE |
37,167,264 | JavaScript - Output random OBJECT from array of objects | <p>Quick question, I have an array of objects:</p>
<pre><code>var objects = [
{username: jon, count: 5},
{username: sally, count: 7},
{username: mark, count: 9,
]
</code></pre>
<p>I want to output one of these objects at random so that I can access its properties and not just it's index.
How do I do this?</p>
| <javascript><arrays><object><random> | 2016-05-11 15:35:50 | LQ_CLOSE |
37,167,682 | how to remove error: expected primary-expression before '.' token | <p>please help me remove this error i made these two structures and when i try to use the cin it shows this error how can i remove this error and please also tell me how to take a string in input using cin.getline and gets().</p>
<pre><code>#include <iostream>
using namespace std;
struct Date //Date structure
{
int day;
int month;
int year;
};
struct Employee //employee structure
{
int Id;
char Name[40];
int Date;
char Gender;
char Des[40];
};
void Setter(Employee E) //function for setting value in Employees
{
cout<<"Enter Id:";
cin>>Employee.Id;
cout<<"Enter Name:";
cin>>Employee.Name;
cout<<"Enter Gender:";
cin>>Employee.Gender;
cout<<"Enter Designation:";
cin>>Employee.Des;
cout<<"Enter Date of joining(DD/MM/YYYY):";
cin>>Employee.Date.day>>Employee.Date.month>>Employee.Date.year;
}
int main() //main
{
Employee el;
Setter(el); //calling function
return 0;
}
</code></pre>
| <c++> | 2016-05-11 15:53:38 | LQ_CLOSE |
37,168,455 | Need help fixing a nullreferenceexception occuring when initializing an object | I've tried searching the internet for a while now, and maybe I just suck at searching because I don't know how to properly phrase the problem.
Anyway, my code looks like this:
SystemOutput systemOutput = null;
SystemCL system = null;
WindowsForm wf = null;
wf = new WindowsForm(system);
systemOutput = new SystemOutput(wf);
system = new SystemCL(systemOutput, wf);
The rest of the code doesn't really matter for the matter of solving my problem (I think?)
So as you can see the objects reference eachother, which means that if the other objects hasn't been initialized yet, it will give me an error. So I tried first making them null, but now the first object get a nullreferencepointer, because the object is null.
How do I fix this puzzle? Is there a better way to do this? | <c#><nullreferenceexception><params> | 2016-05-11 16:30:50 | LQ_EDIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.