pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
34,882,019 | 0 | <p>You need target paragraph thus use <a href="http://api.jquery.com/prev/"><code>.prev()</code></a> then use <a href="http://api.jquery.com/append/"><code>append()</code></a></p> <pre><code>$('div.roundbox').prev('p').append('2015-2016'); </code></pre> |
24,049,572 | 0 | <p>A fix has been submitted which probably addresses your problem. Please pull the latest version of the component and try again.</p> |
29,729,689 | 0 | <p>In the MIDDLEWARE_CLASSES of settings.py, you have <code>'django.middleware.security.SecurityMiddleware',</code>, which is new in Django 1.8. Either make sure Heroku is using Django 1.8, or remove that line from MIDDLEWARE_CLASSES.</p> |
23,717,319 | 0 | <p>You have a syntax error in your code: <code>.navbar ul li a: hover</code> Remove the space after the <code>:</code> and it will work.</p> |
37,451,462 | 0 | How do I validate my email submission on php? <p>I'm just getting into coding and put together a webpage using dreamweaver. I created a php page with my email coding which is executed from a form and submit button on an html page. I continously recieve blank emails on a daily basis which apparently means I need to add validation coding. I tried adding the coding but the problem persists. The page still submits even if the form is blank.</p> <p>Below is my current coding.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code><?php if(!filter_var($_POST['CustomerEmail'], FILTER_VALIDATE_EMAIL)) { $valerrors[] = "The email address you supplied is invalid." ;} $customeremail=$_POST['CustomerEmail']; $email='[email protected]'; $custfirst=$_POST['CustomerFirstName']; $custlast=$_POST['CustomerLastName']; $custphone=$_POST['CustomerNumber']; $custaddress=$_POST['CustomerAddress']; $custcity=$_POST['CustomerCity']; $custstate=$_POST['CustomerState']; $custrequest=$_POST['CustomerService']; $subject='Service Request'; $body = <<<EOD <br><hr><br> Email: $customeremail <br> First Name: $custfirst <br> Last Name: $custlast <br> Phone: $custphone <br> Address: $custaddress <br> City: $custcity <br> State: $custstate <br> Request: $custrequest <br> EOD; $headers = "From: $customeremail\r\n"; $headers .= "Content-type: text/html\r\n"; $Send = mail($email, $subject, $body, $headers); $confirmation = <<<EOD <html>"Thanks for Submitting."</html> EOD; echo"$confirmation"; ?></code></pre> </div> </div> </p> <p>It's possible that I'm placing the if statement in the wrong place. Can someone correct my coding so the confirmation page will not load and the email will not be sent if the customer email is left blank?</p> |
9,735,728 | 0 | How to trace map region while scrolling Map in iPhone <p>I completed to display map view to current location in iPhone with maximize zoom level.</p> <p>But now i want to trace <strong>any scrolling</strong> in map view to get its visible area.</p> <p>Is there any Event to do that if Yes then How??</p> <p>If No the How it possible?</p> |
34,294,017 | 0 | <p>The issue is that DeletionPolicy must be set to one of three strings. And, though your If check will return one of them, from a systematic perspective, it only knows that it's returning a String - but is not guaranteed to be a valid string (same with your map and parameter checks), and thus it only accepts a string literal and not something that resolves to string.</p> <p>I believe that this limitation has been raised to the AWS Engineering team previously, as it is a nuisance. </p> |
546,116 | 0 | <p>Why not just use the UNIQUE attribute on the column in your database? Setting that will make the SQL server enforce that and throw an error if you try to insert a dupe.</p> |
17,293,944 | 0 | <p>They are like two "Tom"s in your class! Because:</p> <p>In this case, <code>"odp" = "odp"</code> because they are <strong>TWO</strong> strings with <strong>SAME</strong> VALUE!!</p> <p>So they are not <code>==</code> because they are <strong>TWO</strong> different strings store in <strong>different</strong> (Memory) <strong>location</strong></p> <p>They are <code>=</code> because they have the <strong>identical string value</strong>.</p> <p>One more step deeper, "odp" is anonymous variable. And two anonymous variable leads to this <strong>Two</strong> strings.</p> <p>For your convenience:</p> <pre><code># "odp" = "odp";; - : bool = true # "odp" != "odp";; - : bool = true # "odp" <> "odp";; - : bool = false </code></pre> |
3,328,794 | 0 | Is there a performance difference between PDO fetch statements? <p>like in</p> <pre><code>/* Exercise PDOStatement::fetch styles */ print("PDO::FETCH_ASSOC: "); print("Return next row as an array indexed by column name\n"); $result = $sth->fetch(PDO::FETCH_ASSOC); print_r($result); print("\n"); print("PDO::FETCH_BOTH: "); print("Return next row as an array indexed by both column name and number\n"); $result = $sth->fetch(PDO::FETCH_BOTH); print_r($result); print("\n"); print("PDO::FETCH_LAZY: "); print("Return next row as an anonymous object with column names as properties\n"); $result = $sth->fetch(PDO::FETCH_LAZY); print_r($result); print("\n"); print("PDO::FETCH_OBJ: "); print("Return next row as an anonymous object with column names as properties\n"); $result = $sth->fetch(PDO::FETCH_OBJ); print $result->NAME; print("\n"); </code></pre> <p>Well the default are FETCH BOTH, I am wondering if FETCH ASSOC is faster when I'm going to fetch a lot of data; or they are the same?</p> <p>Thanks</p> |
15,109,170 | 0 | <p>In addition to what @abarnert said, I today had to find out that the default <code>cpio</code> utility on Mountain Lion uses a different archive format per default (not sure which), even with the man page stating it would use the old cpio/odc format. So, if anyone stumbles upon the <code>cpio read error: bad file format</code> message while trying to install his/her manipulated packages, be sure to include the format in the re-pack step:</p> <pre><code>find ./Foo.app | cpio -o --format odc | gzip -c > Payload </code></pre> |
1,902,402 | 0 | <p>It's possible to set environment variables during the build to alter the path and still have it work in a local environment.</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/ms184806.aspx" rel="nofollow noreferrer">How to: Parameterize the URL for a Web Performance Tests Web Server</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/ms243136%28VS.80%29.aspx" rel="nofollow noreferrer">Testing Web Sites and Web Services in a Team Environment</a></li> </ul> |
27,545,124 | 0 | jQuery file upload plugin error <p>I am trying to implement the basic fileupload from blueimp file upload plugin:</p> <p><a href="http://blueimp.github.io/jQuery-File-Upload/basic.html" rel="nofollow">http://blueimp.github.io/jQuery-File-Upload/basic.html</a></p> <p>each time I run the code ,I select 3 files to upload I get this error: Unable to get property 'files' of undefined or null reference.</p> <p>Can anyone help me with this? Thanks</p> <pre><code>var url = 'FileUploadHandler.ashx?upload=start'; $('#fileupload').fileupload({ dataType: 'json', multipart:true, limitMultiFileUploads: 3, url: url, add: function (e, data) { $.each(data.result.files, function (index, file) { $('<p/>').text(file.name).appendTo('#files'); }); data.submit(); }, progressall: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); $('#progress .progress-bar').css( 'width', progress + '%' ); } }).prop('disabled', !$.support.fileInput) .parent().addClass($.support.fileInput ? undefined : 'disabled'); }); </code></pre> |
14,085,986 | 0 | <p>There can be situations when you will need two different <code>lock</code>'s, which are independent of each other. Meaning when one 'lockable' part of code is locked other 'lockable' should not be locked. That's why there is ability to provide lock objects - you can have several of them for several independent <code>lock</code>'s </p> |
10,441,567 | 0 | JSP download from intranet <p>I need to read binary file from intranet http server and get it to download to public.</p> <p>SCHEMA</p> <p>intranet file server(Apache)=1 <-->Public http server(Apache Tomcat)=2<-->internet authorized user=3 </p> <p>howto release this without save to filesystem on server 2</p> <p>Thanks for answers i am new on java.</p> <p>Sorry for my English.</p> |
6,025,464 | 0 | Reset functions after ajax <p>I have this javascript file: <a href="http://pastebin.com/m2keHsTM" rel="nofollow">http://pastebin.com/m2keHsTM</a></p> <p>A big part of it is a toggle switch that works by sliding your finger or mouse on it. As you see at the end of the document </p> <pre><code>var togglebox = "<div class='toggle_box'></div>"; $('input[type=checkbox]').css('display','none'); $('fieldset[data-input-type=checkbox]').append(togglebox); var mouseDown = false; var beginTouchDown = 0; create_elements(); set_listeners(); </code></pre> <p>replaces the checkboxes on the page by div's that are "slideable" This works great, only when I load another page trough ajax, other new checkboxes do not get replaced. Is there a way to reset those functions and make them check again after an ajax call?</p> <p>Thanks a lot for your help :)</p> |
36,945,788 | 0 | Getting Google API Push Notifications for Resources/Rooms <p>I'm trying to get Google Calendar Push Notifications working for Resources (aka Rooms). They work perfectly for user calendars, but when I call/watch on a Resource, it successfully creates. I get the initial "Sync" call on the server, but then I never hear back from Google again.</p> <p>My approach to creating the watch is to authenticate an administrator, and use that Token to add the watch on the resource that the administrator had added as a calendar to his list, so it's showing up in the calendarList/list call. I've also turned on all notifications on the admin's account for that calendar.</p> <p>Any idea on what I might be doing wrong? </p> |
19,130,036 | 0 | Text reaching over the specified width of its DIV <p>EDIT: Another image to further showcase my issue:</p> <p><a href="http://imageshack.us/photo/my-images/405/cvtc.png/" rel="nofollow noreferrer">http://imageshack.us/photo/my-images/405/cvtc.png/</a></p> <p>I know this question has been asked but every solution I have tried has not worked, i.e.: word-wrap, text-wrap, overflow-wrap.</p> <p>I have text that I have measure to be 344px in width, and would like the rest of my texts to meet that boundary and/or not flow over it. I keep setting this specified width of 344 or even less and this last set of text especially is just causing issues. Here is a screen shot of the issue as well as my HTML and CSS. Any help is appreciated!</p> <p><img src="https://i.stack.imgur.com/amMc0.jpg" alt="http://imageshack.us/photo/my-images/706/1fj8.png/"></p> <p>HTML</p> <pre><code> <!doctype html> <html> <head> <meta charset="UTF-8"> <title>Jessica ___: PORTFOLIO</title> <link rel="stylesheet" type="text/css" href="style1.css"> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript" src="jquery.lettering.js"></script> <link href='http://fonts.googleapis.com/css?family=Quicksand:300,400,700' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=Playfair+Display:700italic' rel='stylesheet' type='text/css'> </head> <body> <div id="letter-container" class="letter-container"> <div id="heading">HELLO</div> <div id="aboutintro">My name is</div> <div id="name">jessica ___</div> <div id="aboutbody">and I'm a student at the College of Design, Architecture, Art, and Planning of the University of Cincinnati and I like to design websites and take pictures.</div> </div> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript" src="jquery.lettering.js"></script> <script type="text/javascript"> $(function() { $("#heading").lettering(); }); </script> <script type="text/javascript"> $(function(){ $("#aboutintro").delay(4000).fadeIn(500); }); </script> <script type="text/javascript"> $(function() { $("#name").lettering(); }); </script> <script type="text/javascript"> $(function(){ $("#aboutbody").delay(6000).fadeIn(500); }); </script> </div> </body> </html> </code></pre> <p>CSS</p> <pre><code> @charset "UTF-8"; /* CSS Document */ html { background: url(grungebg.png) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; margin:0; padding:0; } @font-face { font-family: 'league_gothicregular'; src: url('leaguegothic-regular-webfont.eot'); src: url('leaguegothic-regular-webfont.eot?#iefix') format('embedded-opentype'), url('leaguegothic-regular-webfont.woff') format('woff'), url('leaguegothic-regular-webfont.ttf') format('truetype'), url('leaguegothic-regular-webfont.svg#league_gothicregular') format('svg'); font-weight: normal; font-style: normal; } .letter-container { margin-left:auto; margin-right:auto; width:344px; text-align:center; } #heading { font-family: league_gothicregular, sans-serif; } #heading span { font-size: 200px; background-image: url(mask.png); -webkit-background-clip: text; background-clip: text; color: rgba(0,0,0,0); -webkit-text-fill-color: transparent; -webkit-transition: all 0.3s linear; -moz-transition: all 0.3s linear; -o-transition: all 0.3s linear; -ms-transition: all 0.3s linear; transition: all 0.3s linear; -webkit-animation: sharpen 0.6s linear backwards; -moz-animation: sharpen 0.6s linear backwards; -ms-animation: sharpen 0.6s linear backwards; animation: sharpen 0.6s linear backwards; } #heading span:nth-child(1) { -webkit-animation-delay: 2.2s; -moz-animation-delay: 2.2s; -ms-animation-delay: 2.2s; animation-delay: 2.2s; } #heading span:nth-child(2) { -webkit-animation-delay: 2.6s; -moz-animation-delay: 2.6s; -ms-animation-delay: 2.6s; animation-delay: 2.6s; } #heading span:nth-child(3) { -webkit-animation-delay: 2.9s; -moz-animation-delay: 2.9s; -ms-animation-delay: 2.9s; animation-delay: 2.9s; } #heading span:nth-child(4) { -webkit-animation-delay: 2.4s; -moz-animation-delay: 2.4s; -ms-animation-delay: 2.4s; animation-delay: 2.4s; } #heading span:nth-child(5) { -webkit-animation-delay: 3s; -moz-animation-delay: 3s; -ms-animation-delay: 3s; animation-delay: 3s; } #heading span:nth-child(6) { -webkit-animation-delay: 2.7s; -moz-animation-delay: 2.7s; -ms-animation-delay: 2.7s; animation-delay: 2.7s; } } @keyframes sharpen { 0% { opacity: 0; text-shadow: 0px 0px 100px #fff; color: transparent; } 90% { opacity: 0.9; text-shadow: 0px 0px 10px #fff; color: transparent; } 100% { color: #fff; opacity: 1; text-shadow: 0px 0px 2px #fff, 1px 1px 4px rgba(0,0,0,0.7); } } @-moz-keyframes sharpen { 0% { opacity: 0; text-shadow: 0px 0px 100px #fff; color: transparent; } 90% { opacity: 0.9; text-shadow: 0px 0px 10px #fff; color: transparent; } 100% { color: #fff; opacity: 1; text-shadow: 0px 0px 2px #fff, 1px 1px 4px rgba(0,0,0,0.7); } } @-webkit-keyframes sharpen { 0% { opacity: 0; text-shadow: 0px 0px 100px #fff; color: transparent; } 90% { opacity: 0.9; text-shadow: 0px 0px 10px #fff; color: transparent; } 100% { color: #fff; opacity: 1; text-shadow: 0px 0px 2px #fff, 1px 1px 4px rgba(0,0,0,0.7); } } @-ms-keyframes sharpen { 0% { opacity: 0; text-shadow: 0px 0px 100px #fff; color: transparent; } 90% { opacity: 0.9; text-shadow: 0px 0px 10px #fff; color: transparent; } 100% { color: #fff; opacity: 1; text-shadow: 0px 0px 2px #fff, 1px 1px 4px rgba(0,0,0,0.7); } } #aboutintro { font-family: 'Quicksand', sans-serif; font-size:65px; font-weight:300; color:white; display:none; } #name{ font-family: 'Playfair Display', serif; font-size:65px; font-weight:700; font-style:italic; background-image: url(mask.png); -webkit-background-clip: text; background-clip: text; color: rgba(0,0,0,0); -webkit-text-fill-color: transparent; -webkit-transition: all 0.3s linear; -moz-transition: all 0.3s linear; -o-transition: all 0.3s linear; -ms-transition: all 0.3s linear; transition: all 0.3s linear; -webkit-animation: sharpen 0.6s linear backwards; -moz-animation: sharpen 0.6s linear backwards; -ms-animation: sharpen 0.6s linear backwards; animation: sharpen 0.6s linear backwards; -webkit-animation-delay: 5s; -moz-animation-delay: 5s; -ms-animation-delay: 5s; animation-delay: 5s; text-align:center; } } @keyframes sharpen { 0% { opacity: 0; text-shadow: 0px 0px 100px #fff; color: transparent; } 90% { opacity: 0.9; text-shadow: 0px 0px 10px #fff; color: transparent; } 100% { color: #fff; opacity: 1; text-shadow: 0px 0px 2px #fff, 1px 1px 4px rgba(0,0,0,0.7); } } @-moz-keyframes sharpen { 0% { opacity: 0; text-shadow: 0px 0px 100px #fff; color: transparent; } 90% { opacity: 0.9; text-shadow: 0px 0px 10px #fff; color: transparent; } 100% { color: #fff; opacity: 1; text-shadow: 0px 0px 2px #fff, 1px 1px 4px rgba(0,0,0,0.7); } } @-webkit-keyframes sharpen { 0% { opacity: 0; text-shadow: 0px 0px 100px #fff; color: transparent; } 90% { opacity: 0.9; text-shadow: 0px 0px 10px #fff; color: transparent; } 100% { color: #fff; opacity: 1; text-shadow: 0px 0px 2px #fff, 1px 1px 4px rgba(0,0,0,0.7); } } @-ms-keyframes sharpen { 0% { opacity: 0; text-shadow: 0px 0px 100px #fff; color: transparent; } 90% { opacity: 0.9; text-shadow: 0px 0px 10px #fff; color: transparent; } 100% { color: #fff; opacity: 1; text-shadow: 0px 0px 2px #fff, 1px 1px 4px rgba(0,0,0,0.7); } } #aboutbody { font-family: 'Quicksand', sans-serif; font-size:12px; font-weight:400px; color:#e5e5e5; display:none; margin-left:auto; margin-right:auto; padding:0; margin:0; } </code></pre> |
27,032,258 | 0 | <p>I don't think you can do it from the app level itself, since the push notifications that go to an app are controlled at the OS level (so push notifications for the app, but regardless of what for)</p> <p>However, you can setup tags (or something) on your server so then the app enables/disabled the server to send notifications for a specific topic.</p> <p>Does that make sense?</p> |
18,951,440 | 0 | <p>You can covert the PPT file to HTML:</p> <pre><code>unoconv -o image/ -f html SinoProbe_02_02_001.ppt </code></pre> <p>Then the image folder will fill with HTML and JPG files.</p> |
1,976,841 | 0 | <p>Cookies are sent via the user-agent every time a page is requested. The user-agent doesn't need to be a browser. It could be a small shell script. Even if it is a browser, there's an "edit cookie" extension for Firefox.</p> |
22,849,321 | 0 | <p>Something like this?</p> <p><img src="https://i.stack.imgur.com/IXpfY.png" alt=""></p> <pre><code># generate more illustrative dataset: you have this already set.seed(1) x <- 1:1000 y <- as.POSIXct("06/01/2013",format="%m/%d/%Y")+sample(0:(210*24*60)*60,1000) y <- strftime(y,format="%m/%d/%Y %H:%M") data <- data.frame(ID=x,Starttime=y) # you start here... library(lubridate) # for wday(...) library(ggplot2) library(RColorBrewer) # for brewer.pal(...) data$date <- as.POSIXct(data$Starttime, format="%m/%d/%Y %H:%M") data$dow <- wday(data$date) data$cdow <- wday(data$date,label=T) data$tod <- as.numeric(data$date - as.POSIXct(strftime(data$date,format="%Y-%m-%d")))/60 data$bins <- cut(data$tod,breaks=1:24,labels=F) counts <- aggregate(ID~bins+dow,data,length) colnames(counts)[ncol(counts)] <- "Events" ggplot(counts, aes(x=bins,y=8-dow))+ geom_tile(aes(fill=Events))+ scale_fill_gradientn(colours=brewer.pal(9,"YlOrRd"), breaks=seq(0,max(counts$Events),by=2))+ scale_y_continuous(breaks=7:1,labels=c("Sun","Mon","Tues","Wed","Thurs","Fri","Sat"))+ labs(x="Time of Day (hours)", y="Day of Week")+ coord_fixed() </code></pre> |
21,473,935 | 0 | <p>You can do some thing like the following. </p> <ol> <li><p>Use Parameterized Plugin and pass SVN revision to the down stream project.</p></li> <li><p>In the down stream project, no need to select svn as the source code management tool. Instead, add a first build set up to update your working directory to the revision which is passed from upstream project.</p></li> </ol> <p><code>cd $workspace</code></p> <p><code>svn update -r$pameter</code></p> <p>I have done like this for one of our projects and it is working fine.</p> <p>If you are using clean build, instead of <code>svn update</code> you can use checkout also the same way.</p> <p><code>svn checkout url://repository/path@$parameter</code></p> <p>or</p> <p><code>svn checkout -r $parameter url://repository/path</code></p> |
7,126,722 | 0 | For purpose of EF linq query, is First(c=>cond) equiv to Where(c=>cond).First()? <p>Is there any hidden subtlety, is one perferred, or is one just a shorter way to write the other?</p> <pre><code>Client = db.Clients.First(c=>c.Name == "Client 1") </code></pre> <p>and</p> <pre><code>Client = db.Clients.Where(c=>c.Name == "Client 1").First() </code></pre> |
36,534,366 | 0 | <p>Consider wanting to match the word "march":</p> <pre><code>>>> regex = re.compile(r'\bmarch\b') </code></pre> <p>It can come at the end of the sentence...</p> <pre><code>>>> regex.search('I love march') <_sre.SRE_Match object at 0x10568e4a8> </code></pre> <p>Or the beginning ...</p> <pre><code>>>> regex.search('march is a great month') <_sre.SRE_Match object at 0x10568e440> </code></pre> <p>But if I don't want to match things like <code>marching</code>, word boundaries are the most convenient:</p> <pre><code>>>> regex.search('my favorite pass-time is marching') >>> </code></pre> <p>You might be thinking "But I can get all of these things using <code>r'\s+march\s+'</code>" and you're kind of right... The difference is in what matches. With the <code>\s+</code>, you also might be including some whitespace in the match (since that's what <code>\s+</code> means). This can make certain things like search for a word and replace it more difficult because you might have to manage keeping the whitespace consistent with what it was before.</p> |
6,608,215 | 0 | How to get values from query string and pass it to new page using .htaccess file <p>currently I m using following code in my site in .htaccess file :</p> <pre><code>RewriteRule ^([^/\.]+).php?$ comman.php?cat=$1 [L] </code></pre> <p>This redirects user to comman.php page say, user requests</p> <p><a href="http://www.mysite.com/myfolder/page1.php" rel="nofollow">http://www.mysite.com/myfolder/page1.php</a></p> <p>will redirects to </p> <p><a href="http://www.mysite.com/myfolder/comman.php?cat=page1" rel="nofollow">http://www.mysite.com/myfolder/comman.php?cat=page1</a></p> <p>This works fine. My question is how can I achieve following</p> <p><a href="http://www.mysite.com/myfolder/page1.php?var1=123" rel="nofollow">http://www.mysite.com/myfolder/page1.php?var1=123</a></p> <p>to redirect</p> <p><a href="http://www.mysite.com/myfolder/comman.php?cat=page1&param=123" rel="nofollow">http://www.mysite.com/myfolder/comman.php?cat=page1&param=123</a></p> <p>i.e. whatever value passed to url using get method to add in my new url.</p> <p>Thanks in Advance.....</p> |
22,937,691 | 0 | Generate Word (docx) Files with from Templates (dotx) on Server Application <p>I'm currently working on a project where I have to transfer an existing VB program into a Server Application using ASP.NET. While I had success doing that there's one thing that I'm struggeling with:</p> <p>The VB Program was using Microsoft Word Interop to generate Excel files and fill Word Templates with data. While i managed to be able to generate the files locally with Interop I can't get it to work for somebody that is accessing the Application from a client.</p> <p>I also tried using OpenXML to solve my problem but somehow it always said that the file is corrupt after I tried to fill the bookmarks.</p> <p>In the end the user shoud be able to download the Word document filled with the necessary data.</p> <p>What would be the best solution for this problem?</p> |
15,069,802 | 0 | <p>Is working fine for me, please check the following code:</p> <p>$('input').bind('click mouseup mousedown', function(event) { // some code for a click event</p> <pre><code>if (event.type == 'mousedown'){ console.log('mousedown'); $(this).addClass('active'); } if (event.type == 'mouseup'){ console.log('mouseup'); $(this).removeClass('active'); } //console.log(event.type); </code></pre> <p>}); <a href="http://jsfiddle.net/rpfHw/3/" rel="nofollow">http://jsfiddle.net/rpfHw/3/</a></p> <p>Best</p> |
33,727,457 | 0 | What time format is this: 38793.20139 <p>This data is from scientific tracking data. What is this date format:</p> <p>38793.20139</p> <p>I have looked through all of the stackoverflow datetime format entries I could find.</p> |
34,701,508 | 0 | <p>You have the fade backwards </p> <pre><code> $(".btn--alt").hover( function () { $("#please").fadeOut(); }, function () { $("#please").fadeIn(); } ); </code></pre> <p>See this example:</p> <p><a href="https://jsfiddle.net/pm7dqk5r/" rel="nofollow">fiddle</a></p> |
26,070,327 | 0 | <p>Here's an easy way to do it, using the fact that on the lines in question, if your file follows the same format then the numbers will always appear in the same character of the line. This is a little bit fragile, and it'd be better to make your program more robust, to cope with arbitrary amounts of whitespace, for instance, but I'll leave that as an exercise to you:</p> <pre><code>#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_LEN 100 #define BUY_LEN 9 #define AWARD_LEN 11 int main(void) { FILE * infile = fopen("file.dat", "r"); if ( !infile ) { perror("couldn't open file"); return EXIT_FAILURE; } char buffer[MAX_LEN]; char * endptr; while ( fgets(buffer, MAX_LEN, infile) ) { if ( !strncmp(buffer, "BUY ITEM ", BUY_LEN ) ) { char * num_start = buffer + BUY_LEN; long item = strtol(num_start, &endptr, 0); if ( endptr == num_start ) { fprintf(stderr, "Badly formed input line: %s\n", buffer); return EXIT_FAILURE; } printf("Bought item %ld\n", item); } else if ( !strncmp(buffer, "AWARD ITEM ", AWARD_LEN) ) { char * num_start = buffer + AWARD_LEN; long item = strtol(num_start, &endptr, 0); if ( endptr == num_start ) { fprintf(stderr, "Badly formed input line: %s\n", buffer); return EXIT_FAILURE; } printf("Awarded item %ld\n", item); } } fclose(infile); return 0; } </code></pre> <p>Running this with the sample data file in your question, you get:</p> <pre><code>paul@local:~/src/sandbox$ ./extr Bought item 8 Bought item 10 Awarded item 7 Bought item 1 Bought item 3 Awarded item 9 Bought item 7 paul@local:~/src/sandbox$ </code></pre> <p>Incidentally, based on one of the suggestions in your question, you might want to check out the answers to the question <a href="http://stackoverflow.com/questions/5431941/while-feof-file-is-always-wrong">"<code>while( !feof( file ) )</code>" is always wrong</a>.</p> |
25,633,238 | 0 | Design Pattern to output separate different files from same input parameter <p>I have this Food class with 20 properties. I need to use this Food class and output 3 different files, using variations of these 20 fields. For example, File 1 contains output only 8 fields. File 2 contains 15 fields. File 3 contains 18 fields.</p> <p>So right now, I have these 3 separate methods.</p> <pre><code> FoodService() { void WriteRecommendedFood(IList<Food> foodList); void WriteRecommendedFoodCalculation(IList<Food> foodList); void WriteRecommendedFoodAllEligibleFoods(IList<Food> foodList); } </code></pre> <p>So I'd write:</p> <pre><code> public void WriteRecommendedFood(IList<Food> foodList) { using (StreamWriter sw = new StreamWriter("file.csv", false) { StringBuilder sb = new StringBuilder(); foreach (Food f in foodList) { sb.Append(f.Field1); //Repeat for the # of fields I want to spit out sb.Clear(); sw.WriteLIne(sb.ToString()); } sw.Close(); } } </code></pre> <p>I feel like I'm writing the same code three times (with slight variations). I started to read up on different design patterns like Visitor and Strategy pattern, but I'm not sure which design pattern to improve my code. (Note: I only need to output it to a comma delimited file at this time. Also, from the UI side, the user gets to select which one they want to output (either one to all 3 files.) Any suggestions?</p> |
15,190,532 | 0 | <p>If you want to use pickle you can use the <code>loads</code> and <code>dumps</code> functions.</p> <pre><code>import pickle a_dict = { x:str(x) for x in range(5) } serialized_dict = pickle.dumps(a_dict) # Send it through the socket and on the receiving end: a_dict = pickle.loads(the_received_string) </code></pre> <p>You can also use JSON in a similar fashion. I like JSON because it is human readable and isn't python specific.</p> <pre><code>import json a_dict = { x:str(x) for x in range(5) } serialized_dict = json.dumps(a_dict) # Send it through the socket and on the receiving end: a_dict = json.loads(the_received_string) </code></pre> |
4,249,424 | 0 | Updating rows in DataTable - why isn't this working? <p>I'm trying to update fields in a DataTable. The field I'm trying to edit is a date, I need to format it.</p> <pre><code>foreach (DataRow row in dt.Rows) { string originalRow = row["Departure Date"].ToString(); //displays "01/01/2010 12:00:00 AM" row["Departure Date"] = DateTime.Parse(row["Departure Date"].ToString()).ToString("MM/dd/yyyy"); string newRow = row["Departure Date"].ToString(); //also displays "01/01/2010 12:00:00 AM" } </code></pre> <p>How come this isn't getting updated?</p> |
15,781,823 | 0 | <p>Correction, you're missing the <code>#</code>, and you're missing the <code>/</code> in <code></li></code></p> <pre><code>for(var i=0; i<test.length; i++) { $("#xyz" + i).html('<li>' + test[i] +'</li>'); } </code></pre> |
31,624,081 | 0 | <p>If you are using the new support library for 5.1 in android studio, you can instead use this on your AppCompatActivity</p> <pre><code> ActionBar actionBar = getSupportActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeAsUpIndicator(R.mipmap.ic_arrow_back_white_24dp); actionBar.setDisplayShowHomeEnabled(true); </code></pre> <p>cheers.</p> |
10,515,441 | 0 | <p>Add a check if there's already a video playing, if yes remove it.</p> <pre><code>$(function(){ $('.toggle').click(function(e) { e.preventDefault(); var content = '<video id="my_video"><source src="animation.mp4" type="video/mp4"/> </video>', search = $('video#my_video').length; if(search > 0) { $('video#my_video').remove(); } else { $('#videowrapper').append(content); _V_('my_video', {'controls': true}); } }); }); </code></pre> <p>Something like this should suffice.</p> <p>Thanks for downvoting me, I accidentally pressed tab to make spaces, which took my focus to the post-button, and then I pressed enter cause i wanted a new line, and it posted my post before I was done :P</p> |
22,402,516 | 0 | Update and remove GridView items at runtime <p>i am developing a project where i compare the images of two items,So if two items will have same image after clicking these items should be hide. my code is given below and this code encounter a problem. is this a logical error or any other issue? i try to solve the issue but did't resolve.. Please guide me... here is my main Activity.<br> MainActivity.java </p> <pre><code>public class MainActivity extends Activity { Context ctx; int imagesArray[]; ImageAdapter adapter; List<Integer> pictures; boolean flage = false; GridView gridView; int save1, save2; int img1 = -1, img2 = -1; public int OriginalArray[] = { R.drawable.sample_0, R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_0, R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3 }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final ImageView myimage = new ImageView(ctx); gridView = (GridView) findViewById(R.id.gv_memory); gridView.setAdapter(adapter); shuffleArray(); gridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { // TODO Auto-generated method stub myimage.setImageResource(pictures.get(position)); if (flage == false) { img1 = pictures.get(position); flage = true; } else if (flage == true) { img2 = pictures.get(position); checkResult(); flage = false; } } private void checkResult() { // TODO Auto-generated method stub if (img1 == img2) { adapter.pictureList.remove(img1); adapter.pictureList.remove(img2); adapter.notifyDataSetChanged(); Toast.makeText(MainActivity.this, "Congratualatin !!!!", Toast.LENGTH_LONG).show(); } else { Toast.makeText(MainActivity.this, "Sorry!!!!", Toast.LENGTH_LONG).show(); } } }); } private void shuffleArray() { // TODO Auto-generated method stub pictures = new ArrayList<Integer>(); for (int index = 0; index < OriginalArray.length; index++) { pictures.add(OriginalArray[index]); } Collections.shuffle(pictures); } } </code></pre> <p>ImageAdapter.java </p> <pre><code>public class ImageAdapter extends BaseAdapter { private Context context; List<Integer> pictureList = new ArrayList<Integer>(); public ImageAdapter(Context c) { context = c; for (int i = 0; i < 8; i++) { pictureList.add(R.drawable.question); } } @Override public int getCount() { // TODO Auto-generated method stub return (pictureList.size()); } @Override public Object getItem(int position) { // TODO Auto-generated method stub return pictureList.get(position); } @Override public long getItemId(int position) { // TODO Auto-generated method stub return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub ImageView myimage = new ImageView(context); myimage.setImageResource(pictureList.get(position)); myimage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); myimage.setLayoutParams(new GridView.LayoutParams(70, 70)); return myimage; } } </code></pre> <p>LogCat. </p> <pre><code>03-14 06:09:03.793: D/dalvikvm(2877): GC_FOR_ALLOC freed 54K, 8% free 2771K/2996K, paused 111ms, total 117ms 03-14 06:09:03.802: I/dalvikvm-heap(2877): Grow heap (frag case) to 3.943MB for 1127536-byte allocation 03-14 06:09:03.922: D/dalvikvm(2877): GC_FOR_ALLOC freed 2K, 6% free 3870K/4100K, paused 118ms, total 118ms 03-14 06:09:03.962: D/AndroidRuntime(2877): Shutting down VM 03-14 06:09:03.962: W/dalvikvm(2877): threadid=1: thread exiting with uncaught exception (group=0x41465700) 03-14 06:09:03.972: E/AndroidRuntime(2877): FATAL EXCEPTION: main 03-14 06:09:03.972: E/AndroidRuntime(2877): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.memory/com.example.memory.MainActivity}: java.lang.NullPointerException 03-14 06:09:03.972: E/AndroidRuntime(2877): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211) 03-14 06:09:03.972: E/AndroidRuntime(2877): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 03-14 06:09:03.972: E/AndroidRuntime(2877): at android.app.ActivityThread.access$600(ActivityThread.java:141) 03-14 06:09:03.972: E/AndroidRuntime(2877): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 03-14 06:09:03.972: E/AndroidRuntime(2877): at android.os.Handler.dispatchMessage(Handler.java:99) 03-14 06:09:03.972: E/AndroidRuntime(2877): at android.os.Looper.loop(Looper.java:137) 03-14 06:09:03.972: E/AndroidRuntime(2877): at android.app.ActivityThread.main(ActivityThread.java:5103) 03-14 06:09:03.972: E/AndroidRuntime(2877): at java.lang.reflect.Method.invokeNative(Native Method) 03-14 06:09:03.972: E/AndroidRuntime(2877): at java.lang.reflect.Method.invoke(Method.java:525) 03-14 06:09:03.972: E/AndroidRuntime(2877): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 03-14 06:09:03.972: E/AndroidRuntime(2877): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 03-14 06:09:03.972: E/AndroidRuntime(2877): at dalvik.system.NativeStart.main(Native Method) 03-14 06:09:03.972: E/AndroidRuntime(2877): Caused by: java.lang.NullPointerException 03-14 06:09:03.972: E/AndroidRuntime(2877): at android.view.ViewConfiguration.get(ViewConfiguration.java:318) 03-14 06:09:03.972: E/AndroidRuntime(2877): at android.view.View.<init>(View.java:3264) 03-14 06:09:03.972: E/AndroidRuntime(2877): at android.widget.ImageView.<init>(ImageView.java:112) 03-14 06:09:03.972: E/AndroidRuntime(2877): at com.example.memory.MainActivity.onCreate(MainActivity.java:33) 03-14 06:09:03.972: E/AndroidRuntime(2877): at android.app.Activity.performCreate(Activity.java:5133) 03-14 06:09:03.972: E/AndroidRuntime(2877): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 03-14 06:09:03.972: E/AndroidRuntime(2877): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175) 03-14 06:09:03.972: E/AndroidRuntime(2877): ... 11 more 03-14 06:14:04.503: I/Process(2877): Sending signal. PID: 2877 SIG: 9 </code></pre> |
36,602,276 | 0 | <p>I have found more flexible solution. I have created xlsx file which will be updated once per week with exactly measured cities. My script will read that xlsx file and pull cities from that. On that way I am avoiding empty printed pdf pages. Thanks all!</p> |
15,485,066 | 0 | Condensing repetitive if statements <p>I have the following code, which scans a directory and puts files containing "a" within its filename to a new folder A. Similarly, it puts files with "b" within its filename to a new folder called B. Since the if statements are basically the same, with the only thing that changes being the letter "a" or "b" and being sent to either destA or destb (desitinations), how can I trim this code down? I know there is a better way because much of the code is repeated... Thanks.</p> <pre><code>static void Main() { string path = @"C:\Users\me\Desktop\FOLDER"; string destA = @"C:\Users\me\Desktop\FOLDER\A"; string destB = @"C:\Users\me\Desktop\FOLDER\B"; DirectoryInfo dir = new DirectoryInfo(path); FileInfo[] filesxx = dir.GetFiles(); foreach (FileInfo filexx in filesxx) { if (filexx.Name.Contains("a")) { if (!Directory.Exists(destA)) Directory.CreateDirectory(destA); Console.WriteLine(filexx); filexx.CopyTo(Path.Combine(destA, filexx.Name), true); } else if (filexx.Name.Contains("b")) { if (!Directory.Exists(destB)) Directory.CreateDirectory(destB); Console.WriteLine(filexx); filexx.CopyTo(Path.Combine(destB, filexx.Name), true); } else { Console.WriteLine("Other: ", filexx); } } Console.Read(); } </code></pre> |
31,011,211 | 0 | <p>It's crashing because you have not initialized Sport *one; and you're attempting to call methods on a null pointer. You need to first create a Running object within the Activity constructor using the "new" operator like so:</p> <pre><code>one = new Running(n, time); </code></pre> <p>Create an overloaded constructor in your "Running" class that takes the appropriate arguments as well, so that you can initialize your variable as shown above.</p> |
37,956,697 | 0 | <p>You can aggregate (use <code>max</code> or <code>min</code> etc) in the same query.</p> <pre><code>select VisitIDCode ,MAX(CASE WHEN LeftJustifiedLabel = 'Additional Intervention Information' Then ValueText End) As 'Additional Intervention Information' ,MAX(CASE WHEN LeftJustifiedLabel = 'American Cancer Society Comment:' Then ValueText End) As 'American Cancer Society Comment:' ,MAX(CASE WHEN LeftJustifiedLabel = 'Intevention' Then ValueText End) As 'Intevention' From #AssessmentFS group by VisitIDCode </code></pre> |
18,591,764 | 0 | <pre><code>/// <summary> /// Returns a collapsed visibility when the price is less than or equal to the comparison price. /// </summary> public class PriceToVisibilityConverter : IValueConverter { private const double comparePrice = 2000; public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { double price; if (double.TryParse(value.ToString(), out price)) { return price > comparePrice ? Visibility.Visible : Visibility.Collapsed; } return Visibility.Collapsed; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } </code></pre> <p>in your app.xaml</p> <pre><code><Application.Resources > <ResourceDictionary> <converter:PurchaseStatusConverter xmlns:converter="clr-namespace:namespacetoyourtype" x:Key="PurchaseStatusConverter" /> <converter:PriceToVisibilityConverter xmlns:converter="clr-namespace:namespacetoyourtype" x:Key="PriceToVisibilityConverter" /> <ResourceDictionary> </Application.Resources > </code></pre> <p>In your xaml</p> <pre><code><TextBlock Name="price" Vis Text="Some text" Visibility="{Binding Price, Converter={StaticResource PriceToVisibilityConverter}}" TextWrapping="Wrap" FontSize="24" /> </code></pre> |
25,144,180 | 0 | <p>Your issue is with attempting to change your month by adding 1. 1 in date serials in Excel is equal to 1 day. Try changing your month by using the following:</p> <pre><code>NewDate = Format(DateAdd("m",1,StartDate),"dd/mm/yyyy") </code></pre> |
28,952,453 | 0 | <p>If you are using Laravel 5, you can do it like this (I am not sure if it is the best way)</p> <pre><code>return view("layout/here", [ "content" => view("dynamic/content/here") ]); </code></pre> <p>then in your view you can do this</p> <pre><code> <?php echo $content; ?> </code></pre> <p>of course, if you are not using blade.</p> |
12,957,040 | 0 | wp_ajax_ actions that use object-oriented action handlers? <p>I'm trying to pass an ajax action to /wp-admin/admin-ajax.php, however I can't seem to get it to call any functions that use a class to encapsulate the namespace. I get the following error:</p> <pre><code>Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'PHP_faq_backend' not found in /wp-includes/plugin.php </code></pre> <p>My action is as follows:</p> <pre><code>add_action('wp_ajax_edit_form', array('PHP_faq_backend', 'edit_form')); </code></pre> <p>Obviously I don't want to force this by modifying the admin-ajax.php file, but how do I get my classfiles loaded so the action will work?</p> |
15,754,009 | 0 | <p>Edit: I updated the code to work better.</p> <p>I'm unsure exactly what the issue is but looking at your code I wouldn't be surprised that the negative look behind regex isn't matching multiple word strings where the "keyword" is not the first word after the src or alt. It might possible to beef up the regex, but IMHO a complicated regex might be a little too brittle for your html parsing needs. I'd recommend doing some basic html parsing yourself and doing a simple string replace in the right places.</p> <p>Here's some basic code. There is certainly a much better solution than this, but I'm not going to spend too much time on this. Probably, rather than inserting html in a text node, you should create a new html <code>a</code> element with the right attributes. Then you wouldn't have to decode it. But this would be my basic approach.</p> <p> <pre><code>$text = "Lorem ipsum <img src=\"lorem ipsum\" alt=\"dolor sit amet\" /> dolor sit amet"; $result = array( array('keyword' => 'lorem', 'link' => 'http://www.google.com'), array('keyword' => 'ipsum', 'link' => 'http://www.bing.com'), array('keyword' => 'dolor sit', 'link' => 'http://www.yahoo.com'), ); $doc = new DOMDocument(); $doc->loadHTML($text); $xpath = new DOMXPath($doc); foreach($result as $row) { if (!empty($row['keyword'])) { $search = $row['keyword']; $replace = '<a href="'.$row['link'].'.html" class="ared">'.$row['keyword'].'</a>'; $text_nodes = $xpath->evaluate('//text()'); foreach($text_nodes as $text_node) { $text_node->nodeValue = str_ireplace($search, $replace, $text_node->nodeValue); } } } echo html_entity_decode($doc->saveHTML()); </code></pre> <p>The <code>$result</code> data structure is meant to be similar to result of your <code>mysql_fetch_array()</code>. I'm only getting the children of the root for the created html DOMDocument. If the <code>$text</code> is more complicated, it should be pretty easy to traverse more thoroughly through the document. I hope this helps you.</p> |
7,884,847 | 0 | <p>You can pass command line parameters with ClickOnce. You could have one normal link and then one link that contains a command line parameter that you can read in the startup to activte the app after they login (or any action you want).</p> |
24,884,532 | 0 | <p>I did not realize that the BaseEntity also had a <a href="http://symfony.com/doc/current/reference/constraints/Callback.html" rel="nofollow">callback validator</a>.</p> <pre><code>/** * @ORM\Entity ... * @Assert\Callback(callback="validate") */ abstract class Approval { ... /** * @param ExecutionContextInterface $context */ public function validate(ExecutionContextInterface $context) { // some logic messing with my AssertNotBlank constraints } } </code></pre> <p>I added what I wanted to do with the validation groups there as well. I suppose it should be possible to work with them as well.</p> |
5,737,957 | 0 | Assert that an instance method is called once in the controller <p>I am trying to assert that an instance method is called on a certain controller action once. The test does not work for some reason. The code does indeed do what it is supposed to.</p> <p>I am using Rspec 1.x and factory_girl </p> <p>Test</p> <pre><code>context 'as a regular API user' do before do login_as_regular_user Feed.superfeedr_api.stub!(:pingable?).and_return(true) @feed_entry = Factory(:feed_entry) post :read, :id => @feed_entry.id, :format => 'json' end it "should call read_by method once" do @user = Factory.create(:user) controller.stub!(:current_account).and_return(@user.account) @feed_entry.should_receive(:read_by).once post :read, :id => @feed_entry.id, :format => 'json' end it { should respond_with(204)} it { should assign_to(:feed_entry).with(@feed_entry) } it { should respond_with_content_type(/json/) } end </code></pre> <p>Controller</p> <pre><code># POST /entries/1234/read - mark as read # DELETE /entries/1234/read - mark as unread def read if request.post? @feed_entry.read_by(current_account) elsif request.delete? @feed_entry.unread_by(current_account) end respond_to do |format| format.html { redirect_to topic_path(params[:topic_id]) } format.json { render :nothing => :true, :status => :no_content } format.plist { render :nothing => :true, :status => :no_content } end end </code></pre> <p>Error</p> <pre><code>1) Spec::Mocks::MockExpectationError in 'FeedEntriesController.read as a regular API user should call read_by method once' #<FeedEntry:0x107db8758> expected :read_by with (any args) once, but received it 0 times ./spec/controllers/feed_entries_controller_spec.rb:82: Finished in 2.242711 seconds 25 examples, 1 failure, 3 pending </code></pre> |
9,006,017 | 0 | <p>The problem you face is that you wish to go to the bottom of your page which has not loaded yet. I would consider loading the page in a hidden format then show it when it has all loaded and after scrolling the user at the location you want. Use the focus or scroll to methods.</p> <p>Take a look at the filament group website.</p> <p><a href="http://filamentgroup.com/" rel="nofollow">http://filamentgroup.com/</a> </p> <p>they hide the page with a loading screen until it is ready.</p> <p>This way there is no jerk.</p> <p>Hope this helps.</p> |
25,803,471 | 0 | <p>This is the same case as with forward declaration of class/struct type:</p> <pre><code>struct node; struct node* node_ptr; /* is valid */ struct node node_instance; /* is invalid */ </code></pre> <p>So <code>struct node;</code> basically says: hey there is a structure defined somewhere outside this file. The type is valid, pointers may be used, but you cannot instantiate the object.</p> <p>This is because the size of the pointer is known and is specific to the target architecture (e.g. 32 or 64-bit). The size of the structure is unknown until declared.</p> <p>When you declare the type completey, then you will be allowed to declare the object of that type:</p> <pre><code>struct node { int a; struct node* b; /* this will work, but the size of struct is unknown yet */ } struct node* node_ptr; /* this works always with full and forward declarations */ struct node node_object; /* now, the size of struct is known, so the instance may be created */ </code></pre> |
7,949,518 | 0 | <p>Ha, figured it out. The progress bar at 0% width was wrapping the overflow text onto multiple lines. Fix was using <code>white-space: nowrap;</code> on the progress bar text</p> |
2,234,428 | 0 | <p>In your form, you want PHP to treat your input as an array, so change your HTML like so-> add [] after the name. </p> <pre><code><input name="price[]" type="checkbox" value="" /> </code></pre> <p>Then in PHP just access the form variable name like you normally would and loop through the values and sum them. </p> |
37,858,254 | 0 | <p>check with this code </p> <pre><code>override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { if(self.courses.count > 0){ tablecount = self.courses.count } else { tablecount = 0 self.table.reloaddata() } return tablecount } </code></pre> |
31,434,699 | 0 | How to use xpath in camel when the outermost element has an xmlns attribute? <p>I am having some trouble using xpath to extract the "Payload" values below using apache-camel. I use the below xpath in my route for both of the example xml, the first example xml returns SomeElement and SomeOtherElement as expected, but the second xml seems unable to parse the xml at all. </p> <pre><code>xpath("//Payload/*") </code></pre> <p>This example xml parses just fine.</p> <pre><code><Message> <Payload> <SomeElement /> <SomeOtherElement /> </Payload> </Message> </code></pre> <p>This example xml does not parse.</p> <pre><code><Message xmlns="http://www.fake.com/Message/1"> <Payload> <SomeElement /> <SomeOtherElement /> </Payload> </Message> </code></pre> <p>I found a similar <a href="http://stackoverflow.com/questions/5856245/how-to-select-xml-root-node-when-root-node-has-attribute">question</a> about xml and xpath, but it deals with C# and is not a camel solution. </p> <p>Any idea how to solve this using apache-camel?</p> |
23,808,539 | 0 | <p>Re : 'how' is this used - one place we are finding this useful is when dealing with java api mappings where <code>null</code> is commonplace, e.g. on jdbc prepared statements to nullable sql columns. The <code>Option</code>al internal model fields can be mapped:</p> <pre><code>stmt.setDate("field", myModel.myDateField.orNull) </code></pre> <p>Instead of the more verbose:</p> <pre><code>stmt.setDate("field", myModel.myDateField.getOrElse(null)) </code></pre> |
15,065,043 | 0 | <p>This is quite simple.</p> <ol> <li>Get maximum and minimum values of latitude and longitude.</li> <li>generate random value of longitude (use uniform distribution).</li> <li>generate random value of latitude (you can use uniform distribution or take into account shape of the earth).</li> <li>check if random point is inside of polygon, if not then try again.</li> </ol> |
41,024,130 | 0 | Filter the array with another array containing the names to be filtered from the first array <pre><code>input : ['Ram', 'Shyam' , 'Hari' , 'Gopal' , 'Hawa'] ['Shyam' , 'Hawa'] output: ['Ram' , 'Hari' , 'Gopal'] </code></pre> |
27,035,659 | 0 | view state MAC validation failed <p>I made one web application in asp.net. It works fine but some time it shows the error Validation of view state MAC failed. After refreshing the page all works fine. This error comes at least once in a day. Can any one please help.</p> |
38,015,203 | 0 | <p>Starting from iOS 10, <strong>it's mandatory to add "NSCameraUsageDescription"</strong> in info.plist which is just an informatory message to the user stating the reason for accessing camera. It will be displayed to the user while trying to access the camera.</p> <p>Though this key is existing since iOS 7, it has been made mandatory in iOS 10 beta. Please refer to below Apple reference link.</p> <p><a href="https://developer.apple.com/library/prerelease/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW15" rel="nofollow">https://developer.apple.com/library/prerelease/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW15</a></p> |
27,023,669 | 0 | <p>That's not the strict solution to the issue. </p> <p>What's happening is that you have only one server block and it becomes the default server block for all requests, even the ones not matching the server name. You simply need to add a default server block in your configuration :</p> <pre><code>server { listen 80 default_server; } </code></pre> <p>By the way, you have a typo (semicolon before <code>permanent</code>) and you don't need a rewrite as you have specific regular expression. Use this instead :</p> <p><code>return 301 http://www.example.net$request_uri;</code></p> |
32,940,478 | 0 | <p>First off you are looping through your calculateAverage funtion 4 times. Are you doing this on purpose? I think you should only do this once. </p> <p>Second, in your while loop</p> <pre><code>while (grade <= 100 && grade != -1) { numberofGrades++; sumofGrades += grade; average = sumofGrades / numberofGrades; } </code></pre> <p>you are infinitely looping. This will loop forever if a value other than -1 is entered. This should be changed to an if statement.</p> <pre><code>if (grade <= 100 && grade != -1) </code></pre> <p>But there is a better way to write this code (if I am guessing what you actually want it to do)</p> <pre><code>#include <stdio.h> float calculateAverage (int sum, int size); int main(void) { int input; int sum = 0; int count = 0; while (input != -1 && input >= 0 && input <= 100) { printf ("Enter a Grade: "); scanf ("%d", &input); if (input != -1) { sum += input; count++; } } float average = calculateAverage(sum, count); return 0; } float calculateAverage (int sum, int count) { // Do your average math here.... } </code></pre> |
3,121,776 | 0 | <blockquote> <p>I'm willing shut the app down when they try but need to do some things first.</p> </blockquote> <p>Having necessary steps at program shutdown leads to fragile programs that break easily. Even if you could prevent someone from killing your program via the task manager, you cannot stop them from turning off the computer, or even pulling the cable out of the wall. Whatever task that was so vitally important to complete will be lost. And what if there is a power cut? Again your task won't complete and your vital clean up code will not be run.</p> <p>Instead you should make your program robust to failures at any point. Use transactions, and always save state to files atomically - make sure that you always have at least one valid copy of your data. Don't overwrite important files in a way that they become temporarily invalid.</p> <p>Finally, you can add a dialog box to your program that when they try to close it, warns them that the program needs to shut down properly. If you make your shutdown fast users won't want to kill it and will let it terminate properly. If your shutdown takes ages then people will try to kill it. If you are nice to your users, they will be nice to you too.</p> <p>If shutting down fast means that the user will lose some unfinished work then warn them about this and give them the opportunity to wait for the task to finish, but if they really want to quit your program then let them quit.</p> |
23,201,155 | 0 | How to choose specific columns when using depth in serializer <p>I have a model which consists of two <code>ForeignKeys</code>. I am only interested in parsing the content of the <code>ForeignKeys</code>, so i'm using the <code>depth</code> variable, which basically gives me all columns of the tables referenced with the FK. Is there a way to select which columns there should be included?</p> <pre><code>class SomeSerializer(serializers.ModelSerializer): class Meta: model = MyAwesomeModel fields = ('id', 'fk_one','fk_two') depth = 1 </code></pre> |
8,105,280 | 0 | <h2>Solution</h2> <p>Use <code>min-width</code>.</p> <h3>Sample</h3> <p><a href="http://jsfiddle.net/z4PWU/" rel="nofollow">http://jsfiddle.net/z4PWU/</a></p> <h3>HTML</h3> <pre><code><!-- Empty floating divs --> <div></div> <div></div> <div></div> <br /> <!-- Non-Empty floating divs --> <div>&nbsp;</div> <div>&nbsp;</div> <div>&nbsp;</div> <br /> <!-- min/max width for floating divs --> <div style="min-width:50px;"></div> <div style="min-width:50px;"></div> <div style="min-width:50px;"></div> </code></pre> <h3>CSS</h3> <pre><code>div { float: left; border: 1px solid blue; height: 15px; /* Make them better visible */ } </code></pre> |
9,071,665 | 0 | <p>You appear to have an extra <code>DECLARE</code> after your connect statement.</p> |
619,714 | 0 | <p>The purpose of handlers in non-MVC projects is to provide some type of encoded response, outside of HTML. Typically, a handler would return XML (rss, RESTful, etc), JSON for jQuery or other Javascript, or sometimes just pure data such as file binary downloads. I've used handlers to even return special javascript to be excuted on the client, as a way of lazy-loading large binary or requirements on a "demand-only" approach. More or less, a handler would be used to return "anything but HTML".</p> <p>In MVC, you would move away from handlers and utilize the Controller to return whatever data you like. So, in the method like:</p> <pre><code>mywebsite.com/restapi/content/56223 </code></pre> <p>You RestfulContentController would have a method for Index(), that would NOT return a View(), but instead pure XML or JSON.</p> <pre><code>public class JSONContentController : Controller { public JsonResult Index(int ContentID) { // get Content() by ContentID // // return a JSON version return Content().SerializeToJSON(); } } </code></pre> |
19,548,077 | 0 | <p>If you want to test this method, you may <a href="http://stackoverflow.com/a/34586/1851024">consider making it public/protected/package local</a>. Then you'll be able to mock or overload it in a subclass you are to test.</p> |
25,997,467 | 0 | Ajax is not updating data <p>I've got a forum in which user is allowed to edit and delete only his comments, I've defined an "edit" button, that by a click of mouse brings down a modal, and in that modal user is allowed to get access to the data's he/she has been sent before, I've written an ajax to target these field and update them whenever the users clicks on "edit" button, code totally makes sense, but so far the functionality doesn't, to make it more clear, user clicks, modal comes down, whatever he/she has been posted will appear in fields, and there is an "edit" button at the bottom of modal, which is responsible for changing and updating data. here is the modal code : </p> <pre><code> <button id="btn-btnedit" class="btn btn-primary " data-toggle="modal" data-target="#myModal<?php echo $list['id']; ?>"> Edit <i class="fa fa-pencil-square-o"></i> </button> <!-- Modal --> <div class="modal fade" id="myModal<?php echo $list['id']; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button> <h4 class="modal-title" id="myModalLabel">Modal title</h4> </div> <div class="modal-body"> <div class="container"> <form style="width: 550px;" action="" method="post" id="signin-form<?php echo $list['id']; ?>" role="form"> <input type="hidden" name="commentID" value="<?php echo $list['id']; ?>"> <div class="from-group"> <label for="title">Title: </label> <input class="form-control" type="text" name="title" id="txttitle" value="<?php echo $list['title']; ?>" placeholder="Page Title"> </div> <div class="from-group"> <label for="label">Label: </label> <input class="form-control" type="text" name="label" id="txtlabel" value="<?php echo $list['label']; ?>" placeholder="Page Label"> </div> <br> <div class="from-group"> <label for="body">Body: </label> <textarea class="form-control editor" name="body" id="txtbody" row="8" placeholder="Page Body"><?php echo $list['body']; ?></textarea> </div> <br> <input type="hidden" name="editted" value="1"> <br> <br> <input type="submit" id="btnupdate" value="Edit"> </form> </div> </div> </code></pre> <p>as you can see I've assigned "editted" to my "name" attribute, which is later on used to call the query in the database, sql code is as below : </p> <pre><code> case 'postupdate'; if(isset($_GET['editted'])){ $title = $_GET['title']; $label = $_GET['label']; $body = $_GET['body']; $action = 'Updated'; $q = "UPDATE posts SET title ='".$title."', label = '".$label."', body = '".$body."' WHERE id = ".$_GET['commentID']; $r = mysqli_query($dbc, $q); $message = '<p class="alert alert-success"> Your Post Is Succesfully '.$action.'</p>' ; } </code></pre> <p>and here is the ajax code snippet; </p> <pre><code> $('#btnupdate').click(function() { var tempTitle = $('#txttitle').val(); var tempLabel = $('#txtlabel').val(); var tempBody = $('#txtbody').val(); var tempUrl = "index.php?page=postupdate"+"&title="+tempTitle+"&label="+tempLabel+"&body="+tempBody+"&commentID=30&editted=1"; $.get(tempUrl); }); </code></pre> <p>I assume there is nothing advance about this segment of code, and i'm missing something very simple, any consideration is highly appreciated :)</p> |
13,226,987 | 0 | <p>You need to explicitly define getter/setter in your interface. In our case (without changing structure and idea):</p> <pre><code>trait Node { def next: Node def next_=(node: Node) } // `var next: Node` generates implementations for `def next: Node` and `def next_=(node: Node)` case class SpecificNode(var next: Node) extends Node object NullNode extends Node { def next = throw new Exception("no more node") def next_=(node: Node) { throw new Exception("can't change next on null node") } } val n1 = SpecificNode(NullNode) val n2 = SpecificNode(SpecificNode(NullNode)) val n3: Node = SpecificNode(n1) // some function to test our structure: def length(n: Node, prev: Int = 0): Int = if (n == NullNode) prev else length(n.next, prev + 1) println(length(n3)) n3.next = n2 println(length(n3)) </code></pre> <p>Side note: this is mutable linked list, I suggest you to check how immutable list implemented in standard scala library</p> |
29,704,404 | 0 | <p>Maybe you need:</p> <pre><code>$.ajax({ url: "test.html", error: function(){ // will fire when timeout is reached }, success: function(){ //do something }, timeout: 3000 // sets timeout to 3 seconds }); </code></pre> <p>[READ] <a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow">http://api.jquery.com/jQuery.ajax/</a></p> <p>You can specify the timeout as a property.</p> |
15,252,203 | 0 | can I check my cookies to decide what page to load in RegisterRoutes <p>I want to read the cookie to see if they have been to the site before and then decide where they should go at that point.</p> <p>If not cookie, then load default page.</p> <p>Would I handle this in the RegisterRoutes?</p> <p>Here is what I currently have:</p> <pre><code> public class MvcApplication : HttpApplication { public static void RegisterGlobalFilters(GlobalFilterCollection filters) { //filters.Add(new HandleErrorAttribute()); } public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Account", action = "Logon", id = UrlParameter.Optional } ); } protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); } } </code></pre> <p>Do I change the RegisterRoutes to decided where to go from here or would I do this elsewhere?</p> |
16,857,018 | 0 | <p>You can use php libraries tcpdf or dompdf for your need. Both will work fine for your need. <strong>TCPDF</strong> is better than <strong>dompdf</strong> for using <code>DIV</code></p> |
2,809,934 | 0 | <p>As they always say, have a look at the MMAPI docs. forum Nokia has good examples of this for the MMAPI. </p> <p>But first you can check your code by adding: </p> <pre><code>p.realize(); p.prefetch(); </code></pre> <p>To pause / stop the player call <code>p.stop()</code>. </p> <p>To get the current position call <code>p.getMediaTime();</code> To get the full duration of the file call <code>p.getDuration();</code></p> <p>From those you can calculate the progress. </p> <p>To control volume: </p> <pre><code>import javax.microedition.media.Player; import javax.microedition.media.Manager; import javax.microedition.media.*; import javax.microedition.media.control.VolumeControl; private VolumeControl vc; public void changeVolume(int diff) { VolumeControl vc; if ( p != null) { vc = (VolumeControl) p.getControl("VolumeControl"); if (vc != null) { int cv = vc.getLevel(); cv += diff; cv = vc.setLevel(cv); } } } </code></pre> <p>Define your player class to implement runnable, and control it in its own thread. </p> <p>Have a look at: <a href="http://www.java-tips.org/java-me-tips/midp/" rel="nofollow noreferrer">http://www.java-tips.org/java-me-tips/midp/</a></p> <p>Hope this helps.</p> |
706,160 | 0 | <p>In your code $row is a an object (you've used mysql_fetch_object), and the .= operator tries to build a string, concatenating $liResult and $row. I believe this behaviour only works if your object implements a <a href="http://uk3.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring" rel="nofollow noreferrer">toString method</a></p> <p>You could return an array of rows using this code:</p> <pre><code>public function fetchObject($psClassname ="",$paParams =array()){ $lrResource = $this->mrQueryResource; $liResult = array(); while($row = mysql_fetch_object($lrResource,$psClassname,$paParams)){ $liResult[] = $row; } return $liResult; } </code></pre> |
40,805,460 | 0 | javascript - onclick() requires two clicks to trigger event <p>My problem is that when <code>onclick()</code> is triggered the first time, nothing happens, but when it is clicked a second time, the code is executed.</p> <p>The <code>onclick()</code> should turn the <code><div></code> into a png image file and save it to the computer.</p> <p>HTML (the TableDay function refers to a function I wrote which basically makes it easier to create the table):</p> <pre><code><div id="TableDiv"> <table id="Table"> <tr> <th>Dag\Uur</th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>8</th><th>9</th> </tr> <?php TableDay("Maandag",1); TableDay("Dinsdag",10); TableDay("Woensdag",19); TableDay("Donderdag",28); TableDay("Vrijdag",37); ?> </table> </div> <a id="Image" href="##" onclick="printTable()">Download</a> </code></pre> <p>(Text is Dutch)</p> <p>The <code>onclick="printTable()"</code> refers to the following Javascript code:</p> <pre><code><script> var element = $("#TableDiv"); // global variable var getCanvas; // global variable function printTable() { html2canvas(element, { onrendered: function (canvas) { getCanvas = canvas; }}); var imgageData = getCanvas.toDataURL("image/png"); // Now browser starts downloading it instead of just showing it var newData = imgageData.replace(/^data:image\/png/, "data:application/octet-stream"); $("#Image").attr("download", "Rooster.png").attr("href", newData); } </script> </code></pre> <p>What is happening exactly and how can I make it so that the <code><a></code> reference in the html code only needs to be clicked once?</p> |
20,910,991 | 0 | <p>In HTML GridView render as table , better you can use Jquery to add the values ,</p> <pre><code>var total=0; $('#gridview1').find('tr td').each(function(i, td){ var data= parseInt( $(td).val()); total+=data; }); </code></pre> |
3,433,282 | 0 | How is Java's for loop code generated by the compiler <p>How is Java's for loop code generated by the compiler?</p> <p>For example, if I have:</p> <pre><code>for(String s : getStringArray() ) { //do something with s } </code></pre> <p>where <code>getStringArray()</code> is a function that returns the Array I want to loop on, would function be called always or only once? How optimal is the code for looping using this construct in general?</p> |
14,182,437 | 0 | <p>While inserting a contact into RAW Contact table, provide A AccountType and accountName.</p> <pre><code> final ContentProviderOperation.Builder newContact = ContentProviderOperation .newInsert(RawContacts.CONTENT_URI); newContact.withValue(RawContacts.ACCOUNT_TYPE, rawContact.accountType); newContact.withValue(RawContacts.ACCOUNT_NAME, rawContact.accountName); newContact.withValue(RawContacts.AGGREGATION_MODE, RawContacts.AGGREGATION_MODE_DISABLED); </code></pre> |
24,905,558 | 0 | <p>If you use Smarty you shouldn't do such thing at all. What's the point of using Smarty and putting HTML code into PHP? There is none.</p> <p>You should use <code>fetch()</code> instead</p> <p>You can do:</p> <pre><code>function test($smarty){ return $smarty->fetch('testtemplate.tpl'); } $smarty->assign('mycode', test($smarty)); </code></pre> <p>And in <code>testtemplate.tpl</code> you can simply put:</p> <pre><code><div style="font-size:13px;font-family:Arial"> <a href='google.com'>sasa</a> </div> </code></pre> <p>In Smarty you have 2 methods:</p> <p><code>display()</code> - for displaying template</p> <p><code>fetch()</code> - to fetch template into string and then do anything you want with it</p> |
35,680,347 | 0 | <p>The standard Javascript way is to pass an "options" object like</p> <pre><code>info({spacing:15, width:46}); </code></pre> <p>used in the code with</p> <pre><code>function info(options) { var spacing = options.spacing || 0; var width = options.width || "50%"; ... } </code></pre> <p>as missing keys in objects return <code>undefined</code> that is "falsy".</p> <p>Note that passing values that are "falsy" can be problematic with this kind of code... so if this is needed you have to write more sophisticated code like</p> <pre><code>var width = options.hasOwnProperty("width") ? options.width : "50%"; </code></pre> <p>or</p> <pre><code>var width = "width" in options ? options.width : "50%"; </code></pre> <p>depending on if you want to support inherited options or not.</p> <p>Pay also attention that every object in Javascript inherits a <code>constructor</code> property, so don't name an option that way.</p> |
14,681,174 | 0 | <p>From Javascript you shouldcatch the event <code>window.onbeforeunload</code></p> |
5,233,366 | 0 | <p>A couple ideas:</p> <ol> <li><p>Sometimes this can happen if there are oddities with your system clock or modified dates on the files. Try resetting the modified date. Maybe the easiest way is by zipping up the project, then extracting over top. Also of course delete your <code>.suo</code> and <code>.ncb</code> files.</p></li> <li><p>Make sure the <code>.h</code> file is IN the project tree. If it's <code>#include</code>d, but not specifically in the project tree, I don't believe VS will recognize changes always.</p></li> </ol> |
34,670,145 | 0 | Generating an edge list from ID and grouping vectors <p>I have a data frame of 205,000+ rows formatted as follows:</p> <pre><code>df <- data.frame(project.id = c('SP001', 'SP001', 'SP001', 'SP017', 'SP018', 'SP017'), supplier.id = c('1224', '5542', '7741', '1224', '2020', '9122')) </code></pre> <p>In the actual data frame there are 6700+ unique values of <code>project.id</code>. I would like to create an edge list that pairs suppliers who have worked on the same project.</p> <p>Desired end result for <code>project.id = SP001</code>:</p> <pre><code>to from 1224 5542 1224 7741 5542 7741 </code></pre> <p>So far I've tried using <code>split</code> to create a list by project.id and then running <code>lapply+combn</code> to generate all possible combinations of <code>supplier.id</code> within each list/group:</p> <pre><code>try.list <- split(df, df$project.id) try.output <- lapply(try.list, function(x) combn(x$supplier.id, 2)) </code></pre> <p>Is there a more elegant/efficient (read "computed in less than 2hrs") way to generate something like this?</p> <p>Any help would be much appreciated</p> |
13,470,391 | 0 | Need assistance regarding objective-c and opps concept <p>Currently I am working on messaging app, which send text messages, image and audio files.</p> <p>Files get uploaded on http server, for downloading and uploading I am using NSURLConnection. </p> <p>When user tap download button I extract out the cell of table view and add progressview as a subview like this</p> <p><strong>In header file</strong></p> <pre><code>@property (strong, nonatomic) UIProgressView *progress; </code></pre> <p><strong>In Class File my download method</strong></p> <pre><code>progress = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleBar]; progress.trackTintColor = [UIColor grayColor]; progress.frame = CGRectMake(10, 50, 160, 30); progress.progress = 0.0; [cell addSubview:progress]; </code></pre> <p><strong>When data is received this NSURLConenction delegate method get called</strong></p> <pre><code>-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { if(imgUpload) { NSLog(@"UPLOAD"); } else { [self.resourceData appendData:data]; NSNumber *resourceLength = [NSNumber numberWithUnsignedInteger:[self.resourceData length]]; [self.progress setProgress:[resourceLength floatValue] / [self.filesize floatValue] animated:YES]; } } </code></pre> <p>If there are more then one file and every time user tap on the download button this whole code will execute and progressview will be added to that cell, but all are referred through <strong>progress</strong> variable. <strong>How every individual progressview is identified uniquely</strong>. If I try to download three files all progressview indicate there own progress and works fine.</p> <p>Please clear this concept.</p> <p><strong>Yes under the hood data is messing up, I tried to download audio and image file together but ended up with corrupt files.</strong></p> <p><strong>Please provide a example how to solve this issue.</strong></p> |
39,164,377 | 0 | <p>Change the following line:</p> <pre><code>return view('welcome')->withRestaurants($restaurants); // there is nothing like withRestaurants in laravel </code></pre> <p>to </p> <pre><code>return view('welcome', array('restaurants' => $restaurants)); </code></pre> <p>and try again.</p> |
21,213,935 | 0 | How to select object in muti level array <p>I am attempting to get just the smiling array under tags then attributes. I have tried both to search and simply select. Every attempt results in an undefined variable. If you could explain how to select the smiling array that would be excellent!</p> <pre><code> { "status": "success", "photos": [{ "url": "http://tinyurl.com/673cksr", "pid": "F@019cbdb135cff0880096136c4a0b9bad_3547b9aba738e", "width": 375, "height": 406, "tags": [{ "uids": [], "label": null, "confirmed": false, "manual": false, "width": 30.67, "height": 28.33, "yaw": -16, "roll": -1, "pitch": 0, "attributes": { "face": { "value": "true", "confidence": 84 }, "smiling": { "value": "false", "confidence": 46 } }, "points": null, "similarities": null, "tid": "TEMP_F@019cbdb135cff0880096136c00d500a7_3547b9aba738e_56.80_41.13_0_1", "recognizable": true, "center": { "x": 56.8, "y": 41.13 }, "eye_left": { "x": 66.67, "y": 35.71, "confidence": 51, "id": 449 }, "eye_right": { "x": 50.67, "y": 35.47, "confidence": 57, "id": 450 }, "mouth_center": { "x": 60.8, "y": 51.23, "confidence": 53, "id": 615 }, "nose": { "x": 62.4, "y": 42.61, "confidence": 54, "id": 403 } }] }], "usage": { "used": 21, "remaining": 79, "limit": 100, "reset_time": 1390111833, "reset_time_text": "Sun, 19 January 2014 06:10:33 +0000" }, "operation_id": "edc2f994cd8c4f45b3bc5632fdb27824" } </code></pre> |
12,483,668 | 0 | <p>It's really whichever you like better. I've tried out both and don't see any real advantages which would make one superior </p> |
21,629,330 | 0 | How do I embed a JFrame into a JavaFX 2.0 application? <p>I have searched stackoverflow extensively for help on this topic, but the Q&As I found are old and the answers have changed for the current version of the JDK (I'm currently using 7u51). </p> <p>Note that I was never SUPER proficient in Swing to begin with, but I believe I understand the fundamentals. (I've always been more focused on the meat inside an app, not the GUI).</p> <p>I'm trying to work with a third party library. The third party library requires that it's components use JFrame.</p> <p>Therefore, I'm trying to see how I would embed a JFrame into my JavaFX application. There was an old answer about doing something with javafx.ext.swing, but that's no longer included in JavaFX.</p> <p>Help?</p> <p>==========</p> <p>I should also add: I think Java 8, which is currently beta, will support what I need based on this: <a href="http://docs.oracle.com/javafx/8/embed_swing/jfxpub-embed_swing.htm">http://docs.oracle.com/javafx/8/embed_swing/jfxpub-embed_swing.htm</a> , but I need to see if there is a way to do this without relying on a beta product.</p> |
39,918,363 | 0 | <p>Don't use string comparisons for date/times.</p> <pre><code>SELECT event_cust.* FROM event_cust WHERE TimeValue([start_time]) >= CDate([Forms]![CustEventRptForm]![FromHour]) AND TimeValue([start_time]) <= CDate([Forms]![CustEventRptForm]![ToHour]) </code></pre> |
34,697,179 | 0 | <p>Reducer should be aware only of a small part of state.</p> <p>Good place for described logic is the action creator. With redux-thunk you will be able to make a decision based on a global state.</p> <pre><code>function selectFilter(enjoys) { return (dispatch, getState) => { dispatch({type: SELECT_FILTER, enjoys}); // if getState().ui.userList.selected exists in getState().data dispatch({type: SELECT_USER, name: null}); } }; </code></pre> |
32,827,497 | 0 | <p>One slow but clear way would be</p> <pre><code>var matched = cars.Where(car => intList.Contains(car.id)).ToList(); </code></pre> <p>You can make this quicker by turning the <code>intList</code> into a dictionary and using <code>ContainsKey</code> instead.</p> <pre><code>var intLookup = intList.ToDictionary(k => k); var matched = cars.Where(car => intLookup.ContainsKey(car.id)).ToList(); </code></pre> <p>Even better still, a <code>HashSet</code>:</p> <pre><code>var intHash = new HashSet(intList); var matched = cars.Where(car => intHash.Contains(car.id)).ToList(); </code></pre> |
12,439,300 | 0 | <p>You need to add "px" to left. </p> <pre><code>bouger.style.left= left + "px"; </code></pre> <p>Of course, it also runs so fast you can't see anything happen, so I have a modified version:</p> <p><a href="http://jsfiddle.net/5GEru/2/" rel="nofollow">http://jsfiddle.net/5GEru/2/</a></p> <p>Also, your code should terminate at some point. Like when left becomes greater than SOMETHING for example. If you're using jQuery of course, you could just do:</p> <pre><code>$(function(){ $("#bouge").animate({"left": 500},2000); }); </code></pre> <p>See: <a href="http://jsfiddle.net/5GEru/6/" rel="nofollow">http://jsfiddle.net/5GEru/6/</a><br> </p> |
12,400,413 | 0 | <p>It seems like you misunderstanding some concepts in software development process. This:</p> <blockquote> <p>Since I want to manage both projects at the same time, I created a new solution for second application, which subclasses the necessary forms and classes</p> </blockquote> <p>is a very bad idea. </p> <p>In fact, new functionality brings you to new <em>version</em> of your software.<br> Do not inherit anything. Just make a development branch (in terms of source control) for your previous project version, and continue to develop new version, extending functionality. </p> <p>This will allow you to get two, completely independent versions of your software, which you will support simultaneously.</p> |
39,419,031 | 0 | <p>Just change your loop to:</p> <pre><code>for (pos = s.begin(); pos != s.end(); ++pos) { cout << static_cast<void*>( &*pos ) << endl; } </code></pre> <p><code>static_cast</code> is necessary because <code>&*pos</code> has type <code>char *</code> which would be printed by <code>std::ostream</code> not the way you want.</p> |
8,098,226 | 0 | <p>As far as I know, the only way to work on a HIT is through the mTurk website. i.e. - not via API.</p> <p>There is a site that is trying to do something very similar to what you have described. <a href="http://www.sparked.com/" rel="nofollow">http://www.sparked.com/</a></p> |
21,245,488 | 0 | <p>One way is with a custom binding handler. </p> <pre><code>ko.bindingHandlers.lineBreaks = { init: function (element, valueAccessor, allBindings, data, context) { $(element).html(value.replace(/-/g, '<br />')); } }; </code></pre> <p>See <a href="http://jsfiddle.net/rwisch45/t5EqM/3/" rel="nofollow">updated fiddle</a></p> <p>And if the value of the observable might change, then you can add an update section to the binding handler with the same code that is in the init.</p> <pre><code>ko.bindingHandlers.lineBreaks = { init: function (element, valueAccessor, allBindings, data, context) { $(element).html(value.replace(/-/g, '<br />')); }, update: function (element, valueAccessor, allBindings, data, context) { $(element).html(value.replace(/-/g, '<br />')); } }; </code></pre> <p>Now the displayed value will be formatted via the binding handler when the value of the observable updates.</p> <p>You can probably achieve the same effect with an <a href="http://knockoutjs.com/documentation/extenders.html" rel="nofollow">extender</a> as well.</p> |
29,477,871 | 0 | <p>Make the first timeout with the offset for the hour.</p> <pre><code>setTimeout(worker,3600000 - ((new Date) % 3600000)) </code></pre> <p>This will be somewhat accurate (Date object construction might take some milliseconds).</p> |
29,552,865 | 0 | <p>This is, to me, a good case for many-to-many relationship with additional information (location, timedate, and parcel). Parcel can have many locations (at different times), and a location might belong to many parcels (at different times). I hope I understand you correctly.</p> <p>Here is my suggested design:</p> <pre><code>public class Parcel { public int ParcelId { get; set; } public List<ParcelAssignment> ParcelAssignments { get; set; } } public class Location { [Key] public int LocationId { get; set; } public LocationType LocationType { get; set; } public List<ParcelAssignment> ParcelAssignments { get; set; } } public enum LocationType { Warehouse, Truck } public class ParcelAssignment { [Key] public int ParcelAssignmentId { get; set; } [Required] public int LocationId { get; set; } [ForeignKey("LocationId")] public Location Location { get; set; } [Required] public int ParcelId { get; set; } [ForeignKey("ParcelId")] public Parcel Parcel { get; set; } public DateTime DateOfAssignment { get; set; } } </code></pre> <p>Your fluent api that goes to your dbcontext class:</p> <pre><code>modelBuilder.Entity<ParcelAssignment>() .HasRequired(pa => pa.Parcel) .WithMany(p => p.ParcelAssignments) .HasForeignKey(pa => pa.ParcelId); modelBuilder.Entity<ParcelAssignment>() .HasRequired(pa => pa.Location) .WithMany(l => l.ParcelAssignments) .HasForeignKey(pa => pa.LocationId); </code></pre> <p>You can read more about many-to-many relationships on EF here: </p> <p><a href="https://practiceaspnet.wordpress.com/2015/03/25/understanding-many-to-many-relationships-in-entity-framework-part-i/" rel="nofollow">https://practiceaspnet.wordpress.com/2015/03/25/understanding-many-to-many-relationships-in-entity-framework-part-i/</a></p> <p><a href="https://practiceaspnet.wordpress.com/2015/03/25/understanding-many-to-many-relationships-in-entity-framework-part-ii/" rel="nofollow">https://practiceaspnet.wordpress.com/2015/03/25/understanding-many-to-many-relationships-in-entity-framework-part-ii/</a></p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.