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
34,821,625
What perl web framework to use for the old CGI based perl code?
<p>Yes, while i'm working on node.js, i still love perl, :)</p> <p>The old web product is based on old perl CGI, i'm looking to the simplest way to fix XSS/Sql injection/etc. web security holes, within a week including testing, :(</p> <p>So for Catalyst Dancer Mason Maypole Mojolicious</p> <p>which one should i use in the ARM platform ? Thank you !</p>
<perl>
2016-01-15 23:30:11
LQ_CLOSE
34,821,742
Where to set cookie in Isomorphic Redux Application?
<p>I have 3 general questions about redux and isomorphic application:</p> <ul> <li><strong>What is the best way to share 'runtime' data between client and server?</strong> For instance, when the user logged in a distant API, I store the session object in cookies. In that way, <strong>next time</strong> the client requests my front-end, the front-end server can read the cookies and initialize the redux store with it's previous session. The downside of this is that the client HAS to validate/invalidate the session on boot (eg in componentDidMount of the root component). Should I request the session server side rather than read it from cookies?</li> <li><strong>Where should I execute the operation of cookie storing, in action creators or in reducers?</strong> Should I store the cookie in my reducer that handle the user session?</li> <li><strong>Where should I execute the operation of redirect the user (via react-router)?</strong> I mean when my user is successfully logged in, from where should I dispatch the redirect action (from the loginActionCreator once the login promise is resolved?, somewhere else? )</li> </ul> <p>Thanks in advance.</p>
<javascript><node.js><reactjs><redux><isomorphic-javascript>
2016-01-15 23:42:27
HQ
34,822,072
Why does Windows 10 start extra threads in my program?
<p>With Visual Studio 2015, in a new, empty C++ project, build the following for Console application:</p> <pre><code>int main() { return 0; } </code></pre> <p>Set a break point on the return and launch the program in the debugger. On Windows 7, as of the break point, this program has only one thread. But on Windows 10, it has five(!) threads: the main thread and four "worker threads" waiting on a synchronization object.</p> <p>Who's starting up the thread pool (or how do I find out)?</p>
<c++><windows><multithreading><threadpool>
2016-01-16 00:21:28
HQ
34,822,381
Error: Connection strategy not found MongoDB
<p>here is a simple connection to use express session store, it keeps banging out this error even though the text is right from the book. I am pretty sure is has something to do with 'new MongoStore' object initialization.</p> <pre><code>var express = require('express'), expressSession = require('express-session'); var MongoStore = require('connect-mongo/es5')(expressSession); var sessionStore = new MongoStore({ host: '127.0.0.1', port: '27017', db: 'session' }); var app = express() .use(expressSession({ secret: 'my secret sign key', store: sessionStore })) .use('/home', function (req, res) { if (req.session.views) { req.session.views++; } else { req.session.views = 1; } res.end('Total views for you:' + req.session.views); }) .use('/reset', function(req, res) { delete req.session.views; res.end('Cleared all your views'); }) .listen(3000); </code></pre>
<mongodb><express-session><connect-mongo>
2016-01-16 01:02:59
HQ
34,822,580
updata query from access to sql server
I have this query below from access and I need to convert it into sql server: UPDATE (CASE_INFO INNER JOIN CASE_PRICE ON CASE_INFO.CASE_TYPE = CASE_PRICE.CASE_TYPE) INNER JOIN [CASECHANGE|INPUT] ON CASE_INFO.CASE_NUMBER = [CASECHANGE|INPUT].CASE_NUMBER SET CASE_INFO.FF_REVENUE_AMT = [FF_Payment], CASE_INFO.CM_REVENUE_AMT = [CM_Payment] WHERE (((CASE_INFO.SCHEDULED_DATE) Between [CASE_PRICE].[POP_START] And [CASE_PRICE].[POP_END]) AND ((CASE_INFO.DISCONTINUE_30)=No));
<sql><sql-server><ms-access>
2016-01-16 01:35:45
LQ_EDIT
34,822,786
UIImage Caching is hight
Everyone.My English is not good.. + (nullable UIImage *)imageNamed:(NSString *)name; I use this method. --------------------------------------------------------------- e.g `UIImage *image=[UIImage imageNamed:@"test"];` --------------------------------------------------------------- But my image's type is png. [enter image description here][1] In my project,loads a lot of different images. So,My cashe is very hight [enter image description here][2] Please help me,thanks! [1]: http://i.stack.imgur.com/M2SAI.png [2]: http://i.stack.imgur.com/mCNpx.png
<ios><memory-management><uiimage>
2016-01-16 02:10:27
LQ_EDIT
34,823,611
Android dataBinding - how to use bool resource to trigger visibility of layout
<p>I currently have a bool.xml file in android which looks like this:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;bool name="showAds"&gt;true&lt;/bool&gt; &lt;/resources&gt; </code></pre> <p>Now i have a layout.xml file which uses databinding. I want to show or hide the visilibity of a adView based on a the boolean showAds defined above. So far i have this:</p> <pre><code> &lt;com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="@{@bool/showAds ? View.Visible:View:gone}" ads:adSize="BANNER" ads:adUnitId="ca-app-pub-1234567/34343"&gt; </code></pre> <p>but it does not compile. how can i get the boolean to decide if the ad should show or not ?The syntax is wrong. </p>
<android><data-binding>
2016-01-16 04:45:11
HQ
34,823,654
How would I import a module within an npm package subfolder with webpack?
<p>Lets say theres a package in <code>node_modules</code> called foo and I want to import a module within a library such as <code>foo/module</code> via webpack &amp; babel...</p> <p><code>import Foo from 'foo';</code> works</p> <p><code>import SomeOtherModule from 'foo/module';</code> fails with the following:</p> <blockquote> <p>Module not found: Error: Cannot resolve module 'foo/module' in /Users/x/Desktop/someproject/js</p> </blockquote> <p>Which makes make it seem like webpack is looking for the file in the wrong place instead of <code>node_modules</code></p> <p>My webpack.config looks like this:</p> <pre><code>var webpack = require('webpack'); var path = require('path'); module.exports = { entry: ['babel-polyfill','./js/script.js'], output: { path: __dirname, filename: './build/script.js' }, module: { loaders: [ { test: /\.js$/, loader: 'babel', query: { cacheDirectory: true, presets: ['es2015'] } } ], }, plugins: [ new webpack.NoErrorsPlugin() ], stats: { colors: true }, devtool: 'source-map' }; </code></pre>
<npm><webpack><babeljs>
2016-01-16 04:54:25
HQ
34,823,715
Cake PHP show Internal Server Error 500
Following cake php code is in index.php file when it runs on server it shows internal server error 500. <?php if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } if (!defined('ROOT')) { define('ROOT', dirname(dirname(dirname(__FILE__)))); } if (!defined('APP_DIR')) { define('APP_DIR', basename(dirname(dirname(__FILE__)))); } $vendorPath = ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib'; $dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php'; if (!defined('CAKE_CORE_INCLUDE_PATH') && file_exists($vendorPath . DS . $dispatcher)) { define('CAKE_CORE_INCLUDE_PATH', $vendorPath); } if (!defined('WEBROOT_DIR')) { define('WEBROOT_DIR', basename(dirname(__FILE__))); } if (!defined('WWW_ROOT')) { define('WWW_ROOT', dirname(__FILE__) . DS); } if (php_sapi_name() === 'cli-server') { if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['PHP_SELF'])) { return false; } $_SERVER['PHP_SELF'] = '/' . basename(__FILE__); } if (!defined('CAKE_CORE_INCLUDE_PATH')) { if (function_exists('ini_set')) { ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path')); } if (!include 'Cake' . DS . 'bootstrap.php') { $failed = true; } } else { if (!include CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php') { $failed = true; } } if (!empty($failed)) { trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } App::uses('Dispatcher', 'Routing'); $Dispatcher = new Dispatcher(); $Dispatcher->dispatch( new CakeRequest(), new CakeResponse() ); Cake PHP show Internal Server Error 500 Cake PHP show Internal Server Error 500 Cake PHP show Internal Server Error 500
<php><cakephp>
2016-01-16 05:05:45
LQ_EDIT
34,824,098
Why is SVG scrolling performance so much worse than PNG?
<p>A site I'm working on displays a large number (>50) of complex SVG images in a scrolling dialog window. When viewing the site in Chrome, the scrolling performance of the dialog window is very poor - it is noticeably laggy and slow. However, if I replace the SVG images with PNG images, the scrolling is perfectly smooth and responsive.</p> <p>Here's a demonstration of the difference: <a href="https://jsfiddle.net/NathanFriend/42knwc1s/" rel="noreferrer">https://jsfiddle.net/NathanFriend/42knwc1s/</a></p> <p>Why is the SVG scrolling performance so much worse than the PNG scrolling performance? After the browser renders an SVG image, I would assume it doesn't need to rerender the image until the image is manipulated in some way (like resizing). Does scrolling an element that contains SVG images cause the images to be rerendered for every frame of the scroll animation?</p> <p><br /></p> <pre><code> ` </code></pre>
<performance><google-chrome><svg><png><render>
2016-01-16 06:08:24
HQ
34,824,375
how can i display first 3list data instead of displaying all data in ul li using Html and css only?
<ul> <li>Karnataka</li> <li>Assam</li> <li>Gujarath</li> <li>Westbengal</li> <li>Karnataka</li> <li>Assam</li> <li>Gujarath</li> <li>Westbengal</li> <li>Karnataka</li> <li>Assam</li> <li>Gujarath</li> <li>Westbengal</li> </ul> in this i have to display first three data.
<html><css>
2016-01-16 06:50:11
LQ_EDIT
34,824,487
When is --thunder-lock beneficial?
<p>This long, detailed, and entertaining article describes the history and design of <code>--thunder-lock</code>: <a href="http://uwsgi-docs.readthedocs.org/en/latest/articles/SerializingAccept.html" rel="noreferrer">http://uwsgi-docs.readthedocs.org/en/latest/articles/SerializingAccept.html</a></p> <p>But it doesn't help me decide when I need it!</p> <p>When is and isn't <code>--thunder-lock</code> beneficial?</p>
<python><uwsgi>
2016-01-16 07:08:36
HQ
34,824,621
Opening non-default browser with lite-server in angular2 quick start guide
<p>Having followed the TypeScript version of the <a href="https://angular.io/docs/ts/latest/quickstart.html">Angular 2 Quick Start guide</a>, I was wondering if it is possible, and if so how to configure the lite-server to launch a browser other than the default.</p> <p>It seems lite-server will take command line args, served to it via <code>yargs.argv</code>. And it seems <code>yargs</code> will attempt to parse command line args based on fairly common standards (i.e. If a token begins with a <code>--</code>, it represents an argument name, otherwise an argument value) to obtain <code>argv</code>. lite-server will attempt to use the <code>open</code> property that it gets from <code>argv</code>, which is ultimately what launches the browser via [one of the of the node packages that launches processes]. node-open? xdg -open? Not sure, not really as important to me right now as long as my assumption (based on looking at several of these process launchers) is correct, that they all optionally take an argument defining the process to launch. If omitted, the default browser would be used since the file type to open is html, which is what happens.</p> <p>If all that is correct, or at least the gist of it, then it seems I just need to specify <code>--open chrome</code>, for example (assuming chrome is in my <code>PATH</code> - working on a win machine btw), at the end of the <code>lite</code> command defined in <code>package.json</code>.</p> <p>So something like...</p> <pre><code>"scripts": { "tsc": "tsc", "tsc:w": "tsc -w", "lite": "lite-server", "lite:c": "lite-server --open chrome", "lite:f": "lite-server --open firefox ", "start": "concurrent \"npm run tsc:w\" \"npm run lite\" " }, </code></pre> <p>I apologize if this seems inane, but I won't be at a computer where I can test this for a few days, and I need to know if I have the answer and can stop researching this :). Thanks!</p>
<node.js><angular><launching>
2016-01-16 07:30:10
HQ
34,824,826
How 2 fragments communicate each other inside an activity
<p>Consider an activity we can call as a base activity. Two fragments are added to this base activity , call as fragmentOne and fragentTwo.How can fragmentOne can communicate with fragentTwo and vice versa .</p>
<android><android-fragments><android-activity>
2016-01-16 07:59:04
LQ_CLOSE
34,825,119
Difficulty in creating program for admission in schools.
I had just made a project program that functions as an easy way to apply for admission in school. So far, everything went kinda okay but I am not getting the proper output. Please look into the material posted below and help me. def search(t2): t2=(('xxx',1),('yyy',2),('zzz',3)) s=input('Enter student ID=') for i in range(len(t2)): for ch in t2: if ch==s: print'Student =>',t2[i],'of Id number',t2[i+1] break else: print'Invalid Entry, try again' def details(t1): n=raw_input('Enter applicant name=') t2=(('xxx',1),('yyy',2),('zzz',3)) for i in range(len(t1)): if len(t1)<5: t2=t2+(n,i) break elif len(t1)==5: print'Sorry, class full' else: print'Sorry, class full' print'Student added successfully to class' def delete(t2): l=list(t2) j=input('Enter the student ID=') for i in range(len(t2)): for ch in l: if j==ch: del l[i] del l[i+1] break else: print'Student not found. Please try again' print tuple(l) n=input('Enter the number of students=') t1=tuple() t2=(('xxx',1),('yyy',2),('zzz',3)) name=raw_input('Enter the student name=') idn=input('Enter the Id no.=') for i in range(n): t1=t1+(name,) t1=t1+(idn,) while True: print'\n\n\t\t----Admission Menu----' print'\t\t1->Apply for admission' print'\t\t2->Search for a student' print'\t\t3->Remove a student' print'\t\t4->Exit' ch=input('Enter your choice=') if ch==1: details(t1) elif ch==2: search(t1) elif ch==3: delete(t1) elif ch==4: print'Thank You for visiting --School Name--' exit() else: print'Wrong choice, please select a valid choice and try again'
<python><python-2.7>
2016-01-16 08:42:31
LQ_EDIT
34,825,400
simple login php not working
<p>Created a simple login form but it doesnt seem to work.It always opens the admin page. </p> <pre><code>$username=$_POST["username"]; $password=$_POST["password"]; if(mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'",$con)){ session_start(); $_SESSION["username"]=$username; $_SESSION["password"]=$password; header('location:admin.html'); } else{ echo "Login Failed.&lt;a href=index.html&gt;Re Login&lt;/a"; } </code></pre> <p>Need help.And here is the html part.</p> <pre><code> &lt;form method="post" id="loginform" action="validate.php"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; &lt;label&gt;Username :&lt;/label&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="text" name="username"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;br&gt; &lt;tr&gt; &lt;td&gt; &lt;label&gt;Password :&lt;/label&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="password" name="password"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;br&gt; &lt;tr&gt; &lt;td&gt; &lt;input type="submit" id="login" value="Log In" class="btn btn-primary"/&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="reset" id="reset" value="Reset" class="btn btn-primary"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p> Need the working code in 2hrs else im dommed</p>
<php><mysql><login>
2016-01-16 09:23:17
LQ_CLOSE
34,825,675
IntelliJ annotate vs git blame
<p>I am using IntelliJ's annotate feature to see in the editor who last changed a line in a file. </p> <p>Now I am using JGit to read the same annotations and they differ. For me it seems that Intellij checks that a line has not been changed between commits and still uses the old commit message. JGit does not see it and so makes an other message. </p> <p>Can anybody confirm that the behavior of JGit blame and IntelliJ differs? Whats the reason and how can I force IntelliJ to behave the same like JGit? Maybe IntelliJ ignores whitespace changes?</p> <p>I am using IntelliJ 15.0.1 and JGit 4.1.1</p>
<git><intellij-idea><jgit><git-blame>
2016-01-16 09:57:43
HQ
34,826,163
sql sever date column sorting dates automatically
I have a table with a date column. I am inserting dates in that column using DateTimePicker in c#. Everything works fine. But I want the dates inserted in the table to be ordered. Currently when I add today's date in one row and then add yesterday's date or any past date, it gets added in the 2nd row ofc. I want that to be added in 1st row instead. Before today's date, to make all the dates in order. Is there any property of the date column I can use to ensure the dates order?
<sql><sql-server><sorting><date>
2016-01-16 10:58:46
LQ_EDIT
34,826,433
Platform invoke #define directive
<p>I am trying to understand platform invokes. So, i understood many concepts but how can i invoke <code>#define</code> directives in c#.</p> <p>Example:</p> <p>in C++ side i have this: </p> <pre><code>#define dont_care_how_you_invoke_me (ptr) </code></pre> <p>I've tried this:</p> <pre><code>[DllImport("mydll.dll")] static extern void dont_care_how_you_invoke_me(IntPtr ptr); </code></pre> <p>This didn't work. I've searched on google for a while and couldn't find anything so i'm not even sure if this is possible or not.</p> <p>Thanks in advance</p>
<c#><c++><c><pinvoke>
2016-01-16 11:31:27
LQ_CLOSE
34,826,520
How to send post parameters dynamically (or in loop) in OKHTTP 3.x in android?
<p>I am using OKHTTP 3.x version. I want to post multiple parameters and would like to add the params in a loop. I know that in version 2.x , I can use FormEncodingBuilder and add params to it in loop and then from it create a request body. But In 3.x , the class has been removed.</p> <p>Here is my current code :</p> <pre><code>RequestBody formBody = new FormBody.Builder() .add("Param1", value1) .add("Param2", value2) .build(); Request request = new Request.Builder() .url("url") .post(formBody) .build(); </code></pre> <p>Now I want to add 5 params but in a loop i.e create request body by building formbody in a loop. Like I wrote above, I know how to do it in OKHTTP version 2.x but I am using version 3.x.</p> <p>Any help or guidance is appreciated.</p> <p>Thanks in Advance</p>
<android><okhttp3>
2016-01-16 11:40:49
HQ
34,826,736
Running TensorFlow on a Slurm Cluster?
<p>I could get access to a computing cluster, specifically one node with two 12-Core CPUs, which is running with <a href="https://en.wikipedia.org/wiki/Slurm_Workload_Manager" rel="noreferrer">Slurm Workload Manager</a>.</p> <p>I would like to run <a href="https://en.wikipedia.org/wiki/TensorFlow" rel="noreferrer">TensorFlow</a> on that system but unfortunately I were not able to find any information about how to do this or if this is even possible. I am new to this but as far as I understand it, I would have to run TensorFlow by creating a Slurm job and can not directly execute python/tensorflow via ssh. </p> <p>Has anyone an idea, tutorial or any kind of source on this topic?</p>
<python><python-2.7><cluster-computing><tensorflow><slurm>
2016-01-16 12:03:59
HQ
34,827,293
How is the output of this simple java code 6 and not 4?
How is the output of this simple java code 6 and not 4? Also since int x = 10 and int y = 15, how come they are able to declare int x and int y again to be 5 and x-2? I thought you can only declare the value of an int once? thanks, sorry I'm new to java. here's the code: public class shortq { public static void main (String args[]) { int x = 10 , y =15; x = 5; y = x-2; System.out.println(x+1); } }
<java>
2016-01-16 13:04:52
LQ_EDIT
34,827,441
google chrome app offline database
I'm building starting to learn how to build an app in google chrome.. but if I have this problem which really complicates my way.. I want to my app to be operated offline only and its database is offline, this is because I will just use my app inside our office... is there a database is very simple way to connect to a database(eg: like I'll just copy paste it in my app folder)?I would prefer that the database has a very simple documentation on how to use it.. your recomendations would be of great help . .
<database><google-chrome>
2016-01-16 13:20:42
LQ_EDIT
34,827,969
joining strings in a table according to values in another column
<p>I got a table like this:</p> <pre><code>id words 1 I like school. 2 I hate school. 3 I like cakes. 1 I like cats. </code></pre> <p>Here's what I want to do, joining the strings in each row according to id. </p> <pre><code>id words 1 I like school. I like cats. 2 I hate school. 3 I like cakes. </code></pre> <p>Is there a package to do that in R?</p>
<r><string>
2016-01-16 14:17:48
LQ_CLOSE
34,828,161
Can virtual functions be constexpr?
<p>Can virtual functions like <code>X::f()</code> in the following code</p> <pre><code>struct X { constexpr virtual int f() const { return 0; } }; </code></pre> <p>be <code>constexpr</code>?</p>
<c++><c++11><virtual-functions><constexpr>
2016-01-16 14:34:02
HQ
34,828,267
PHP bug? Two functions with different names announced as redeclaration
<p>I need to declare two functions with different names (small 'i' and big "I").</p> <pre><code>function i() { echo 'Small i'; } function I() { echo 'Big I'; } </code></pre> <p>PHP's output is:</p> <pre><code>PHP Fatal error: Cannot redeclare I() </code></pre> <p>Why? Small "i" is not big "I".</p> <p>I tested it in Linux and in Windows.</p>
<php>
2016-01-16 14:47:21
LQ_CLOSE
34,828,418
What do 3 dots/periods/ellipsis in a relay/graphql query mean?
<p>The <a href="https://facebook.github.io/relay/docs/graphql-object-identification.html#content" rel="noreferrer">relay docs</a> contain this fragment:</p> <pre><code>query RebelsRefetchQuery { node(id: "RmFjdGlvbjox") { id ... on Faction { name } } } </code></pre> <p>What does this <code>... on Faction</code> on syntax mean?</p>
<relayjs><graphql>
2016-01-16 15:02:23
HQ
34,828,768
Is NodeJS required for a build Electron App?
<p>I have created my own app using electron and now built it using electron-packager to an .app file.</p> <p>Of course on my Mac — with NodeJS installed — it works. Now I wonder if it would work if I sent my app to a friend who doesn't have NodeJS installed. So my question is: <strong>Is NodeJS required to run a packaged electron app?</strong></p> <p>Thank you!</p>
<javascript><node.js><electron>
2016-01-16 15:35:58
HQ
34,829,488
Unable to work with React Native Async Storage
<p>I am having difficulty working with react native async storage. Most of the time my code jumps off the current execution and goes to the next line without getting the results from the current line. I am getting errors most of the time.</p> <p>I tried this example-</p> <pre><code>'use strict'; var React = require('react-native'); var { AsyncStorage, PickerIOS, Text, View } = React; var PickerItemIOS = PickerIOS.Item; var STORAGE_KEY = '@AsyncStorageExample:key'; var COLORS = ['red', 'orange', 'yellow', 'green', 'blue']; var BasicStorageExample = React.createClass({ componentDidMount() { this._loadInitialState().done(); }, async _loadInitialState() { try { var value = await AsyncStorage.getItem(STORAGE_KEY); if (value !== null){ this.setState({selectedValue: value}); this._appendMessage('Recovered selection from disk: ' + value); } else { this._appendMessage('Initialized with no selection on disk.'); } } catch (error) { this._appendMessage('AsyncStorage error: ' + error.message); } }, getInitialState() { return { selectedValue: COLORS[0], messages: [], }; }, render() { var color = this.state.selectedValue; return ( &lt;View&gt; &lt;PickerIOS selectedValue={color} onValueChange={this._onValueChange}&gt; {COLORS.map((value) =&gt; ( &lt;PickerItemIOS key={value} value={value} label={value} /&gt; ))} &lt;/PickerIOS&gt; &lt;Text&gt; {'Selected: '} &lt;Text style={{color}}&gt; {this.state.selectedValue} &lt;/Text&gt; &lt;/Text&gt; &lt;Text&gt;{' '}&lt;/Text&gt; &lt;Text onPress={this._removeStorage}&gt; Press here to remove from storage. &lt;/Text&gt; &lt;Text&gt;{' '}&lt;/Text&gt; &lt;Text&gt;Messages:&lt;/Text&gt; {this.state.messages.map((m) =&gt; &lt;Text key={m}&gt;{m}&lt;/Text&gt;)} &lt;/View&gt; ); }, async _onValueChange(selectedValue) { this.setState({selectedValue}); try { await AsyncStorage.setItem(STORAGE_KEY, selectedValue); this._appendMessage('Saved selection to disk: ' + selectedValue); } catch (error) { this._appendMessage('AsyncStorage error: ' + error.message); } }, async _removeStorage() { try { await AsyncStorage.removeItem(STORAGE_KEY); this._appendMessage('Selection removed from disk.'); } catch (error) { this._appendMessage('AsyncStorage error: ' + error.message); } }, _appendMessage(message) { this.setState({messages: this.state.messages.concat(message)}); }, }); exports.title = 'AsyncStorage'; exports.description = 'Asynchronous local disk storage.'; exports.examples = [ { title: 'Basics - getItem, setItem, removeItem', render(): ReactElement { return &lt;BasicStorageExample /&gt;; } }, ]; </code></pre> <p>This works. But, my functions doesn't work as expected. I am getting <code>undefined</code>.</p>
<react-native>
2016-01-16 16:47:34
HQ
34,829,600
Why is the maximal path length allowed for unix-sockets on linux 108?
<p>When creating a unix socket, the path name (<code>man 7 unix</code>) is allowed to be maximally 108 chars long. For a friend this caused a bug in his program because his path was longer. Now we wonder how exactly that number was determined.</p> <p>I have the suspicion that the number was determined so that <code>sizeof</code> of that struct <code>sockaddr_un</code> is unambiguous compared to the sizeof of other sockaddresses like <code>sockaddr_in</code>. But if they wanted to avoid clashes with other sizeof values, why not use a prime number for example? Can someone please provide an authorative source for that?</p>
<c><linux><sockets><unix-socket>
2016-01-16 16:58:49
HQ
34,829,673
build script in package.json using webpack with --config flag as
<p>In my package.json I'm trying to use <code>webpack</code> in a script but it keeps failing.</p> <pre><code> "scripts": { "start": "node server.js", "test": "mocha 'src/**/test*.coffee' --watch --compilers coffee:coffee-script/register", "build": "webpack --config webpack.dist.config.js" }, </code></pre> <p>the scripts <code>start</code> and <code>test</code> works as expected but when running <code>npm build</code> in terminal I'm getting nothing:</p> <pre><code>➜ client git:(master) ✗ npm build ➜ client git:(master) ✗ </code></pre> <p>When running the command manually, things happen:</p> <pre><code>➜ client git:(master) ✗ webpack --config webpack.dist.config.js Hash: 9274a04acd39605afc25 Version: webpack 1.9.10 Time: 5206ms Asset Size Chunks Chunk Names bundle.js 5.23 MB 0 [emitted] main [0] multi main 28 bytes {0} [built] [349] ../config.js 181 bytes {0} [built] + 413 hidden modules ➜ client git:(master) ✗ </code></pre> <p>Have I miss understod how npm scripts are suppose to work?</p>
<npm>
2016-01-16 17:06:47
HQ
34,829,955
What is causing this: Cannot jump from switch statement to this case label
<p>This is a switch statement that I am getting errors on:</p> <pre><code> switch (transaction.transactionState) { case SKPaymentTransactionStatePurchasing: // show wait view here statusLabel.text = @"Processing..."; break; case SKPaymentTransactionStatePurchased: [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; // remove wait view and unlock iClooud Syncing statusLabel.text = @"Done!"; NSError *error = nil; [SFHFKeychainUtils storeUsername:@"IAPNoob01" andPassword:@"whatever" forServiceName: kStoredData updateExisting:YES error:&amp;error]; // apply purchase action - hide lock overlay and [oStockLock setBackgroundImage:nil forState:UIControlStateNormal]; // do other thing to enable the features break; case SKPaymentTransactionStateRestored: [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; // remove wait view here statusLabel.text = @""; break; case SKPaymentTransactionStateFailed: if (transaction.error.code != SKErrorPaymentCancelled) { NSLog(@"Error payment cancelled"); } [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; // remove wait view here statusLabel.text = @"Purchase Error!"; break; default: break; } </code></pre> <p>The last two cases, plus the default, are giving me the following error:</p> <blockquote> <p>Cannot jump from switch statement to this case label</p> </blockquote> <p>I have used the switch statement many, many times; this is the first time I have seen this. The code has been copied from a tutorial (<a href="http://xcodenoobies.blogspot.com/2012/04/implementing-inapp-purchase-in-xcode.html" rel="noreferrer">here</a>), which I am trying to adapt for my app. Would appreciate the help on this one. SD</p>
<objective-c><switch-statement><ios9>
2016-01-16 17:33:20
HQ
34,830,092
GH pages deploy via admin interface
<p>The video on <a href="https://www.getlektor.com/docs/deployment/travisci/" rel="nofollow">https://www.getlektor.com/docs/deployment/travisci/</a></p> <p>describes the set-up nicely.</p> <p>Is there an option to make run the whole local git committing &amp; pushing via the publish link in the admin interface?</p>
<github><deployment><publishing><github-pages><lektor>
2016-01-16 17:45:33
LQ_CLOSE
34,830,796
I'm brand new to coding
I am having a problem getting this code to work. When ever I input anything 249 or lower it works as it should. But anything else gets me the *else* statement. My experience level with code is almost zero. This is my first class and it's only week two. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ILAB02 { class Program { static void Main(string[] args) { double salesAmount, shippingAmount; salesAmount = 0.00; shippingAmount = 0.00; Console.WriteLine("What is the total amount of sales?"); salesAmount = Convert.ToDouble(Console.ReadLine()); if (salesAmount > 5000.00) { shippingAmount = 20.00; } if (salesAmount > 1000.00 && salesAmount <= 5000.00) { shippingAmount = 15.00; } if (salesAmount > 500.00 && salesAmount<=1000.00) { shippingAmount = 10.00; } if (salesAmount > 250.00 && salesAmount <=500.00) { shippingAmount = 8.00; } if (salesAmount > 0.00 && salesAmount <=250.00) { shippingAmount = 5.00; } else { shippingAmount = 0.00; Console.WriteLine("Error incorrect input!"); } Console.WriteLine("Total sales amount is {0:C}",salesAmount); Console.WriteLine("Shipping charges is {0:C}", shippingAmount); Console.ReadLine(); } } }
<c#><if-statement>
2016-01-16 18:52:10
LQ_EDIT
34,830,882
How to submit login form in Rvest package w/o button argument
<p>I am trying to scrape a web page that requires authentication using html_session() &amp; html_form() from the rvest package. I found this e.g. provided by Hadley Wickham, but am not able to customize it to my case.</p> <pre><code>united &lt;- html_session("http://www.united.com/") account &lt;- united %&gt;% follow_link("Account") login &lt;- account %&gt;% html_nodes("form") %&gt;% extract2(1) %&gt;% html_form() %&gt;% set_values( `ctl00$ContentInfo$SignIn$onepass$txtField` = "GY797363", `ctl00$ContentInfo$SignIn$password$txtPassword` = password) account &lt;- account %&gt;% submit_form(login, "ctl00$ContentInfo$SignInSecure") </code></pre> <p>In my case, I can't find the values to set in the form, hence I am trying to give the user and pass directly: set_values("email","password")</p> <p>I also don't know how to refer to submit button, so I tried: submit_form(account,login)</p> <p>The error I got for the submit_form function is: Error in names(submits)[[1]] : subscript out of bounds</p> <p>Any idea on how to go about this is appreciated. Thank you</p>
<r><web-scraping><forms><rvest>
2016-01-16 18:59:53
HQ
34,830,908
Make the `drop` argument in `dcast` only look at the RHS of the formula
<p>The <code>drop</code> argument in <code>dcast</code> (from "reshape2" or "dplyr") can be useful when going from a "long" to a "wide" dataset and you want to create columns even for combinations that do not exist in the long form.</p> <p>It turns out that using <code>drop</code> also affects combinations the left hand side (LHS) of the formula as well as the right hand side (RHS). Thus, it also creates extra <em>rows</em> based on the combinations of LHS values.</p> <p>Is there a way to override this behavior?</p> <hr> <p>Here's some sample data:</p> <pre><code>library(data.table) DT &lt;- data.table(v1 = c(1.105, 1.105, 1.105, 2.012, 2.012, 2.012), ID = c(1L, 1L, 1L, 2L, 2L, 2L), v2 = structure(c(2L, 3L, 5L, 1L, 2L, 6L), .Label = c("1", "2", "3", "4", "5", "6"), class = "factor"), v3 = c(3L, 2L, 2L, 5L, 4L, 3L)) </code></pre> <p>Notice that "v2" is a <code>factor</code> column with 6 levels. I essentially want to go from "long" to wide", but add in columns for any missing factor levels (in this case "4").</p> <p><code>reshape</code> handles the shape, but not the missing columns:</p> <pre><code>reshape(DT, direction = "wide", idvar = c("ID", "v1"), timevar = "v2") # v1 ID v3.2 v3.3 v3.5 v3.1 v3.6 # 1: 1.105 1 3 2 2 NA NA # 2: 2.012 2 4 NA NA 5 3 </code></pre> <p><code>dcast</code> handles adding the missing columns, but only if there's one value on the LHS:</p> <pre><code>dcast(DT, ID ~ v2, value.var = "v3", drop = FALSE) # ID 1 2 3 4 5 6 # 1: 1 NA 3 2 NA 2 NA # 2: 2 5 4 NA NA NA 3 </code></pre> <p>If there are multiple values on the LHS, the combinations of the values on the LHS are also expanded out, as if we had used <code>CJ</code> or <code>expand.grid</code>, but rows 2 and 3 are not at all of interest to me:</p> <pre><code>dcast(DT, ... ~ v2, value.var = "v3", drop = FALSE) # v1 ID 1 2 3 4 5 6 # 1: 1.105 1 NA 3 2 NA 2 NA # 2: 1.105 2 NA NA NA NA NA NA # 3: 2.012 1 NA NA NA NA NA NA # 4: 2.012 2 5 4 NA NA NA 3 </code></pre> <p>This is similar to using <code>xtabs</code> in base R: <code>ftable(xtabs(v3 ~ ID + v1 + v2, DT))</code>.</p> <hr> <p>Is there a way to let <code>dcast</code> know that essentially, "Hey. The combination of values on the LHS are the IDs. Don't try to fill them in for me."</p> <p>My current approach is to do three steps, one for collapsing down the LHS values, another for spreading out the RHS values, and then one for merging the result.</p> <pre><code>merge(DT[, list(v1 = unique(v1)), .(ID)], ## or unique(DT[, c("ID", "v1"), with = FALSE]) dcast(DT, ID ~ v2, value.var = "v3", drop = FALSE), by = "ID")[] # ID v1 1 2 3 4 5 6 # 1: 1 1.105 NA 3 2 NA 2 NA # 2: 2 2.012 5 4 NA NA NA 3 </code></pre> <p>Is there a better approach that I'm missing?</p>
<r><data.table><reshape><reshape2>
2016-01-16 19:01:51
HQ
34,830,981
Foreach as in array without looping php
i have code : <?php foreach($this->params as $key=>$val) { $this->rawRequest .= "&$key=$val"; } ?> how to $this->params as $key=>$val without looping?
<php>
2016-01-16 19:10:54
LQ_EDIT
34,831,102
Andrioid request to Server
<p>I am working on android application. In that app i want, Application request the server on that time also if the application is not connected with the internet.</p> <p>Is there any way to connect the server in offline time also.</p>
<android><api><android-activity><android-api-levels>
2016-01-16 19:21:39
LQ_CLOSE
34,831,328
Save Time (NSDate) in NSUserDefaults [Swift 2]
please excuse my bad english skills. I am trying to save the time once the "user" reachs the Limit. So the limit is 10 for example and once he reachs this limit, i want to save the current time. Then he has to wait 1 hour to continue playing. I started doing this, but I already get an error, when I try this: var CurrentTime = NSDate() CurrentTime = NSUserDefaults.standardUserDefaults() Error: Cannot assign value of type 'NSUserDefaults' to type 'NSDate' It seems like swift cannot save a 'NSDate' as a 'NSUserDefault'. I would be happy if you could help me out :)
<ios><swift><time><nsdate><nsuserdefaults>
2016-01-16 19:45:15
LQ_EDIT
34,831,700
change select value when press button
<p>i'm still Beginner at this i have table and i select data between two date range using this code and its working fine for me</p> <pre><code>$StartDate = "2016-01-01"; $EndDate = "2016-12-30"; $result = mysql_query("SELECT *FROM users where submit_date BETWEEN '$StartDate' AND '$EndDate'") or die(mysql_error()); </code></pre> <p>then i added 2 data picker and button</p> <pre><code>echo "&lt;form method=post action=&gt;&lt;table&gt;". "&lt;tr&gt;&lt;td&gt;Start Date : &lt;/td&gt;&lt;td&gt;&lt;input type=date name=StartDate value=$StartDate&gt;&lt;/td&gt;&lt;/tr&gt;". "&lt;tr&gt;&lt;td&gt;End Date : &lt;/td&gt;&lt;td&gt;&lt;input type=date name=EndDate value=$EndDate&gt;&lt;/td&gt;&lt;/tr&gt;". "&lt;tr&gt;&lt;td colspan=2&gt;&lt;input type=submit name=UpdateSelect value=Set&gt;&lt;/td&gt;&lt;/tr&gt;". "&lt;/table&gt;&lt;/form&gt;"; </code></pre> <p>now i need help with this how to update the page when i press the sumbit button to start selecting from the new start date and end date.</p> <p>i'm sorry for my bad english. and thanks</p>
<php><html><mysql><sql>
2016-01-16 20:20:02
LQ_CLOSE
34,831,782
im creating windows form application, how can i ask user to enter name in block letters?
i have started windows form application. i want that when a registration form runs, it should ask user to enter name in block letters, any text box should not be left NULL, and how to create a text which should alpha numeric? please help soon.
<c#><winforms><visual-studio>
2016-01-16 20:27:27
LQ_EDIT
34,832,405
Cant get ASP.NET MVC 6 Controller to return JSON
<p>I have an MVC 6 project in which i am using Fiddler to test out Web API. If i take the following controller action which uses EntityFramework 7 to return a List. Then the html will render fine.</p> <pre><code>[HttpGet("/")] public IActionResult Index() { var model = orderRepository.GetAll(); return View(model); } </code></pre> <p>But when i try to return a Json response instead i get a 502 error.</p> <pre><code>[HttpGet("/")] public JsonResult Index() { var model = orderRepository.GetAll(); return Json(model); } </code></pre> <p>Any Idea on why the object isnt serialized into json correctly?</p>
<c#><json><asp.net-web-api><asp.net-core-mvc><entity-framework-core>
2016-01-16 21:36:13
HQ
34,832,578
Android databinding - How to get dimensions from dimens.xml
<p>I want to set margins based on dimensions i have created in dimens.xml The dimensions it sself works fine, its just data binding cant find it in the case below:</p> <pre><code>&lt;TextView android:id="@+id/title_main" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_below="@+id/disableButton" ************* android:layout_marginBottom="@{@bool/showAds ? @dimen/frontpage_margin_ads: @dimen/frontpage_margin_noads}" ************* android:gravity="center_horizontal" android:text="@string/app_name" android:textColor="@android:color/holo_orange_dark" android:contentDescription="@string/app_name" android:textSize="64sp" android:textStyle="bold" /&gt; </code></pre> <p>it did find it but it says that marginbottom cannot take type float. How can i fix this? I tried casting both dimens to int but then it complains that it cannot be casted to int. </p> <p>My dimensions xml file looks like this:</p> <pre><code> &lt;resources&gt; &lt;!-- Default screen margins, per the Android Design guidelines. --&gt; &lt;dimen name="activity_horizontal_margin"&gt;16dp&lt;/dimen&gt; &lt;dimen name="activity_vertical_margin"&gt;16dp&lt;/dimen&gt; &lt;dimen name="bigText"&gt;44sp&lt;/dimen&gt; &lt;dimen name="littleText"&gt;44sp&lt;/dimen&gt; &lt;dimen name="mediumText"&gt;40sp&lt;/dimen&gt; &lt;dimen name="smallText"&gt;24sp&lt;/dimen&gt; &lt;dimen name="fab_margin"&gt;16dp&lt;/dimen&gt; &lt;dimen name="frontpage_margin_noads"&gt;0dp&lt;/dimen&gt; &lt;dimen name="frontpage_margin_ads"&gt;13dp&lt;/dimen&gt; &lt;/resources&gt; </code></pre>
<android><data-binding>
2016-01-16 21:55:56
HQ
34,832,712
how to derive cluster properties
I have clustered ~40000 points into 79 clusters. Each point is a vector of 18 features. I want to 'derive' the characteristics of each cluster - the prominent features/characteristics of the clusters. Are there machine-learning algorithms to derive this? Thanks.
<machine-learning><cluster-analysis><data-mining>
2016-01-16 22:10:15
LQ_EDIT
34,832,755
Nested Touchable with absolute position
<p>I need to implement an interface where an object is clickable, but an area of this object does another action, like this:</p> <pre><code>|-----------| | | | -&gt; clicking on this small area does an action | ---| | | | | | | -&gt; clicking on this area does another action | | |-----------| </code></pre> <p>I did an implementation similar this structure:</p> <pre><code>&lt;View&gt; // Container &lt;Touchable onPress={do X}&gt; // Large area &lt;Touchable onPress={do Y} style={{position: absolute, top: 0, right: 0}}&gt; // Small area &lt;/View&gt; </code></pre> <p>The problem is that the small area never activate the onPress props. The event is always triggered on the large area.</p> <p>Can someone help me with this?</p> <p>Thanks!</p>
<reactjs><react-native>
2016-01-16 22:16:33
HQ
34,832,893
Jquery Ajax method POST does not work on hosting
I've been working on a website for quite some time, but it was all done on localhost. After making login form work properly I decided to upload it to hosting. Issue is that callback functions of ajax don't seem to work if I use method: "POST". If I change POST to GET it will work... Ajax code: $.ajax({ method: 'POST', url: "php/login.php", data: { username: val_username, password: val_password }, success: function(response) { if (response == 0) { location.reload(); } else { alert("Wrong username or password. Error #"+response); } } }); login.php <?php session_start(); require "../php_includes/mysql.php"; // Create connection $conn = new mysqli($db_server, $db_user, $db_pass, $db_name); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // escape your parameters to prevent sql injection $username = mysqli_real_escape_string($conn, $_POST['username']); $password = mysqli_real_escape_string($conn, $_POST['password']); $sql = "SELECT * FROM korisnici WHERE username='$username'"; $sql_result = $conn->query($sql); if ($sql_result->num_rows > 0) { $row = $sql_result->fetch_assoc(); if (password_verify($password, $row["password"])) { $_SESSION["loggedin"] = true; $_SESSION["userid"] = $row["id"]; echo 0; } else echo 2; } else echo 1; ?> I have checked all the file locations, no issue there, since everything works if I change method to GET. I tried changing datatypes in ajax, tried adding some headers to php file that I've found searching around stackoverflow, but nothing helps...
<javascript><php><jquery><ajax><post>
2016-01-16 22:34:38
LQ_EDIT
34,833,000
Django: change the value of a field for all objects in a queryset
<p>I have a model <code>MyModel</code> with a boolean field <code>active</code></p> <p>Elsewhere, I am retrieving a queryset:</p> <pre><code>qs = MyModel.Objects.filter(....) </code></pre> <p>how can I set <code>active=False</code> for all objects in this <code>qs</code>?</p>
<python><django><django-queryset>
2016-01-16 22:46:22
HQ
34,833,044
Remove trailing zeros from string java
<p>Although I have seen a question similar to this one asked quite a few times, I actually mean remove all trailing zeroes.</p> <p>I would like to convert something like</p> <pre><code>"1903895810000" </code></pre> <p>to</p> <pre><code>"190389581" </code></pre> <p>I am looking for a String.replace() solution</p>
<java>
2016-01-16 22:51:23
LQ_CLOSE
34,833,120
Azure Web Apps : How to access specific instance directly via URL?
<p>We have deployed our Sitecore CMS on to Azure Web Apps and having some indexing issues or similar. i.e. the updated changes is reflected for some users and not for all.</p> <p>We have a scale turned on to 2. </p> <p>I would like to troubleshoot by accessing the instance 1 and 2 directly via URL to make sure both instances have index built 100%. </p> <p>How do I access each Azure Web Role instances directly via URL?</p> <p>Thanks.</p>
<azure><azure-web-sites>
2016-01-16 23:01:18
HQ
34,833,627
Error "You must not call setTag() on a view Glide is targeting" when use Glide
<p>I use <a href="https://github.com/bumptech/glide">Glide</a> library inner custom adapter view in my apps. But I have Error :</p> <pre><code>"You must not call setTag() on a view Glide is targeting" </code></pre> <p>This part of my code :</p> <pre><code> @Override public View getView(int position, View view, ViewGroup container) { ViewHolder holder; if (view == null) { holder = new ViewHolder(); view = holder.imageView = new ImageView(context); view.setTag(holder); } else { holder = (ViewHolder) view.getTag(); } holder.imageView.setAdjustViewBounds(true); LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); holder.imageView .setLayoutParams(vp); holder.imageView .setScaleType(ImageView.ScaleType.CENTER_CROP); String var_news_article_images = imageIdList.get(getPosition(position)); Glide.with(context) .load(var_news_article_images) .placeholder(R.drawable.placeholder) .into(holder.imageView); return view; } </code></pre> <p>so how to fix it ?</p>
<android><android-glide>
2016-01-17 00:12:07
HQ
34,834,248
when i run this program without ''static '' keyword .it runs fine,but with '''static'' keyword it shows error.
class Ideone { static final int iop;// your code goes here public Ideone() { iop=56; System.out.println(iop); } public static void main (String[] args) throws java.lang.Exception { new Ideone(); } }
<java>
2016-01-17 01:52:44
LQ_EDIT
34,834,258
Python - Most elegant way to extract a substring, being given left and right borders
<p>I have a string - Python :</p> <pre><code>string = "/foo13546897/bar/Atlantis-GPS-coordinates/bar457822368/foo/" </code></pre> <p>Expected output is :</p> <pre><code>"Atlantis-GPS-coordinates" </code></pre> <p>I know that the expected output is ALWAYS surrounded by "/bar/" on the left and "/" on the right :</p> <pre><code>"/bar/Atlantis-GPS-coordinates/" </code></pre> <p>Proposed solution would look like :</p> <pre><code>a = string.find("/bar/") b = string.find("/",a+5) output=string[a+5,b] </code></pre> <p>This works, but I don't like it. Does someone know a beautiful function or tip ?</p>
<python><string><find>
2016-01-17 01:55:13
HQ
34,834,504
ASP.NET 5 / MVC 6 On-Premises Active Directory
<p>For earlier versions of .NET application templates i.e. 4.5.2 you can create a new Web Application, Change the Authentication to 'Work and School Accounts' and choose 'On-Premises'. In .NET 5 Web Application templates the 'Work and School Accounts' option does not have an 'On-Premises' option.</p> <p>How do you go about authenticating via an on-premises Active Directory (LDAP) in .NET 5 using ASP.NET Identity. To be clear, I am not looking for Windows Authentication, I want to have users enter their credentials and process the authentication against the on-premises AD. IOW, users don't need to be logged into a windows machine, they can access from their mobile devices etc.</p> <p>I've searched for hours to no avail but I wouldn't be surprised if the answer is out there somewhere. Any help is appreciated!</p>
<c#><active-directory><ldap><asp.net-identity><asp.net-core-mvc>
2016-01-17 02:36:22
HQ
34,834,586
I am trying to insert value directly to double pointer matrix as follows
<pre><code>int **matrix = {{1,2,3,4},{1,2,3,4},{1,2,3,4},{1,2,3,4}}; int vertices = 4; matrix = malloc(vertices * sizeof (int *)); </code></pre> <p>so when I print the matrix, it is displaying garbage values.</p>
<c>
2016-01-17 02:51:45
LQ_CLOSE
34,834,700
Object Oriented Programming vs. Procedural Programming
<p>I'm trying to write two examples of code in java: OOP and procedural, but I can't think of procedural code example. I have one example of an OOP code below. Can someone give me an example of a procedural code and explain a little as to what it does? </p> <p>OOP example below:</p> <pre><code>Class test { public static void main (String args []){ int test = 6; if (test == 9){ System.out.println(“True”); } else { System.out.println(“False”); } } </code></pre>
<java><oop><code-snippets><procedural>
2016-01-17 03:09:58
LQ_CLOSE
34,835,416
Can I add cookies to a webpack dev server proxy?
<p>I'm trying to set up a proxy within my webpack dev server. The issue is that I don't control the server I'm connecting to, and I need to authenticate the request.</p> <p>Is there a way I can add cookies on to the request I send to the proxy server? I've looked through the <a href="https://webpack.github.io/docs/webpack-dev-server.html#proxy">webpack dev server proxy server page</a>, and the <a href="https://github.com/nodejitsu/node-http-proxy#options">node-http-proxy</a> page it links to, and I don't see any mention of cookies. I'm also not sure if there's a way for me to see these forwarded requests, so I can't tell if anything I'm trying is doing anything.</p> <p>Any ideas?</p>
<node.js><cookies><proxy><webpack><webpack-dev-server>
2016-01-17 05:24:41
HQ
34,835,445
Best way to read specify length of bytes in stream (C#)
What is the best way to read a **specify** Length of bytes in a stream.
<c#><stream>
2016-01-17 05:29:50
LQ_EDIT
34,835,497
I want to design an ANDROID app which sets user mobile number by taking input from them and after that it always shows next activity using service?
<p>I want to design an ANDROID app which sets user mobile number by taking input from them and after that it always shows next activity using service each time when user opens the app but not that setting number activity.Please suggest me the method to do that..</p>
<android>
2016-01-17 05:40:37
LQ_CLOSE
34,836,305
How do I make a flowchart using markdown on my github blog
<p>I recently put some posts on my github jekyll blog.Everything is fine,except my flowchart.I used to make flowchart like this:</p> <pre><code>```flow my content ``` </code></pre> <p>but when I preview the post,It can't display as a flowchart. This is Ok in some other markdown editor.If I want to make flowchart on my github blog,what can I do?Thanks.</p>
<github><markdown>
2016-01-17 07:58:03
HQ
34,836,944
PHP : ranking on array value without ties
i have an array rank, <br> `rank = [1,3,2,1]` i want the output like this `rank = [1,4,3,2]` thank you in advice
<php><sorting><ranking>
2016-01-17 09:36:32
LQ_EDIT
34,837,026
What's the meaning of pool_connections in requests.adapters.HTTPAdapter?
<p>When initializing a requests' <code>Session</code>, two <a href="http://docs.python-requests.org/en/latest/api/#requests.adapters.HTTPAdapter" rel="noreferrer"><code>HTTPAdapter</code></a> will be created and <a href="https://github.com/kennethreitz/requests/blob/master/requests/sessions.py#L340-L341" rel="noreferrer">mount to <code>http</code> and <code>https</code></a>.</p> <p>This is how <code>HTTPAdapter</code> is defined:</p> <pre><code>class requests.adapters.HTTPAdapter(pool_connections=10, pool_maxsize=10, max_retries=0, pool_block=False) </code></pre> <p>While I understand the meaning of <code>pool_maxsize</code>(which is the number of session a pool can save), I don't understand what <code>pool_connections</code> means or what it does. Doc says:</p> <pre><code>Parameters: pool_connections – The number of urllib3 connection pools to cache. </code></pre> <p>But what does it mean "to cache"? And what's the point using multiple connection pools?</p>
<python><python-requests><urllib3>
2016-01-17 09:50:49
HQ
34,837,102
How to put a song in android?
<p>I have a game and I want to put a background song. I read that you have to put an mp3 in the raw folder, but I don't know where is it. Thanks.</p>
<android><android-studio>
2016-01-17 10:01:39
LQ_CLOSE
34,837,150
Applicative is to monad what X is to comonad
<p>Can we solve this equation for X ?</p> <blockquote> <p>Applicative is to monad what X is to comonad</p> </blockquote>
<haskell><monads><applicative><comonad>
2016-01-17 10:08:08
HQ
34,837,725
Spring Data Repositories - Find where field in list
<p>I'm trying to use spring <code>PagingAndSortingRepository</code> with a <code>find MyEntity where field in fieldValues</code> query as follows:</p> <pre><code>@Repository public interface MyEntity extends PagingAndSortingRepository&lt;MyEntity, String&gt; { List&lt;MyEntity&gt; findByMyField(Set&lt;String&gt; myField); } </code></pre> <p>But of no success.</p> <p>I expected the above function to return all entities whose field matches one of the field values but it only returns <strong>empty results</strong>.</p> <p>Even though it seems like a pretty straight forward ability i could not find any reference to it in the <a href="http://docs.spring.io/spring-data/data-commons/docs/1.6.1.RELEASE/reference/html/repositories.html" rel="noreferrer">docs</a>.</p> <p>Is / How that could be achieved?</p> <p>Thanks.</p>
<java><spring><spring-data><spring-data-mongodb><spring-data-commons>
2016-01-17 11:18:51
HQ
34,838,210
What is the differenect between spring cloud and spring cloud Netflix?
<p>Could somebody explain what the difference between spring cloud and spring cloud netflix? I am just starting to learn and the difference is not very clear for me. The spring cloud is an "interface" (or standart or base implenetation) and Netflix is another "implementation"? Or netflix provide something different things? (what exactly?)</p> <p>Also Netflix is private company - is there any restriction about using they components? Is spring cloud netflix free?</p>
<java><spring><spring-cloud><netflix>
2016-01-17 12:18:04
LQ_CLOSE
34,838,294
What is difference between creating object using Object.create() and Object.assign()?
<p>Considering following code:</p> <pre><code>var obj1 = Object.create({}, {myProp: {value: 1}}); var obj2 = Object.assign({}, {myProp: 1}); </code></pre> <p>Is there any difference between <code>obj1</code> and <code>obj2</code> since each object has been created in a different way?</p>
<javascript><object-create>
2016-01-17 12:27:48
HQ
34,838,463
Regex match and count
Using Regex how would you count triplicates in a string? example 122244445577777 1 222 444 4 55 777 77 answer 3
<regex><match>
2016-01-17 12:45:42
LQ_EDIT
34,838,542
How to get Timezone offset from moment Object?
<p>I have <code>moment</code> Object defined as:</p> <pre><code>var moment = require('moment'); moment('2015-12-20T12:00:00+02:00'); </code></pre> <p>When I print it, I get:</p> <pre><code>_d: Sun Dec 20 2015 12:00:00 GMT+0200 (EET) _f: "YYYY-MM-DDTHH:mm:ssZ" _i: "2015-12-20T12:00:00+02:00" _isAMomentObject: true _isUTC: false _locale: r _pf: Object _tzm: 120 </code></pre> <p>How to fetch by right way <code>_tzm</code>? (suppose its offset in minutes)</p> <p>Thanks,</p>
<javascript><node.js><momentjs>
2016-01-17 12:54:37
HQ
34,839,339
for loop with table wchich return 12 values(month) php
I write this code when i try to return 12 numbers from 1 to 12: public function getMonths() { for($monthNum = 1; $monthNum <= 12; $monthNum++) { $month[$monthNum]=$monthNum; } return [$month]; } How can i return this 12 numbers? I have now zero in my first return value. Anyone know how to resolve this? I need only 12 numbers without 0?
<php><arrays>
2016-01-17 14:17:30
LQ_EDIT
34,839,399
How to access the $container within middleware class in Slim v3?
<p>I've been reading that in Slim v2, $app was bound to the middleware class. I'm finding this not to be the case in v3? Below is my middleware class, but I'm just getting undefined:</p> <pre><code>&lt;?php namespace CrSrc\Middleware; class Auth { /** * Example middleware invokable class * * @param \Psr\Http\Message\ServerRequestInterface $request PSR7 request * @param \Psr\Http\Message\ResponseInterface $response PSR7 response * @param callable $next Next middleware * * @return \Psr\Http\Message\ResponseInterface */ public function __invoke($request, $response, $next) { // before var_dump($this-&gt;getContainer()); // method undefined var_dump($this-&gt;auth); exit; // method undefined if (! $this-&gt;get('auth')-&gt;isAuthenticated()) { // Not authenticated and must be authenticated to access this resource return $response-&gt;withStatus(401); } // pass onto the next callable $response = $next($request, $response); // after return $response; } } </code></pre> <p>What's the correct way to access the DI container within middleware? I'm guessing there ought to be a way?</p>
<php><slim><slim-3>
2016-01-17 14:24:25
HQ
34,839,449
AWS Configure Bash One Liner
<p>Can anybody tell me how to automate the aws configure in bash with a one liner?</p> <p>Example:</p> <pre><code>$ aws configure --profile user2 AWS Access Key ID [None]: AKIAI44QH8DHBEXAMPLE AWS Secret Access Key [None]: je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY Default region name [None]: us-east-1 Default output format [None]: text </code></pre> <p>Application: I want to automate this inside a Docker Entrypoint!</p>
<bash><amazon-web-services><docker>
2016-01-17 14:29:05
HQ
34,839,492
Swift2 - Drawing from dictionary
I'm trying to copy image pixel by pixel and I save the data from the image in dictionary:[UIColor:CGPoint] how to draw on CGContext all points pixel by pixel with the exact color for certain pixel?
<ios><swift><dictionary><uicolor><cgpoint>
2016-01-17 14:32:49
LQ_EDIT
34,839,615
Cumulative values of a column for each group (R)
<p>I have a data frame that looks like this :</p> <pre><code>&gt; year&lt;-c(2014,2014,2014,2015,2015,2015,2016,2016,2016) &gt; group&lt;-c("A","B","C","A","B","C","A","B","C") &gt; n&lt;-c(1,1,1,1,2,0,2,1,1) &gt; df&lt;-data.frame(year=year,group=group,n=n) &gt; df year group n 2014 A 1 2014 B 1 2014 C 1 2015 A 1 2015 B 2 2015 C 0 2016 A 2 2016 B 1 2016 C 1 </code></pre> <p>I want to create a column that contains the cumulated values of n for each group to have something like this : </p> <pre><code>year group n sum 2014 A 1 1 2014 B 1 1 2014 C 1 1 2015 A 1 2 2015 B 2 3 2015 C 0 1 2016 A 2 4 2016 B 1 4 2016 C 1 2 </code></pre>
<r>
2016-01-17 14:45:17
LQ_CLOSE
34,839,848
un able to insert data into database using php
<p>this php code is written at the end of of my file </p> <pre><code> &lt;?php if(isset($_POST['submit'])) { $Jobtitle = $_POST['jobtitle']; $Firstname = $_POST['firstname']; $Lastname = $_POST['lastname']; $Name=$Firstname+$Lastname; $Sin = $_POST['sin']; $Phone = $_POST['phone']; $Email = $_POST['email']; $Address = $_POST['address']; $Postal = $_POST['postal']; $State = $_POST['state']; $Country = $_POST['country']; $Skill = $_POST['skill']; $Owntransport = $_POST['owntransport']; $ADate = $_POST['a-date']; $Workpermit = $_POST['workpermit']; $Daysavailable = $_POST['days-available']; $Strength = $_POST['strength']; $eFirstname = $_POST['efirstname']; $eLastname = $_POST['elastname']; $eName=$eFirstname+$eLastname; $ePhone = $_POST['ephone']; $query=" INSERT INTO `general`(`jobtitle`, `name`, `sin`, `pno`, `email`, `address`, `doc`, `skills`, `transport`, `avadate`, `authorize`, `days`, `strength`, `ename`, `ephone`) VALUES ('{$Jobtitle}','{$Name}','{$Sin}','{$Phone}','{$Email}','{$Address}','{$Postal}','{$State}','{$Country}','{$Skill}','{$Owntransport}','{$ADate}','{$Workpermit}','{$Daysavailable}','{$Strength}','{$eName}','{$ePhone}')"; // $query = "INSERT INTO info (name,password,gender,hobby,phone no,dob,message) VALUES ('{$Name}','{$Password}','{$Gender}','{$Hobby}','{$Phone}','{$Dob}','{$Message}')"; $result = mysql_query($query); if($result) { echo "data entered"; } unset($_POST); } else{ echo "error in entering data"; } </code></pre> <p>?></p> <p>this is the button tag</p> <pre><code>&lt;button type="button" class="btn btn-primary"name="submit"value="submit" id="submit"&gt;Submit&lt;/button&gt; </code></pre> <p>this is the form tag</p> <pre><code>&lt;form method="post" id="contactform" action="#" role="form"&gt; </code></pre> <p>connection .php file giving me the connection to database but I am unable to store the data in databse it gives me the error that data is not entered</p>
<php><mysql>
2016-01-17 15:08:02
LQ_CLOSE
34,840,001
how to make smooth grayscale on hover using CSS
<p>I have logo in my website, it is grayscaled on hover i want it to be colored smoothly. it is working but not smoothly. i am using CSS transition.</p> <p>This is my code</p> <pre><code>&lt;img alt="TT ltd logo" src="./img/tt-logo.png" class="tt-logo" /&gt; &lt;style&gt; img.tt-logo { filter: grayscale(1); transition: grayscale 0.5s; } img.tt-logo:hover { filter: grayscale(0); } &lt;/style&gt; </code></pre>
<css><css-transitions><grayscale>
2016-01-17 15:21:07
HQ
34,840,153
npm deprecated warnings – do I need to update something?
<p>After doing <code>npm install</code> to fetch a project's dependencies, I regularly get a lot messages like this:</p> <p><code>npm WARN deprecated lodash@1.0.2: lodash@&lt;2.0.0 is no longer maintained. Upgrade to lodash@^3.0.0</code></p> <p>Obviously I don't understand node good enough to conclude what I should do – the project doesn't even include lodash directly.</p> <p>Do I need to update something on my side? Or is it the package maintainers task?</p>
<node.js><npm>
2016-01-17 15:37:48
HQ
34,840,662
Android Country codes
<p>How i use Country codes String in my android code using edittext startswith number here my code m using.</p> <p>String</p> <pre><code>private static final String[] mCodes = { "+93", "+355", "+213", "+376", "+244", "+672", "+54", "+374", "+297", "+61", "+43", "+994", "+973", "+880", "+375", "+32", "+501", "+229", "+975", "+591", "+387", "+267", "+55", "+673", "+359", "+226", "+95", "+257", "+855", "+237", "+1", "+238", "+236", "+235", "+56", "+86", "+61", "+61", "+57", "+269", "+242", "+243", "+682", "+506", "+385", "+53", "+357", "+420", "+45", "+253", "+670", "+593", "+20", "+503", "+240", "+291", "+372", "+251", "+500", "+298", "+679", "+358", "+33", "+689", "+241", "+220", "+995", "+49", "+233", "+350", "+30", "+299", "+502", "+224", "+245", "+592", "+509", "+504", "+852", "+36", "+91", "+62", "+98", "+964", "+353", "+44", "+972", "+39", "+225", "+81", "+962", "+254", "+686", "+965", "+996", "+856", "+371", "+961", "+266", "+231", "+218", "+423", "+370", "+352", "+853", "+389", "+261", "+265", "+60", "+960", "+223", "+356", "+692", "+222", "+230", "+262", "+52", "+691", "+373", "+377", "+976", "+382", "+212", "+258", "+264", "+674", "+977", "+31", "+599", "+687", "+64", "+505", "+227", "+234", "+683", "+850", "+47", "+968", "+92", "+680", "+507", "+675", "+595", "+51", "+63", "+870", "+48", "+351", "+974", "+40", "+7", "+250", "+590", "+685", "+378", "+239", "+966", "+221", "+381", "+248", "+232", "+65", "+421", "+386", "+677", "+252", "+27", "+82", "+34", "+94", "+290", "+508", "+249", "+597", "+268", "+46", "+41", "+963", "+886", "+992", "+255", "+66", "+228", "+690", "+676", "+216", "+90", "+993", "+688", "+971", "+256", "+380", "+598", "+998", "+678", "+58", "+84", "+681", "+967", "+260", "+263" }; </code></pre> <p>Edittext</p> <pre><code>etAddNumber = (EditText) findViewById(R.id.etAddNumber); String addnumber = etAddNumber.getText().toString(); </code></pre> <p>And also use edittext code, if user enter number without country code show Toast</p> <pre><code> if (!addnumber.startsWith(mCodes.toString())) { Toast.makeText(getApplicationContext(), "You did not enter country code", Toast.LENGTH_SHORT).show(); } </code></pre> <p>Thanks Advance</p>
<android>
2016-01-17 16:30:29
LQ_CLOSE
34,840,986
MySQL query with increment based on already existing values and only in rows with collum "Confirmed" not zero
I have a table that is manually edited from a webstore. I would like to do this faster with a query. Table: Orders I would like to auto increment collum 'Invoice number' in all rows if collum 'status id' (is not zero / 1-5) And i would like to start from a ceratain row (The next row after last manual input)
<mysql>
2016-01-17 16:59:58
LQ_EDIT
34,840,994
Javascript Redux - how to get an element from store by id
<p>For the past weeks I've been trying to learn React and Redux. Now I have met a problem thay I haven't found a right answer to.</p> <p>Suppose I have a page in React that gets props from the link.</p> <pre><code>const id = this.props.params.id; </code></pre> <p>Now on this page, I'd like to display an object from STORE with this ID.</p> <pre><code> const initialState = [ { title: 'Goal', author: 'admin', id: 0 }, { title: 'Goal vol2', author: 'admin', id: 1 } ] </code></pre> <p>My question is: should the function to query the the object from the STORE be in the page file, before the render method, or should I use action creators and include the function in reducers. I've noticed that the reduceres seem to contain only actions that have an impoact on store, but mine just queries the store.</p> <p>Thank you in advance.</p>
<javascript><reactjs><flux><redux>
2016-01-17 17:00:59
HQ
34,841,065
Hello, i need jquery function for symbol counter in text box when click on button
i need jquery function for symbol counter in text box when click on button. I dont know how work this. <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title></title> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> </head> <body> <input type="text"id="id1"></input></div><br/><br/> <button onclick="#"id="id2"> Count Symbols</button> <p id="id1"></p> <script> $( document.#id1 ) .click(function() { $( document.#id1 ).append( $( "#id2" ) ); var n = $( "#id2" ).length; $( ).text( "There are " + n + " symbols."); }) </script> </body> </html> <!-- end snippet -->
<javascript><jquery>
2016-01-17 17:07:18
LQ_EDIT
34,841,440
IntelliJ: find code path between two methods
<p>I have two methods in my code base. I would like to figure out, if there exists a path in which one will be called from the other. Is there some way to achieve this easily in IntelliJ without digging manually through call hierarchies?</p>
<intellij-idea>
2016-01-17 17:39:46
HQ
34,841,813
How to install Angular2 beta with Bower?
<p>I'm trying to install Angular2 with Bower with command <code>bower install -S angular2</code> and have next messages in console:</p> <pre><code>$ bower install -S angular2 bower angular2#* cached git://github.com/angular/bower-angular.git#1.4.8 bower angular2#* validate 1.4.8 against git://github.com/angular/bower-angular.git#* bower angular#~1.4.8 install angular#1.4.8 angular#1.4.8 bower_components/angular </code></pre> <p>My <code>bower.json</code> file now contains next info in <code>dependencies</code> section:</p> <pre><code>"dependencies": { "angular": "angular2#~1.4.8" } </code></pre> <p>And I have Angular 1.4.8 after that in <code>bower_components</code> path.</p> <p>So, how to install Angular2 beta with Bower?</p>
<bower><angular>
2016-01-17 18:11:25
HQ
34,842,526
Update console without flickering - c++
<p>I'm attempting to make a console side scrolling shooter, I know this isn't the ideal medium for it but I set myself a bit of a challenge.</p> <p>The problem is that whenever it updates the frame, the entire console is flickering. Is there any way to get around this?</p> <p>I have used an array to hold all of the necessary characters to be output, here is my <code>updateFrame</code> function. Yes, I know <code>system("cls")</code> is lazy, but unless that's the cause of problem I'm not fussed for this purpose. </p> <pre><code>void updateFrame() { system("cls"); updateBattleField(); std::this_thread::sleep_for(std::chrono::milliseconds(33)); for (int y = 0; y &lt; MAX_Y; y++) { for (int x = 0; x &lt; MAX_X; x++) { std::cout &lt;&lt; battleField[x][y]; } std::cout &lt;&lt; std::endl; } } </code></pre>
<c++>
2016-01-17 19:16:45
HQ
34,842,806
Ruby : Generate Random number in a range less one element
<p>Folks, </p> <p>I'm trying to generate a random number between (0..10) less, say, 5. </p> <pre><code>new_index = rand(0..(old_index - 1)) || new_index = rand((old_index + 1)..10) </code></pre> <p>Can anyone shed any light?</p>
<ruby>
2016-01-17 19:42:19
LQ_CLOSE
34,842,812
Create php form to allow create new XMPP accounts
<p>I want create a simple PHP form (nickname and username) to allow users register a new jabber account in the server through the website. I'm using prosody as XMPP server and I can create new accounts through clients such Pidgin, etc but although I was reading about it, I found that to use XMPP over http I should enable a bosh server but I don't know if it can help me to find a solution for my problem and the few libraries which I found of XMPP in PHP haven't any function to create new accounts in the server (or unless I didn't see any function...). And I don't want use the exec function due to that the command to register new users ask me for sudo privileges. If someone can teach me about how deal with it to learn I will be very grateful.</p>
<php><xmpp><xmpphp><prosody-im>
2016-01-17 19:42:50
LQ_CLOSE
34,843,297
Modify @OneToMany entity in Spring Data Rest without its repository
<p>In my project I use object of type <em>A</em> which has OneToMany relation (orphanRemoval = true, cascade = CascadeType.ALL, fetch = FetchType.EAGER) to objects of type <em>B</em>. I need SpringDataRest (SDR) to store complete full <em>A</em> object with its <em>B</em> objects (children) using single one POST request. I tried several combinations in SDR, the only one which worked for me, was to create @RepositoryRestResource for object <em>A</em> and to create @RepositoryRestResource also for object <em>B</em>, but mark this (<em>B</em>) as exported=false (if I did not create repository out of object <em>B</em> at all, it would not work -> just <em>A</em> object would be stored on single POST request, but not its children (@OneToMany relation) of type <em>B</em>; the same outcome occurs if exported=false is omitted for <em>B</em> repository). Is this ok and the only way how to achieve it (single POST request with storing all objects at once)?</p> <p>The reason I'm asking, in my previous example, I have to (I would like to) control all objects "lifecycle" by using <em>A</em>'s repository. I am ok with it, because <em>A</em>-><em>B</em> relation is composition (<em>B</em> does not exists outside of <em>A</em>). But I have serious problem of editing (also removing) one certain object of type <em>B</em> by SDR using its parent repository (since object <em>B</em> doest not have its own repository exported). Maybe, this is not possible by definition. I have tried these solutions:</p> <ul> <li>PATCH for "/A/1/B/2" does not work -> method not allowed (in headers is "Allow: GET, DELETE") -> so, also PUT is out of question</li> <li>Json Patch would not work either - PATCH for "/A/1" using json patch content-type [{"op": "add", "path": "/B/2", ....}] -> "no such index in target array" - because Json Patch uses scalar "2" after "array" as a index to its array. This is not practical in Java world, when relations are kept in Set of objects - indexing has no meaning at all.</li> <li>I could export repository (exported=true) of object <em>B</em> for manipulating it "directly", but this way I would loose ability to store the whole object <em>A</em> with its <em>B</em> objects at one single POST request as I have mentioned before.</li> </ul> <p>I would like to avoid sending the whole <em>A</em> object with one single tiny modification of its <em>B</em> object for PUT, if possible. Thank you.</p>
<java><rest><spring-data-rest><json-patch>
2016-01-17 20:30:45
HQ
34,843,363
Visual Studio hangs when creating Azure App Service
<p>I'm trying to follow a tutorial on Azure deployment. I'm stuck on one of the first steps creating the App Service. It seams that the form tries to find all App Service Plans but can't, so all of Visual Studio hangs. I had to kill it with Task Manager. Any clues on how I can fix this? Do I need to create something at the Azure management console?</p> <p><a href="https://i.stack.imgur.com/ofRSU.png"><img src="https://i.stack.imgur.com/ofRSU.png" alt="enter image description here"></a></p>
<visual-studio><azure>
2016-01-17 20:37:20
HQ
34,843,364
how can i copy an array from a class and double the size of the new array?
CDCatalogue::CDCatalogue() //creates array of 4 { maxsize=4; numcds = 0; cds = new CD[maxsize]; } //this copy cat into new array with double the size of cat CDCatalogue::CDCatalogue(const CDCatalogue& cat) { }
<c++><arrays><copying>
2016-01-17 20:37:21
LQ_EDIT
34,843,826
Create Regular Expression with exact 2 repetition of single charcter
I am fighting with regular expression - I want to create one for validation in REST resource, the id which is queried needs to have two : , for example key1:key2:key3 how can i create it? the length of key1-3 can change and not equal thanks
<regex><scala>
2016-01-17 21:20:10
LQ_EDIT
34,844,209
Consumer not receiving messages, kafka console, new consumer api, Kafka 0.9
<p>I am doing the <a href="http://kafka.apache.org/documentation.html#quickstart">Kafka Quickstart</a> for Kafka 0.9.0.0.</p> <p>I have zookeeper listening at <code>localhost:2181</code> because I ran</p> <pre><code>bin/zookeeper-server-start.sh config/zookeeper.properties </code></pre> <p>I have a single broker listening at <code>localhost:9092</code> because I ran</p> <pre><code>bin/kafka-server-start.sh config/server.properties </code></pre> <p>I have a producer posting to topic "test" because I ran</p> <pre><code>bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test yello is this thing on? let's try another gimme more </code></pre> <p>When I run the old API consumer, it <em>works</em> by running</p> <pre><code>bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning </code></pre> <p>However, when I run the new API consumer, I don't get anything when I run</p> <pre><code>bin/kafka-console-consumer.sh --new-consumer --topic test --from-beginning \ --bootstrap-server localhost:9092 </code></pre> <p>Is it possible to subscribe to a topic from the console consumer using the new api? How can I fix it?</p>
<apache-kafka><kafka-consumer-api>
2016-01-17 21:55:04
HQ
34,844,258
code 7: How to replace an image by another by clicking a button?
I started Xcoding a few days ago and get stopped by the following problem: image does not change by clicking. The former image disappears. Thanks for any help, Peter ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController @property (strong, nonatomic) IBOutlet UIImageView *imgView; - (IBAction)changeImage:(id)sender; @end ViewController.m #import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize imgView; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)changeImage:(id)sender { UIImage *img = [UIImage imageNamed:@"animal_3.png"]; [imgView setImage: img];} @end
<ios><objective-c><uiimageview>
2016-01-17 21:59:26
LQ_EDIT
34,844,385
How can i create object from a file in c++?
Im learning c++. I have my class complex: #include "Complejo.h" #include <sstream> Complejo::Complejo() { // TODO Auto-generated constructor stub real = 0; imaginary = 0; } Complejo::Complejo(int a, int b){ real = a; imaginary = b; } Complejo::~Complejo() { // TODO Auto-generated destructor stub } std::string Complejo::mostrar()const{ std::stringstream s; s << real << "+" << imaginary <<"i"; return s.str(); } and in my main i need to read a file(every line has a complex) like this: 3 + 5i 4 + 2i 3 + 3i and create objects. How i can do it?
<c++><fgets>
2016-01-17 22:12:56
LQ_EDIT
34,844,435
java program for poerball lottery
I have to check all test cases which i have given in arrays but i am not getting perfect answer.Please help me with this question.Create a PowerBall class that contains: - A field for an int array of size 6. - A constructor that initializes this array with 6 random values (0-9). - A method called checkMatch that takes as an argument an int array and returns how many numbers match the class's int array. To match, the same numbers must be in the same position. Write a main class which asks to user to enter 6 numbers as their lottery ticket and store it in an array. Then create a PowerBall object and give the user's ticket to the checkMatch method. Then figure out the amount won based on the return value. The winnings are determined as follows: If 0 numbers match, no winnings If 1 number matches, win $4 If 2 numbers match, win $7 If 3 numbers match, win $100 If 4 numbers match, win $10,000 If 5 numbers match, win $1 Million If all 6 numbers match, win Grand Prize of $450 Million Output the user's lottery ticket, the powerball numbers, how many matched, and the amount of money won. (JAVA PROGRAM HELP) class PowerBall { /* * ALL PRIVATE DATA BELOW */ private int[] winningNumber; private int[] ticketNumber; private long cash; static private IntUtil u = new IntUtil(); int matchBalCount ; int powerBallMatchCount; public int cash() { for (int i = 0; i < winningNumber.length; i++) { for (int j = 0; j < ticketNumber.length; j++) { if (i == winningNumber.length-1 && ticketNumber[i] == winningNumber[j]) { powerBallMatchCount=1; } else if (ticketNumber[i] == winningNumber[j]) { matchBalCount++; } } } return 100; } public void check(int matchBalCount,int powerBalCount){ System.out.println("prize---matchBalCount::"+matchBalCount+" ,powerBallMatchCount::"+powerBallMatchCount); if (matchBalCount == 0 && powerBallMatchCount>0) { System.out.println("4"); }else if (matchBalCount == 1 && powerBallMatchCount>0) { System.out.println("4"); }else if (matchBalCount == 2 && powerBallMatchCount>0) { System.out.println("7"); }else if (matchBalCount == 3 && powerBallMatchCount<0) { System.out.println("7"); }else if (matchBalCount == 3&& powerBallMatchCount>0) { System.out.println("100"); }else if (matchBalCount == 4 && powerBallMatchCount<0) { System.out.println("100"); }else if (matchBalCount == 4 && powerBallMatchCount>0) { System.out.println("50000"); }else if (matchBalCount == 5 && powerBallMatchCount>0) { System.out.println("1lakh"); } } PowerBall(int[] w, int[] t) { winningNumber = w; ticketNumber = t; cash = 0; check(matchBalCount,powerBallMatchCount); } private static void test1() { int[] w = {4, 8, 19, 27, 24, 10}; { int[] n = {4, 8, 19, 27, 24, 10}; PowerBall x = new PowerBall(w, n); // x.cash(); } { int[] n = {24, 27, 19, 8, 4, 10}; PowerBall x = new PowerBall(w, n); } { int[] n = {24, 27, 19, 8, 4, 5}; PowerBall x = new PowerBall(w, n); } { int[] n = {124, 127, 119, 18, 14, 10}; PowerBall x = new PowerBall(w, n); } { int[] n = {124, 127, 119, 18, 14, 5}; PowerBall x = new PowerBall(w, n); } { int[] n = {124, 127, 119, 18, 14}; PowerBall x = new PowerBall(w, n); } { int[] n = {124, 124, 19, 119, 18, 14}; PowerBall x = new PowerBall(w, n); } } private static void testRandom() { int[] w = {4, 8, 19, 27, 24, 10}; int max = 10; long c = 0; for (int i = 0; i < max; ++i) { int[] n = u.generateRandomNumber(6, true, 1, 99); PowerBall x = new PowerBall(w, n); c = c + x.cash(); } System.out.println("Out of " + max + " times you win " + c + "$"); } private static void testBench() { test1(); testRandom(); } public static void main(String[] args) { System.out.println("PowerBall.java"); testBench(); System.out.println("Done"); } }
<java><arrays>
2016-01-17 22:18:44
LQ_EDIT
34,844,514
"Protocols cannot be used with isinstance()" - why not?
<p>The new <code>typing</code> module contains several objects with names like "SupportsInt" (-Float, -Bytes, etc.). The name, and the descriptions on <a href="https://docs.python.org/3/library/typing.html">the documentation page for the module</a>, might be read to suggest that you can test whether an object is of a type that "supports <code>__int__()</code>". But if you try to use <code>isinstance()</code>, it gives a response that makes it clear that that isn't something you are meant to do:</p> <pre><code>&gt;&gt;&gt; isinstance(5, typing.SupportsInt) (Traceback omitted) TypeError: Protocols cannot be used with isinstance(). </code></pre> <p>On the other hand, you can use <code>issubclass()</code>:</p> <pre><code>&gt;&gt;&gt; issubclass((5).__class__, typing.SupportsInt) True &gt;&gt;&gt; issubclass(type(5), typing.SupportsInt) True </code></pre> <p>What is a "protocol" in this context? Why does it disallow the use of <code>isinstance()</code> in this way?</p>
<python><python-3.x><isinstance>
2016-01-17 22:27:18
HQ
34,844,561
Difference between Notifications API and Push API from Web perspective
<p>What is the difference between <a href="https://developer.chrome.com/apps/notifications" rel="noreferrer">Chrome Notifications API</a> and the <a href="https://developers.google.com/web/updates/2015/03/push-notifications-on-the-open-web?hl=en" rel="noreferrer">Push Notification API</a> when developing Web notifications. When each one should be used and how are they different?</p>
<javascript><web-services><web><notifications><push-notification>
2016-01-17 22:32:28
HQ
34,844,765
Can't update or install package: An item with the same key has already been added
<h3>Problem</h3> <p>In a particular project, I can't update or install any NuGet packages. When I try to do so using the NuGet GUI, it does some work and then stops without saying anything. When I try to do so using the package manager console, I get this output:</p> <pre><code>PM&gt; Update-Package –reinstall EntityFramework Attempting to gather dependencies information for multiple packages with respect to project 'SmartCentre', targeting '.NETFramework,Version=v4.5.2' Update-Package : An item with the same key has already been added. At line:1 char:15 + Update-Package &lt;&lt;&lt;&lt; –reinstall EntityFramework + CategoryInfo : NotSpecified: (:) [Update-Package], Exception + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand </code></pre> <h3>Environment</h3> <ul> <li>Visual Studio Professional 2015 Update 1</li> <li>NuGet 3.3.0.167</li> </ul> <h3>What I've tried</h3> <ul> <li>Deleting the <code>packages</code> folder</li> <li>Restarting Visual Studio</li> <li>Restarting the computer</li> </ul>
<nuget>
2016-01-17 22:54:36
HQ
34,844,778
C language - death loop, maybe it's the scanf
scanf("%d",&jogadores[pos].dados[4][2]); while(jogadores[pos].dados[4][2]<0){ printf("O valor não pode ser menor que 0, introduz novamente: "); scanf("%d",&jogadores[pos].dados[4][2]); }; Do you know what is wrong is this piece of code, I think it skips the first scanf because it keeps printing "O valor não pode ser menor que 0, introduz novamente: "
<c><loops><scanf>
2016-01-17 22:55:48
LQ_EDIT
34,845,729
BETTER query and faster
<p>i would like to ask between these two query, what query is faster? if the data is 20k to 100k..</p> <pre><code>SELECT SUM(price * quantity) as sales FROM ( SELECT price, quantity, date FROM orderline UNION ALL SELECT price, quantity, date FROM creditorderline ) WHERE date BETWEEN '2010-01-01' AND '2016-01-01' </code></pre> <p>OR</p> <pre><code>SELECT SUM(price * quantity) as sales FROM ( SELECT price, quantity, date FROM orderline WHERE date BETWEEN '2010-01-01' AND '2016-01-01' UNION ALL SELECT price, quantity, date FROM creditorderline WHERE date BETWEEN '2010-01-01' AND '2016-01-01' ) </code></pre>
<mysql>
2016-01-18 00:56:44
LQ_CLOSE
34,845,786
Set Default/Null Value with Select TagHelper
<p>In asp.net mvc you can use:</p> <pre><code>@Html.DropDownListFor(model =&gt; model.Category, ViewBag.Category as IEnumerable&lt;SelectListItem&gt;, "-- SELECT --", new { @class = "form-control" }) </code></pre> <p>Using asp.net 5, how do I include the default or null value <strong>(-- SELECT --)</strong> in a taghelper:</p> <pre><code>&lt;select asp-for="Category" asp-items="@ViewBag.Category" class="form-control"&gt;&lt;/select&gt; </code></pre>
<c#><asp.net-core><asp.net-core-mvc><tag-helpers>
2016-01-18 01:04:49
HQ
34,845,990
Spring use one application.properties for production and another for debug
<p>I have a Spring application and I would like to be able to switch between configurations depending if I'm debugging the server or if the server is running in production. (the difference in configurations being things like database location.)</p> <p>Ideally, I'd like to pass in a command line argument to my Spring application on boot-up and set the application configuration.</p> <p>I have two separate application.properties files, one with the production values, and another with the debug values. How can I switch between the two of them?</p>
<java><spring>
2016-01-18 01:34:45
HQ