pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
4,453,806
0
<blockquote> <p>The HTML search form will contain text fields, many select dropdowns and some checkboxes. Can anyone offer any advice, best practice, design patterns or resources to assist with this kind of problem.</p> </blockquote> <p>I would suggest that Google exemplifies the best UI for search. Don't give me a lot of fiddly fields, just one text field so I can type "Shirley Jones UAF"</p>
8,914,898
0
<p>I would advise learning about Unit Testing. Read <a href="http://msdn.microsoft.com/en-us/magazine/cc163665.aspx" rel="nofollow">this</a> article on MSDN and search on Google for how to write unit tests. They are a great way to test individual units of code and so should be ideal for your situation.</p> <p>I would also advise separating out UI-related code, such as calls to <code>MessageBox</code>, other UI elements and <code>Console</code>; from the code you wish to test. This will make it much easier to test the logic and execution of your code.</p>
28,559,264
0
<p>This looks like very close to <a href="http://stackoverflow.com/questions/28420066/java-velocity-loop-add-div-around-every-3-items/28426218#28426218">question 28420066</a>.</p> <p>In Velocity 1.7+, use $foreach.index (0-based), $foreach.count (1-based), $foreach.first and $foreach.last (<a href="http://velocity.apache.org/engine/releases/velocity-1.7/user-guide.html#Loops" rel="nofollow">check the doc</a>).</p> <pre><code>&lt;ul&gt; #foreach( $product in $allProducts ) #if( $foreach.index %4 == 0 ) #if( !$foreach.first ) &lt;/ul&gt; #end &lt;ul&gt; #end $product #if( $foreach.last ) &lt;/ul&gt; #end #end &lt;/ul&gt; </code></pre>
32,624,714
1
Beautiful soup queries <p>I'm struggling to have queries in BS with multiple conditions of the type AND or OR. From what I read I have to use lambda. As an example, I'm looking for tags that match either "span", {"class":"green"} or tag.name == "h1" on the page <a href="http://www.pythonscraping.com/pages/warandpeace.html" rel="nofollow">http://www.pythonscraping.com/pages/warandpeace.html</a></p> <p>I manage to get them separately using the lambda syntax:<br> <code>bsObj.findAll(lambda tag: tag.name == "h1")</code> will return h1<br> <code>bsObj.findAll(lambda tag: tag.name == "span", {"class":"green"})</code> wil return span green </p> <p>Or I can get all "span" tags and "h1" :<br> <code>bsObj.findAll(lambda tag: tag.name == "span" or tag.name == "h1")</code> return span green and red as well as h1</p> <p>But I don't manage to get the span of <strong>class green or h1</strong>, as the following code does not provide the right result :<br> <code>bsObj.findAll(lambda tag: tag.name == "span", {"class":"green"} or tag.name == "h1")</code></p> <p>Can please someone explain me the right way to do it in <strong>one</strong> query ? Goal here is not only to get the result but rather understand the syntax. Thanks !</p> <p>(using Python 3.4)<br> PS : I think this issue is different from the the one here: <a href="http://stackoverflow.com/questions/18725760/beautifulsoup-findall-given-multiple-classes">BeautifulSoup findAll() given multiple classes?</a> as well as a variation of <a href="http://stackoverflow.com/questions/20648660/python-beautifulsoup-give-multiple-tags-to-findall?rq=1">Python BeautifulSoup give multiple tags to findAll</a> (as we want a specific attribute)</p>
2,834,304
0
<p>Actually, no one cares. With reflector I finally found the place in the framework, where my <code>false</code> is being swallowed: <code>DomainService.AuthorizeChangeSet</code> is called by <code>DomainService.Submit</code>, which is still returning the outcome of <code>DomainService.AuthorizeChangeSet</code>. But see what the <code>ChangeSetProcessor.Process</code> is doing with it:</p> <pre><code>public static IEnumerable&lt;ChangeSetEntry&gt; Process(DomainService domainService, IEnumerable&lt;ChangeSetEntry&gt; changeSetEntries) { ChangeSet changeSet = CreateChangeSet(changeSetEntries); domainService.Submit(changeSet); return GetSubmitResults(changeSet); } </code></pre> <p>... nothing.</p>
25,646,223
0
I'm trying to perform two string comparisons with an "if" and an "OR" <p>I'm new to bash and I am trying to do two string comparisons with an or statement. Can anyone give me any idea where I have gone wrong?</p> <pre><code> echo $DEVICETYPE FILEHEADER=ANDROID if [[ "$DEVICETYPE" == "iPad" ] || ["$DEVICETYPE" == "iPhone" ]]; then $FILEHEADER = IOS fi echo $FILEHEADER </code></pre> <blockquote> <blockquote> <blockquote> <p>iPad</p> <p>ANDROID</p> </blockquote> </blockquote> </blockquote>
36,258,858
0
wso2 am gateway forwarding of multipart/form-data post requests <p>I am using a demo API which receives a file and note as multipart/form-data input and displays the content of the file and the note. Here is a sample HTML which runs the API correctly:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;FORM action="http://cgi-lib.berkeley.edu/ex/fup.cgi" method="post"&gt; &lt;P&gt;Choose file: &lt;INPUT type="file" name="upfile"&gt; &lt;p&gt;Note: &lt;INPUT type="text" name="note"&gt; &lt;p&gt;&lt;INPUT type="submit" value="Send"&gt; &lt;/FORM&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Now I'm trying to created a managed API in the WSO2 APIM publisher. Below are the parameters I filled in:</p> <p><a href="https://i.stack.imgur.com/vsUo8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vsUo8.png" alt="enter image description here"></a></p> <p>I'm replacing the action of the HTML to go through the API I added:</p> <pre><code>&lt;FORM action="http://ec2-52-48-93-41.eu-west-1.compute.amazonaws.com:8280/test" method="post"&gt; </code></pre> <p>But now when I run the HTML I get the following error from the API:</p> <pre><code>cgi-lib.pl: Unknown Content-type: application/x-www-form-urlencoded; charset=UTF-8 </code></pre> <p>Seems like the WSO2 gateway forwarded the request as application/x-www-form-urlencoded rather than as mulipart/form-data.</p> <p>Based on the following discussion <a href="http://stackoverflow.com/questions/29025525/multipart-form-data-file-upload-using-wso2-api-manger">multipart form data file upload using WSO2 API manger ?</a> I tried to comment out</p> <pre><code> &lt;messageFormatter contentType="multipart/form-data" class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/&gt; &lt;messageBuilder contentType="multipart/form-data" class="org.apache.axis2.builder.MultipartFormDataBuilder"/&gt; </code></pre> <p>And replace them with</p> <pre><code> &lt;messageFormatter contentType="multipart/form-data" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/&gt; &lt;messageBuilder contentType="multipart/form-data" class="org.wso2.carbon.relay.BinaryRelayBuilder"/&gt; </code></pre> <p>Then restarted the server, but it did not cause any impact.</p> <p>Any ideas will be appreciated.</p> <p>Some log messages that I collected. The target API is different, but it is also a multipart/form-data API which dumps whatever it receives. </p> <p>The incoming request does have content-type multipart/form-data, with content-length of 292 </p> <pre><code>DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &gt;&gt; POST /test/1.0.0 HTTP/1.1 {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &gt;&gt; Host: ec2-52-48-93-41.eu-west-1.compute.amazonaws.com:8280 {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &gt;&gt; Connection: keep-alive {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &gt;&gt; Content-Length: 292 {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &gt;&gt; Cache-Control: max-age=0 {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &gt;&gt; Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &gt;&gt; Origin: null {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &gt;&gt; Upgrade-Insecure-Requests: 1 {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &gt;&gt; User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36 {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &gt;&gt; Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryqwBdAwOnlDYeHNNR {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &gt;&gt; Accept-Encoding: gzip, deflate {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &gt;&gt; Accept-Language: en-US,en;q=0.8,he;q=0.6 {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &gt;&gt; Cookie: region3_registry_menu=visible; region1_manage_menu=visible; region1_identity_menu=visible; menuPanel=visible; menuPanelType=main; csrftoken=n1g69f3slt1d90qvtaa28rtm1b {org.apache.synapse.transport.http.headers} </code></pre> <p>The outgoing request does not have content-type:</p> <pre><code>DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 &gt;&gt; POST /sample2/api/company/upload HTTP/1.1 {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 &gt;&gt; Cookie: region3_registry_menu=visible; region1_manage_menu=visible; region1_identity_menu=visible; menuPanel=visible; menuPanelType=main; csrftoken=n1g69f3slt1d90qvtaa28rtm1b {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 &gt;&gt; Origin: null {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 &gt;&gt; Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 &gt;&gt; Cache-Control: max-age=0 {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 &gt;&gt; Upgrade-Insecure-Requests: 1 {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 &gt;&gt; Accept-Encoding: gzip, deflate {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 &gt;&gt; Accept-Language: en-US,en;q=0.8,he;q=0.6 {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 &gt;&gt; Transfer-Encoding: chunked {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 &gt;&gt; Host: localhost:8080 {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 &gt;&gt; Connection: Keep-Alive {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 &gt;&gt; User-Agent: Synapse-PT-HttpComponents-NIO {org.apache.synapse.transport.http.headers} </code></pre> <p>Naturally, the incoming response has HTTP 415, unsupported media:</p> <pre><code>DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 &lt;&lt; HTTP/1.1 415 Unsupported Media Type {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 &lt;&lt; Server: Apache-Coyote/1.1 {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 &lt;&lt; Content-Length: 0 {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-outgoing-1 &lt;&lt; Date: Mon, 28 Mar 2016 13:53:05 GMT {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &lt;&lt; HTTP/1.1 415 Unsupported Media Type {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &lt;&lt; Access-Control-Allow-Origin: * {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &lt;&lt; Access-Control-Allow-Methods: POST {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &lt;&lt; Access-Control-Allow-Headers: authorization,Access-Control-Allow-Origin,Content-Type {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &lt;&lt; Date: Mon, 28 Mar 2016 13:53:05 GMT {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &lt;&lt; Transfer-Encoding: chunked {org.apache.synapse.transport.http.headers} DEBUG {org.apache.synapse.transport.http.headers} - http-incoming-1 &lt;&lt; Connection: keep-alive {org.apache.synapse.transport.http.headers} </code></pre> <p>Also worth loading is the synapse of the API:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;api xmlns="http://ws.apache.org/ns/synapse" name="admin--test" context="/test/1.0.0" version="1.0.0" version-type="context"&gt; &lt;resource methods="POST" url-mapping="/*" faultSequence="fault"&gt; &lt;inSequence&gt; &lt;filter source="$ctx:AM_KEY_TYPE" regex="PRODUCTION"&gt; &lt;then&gt; &lt;property name="api.ut.backendRequestTime" expression="get-property('SYSTEM_TIME')"/&gt; &lt;send&gt; &lt;endpoint name="admin--test_APIproductionEndpoint_0"&gt; &lt;http uri-template="http://localhost:8080/sample2/api/company/upload"/&gt; &lt;/endpoint&gt; &lt;/send&gt; &lt;/then&gt; &lt;else&gt; &lt;sequence key="_sandbox_key_error_"/&gt; &lt;/else&gt; &lt;/filter&gt; &lt;/inSequence&gt; &lt;outSequence&gt; &lt;class name="org.wso2.carbon.apimgt.usage.publisher.APIMgtResponseHandler"/&gt; &lt;send/&gt; &lt;/outSequence&gt; &lt;/resource&gt; &lt;handlers&gt; &lt;handler class="org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler"&gt; &lt;property name="apiImplementationType" value="ENDPOINT"/&gt; &lt;/handler&gt; &lt;handler class="org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler"/&gt; &lt;handler class="org.wso2.carbon.apimgt.gateway.handlers.throttling.APIThrottleHandler"&gt; &lt;property name="policyKey" value="gov:/apimgt/applicationdata/tiers.xml"/&gt; &lt;property name="policyKeyApplication" value="gov:/apimgt/applicationdata/app-tiers.xml"/&gt; &lt;property name="policyKey" value="gov:/apimgt/applicationdata/tiers.xml"/&gt; &lt;property name="policyKeyApplication" value="gov:/apimgt/applicationdata/app-tiers.xml"/&gt; &lt;property name="id" value="A"/&gt; &lt;property name="policyKeyResource" value="gov:/apimgt/applicationdata/res-tiers.xml"/&gt; &lt;/handler&gt; &lt;handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageHandler"/&gt; &lt;handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtGoogleAnalyticsTrackingHandler"&gt; &lt;property name="configKey" value="gov:/apimgt/statistics/ga-config.xml"/&gt; &lt;/handler&gt; &lt;handler class="org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler"/&gt; &lt;/handlers&gt; &lt;/api&gt; </code></pre>
4,007,724
0
auto partial page refresh in asp.net without UpdatePanel <p>I want to make auto partial page refresh in asp.net. There is UpdatePanel but it sends too much data. So I've found that I can make a webservice and call it by the JavaScript code. But I don't know how to call webservice automatic. There are many examples showing how to call webservice by the button click event:</p> <p><a href="http://www.asp.net/ajax/videos/how-do-i-make-client-side-network-callbacks-with-aspnet-ajax" rel="nofollow">http://www.asp.net/ajax/videos/how-do-i-make-client-side-network-callbacks-with-aspnet-ajax</a></p> <p>How to do this by the interval? Am I going in good direction?</p>
12,622,754
0
Using OAuth 2.0 for Devices - Google API - Google Drive <p>I took a look in some docs at developers.google and some questions here in stackoverflow and I really would like to found an objective answer about use the Google OAuth Server to authenticate an application and grant access to download docs into a Google Drive account with NO BROWSER interaction.</p> <p>As far as I could look, docs like "Using OAuth 2.0 for Server to Server Applications", "Using OAuth 2.0 for Devices", answers here, I couldn't found an article saying "Is possible to authorize an application to get files from a common Google Drive account in Devices with no browser...".</p> <p>Anyone have tried and had success in this jorney?</p>
18,578,783
0
<pre><code>str.str[0].toUpperCase(); </code></pre> <p>should just be </p> <pre><code>str[0].toUpperCase(); </code></pre> <p>If that isn't the case, you should try <code>console.log(str)</code> and find out what exactly <code>str</code> is but I believe this is your problem.</p>
2,835,261
0
Excel VBA macro workbook startup - security warning - automatic update of links disabled <p>I've created an add-in and installed it, but now when I open Excel I get an error pop-up telling me that the add-in file is a security risk and that automatic updating of links is disabled. I've looked it up and it refers to the Windows DDE protocol, but what does that have to do with this add-in? Does anyone know what's happening behind the scenes here?</p> <p>Thanks</p>
4,840,021
0
<p>I had a very similar problem myself: I was developing a C program (using the MinGW gcc compiler) which used the curl library to do http GET operations. I tested it on Windows XP (32-bit) and Windows 7 (64-bit). My program was working in Windows XP, but in Windows 7 it crashed with the same 0xc000007b error message as the OP got.</p> <p>I used Dependency Walker on a down-stripped program (with only one call to the curl library:<code>curl_easy_init()</code>). I essentially got the same log as yours, with OPENLDAP.DLL as the last successfully loaded module before the crash.</p> <p>However, it seems my program crashed upon loading LIBSASL.DLL (which was the next module loaded according to the log from Dependency Walker run on Windows XP).</p> <p>When looking again in the log from Dependency Walker on Windows 7, LIBSASL.DLL indeed shows up a x64 module. I managed to get my program to run by copying a 32-bit version of the DLL file from another application on my harddisk to my program's directory. </p> <p>Hopefully this will work for other people having similar problems (also for the OP if the problem still wasn't resolved after these years). If copying a 32-bit version of LIBSADL.DLL to your program's directory doesn't help, another module might cause the crash. Run Dependency Walker on both the 32- and 64-bit systems and look up the module name from the log of the successful run.</p>
14,393,716
0
launch command line from java without knowing OS <p>Is there a way to launch the command line from java without knowing OS? For example, the method would open up the terminal shell for a Linux OS and open the command line for Windows. </p> <p>I do know (from looking at previous questions) that i can just check the OS and then open the proper command line, but is there a way to open the command line from a java method that is OS agnostic?</p>
16,375,955
0
<p>It's not possible to do so.....</p>
15,414,905
0
<p>I got this to work by combining both of the answers already provided;</p> <ul> <li>Wrap the <code>&lt;ul&gt;</code> into its own <code>&lt;div id="scroller"&gt;</code></li> <li>Remove the fixed <code>width</code> property from the <code>.simply-scroll .simply-scroll-list li</code> element in the CSS</li> <li>Add <code>padding</code> to this element as required.</li> </ul> <p>Working in Firefox, Chrome and IE.</p>
26,573,644
0
<p>It's in the documentation: <a href="http://msdn.microsoft.com/en-us/library/microsoft.web.services2.soapwebrequest.timeout.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/microsoft.web.services2.soapwebrequest.timeout.aspx</a> .</p> <p>In short, use the SoapWebRequest's Timeout property.</p>
39,671,783
0
<p>When executed for first time hashBucket is empty. So range is empty. So this for loop doesn't do anything. 'for i in range(len(hashBucket)):' I think. Is that right?</p>
40,421,653
0
ElasticSearch: unable to resolve class org.joda.time.Period <p>I'm using this script in order to get the time difference between two fields:</p> <pre><code>new org.joda.time.Period(doc[firstDateField].date, doc[secondDateField].date).getHours(); </code></pre> <p>The problem is ES is telling me that:</p> <pre><code>bbd8b73ce0b0dd070d07e63f11dcdad4fa12121d: 1: unable to resolve class org.joda.time.Period Nov 04 10:27:21 core-01 docker[3876]: @ line 1, column 1. Nov 04 10:27:21 core-01 docker[3876]: new Period(doc[firstDateField].date, doc[secondDateField].date).getHours(); Nov 04 10:27:21 core-01 docker[3876]: ^ </code></pre>
16,019,217
0
<p>I read about this is a book by Knuth and according to that book, the Batcher's parallel merge sort is the fastest algorithm and also the most hardware efficient.</p>
19,621,369
0
Servlet filters as security for web aplication <p>I want to do my own custom registration system like we have on most of web sites:</p> <ol> <li>User put password username e-male and so on </li> <li>After registration process tries to log in with inserted user name and passwords from registration form.</li> </ol> <p>I was considering to do this with spring-security, but I want to do this with servlets because it's essential things to know for each web developer.</p> <p>As my particular view I was thinking to use filters. Would you suggest something for me to read about filters and also how to perform security with servlets and filters?? </p> <p>Thank you with best regards. </p>
27,774,787
0
<p>Follow these simple steps on <a href="https://www.promptcloud.com/how-to-run-ajax-web-crawls/" rel="nofollow">how to run Python/Ajax crawls</a>. <a href="https://www.promptcloud.com/data-hub-blog/web-scraping-interactive-ajax-crawls/" rel="nofollow">How to set interactive crawls using AJax</a></p>
17,432,434
0
How to add view on imageView? <p>I have created a class that extends a view which will work as a drawing slate to draw a text. I want to add that drawing slate in image View. And I have main activity which contains a scrollable list on top and a image view below list. Now I want to add that View(Drawing slate) on image View. So how to implement this? I tried lot, but I am not getting how to do this.Do i need to use any other view instead of image View? Please help as soon as possible. Thanks in advance.</p>
37,211,948
0
Issue in Kohana Query <p>I'm facing an issue in my query.Kindly help me to sort the issue (I’m newbie in Kohana Framework)</p> <pre><code>$posts-&gt;select(array(DB::expr('( SELECT COUNT(id_visit) FROM `oc2_visits` WHERE `oc2_post`.`id_post` = `oc2_visits`.`id_ad` AND `oc2_visits`.controller = "Blog" GROUP BY `oc2_visits`.`id_ad`)'), 'hits')); //we sort all ads with few parameters $posts = $posts-&gt;order_by('created','desc') -&gt;limit($pagination-&gt;items_per_page) -&gt;offset($pagination-&gt;offset) -&gt;limit(Theme::get('num_home_blog_posts', 4))-&gt;cached() -&gt;find_all(); </code></pre> <p>As you can see 'hits' is property set at DB:expr(). In my view I'm trying to access the $posts->hits; property. Then the issue appearing hits property doesn't exists. <a href="https://i.stack.imgur.com/XSVTs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XSVTs.png" alt="enter image description here"></a></p> <p>Image is attached, Please help I'm not expert in kohana framework.</p>
21,155,503
0
<p>Found new way to put job back to same queue with some delay time. We can use direct <strong>release</strong> function of pheanstalk library. e.g. </p> <pre><code> $this-&gt;pheanstalk-&gt;release($job,$priority,$delay); </code></pre> <p>This way, we don't need to find job's actual tube and can save concurrency issues, specially in my case.</p> <p>Thanks for your help !!!</p>
4,820,989
0
How to read a text file from the root folder and display it in div? <p>Hi I have a complicated html page. I want to read a text file and display its content into a div on Page load. I can use javascript if needed. Pl. help.</p>
27,407,152
0
<p>It's been a while since I did this but I just had <code>&lt;cfpop&gt;</code> login to the email account in question, search for emails with a specific subject, gather up the data I wanted from there, like the email address it bounced from, and update the database using an IN clause based on a list of bounced email addresses.</p> <p>Just make sure to delete the messages you've scanned afterwards.</p> <p>However, in CF10+, you can use the secure attribute instead of invoking java for the secure connection.</p> <pre><code>&lt;cfpop server="pop.gmail.com" action="getHeaderOnly" name="popMessages" port="995" maxrows="10" username="[email protected]" password="password" secure="yes|no"&gt; </code></pre> <p>A quick google for how to access gmail with cfpop returned this, useful for connecting with older CFs.</p> <pre><code>&lt;!--- See: http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html Warning: Changing system properties is potentially dangerous and should be done with discretion. ---&gt; &lt;cfset javaSystem = createObject("java", "java.lang.System") /&gt; &lt;cfset javaSystemProps = javaSystem.getProperties() /&gt; &lt;cfset javaSystemProps.setProperty("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory") /&gt; &lt;cfpop server="pop.gmail.com" action="getHeaderOnly" name="popMessages" port="995" maxrows="10" username="[email protected]" password="password"&gt; </code></pre>
17,059,349
0
Java: To what extent should we encapsulate our methods and classes? <p>To what extent should we encapsulate our methods and classes? for example, besides getter and setter, what else non-static methods should be declared as public?</p> <p>And if we declared too many private methods, how can we conduct the unit tests for them?</p> <p>I heard a saying that "if your private method is so complex that it needs a separate unit test, it often means that it deserved its own class", so how can we decide if a method is complex enough to have a separate unit test? (for example, for methods like getter/setter we do not need to test them right)</p>
38,611,385
0
<blockquote> <p>I had the same issue a year ago.</p> </blockquote> <ol> <li>First and foremost, make sure that mod_rewrite module is enabled in your apache server. Don't waste time for other solution.</li> <li>Secondly, that might be because of htaccess rules. Kindly, use this basic line of code for htaccess.</li> </ol> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [QSA,L]</code></pre> </div> </div> </p>
20,011,250
0
<p>a combination of both solutions presented here:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Mime { class Mime { public static string GetMimeType(string fileName) { if (string.IsNullOrEmpty(fileName) || string.IsNullOrWhiteSpace(fileName)) { throw new ArgumentNullException("filename must contain a filename"); } string extension = System.IO.Path.GetExtension(fileName).ToLower(); if (!extension.StartsWith(".")) { extension = "." + extension; } string mime; if (_mappings.TryGetValue(extension, out mime)) return mime; else if (GetWindowsMimeType(extension, out mime)) { _mappings.Add(mime); return mime; } else return "application/octet-stream"; } public static bool GetWindowsMimeType(string ext, out string mime) { mime="application/octet-stream"; Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext); if (regKey != null) { object val=regKey.GetValue("Content Type") ; if (val != null) { string strval = val.ToString(); if(!(string.IsNullOrEmpty(strval)||string.IsNullOrWhiteSpace(strval))) { mime=strval; return true; } } } return false; } private static IDictionary&lt;string, string&gt; _mappings = new Dictionary&lt;string, string&gt;(StringComparer.InvariantCultureIgnoreCase) { #region Big freaking list of mime types // combination of values from Windows 7 Registry and // from C:\Windows\System32\inetsrv\config\applicationHost.config // some added, including .7z and .dat {".323", "text/h323"}, {".3g2", "video/3gpp2"}, {".3gp", "video/3gpp"}, {".3gp2", "video/3gpp2"}, {".3gpp", "video/3gpp"}, {".7z", "application/x-7z-compressed"}, {".aa", "audio/audible"}, {".AAC", "audio/aac"}, {".aaf", "application/octet-stream"}, {".aax", "audio/vnd.audible.aax"}, {".ac3", "audio/ac3"}, {".aca", "application/octet-stream"}, {".accda", "application/msaccess.addin"}, {".accdb", "application/msaccess"}, {".accdc", "application/msaccess.cab"}, {".accde", "application/msaccess"}, {".accdr", "application/msaccess.runtime"}, {".accdt", "application/msaccess"}, {".accdw", "application/msaccess.webapplication"}, {".accft", "application/msaccess.ftemplate"}, {".acx", "application/internet-property-stream"}, {".AddIn", "text/xml"}, {".ade", "application/msaccess"}, {".adobebridge", "application/x-bridge-url"}, {".adp", "application/msaccess"}, {".ADT", "audio/vnd.dlna.adts"}, {".ADTS", "audio/aac"}, {".afm", "application/octet-stream"}, {".ai", "application/postscript"}, {".aif", "audio/x-aiff"}, {".aifc", "audio/aiff"}, {".aiff", "audio/aiff"}, {".air", "application/vnd.adobe.air-application-installer-package+zip"}, {".amc", "application/x-mpeg"}, {".application", "application/x-ms-application"}, {".art", "image/x-jg"}, {".asa", "application/xml"}, {".asax", "application/xml"}, {".ascx", "application/xml"}, {".asd", "application/octet-stream"}, {".asf", "video/x-ms-asf"}, {".ashx", "application/xml"}, {".asi", "application/octet-stream"}, {".asm", "text/plain"}, {".asmx", "application/xml"}, {".aspx", "application/xml"}, {".asr", "video/x-ms-asf"}, {".asx", "video/x-ms-asf"}, {".atom", "application/atom+xml"}, {".au", "audio/basic"}, {".avi", "video/x-msvideo"}, {".axs", "application/olescript"}, {".bas", "text/plain"}, {".bcpio", "application/x-bcpio"}, {".bin", "application/octet-stream"}, {".bmp", "image/bmp"}, {".c", "text/plain"}, {".cab", "application/octet-stream"}, {".caf", "audio/x-caf"}, {".calx", "application/vnd.ms-office.calx"}, {".cat", "application/vnd.ms-pki.seccat"}, {".cc", "text/plain"}, {".cd", "text/plain"}, {".cdda", "audio/aiff"}, {".cdf", "application/x-cdf"}, {".cer", "application/x-x509-ca-cert"}, {".chm", "application/octet-stream"}, {".class", "application/x-java-applet"}, {".clp", "application/x-msclip"}, {".cmx", "image/x-cmx"}, {".cnf", "text/plain"}, {".cod", "image/cis-cod"}, {".config", "application/xml"}, {".contact", "text/x-ms-contact"}, {".coverage", "application/xml"}, {".cpio", "application/x-cpio"}, {".cpp", "text/plain"}, {".crd", "application/x-mscardfile"}, {".crl", "application/pkix-crl"}, {".crt", "application/x-x509-ca-cert"}, {".cs", "text/plain"}, {".csdproj", "text/plain"}, {".csh", "application/x-csh"}, {".csproj", "text/plain"}, {".css", "text/css"}, {".csv", "text/csv"}, {".cur", "application/octet-stream"}, {".cxx", "text/plain"}, {".dat", "application/octet-stream"}, {".datasource", "application/xml"}, {".dbproj", "text/plain"}, {".dcr", "application/x-director"}, {".def", "text/plain"}, {".deploy", "application/octet-stream"}, {".der", "application/x-x509-ca-cert"}, {".dgml", "application/xml"}, {".dib", "image/bmp"}, {".dif", "video/x-dv"}, {".dir", "application/x-director"}, {".disco", "text/xml"}, {".dll", "application/x-msdownload"}, {".dll.config", "text/xml"}, {".dlm", "text/dlm"}, {".doc", "application/msword"}, {".docm", "application/vnd.ms-word.document.macroEnabled.12"}, {".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"}, {".dot", "application/msword"}, {".dotm", "application/vnd.ms-word.template.macroEnabled.12"}, {".dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template"}, {".dsp", "application/octet-stream"}, {".dsw", "text/plain"}, {".dtd", "text/xml"}, {".dtsConfig", "text/xml"}, {".dv", "video/x-dv"}, {".dvi", "application/x-dvi"}, {".dwf", "drawing/x-dwf"}, {".dwp", "application/octet-stream"}, {".dxr", "application/x-director"}, {".eml", "message/rfc822"}, {".emz", "application/octet-stream"}, {".eot", "application/octet-stream"}, {".eps", "application/postscript"}, {".etl", "application/etl"}, {".etx", "text/x-setext"}, {".evy", "application/envoy"}, {".exe", "application/octet-stream"}, {".exe.config", "text/xml"}, {".fdf", "application/vnd.fdf"}, {".fif", "application/fractals"}, {".filters", "Application/xml"}, {".fla", "application/octet-stream"}, {".flr", "x-world/x-vrml"}, {".flv", "video/x-flv"}, {".fsscript", "application/fsharp-script"}, {".fsx", "application/fsharp-script"}, {".generictest", "application/xml"}, {".gif", "image/gif"}, {".group", "text/x-ms-group"}, {".gsm", "audio/x-gsm"}, {".gtar", "application/x-gtar"}, {".gz", "application/x-gzip"}, {".h", "text/plain"}, {".hdf", "application/x-hdf"}, {".hdml", "text/x-hdml"}, {".hhc", "application/x-oleobject"}, {".hhk", "application/octet-stream"}, {".hhp", "application/octet-stream"}, {".hlp", "application/winhlp"}, {".hpp", "text/plain"}, {".hqx", "application/mac-binhex40"}, {".hta", "application/hta"}, {".htc", "text/x-component"}, {".htm", "text/html"}, {".html", "text/html"}, {".htt", "text/webviewhtml"}, {".hxa", "application/xml"}, {".hxc", "application/xml"}, {".hxd", "application/octet-stream"}, {".hxe", "application/xml"}, {".hxf", "application/xml"}, {".hxh", "application/octet-stream"}, {".hxi", "application/octet-stream"}, {".hxk", "application/xml"}, {".hxq", "application/octet-stream"}, {".hxr", "application/octet-stream"}, {".hxs", "application/octet-stream"}, {".hxt", "text/html"}, {".hxv", "application/xml"}, {".hxw", "application/octet-stream"}, {".hxx", "text/plain"}, {".i", "text/plain"}, {".ico", "image/x-icon"}, {".ics", "application/octet-stream"}, {".idl", "text/plain"}, {".ief", "image/ief"}, {".iii", "application/x-iphone"}, {".inc", "text/plain"}, {".inf", "application/octet-stream"}, {".inl", "text/plain"}, {".ins", "application/x-internet-signup"}, {".ipa", "application/x-itunes-ipa"}, {".ipg", "application/x-itunes-ipg"}, {".ipproj", "text/plain"}, {".ipsw", "application/x-itunes-ipsw"}, {".iqy", "text/x-ms-iqy"}, {".isp", "application/x-internet-signup"}, {".ite", "application/x-itunes-ite"}, {".itlp", "application/x-itunes-itlp"}, {".itms", "application/x-itunes-itms"}, {".itpc", "application/x-itunes-itpc"}, {".IVF", "video/x-ivf"}, {".jar", "application/java-archive"}, {".java", "application/octet-stream"}, {".jck", "application/liquidmotion"}, {".jcz", "application/liquidmotion"}, {".jfif", "image/pjpeg"}, {".jnlp", "application/x-java-jnlp-file"}, {".jpb", "application/octet-stream"}, {".jpe", "image/jpeg"}, {".jpeg", "image/jpeg"}, {".jpg", "image/jpeg"}, {".js", "application/x-javascript"}, {".jsx", "text/jscript"}, {".jsxbin", "text/plain"}, {".latex", "application/x-latex"}, {".library-ms", "application/windows-library+xml"}, {".lit", "application/x-ms-reader"}, {".loadtest", "application/xml"}, {".lpk", "application/octet-stream"}, {".lsf", "video/x-la-asf"}, {".lst", "text/plain"}, {".lsx", "video/x-la-asf"}, {".lzh", "application/octet-stream"}, {".m13", "application/x-msmediaview"}, {".m14", "application/x-msmediaview"}, {".m1v", "video/mpeg"}, {".m2t", "video/vnd.dlna.mpeg-tts"}, {".m2ts", "video/vnd.dlna.mpeg-tts"}, {".m2v", "video/mpeg"}, {".m3u", "audio/x-mpegurl"}, {".m3u8", "audio/x-mpegurl"}, {".m4a", "audio/m4a"}, {".m4b", "audio/m4b"}, {".m4p", "audio/m4p"}, {".m4r", "audio/x-m4r"}, {".m4v", "video/x-m4v"}, {".mac", "image/x-macpaint"}, {".mak", "text/plain"}, {".man", "application/x-troff-man"}, {".manifest", "application/x-ms-manifest"}, {".map", "text/plain"}, {".master", "application/xml"}, {".mda", "application/msaccess"}, {".mdb", "application/x-msaccess"}, {".mde", "application/msaccess"}, {".mdp", "application/octet-stream"}, {".me", "application/x-troff-me"}, {".mfp", "application/x-shockwave-flash"}, {".mht", "message/rfc822"}, {".mhtml", "message/rfc822"}, {".mid", "audio/mid"}, {".midi", "audio/mid"}, {".mix", "application/octet-stream"}, {".mk", "text/plain"}, {".mmf", "application/x-smaf"}, {".mno", "text/xml"}, {".mny", "application/x-msmoney"}, {".mod", "video/mpeg"}, {".mov", "video/quicktime"}, {".movie", "video/x-sgi-movie"}, {".mp2", "video/mpeg"}, {".mp2v", "video/mpeg"}, {".mp3", "audio/mpeg"}, {".mp4", "video/mp4"}, {".mp4v", "video/mp4"}, {".mpa", "video/mpeg"}, {".mpe", "video/mpeg"}, {".mpeg", "video/mpeg"}, {".mpf", "application/vnd.ms-mediapackage"}, {".mpg", "video/mpeg"}, {".mpp", "application/vnd.ms-project"}, {".mpv2", "video/mpeg"}, {".mqv", "video/quicktime"}, {".ms", "application/x-troff-ms"}, {".msi", "application/octet-stream"}, {".mso", "application/octet-stream"}, {".mts", "video/vnd.dlna.mpeg-tts"}, {".mtx", "application/xml"}, {".mvb", "application/x-msmediaview"}, {".mvc", "application/x-miva-compiled"}, {".mxp", "application/x-mmxp"}, {".nc", "application/x-netcdf"}, {".nsc", "video/x-ms-asf"}, {".nws", "message/rfc822"}, {".ocx", "application/octet-stream"}, {".oda", "application/oda"}, {".odc", "text/x-ms-odc"}, {".odh", "text/plain"}, {".odl", "text/plain"}, {".odp", "application/vnd.oasis.opendocument.presentation"}, {".ods", "application/oleobject"}, {".odt", "application/vnd.oasis.opendocument.text"}, {".one", "application/onenote"}, {".onea", "application/onenote"}, {".onepkg", "application/onenote"}, {".onetmp", "application/onenote"}, {".onetoc", "application/onenote"}, {".onetoc2", "application/onenote"}, {".orderedtest", "application/xml"}, {".osdx", "application/opensearchdescription+xml"}, {".p10", "application/pkcs10"}, {".p12", "application/x-pkcs12"}, {".p7b", "application/x-pkcs7-certificates"}, {".p7c", "application/pkcs7-mime"}, {".p7m", "application/pkcs7-mime"}, {".p7r", "application/x-pkcs7-certreqresp"}, {".p7s", "application/pkcs7-signature"}, {".pbm", "image/x-portable-bitmap"}, {".pcast", "application/x-podcast"}, {".pct", "image/pict"}, {".pcx", "application/octet-stream"}, {".pcz", "application/octet-stream"}, {".pdf", "application/pdf"}, {".pfb", "application/octet-stream"}, {".pfm", "application/octet-stream"}, {".pfx", "application/x-pkcs12"}, {".pgm", "image/x-portable-graymap"}, {".pic", "image/pict"}, {".pict", "image/pict"}, {".pkgdef", "text/plain"}, {".pkgundef", "text/plain"}, {".pko", "application/vnd.ms-pki.pko"}, {".pls", "audio/scpls"}, {".pma", "application/x-perfmon"}, {".pmc", "application/x-perfmon"}, {".pml", "application/x-perfmon"}, {".pmr", "application/x-perfmon"}, {".pmw", "application/x-perfmon"}, {".png", "image/png"}, {".pnm", "image/x-portable-anymap"}, {".pnt", "image/x-macpaint"}, {".pntg", "image/x-macpaint"}, {".pnz", "image/png"}, {".pot", "application/vnd.ms-powerpoint"}, {".potm", "application/vnd.ms-powerpoint.template.macroEnabled.12"}, {".potx", "application/vnd.openxmlformats-officedocument.presentationml.template"}, {".ppa", "application/vnd.ms-powerpoint"}, {".ppam", "application/vnd.ms-powerpoint.addin.macroEnabled.12"}, {".ppm", "image/x-portable-pixmap"}, {".pps", "application/vnd.ms-powerpoint"}, {".ppsm", "application/vnd.ms-powerpoint.slideshow.macroEnabled.12"}, {".ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow"}, {".ppt", "application/vnd.ms-powerpoint"}, {".pptm", "application/vnd.ms-powerpoint.presentation.macroEnabled.12"}, {".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"}, {".prf", "application/pics-rules"}, {".prm", "application/octet-stream"}, {".prx", "application/octet-stream"}, {".ps", "application/postscript"}, {".psc1", "application/PowerShell"}, {".psd", "application/octet-stream"}, {".psess", "application/xml"}, {".psm", "application/octet-stream"}, {".psp", "application/octet-stream"}, {".pub", "application/x-mspublisher"}, {".pwz", "application/vnd.ms-powerpoint"}, {".qht", "text/x-html-insertion"}, {".qhtm", "text/x-html-insertion"}, {".qt", "video/quicktime"}, {".qti", "image/x-quicktime"}, {".qtif", "image/x-quicktime"}, {".qtl", "application/x-quicktimeplayer"}, {".qxd", "application/octet-stream"}, {".ra", "audio/x-pn-realaudio"}, {".ram", "audio/x-pn-realaudio"}, {".rar", "application/octet-stream"}, {".ras", "image/x-cmu-raster"}, {".rat", "application/rat-file"}, {".rc", "text/plain"}, {".rc2", "text/plain"}, {".rct", "text/plain"}, {".rdlc", "application/xml"}, {".resx", "application/xml"}, {".rf", "image/vnd.rn-realflash"}, {".rgb", "image/x-rgb"}, {".rgs", "text/plain"}, {".rm", "application/vnd.rn-realmedia"}, {".rmi", "audio/mid"}, {".rmp", "application/vnd.rn-rn_music_package"}, {".roff", "application/x-troff"}, {".rpm", "audio/x-pn-realaudio-plugin"}, {".rqy", "text/x-ms-rqy"}, {".rtf", "application/rtf"}, {".rtx", "text/richtext"}, {".ruleset", "application/xml"}, {".s", "text/plain"}, {".safariextz", "application/x-safari-safariextz"}, {".scd", "application/x-msschedule"}, {".sct", "text/scriptlet"}, {".sd2", "audio/x-sd2"}, {".sdp", "application/sdp"}, {".sea", "application/octet-stream"}, {".searchConnector-ms", "application/windows-search-connector+xml"}, {".setpay", "application/set-payment-initiation"}, {".setreg", "application/set-registration-initiation"}, {".settings", "application/xml"}, {".sgimb", "application/x-sgimb"}, {".sgml", "text/sgml"}, {".sh", "application/x-sh"}, {".shar", "application/x-shar"}, {".shtml", "text/html"}, {".sit", "application/x-stuffit"}, {".sitemap", "application/xml"}, {".skin", "application/xml"}, {".sldm", "application/vnd.ms-powerpoint.slide.macroEnabled.12"}, {".sldx", "application/vnd.openxmlformats-officedocument.presentationml.slide"}, {".slk", "application/vnd.ms-excel"}, {".sln", "text/plain"}, {".slupkg-ms", "application/x-ms-license"}, {".smd", "audio/x-smd"}, {".smi", "application/octet-stream"}, {".smx", "audio/x-smd"}, {".smz", "audio/x-smd"}, {".snd", "audio/basic"}, {".snippet", "application/xml"}, {".snp", "application/octet-stream"}, {".sol", "text/plain"}, {".sor", "text/plain"}, {".spc", "application/x-pkcs7-certificates"}, {".spl", "application/futuresplash"}, {".src", "application/x-wais-source"}, {".srf", "text/plain"}, {".SSISDeploymentManifest", "text/xml"}, {".ssm", "application/streamingmedia"}, {".sst", "application/vnd.ms-pki.certstore"}, {".stl", "application/vnd.ms-pki.stl"}, {".sv4cpio", "application/x-sv4cpio"}, {".sv4crc", "application/x-sv4crc"}, {".svc", "application/xml"}, {".swf", "application/x-shockwave-flash"}, {".t", "application/x-troff"}, {".tar", "application/x-tar"}, {".tcl", "application/x-tcl"}, {".testrunconfig", "application/xml"}, {".testsettings", "application/xml"}, {".tex", "application/x-tex"}, {".texi", "application/x-texinfo"}, {".texinfo", "application/x-texinfo"}, {".tgz", "application/x-compressed"}, {".thmx", "application/vnd.ms-officetheme"}, {".thn", "application/octet-stream"}, {".tif", "image/tiff"}, {".tiff", "image/tiff"}, {".tlh", "text/plain"}, {".tli", "text/plain"}, {".toc", "application/octet-stream"}, {".tr", "application/x-troff"}, {".trm", "application/x-msterminal"}, {".trx", "application/xml"}, {".ts", "video/vnd.dlna.mpeg-tts"}, {".tsv", "text/tab-separated-values"}, {".ttf", "application/octet-stream"}, {".tts", "video/vnd.dlna.mpeg-tts"}, {".txt", "text/plain"}, {".u32", "application/octet-stream"}, {".uls", "text/iuls"}, {".user", "text/plain"}, {".ustar", "application/x-ustar"}, {".vb", "text/plain"}, {".vbdproj", "text/plain"}, {".vbk", "video/mpeg"}, {".vbproj", "text/plain"}, {".vbs", "text/vbscript"}, {".vcf", "text/x-vcard"}, {".vcproj", "Application/xml"}, {".vcs", "text/plain"}, {".vcxproj", "Application/xml"}, {".vddproj", "text/plain"}, {".vdp", "text/plain"}, {".vdproj", "text/plain"}, {".vdx", "application/vnd.ms-visio.viewer"}, {".vml", "text/xml"}, {".vscontent", "application/xml"}, {".vsct", "text/xml"}, {".vsd", "application/vnd.visio"}, {".vsi", "application/ms-vsi"}, {".vsix", "application/vsix"}, {".vsixlangpack", "text/xml"}, {".vsixmanifest", "text/xml"}, {".vsmdi", "application/xml"}, {".vspscc", "text/plain"}, {".vss", "application/vnd.visio"}, {".vsscc", "text/plain"}, {".vssettings", "text/xml"}, {".vssscc", "text/plain"}, {".vst", "application/vnd.visio"}, {".vstemplate", "text/xml"}, {".vsto", "application/x-ms-vsto"}, {".vsw", "application/vnd.visio"}, {".vsx", "application/vnd.visio"}, {".vtx", "application/vnd.visio"}, {".wav", "audio/wav"}, {".wave", "audio/wav"}, {".wax", "audio/x-ms-wax"}, {".wbk", "application/msword"}, {".wbmp", "image/vnd.wap.wbmp"}, {".wcm", "application/vnd.ms-works"}, {".wdb", "application/vnd.ms-works"}, {".wdp", "image/vnd.ms-photo"}, {".webarchive", "application/x-safari-webarchive"}, {".webtest", "application/xml"}, {".wiq", "application/xml"}, {".wiz", "application/msword"}, {".wks", "application/vnd.ms-works"}, {".WLMP", "application/wlmoviemaker"}, {".wlpginstall", "application/x-wlpg-detect"}, {".wlpginstall3", "application/x-wlpg3-detect"}, {".wm", "video/x-ms-wm"}, {".wma", "audio/x-ms-wma"}, {".wmd", "application/x-ms-wmd"}, {".wmf", "application/x-msmetafile"}, {".wml", "text/vnd.wap.wml"}, {".wmlc", "application/vnd.wap.wmlc"}, {".wmls", "text/vnd.wap.wmlscript"}, {".wmlsc", "application/vnd.wap.wmlscriptc"}, {".wmp", "video/x-ms-wmp"}, {".wmv", "video/x-ms-wmv"}, {".wmx", "video/x-ms-wmx"}, {".wmz", "application/x-ms-wmz"}, {".wpl", "application/vnd.ms-wpl"}, {".wps", "application/vnd.ms-works"}, {".wri", "application/x-mswrite"}, {".wrl", "x-world/x-vrml"}, {".wrz", "x-world/x-vrml"}, {".wsc", "text/scriptlet"}, {".wsdl", "text/xml"}, {".wvx", "video/x-ms-wvx"}, {".x", "application/directx"}, {".xaf", "x-world/x-vrml"}, {".xaml", "application/xaml+xml"}, {".xap", "application/x-silverlight-app"}, {".xbap", "application/x-ms-xbap"}, {".xbm", "image/x-xbitmap"}, {".xdr", "text/plain"}, {".xht", "application/xhtml+xml"}, {".xhtml", "application/xhtml+xml"}, {".xla", "application/vnd.ms-excel"}, {".xlam", "application/vnd.ms-excel.addin.macroEnabled.12"}, {".xlc", "application/vnd.ms-excel"}, {".xld", "application/vnd.ms-excel"}, {".xlk", "application/vnd.ms-excel"}, {".xll", "application/vnd.ms-excel"}, {".xlm", "application/vnd.ms-excel"}, {".xls", "application/vnd.ms-excel"}, {".xlsb", "application/vnd.ms-excel.sheet.binary.macroEnabled.12"}, {".xlsm", "application/vnd.ms-excel.sheet.macroEnabled.12"}, {".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}, {".xlt", "application/vnd.ms-excel"}, {".xltm", "application/vnd.ms-excel.template.macroEnabled.12"}, {".xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template"}, {".xlw", "application/vnd.ms-excel"}, {".xml", "text/xml"}, {".xmta", "application/xml"}, {".xof", "x-world/x-vrml"}, {".XOML", "text/plain"}, {".xpm", "image/x-xpixmap"}, {".xps", "application/vnd.ms-xpsdocument"}, {".xrm-ms", "text/xml"}, {".xsc", "application/xml"}, {".xsd", "text/xml"}, {".xsf", "text/xml"}, {".xsl", "text/xml"}, {".xslt", "text/xml"}, {".xsn", "application/octet-stream"}, {".xss", "application/xml"}, {".xtp", "application/octet-stream"}, {".xwd", "image/x-xwindowdump"}, {".z", "application/x-compress"}, {".zip", "application/x-zip-compressed"}, #endregion }; } } </code></pre>
29,476,522
0
<p>I have tried using Aircrack on several Linux distribution and issues like this one happened quite often (usually because of dependency problems).</p> <p>I solved all problems by installing <a href="http://www.backtrack-linux.org/" rel="nofollow" title="Backtrack">Backtrack</a>, which contains all the packages you need, pre-installed.</p> <p>You can install it to USB drive as well</p>
18,939,806
0
Accessing an Objective-C ivar from outside the class at runtime <p>I know this idea completely breaks encapsulation, but say I have the following class extension:</p> <pre><code>@interface MyClass () { int reallyImportantIvar; } // ... @end </code></pre> <p>Normally, the class behaves like it should inside the Objective-C layer - sending and receiving messages, etc. However there is one ('public') subroutine where I need the best possible performance and very low latency, so I would prefer to use a C method. Of course, if I do, I can no longer access <em>reallyImportantIvar</em>, which is the key to my performance-critical task.</p> <p>It seems I have two options:</p> <ol> <li>Make the instance variable a static variable instead.</li> <li>Directly access the instance variable through the Objective-C runtime.</li> </ol> <p>My question is: is Option 2 even possible, and if so, what is its overhead? (E.g. Am I still looking at an O(n) algorithm to look up a class's instance variables anyway?)</p>
30,071,578
0
<p>This may occur if you started transaction explicitly. Every explicit transactions must be finished explicitly. So, if your connection is open explicitly, you should close it explicitly.</p> <p>You may use :</p> <pre><code>//Commit(Stop) the transaction before open an other connection if Dm.Transaction.InTransaction then dm.Transaction.Commit; </code></pre> <blockquote> <p>Note: In applications that connect an InterBaseExpress dataset to a client dataset, every query must be in its own transaction. You must use one transaction component for each query component.</p> </blockquote> <p><a href="http://docwiki.embarcadero.com/Libraries/XE8/en/IBX.IBDatabase.TIBTransaction" rel="nofollow">http://docwiki.embarcadero.com/Libraries/XE8/en/IBX.IBDatabase.TIBTransaction</a> </p>
25,326,017
0
Perl regex forward reference <p>I would like to match a forward reference with regexp. The pattern I am looking for is</p> <pre><code>[snake-case prefix]_[snake-case words] [same snake-case prefix]_number </code></pre> <p>For example: </p> <pre><code>foo_bar_eighty_twelve foo_bar_8012 </code></pre> <p>I cannot extract <code>foo_bar</code> and <code>eighty_twelve</code> without looking first at <code>foo_bar_8012</code>. Thus I need a forward reference, not a backward reference which work only if my prefix is not a snake-case prefix. </p> <pre><code>my $prefix = "foo"; local $_ = "${prefix}_thirty_two = ${prefix}_32"; # Backward reference that works with a prefix with no underscores { /(\w+)_(\w+) \s+ = \s+ \1_(\d+)/ix; print "Name: $2 \t Number: $3\n"; } # Wanted Forward reference that do not work :( { /\2_(\w+) \s+ = \s+ (\w+)_\d+/ix; print "Name: $1 \t Number: $2\n"; } </code></pre> <p>Unfortunately, my forward reference does not work and I do not know why. I've read that Perl support that kind of patterns. </p> <p>Any help ? </p>
15,949,234
0
<p>This happens because you have forgot a newline at the end of your log message. When the kernel outputs a partial message (by passing a string to <code>printk()</code> that does not end with a newline), the logging system will buffer the text until the rest of the message arrives. See also — <a href="http://lwn.net/Articles/503430/" rel="nofollow"><code>printk()</code> problems</a>.</p>
24,660,037
0
general backbone/marionette program structure <p>I need some general guidelines on how to structure a backbone/marionette application. Im very new to these frameworks and also to js in general.</p> <p>Basically I have two pages and each page has a list. I have set up an application and a router for the application:</p> <pre><code>var app = new Backbone.Marionette.Application(); app.module('Router', function(module, App, Backbone, Marionette, $, _){ module.AppLayoutView = Marionette.Layout.extend({ tagName: 'div', id: 'AppLayoutView', template: 'layout.html', regions: { 'contentRegion' : '.main' }, initialize: function() { this.initRouter(); }, ... }); module.addInitializer(function() { var layout = new module.AppLayoutView(); app.appRegion.show(layout); }); }); </code></pre> <p>In the initRouter I have two functions, one for each page that gets called by router depending on the url.</p> <p>The function for the content management page looks like this:</p> <pre><code>onCMNavigated: function(id) { var cMModule = App.module("com"); var cM = new cMModule.ContentManagement({id: id, region: this.contentRegion}); contentManagement.show(); this.$el.find('.nav-item.active').removeClass('active'); this.cM.addClass('active'); } </code></pre> <p>So if this is called, I create a new instance of ContentManagement model. In this model, when show() is called, I fetch the data from a rest api, and I parse out an array of banners that need to be shown in a list view. Is that ok? The model looks like the following:</p> <pre><code>cm.ContentManagement = Backbone.Model.extend({ initialize: function (options) { this.id = options.id; this.region = options.region; }, show: function() { var dSPage = new DSPage({id: this.id}); dSPage.bind('change', function (model, response) { var view = new cm.ContentManagementLayoutView(); this.region.show(view); }, this); dSPage.fetch({ success: function(model, response) { // Parse list of banners and for each create a banner model } } }); cm.ContentManagementLayoutView = Marionette.Layout.extend({ tagName: 'div', id: 'CMLayoutView', className: 'contentLayout', template: 'contentmanagement.html', regions: { 'contentRegion' : '#banner-list' } }); </code></pre> <p>Now my biggest doubt is how do I go on from here to show the banner list? I have created a collectionview and item view for the banner list, but is this program structure correct?</p>
34,472,810
0
<p><strong>1</strong> </p> <p>First of all, you create a protocol <code>ErrorPopoverRenderer</code> with a <em>blueprint</em> for method <code>presentError(...)</code>. You thereafter extend the class <code>UIViewController</code> to conform to this protocol, by implementing the (compulsory) blueprint for method <code>presentError(...)</code>.</p> <p>This means that you can subclass <code>UIViewController)</code> with additional protocol constraint <code>ErrorPopoverRenderer</code> for the subclass. If <code>UIViewController</code> had not been extended to conform to protocol <code>ErrorPopoverRenderer</code>, the subsequent code in the example you linked would case compile time error (<code>... does not comply to protocol ErrorPopoverRenderer</code>)</p> <pre><code>class KrakenViewController: UIViewController, ErrorPopoverRenderer { func failedToEatHuman() { //… //Throw error because the Kraken sucks at eating Humans today. presentError(ErrorOptions(message: "Oh noes! I didn't get to eat the Human!", size: CGSize(width: 1000.0, height: 200.0))) //Woohoo! We can provide whatever parameters we want, or no parameters at all! } } </code></pre> <p>However, there is a possible issue with this method, as presented in your link:</p> <blockquote> <p>Now we have to implement every parameter every time we want to present an ErrorView. This kind of sucks because we can’t provide default values to protocol function declarations.</p> </blockquote> <p>So of the protocol <code>ErrorPopoverRenderer</code> is not intended solely for use by <code>UIViewController</code>:s (or subclasses thereof), then the solution above isn't very generic.</p> <p><strong>2</strong></p> <p>If we want to have a more broad use of <code>ErrorPopoverRenderer</code>, we place the <em>specific</em> blueprints for each class type that might make use of the protocol in <em>protocol extensions</em>. This is really neat as the more specifics parts of <code>ErrorPopoverRenderer</code> blueprints for method <code>presentError()</code> can be specified differently for different classes that are to possibly conform to the protocol, and the method <code>presentError()</code> can be made more minimalistic.</p> <p>I quote, from the example:</p> <blockquote> <p>Using <strong>Self</strong> here indicates that that extension will only ever take place if and only if the conformer inherits from UIViewController. This gives us the ability <strong>to assume that the ErrorPopoverRenderer is indeed a UIViewController</strong> without even extending UIViewController.</p> </blockquote> <p>In this method, since <strong>the code now knows</strong> (we did, already in 1.) that it is a view controller that will call <code>presentError()</code>, we can place the specific <code>UIViewController</code> stuff directly in the blueprint implementation, and needn't send it as a long list of arguments.</p> <p>Hence, 2. is, for this specific use, a kind of more "generic" approach, in the sense that we slightly minimise code duplication (calling <code>presentError()</code> vs <code>presentError(... lots of args ...)</code> from several different <code>UIViewController</code>:s).</p>
3,447,685
0
<blockquote> <p>How nice of Microsoft to require registration now if we want to provide them information that will make their tool better.</p> </blockquote> <p>The reasoning behind it is probably this:</p> <ul> <li><p>Registration is for your own protection: If there was no registration, anyone could have error reports for your app problems sent to them. Even (and specifically) your competitors!</p></li> <li><p>A Certification Authority (CA) verifies the identity of the ISV (independent software vendor) companies that register with them. Microsoft uses the certificate as proof of identity of an ISV company that registers with Winqual. If they had to do the ID checking themselves, they'd likely need an own department for this.</p></li> <li>The registration is to allow <em>you</em> to make <em>your</em> application better, to cut down on future support and to keep <em>your</em> customer base happy. It's not for "their tool". Correct? :-)</li> </ul>
28,393,248
0
<p>You cannot overload functions in C, but you can organize your code to make it optimal. I would create a function for <code>rgb2hsv</code> and that would get a <code>void *</code> type of parameter, would determine the type and use it, handling all possible cases. And you should use only this function. On lower levels you still duplicate your function, on higher level you will not have to call two separate functions. This would simplify usage.</p>
12,371,672
0
<pre><code>return Class.forName(className); </code></pre> <p>regarding your edit, you cannot "cast" a string value to a long value. in order to convert a string value to some other type, then you need something more complex, like <a href="http://commons.apache.org/beanutils/api/org/apache/commons/beanutils/ConvertUtils.html" rel="nofollow">this</a>.</p>
13,843,641
0
Query result is different when executing a simple search in PHP <p>I am executing the following query in a MySQL database (look at SELECT AND WHERE, the rest is not important):</p> <pre><code>SELECT distinct fname //more fields... FROM filedepot_files AS ff INNER JOIN filedepot_categories AS fc ON ff.cid = fc.cid INNER JOIN filedepot_access AS fa ON fc.cid = fa.catid WHERE fa.permid=$id AND fname LIKE '%$key%' ORDER BY DATE </code></pre> <p>The environment is a PHP script running under Drupal with FileDepot module but I doubt that matters at all.</p> <p>This is the PHP script (well the part that matters):</p> <pre><code>$id = 1; $key = $_GET['key']; $query = .... (see above) $result = db_query($query); while($row = db_fetch_array($result)){ //do stuff echo $row['fname']; } </code></pre> <p><code>db_query()</code> is a Drupal method that allows to easily execute SQL queries and a returns an array, <code>db_fetch_array()</code> allows to parse the result.</p> <p>Now, DB contains the following entries for fname (there are more, these are just examples):</p> <ul> <li>Dichiarazione 1</li> <li>Dichiarazione 2</li> <li>Guida 1</li> <li>Guida 2</li> </ul> <p>If I launch the script with "guida" as key it correctly returns the two entries both with PHP and MySQL. If i use "Guida" it works as well. However if I use "dichiarazione" it doesnt with PHP while it does with MySQL. Strange thing is that "Dichiarazione" works both with PHP and MySQL.</p> <p>What is wrong with the query? I tryed to use <code>LOWER(fname) LIKE '%$key%'</code> but it doesn't seem to work as intended.</p> <p>I am sure there is something stupid that I am missing but I can't seem to find what that is...</p>
21,391,241
0
Best way to store / retrieve this data in IOS ( a single word and a path to a file ) <p>I know there are probably many ways to do this. </p> <p>I am wondering what direction I should look into for this. I need speed and ease of use. I'm going to guess go with an associative array. But interested in what the seasoned ios developers have to say on it.</p> <p>basically it will be about 50-200 items. No more than that. Each item containing a single word and a path to a file. ( note that details of the file will be processed / incorporated into the app at runtime ).</p>
20,210,111
0
NSLog(@" %@",NSStringFromCGRect([(UIButton*)[array lastObject]frame])); <pre><code>NSLog(@" %@",NSStringFromCGRect([(UIButton*)[array lastObject]frame])); </code></pre> <p>what is the error in this statement. My code is breaking error [__NSArrayI frame]: unrecognized selector sent to instance 0x1c5f2e00</p>
18,737,270
0
System subheadings in Android app <p>Like here.</p> <p><img src="https://i.stack.imgur.com/Nbu0i.png" alt="enter image description here"></p> <p>Like those blue <code>phone</code>, <code>email</code> , <code>adress</code>. I've been googling for a while, havn't found any built-in way to add them :(. Is there any? (Supporting 2.3, preferably)</p> <p><strong>Here is the same question with good answer too</strong>: <a href="http://stackoverflow.com/questions/10020466/android-4-0-sub-title-section-label-styling">Android 4.0 Sub-Title (section) Label Styling</a></p> <p><strong>And here is the <em>more or less</em> good way to reach what I want (but it's grey):</strong> <code>&lt;TextView style="?android:attr/listSeparatorTextViewStyle" ... &gt;</code></p>
32,986,183
0
<p>This one worked for me 100% after trying a bunch of other things:</p> <ol> <li>Go to Tools -> Options -> Environment -> Keyboard -> Press the (RESET) button </li> <li>Go to ReSharper - > Options -> Keyboard &amp; Menus -> Select the "Visual Studio" scheme -> Press "Apply Scheme"</li> <li>Press "Save"</li> <li>Press "CTRL-T". Since this shortcut is mapped in both VS and Resharper, you will be presented with the "Shortcut Conflict"-window. Here you select "Use ReSharper (Ultimate) command" and make sure to check the box "Apply to all ReSharper (Ultimate) shortscuts".</li> </ol> <p>Voila!</p>
33,001,590
0
nullPointerException after Screen rotation <p>I get nullPointerException exception returned by object <code>LinearLayout</code> after screen rotation although i am passing null in <code>onCreate()</code> super.onCreate(null); . I know Activity must be destroyed and re-created beside i'm passing savedInstanceState = null that mean Activity should start after rotation as it start for first time, why i get this Exception after rotation ?</p> <p><strong>onCreate() snippet where <code>LinearLayout</code> object called historyText</strong></p> <pre><code>LinearLayout historyText ; // this return exception if it used after rotation . @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(null); setContentView(R.layout.activity_main); historyText = (LinearLayout) findViewById(R.id.historyLayoutText); Log.e("HISTORYVISIBILITY", "VISIBILITY = "+historyText.getVisibility()); getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); database = new Database(this); Bundle extras = getIntent().getExtras(); intent = extras.getInt("activity"); p = new Progress(); getSupportFragmentManager().beginTransaction() .add(R.id.group, p) .commit(); orientation = getRotation(); switch (orientation){ case "p" : addPlus(); } } </code></pre> <p><strong>Logcat</strong></p> <pre><code> 10-07 22:21:24.365: E/AndroidRuntime(7768): FATAL EXCEPTION: main 10-07 22:21:24.365: E/AndroidRuntime(7768): Process: developer.mohab.gymee, PID: 7768 10-07 22:21:24.365: E/AndroidRuntime(7768): java.lang.RuntimeException: Unable to start activity ComponentInfo{developer.mohab.gymee/developer.mohab.gymee.Cardio.Cardio}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.widget.LinearLayout.getVisibility()' on a null object reference 10-07 22:21:24.365: E/AndroidRuntime(7768): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) 10-07 22:21:24.365: E/AndroidRuntime(7768): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442) 10-07 22:21:24.365: E/AndroidRuntime(7768): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4053) 10-07 22:21:24.365: E/AndroidRuntime(7768): at android.app.ActivityThread.access$900(ActivityThread.java:156) 10-07 22:21:24.365: E/AndroidRuntime(7768): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1357) 10-07 22:21:24.365: E/AndroidRuntime(7768): at android.os.Handler.dispatchMessage(Handler.java:102) 10-07 22:21:24.365: E/AndroidRuntime(7768): at android.os.Looper.loop(Looper.java:211) 10-07 22:21:24.365: E/AndroidRuntime(7768): at android.app.ActivityThread.main(ActivityThread.java:5389) 10-07 22:21:24.365: E/AndroidRuntime(7768): at java.lang.reflect.Method.invoke(Native Method) 10-07 22:21:24.365: E/AndroidRuntime(7768): at java.lang.reflect.Method.invoke(Method.java:372) 10-07 22:21:24.365: E/AndroidRuntime(7768): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020) 10-07 22:21:24.365: E/AndroidRuntime(7768): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815) 10-07 22:21:24.365: E/AndroidRuntime(7768): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.widget.LinearLayout.getVisibility()' on a null object reference 10-07 22:21:24.365: E/AndroidRuntime(7768): at developer.mohab.gymee.Cardio.Cardio.onCreate(Cardio.java:76) 10-07 22:21:24.365: E/AndroidRuntime(7768): at android.app.Activity.performCreate(Activity.java:5990) 10-07 22:21:24.365: E/AndroidRuntime(7768): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 10-07 22:21:24.365: E/AndroidRuntime(7768): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332) 10-07 22:21:24.365: E/AndroidRuntime(7768): ... 11 more 10-07 22:21:24.633: E/SurfaceFlinger(319): rejecting buffer: bufWidth=1358, bufHeight=624, front.active.{w=193, h=193} </code></pre>
40,980,396
0
<p>That caused by module configuration cached. It was generated at first time to speed up reading configuration. So, after adding new service configuration always remove the cache in <code>data/cache/module-config-cache.application.config.cache.php</code> It will be created automatically if not found.</p>
32,032,782
0
<p>Read the documentation, log4net is very configurable and well documented.</p> <p>Documentation: <a href="https://logging.apache.org/log4net/release/manual/configuration.html" rel="nofollow">https://logging.apache.org/log4net/release/manual/configuration.html</a></p> <pre><code>using Com.Foo; // Import log4net classes. using log4net; using log4net.Config; public class MyApp { // Define a static logger variable so that it references the // Logger instance named "MyApp". private static readonly ILog log = LogManager.GetLogger(typeof(MyApp)); static void Main(string[] args) { // Set up a simple configuration that logs on the console. BasicConfigurator.Configure(); log.Info("Entering application."); Bar bar = new Bar(); bar.DoIt(); log.Info("Exiting application."); } } </code></pre> <p>Take note the difference in the method for getting to log instance.</p> <ol> <li>You're asking for an ILog for the current Type not an explicitly a filename</li> <li>You're telling log4net to read configuration settings from the app.config/web.config</li> <li>Depending on your config you may need to use the XmlConfigurator</li> </ol> <p>An example of the .config file is:</p> <pre><code>&lt;log4net&gt; &lt;!-- A1 is set to be a ConsoleAppender --&gt; &lt;appender name="A1" type="log4net.Appender.ConsoleAppender"&gt; &lt;!-- A1 uses PatternLayout --&gt; &lt;layout type="log4net.Layout.PatternLayout"&gt; &lt;conversionPattern value="%-4timestamp [%thread] %-5level %logger %ndc - %message%newline" /&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;!-- Set root logger level to DEBUG and its only appender to A1 --&gt; &lt;root&gt; &lt;level value="DEBUG" /&gt; &lt;appender-ref ref="A1" /&gt; &lt;/root&gt; &lt;/log4net&gt; </code></pre> <p>There are lots of Appenders, above is a ConsoleAppender, but a DatabaseAppender exists and other types that might fit with you're need.</p>
25,321,810
0
<p>After exploration, I came across fnServerData Ajax Calling options. With the help of this API, i was able to complete this task. More details <a href="http://legacy.datatables.net/usage/callbacks" rel="nofollow">here</a></p>
16,392,175
0
<p>How are you setting <code>self.newsCount</code>?</p> <p>Either you are not putting an array into <code>self.newsCount</code>, or (more likely) you are setting "<code>newsCount</code>" without <code>retaining</code> it.</p> <p>Are you using <code>ARC</code>? If not, you should be.</p>
24,113,368
0
<p>Java interfaces cannot be instantiated, the programmer has to specify what implementation of the interface he wants to instantiate.</p> <p>For example, if you try to do this (replace INTERFACE with the name of the interface):</p> <pre><code>INTERFACE i = new INTERFACE(); </code></pre> <p>you will get an error, because an interface cannot be instantiated.</p> <p>What you must do is (replace IMPLEMENTATION with the name of the implementation of the interface):</p> <pre><code>INTERFACE i = new IMPLEMENTATION(); </code></pre> <p>As you can see, you ALWAYS tell the program what implementation to use for an interface. There's no room for ambiguity. </p> <p>In your example, the class TextSource is NOT instantating the interface TextReceiver (instantiation occurs with the <strong>"new"</strong> keyword). Instead, it has a constructor that receives the implementation of the interface as a parameter. Therefore, when you call TextSource you MUST tell it what implementation of TextReceiver to use.</p>
15,442,710
0
<pre><code>function getMonth(monthNumber) { var monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; return monthNames[monthNumber-1]; } </code></pre>
21,214,993
0
<p>Separate headers by <code>\r\n</code>.</p> <pre><code>function emailHTML($to, $from, $subject, $HTMLmessage) { $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers = "From: ".$from . "\r\n"; $headers .= "Bcc: [email protected]\r\n"; $headers .= "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n" . " boundary=\"{$mime_boundary}\""; $content .= "This is a multi-part message in MIME format.\r\n\r\n" . "--{$mime_boundary}\r\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\r\n" . "Content-Transfer-Encoding: 7bit\r\n\r\n" . $HTMLmessage . "\r\n\r\n"; $ok = @mail($to, $subject, $content, $headers); if(!$ok) { die("Error sending email"); } } </code></pre>
11,273,633
0
<p>If you consider what <strong><a href="https://github.com/msysgit/msysgit/blob/devel/git-cmd.bat" rel="nofollow"><code>git-cmd.bat</code></a></strong> does, all you need to do is to set the right variable <code>%PATH%</code> before your git commands in your script:</p> <p>If you don't, here is what you would see:</p> <pre><code>C:\Users\VonC&gt;git --version 'git' is not recognized as an internal or external command, operable program or batch file. </code></pre> <p>I have uncompressed the <a href="http://code.google.com/p/msysgit/downloads/list" rel="nofollow">latest portable version of msysgit</a>.</p> <p>Put anywhere a <code>test.bat</code> script (so no powershell involved there) with the following content:</p> <pre><code>@setlocal @set git_install_root="C:\Users\VonC\prg\PortableGit-1.7.11-preview20120620" @set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%git_install_root%\cmd;%PATH% @if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH% @if not exist "%HOME%" @set HOME=%USERPROFILE% @set PLINK_PROTOCOL=ssh REM here is the specific git commands of your script git --version echo %HOME% git config --global --list </code></pre> <p>Make sure <code>HOME</code> is correctly set, because Git will look for your global git config there.</p> <p>The result will give you:</p> <pre><code>C:\Users\VonC&gt;cd prog\git C:\Users\VonC\prog\git&gt;s.bat C:\Users\VonC\prog\git&gt;git --version git version 1.7.11.msysgit.0 C:\Users\VonC\prog\git&gt;echo C:\Users\VonC C:\Users\VonC C:\Users\VonC\prog\git&gt;git config --global --list user.name=VonC </code></pre> <p>Note: that same script would work perfectly from a powershell session.</p>
6,634,673
0
<p>You'll have to make them in code instead of interface builder</p> <pre><code> for (int i = 0; i &lt; n; i++) { UILabel *label = [[UILabel alloc] initWithFrame: CGRectMake(/* where you want it*/)]; label.text = @"text"; //etc... [self.view addSubview:label]; [label release]; } </code></pre>
34,755,770
0
modal appear behind fixed navbar <p>so i have bootstrap based site with fixed navigation bar (that follow you around the page at the top) and when i want to show modal popup, it appear behind those navigation bar, how to fix?</p> <p>and i using <a href="https://graygrids.com/item/margo-free-multi-purpose-bootstrap-template/" rel="nofollow noreferrer">margo template from graygrids</a></p> <p>it also appear in summernote modals for uploading picture, so it looks like all modal will appear behind those navigation bar.</p> <p><a href="https://i.stack.imgur.com/mZy6x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mZy6x.png" alt="enter image description here"></a></p>
6,952,371
0
CSS Fluid layout and images <p>I am trying to create a completely fluid layout in CSS (everything in %), which would work seamlessly across platforms (desktop/mobile/tablets like iPad).</p> <p>With Fluid Layouts, can an image be made completely fluid? For example:</p> <pre><code>img { max-width:100%; } </code></pre> <ul> <li>Does this mean it will adjust/fit to any extent or window size?</li> <li>Also can this be applied to background images as well ?</li> <li>Does this property have any limitations in terms of browser implementation or anything ?</li> </ul>
18,858,052
0
Is this my hosts fault or mine? <p>On the net panel of my Firebug console some of the files sent with my website are racking up an alarming length of time "waiting" for a response from my server, and receiving certain files. I've done everything I can in terms of gzip, minifying code etc. and just wanted to confirm with someone who knows more than me about this stuff that the problem here is definitely with my (shared) server and not an issue.</p> <p>Link to a (cropped) screenshot of the waterfall from the normal Firefox dev tools..</p> <p><a href="http://puu.sh/4tMsf.png" rel="nofollow">screenshot</a></p> <p>I had just cleared my cache. Also in reference to anyone who might point out that it's my fault for buying a plan with a cheap, slow host on a shared plan.. please don't, I am already well aware :p</p>
33,944,193
0
<p>I love pseudo elements so that's exactly what I would use here.</p> <pre><code>h1{ position:relative; } h1:after{ content:""; position:absolute; width:20%; border-top:1px solid green; bottom:0; left:40%; } </code></pre> <p>If you want the underline to be a fixed width, you'll need to use negative margins to center it.</p> <pre><code>h1:after{ content:""; position:absolute; width:100px; border-top:1px solid green; bottom:0; left:50%; margin-left:-50px; } </code></pre>
23,471,581
0
<pre><code>first method </code></pre> <p>you can create an AsynTask .. Your code should run in background in order to be responsive.. otherwise it will show Not Responding ..</p> <pre><code>Second Method </code></pre> <p>You can create a seperate thread for it .. using multitasking.</p> <pre><code>Third </code></pre> <p>Right the code in the <code>onCreate</code> after <code>setContentView</code></p> <pre><code> StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); </code></pre>
15,165,817
0
<p>There is no canonical mechanism in Ember to store and retrieve the current user. The simplest solution is probably to save your current user's account ID to <code>Social.currentAccountId</code> when the user is authenticated (ie. in the success callback of your ajax request). Then you can perform </p> <pre><code>Social.Account.find(Social.get('currentAccountId')) </code></pre> <p>when you need to get the current user.</p>
6,807,908
0
How to determine if an object is at rest? <p>Using the <a href="http://physicshelper.codeplex.com/" rel="nofollow">physics helper</a> library.</p> <p>I'm trying to figure out how I can determine whether a physics object is at rest. Does anyone know how to do this or have any ideas of what I could do?</p> <p>An example scenario is a bouncy ball that can be picked up and thrown around. I tried creating a timer that times each individual bounce from a collision event with the floor and determines if the object is at rest based off of that but this does not work for if the user slides the ball to the left and right.</p> <p>Any suggestions?</p>
11,807,076
0
streaming video from iphone to server programatically <p>I need to implement iphone video streaming to server. I've googled a lot but I found only receiving video streams from server. It is made using UIWebView or MPMoviewPlayer. But how can I stream my captured media to server in realtime? Help me please. How can it be done?</p>
33,073,514
0
<p>Once the last space of a console buffer row is used, the console cursor automatically jumps to the next line.</p> <ol> <li>Reset cursor back to the beginning before it reaches edge of console</li> <li>Erase old console output, placing cursor on next line</li> <li><p>Reset cursor back onto the line that was just cleared</p> <pre><code>while (true) { Console.Write("."); if (Console.CursorLeft + 1 &gt;= Console.BufferWidth) { Console.SetCursorPosition(0, Console.CursorTop); Console.Write(Enumerable.Repeat&lt;char&gt;(' ', Console.BufferWidth).ToArray()); Console.SetCursorPosition(0, Console.CursorTop - 1); } if (Console.KeyAvailable) break; } </code></pre></li> </ol>
7,782,179
0
RIA Services metadata for entities in different class <p>In my project, I have the following: - A class library that contains a Linq2SQL datacontext. - A web project containing the domainservice that uses the datacontext in the library.</p> <p>I've not found a way to add metadata to the services where I don't have to manually build all of the metadata elements myself. Is there some something I am missing?</p> <p>I am using RIA Services 1.0 - if a service pack addresses this, I'd be happy to know about it.</p>
37,626,429
0
<p>Which version of IIS you are using. Assuming 7.5 or above (> Windows 2008 r2), the default log location for IIS is <strong>C:\inetpub\logs\LogFiles</strong> . Inside this all the folders are named in format W3SVC<em>siteID</em>, for example - W3SVC1. W3SVC2 etc.</p> <p>In order to find the site ID</p> <ol> <li>Open IIS Manager</li> <li>Expand server node</li> <li>Click on Sites</li> </ol> <p>In the center pane (also know as workspace) you can see site name and it's ID.</p> <p>Now usually when you browse a page in IIS something like below gets logged </p> <pre><code>2016-02-21 00:18:27 ::1 GET /index.html - 80 - ::1 Mozilla/5.0+(Windows+NT+10.0;+WOW64;+rv:44.0)+Gecko/20100101+Firefox/44.0 200 0 0 75 </code></pre> <p>However you wont see this immediately in log file as IIS buffers that in memory and flushes it later. If you want to forcefully flush the buffer to log file you can run below command from a elevated command prompt</p> <pre><code>netsh http flush logbuffer </code></pre> <p>Hope this helps!</p>
40,421,573
0
<p>Try this.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code> li.breadcr { width: 2em; height: 2em; text-align: center; line-height: 2em; border-radius: 1em; background: #0095c4; margin: 0 3em; display: inline-block; color: white; position: relative; } li.breadcr::before{ content: '' !important; position: absolute !important; top: .9em !important; left: -8em !important; width: 10em !important; height: .2em !important; background: #0095c4 !important; z-index: -1 } li.breadcr:first-child::before { display: none !important; } .active { background: #0095c4; } .active ~ li.breadcr { background: #badae4 !important; } .active ~ li.breadcr::before { background: #badae4 !important; } ul.sub{ list-style: none; } li.sub02{ display: inline-block; font-family: TeX Gyre Heros,Helvetica Neue,Helvetica,Roboto,Arial,sans-serif; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/&gt; &lt;ul&gt; &lt;li class="breadcr" &gt;1&lt;/li&gt; &lt;li class="active breadcr"&gt;2&lt;/li&gt; &lt;li class="breadcr"&gt;3&lt;/li&gt; &lt;/ul&gt; &lt;ul class="sub"&gt; &lt;li class="sub02" style="margin-left: 25px;"&gt;&lt;b&gt;File or link&lt;/b&gt;&lt;/li&gt; &lt;li class="sub02" style="margin-left: 53px;"&gt;&lt;b&gt;Category&lt;/b&gt;&lt;/li&gt; &lt;li class="sub02" style="margin-left: 50px;"&gt;&lt;b&gt;Comments&lt;/b&gt;&lt;li&gt; &lt;/ul&gt;</code></pre> </div> </div> </p>
23,263,872
0
gem install rails -v 4.1.0 stuck with ri-documentation <p>I've run <code>gem install rails -v 4.1.0</code> on my server, but somehow it's stuck with </p> <pre><code>Parsing documentation for rails-4.1.0 Installing ri documentation for rails-4.1.0 </code></pre> <p>Can I abort this? What do I need the ri documentation for? Is it really required?</p>
14,992,656
0
Applescript to add grandparent folder+parent folder prefix to filename <p>I have multiple folders with sub folders that have files in them that need to be labeled with their parent folder+grandparent folder name.</p> <p>i.e. Folder 1>Folder 2>File.jpg needs to be renamed to Folder_1_Folder_2_File.jpg</p> <p>I was able to find a script that somewhat does it, and have been trying to reverse engineer it, but am not having any luck. The script below presents two challenges, 1) It includes the entire path from the root directory, and two, it deletes the name of the file, therefore only allowing one file to be renamed before it errors out. I know that the problem is that the script is renaming the entire file, I just don't know how to proceed.</p> <pre><code>tell application "Finder" set a to every folder of (choose folder) repeat with aa in a set Base_Name to my MakeBase(aa as string) set all_files to (every file in aa) repeat with ff in all_files set ff's name to (Base_Name &amp; "." &amp; (ff's name extension)) end repeat end repeat end tell to MakeBase(txt) set astid to AppleScript's text item delimiters set AppleScript's text item delimiters to ":" set new_Name_Raw to every text item of txt set AppleScript's text item delimiters to "_" set final_Name to every text item of new_Name_Raw as text set AppleScript's text item delimiters to astid return final_Name end MakeBase </code></pre> <p>Thank you!</p>
33,204,590
0
how to make instance variables updating in callback to happen in main thread? <p>This is the code that gets called when the GoogleApiClient gets created. All this does it retrieve the last location of the user. </p> <pre><code> //omitted code @Override public void onConnected(Bundle bundle) { Location location = LocationServices.FusedLocationApi.getLastLocation(mApiClient); if (location != null) { mLongitude = String.valueOf(location.getLongitude()); mLatitude = String.valueOf(location.getLatitude()); Log.d(TAG, mLongitude + "___" + mLatitude); //this one doesn't return null } else { Log.d(TAG, "Location is null"); LocationServices.FusedLocationApi.requestLocationUpdates(mApiClient, mLocationRequest, this); } } </code></pre> <p>This is for the google api client: </p> <pre><code>private void buildGoogleApiClient() { mApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } </code></pre> <p>This snippet is from my onCreate() method:</p> <pre><code>buildGoogleApiClient(); Log.d(TAG, mLongitude + "___" + mLatitude); //this one returns null </code></pre> <p>So when the code gets run, i build a google api client and the onConnected method gets called. Inside of that method, i will update the mLongitude and mLatitude variables which are instance variables. However in the log, they return as null. I was wondering why this happened so i put another log INSIDE the if statement of my onConnected() method as you can see in the first block of code and this one successfully brings back the longitude and latitude. I dont know why its not updating the instance variables. I believe it's because the callback isn't being run on the main thread and so the log happens before the update. So I tried running the code in the main thread like this:</p> <pre><code>runOnUiThread(new Runnable() { @Override public void run() { buildGoogleApiClient(); } }); Log.d(TAG, mLongitude + "___" + mLatitude); </code></pre> <p>unfortunately this doesnt work either. I searched for things relating to this topic and tried implementing them in my code however none seem to work as i dont even know the real cause for this problem.</p> <p>Anyone know how to fix this?</p> <p>Thank you</p>
12,137,621
0
<p>your html is invalid. your <code>&lt;/script&gt;</code> tag should be before the <code>&lt;/head&gt;</code> tag</p> <p>if you really want to execute it only when you press the button then you should consider using ajax or to use a <code>&lt;form&gt;</code></p>
34,055,244
0
Bootstrap Glyphicons hiding border <p>For some reason, glyphicons hide a border of a container if it's being floated. Can someone explain this, and if there's a known workaround?</p> <p><a href="http://www.bootply.com/kmhAN31yEn" rel="nofollow noreferrer">bootply.com/kmhAN31yEn</a></p> <p><a href="https://i.stack.imgur.com/CXZSd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CXZSd.jpg" alt="glyphicon bug"></a></p> <p>OS X 10.11.1, Chrome 47.0.2526.73 (64-bit)</p>
6,363,041
0
<p><a href="http://openntf.org/projects/pmt.nsf/ProjectLookup/GooCalSync" rel="nofollow">GooCalSync (openntf</a> and <a href="http://sourceforge.net/projects/lngooglecalsync/" rel="nofollow">LotusNotes-Google Calendar Synchronizer (sourceforce)</a> are great examples of how to do this in Java.</p>
6,916,128
0
<p>It's hard to say which components you can reuse and how you can reuse without having seen the API :)</p> <p>I'd probably start by pointing the client directly at the new API and inspecting what breaks. If after digging around with the debugger the problems do not look too bad, I'd tweak the client as necessary.</p> <p>However, if you're really just reading from a simple rest API, you may not find a whole lot of benefit from attempting to reuse the Google client. An HTTP client combined with a JSON parser like <a href="http://jackson.codehaus.org/" rel="nofollow">Jackson</a> may be sufficient and less complex.</p> <p>~~Jenny</p>
13,316,591
0
<p>i apologize if i don't understand the question, but maybe what you're looking for is this:</p> <p><a href="http://stackoverflow.com/questions/7366974/selectively-include-dependencies-in-jar">Selectively include dependencies in JAR</a></p> <p>so here's the plugin</p> <p><a href="https://github.com/nuttycom/sbt-proguard-plugin" rel="nofollow">https://github.com/nuttycom/sbt-proguard-plugin</a></p> <p>sbt proguard looks like it will cut down the unnecessary classes, so that your project will not be "heavy"</p>
32,909,855
0
<p><a href="http://yoursite.com/checkout/?add-to-cart=" rel="nofollow">http://yoursite.com/checkout/?add-to-cart=</a>{ID}</p> <p><a href="http://yoursite.com/cart/?add-to-cart=" rel="nofollow">http://yoursite.com/cart/?add-to-cart=</a>{ID}</p> <p>Replace {ID} with the Post ID of the specific Product:</p> <p>result must be something like this:</p> <pre><code>http://yoursite.com/cart/?add-to-cart=&lt;?php echo $post-&gt;ID; ?&gt; </code></pre> <p>I hope it helps</p>
19,422,629
0
<p>There are multiple overloaded of Add method at least in NH version 3.0.0.4000. One of them is having generic parameter that can be used for your case, for example:</p> <pre><code>disjuction.Add&lt;TypeinWhichPrimaryKeyPropertyExists&gt;(x =&gt; x.PrimaryKey == 1) </code></pre>
32,877,308
0
<p>You can stretch an image while preserving the aspect ratio of a portion of that image using slicing. Xcode offers a graphical interface for doing this. The idea is that you decide what parts of the image are allowed to stretch and which aren't.</p> <p><a href="https://developer.apple.com/library/ios/recipes/xcode_help-image_catalog-1.0/chapters/SlicinganImage.html" rel="nofollow">https://developer.apple.com/library/ios/recipes/xcode_help-image_catalog-1.0/chapters/SlicinganImage.html</a></p>
38,173,134
0
<pre><code>test.c:5:5: error: conflicting types for 'getline' int getline (char line[], int maxline); ^ /usr/include/stdio.h:442:9: note: previous declaration is here ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict) ... </code></pre> <p>I hope that answers your question. Your function <code>getline()</code> has the same name as a function defined in the standard library <code>stdio.h</code>, which is why you're getting the error. <strong><em>Just change your function name.</em></strong></p>
21,893,140
0
Radio Button Isenabled trouble <p>I'm setting a combobox to be enabled based on selection of Radioboxes. Currently it's producing this error <code>Object reference not set to an instance of an object.</code> for the following code below. I did it one at a time and to make the ComboBox False works. When I implemented Disc_OnChecked to Set to true it produced the error. If I can get help to bypass this error please.</p> <pre><code>private void Cont_OnChecked(object sender, RoutedEventArgs e) { Cf.IsEnabled = false; } private void Disc_OnChecked(object sender, RoutedEventArgs e) { Cf.IsEnabled = true; } </code></pre> <p>Xaml code:</p> <pre><code>&lt;GroupBox&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;TextBlock Text="Type: "&gt;&lt;/TextBlock&gt; &lt;RadioButton Checked="Disc_OnChecked" GroupName="Group1" x:Name="Disc" IsChecked="true" Content="Discrete" &gt;&lt;/RadioButton&gt; &lt;RadioButton Checked="Cont_OnChecked" GroupName="Group1" x:Name="Cont" Content="Continuous"&gt;&lt;/RadioButton&gt; &lt;/StackPanel&gt; &lt;/GroupBox&gt; &lt;ComboBox x:Name="Cf" Width="125" SelectedIndex="1"&gt; &lt;ComboBoxItem Content="Annual"&gt;&lt;/ComboBoxItem&gt; &lt;ComboBoxItem Content="Semi-annual"&gt;&lt;/ComboBoxItem&gt; &lt;/ComboBox&gt; </code></pre>
30,189,108
0
Combine Columns in CSV file using JAVA <p>I want to combine columns in csv file using java here in this file i want combine first two columns "Product No" and "Product Name".</p> <p>This is My CSV File</p> <pre><code> Productno,Productname,Price,Quantity 1,java,300,5 2,java2,500,10 3,java3,1100,120 </code></pre> <p>Here is My Code</p> <pre><code>private void parseUsingOpenCSV(String filename) { CSVReader reader; FileWriter out = null; CSVWriter outt; try { reader = new CSVReader(new FileReader(filename)); String[] row; try { out= new FileWriter("E:/data/test/newww.csv"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { while ((row = reader.readNext()) != null) { for (int i = 0; i &lt; row.length; i++) { // display CSV values System.out.println(row[i]); String com = row[i]; out.write(com); } } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (FileNotFoundException e) { System.err.println(e.getMessage()); }finally{ if (out != null) { try { out.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } </code></pre> <p>By using this code i get output is below</p> <pre><code>Product No Product Name Price 1 java 300 2 java2 500 3 java3 1100 </code></pre> <p>But I want Output like this....</p> <pre><code> ProductnoProductname,Price,Quantity 1java,300,5 2java2,500,10 3java3,1100,120 </code></pre>
27,488,943
0
How to config to show depended library jars rather than packages in "Packages view" of Intellij IDEA? <p>I installed Intellij IDEA 14 on my mac osx, but I found the display of depended library in Packages view was very annoying.The following is the screenshot of intellij idea, all the package name of depended jars are displayed here, they are indeed too many...</p> <p>intellij idea screenshot:</p> <p><img src="http://ww2.sinaimg.cn/bmiddle/c07d8ae3jw1enaucayottj20af0blab4.jpg"></p> <p><strong>I just want to know how to config to make the library view look like eclipse, display all the depended jars rather than expanded package name.</strong></p> <p>eclipse screenshot:</p> <p><img src="http://ww2.sinaimg.cn/bmiddle/c07d8ae3jw1enaucddd4aj209q0b2wfh.jpg"></p>
9,625,380
0
Database query times out on heroku <p>I'm stress testing an app by adding loads and loads of items and forcing it to do lots of work. </p> <pre><code>select *, ( select price from prices WHERE widget_id = widget.id ORDER BY id DESC LIMIT 1 ) as maxprice FROM widgets ORDER BY created_at DESC LIMIT 20 OFFSET 0 </code></pre> <ul> <li>that query selects from widgets (approx 8500) and prices has 777000 or so entries in it.</li> </ul> <p>The query is timing out on the test environment which is using the basic Heroku shared database. (193mb in use of the 5gig max.)</p> <p>What will solve that time out issue? The prices update each hour, so every hour you get 8500x new rows. </p> <p>It's hugely excessive amounts for the app (in reality it's unlikely it would ever have 8500 widgets) but I'm wondering what's appropriate to solve this?</p> <p>Is my query stupid? (i.e. is it a bad style of query to do that subselect - my SQL knowledge is terrible, one of the goals of this project is to improve it!) </p> <p>Or am I just hitting a limit of a shared db and should expect to move onto a dedicated db (e.g. the min $200 per month dedicated postgres instance from Heroku.) given the size of the prices table? Is there a deeper issue in terms of how I've designed the DB? (i.e. it's a one to many, one widget has many prices.) Is there a more sensible approach?</p> <p>I'm totally new to the world of sql and queries etc. at scale, hence the utter ignorance expressed above. :)</p>
15,104,142
0
<p>The first one is faster because vector rendering mathematics are required to fill your shape in the latter.</p> <p>If you want noticeable (and I mean very noticeable) performance gains, you should have <em>one</em> Bitmap on the stage. What you do from there is store references to <code>BitmapData</code> to represent graphics, and sample those onto your one Bitmap via <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#copyPixels%28%29" rel="nofollow"><code>.copyPixels()</code></a>.</p> <p>Example:</p> <pre><code>// This is the only actual DisplayObject that will hit the Stage. var canvas:Bitmap = new Bitmap(); canvas.bitmapData = new BitmapData(500, 400); addChild(canvas); // Create some BitmapData and draw it to the canvas. var rect:BitmapData = new BitmapData(40, 40, false, 0xFF0000); canvas.bitmapData.copyPixels(rect, rect.rect, new Point(20, 20)); </code></pre>
7,193,708
0
<p>You can currently find Hype or Pixelmator on the Mac App Store. </p> <p>This proves evidently that you can save to disk and read from disk, which seems a basic feature of any serious application. Moreover, Apple is pushing developers to start using incremental auto-backups of files, it would therefore be very surprising if they forbade that in the App Store, wouldn't it?</p>
23,877,947
0
<p>When angular is creating your controller, it will use the <code>new</code> keyword on the function you passed in. Thus, it will construct a new object using the constructor you passed in. Constructing objects using a constructor function will always return the instance of the newly created object. </p> <p>There are some details about the constructing process (see <a href="http://stackoverflow.com/a/1978474/576725">this</a> SO answer) </p> <ol> <li>When the returned object is the same as <code>this</code> it can be omitted, as it will be returned by default</li> <li>If returning some primitive type, null, or something different (described in the other SO answer) also <code>this</code> will be returned.</li> <li>If returning an instance, the reference to this instance will be returned.</li> </ol>
11,766,854
0
<p>Only if you had read UIColor's class reference...</p> <pre><code>UIColor *color = [UIColor colorWithRed:200 / 255.0 green:100 / 255.0 blue: 200 / 255.0 alpha: 1.0]; </code></pre> <p>will solve your problem.</p>
24,197,998
0
<p>I have update the jsfiddle try this</p> <pre><code>[http://jsfiddle.net/W4xBJ/2/][1] </code></pre> <p>Actually your key is store_url not set_url. you were using the wrong key</p>
15,437,350
0
<p>Try this for example:</p> <p>Course class:</p> <pre><code>import java.util.ArrayList; import java.util.List; public class Course { private List&lt;Student&gt; students = new ArrayList&lt;Student&gt;(); private String teacherName; private String subjectName; public Course(String subjectName, String teacherName) { this.subjectName = subjectName; this.teacherName = teacherName; } public void addStudent(Student student) { students.add(student); } public float getAverageGrade() { float grade = 0; for (Student student : students) { grade += student.getGrade(); } return grade / students.size(); } public void printCourse() { System.out.println("Course "+subjectName+" taught by "+teacherName); System.out.println("Students:"); printStudents(); System.out.println("Aberage grade: "+getAverageGrade()); } public void printStudents() { for (Student student : students) { System.out.println(student.getName()+"\t age "+student.getAge()+" \t grade "+student.getGrade()); } } } </code></pre> <p>Student class:</p> <pre><code>public class Student { private String name; private int age; private int grade; public Student(String name, int age, int grade) { this.grade = grade; this.age = age; this.grade = grade; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public int getGrade() { return grade; } public void setGrade(int grade) { this.grade = grade; } } </code></pre>
33,901,004
0
<p>You cannot change line size for <code>sjp.int</code> currently, so you have to modify the returned plot object(s), which are in the return value <code>plot.list</code>. Then you can overwrite <code>geom_line()</code>.</p> <pre><code>dummy &lt;- sjp.int(test, type = "eff") dummy$plot.list[[1]] + geom_line(size = 3) </code></pre> <p><a href="https://i.stack.imgur.com/6AA66.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6AA66.png" alt="enter image description here"></a></p> <p>I've added a <code>geom.size</code> argument to <code>sjp.int</code>, see <a href="https://github.com/sjPlot/devel" rel="nofollow noreferrer">GitHub</a>.</p>
37,982,054
0
Using jQuery's unwrap() to remove a class <p>I want to remove the class of <code>emphasis</code> from all tags that have that class in a specific cell of the table. I'm selecting the table cell content like this: </p> <pre><code>var answer = $('tr.problem_display_work:last td:first').html(); </code></pre> <p>In another place in the code, I'm using <code>unwrap()</code> like this: </p> <pre><code>$(".emphasis").contents().unwrap(); </code></pre> <p>However, I'm not sure how to combine the two. I tried this, but it failed:</p> <pre><code>var answer = $('tr.problem_display_work:last td:first').html().(".emphasis").contents().unwrap(); </code></pre> <p>Any ideas?</p> <p>EDIT FOR CLARIFICATION #1: I want to keep the HTML inside the tag. So, if I have: <code>14 + 6 = &lt;span class="emphasis"&gt;20&lt;/span&gt;</code> I want to end up with <code>14 + 6 = 20</code>.</p> <p>EDIT FOR CLARIFICATION #2: The HTML in question is getting set as the value for a hidden <code>&lt;input&gt;</code> field like this <code>$('#answer').val(answer);</code>. Gleb Kemarsky's solution is good, but it doesn't get applied the value for the input field for some reason.</p> <p>EDIT FOR CLARIFICATION #3...</p> <p>I have a <code>&lt;table&gt;</code> with some rows and cells. In the first cell of the last row I have some content (<code>14 + 6 = &lt;span class="emphasis"&gt;20&lt;/span&gt;</code> for example).</p> <p>I use <code>var answer = $('tr.problem_display_work:last td:first').html();</code> to get the HTML of that cell, then I use <code>$('#answer').val(answer);</code> to update the value of a hidden <code>&lt;input id="answer"&gt;</code>. </p> <p>When that happens, I'd like to turn <code>14 + 6 = &lt;span class="emphasis"&gt;20&lt;/span&gt;</code> into <code>14 + 6 = 20</code> for the value of the hidden <code>&lt;input id="answer"&gt;</code>, but leave it as <code>14 + 6 = &lt;span class="emphasis"&gt;20&lt;/span&gt;</code> in the table.</p> <p>EDIT FOR CLARIFICATION #4...</p> <p>The key is that any <code>&lt;span&gt;</code>s with the class of <code>emphasis</code> be removed. </p> <p>This.. <code>&lt;span class="emphasis"&gt;&lt;div class="fraction_display"&gt;&lt;span class="numer_display"&gt;21&lt;/span&gt;&lt;span class="bar_display"&gt;/&lt;/span&gt;&lt;span style="border-top-color: green;" class="denom_display"&gt;23&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;</code></p> <p>should end up as... <code>&lt;div class="fraction_display"&gt;&lt;span class="numer_display"&gt;21&lt;/span&gt;&lt;span class="bar_display"&gt;/&lt;/span&gt;&lt;span style="border-top-color: green;" class="denom_display"&gt;23&lt;/span&gt;&lt;/div&gt;</code></p>
34,448,607
0
How to add attachments to mailto in c#? <pre><code>string email ="[email protected]"; attachment = path + "/" + filename; Application.OpenURL ("mailto:" + email+" ?subject=EmailSubject&amp;body=EmailBody"+"&amp;attachment="+attachment); </code></pre> <p>In the above code, <code>attachment</code> isn't working. Is there any other alternative to add attachments using a mailto: link in C#?</p>
31,921,094
0
<p>I think you didn't understood my comment. I mean something like this:</p> <pre><code>&lt;LinearLayout with vertical orientation&gt; &lt;HeaderView/&gt; &lt;HorizontalListView/&gt; &lt;FooterView/&gt; &lt;/End of LinearLayout&gt; </code></pre>
37,071,385
0
<blockquote> <p>increasing the heap size</p> </blockquote> <p>is the way to go. But you also have to check how to do a distribute test; because 12000 is a big test that can't be run only in one machine alone; it is not a good practice.</p> <p><a href="http://jmeter.apache.org/usermanual/jmeter_distributed_testing_step_by_step.pdf" rel="nofollow">http://jmeter.apache.org/usermanual/jmeter_distributed_testing_step_by_step.pdf</a></p>
9,978,987
0
<p>You can have .net give the User's Userpath. Like "C:\Users\User\MyDocuments". Actually, that's what George's link is about. +1 for him.</p>
13,372,952
0
<p>Don't single quote your table name, if anything use magic quotes (`)</p> <p>You should not be building the query by concatenating strings.</p> <p>To avoid potential issues with SQL injection, it would be wise to use prepared queries.</p> <p>I've just confirmed this on a mysql server</p> <pre><code>mysql&gt; delete from 'sessions' where `last_activity` = 0; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''sessions' where `last_activity` = 0' at line 1 mysql&gt; delete from sessions where `last_activity` = 0; Query OK, 0 rows affected (0.00 sec) </code></pre>
9,199,883
0
<identifier> expected <p>i make first steps with android. but i get this error: identifier expeted at "<code>puplic void try(View view)</code>". where is the error?</p> <pre><code> import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.EditText; public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } puplic void try(View view) { String wert; EditText F1 = (EditText)findViewById(R.id.b1); wert = F1.getText().toString(); } } </code></pre>
29,432,061
0
<p>The selector <code>#credentials.errors</code> looks for an element with the ID "credentials" and a class "errors", <em>not</em> an element with the ID "credentials.errors". The dot is being interpreted as the start of a class selector. In other words, it's equivalent to <code>.errors#credentials</code>, with both simple selectors swapped around.</p> <p><code>document.getElementById()</code> works because it simply takes a string as the input ID. It does not try to parse it as a compound selector.</p> <p>To correctly locate the element with an ID selector, you need to escape the dot:</p> <pre><code>driver.findElement(By.cssSelector("#credentials\\.errors")); </code></pre> <p>You can also use an attribute selector instead so you don't have to escape anything:</p> <pre><code>driver.findElement(By.cssSelector("[id='credentials.errors']")); </code></pre>
10,628,885
0
<p>You are using <code>PDO</code> to interface with the database. Use <a href="http://php.net/PDO.lastInsertId"><code>PDO::lastInsertId()</code></a> to get the last inserted id.</p> <pre><code>$stmt-&gt;execute(); echo 'last id was ' . $db-&gt;lastInsertId(); </code></pre> <p><code>mysql_insert_id()</code> is part of the <code>ext/mysql</code> extension. You cannot mix-match functions from both extensions to interface with the same connection.</p>
24,882,173
0
Google Analitics : Send PageViews or Event with PHP <p>I have an website who already use Google Analytics, but it' didn't send page view for Ajax action (a Dynamical search engine for exemple) i don't find an API to send it with PHP by server.</p>
36,072,700
0
<p>If you attach this script to <code>Water</code> particle, and you have a <code>Fire</code> particle, then in your water collision script</p> <pre><code>if (other.gameObject.name=="Fire") { Destroy(other.gameObject); // bonus effect for smoke particles // Instantiate(smokeObject, other.gameObject.transform.position, other.gameObject.transform.rotation); } </code></pre>