pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
25,294,454 | 0 | <p>It really depends on what scope you want the iterator to have. Generally speaking, you want to restrict its scope as much as possible while still letting it to its job<sup>1</sup>.</p> <p>If you're only going to use it inside the body of the loop, then it's preferable to define it in the loop header, so its scope is restricted to the loop body.</p> <p>If you're going to use it after the end of the loop, then define it above the loop so it still exists after the end of the loop.</p> <p>Of course, you generally want to avoid the whole question, such as by using a standard algorithm or range-based for loop (usually with <code>auto</code> instead of specifying the type explicitly).</p> <hr> <p><sub> 1. The same applies in general, not just to iterators. </sub></p> |
20,264,567 | 0 | <p>First, this line contains undefined behavior</p> <pre><code>print(++ptr,ptr--,ptr,ptr++,++ptr); </code></pre> <p>because it uses a variable that is part of an expression with side effect multiple times without reaching a <a href="http://en.wikipedia.org/wiki/Sequence_point" rel="nofollow"><em>sequence point</em></a>.</p> <blockquote> <p>In the code static keyword is used so i thought that each time it would take a different input.</p> </blockquote> <p>Presence or absence of <code>static</code> keyword makes no difference in this example, because the code never prints the value of the pointer, only the content of memory pointed to by that pointer.</p> <p>You can remove undefined behavior by moving each expression with side effects to a separate line, like this:</p> <pre><code>static int arr[]={97,98,99,100,101,102,103,104}; // static can be removed int *ptr=arr+1; // Start at index 1 printf("%d\n", *++ptr); // Move to index 2, prints 99 printf("%d\n", *ptr--); // Print 99, move to index 1 printf("%d\n", *ptr); // Print 98, stay at position 1 printf("%d\n", *ptr++); // Print 98, move to position 2 printf("%d\n", *++ptr); // Move to position 3, print 100 </code></pre> <p>(<a href="http://ideone.com/l110nj" rel="nofollow">demo</a>)</p> <p>Now the output is different (and correct):</p> <pre><code>99 99 98 98 100 </code></pre> <p>This is the output that you should expect to have based on the semantic of the pre-increment/decrement and post-increment/decrement operators.</p> |
23,709,460 | 0 | When using the *sync functions in Node.js, what (if any) background operations continue to run <p>When using the Node.js *Sync functions (I understand you shouldn't, and the reasons why), what (if any) background processes continue to run?</p> <p>For example, if I'm using http.createServer, and from one of the requests I call fs.writeFileSync(), will the server continue to serve new clients whilst that write is in progress (not just accept the connection, but process the entire request)? I.e. would writeFileSync() block the entire process, or just the current call chain?</p> |
19,637,578 | 0 | Error logging in with PayPal payments <p>I am using PayPal to process payments on my site, direct the user to the paypal checkout site, then redirect them back to the success page on my site, but I am having issues when one is directed to the paypal landing page. It won't accept valid paypal username and or passwords to login to complete the transaction. Has anyone had this issue before? Any help would be appreciated.</p> <p>Here is the html form code I have:</p> <pre><code><form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="ZHGKEN49VB9SG"> <input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> </code></pre> <p>Here is the link if it helps: <a href="http://tunesparker.com/members" rel="nofollow">http://tunesparker.com/members</a></p> |
7,393,812 | 0 | Ruby send method with rails associations <p>I have been messing about with making a sortable table module thing. I know some might exist but want to get experience doing this myself. I had the idea of have it like so:</p> <pre><code>SortedTable.new(ModelName, Hash_Of_Columns_And_Fields, ID) </code></pre> <p>example</p> <pre><code>SortedTable.new(Post, {"Title" => "title", "Body" => "body", "Last Comment" => "comment.last.title"}, params[:id]) </code></pre> <p>I am planning to do something like:</p> <pre><code>def initialize(model, fields, id) data = {} model = model.capitalize.constantize model.find(id) fields.each do |column, field| data[column] = model.send(field) end end </code></pre> <p>This works fine for title and body but when it comes to getting the <code>Last Comment</code> with <code>comment.last.title</code> it errors out. I have tried doing <code>Post.send("comments.last.title")</code> but says <code>NoMethodError: undefined method 'comments.last.title' for #<Post:0x0000010331d220></code></p> <p>I know I can do <code>Post.send("comments").send("last").send("title")</code> and that works but I can not think of how to do that dynamically by taking the fields and spliting the on . then chaining the sends. Can anyone give me advice on how to do this? If I am doing this completely wrong also then please say or point me in the direction of code that does something similar. I am not a expert ruby developer but I am trying.</p> <p>P.S The above code might not work as I am not at a computer with ruby/rails to test, but hopefully you get the concept.</p> <p>Cheers</p> |
35,057,308 | 0 | <p>For me changing back to MAMPS standard port settings did the trick.</p> |
4,631,207 | 0 | <p>This should do the trick:</p> <pre><code>#!/bin/bash for file in `find $1 -type f -name "*.txt"`; do nlines=`tail -n 1 $file | grep '^$' | wc -l` if [ $nlines -eq 1 ] then echo $file fi done; </code></pre> <p>Call it this way: <code>./script dir</code></p> <p>E.g. <code>./script /home/user/Documents/</code> -> lists all text files in <code>/home/user/Documents</code> ending with <code>\n</code>.</p> |
7,082,702 | 0 | <p>If you want to totally throw it away:</p> <pre><code>import subprocess import os with open(os.devnull, 'w') as fp: cmd = subprocess.Popen(("[command]",), stdout=fp) </code></pre> <p>If you are using Python 2.5, you will need <code>from __future__ import with_statement</code>, or just don't use <code>with</code>.</p> |
32,776,749 | 0 | <p>check below query, I tried below eg. and it is working fine for me,</p> <pre><code>SELECT users.*, threads.* FROM users, threads WHERE users.Username LIKE '?' OR threads.Name LIKE '?' </code></pre> <p>eg.</p> <pre><code>select p.name,bi.mrp from billitem bi,product p where p.name like 'a%' or bi.productname like 'ta%' </code></pre> |
14,523,648 | 0 | <p>You can use <code>wmic</code> command to get the current Date and time without getting affected by regional settings.</p> <pre><code>@echo off SETLOCAL EnableDelayedExpansion for /f "skip=1 tokens=1-6 delims= " %%a in ('wmic path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') do ( IF NOT "%%~f"=="" ( set /a FormattedDate=10000 * %%f + 100 * %%d + %%a set FormattedDate=!FormattedDate:~0,4!-!FormattedDate:~-4,2!-!FormattedDate:~-2,2! set /a FormattedTime=%%b * 10000 + %%c * 100 + %%e set FormattedTime=!FormattedTime:~0,2!:!FormattedTime:~-4,2!:!FormattedTime:~-2,2! ) ) echo !FormattedDate!T!FormattedTime!Z <--Assuming UTC timezone is used PAUSE </code></pre> <p>Here is the output after executing the script:</p> <pre><code>C:\>dateTime.bat 2013-01-25T22:11:40Z Press any key to continue... </code></pre> <p>Hope it helps :)</p> |
6,138,103 | 0 | <p>Jboss and Glassfish are great examples of application servers free for commercial use, you have to distinguish the difference between free use and support, both of them are free to use but if you want to get same support (not talking here about forums etc) you would have to probably pay for it.</p> |
38,276,018 | 0 | <p>I don't have a spotify account so, not sure with the user name password. But their doc says that they have REST implementation, so your credentials need to be 64 bit encoded.</p> <p>In this line <code>HttpRequest.SetRequestHeader "Authorization", "Basic " & strClient_secret</code></p> <p>the variable <code>strClient_secret</code> needs to be 64 bit encoded. </p> <p>so try adding a function like this, while replacing the place holders with correct user name and password.</p> <pre><code>Private Function EncodeBase64() As String arrData = StrConv(<<YOUR_SPOTIFY_USERID>> & ":" & <<YOUR_SPOTIFY_USERPASS>>, vbFromUnicode) Set objXML = New MSXML2.DOMDocument Set objNode = objXML.createElement("b64") objNode.DataType = "bin.base64" objNode.nodeTypedValue = arrData EncodeBase64 = objNode.text Set objNode = Nothing Set objXML = Nothing End Function </code></pre> <p>then change the line above to : <code>HttpRequest.SetRequestHeader "Authorization", "Basic " & EncodeBase64</code></p> <p>have a look here for REST and VBA: <a href="http://ashuvba.blogspot.com/2014/08/excel-vba-json-rest-with-jira-json-is.html" rel="nofollow">http://ashuvba.blogspot.com/2014/08/excel-vba-json-rest-with-jira-json-is.html</a></p> <p>It will set you on correct route hopefully.</p> |
37,001,010 | 0 | <p>I'm not sure you can use a different respond_to as you can only redirect or render once in an action. </p> <p>One approach would be to create a new route / controller method for updating the team name.</p> <p>routes</p> <pre><code>resources :teams do member { post 'update_name' } end </code></pre> <p>show.html.erb</p> <p>In the view, you can post to the above route and in the controller, create a method for the new route.</p> <pre><code><%= form_for @team, :url => update_name_team_path(@team) </code></pre> <p>teams_controller</p> <pre><code>def update_name @team = Team.find(params[:id]) redirect_to team_path(@team) end </code></pre> |
27,720,162 | 0 | Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor <p>I am using Spring 3.2.8.RELEASE, here is pom I am using</p> <pre><code><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <artifactId>PRINT</artifactId> <groupId>in.myOrg</groupId> <version>0.0.1-SNAPSHOT</version> </parent> <!-- <groupId>in.myOrg</groupId> --> <artifactId>PRINT-APP</artifactId> <!-- <version>0.0.1-SNAPSHOT</version> --> <packaging>war</packaging> <properties> <org.springframework.version>3.2.8.RELEASE</org.springframework.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>in.myOrg</groupId> <artifactId>PRINT-Common</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <!-- dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> </dependency --> <!-- dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core</artifactId> <version>3.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> <version>3.2.5.RELEASE</version> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.3</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.3</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging-api</artifactId> <version>1.1</version> </dependency> <dependency> <groupId>commons-pool</groupId> <artifactId>commons-pool</artifactId> <version>1.6</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.2.1</version> </dependency> <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.12</version> </dependency> <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.webconsole</artifactId> <version>3.1.2</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.7</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml-schemas</artifactId> <version>3.7</version> </dependency> <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>stax</groupId> <artifactId>stax-api</artifactId> <version>1.0.1</version> </dependency> <dependency> <groupId>xml-apis</groupId> <artifactId>xml-apis</artifactId> <version>1.0.b2</version> </dependency> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>net.sourceforge.jtds</groupId> <artifactId>jtds</artifactId> <version>1.2.2</version> </dependency> <!-- Jersey --> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> <version>1.8</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-core</artifactId> <version>1.8</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.jaxrs</groupId> <artifactId>jackson-jaxrs-json-provider</artifactId> <version>2.3.2</version> </dependency> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>1.9.11</version> </dependency> <!-- Spring 3 dependencies --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${org.springframework.version}</version> </dependency> <!-- Jersey + Spring --> <dependency> <groupId>com.sun.jersey.contribs</groupId> <artifactId>jersey-spring</artifactId> <version>1.8</version> <exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </exclusion> </exclusions> </dependency> <!-- Spring AOP + AspectJ --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${org.springframework.version}</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>1.6.11</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.6.11</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjtools</artifactId> <version>1.6.2</version> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>1.7.1</version> </dependency> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>5.0.6</version> </dependency> </dependencies> <build> <finalName>PRINT-APP</finalName> <resources> <resource> <directory>src/main/resources</directory> <targetPath>${basedir}/target</targetPath> <includes> <include>log4j.properties</include> </includes> </resource> </resources> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.3</version> <configuration> <warSourceDirectory>WebContent</warSourceDirectory> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.6</version> </plugin> <!-- plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <version>1.0-alpha-2</version> <executions> <execution> <phase>initialize</phase> <goals> <goal>read-project-properties</goal> </goals> </execution> </executions> <configuration> <files> <file>${basedir}\src\main\resources\build.properties</file> </files> </configuration> </plugin --> </plugins> </build> </code></pre> <p> I am getting following exception:</p> <pre><code>org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor] for bean with name 'org.springframework.context.annotation.internalAsyncAnnotationProcessor' defined in null: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1284) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:575) at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1350) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:355) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:326) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:434) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:624) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2944) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1208) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569) at org.springframework.util.ClassUtils.forName(ClassUtils.java:255) at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:416) at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1302) at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1273) ... 19 more Caused by: java.lang.ClassNotFoundException: org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569) ... 30 more </code></pre> <p>Can someone tell what problem is this, is it because of some version conflict?</p> |
22,592,262 | 0 | <p>Try this</p> <pre><code>var formfields = {step: $(this).data('step')}; $(this).parent().parent().parent().find('input').each(function () { formfields[$(this).prop('name')] = $(this).val(); }); console.log(formfields); </code></pre> |
15,019,945 | 0 | How many calls to generator are made? <p>Suppose I have the following algorithm:</p> <pre><code>procedure(n) if n == 1 then break R = generaterandom() procedure(n/2) </code></pre> <p>Now I understand that the complexity of this algorithm is <code>log(n)</code> but does it make <code>log(n)</code> calls to the random generator or <code>log(n)-1</code> since it is not called for the call when <code>n==1</code>.</p> <p>Sorry if this is obvious, but i've been looking around and its not really stated anywhere what the exact answer is.</p> |
11,312,907 | 0 | <p>I managed to fix this. There was two problems I found.</p> <ul> <li>Media Foundation was not initialized</li> </ul> <p><code>MFStartup(MF_VERSION);</code> needs to be called before Media Foundation can be used. I added this code just before creating the media engine.</p> <ul> <li>Referencing a pointer. </li> </ul> <p>Line <code>m_pickFileTask.then([&player](StorageFile^ fileHandle)</code> should be <code>m_pickFileTask.then([player](StorageFile^ fileHandle)</code>. <code>This</code> is already a pointer to the current class, and <code>&</code> provides the address of variable, so I was actually passing the pointer's pointer.</p> |
31,606,032 | 0 | <p>For this kind of requirement <code>QT</code> has <a href="http://doc.qt.io/qt-4.8/signalsandslots.html" rel="nofollow">Signal and Slots</a>. You have a <code>Signal</code> which will be emitted and consumed by assigned <code>SLOT</code> method. </p> <p>As you want to read Serial Data you should have Signal <code>readyRead</code> and connected to Slot which is done as below:</p> <pre><code>YourClass :: YourClass(QObject* parent): QObject(parent) { connect(serial, SIGNAL(readyRead()),this,SLOT(myReceivedData())); } </code></pre> <p>As this code in your Class <code>Constructor</code>.</p> <p>Implement this method as below:</p> <pre><code>void YourClass :: myReceivedData() { QByteArray readData= serial->readAll(); qDebug() << readCurData; // Here I am printing the received Serial Data } </code></pre> |
34,971,930 | 0 | <p>I would keep that logic out of the HTML and in your controller if possible and add another function to set a new value in your view (either num1 * num2 or "Please enter a number"). </p> <pre><code>$scope.isFinite = function(num1, num2) { //Your logic for this function } $scope.checkFinite() { $scope.answer = null; if($scope.isFinite($scope.num1, $scope.num2)) { $scope.answer = $scope.num1 * $scope.num2; }; else { $scope.answer = "Please enter a number" }; } </code></pre> <p>Then update your html as so: <code><p>Your total value is {{answer}} </p></code></p> <p>You will need to run $scope.checkFinite() when your input changes, there are a couple of ways you can do that:</p> <pre><code><div ng-app = ""> <p>Enter variable 1: <input type = "number" ng-change="checkFinite()" ng-model = "var1"></p> <p>Enter variable 2: <input type ="number" ng-change="checkFinite()" ng-model ="var2"></p> </code></pre> <p>Basically, if the values change in the inputs, it will run $scope.checkFinite(), its a nifty little directive in Angular.</p> <p>Another way you can do this, where you run the function ($scope.checkFinite()) when either inputs change is through a couple of watches in your controller:</p> <pre><code>$scope.$watch('num1', function() { $scope.checkFinite(); }); $scope.$watch('num2', function() { $scope.checkFinite(); }); </code></pre> <p>Let me know if you have any other questions!</p> <p>PS Don't go crazy with $scope.$watch, it's easy to fall into that trap.</p> |
40,944,208 | 0 | <p>Set LayoutParams as FILL_PARENT in both width and height</p> <pre><code> public void onClick(View view) { //getSupportActionBar().hide();if you need hidden actionbar also view.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); } </code></pre> |
15,787,471 | 0 | Delphi host for JavaFX applets <p>I have created a NPAPI host for JavaFX applets in Delphi 2010. The host uses a private JRE to show the applet. With Java 7 Update 10 it is possible to disable Java content in the browser. I do not want this setting to disable the plugins in my host. Is it possible to override the deployment properties for my private JRE?</p> |
27,144,000 | 0 | <p>The <code>DATATYPE</code> are different in <code>Oracle</code>. </p> <p>Also, <code>auto_increment</code> is not in <code>Oracle</code>. In <code>11g</code> and prior, create a <code>SEQUENCE</code> to populate the ID column, in <code>12c</code>, use <code>IDENTITY COLUMNS</code>.</p> <pre><code>SQL> DROP TABLE metadata PURGE; Table dropped. SQL> SQL> CREATE TABLE MetaData 2 ( 3 ID NUMBER NOT NULL, 4 metaDataId VARCHAR2(255) NOT NULL, 5 parentId number NOT NULL, 6 locked number, 7 userId number NOT NULL, 8 CONSTRAINT p_id PRIMARY KEY (id), 9 CONSTRAINT u_metadataid UNIQUE (metaDataId) 10 ); Table created. SQL> </code></pre> <p>For the <code>auto_increment</code> of ID, in <code>Oracle 10g</code>, you need to create a <code>sequence</code>.</p> <p>In <code>12c</code>, you can have an <code>IDENTITY COLUMN</code>.</p> |
3,339,907 | 0 | Why doesn't lint tell me the line number and nature of the parse error? <p>I'm calling php lint from a Windows batch file, like so:</p> <pre><code>@echo off for %%f in (*.php) do php -l %%f </code></pre> <p>When a file contains a syntax error, it only outputs <code>Errors parsing xxx.php</code>. Is there any way to get it to tell me what the nature of the error is, and what line it's on? Maybe another switch?</p> |
21,121,401 | 0 | <p>You probably have some relations between tables through these fields, as @Wrikken said in comments to your question. I've used a pretty similar table structure, and also added one more table to reproduce the assumption I'm talking about:</p> <blockquote> <p>-- First table, similar to problem table</p> <p>CREATE TABLE <code>bars</code> ( <code>id</code> int(11), <code>list</code> text, <code>bar</code> varchar(255), PRIMARY KEY (<code>id</code>) );</p> <p>INSERT INTO <code>bars</code> (<code>id</code>, <code>list</code>, <code>bar</code>) VALUES (1, '["1","2","3","4"]', 'TEST');</p> <p>-- Second table, to reproduce the assumtion</p> <p>CREATE TABLE <code>foos</code> ( <code>id</code> int(11), <code>foo</code> varchar(255), PRIMARY KEY (<code>id</code>) );</p> <p>INSERT INTO <code>foos</code> (<code>id</code>, <code>foo</code>) VALUES (1, 'foo1'), (2, 'foo2'), (3, 'foo3'), (4, 'foo4'), (5, 'foo5'), (6, 'foo6');</p> </blockquote> <p>From scratch everything works fine as expected, i can edit TEXT field as text:</p> <p><img src="https://i.stack.imgur.com/JOSTO.png" alt="enter image description here"></p> <p>To reproduce 'dropdown' effect I've opened a problem <code>bars</code> table (with TEXT field) relations:</p> <p><img src="https://i.stack.imgur.com/hhNz8.png" alt="enter image description here"></p> <p>and have added a reference to <code>foos</code>, a table with possible ids, that are stored in <code>list</code> TEXT field as array:</p> <p><img src="https://i.stack.imgur.com/5CIlL.png" alt="enter image description here"></p> <p>Now when editing a record i have a dropdown instead of textarea for TEXT <code>list</code> field</p> <p><img src="https://i.stack.imgur.com/P5Geo.png" alt="enter image description here"></p> <p>So, try to check whether you have your TEXT field involved in any relations</p> <p><em>sorry, no rep to comment yet, so giving a complete answer that may not be a solution at all</em></p> |
3,529,399 | 0 | <p>The solution for that problem seems to be this: you have to call the <code>[player stop]</code> before releasing it. It appears a little strange since I'm already receiving a notification about the player finished playing. Doing so the memory gets deallocated (only a small amount remains , ~100Kb from CoreMedia, but I believe is it normal</p> |
39,148,051 | 0 | <p>These could be the reason behind "Invalid record error" - </p> <pre><code>Reason - It usually happens when you use "create" and "build" together. create method persists the instance while the build method keeps it only in memory. </code></pre> <p>Firstly, I will suggest you to use build method and please check validations related to it. There is something wrong in your validations.</p> |
32,199,606 | 0 | <p>If the user of the app write the html tags, the app should store them.</p> <p>So as you suggest yourself, you will have to store the string before calling <code>Html.fromHtml</code>.</p> |
10,517,964 | 0 | local variable scope in linq anonymous method ( closure) <p>What is the scope of local variable declared in Linq Query.</p> <p>I was writing following code</p> <pre><code> static void Evaluate() { var listNumbers = Enumerable.Range(1, 10).Select(i => i); int i = 10; } </code></pre> <p>Compiler flagged error on line int i=10, stating </p> <pre><code>A local variable named 'i' cannot be declared in this scope because it would give a different meaning to 'i', which is already used in a 'child' scope to denote something else </code></pre> <p>I am unable to understand why this error is coming.</p> <p>My understanding was that <code>i</code> will become out of scope after first line (in foreach loop). So <code>i</code> can be declared again. </p> <p>Actual behavior is that <code>i</code> cannot be accessed after first line (in foreach loop), which is correct. But <code>i</code> cannot be declared again. This seems strange.</p> <p>EDIT This is a following question based on response by Andras. The answer is very good, but causes further doubts.</p> <pre><code> static void Evaluate3() { var listNumbers = Enumerable.Range(1, 10).Select(i => i); var listNumbers1 = Enumerable.Range(1, 10).Select(i => i); } </code></pre> <p>Based on the logic of function Evaluate that .Select(i=>i), and int i=10, both i, are local to function block and hence complication error.</p> <p>Function Evaluate3 should not compile as well as there are two i in the method block, but it is compiling successfully without any warning/error. </p> <p>Question, Either both Evaluate and Evaluate3 should not compile, or both should compile.</p> |
25,420,017 | 0 | <p>The style you described is not common partially because of the issues you mentioned. If your trying to achieve a functional style, you would be better off just using functions with type aliases.</p> <pre><code>// Alias the function type to a meaningful name type FetchFeed = String => List[Feed] // Declaring an implementation val fetchFeed: FetchFeed = url => ... // Nice type name to work with class MyWork(fetchFeed: FetchFeed) // Declaring a mock is still easy new MyWork(_ => List(new Feed)) </code></pre> |
38,520,501 | 0 | <p><code>var ifExist = YourList.Any(lambda expression)</code> checking if <code>YourList<T></code> contains object whitch fulifill lambda expression . It's only return <code>true</code> or <code>false</code>. If you want to have list of objects you should use <code>var YourNewList = YourList.Where(lambda expression).ToList()</code>.</p> |
18,180,292 | 0 | Bootstrap 3 RC1: Column Ordering <p>I have two primary boxes: an 8-col wide box with a bunch of panels and a second, 4-col (offset-1) to the right as a sidebar.</p> <p>I want to push the sidebar on top of the box o' sidebars on small screens. I've tried applying <code>col-12 col-push-12</code> (panel box) and <code>col-12 col-pull-12</code> (sidebar box) without any luck. I also want to ensure the sidebar is "centered" (i.e. as if it was col-offset-4 col-4) on the grid when it's pushed up top as well.</p> <p>I've also noticed some movement (open issues) on the Bootstrap repo over at GitHub regarding some of this behaviour, but I might just be conflating things.</p> <pre><code><div class="container content"> <div class="row"> <div class="col-lg-8 col-12"> <div class="panel listing"> ... </div> </div> <div class="col-sm-4 col-sm-offset-4 col-lg-3 col-lg-offset-1 col-12"> <div class="sidebar"> ... </div> </div> </div> </div> </code></pre> <p>Above is the "vanilla" code as it stands right now: what do I need to do to get the sidebar above on mobile and tablet?</p> <p><strong>Update</strong>: It appears the accepted answer/implementation no longer works due to some commits (given that "RC1" isn't what I'd call an RC!) today: <a href="https://github.com/twbs/bootstrap/commits/3.0.0-wip" rel="nofollow">https://github.com/twbs/bootstrap/commits/3.0.0-wip</a></p> <p>If anyone has an updated answer I'd appreciate it.</p> |
17,722,353 | 0 | PostSharp: BindingException when using with Microsoft.Bcl in Windows Phone 7 project <p>Following code throws exception during compilation:</p> <pre class="lang-cs prettyprint-override"><code>[PSerializable] public class MyAspectAttribute : OnMethodBoundaryAspect { } [MyAspect] Task<object> Method1<T>() { throw new NotImplementedException(); } </code></pre> <p>I have tried to find the minimal set of action to reproduce this problem and here it is:</p> <ol> <li>Create empty Windows Phone 7.1 project</li> <li>Add Microsoft.Bcl and PostSharp NuGet packages to it</li> <li>Create simple empty aspect (like below)</li> <li>Add somewhere generic method that returns any type from System.Threading.Tasks.dll</li> </ol> <p>Full exception text:</p> <pre class="lang-none prettyprint-override"><code>Unhandled exception (3.0.31.0, 32 bit, CLR 4.5, Release): PostSharp.Sdk.CodeModel.BindingException: The type 'System.Threading.Tasks.Task`1' does not exist in the target platform. at PostSharp.Sdk.CodeModel.Binding.ReflectionBindingManager.GetReferenceAssembly(IAssemblyName assemblyName, String typeName, BindingOptions bindingOptions) at PostSharp.Sdk.CodeModel.Binding.ReflectionBindingManager.ResolveAssembly(Type type, BindingOptions bindingOptions) at PostSharp.Sdk.CodeModel.ModuleDeclaration.FindType(Type reflectionType, BindingOptions bindingOptions) at PostSharp.Sdk.CodeModel.ModuleDeclaration.FindType(Type reflectionType, BindingOptions bindingOptions) at ^XJbqCOExOmCj.^i8LBKh1N(ModuleDeclaration _0, MethodBase _1, BindingOptions _2) at PostSharp.Sdk.CodeModel.ModuleDeclaration.FindMethod(MethodBase reflectionMethod, BindingOptions bindingOptions) at ^XJbqCOExOmCj.^4IrPP9eT(Object _0, IMethod _1, Type[] _2, Type[] _3, BindingOptions _4) at PostSharp.Sdk.CodeModel.MethodDefDeclaration.^NqB3CEvX(BindingOptions _0) at ^Mzw3\.bgGgRlJ.^cCM832sT[??0](Object _0, BindingOptions _1, ^d1u4kZd5aJLe _2) at PostSharp.Sdk.CodeModel.MethodDefDeclaration.GetSystemMethod(Type[] genericTypeArguments, Type[] genericMethodArguments, BindingOptions bindingOptions) at PostSharp.Sdk.CodeModel.MethodDefDeclaration.^xHA5o+hH(Type[] _0, Type[] _1, BindingOptions _2) at PostSharp.Sdk.CodeModel.MetadataDeclaration.^UDRJYqgBJZ7t(Type[] _0, Type[] _1, BindingOptions _2) at PostSharp.Sdk.AspectWeaver.AspectWeaverInstance..ctor(AspectWeaver aspectWeaver, AspectInstanceInfo aspectInstanceInfo) at PostSharp.Sdk.AspectWeaver.AspectWeavers.MethodLevelAspectWeaverInstance..ctor(MethodLevelAspectWeaver aspectWeaver, AspectInstanceInfo aspectInstanceInfo) at ^wy1eTA/ccvw/.CreateAspectWeaverInstance(AspectInstanceInfo _0) at PostSharp.Sdk.AspectWeaver.AspectWeaverTask.^lp9i7ZhC(InstructionWriter _0, AspectInstanceInfo _1, StructuredDeclarationDictionary`1 _2) at PostSharp.Sdk.AspectWeaver.AspectWeaverTask.^Vyy/rF6E.^Qs9Uz9QP(IMetadataDeclaration _0, AspectInstanceInfo _1) at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^lNgKC+Z4(IMetadataDeclaration _0, Func`3 _1) at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^RdBVqi\.M.^8/pSq47Q(IMetadataDeclaration _0) at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^d+wOzSPF(IMetadataDeclaration _0, Func`2 _1) at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^+g+TCqVg(TypeDefDeclaration _0, Func`2 _1, Set`1 _2) at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^fJqG(Func`2 _0) at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^fJqG(Func`3 _0) at PostSharp.Sdk.AspectWeaver.AspectWeaverTask.Execute() at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase) at PostSharp.Sdk.Extensibility.Project.Execute() at PostSharp.Hosting.PostSharpObject.ExecuteProjects() at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation) </code></pre> |
38,142,733 | 0 | <p>Are you making multiple connection to your database without closing them? If you are you should try implementing a check to see if only one connection is up.</p> <p>To check if your database is open you can do:</p> <pre><code>if(yourConnection.isOpen()){ doSomething(); //Maybe you want to close it here, if thats the case yourConnection.close(); } </code></pre> |
6,778,704 | 0 | <p>I did not try it, but you should be able to effectively emulate what is done there on the C side - decrypt each 16-byte (=128 bit) block separately, and reset the cipher between two calls.</p> <hr> <p>Please note that using CTR mode for just one block, with a zero initialization vector and counter, defeats the goal of CTR mode - <strong>it is worse than <a href="http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29" rel="nofollow">ECB</a></strong>.</p> <p>If I see this right, you could try to encrypt some blocks of zeros with your C function (or the equivalent Java version) - these should come out as the same block each time. XOR this block with any ciphertext to get your plaintext back.</p> <p>This is the equivalent to a Caesar cipher on a 128-bit alphabet (e.g. the 16-byte blocks), the block cipher adds no security here to a <strong>simple 128-bit XOR cipher</strong>. Guessing one block of plaintext (or more generally, guessing 128 bits at the right positions, not necessary all in the same block) allows getting the effective key, which allows getting all the remaining plaintext blocks.</p> |
35,415,014 | 0 | <p>It's impossible, whether in php or jquery.</p> |
4,168,455 | 0 | Why Flash Firebug doesn't work with flex 4.5? <p>Why Flash Firebug doesn't work with flex 4.5?</p> <p>UPDATE:</p> <p>Hy! I have Flex 4.5 and in the main application, in the script tag I write:</p> <pre><code>import ominds.Firebug; </code></pre> <p>I use flash player WIN 10,1,85,3 Debug enabled. I export swf as 10.1.85 version.</p> <p>And when I open the flashFirebug I get this: "No SWF files with the O-Minds package found, you should import the O-Minds package into your flash files. For more information visit: o-minds.com/products/flashfirebug"</p> <p>I appreciate any help (:</p> <p>I'm using robotlegs if this matters...</p> |
23,349,358 | 0 | <p>If your target systems are managed by reasonable people, the software will be managed by the packaging system. On Redhat, Fedora, CentOS or SUSE systems that will be RPM. On any system derived from Debian it will be APT.</p> <p>So your script can check for one of those two packaging systems. Although be warned that you can install RPM on a Debian system so the mere presence of RPM doesn't tell you the system type. Packages can also be named differently. For example, SUSE will name things a bit differently from Redhat.</p> <p>So, use <code>uname</code> and/or <code>/etc/issue</code> to determine system type. Then you can look for a particular package version with <code>rpm -q apache</code> or <code>dpkg-query -s postgresql</code>.</p> <p>If the systems are managed by lunatics, the software will be hand-built and installed in /opt or /usr/local or /home/nginx and versions will be unknown. In that case good luck.</p> |
25,524,026 | 0 | <p>I stumbled upon this problem after upgrading php to 5.5 and reinstalling apache.</p> <p>Finally,this fixed it, in case someone else needs it.</p> <p><code>apt-get install libapache2-mod-php5</code></p> <p>(<a href="http://serverfault.com/a/243979/239598">here's the answer</a>)</p> |
10,347,769 | 0 | <p>I would strongly recommend that you look at build tools like Ant or Maven. They are defacto standard for Java projects and will help you to achieve such tasks.</p> <p>Look at this link: <a href="http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html" rel="nofollow">http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html</a></p> <p>It will basically take 5 minutes of your time to understand the basic principles of Maven and perhaps 30 more to know how to use a plugin to to exactly what you want. If I had known five years ago about Maven it would literally saved weeks of my time.</p> |
4,582,120 | 0 | <p>An update on the last post... the code now includes a class for the list data structure. I've removed some bugs from the code. It should deliver the right results now.</p> <p>It seems that for one dimensional data structures, a list structure can actually be faster that an array. But for two dimensional structures, as in the code below, arrays are substantially faster than lists, and significantly faster than dictionaries.</p> <p>But it all depends on what you want to use the data structures for. For relatively small data sets, dictionaries and lists are often more convenient structures to use.</p> <pre><code>public interface IDataStructureTimeTestHandler { void PerformTimeTestsForDataStructures(); } public class DataStructureTimeTestHandler : IDataStructureTimeTestHandler { // Example of use: //IDataStructureTimeTestHandler iDataStructureTimeTestHandler = new DataStructureTimeTestHandler(); //iDataStructureTimeTestHandler.PerformTimeTestsForDataStructures(); private IDataStructureTimeTest[] iDataStructureTimeTests; private TimeSpan[,] testsResults; public DataStructureTimeTestHandler() { iDataStructureTimeTests = new IDataStructureTimeTest[3]; testsResults = new TimeSpan[4, 3]; } public void PerformTimeTestsForDataStructures() { iDataStructureTimeTests[0] = new ArrayTimeTest(); iDataStructureTimeTests[1] = new DictionaryTimeTest(); iDataStructureTimeTests[2] = new ListTimeTest(); for (int i = 0; i < iDataStructureTimeTests.Count(); i++) { testsResults[0, i] = iDataStructureTimeTests[i].InstantiationTime(); testsResults[1, i] = iDataStructureTimeTests[i].WriteTime(); testsResults[2, i] = iDataStructureTimeTests[i].ReadTime(LoopType.For); testsResults[3, i] = iDataStructureTimeTests[i].ReadTime(LoopType.Foreach); } } } public enum LoopType { For, Foreach } public interface IDataStructureTimeTest { TimeSpan InstantiationTime(); TimeSpan WriteTime(); TimeSpan ReadTime(LoopType loopType); } public abstract class DataStructureTimeTest { protected IStopwatchType iStopwatchType; protected long numberOfElements; protected int number; protected delegate void TimeTestDelegate(); protected DataStructureTimeTest() { iStopwatchType = new StopwatchType(); numberOfElements = 10000000; } protected void TimeTestDelegateMethod(TimeTestDelegate timeTestMethod) { iStopwatchType.StartTimeTest(); timeTestMethod(); iStopwatchType.EndTimeTest(); } } public class ArrayTimeTest : DataStructureTimeTest, IDataStructureTimeTest { private int[,] integerArray; public TimeSpan InstantiationTime() { TimeTestDelegateMethod(new TimeTestDelegate(InstantiationTime_)); return iStopwatchType.TimeElapsed; } private void InstantiationTime_() { integerArray = new int[numberOfElements, 2]; } public TimeSpan WriteTime() { TimeTestDelegateMethod(new TimeTestDelegate(WriteTime_)); return iStopwatchType.TimeElapsed; } private void WriteTime_() { number = 0; for (int i = 0; i < numberOfElements; i++) { integerArray[i, 0] = number; integerArray[i, 1] = number; number++; } } public TimeSpan ReadTime(LoopType dataStructureLoopType) { switch (dataStructureLoopType) { case LoopType.For: ReadTimeFor(); break; case LoopType.Foreach: ReadTimeForEach(); break; } return iStopwatchType.TimeElapsed; } private void ReadTimeFor() { TimeTestDelegateMethod(new TimeTestDelegate(ReadTimeFor_)); } private void ReadTimeFor_() { for (int i = 0; i < numberOfElements; i++) { number = integerArray[i, 1]; } } private void ReadTimeForEach() { TimeTestDelegateMethod(new TimeTestDelegate(ReadTimeForEach_)); } private void ReadTimeForEach_() { foreach (int i in integerArray) { number = i; } } } public class DictionaryTimeTest : DataStructureTimeTest, IDataStructureTimeTest { private Dictionary<int, int> integerDictionary; public TimeSpan InstantiationTime() { TimeTestDelegateMethod(new TimeTestDelegate(InstantiationTime_)); return iStopwatchType.TimeElapsed; } private void InstantiationTime_() { integerDictionary = new Dictionary<int, int>(); } public TimeSpan WriteTime() { TimeTestDelegateMethod(new TimeTestDelegate(WriteTime_)); return iStopwatchType.TimeElapsed; } private void WriteTime_() { number = 0; for (int i = 0; i < numberOfElements; i++) { integerDictionary.Add(number, number); number++; } } public TimeSpan ReadTime(LoopType dataStructureLoopType) { switch (dataStructureLoopType) { case LoopType.For: ReadTimeFor(); break; case LoopType.Foreach: ReadTimeForEach(); break; } return iStopwatchType.TimeElapsed; } private void ReadTimeFor() { TimeTestDelegateMethod(new TimeTestDelegate(ReadTimeFor_)); } private void ReadTimeFor_() { for (int i = 0; i < numberOfElements; i++) { number = integerDictionary[i]; } } private void ReadTimeForEach() { TimeTestDelegateMethod(new TimeTestDelegate(ReadTimeForEach_)); } private void ReadTimeForEach_() { foreach (KeyValuePair<int, int> i in integerDictionary) { number = i.Key; number = i.Value; } } } public class ListTimeTest : DataStructureTimeTest, IDataStructureTimeTest { private List<int[]> integerList; public TimeSpan InstantiationTime() { TimeTestDelegateMethod(new TimeTestDelegate(InstantiationTime_)); return iStopwatchType.TimeElapsed; } private void InstantiationTime_() { integerList = new List<int[]>(); } public TimeSpan WriteTime() { TimeTestDelegateMethod(new TimeTestDelegate(WriteTime_)); return iStopwatchType.TimeElapsed; } private void WriteTime_() { number = 0; for (int i = 0; i < numberOfElements; i++) { integerList.Add(new int[2] { number, number }); number++; } } public TimeSpan ReadTime(LoopType dataStructureLoopType) { switch (dataStructureLoopType) { case LoopType.For: ReadTimeFor(); break; case LoopType.Foreach: ReadTimeForEach(); break; } return iStopwatchType.TimeElapsed; } private void ReadTimeFor() { TimeTestDelegateMethod(new TimeTestDelegate(ReadTimeFor_)); } private void ReadTimeFor_() { for (int i = 0; i < numberOfElements; i++) { number = integerList[i].ElementAt(1); } } private void ReadTimeForEach() { TimeTestDelegateMethod(new TimeTestDelegate(ReadTimeForEach_)); } private void ReadTimeForEach_() { foreach (int[] i in integerList) { number = i.ElementAt(1); } } } </code></pre> |
13,422,354 | 0 | <p>Since your parameters are named differently, not too big a deal to query for each one.</p> <pre><code>string ok = string.Empty; NavigationContext.QueryString.TryGetValue("ok", out ok); string ko = string.Empty; NavigationContext.QueryString.TryGetValue("ko", out ko); </code></pre> |
187,904 | 0 | <p>If you used double quotes instead of single quotes it would work, but you'd be open to an injection attack if the variables weren't sanitized properly.</p> |
12,280,993 | 0 | Google Analytics event tracking - max string length <p>I am using Google Analytics for tracking events in my Android App. My question is: is there a limit for the string length in an event? I have found nothing about this topic on Googles devguide site.</p> <p>Best regards!</p> <p><strong>Edit:</strong> I tried it whith a string with 2000 characters - and it works. If you need more (I don't believe), than try it first.</p> |
32,542 | 0 | <p>The biggest one is making sure you don't put pointers into 32-bit storage locations.</p> <p>But there's no proper 'language-agnostic' answer to this question, really. You couldn't even get a particularly firm answer if you restricted yourself to something like standard 'C' or 'C++' - the size of data storage, pointers, etc, is all terribly implementation dependant.</p> |
16,610,016 | 0 | <p>Try this</p> <pre><code> o = { center : { x:1, y:1 } } o.startPosition = {x:o.center.x, y:o.center.y} </code></pre> |
7,736,699 | 0 | Django TinyMCE issues <p>All the textareas are inline, StackedInline</p> <p>All textareas works fine in this model change_view. BUT, when I add a new row the last row is not editiable in the textarea.</p> <p>If I remove the mode:"textareas" in the tunyMCE Init, it abviasly removes the wsgi editor but then the textareas work when adding new ones. So I guess its tinyMCE that breaks it.</p> <p>But I haved copied this tinyMCE files form another project where it works. So I dont know wtf!</p> <p>I have my tinymce setup like this:</p> <p>media/js/tinymce</p> <p>then I have in templates:</p> <p>templates/admin/app_name/model_name/change_form.html</p> <p>and this is my change_form.html</p> <pre><code>{% extends "admin/change_form.html" %} {% load i18n %} {% block extrahead %}{{ block.super }} {% url 'admin:jsi18n' as jsi18nurl %} <script type="text/javascript" src="{{ jsi18nurl|default:"../../../jsi18n/" }}"></script> {{ media }} <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery-1.6.4.min.js"></script> <script type="text/javascript" src="{{ MEDIA_URL }}js/tiny_mce/tiny_mce.js"></script> <script type="text/javascript"> function CustomFileBrowser(field_name, url, type, win) { var cmsURL = "/admin/filebrowser/browse/?pop=2"; cmsURL = cmsURL + "&type=" + type; tinyMCE.activeEditor.windowManager.open({ file: cmsURL, width: 850, // Your dimensions may differ - toy around with them! height: 650, resizable: "yes", scrollbars: "yes", inline: "no", // This parameter only has an effect if you use the inlinepopups plugin! close_previous: "no", }, { window: win, input: field_name, editor_id: tinyMCE.selectedInstance.editorId, }); return false; }; tinyMCE.init({ // add these two lines for absolute urls remove_script_host : false, convert_urls : false, // General options mode : "textareas", theme : "advanced", plugins : "safari,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media", file_browser_callback: 'CustomFileBrowser', // Theme options theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|styleselect,formatselect,|,undo,redo,|,link,unlink,image,code", theme_advanced_buttons3 : "", theme_advanced_buttons4 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", // theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : false, width:300, height:300, }); </script> {% endblock %} {% block object-tools %} {% if change %}{% if not is_popup %} <ul class="object-tools"> <li><a href="history/" class="historylink">{% trans "History" %}</a></li> {% if has_absolute_url %} <li><a href="../../../r/{{ content_type_id }}/{{ object_id }}/" class="viewsitelink"> {% trans "View on site" %}</a> </li> <li><a href="../../../r/{{ content_type_id }}/{{ object_id }}/html/" class="viewsitelink"> {% trans "View source" %}</a> </li> {% endif%} </ul> {% endif %}{% endif %} {% endblock %} </code></pre> <p>Even If I do this in textareas.js and include that in the chnage_form.html extrahead block it does the same.</p> |
35,597,290 | 0 | Invalid argument tag <p>I am doing some customization of block insertion in Autocad. When setting up the attributes, I am getting an error in my procedure:</p> <p>"Invalid argument Tag in setting TagString"</p> <p>The code is as follows:</p> <pre><code>Sub Ch10_GettingAttributes() ' Create the block Dim blockObj As AcadBlock Dim insertionPnt(0 To 2) As Double insertionPnt(0) = 0 insertionPnt(1) = 0 insertionPnt(2) = 0 Set blockObj = ThisDrawing.Blocks.Add _ (insertionPnt, "TESTBLOCK") ' Define the attribute definition Dim attributeObj As AcadAttribute Dim height As Double Dim mode As Long Dim prompt As String Dim insertionPoint(0 To 2) As Double Dim tag As String Dim value As String height = 1# mode = acAttributeModeVerify prompt = "Attribute Prompt" insertionPoint(0) = 5 insertionPoint(1) = 5 insertionPoint(2) = 0 tag = "Attribute Tag" value = "Attribute Value" ' Create the attribute definition object on the block Set attributeObj = blockObj.AddAttribute(height, mode,_ prompt, insertionPoint, tag, value) End Sub </code></pre> <p>What would cause this error?</p> |
2,514,485 | 0 | <p>You need to know both, The RoR framework is an organizational and convenience system if you will, what it organizes is your ruby code.</p> <p>If you have programmed before then here are most of your answers:<br> <a href="http://www.ruby-doc.org/core/" rel="nofollow noreferrer">http://www.ruby-doc.org/core/</a><br> <a href="http://railsapi.com" rel="nofollow noreferrer">http://railsapi.com</a></p> |
36,150,257 | 1 | Probability Distribution Function Python <p>I have a set of raw data and I have to identify the distribution of that data. What is the easiest way to plot a probability distribution function? I have tried fitting it in normal distribution. </p> <p>But I am more curious to know which distribution does the data carry within itself ? </p> <p>I have no code to show my progress as I have failed to find any functions in python that will allow me to test the distribution of the dataset. I do not want to slice the data and force it to fit in may be normal or skew distribution. </p> <p>Is any way to determine the distribution of the dataset ? Any suggestion appreciated.</p> <p>Is this any correct approach ? <a href="http://stackoverflow.com/questions/7062936/probability-distribution-function-in-python">Example</a><br> This is something close what I am looking for but again it fits the data into normal distribution. <a href="http://stackoverflow.com/questions/23251759/how-to-determine-what-is-the-probability-distribution-function-from-a-numpy-arra">Example</a></p> <p>EDIT:</p> <p>The input has million rows and the short sample is given below </p> <pre><code>Hashtag,Frequency #Car,45 #photo,4 #movie,6 #life,1 </code></pre> <p>The frequency ranges from <code>1</code> to <code>20,000</code> count and I am trying to identify the distribution of the frequency of the keywords. I tried plotting a simple histogram but I get the output as a single bar. </p> <p>Code: </p> <pre><code>import pandas import matplotlib.pyplot as plt df = pandas.read_csv('Paris_random_hash.csv', sep=',') plt.hist(df['Frequency']) plt.show() </code></pre> <p>Output <a href="https://i.stack.imgur.com/ZqY70.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZqY70.png" alt="Output of frequency count"></a></p> |
36,919,928 | 0 | <p>To understand why it is returning <code>undefined</code> instead of <code>ali</code>, you have to understand <strong>JavaScript binding</strong>.</p> <p>If you are accessing a method through a reference instead of directly through its owner object, as you are doing, the method loses its implicit binding, and <code>this</code> stops referencing its owner object and goes back to its default binding, meaning the global object (or <code>undefined</code> in strict mode).</p> <p>Ultimately, what matters is the manner in which the function is invoked.</p> <p>See below for more information (there are exceptions, but it can be generally summarized as the following):</p> <blockquote> <p><strong><a href="https://github.com/getify/You-Dont-Know-JS/blob/master/this%20%26%20object%20prototypes/ch2.md#determining-this" rel="nofollow">Breakdown from YDKJS: Determining <code>this</code></a></strong></p> <p>Now, we can summarize the rules for determining this from a function call's call-site, in their order of precedence. Ask these questions in this order, and stop when the first rule applies.</p> <ol> <li><p>Is the function called with new (<strong>new binding</strong>)? If so, this is the newly constructed object.</p> <ul> <li>var bar = new foo()</li> </ul></li> <li><p>Is the function called with call or apply (<strong>explicit binding</strong>), even hidden inside a bind hard binding? If so, this is the explicitly specified object.</p> <ul> <li>var bar = foo.call( obj2 )</li> </ul></li> <li><p>Is the function called with a context (<strong>implicit binding</strong>), otherwise known as an owning or containing object? If so, this is that context object.</p> <ul> <li>var bar = obj1.foo()</li> </ul></li> <li><p>Otherwise, default the this (<strong>default binding</strong>). If in strict mode, pick undefined, otherwise pick the global object.</p> <ul> <li>var bar = foo()</li> </ul></li> </ol> </blockquote> <p>Note: In ES6, <code>this</code> is the <strong>lexical <code>this</code></strong> for fat arrow functions <code>=></code> and with object short hand notation (e.g., <code>sampleMethod() {}</code>), meaning that <code>this</code> takes on the outer context as reference. </p> |
15,256,560 | 0 | <p>Hard to tell if it's your only problem but <a href="http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.readexisting.aspx" rel="nofollow"><code>SerialPort.ReadExisting()</code></a> only reads the data that is <em>immediately</em> available (ie in the stream and buffer).</p> <p>Your program writes data to the modem, and calls <code>ReadExisting()</code> right away. <code>ReadExisting</code> will return immediately with no data available, since the modem has had no time to respond.</p> |
32,404,260 | 0 | Getting a 404 after starting Artifactory/Tomcat running on centos <p>I'm trying to get Artifactory running on a centos server. This is what I did:</p> <p>Created a new user called artifactory</p> <p>switched to that user</p> <p><code>wget https://bintray.com/artifact/download/jfrog/artifactory-rpms/jfrog-artifactory-oss-4.0.2.rpm</code></p> <p>then followed instructions from artifactorys docs</p> <p><code>rpm -ivh jfrog-artifactory-oss-4.0.2.rpm</code></p> <p><code>service artifactory start</code></p> <p><code>service artifactory check</code></p> <p>I get a pid, which according to docs. Everything is working properly. I then navigate to the webpage, but I get a 404:</p> <blockquote> <p>HTTP Status 404 - /artifactory</p> <p>type Status report</p> <p>message /artifactory</p> <p>description The requested resource is not available.</p> <p>Apache Tomcat/8.0.22</p> </blockquote> <p>I want to check logs, which are apparently located at $ARTIFACTORY_HOME/logs/artifactory.log but dir is not found. Doing echo $ARTIFACTORY_HOME doesn't output anything. I did a find command on artifactory.log but no results. Super confused. Any tips would be appreciated.</p> <p><strong>UPDATE:</strong></p> <p>Here are some log updates as per the tips from JBaruch.</p> <p>I navigated to /var/opt/jfrog/artifactory/tomcat/logs</p> <p>ls showed <code>catalina.2015-09-04.log catalina.out host-manager.2015-09-04.log localhost.2015-09-04.log manager.2015-09-04.log</code></p> <p>Here is a output from catalina.out and from localhost.2015-09-04.log:</p> <p>catalina.out</p> <pre><code>Sep 04, 2015 1:26:30 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-nio-8081"] Sep 04, 2015 1:26:30 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFO: Using a shared selector for servlet write/read Sep 04, 2015 1:26:30 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["ajp-nio-8019"] Sep 04, 2015 1:26:30 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFO: Using a shared selector for servlet write/read Sep 04, 2015 1:26:30 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Sep 04, 2015 1:26:30 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/8.0.22 Sep 04, 2015 1:26:30 PM org.apache.catalina.startup.HostConfig deployDescriptor INFO: Deploying configuration descriptor /opt/jfrog/artifactory/tomcat/conf/Catalina/localhost/artifactory.xml Sep 04, 2015 1:26:32 PM org.apache.catalina.core.StandardContext startInternal SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file Sep 04, 2015 1:26:32 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Context [/artifactory] startup failed due to previous errors Sep 04, 2015 1:26:32 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc WARNING: The web application [artifactory] registered the JDBC driver [org.apache.derby.jdbc.AutoloadedDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. Sep 04, 2015 1:26:32 PM org.apache.catalina.startup.HostConfig deployDescriptor INFO: Deployment of configuration descriptor /opt/jfrog/artifactory/tomcat/conf/Catalina/localhost/artifactory.xml has finished in 2,004 ms Sep 04, 2015 1:26:32 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory /opt/jfrog/artifactory/tomcat/webapps/ROOT Sep 04, 2015 1:26:32 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deployment of web application directory /opt/jfrog/artifactory/tomcat/webapps/ROOT has finished in 57 ms Sep 04, 2015 1:26:32 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-nio-8081"] Sep 04, 2015 1:26:32 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-nio-8019"] </code></pre> <p>And for localhost.2015-09-04.log </p> <pre><code>04-Sep-2015 13:26:32.596 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class org.artifactory.webapp.servlet.ArtifactoryHomeConfigListener java.lang.UnsupportedClassVersionError: org/artifactory/webapp/servlet/ArtifactoryHomeConfigListener : Unsupported major.minor version 52.0 (unable to load class org.artifactory.webapp.servlet.ArtifactoryHomeConfigListener) at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2476) at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:854) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1274) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:520) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:501) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:120) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4651) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1750) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) 04-Sep-2015 13:26:32.598 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class org.artifactory.webapp.servlet.logback.LogbackConfigListener java.lang.UnsupportedClassVersionError: org/artifactory/webapp/servlet/logback/LogbackConfigListener : Unsupported major.minor version 52.0 (unable to load class org.artifactory.webapp.servlet.logback.LogbackConfigListener) at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2476) at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:854) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1274) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:520) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:501) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:120) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4651) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1750) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) 04-Sep-2015 13:26:32.600 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class org.artifactory.webapp.servlet.ArtifactoryContextConfigListener java.lang.UnsupportedClassVersionError: org/artifactory/webapp/servlet/ArtifactoryContextConfigListener : Unsupported major.minor version 52.0 (unable to load class org.artifactory.webapp.servlet.ArtifactoryContextConfigListener) at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2476) at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:854) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1274) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:520) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:501) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:120) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4651) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1750) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) 04-Sep-2015 13:26:32.607 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Skipped installing application listeners due to previous error(s) </code></pre> |
35,866,392 | 0 | My imagePickerController didFinishPickingMediaWithInfo newer get called <p>I try to write an App that needs a screen where you can take multible photos. I have used a code example from <a href="http://makeapppie.com/2015/11/04/how-to-make-xib-based-custom-uiimagepickercontroller-cameras-in-swift/" rel="nofollow">http://makeapppie.com/2015/11/04/how-to-make-xib-based-custom-uiimagepickercontroller-cameras-in-swift/</a>.</p> <p>It seems to be working OK, but my imagePickerController didFinishPickingMediaWithInfo newer get called. I am getting an error message from Xcode "Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates." It sounds to me like this could be the problem, and I have googled it, but havn't gotten any wiser. A lot of people write it's an Apple bug and I havn't found anybody offering a solution. </p> <p>So do anybody know if it is the Xcode error that is my problem, and in that case have a solution for that or have I written something wrong in my code:</p> <pre><code>import UIKit class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, CustomOverlayDelegate { var picker = UIImagePickerController() @IBAction func shootPhoto(sender: AnyObject) { if UIImagePickerController.availableCaptureModesForCameraDevice(.Rear) != nil { picker = UIImagePickerController() //make a clean controller picker.allowsEditing = false picker.sourceType = UIImagePickerControllerSourceType.Camera picker.cameraCaptureMode = .Photo picker.showsCameraControls = false //customView stuff let customViewController = CustomOverlayViewController( nibName:"CustomOverlayViewController", bundle: nil ) let customView:CustomOverlayView = customViewController.view as! CustomOverlayView customView.frame = self.picker.view.frame customView.cameraLabel.text = "Hello Cute Camera" customView.delegate = self //presentation of the camera picker.modalPresentationStyle = .FullScreen presentViewController(picker, animated: true,completion: { self.picker.cameraOverlayView = customView }) } else { //no camera found -- alert the user. let alertVC = UIAlertController( title: "No Camera", message: "Sorry, this device has no camera", preferredStyle: .Alert) let okAction = UIAlertAction( title: "OK", style:.Default, handler: nil) alertVC.addAction(okAction) presentViewController( alertVC, animated: true, completion: nil) } } func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) { print("didFinishPickingMediaWithInfo") let chosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage //get the image from info UIImageWriteToSavedPhotosAlbum(chosenImage, self,nil, nil) //save to the photo library } //What to do if the image picker cancels. func imagePickerControllerDidCancel(picker: UIImagePickerController) { dismissViewControllerAnimated(true, completion: nil) } //MARK: Custom View Delegates func didCancel(overlayView:CustomOverlayView) { picker.dismissViewControllerAnimated(true, completion: nil) print("dismissed!!") } func didShoot(overlayView:CustomOverlayView) { picker.takePicture() overlayView.cameraLabel.text = "Shot Photo" print("Shot Photo") } func weAreDone(overlayView: CustomOverlayView) { picker.dismissViewControllerAnimated(true, completion: nil) print("We are done!") } } </code></pre> |
10,715,315 | 0 | <p>The Sonar extension uses the underlying ant task and passes parameters from buildr to ant. The parameters that you can use will be documented in the next release of Buildr. But to get you started here is a simple example that uses all the configuration parameters. The only property that must be set is "enabled", while the remainder attempt to have sensible defaults.</p> <pre><code>require 'buildr/sonar' define "foo" do project.version = "1.0.0" define "bar" do ... end sonar.enabled = true sonar.project_name = 'Foo-Project' sonar.key = 'foo:project' sonar.jdbc_url = 'jdbc:jtds:sqlserver://example.org/SONAR;instance=MyInstance;SelectMethod=Cursor' sonar.jdbc_driver_class_name = 'net.sourceforge.jtds.jdbc.Driver' sonar.jdbc_username = 'sonar' sonar.jdbc_password = 'secret' sonar.host_url = 'http://127.0.0.1:9000' sonar.sources << project('foo:bar')._(:source, :main, :java) sonar.binaries << project('foo:bar').compile.target sonar.libraries << project('foo:bar').compile.dependencies end </code></pre> |
29,130,329 | 0 | <p>The problem might be the format of the single quotes you have in your script. They appear to be close quotes instead of straight quotes. Try pasting into notepad and deleting/retyping all single quotes, then save.</p> |
23,255,242 | 0 | <p>This is because the function works in a separate workspace than the rest of the script. What you may want to do is change that last line to:</p> <pre><code>Write-Output "$message$ServiceName is not running attemting to start" </code></pre> <p>Then when you call the function you can do:</p> <pre><code>$Message = StartServiceFunction </code></pre> <p>And then $Message captures any output from the function, which would be the message you wanted to pass.</p> <p>Or just have the function pass the service that isn't running and attempting to start, and run it as $Message += Function such as:</p> <pre><code>$startservice=Start-Service $ServiceName Write-Output "$ServiceName is not running attemting to start" ForEach($servicename in $services) { $Message += FuncCheckService $ServiceName } </code></pre> <p>Alternatively, and I wouldn't recommend doing it this way, you could reference the global variable instead when you update it:</p> <pre><code>$global:message+="$ServiceName is not running attemting to start" </code></pre> <p>That will update the $message variable outside of the function.</p> |
23,344,050 | 0 | <p>Some of the more common problems when users have to deploy a server is that they have to specify previously the security group that the server has to use. In this security group, is mandatory that you specify the port that you want to use, in order that this port will be opened afterward in the server that you want to deploy.</p> <p>If no security group is specified, by default all ports will be closed and you cannot access to the port 80 or access to the server via SSH using the default port 22 or whatever port that you want to use in your instantiate server.</p> |
2,051,741 | 0 | <p>To disable cell selection you can implement <code>-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath</code> method in table view delegate and return nil if you don't want cell with given NSIndexPath to be selected.<br> As already pointed in other answers to disable cell highlighting you should set its selectionStyle property to UITableViewCellSelectionStyleNone.<br> Also make sure that you set properties correctly when reusing tableviewcells</p> |
28,281,830 | 0 | <p>You could get the Threads in the next way:</p> <pre><code>public function getThreads($user) { $em = $this->getEntityManager(); $query = $em->createQuery( 'SELECT t FROM AcmeMessageBundle:Thread t WHERE :user MEMBER OF t.users ORDER BY t.date DESC' ) ->setParameter('user', $user) ->setMaxResults( 20 ); $threads = $query->getResult(); return $threads; } </code></pre> <p>And you will receive a Doctrine ArrayCollection of Threads (you need to remove AcmeMessageBundle and put the right name of your Bundle).</p> <p><strong>EDIT:</strong> Reading your question again, and seeing your examples, I think that what you want are not the threads, are the posts of the threads related with the user. You could do this adding a bidirectional relation between your Post and your Thread entities, as below:</p> <p>In the Thread entity, add this:</p> <pre><code>/** * @ORM\OneToMany(targetEntity="\Acme\MessageBundle\Entity\Post", mappedBy="thread") */ private $posts; </code></pre> <p>And in the <em>construct</em> function:</p> <pre><code>$this->posts = new \Doctrine\Common\Collections\ArrayCollection(); </code></pre> <p>In the Post entity, modify your lines as here:</p> <pre><code>/** * @ORM\ManyToOne(targetEntity="Acme\MessageBundle\Entity\Thread", inversedby="posts") * @ORM\JoinColumn(nullable=false) */ private $thread; </code></pre> <p>And generate the getter and setter for the posts in the Thread entity, so in this way, you can get the posts after you get the threads as above.</p> |
6,314,754 | 0 | android how to put progressdialog in TabActivity <p>I hav an application where I have an TabActivity and which have 2tabs(each tab as an activity) First tab(an activity) loads data from internet. So I want there a progressdialog until the 1st tab(an activity) loads data from internet.</p> <pre><code>ProgressDialog.show(TabHostActivity.this, "Working..", "Downloading Data...",true); pd.dismiss(); </code></pre> <p>only this much code i have which not give satisfaction please anybody tell me what i write to show a progressdialog until it download the data. (means i hav to use thread). Please give me answer along with code Thank you </p> |
18,271,321 | 0 | <p>You should implement a sliding window approach. In each window, you should apply the SVM to get candidates. Then, once you've done it for the whole image, you should merge the candidates (if you detected an object, then it is very likely that you'll detect it again in shift of a few pixels - that's the meaning of candidates).</p> <p>Take a look at the V&J code at openCV or the latentSVM code (detection by parts) to see how it's done there.</p> <p>By the way, I would use the LatentSVM code (detection by parts) to detect vehicles. It has trained models for cars and for buses.</p> <p>Good luck.</p> |
10,857,763 | 0 | <p>There is no public <code>NativeMethods</code> class in .NET. It is considered good practice to put calls in a <code>NativeMethods</code> class, so this is probably what you are seeing.</p> <p>You need to use P/Invoke to call Win32 API functions. See <a href="http://msdn.microsoft.com/en-us/library/aa288468%28v=vs.71%29.aspx" rel="nofollow">this tutorial</a>.</p> |
8,754,679 | 0 | <pre><code>//global flag to check condition var flag = true; $('#yourelement').click(function(){ if(flag == true){ flag = false; $('#yourotherelement').attr('rel', newValue); }else{ flag = true; $('#yourotherelement').attr('rel', oldValue); } }); </code></pre> |
21,879,864 | 0 | <p>Check my library <a href="https://github.com/sergey-miryanov/linden-google-play" rel="nofollow">https://github.com/sergey-miryanov/linden-google-play</a>. Now it supports Leaderboard, Achievements and CloudSave. Another my lib <a href="https://github.com/sergey-miryanov/linden-google-iap" rel="nofollow">https://github.com/sergey-miryanov/linden-google-iap</a> support in-app purchases for GooglePlay.</p> |
3,778,668 | 0 | <p>It would not be doing you any favors to help you refactor this code. LINQ to Entities queries are eventually translated into SQL, and this SQL is going to be a mess no matter how good the code looks. You need to reconsider your querying strategy based on the tools your database gives you. Ideally, you should be able to write a query which uses an index.</p> <p>There are two strategies to consider: Collations and schema changes.</p> <p>You haven't mentioned which database you are using, but most databases offer collations which are accent-insensitive for WHERE searches. You should consider changing the collation on the column to one of these.</p> <p>Regarding the dollar signs and the like, you probably won't find a collation which would just ignore these unless you write it yourself. So a different option would be to have a separate column in the database, updated by a trigger, which contains the first and last name with these characters removed. Run your search against that, instead, and an index on these columns can be used.</p> |
17,053,885 | 0 | ERROR - The specified data type is not valid. [ Data type (if known) = varchar ] <p>I have recently installed SQL 2008 R2</p> <pre><code>CREATE TABLE TPERSONS( personid int PRIMARY KEY NOT NULL, lastname varchar(50) NULL, firstname varchar(50) NULL, salary money NULL, managerid int NULL -- foreign key to personid ) </code></pre> <p>I do not understand why I receive this error.</p> <pre><code>Major Error 0x80040E14, Minor Error 26302 ) The specified data type is not valid. [ Data type (if known) = varchar ] </code></pre> |
4,440,999 | 0 | <p>Any java.util.Collection that does not implement the Set interface. Probably you'll want something that implements a List.</p> |
1,920,724 | 0 | <p>One reason for using different tablespaces would be a desire to use tablespace transportation for moving data between databases. If you have a limited set of data that you want to move without having to export and import it then tablespace transport is a good option, particularly if it is important for testing reasons that the data have exactly the same physical structure as the source system (for performance analysis work, for example).</p> |
32,068,613 | 0 | <p>May be unrelated to performance, but the code as it written now has strange parallelization structure.</p> <p>I doubt it can produce correct results, because the <code>while</code> loop inside the <code>parallel</code> does not have barriers (<code>omp master</code> does not have barrier, <code>omp for nowait</code> also does not have barrier). </p> <p>As a result, (1) threads may start <code>omp for</code> loop before the master thread finishes <code>Tree.PreProcessing()</code>, some threads actually may execute <code>omp for</code> any number of times before the master works on single pre-processing step; (2) master may run <code>Tree.PropagatePositions()</code> before other threads finish the <code>omp for</code>; (3) different threads may run different time steps; (4) theoretically the master thread may finish all steps of the <code>while</code> loop before some thread even enters parallel region, and thus some iterations of the <code>omp for</code> loop may be never executed at all.</p> <p>Or am I missing something?</p> |
24,933,644 | 0 | <p>I had to read your post multiple times to try to get what you were looking for. If I'm reading you correctly, what you want is the first <code><a></code> tag to act as a <code>display:block</code> so that when you hover over it the entire width is clickable, but you want the second <code><a></code> tag to float to the right on the same line.</p> <p>I believe that <a href="http://jsfiddle.net/Arwxh/" rel="nofollow"><strong>this demo</strong></a> will accomplish what you wish. I changed the order of the anchor links to make it as easy as possible. Also added background colors so you could see what's going on.</p> <pre><code><li class="file"><a href="" class="delete">Delete</a><a href="">Long Link Name</a> </code></pre> <p>The CSS required would be:</p> <pre><code>ul.tree li { list-style: none; padding: 0px; padding-left: 20px; margin: 0px; white-space: nowrap; } ul.tree a { color: #111; text-decoration: none; display: block; padding: 0px 2px; background-color: gold; //so you can see what's happening } ul.tree .delete { background-color: lightgreen; //so you can see what's happening margin: 0 0 0 5px; display: inline; float: right; } ul.tree a:hover { background-color: lightblue; //so you can see what's happening } .tree li.directory { background: url(/images/directory.png) left top no-repeat; } .tree li.file { background: url(/images/file.png) left top no-repeat; } </code></pre> <p>If changing the order of the anchors is out of the question, I could muck around with some more elaborate CSS, but as the complexity of the CSS increases, so do your chances of it breaking in one browser or the other. </p> <hr> <p><strong>EDIT:</strong> Based on your reply, I've created some CSS to add an ellipsis (…) when the link text is too long. It requires setting a width on the main <code><ul></code>, but from your initial question it sounds like you're doing that anyway. You can see the <a href="http://jsfiddle.net/Arwxh/5/" rel="nofollow">updated JSFiddle here</a>, and here's the updated CSS:</p> <pre><code>ul { width: 333px; } ul ul { width: inherit; } a { overflow: hidden; text-overflow: ellipsis; } ul.tree li { list-style: none; padding: 0px; padding-left: 20px; margin: 0px; white-space: nowrap; } ul.tree a { color: #111; text-decoration: none; display: block; padding: 0px 2px; background-color: gold; //so you can see what's happening } ul.tree .delete { background-color: lightgreen; //so you can see what's happening margin: 0 0 0 5px; display: inline; float: right; } ul.tree a:hover { background-color: lightblue; //so you can see what's happening } .tree li.directory { background: url(/images/directory.png) left top no-repeat; } .tree li.file { background: url(/images/file.png) left top no-repeat; } </code></pre> <p><a href="http://jsfiddle.net/Arwxh/" rel="nofollow"><strong>Original Fiddle</strong></a> | <a href="http://jsfiddle.net/Arwxh/5/" rel="nofollow"><strong>Fiddle with long links</strong></a></p> |
23,938,297 | 0 | capistrano - git ls-remote -h doesn't have the git url <p>I'm new to using Capistrano. I set it up correctly, but when I run cap staging deploy I get this -</p> <pre><code>DEBUG [b678d5eb] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/myproj/git-ssh.sh /usr/bin/env git ls-remote -h ) DEBUG [b678d5eb] usage: git ls-remote [--heads] [--tags] [-u <exec> | --upload-pack <exec>] <repository> <refs>... DEBUG [b678d5eb] Finished in 0.325 seconds with exit status 129 (failed). </code></pre> <p>I think the git clone url should follow after the -h, but I'm not sure.</p> <p>I'm using Capistrano 3.2.1. Here's my deploy.rb -</p> <pre><code>lock '3.2.1' set :application, 'myproj' set :repository, 'https://[email protected]/scm/~vrao/myproj.git' set :scm_passphrase, 'blah' </code></pre> <p>Any help would be great.</p> |
11,386,052 | 0 | How to set a variable value and start running from that in Netbeans? <p>I run a program step by step with monitoring variable's value by watch in <code>Netbeans</code>. How can I start the running of the program from a special value for a variable.</p> <p>For example i have this simple code just for testing: For saving time i want to see the changes of the program after the value of i reaches 25(i=25).</p> <p>Using Run Debug>Run to cursor or f4 to go to this line in program.then the program starts from i=0 , but i don,t need to see the changes before i=25.</p> <pre><code>public class DebugCondition { private static void TestMethod() { for(int i=0; i<= 29 ; i++) 15. System.out.print("i"); } public static void main(String[] args) { 18. TestMethod(); } } </code></pre> <p>What I do: 1. click on line 15.</p> <ol start="2"> <li><p>define conditional breakpoint for that line by i>=25.</p></li> <li><p>click on line 18 , then press F4.</p></li> <li><p>Press F7 to go to method, then press F8 to debug body of method.</p></li> <li><p>Result in watch: at first I starts from 0 . <img src="https://i.stack.imgur.com/PI7Sl.png" alt=""></p></li> </ol> <p>What is wrong?</p> |
3,765,952 | 0 | ipad - keyboard inside popover? <p>Is it possible to have the keyboard show inside a UIPopOver instead of filling the screen width?</p> <p>something like the image...</p> <p><img src="https://i.stack.imgur.com/QOt97.png" alt="alt text"></p> |
13,015,714 | 0 | <p>Solution: It seems that the Opacity was the guilty one, instead of making it solid, I have set the opacity to .99 and works without any issues.</p> |
38,657,702 | 0 | <p>Please try the following </p> <pre><code>... if (typeof(conPeek(a, i)) == Types::Container) { info("It's a container"); } ... </code></pre> |
10,465,242 | 0 | ASP.Net/Ruby/PHP MVC Website, jQuery Mobile and Phonegap <p>I have an ASP.Net MVC3 application (it doesn't matter if it is ASP.NET MVC, PHP or RAILS coz in the end it is serving out plaing HTML) which is using jquery mobile and works great in all mobile browsers. The next step for me is to create a native ios app using Phonegap. </p> <p>My guess is all I have to do is in the html page which I put in Phonegap, I will hook into page load event and dynamically load the contents of my MVC view from a remote server.</p> <p>But I am looking for some examples if anyone else has done something similar.</p> <p>-Thanks in advance Nick</p> <p><strong>UPDATE:</strong> I was able to accomplish this by writing the following index.html page. Hope it helps someone else. </p> <p><strong>STILL ISSUES THOUGH</strong> : But having done this...as you may notice I am requesting my ASP.NET MVC page via <a href="http://IP:8081">http://IP:8081</a> URL. This works fine and it loads my page too...but it is not jquery mobile formatted. So, if someone can help me out here, it will be great. </p> <p><strong>EXPLANATION :</strong> Since, the <code>ajax.responseText</code> contains the entire HTML starting from the <code><!DOCTYPE html></code> tag... I think it is pretty obvious that I end up inserting an entire HTML page inside my <code><div data-role="page" id="home"></code> tag which is obviously wrong but I don't have a solution for it yet :(</p> <pre><code><!DOCTYPE html> <html> <head> <title>PhoneGap Ajax Sample</title> <meta name="viewport" content="width=device-width,initial-scale=1, target-densityDpi=device-dpi"/> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script> <script type="text/javascript" src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script> <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> <script type="text/javascript"> function onDeviceReady() { var ajax = new XMLHttpRequest(); ajax.open("GET", "http://192.168.2.30:8081/", true); ajax.send(); ajax.onreadystatechange = function () { alert(ajax.status); if (ajax.readyState == 4 && (ajax.status == 200 || ajax.status == 0)) { document.getElementById('home').innerHTML = ajax.responseText; } } } $(document).bind("mobileinit", function () { alert('mobileinit'); // Make your jQuery Mobile framework configuration changes here! $.support.cors = true; $.mobile.allowCrossDomainPages = true; }); document.addEventListener("deviceready", onDeviceReady, false); </script> </head> <body> <div data-role="page" id="home"> </div> <div data-role="page" id="search"> </div> <div data-role="page" id="recent"> </div> </body> </html> </code></pre> |
20,042,416 | 0 | <p>If you can find out the first and last values of the labels and store them in variables before itself, then you can do some thing like this <a href="http://jsfiddle.net/E7GBd/" rel="nofollow">http://jsfiddle.net/E7GBd/</a> using </p> <pre><code>formatter: function(){} </code></pre> <p>Hope this will help you.</p> |
1,318,627 | 0 | <p>Looping with String.contains() is the way unless you want to move in some heavy artillery like <a href="http://lucene.apache.org/java/docs/" rel="nofollow noreferrer">Lucene</a>.</p> |
29,423,834 | 0 | How to apply JSON data to an EmberJS Model Attribute <p>I'm very new to JS and I'm retrying EmberJS due to the impending 2.0 but especially because of EMBER CLI which I really like the structure.</p> <p>Anyways, I'm building a basic app and what I'm currently looking to do is make a JSON call to reddit to grab the subscriber number and apply that number to a models subscriber number attribute. I'll also be cycling through an array of models too.</p> <p>So for my instance, I've got models of lets say sports teams. Each team as a subreddit and when someone clicks the league they want, I'll be displaying all of the teams in that league.</p> <p>I've got the the JSON working from a pure JS aspect, and I've got the Ember app working w/o any JSON. So I'm just trying to figure out how to connect the two while also realizing I will probably need to do some tear down to properly connect the two.</p> <p>So my question is, how do I go about selecting a single piece of data from Reddit API to a single model attribute?</p> <p>Here is the JS I'm using currently to pull the subscriber number.</p> <pre><code>$.each( teamList, function( key, val ) { $.getJSON( "http://api.reddit.com/r/"+val+"/about", function foo(data) { $("#team").append(val + " : "); $("#team").append(data.data.subscribers + '<br>'); } ); }); </code></pre> <p>My current ember model setup is normal, but I am using fixtures since all data is static other than this model attribute.</p> |
9,774,106 | 0 | <p>I would expect them to compile to identical bytecode.</p> |
13,476,260 | 0 | How to transform {{{...}}} to markdown code blocks with sed or vim? <p>How can I transform comments like</p> <pre><code>{{{ abc def }}} </code></pre> <p>to markdown comments like</p> <pre><code> abc def </code></pre> <p>(4 spaces at the start of each line) in vim or sed?</p> <p>I tried the following but I didn't get the spaces after the first line:</p> <pre><code>:%s/{{{\n\(\_.*\)\n}}}/ \1/ </code></pre> |
10,878,568 | 0 | <p>According to your error log,</p> <p>TextView resource not found "android.content.res.Resources$NotFoundException". for solving it please check fallowing, 1-: Have you mention id for that textview in xml file. 2-: May be possible same id for more then one resource.</p> <p>I hope its help full to you. </p> |
31,160,772 | 0 | how to create vertical scroll effect for slider using js ,html,css <p><a href="http://www.squarespace.com/" rel="nofollow">http://www.squarespace.com/</a> i want to create similar sliding effect for my website could someone suggest how to create such kind of effect I tried using fullpage.js but it doesnot give the same effect is there a plugin or js which could provide such kind of effect</p> |
28,026,010 | 0 | How to run the script both 'on load' and 'on resize' (on a particular window width!) in jQuery? <p>In my current website project I've integrated <a href="https://github.com/alvarotrigo/fullPage.js" rel="nofollow">Alvaro Trigo's FullPage plugin</a> but since it had a very uncommon behaviour on mobile devices (also due to my project's design requirements), I've decided to switch it off when the viewport width is below 768px. For this purpose I just add a simple if-statement to the script:</p> <pre><code>$(document).ready(function(){ if ($(window).width() > 768 ) { $('#fullpage').fullpage({ // code... code... code... }); } }); </code></pre> <p>The problem is that it only takes effect after refreshing the page; so when I go below 768px and reload the page the plugin is switched off, but when I then resize the browser above the mentioned breakpoint, it's still off (and vice versa). I think I should add some lines of code dealing with resize, but unfortunately my current knowledge of JS/jQ doesn't let me do that. Thanks in advance for your time.</p> |
3,322,826 | 0 | <p>The answer would be yes, assuming you consider this a good example of what you want to do:</p> <p><a href="http://pyjs.org/examples/Space.html" rel="nofollow noreferrer">http://pyjs.org/examples/Space.html</a></p> <p>This browser-based version of Asteroids was created using Pyjamas, which enables you to write the code in python in one place, and have it run either on the browser, or on the desktop:</p> <p><a href="http://pyjs.org/" rel="nofollow noreferrer">http://pyjs.org/</a></p> <p>Having recently found Pyjamas, and also preferring to consolidate my code in one language (Python!) and location (instead of having some code server-side, and some browser/client-side, in different languages), it's definitely an exciting technology. Its authors have ported the Google Web Toolkit to Python, a really impressive feat, retaining the expressive power of Python (something like 80,000 lines of Java was shrunk to 8,000 lines of Python). More Pythonistas should know about it. :)</p> |
10,943,872 | 0 | <p>You should probably adapt your server side code to ignore the null values and return only the fields that are set (thus avoiding unnecessary bandwidth usage).<br> In your clientside code I suggest you have a set of defaults for your template and extend them received JSON with the defaults.<br> I'd you're using jquery, the code would look like this : </p> <pre><code>var defaults ={someDay:"somePlace"}; var object = $.extend({},defaults,theJson); </code></pre> <p><strong>update</strong><br> and in order to "clean up" the object in php, you can do something like : </p> <pre><code>foreach($obj as $k => $v) if($v == null) unset($obj[$k]); </code></pre> |
35,793,271 | 0 | <p>Pipe Get-ChildItem to select-object :</p> <pre><code>$source=Get-ChildItem "$source_path\\CUST_MEA_*.csv" | select -Last 1 </code></pre> |
10,476,158 | 0 | <pre><code>if (preg_match('/\b\d{4}-\d{2}-\d{2}\b/' $str)) { // ... } </code></pre> <p>If the word boundary (<code>\b</code>) doesn't do the trick, you could try <a href="http://www.regular-expressions.info/lookaround.html" rel="nofollow">negative lookbehind and lookaheads</a>:</p> <pre><code>if (preg_match('/(?<!\d)\d{4}-\d{2}-\d{2}(?!\d)/' $str)) { // ... } </code></pre> <p>As an additional validation, you could use <a href="http://php.net/manual/en/function.checkdate.php" rel="nofollow"><code>checkdate()</code></a> to weed out invalid dates such as <code>9999-02-31</code> as mentioned in <a href="http://stackoverflow.com/a/10476175/166339">this answer</a>.</p> |
10,634,537 | 0 | V4l2 : difference between : Enque, Deque and Queue(ing) of the buffer? <p>I am a noob in <strong>v4l2</strong> and tryign to find out the difference bweeten the various ioctl calls made during the camera image capture. I am following this <a href="http://linuxtv.org/downloads/presentations/summit_jun_2010/20100206-fosdem.pdf" rel="nofollow">pdf</a> from the linuxtv org site I wanted to know the difference between the following : </p> <p><strong>Query,Enque, Deque and Queue(ing)</strong> of the buffer.Is there is a particular sequence in fetching the raw data from the camera .Does the sequence varies in case of streaming and capture mode?</p> <p>Can any one plz explain. Rgds, Rp</p> |
26,593,446 | 0 | Write the plugin when Selcting the lookup flied and according to filed selection Show/Hide Address filed in form.....? <p>We Have Contact Entities in contact Entitie one lookup filed company Name in that lookup having two values 1.Account and 2.Contact . When we are selecting contact show the address filed when we select account hide the address filed we needs to write the plugin to Execute that works. Kindly any one help me on the same.</p> <p>Thanks!!</p> <p>Rajesh Singh </p> |
31,593,196 | 0 | <p>Try this,</p> <pre><code>session_start(); if(isset($_POST['viewrecord'])){ $sup_code = $_POST['vhidden']; } $_SESSION["sup_code"] = $sup_code; </code></pre> <p>SQL Query</p> <pre><code>$sql = "SELECT sup_code, firstname, lastname, email, telephone FROM dbo.table WHERE sup_code = '".$_SESSION["sup_code"]."'"; </code></pre> |
10,849,567 | 0 | Upgrade setup with inno setup <p>I have installed the setup which has build from inno setup advanced installer, and installed the patch with fixes and replaced the old assemblies.</p> <p>Now we upgrade the setup, during installation, the old version has uninstalled and installing new version but the two assemblies has missed which has replaced in patch setup. But if we uninstall first setup manually and then install with upgraded setup it works fine.</p> <p>Can you please help to upgrade the all files.</p> <p>Thanks, Kannan</p> |
21,176,064 | 0 | <p>You can use <code>Regex</code> when you search a string in MongoDB:</p> <pre><code>Query.Matches("story","<Regex for: moon or cow or Neil>"); </code></pre> <p>Look <a href="http://stackoverflow.com/questions/5421952/how-to-match-multiple-words-in-regex">here</a> to see how to write a regex that matches multiple words. It's basically this:</p> <pre><code>^(?=.*\bmoon\b)(?=.*\bcow\b)(?=.*\bNeil\b) </code></pre> <p>In conclusion:</p> <pre><code>collection.Find(Query.Matches( "story", "^(?=.*\bmoon\b)(?=.*\bcow\b)(?=.*\bNeil\b)")) .SetSortOrder(SortBy.Descending("Submitted")).Skip(skip).Take(limit); </code></pre> |
35,457,343 | 0 | How to add year display script in $('body').append Script? <p>Javas experts, </p> <p>i have this script:</p> <pre><code><script type='text/javascript'> //<![CDATA[ $(document).ready(function() { var credits= $('body').append('<div id="wrap"><div id="wrapp-inner"><div id="wrapleft"></div><div id="wrapright">Designed Templatezy</div></div></div>'); //]]> </script> </code></pre> <p>Now i want to add year script <code><script type='text/javascript'>document.write(new Date().getFullYear());</script></code> to that <code><div id="wrapleft"></code> div:</p> <p><strong>see example below:</strong> </p> <pre><code> <script type='text/javascript'> //<![CDATA[ $(document).ready(function() { var credits= $('body').append('<div id="wrap"><div id="wrapp-inner"><div id="wrapleft"> document.write(new Date().getFullYear());</div><div id="wrapright">Designed Templatezy</div></div></div>'); //]]> </script> </code></pre> <p>I add my year script as the above but it does not worked, i am not well expert in java or jquery, so please anyone can add this year script same to that id in append body. thanks and hope to see your reply.</p> |
7,559,073 | 0 | android - Cursor returning wrong values <p>I'm querying some products in SQLite database, but same base in 2 differents android's versions return differents values.</p> <p>Select result in database.db3 using SQLite Expert:</p> <p><img src="https://i.stack.imgur.com/RHvaU.png" alt="result"></p> <p>I create this code after select, to test:</p> <pre><code> if(cursor.moveToFirst()){ while(!cursor.isAfterLast()){ log("CDPROD:" + cursor.getString(cursor.getColumnIndex("CDPROD"))); cursor.moveToNext(); } } </code></pre> <p>Log Result in android 2.2:</p> <pre><code>09-26 14:30:08.947: INFO/LOGG(20497): CDPROD:000000000000211934 09-26 14:30:08.967: INFO/LOGG(20497): CDPROD:000000000000211944 09-26 14:30:08.967: INFO/LOGG(20497): CDPROD:000000000000212020 09-26 14:30:08.967: INFO/LOGG(20497): CDPROD:000000000000212124 09-26 14:30:08.967: INFO/LOGG(20497): CDPROD:000000000000214280 09-26 14:30:08.967: INFO/LOGG(20497): CDPROD:000000000000212886 </code></pre> <p>Log Result in android 2.1:</p> <pre><code>09-26 14:18:16.772: INFO/LOGG(1039): CDPROD:211934 09-26 14:18:16.772: INFO/LOGG(1039): CDPROD:211944 09-26 14:18:16.772: INFO/LOGG(1039): CDPROD:212020 09-26 14:18:16.772: INFO/LOGG(1039): CDPROD:212124 09-26 14:18:16.772: INFO/LOGG(1039): CDPROD:214280 09-26 14:18:16.772: INFO/LOGG(1039): CDPROD:212886 </code></pre> <p>This is a bug in Android??</p> <p>Ty</p> |
13,480,810 | 0 | <p>You can't access the Downloads folder directly as - contrary to the Documents library - there's no special capability for this folder. </p> <p>You'll have to use a FileOpenPicker to let the user select a folder where they want to have their downloads stored. Then you can store the access token and use it for subsequent files. For more information on access tokens and the FileOpenPicker, see this article: <a href="http://msdn.microsoft.com/en-us/library/windows/apps/jj655411.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windows/apps/jj655411.aspx</a></p> <p>Depending on your use case you may want to download the files into your applications localstorage folder and let the user copy or open them individually from within your app.</p> |
3,867,644 | 0 | Grouped UITableView & edit-mode: strange behaviour <p>recently I implemented an grouped UITableView with editing, but the problem is: if the UITableView is in edit-mode, the content of the cells is moved to the right and this looks really unattractive.</p> <p>Thanks in advance.</p> <p>Regards, Sascha</p> |
22,882,892 | 0 | Website directory structure different from eclipse <p>I am coding a website using java servlets and am using eclipse and tomcat. When I test it using localhost, it works fine. But when I am deploying it on my actual website, the directory structure is messed up and the files are not called properly. </p> <p>My eclipse directory structure on localhost is </p> <p>Project Name .src/packageName/java files .WebContent/HTML files.</p> <p>When I make a call from the html files, I use the relative location and tomcat automatically knows to look in the src/packageName folder. For example, from the /WebContent/login.html page makes a onClick call as follows, . This will automatically trigger the java file in /src/packageName/welcome</p> <p>When I am deploying it in my actual website, the WebContent/login.html is throwing an error WebContent/welcome file is not found. How do I tell my website to search in /src/packageName folder?</p> |
29,800,284 | 0 | How do i setup magnific-popup <p>I am Really new to this so please keep that in mind before judging me.</p> <p>I am having problems getting the script to work for me. </p> <p>What i did was following:</p> <ol> <li><p>I built my js with the builder on the Page <a href="http://dimsemenov.com/plugins/magnific-popup/#mfp-build-tool" rel="nofollow">Magnific - Popup</a></p></li> <li><p>I downloaded the CSS File.</p></li> <li><p>I included the scriptfile just before the /body tag</p></li> <li><p>I tried to open popup with:<br> <code><a class="popup-iframe mfp-iframe" href="index.php/9-uncategorised/230-contact">contact</a></code></p></li> </ol> <p>I dont know what i am missing here :( i tried different classes, dont know which they were.</p> <p>Any help would be really appreciated</p> <p><strong>EDIT:</strong> nvm i fixed it for me with downloading a other plugin (NoNumbers Modals) Now everything works for me. </p> |
34,606,214 | 0 | <p>Is your routes inside the <code>web</code> middleware ? Laravel 5.2 has a new feature called middleware groups. In order to use session, your route should be inside the <code>web</code> middleware. If you check your <code>Kernel.php</code>, you will get a clear idea about the middlewares inside the <code>web</code> middleware group</p> <pre><code> 'web' => [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, ], </code></pre> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.