pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
3,593,691
0
<p>You can't. </p> <p>$3.4.2/2-</p> <p><code>'If T is a fundamental type, its associated sets of namespaces and classes are both empty.</code></p> <p>This means that fundamental types do not have any namespace associated with them.</p> <p>So you can't even say ::int for this reason.</p>
10,211,374
0
<p>This should do the trick:</p> <pre><code>$(".myform :input").length; </code></pre>
26,130,773
0
Make all action methods of a controller ChildActionOnly <p>Instead of having to remember to decorate a bunch of action methods with the <code>ChildActionOnly</code> attribute, it would be convenient to be able to specify all methods in an entire controller as such.</p> <p>Trying to put the <code>ChildActionOnly</code> attribute on the controller class doesn't work (at least in my code context) because during dependency injection for the controllers, which occurs at an early phase in the request pipeline, there is no HttpContext or Request object, and the error "Request is not available in this context" is thrown.</p> <p>Could I create a <code>RouteConstraint</code> that makes the route itself enforce <code>ChildActionOnly</code>? That seems doubtful because of the same request pipeline issue--I don't know if the HttpContext would be available during the time that execution of RouteConstraints occurs. If you have ideas how to implement this, please share.</p> <p>Maybe create a unit test that uses reflection to discover all action methods of a specific controller and ensure they have the <code>ChildActionOnly</code> attribute set...</p> <p>How do I accomplish this? Could you give some starter code (doesn't have to be polished or even working, just a starting point will help).</p>
19,471,061
0
android how to change the app_name dynamically <p>Is it possible to change the app_name value in String.xml? not just setTitle();</p> <p>I know there is a difference of languages may have mutiple xml files but i still want to change the </p> <pre><code>&lt;string name="app_name"&gt;MyApp&lt;/string&gt; </code></pre> <p>to</p> <pre><code>&lt;string name="app_name"&gt;Good&lt;/string&gt; </code></pre> <p>Is there any way to handle this? thank you</p>
17,806,368
0
<p>I got it i am using this simple format its working fine Thank you .</p> <pre><code>myTextView.setText(Html.fromHtml("&lt;h2&gt;Title&lt;/h2&gt;&lt;br&gt;&lt;p&gt;Description here&lt;/p&gt;")); </code></pre>
21,291,491
0
<p>Order matters in the Augeas tree. In that case, XML node attributes need to be set before the <code>#text</code> node and the child nodes.</p> <p>So what you need is:</p> <pre><code>ins #attribute before /files/test.xml/Context/#text set /files/test.xml/Context/#attribute/allowLinking true </code></pre> <p>Note that this change is not idempotent, since <code>insert</code> is not an idempotent operation.</p> <p>On Puppet, you could use <code>onlyif</code> to make this idempotent.</p>
21,841,722
0
<p>You should be able to do the following with jQuery:</p> <pre><code>$('h1').html('&lt;a href="#"&gt;' + $('h1').text() + '&lt;/a&gt;'); </code></pre> <p>or for multiple headers</p> <pre><code>$('h1').each(function() { $(this).html('&lt;a href="#"&gt;' + $(this).text() + '&lt;/a&gt;'); }); </code></pre>
15,531,296
0
PHP - Find/Replace Text in RTF/txt files <p>I'm running into an issue with finding specific text and replacing it with alternative text. I'm testing my code below with <code>.rtf</code> and <code>.txt</code> files only. I'm also ensuring the files are writable, from within my server. </p> <p>It's a hit and miss situation, and I'm curious if my code is wrong, or if this is just weirdness of opening and manipulating files.</p> <pre><code>&lt;?php $filelocation = '/tmp/demo.txt'; $firstname = 'John'; $lastname = 'Smith'; $output = file_get_contents($filelocation); $output = str_replace('[[FIRSTNAME]]', $firstname, $output); $output = str_replace('[[LASTNAME]]', $lastname, $output); $output = str_replace('[[TODAY]]', date('F j, Y'), $output); // rewrite file file_put_contents($filelocation, $output); ?&gt; </code></pre> <p>So, inside the <code>demo.txt</code> file I have about a full page of text with [[FIRSTNAME]], [[LASTNAME]], and [[TODAY]] scattered around.</p> <p>It's hit and miss with the find/replace. So far, [[TODAY]] is always replaced correctly, while the names aren't.</p> <p>Has anyone had this same issue? </p> <p>(on a side note, I've checked error logs and so far no PHP warning/error is returned from opening the file, nor writing it)</p>
16,539,025
0
<p>If your webapps (or most of them) MUST share the same libraries with the same version (i.e. Database driver or SPI ObjectFactories) you should share them in $TOMCAT_HOME/lib. If there is no solid reason for share libs keep them in their webapp's classloader.</p>
23,356,395
0
<p>Use <code>isEqualTo:</code> instead of <code>==</code>.</p>
29,685,062
0
<p>Another solution is to animate the bounds change.</p> <p>There are a few ways, but here's a simple subclass of <code>UITextView</code> which does exactly this.</p> <pre><code>import Foundation import UIKit import QuartzCore class SmoothTextView : UITextView { override func actionForLayer(layer: CALayer!, forKey key: String!) -&gt; CAAction! { if key == "bounds" { let x = super.actionForLayer(layer, forKey: "backgroundColor") if let action:CAAnimation = x as? CAAnimation { let transition = CATransition() transition.type = kCATransitionFade transition.beginTime = action.beginTime transition.duration = action.duration transition.speed = action.speed transition.timeOffset = action.timeOffset transition.repeatCount = action.repeatCount transition.repeatDuration = action.repeatDuration transition.autoreverses = action.autoreverses transition.fillMode = action.fillMode transition.timingFunction = action.timingFunction transition.delegate = action.delegate return transition } } return super.actionForLayer(layer, forKey: key) } } </code></pre> <p>This as of iOS 8.</p> <p>As an extra tweak, you might want to configure the text of your text view instance by adjusting the text container by zeroing all padding or insets:</p> <pre><code>textView.textContainer.lineFragmentPadding = 0.0 textView.textContainerInset = UIEdgeInsetsZero </code></pre>
10,273,202
0
<p>Be sure you are using the same name (case-Sensitive) in Birds Detail View Controller -> Identity Inspector -> Class. "name" with the code in birdsDetailViewController.h: "@interface "name" : UITableViewControlle"</p>
25,467,769
0
CGRect rect = [self rectForMapRect:mapRect]; depraceted <p>I have this code here:</p> <pre><code>CGRect rect = [self rectForMapRect:mapRect]; </code></pre> <p>This gives me a deprecated warning. In order to keep things clean, I wanna make it with actual code, but I don't know how. Could anyone tell me how?</p> <p>Here is the whole bunch of code:</p> <pre><code>- (void)fillMapRect:(MKMapRect)mapRect context:(CGContextRef)context { CGMutablePathRef path = CGPathCreateMutable(); CGRect rect = [self rectForMapRect:mapRect]; CGPathMoveToPoint(path, nil, rect.origin.x, rect.origin.y); CGPathAddLineToPoint(path, nil, rect.origin.x + rect.size.width, rect.origin.y); CGPathAddLineToPoint(path, nil, rect.origin.x + rect.size.width, rect.origin.y + rect.size.height); CGPathAddLineToPoint(path, nil, rect.origin.x, rect.origin.y + rect.size.height); CGPathCloseSubpath(path); CGContextAddPath(context, path); UIColor *overlayColor = [UIColor colorWithWhite:0.0 alpha:0.2]; CGContextSetFillColorWithColor(context, overlayColor.CGColor); CGContextDrawPath(context, kCGPathFillStroke); CGPathRelease(path); </code></pre>
29,465,163
0
<p>You'd want to post the data you've received over to a php script via an ajax call. </p> <p>Here's just an example, but you should be able to work with it from there:</p> <pre><code>$(document).ready(function(){ $("#submit").click(function(){ var name = $("#name").val(); var email = $("#email").val(); var password = $("#password").val(); var contact = $("#contact").val(); // Returns successful data submission message when the entered information is stored in database. var dataString = 'name1='+ name + '&amp;email1='+ email + '&amp;password1='+ password + '&amp;contact1='+ contact; if(name==''||email==''||password==''||contact=='') { alert("Please Fill All Fields"); } else { // AJAX Code To Submit Form. $.ajax({ type: "POST", url: "ajaxsubmit.php", data: dataString, cache: false, success: function(result){ alert(result); } }); } return false; }); }); </code></pre>
966,224
0
<p>If you're the vendor supporting a web application which your customer insists upon using with IE6 rather than an updated browser, I'd say try to offer them upgrade incentives (e.g. lower support contract fees, a one-time renewal discount, or some "enhanced" feature set which would magically be enabled once they upgrade their lowest common denominator browser-wise).</p> <p>I'd agree with some of the previous sentiments mentioned about warning banners, they'd be annoying and useless.</p> <p>If the company is so big and/or bureaucratic that they are a hard sell in terms of upgrading, it might take years for them to get "current". A hospital I once worked for was just finishing an upgrade to Windows NT 4 while XP had already been out a year.</p> <p>Personally, if I had any influence over such a situation I would enclose with my annual invoice a very obvious raise in my support or dev fees substantially every year IE6 remains in use at the customer's site, while at the same time presenting them the attractively lower-priced option of upgrading their browser right alongside.</p>
5,866,921
0
<blockquote> <p>I am led understand that when the function ends the pointer is lost, but will the array still be sent?</p> </blockquote> <p>The behavior is undefined. </p> <blockquote> <p>what is a good way to return this integer array with no arguments in the function call?</p> </blockquote> <pre><code>int nums[8]; </code></pre> <p><code>num</code> is local variable which resides on stack. You cannot return the reference of a local variable. Instead alloc <code>nums</code> with operator <code>new</code> and remember to <code>delete[]</code> it.</p> <pre><code>int* getNums() { int *nums = new int[8] ; // ..... return nums ; } // You should deallocate the resources nums acquired through delete[] later, // else memory leak prevails. </code></pre>
38,111,375
0
Why HTML link did not look like a bootstrap Cancel button <p>I needed a HTML link but need it to look like a bootstrap cancel button. So I wrote this:</p> <pre><code>@Html.ActionLink("Cancel", "Login", new {@class = "btn btn-secondary"}) </code></pre> <p>but did not work! It does NOT look like a button at all. It is just a link. How should I fix this?</p>
26,279,698
0
<p>With this code</p> <pre><code>window.onscroll = function (event) { var amount = window.pageYOffset + "px"; document.getElementById("cover").style.left = amount; } </code></pre> <p>You can achieve it.</p> <p>Working Fiddle: <a href="http://jsfiddle.net/sLse3fez/" rel="nofollow">Fiddle</a></p>
39,845,227
0
<p>Try this</p> <pre><code>var gus = '{{userrole}}'; </code></pre>
25,348,649
0
IE BHO - DISPID_FILEDOWNLOAD being called for page loads? <p>I am implementing an Internet Explorer Browser Helper Object that should catch the <strong>DISPID_FILEDOWNLOAD</strong> event.</p> <p>I first implemented this in C# which worked great except that I also need the cookies that go with the URL so need to call InternetGetCookiesEx. As .NET runs in it's own process it does not return me the session cookies so is no good.</p> <p>I then wrote a quick test DLL in C++ so that it is loaded into the same process as IE which works great for the cookies but I now have a new problem:</p> <p>I am getting calls to <strong>DISPID_FILEDOWNLOAD</strong> in my Invoke function for each page load when I only want them for an actual download.</p> <p>In the C# version I only got a call to WebBrowser.FileDownload for an actual download but it seems that the C++ version is sending a DISPID_FILEDOWNLOAD even for each page load.</p> <pre><code>STDMETHODIMP CIEHlprObj::Invoke( DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pvarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr ) { USES_CONVERSION; if (!pDispParams) return E_INVALIDARG; LPOLESTR lpURL = NULL; m_spWebBrowser2-&gt;get_LocationURL(&amp;lpURL); int i = 0; switch (dispidMember) { case DISPID_BEFORENAVIGATE2: case DISPID_BEFORENAVIGATE: sCurrentFile=NULL; if (pDispParams-&gt;cArgs &gt;= 5 &amp;&amp; pDispParams-&gt;rgvarg[5].vt == (VT_BYREF | VT_VARIANT)) { CComVariant varURL(*pDispParams-&gt;rgvarg[5].pvarVal); varURL.ChangeType(VT_BSTR); char* myStr = OLE2T(varURL.bstrVal); if (myStr) { sCurrentFile = AllocateString(myStr); sCurrentFileW = varURL.bstrVal; } } break; case DISPID_FILEDOWNLOAD: // CALLED FOR EACH PAGE LOAD! if(sCurrentFile) { TCHAR cookies[8192]; DWORD size = 8192; BOOL ret = InternetGetCookieEx(sCurrentFile, 0, cookies, &amp;size, INTERNET_COOKIE_HTTPONLY, 0); ::MessageBox(0, sCurrentFile, "Downloading called multiple times!!", MB_OK); } break; default: break; } return S_OK; } </code></pre> <p><strong>Is there some filter that needs checking somewhere to know if a DISPID_FILEDOWNLOAD event relates to a file load or an actual file download?</strong></p> <p>Many thanks</p> <p><strong>UPDATE:</strong></p> <p>On closer inspection it seems that the C# managed code version is actually doing the same, I just didn't notice it the firs time around.</p> <p>It seems that the FileDownload event is being called in the following circumstances:</p> <ol> <li>New window / tab opened</li> <li>New domain connected to (maybe a new keep-alive connection?)</li> <li>An actual download</li> </ol> <p>Obviously I only want the even on the actual download event.</p>
908,639
0
<p>Personally, I'd combine method two and three: Just create a generic XML document using reflection, say:</p> <pre><code>&lt;object type="xxxx"&gt; &lt;property name="ttt" value="vvv"/&gt; ... &lt;/object&gt; </code></pre> <p>and use an XSTL stylesheet to create the actual HTML from this.</p>
20,228,583
0
Symfony2 form type entity: Option is not selected <p>I use a Symfony2 (2.3) entity form type to load the options of a HTML select from a Doctrine entity:</p> <p>Class RoomFacilityType:</p> <pre><code>public function buildForm(FormBuilderInterface $builder, array $options) { $builder-&gt;add('title', 'text', array('label' =&gt; 'Bezeichnung', 'required' =&gt; false)) -&gt;add('save', 'submit', array('label' =&gt; 'Speichern')); // add referenced object facility type $builder-&gt;add('facilityType', new FacilityTypeType()); } </code></pre> <p>Class FacilityTypeType:</p> <pre><code>public function buildForm(FormBuilderInterface $builder, array $options) { $builder-&gt;add('type', 'entity', array('label' =&gt; 'Ausstattung', 'class' =&gt; 'xyz\abcBundle\Entity\FacilityType', 'property' =&gt; 'type')); } </code></pre> <p>In the controller I create a form with a RoomFacility entity:</p> <pre><code>$formRoomFacility = $this-&gt;createForm(new RoomFacilityType(), $roomFacility); </code></pre> <p>The RoomFacility entity has a ManToOne relation to entity FacilityType.</p> <p>When the form is rendered by a twig template, no option of the HTML select is selected (but when I use a text form type instead, the correct value ist displayed):</p> <pre><code>{{ form_widget(formRoomFacility.facilityType.type) }} </code></pre> <p>I have found questions about how to set an option selected by setting it's value explicitly, but that doesn't solve my problem either:</p> <pre><code>$formRoomFacility-&gt;get('facilityType')-&gt;setData($roomFacility-&gt;getFacilityType()); </code></pre> <p>Any suggestions?</p> <p>Thanks in advance</p> <p>Alex</p>
29,442,452
0
parse cloud code job : delete rows that have been in DB for an hour <p>I'm using parse as a mobile backend for an ios app I'm developing. I know its probably not a permanent solution but for what I'm doing right now it gives me good test results. I need to create a cloud code job which will remove all the rows with entries older than one hour in all of my databases besides one (this DB is just for the sake of having a backup of everything).I want to do this so client side devices can only query for things in the DB that are less than an hour old. I have a "timestamp" on each entry which I was going to incorporate into a js function to first check If all the entries were indeed an hour or more old, and if they were, delete them. I've been doing some research and really havent been able to develop a js function that would do this (I have absolutely no js experience whatSoEver just obj c) from my understanding it would be something similar to this </p> <pre><code> Parse.Cloud.job("deleteRows", function(request, status) { Parse.Cloud.useMasterKey(); var query = new Parse.Query(//inverse of db i dont want to delete from); query.each(function(//row in db?) { // delete here under parameters ? }).then(function() { status.success("rows deleted"); }, function(error) { status.error("job incomplete"); }); }); </code></pre> <p>if anyone could give me a hand I'd really appreciate it. Thanks.</p>
18,272,796
0
xslt not showing results. xpath or ns wrong? <p>i have the following xml and xslt to render it, but got no results. I checked again and again and see not path problem, and the xsl went through the compiler. so I am not sure if it's namespace problem or something else. many thx! </p> <p>XML file</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;bibdataset xsi:schemaLocation="http://www.elsevier.com/xml/ani/ani http://www.elsevier.com/xml/ani/embase_com.xsd" xmlns="http://www.elsevier.com/xml/ani/ani" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ce="http://www.elsevier.com/xml/ani/common" xmlns:ait="http://www.elsevier.com/xml/ani/ait"&gt; &lt;item&gt; &lt;bibrecord&gt; &lt;item-info&gt; &lt;itemidlist&gt;&lt;ce:doi&gt;10.1258/0268355042555000&lt;/ce:doi&gt; &lt;/itemidlist&gt; &lt;/item-info&gt; &lt;head&gt; &lt;citation-title&gt; &lt;titletext xml:lang="en" original="y"&gt;Effect of seasonal variations on the emergence of deep venous thrombosis of the lower extremity &lt;/titletext&gt; &lt;/citation-title&gt; &lt;abstracts&gt; &lt;abstract xml:lang="en" original="y"&gt; &lt;ce:para&gt;Objective: We aimed to determine the role of seasonal and meteorological variations in the incidence of lower extremity &lt;/ce:para&gt; &lt;/abstract&gt; &lt;/abstracts&gt; &lt;/head&gt; &lt;/bibrecord&gt; &lt;/item&gt; &lt;/bibdataset&gt; </code></pre> <p>XSLT file</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.elsevier.com/xml/ani/ani" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ce="http://www.elsevier.com/xml/ani/common" xmlns:ait="http://www.elsevier.com/xml/ani/ait"&gt; &lt;xsl:output indent="yes" omit-xml-declaration="no" media-type="application/xml" encoding="UTF-8" /&gt; &lt;xsl:template match="/"&gt; &lt;searchresult&gt; &lt;xsl:apply-templates select="/bibdataset/item/bibrecord" /&gt; &lt;/searchresult&gt; &lt;/xsl:template&gt; &lt;xsl:template match="bibrecord"&gt; &lt;document&gt; &lt;title&gt;&lt;xsl:value-of select="head/citation-title/titletext" /&gt;&lt;/title&gt; &lt;snippet&gt; &lt;xsl:value-of select="head/abstracts/abstract/ce:para" /&gt; &lt;/snippet&gt; &lt;url&gt; &lt;xsl:variable name="doilink" select="item-info/itemidlist/ce:doi"/&gt; &lt;xsl:value-of select="concat('http://dx.doi.org/', $doilink)" /&gt; &lt;/url&gt; &lt;/document&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre>
11,283,433
0
<p>They reduce reusability in much the same way that global variables do: when you method's computations depend on state which is external to the method, but not passed as parameters (i.e. class fields for example), your method is less reusable, because it's tightly coupled to the state of the object/class in which it resides (or worse, on a different class entirely).</p> <p><strong>Edit</strong>: Ok, here's an example to make it more clear. I've used <code>ThreadLocal</code> just for the sake of the question, but it applies to global variables in general. Assume I want to calculate the sum of the first N integers in parallel on several threads. We know that the best way to do it is to calculate local sums for each thread and them sum them up at the end. For some reason we decide that the <code>call</code> method of each <code>Task</code> will use a <code>ThreadLocal sum</code> variable which is defined in a different class as a global (static) variable:</p> <pre><code>class Foo { public static ThreadLocal&lt;Long&gt; localSum = new ThreadLocal&lt;Long&gt;() { public Long initialValue() { return new Long(0); } }; } class Task implements Callable&lt;Long&gt; { private int start = 0; private int end = 0; public Task(int start, int end) { this.start = start; this.end = end; } public Long call() { for(int i = start; i &lt; end; i++) { Foo.localSum.set(Foo.localSum.get() + i); } return Foo.localSum.get(); } } </code></pre> <p>The code works correctly and gives us the expected value of the global sum, but we notice that the class <code>Task</code> and its <code>call</code> method are now strictly coupled to the <code>Foo</code> class. If I want to reuse the <code>Task</code> class in another project, I must also move the <code>Foo</code> class otherwise the code will not compile.</p> <p>Although this is a simple example complicated on purpose, you can see the perils of "hidden" global variables. It also affects readability, since someone else reading the code will have to also search for the class <code>Foo</code> and see what the definition of <code>Foo.localSum</code> is. You should keep your classes as self-contained as possible.</p>
30,040,853
0
Swift - Getting address from coordinates <p>I have a local search that creates annotations for each search result. I'm trying to add an call out accessory to each of the annotations, and once that will be pressed, the Maps app will open and set directions on how to get to the certain location.</p> <p>The problem that I am having is that in order for the call out accessory to work correctly, you have to get the address using place marks in the Address Book import. I've done plenty of searching and can't figure out how to set it up correctly where I can covert the annotation coordinates into a <code>kABPersonAddressStreetKey</code> so the Maps app can read it correctly. Below is my code for the search function, and the open Maps app function.</p> <pre><code>func performSearch() -&gt; MKMapItem { matchingItems.removeAll() let request = MKLocalSearchRequest() request.naturalLanguageQuery = searchText.text request.region = mapView.region let search = MKLocalSearch(request: request) search.startWithCompletionHandler({(response: MKLocalSearchResponse!, error: NSError!) in if error != nil { println("Error occured in search: \(error.localizedDescription)") } else if response.mapItems.count == 0 { println("No matches found") } else { println("Matches found") for item in response.mapItems as! [MKMapItem] { println("Name = \(item.name)") println("Phone = \(item.phoneNumber)") self.matchingItems.append(item as MKMapItem) println("Matching items = \(self.matchingItems.count)") var annotation = MKPointAnnotation() var coordinates = annotation.coordinate var location = CLLocation(latitude: annotation.coordinate.latitude, longitude: annotation.coordinate.longitude) var street = // Insert code here for getting address from coordinates var addressDictionary = [String(kABPersonAddressStreetKey): street] var placemark = MKPlacemark(coordinate: coordinates, addressDictionary: addressDictionary) var mapItem = MKMapItem(placemark: placemark) return mapItem annotation.coordinate = item.placemark.coordinate annotation.title = item.name self.mapView.addAnnotation(annotation) } } }) } func mapView(mapView: MKMapView!, annotationView view: MKAnnotationView!, calloutAccessoryControlTapped control: UIControl!) { let location = view.annotation as! FirstViewController let launchOptions = [MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving] location.performSearch().openInMapsWithLaunchOptions(launchOptions) } </code></pre> <p>Any help would be greatly appreciated, thanks in advance.</p>
27,818,147
0
<p>Try this, it's working for me.</p> <pre><code>UPDATE Team SET GroupID = CAST(RAND(CHECKSUM(NEWID()))*10000000 AS INT) WHERE GroupID IN (SELECT GroupID FROM Team GROUP BY GroupID HAVING COUNT(GroupID)&lt;4) </code></pre> <p>This code ensures random values are assigned for all GroupId's in Team table AND no GroupID would have an occurrence of more than 4 </p>
12,692,498
0
Can focused Google Maps markers be styled? <p>I have this <a href="http://fiddle.jshell.net/NXhP4/" rel="nofollow">form where you can enter a location</a>, which (if Google can find it) is shown as a marker on a map. Basically I have a Google map with a marker embedded in a form; the map is surrounded with input fields.</p> <p>When you tab trough the form fields, at a certain point elements within the map are focused. One of the focusable elements is the <code>area</code> in the <code>map</code> used on the marker image. On Chrome 22 and Firefox 15 I can't see any default focus styling for areas. That annoyed me, so I tried to add some styling. Even without <code>:focus</code> this is <strong>not</strong> working:</p> <pre><code>area { outline: 2px solid red; } </code></pre> <p>Is there a way to style focused Google maps markers?</p> <hr> <p><strong>Edit</strong>: Since styling areas does not work I tried to see if I could bind a focus event listener to the areas. There is no focus event available for <a href="https://developers.google.com/maps/documentation/javascript/reference#Marker" rel="nofollow">markers</a> in the Google Api. So, that's a dead end.</p> <p>When you try to add a listener on areas (without using the Google Api), you will run into the problem that markers aren't placed synchronically and that there is no callback available in the Google Api.</p> <p>You could setup a <a href="https://developer.mozilla.org/en-US/docs/DOM/window.setInterval" rel="nofollow"><code>setInterval</code></a> to add focus listeners to new areas, but I don't like that solution a lot.</p> <p>Does anyone have any other ideas?</p>
32,192,341
0
g++ undefined reference to `main' <p>I have a gcc 5.2.0 configured as follows :</p> <pre><code>Using built-in specs. COLLECT_GCC=gcc-5.2.0 COLLECT_LTO_WRAPPER=/usr/local/lvm/gcc-5.2.0/libexec/gcc/x86_64-unknown-linux-gnu/5.2.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../configure --prefix=/usr/local/lvm/gcc-5.2.0 --enable-checking=release --with-gmp=/usr/local/lvm/gmp-6.0.0 --with-mpfr=/usr/local/lvm/mpfr-3.1.2 --with-mpc=/usr/local/lvm/mpc-1.0.3 --enable-languages=c,c++,fortran,objc,obj-c++ --with-isl=/usr/local/lvm/isl-0.14 --with-cloog=/usr/local/lvm/cloog-0.18.4 --program-suffix=-5.2.0 Thread model: posix gcc version 5.2.0 (GCC) </code></pre> <p>and g++ :</p> <pre><code>Using built-in specs. COLLECT_GCC=g++-5.2.0 COLLECT_LTO_WRAPPER=/usr/local/lvm/gcc-5.2.0/libexec/gcc/x86_64-unknown-linux-gnu/5.2.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../configure --prefix=/usr/local/lvm/gcc-5.2.0 --enable-checking=release --with-gmp=/usr/local/lvm/gmp-6.0.0 --with-mpfr=/usr/local/lvm/mpfr-3.1.2 --with-mpc=/usr/local/lvm/mpc-1.0.3 --enable-languages=c,c++,fortran,objc,obj-c++ --with-isl=/usr/local/lvm/isl-0.14 --with-cloog=/usr/local/lvm/cloog-0.18.4 --program-suffix=-5.2.0 Thread model: posix gcc version 5.2.0 (GCC) </code></pre> <p>I have the following simple c++ code in tmp2.cpp file :</p> <pre><code>extern "C" { double mysum(double x, double y) { return x+y; } } </code></pre> <p>that I am trying to compile into a dynamic library (.so) as follows :</p> <pre><code>export LD_LIBRARY_PATH=/usr/local/lvm/gmp-6.0.0:/usr/local/lvm/mpfr-3.1.2:/usr/local/lvm/mpc-1.0.3:/usr/local/lvm/cloog-0.18.4:/usr/local/lvm/isl-0.14/lib:/usr/local/lvm/gcc-5.2.0/lib64 export PATH=/usr/local/lvm/gcc-5.2.0/bin/:$PATH g++-5.2.0 -m32 -Wall -g -c ./tmp2.cpp g++-5.2.0 -m32 -dynamiclib ./tmp2.o -o ./tmp2.so </code></pre> <p>and the last command gives me the following error :</p> <pre><code>/usr/lib/../lib32/crt1.o: In function `_start': (.text+0x18): undefined reference to `main' collect2: error: ld returned 1 exit status </code></pre> <p>The detail output thx to <code>-v</code> can be found in a gist <a href="https://gist.github.com/MisesEnForce/097c8a9e37ebdc61a041" rel="nofollow">here</a>.</p> <p>I am quite new to gcc/g++ and don't really get what is going on. What's happened ?</p>
8,198,576
0
cookie produced based on select list <p>Ok so I have this jsFiddle I have worked on to produce a slide down effect on a div based on the select. I need to produce a cookie when the selection is made so when the page is reloaded, the div remains open. Not sure how to produce this effect in the code. Any help is really appreciated!</p> <p>Heres the link for a working example : <a href="http://jsfiddle.net/J9uuL/1/" rel="nofollow">http://jsfiddle.net/J9uuL/1/</a></p>
38,760,027
0
<p>Something obvious found ;-) </p> <p>Don't import from </p> <pre><code>import { ROUTER_PROVIDERS } from '@angular/router-deprecated'; </code></pre> <p>use instead</p> <pre><code>import { ROUTER_PROVIDERS } from '@angular/router'; </code></pre> <p>You might also need to fix your systemjs config.</p>
12,905,929
0
<blockquote> <p><em>Python should have permission to read and write files in its installation folder</em></p> </blockquote> <p>That's not actually true. Permissions are resolved on Windows not by the program that is running, but the <em>user account</em> which is doing the action. So the answer is that <em>your user account</em> does not have access to write to the Python installation folder.</p> <p>In general, to install system-wide software (which you're trying to do), you would need to run your commands under a local administrator account. However, a better option might be to find a way to install your program somewhere else (for testing purposes).</p>
15,550,431
0
<p>There are many ways to solve it, one is by using a subquery which separately gets the one record for every district. Since you haven't mentioned your RDBMS that you are using, this will work on almost all RDBMS.</p> <pre><code>SELECT a.* FROM tableName a INNER JOIN ( SELECT district, MAX(longitude) max_val FROM tableName GROUP BY district ) b ON a.district = b.district AND a.longitude = max_val </code></pre> <ul> <li><a href="http://www.sqlfiddle.com/#!2/ee2f4/1" rel="nofollow">SQLFiddle Demo</a></li> </ul> <p>OUTPUT</p> <pre><code>╔════════════╦══════════╦═══════════╦══════════╗ β•‘ RESTAURANT β•‘ DISTRICT β•‘ LONGITUDE β•‘ LATITUDE β•‘ ╠════════════╬══════════╬═══════════╬══════════╣ β•‘ perseus β•‘ 1 β•‘ 80.879 β•‘ -56.00 β•‘ β•‘ artica β•‘ 2 β•‘ 67.708 β•‘ -69.89 β•‘ β•‘ petera β•‘ 3 β•‘ 89.00 β•‘ -78.89 β•‘ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β• </code></pre> <p><strong>UPDATE 1</strong></p> <pre><code>WITH recordList AS ( SELECT restaurant, district, longitude, latitude, ROW_NUMBER() OVER (PARTITION BY district ORDER BY longitude DESC) rn FROM TableName ) SELECT restaurant, district, longitude, latitude FROM recordList WHERE rn = 1 </code></pre> <ul> <li><a href="http://www.sqlfiddle.com/#!3/80588/1" rel="nofollow">SQLFiddle Demo</a></li> </ul>
2,470,465
0
How can I get the high-res mtime for a symbolic link in Perl? <p>I want to reproduce the output of <code>ls --full-time</code> from a Perl script to avoid the overhead of calling <code>ls</code> several thousand times. I was hoping to use the <a href="http://perldoc.perl.org/functions/stat.html" rel="nofollow noreferrer">stat</a> function and grab all the information from there. However, the timestamp in the ls output uses the high-resolution clock so it includes the number of nanoseconds as well (according to the GNU docs, this is because --full-time is equivalent to <code>--format=long --time-style=full-iso</code>, and the full-iso time style includes the nanoseconds).</p> <p>I came across the <a href="http://perldoc.perl.org/Time/HiRes.html" rel="nofollow noreferrer">Time::HiRes</a> module, which overrides the standard stat function with one that returns atime/mtime/ctime as floating point numbers, but there's no override for <a href="http://perldoc.perl.org/functions/lstat.html" rel="nofollow noreferrer">lstat</a>. This is a problem, because calling stat on a symlink returns info for the linked file, not for the link itself.</p> <p>So my question is this - where can I find a version of lstat that returns atime/mtime/ctime in the same way as Time::HiRes::stat? Failing that, is there another way to get the modtime for a symlink in high resolution (other than calling ls).</p>
4,316,876
0
<p>I think that you should compare every character (A) of every name against the corresponding character (B) of all the other names, then, eventually, swap the two names if B and all characters preceding it are smaller than A and characters before. Right now that's my only idea but I can't translate it in code, I should think about it still some time...</p> <p>I tried to explain it as best as I could, anyway I'm sorry if it's a mess.. =)</p>
30,656,197
0
How to get Jackson to use a Google Guice Injector to create instances? <p>We use Google Guice for DI (mostly with constructor injection) and Jackson for object serialization to/from JSON. As such we build our object graph through Guice Modules.</p> <p>How do we provide/instruct Jackson to use our pre-built Guice Injector? Or it's own injector based on a Guice Module we provide? My preference is to provide it the injector because we already have means to control which module is used based on the environment/configuration we want to run in.</p> <p>Here's a unit test:</p> <pre><code>public class Building { @JsonIgnore public final ElectricalProvider electricalProvider; public String name; @Inject Building(ElectricalProvider electricalProvider){ this.electricalProvider = electricalProvider; } public String getName() { return name; } public void setName(String name) { this.name = name; } } public interface ElectricalProvider {} public class SolarElectricalProvider implements ElectricalProvider{} @Test public void testJacksonGuice() throws IOException { Injector injector = Guice.createInjector(new Module() { @Override public void configure(Binder binder) { binder.bind(ElectricalProvider.class).to(SolarElectricalProvider.class); } }); Building building1 = injector.getInstance(Building.class); building1.setName("test building"); ObjectMapper objectMapper = new ObjectMapper(); byte[] buildingJsonBytes = objectMapper.writeValueAsBytes(building1); Building building2 = objectMapper.readValue(buildingJsonBytes, Building.class); assertThat(building1, is(equalTo(building2))); assertThat(building2.electricalProvider, is(instanceOf(SolarElectricalProvider.class))); } </code></pre> <p>That when run generates this exception <code>com.fasterxml.jackson.databind.JsonMappingException</code>, with this message: No suitable constructor found for type [simple type, class Building]: can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?)</p> <p>After a bit of googling, I came across the <a href="https://github.com/FasterXML/jackson-module-guice" rel="nofollow">jackson-module-guice</a> project but it doesn't appear to be what we need or doesn't provide as to how to accomplish what we need to do.</p>
485,686
0
<p>I don't know any <strong>Django module</strong> which would offer what you want (at least wiki i.e. editable text with some lightweight markip language, coupled with version control system), but you can take a look at <a href="http://git.or.cz/gitwiki/InterfacesFrontendsAndTools" rel="nofollow noreferrer">InterfacesFrontendsAndTools</a> page at Git Wiki, section "Wikis, blogs, etc.". Among others you can find there:</p> <ul> <li><a href="http://blitiri.com.ar/git/?p=wikiri" rel="nofollow noreferrer" title="gitweb">wikiri</a>: simple, single-file wiki written in Python, with optional git support for history tracking</li> <li><strong><a href="https://www.ohloh.net/p/chuyen" rel="nofollow noreferrer" title="Ohloh">Chuyen</a></strong>: a weblog software written in Python, using the Django web framework and Git as its data storage backend through PyGit</li> <li><a href="http://blog.codezen.org/entries/tag/pystl" rel="nofollow noreferrer">Pystl</a>: very simple, small blog engine in Python, using Git for version control.</li> </ul>
39,674,698
0
<p>This is reason :</p> <p>Grails is a mix of many frameworks, spring, hibernate etc. All the frameworks are included and you need them as they are the baseline of grails every grails application comes with many plugins by default (look into your BuildConfig.groovy): cache, asset, scaffolding etc. Every plugin has their own dependencies like classes, jars, js etc All of them add up.</p> <p>Solution: a war and also a jar are just containers. Open them with your favorite unzip program and check.</p> <p>You can remove that by using following command</p> <pre><code>grails war -nojars </code></pre> <p>Note: It will build a war without WEB-INF/lib jars. But you have to provide them to your webserver before deployment. </p> <p>reference: <a href="http://mrhaki.blogspot.in/2009/05/create-much-smaller-grails-war-file.html" rel="nofollow">http://mrhaki.blogspot.in/2009/05/create-much-smaller-grails-war-file.html</a></p> <p>OR</p> <p>If you want remove the perticular jar files then you can use below config </p> <p>Add to your BuildConfig.groovy:</p> <pre><code>grails.war.resources = { stagingDir -&gt; delete(file:"${stagingDir}/WEB-INF/lib/whatever.jar") } </code></pre>
35,679,688
0
<p>There is also the DOM way of doing this in JavaScript:</p> <pre><code>// Create a div and set class var new_row = document.createElement("div"); new_row.setAttribute("class", "aClassName" ); // Add some text new_row.appendChild( document.createTextNode("Some text") ); // Add it to the document body document.body.appendChild( new_row ); </code></pre>
32,228,917
0
Get an array of integer with Laravel query builder <p>I have this query :</p> <pre><code>$inError = DB::table('errors') -&gt;select('fk_fact') -&gt;distinct() -&gt;get(); </code></pre> <p>And I want it to return an array of integers instead of returning an array of objects, I don't want to loop over all the results and push the values one by one... Is there a way to do this with Laravel? </p>
31,391,581
0
How to bind multiple struct fields without getting "use moved value" error? <p>I'm trying to code a generic list as an exercise - I know it's already supported by the syntax, I'm just trying to see if I can code a recursive data structure. As it turns out, I can't. I'm hitting a wall when I want to access more than one field of an owned struct value.</p> <p>What I'm doing is basically this - I define a struct that will hold a list:</p> <pre class="lang-rust prettyprint-override"><code>struct ListNode&lt;T&gt; { val: T, tail: List&lt;T&gt; } struct List&lt;T&gt;(Option&lt;Box&lt;ListNode&lt;T&gt;&gt;&gt;); </code></pre> <p>Empty list is just represented by <code>List(None)</code>.</p> <p>Now, I want to be able to append to a list:</p> <pre><code>impl&lt;T&gt; List&lt;T&gt; { fn append(self, val: T) -&gt; List&lt;T&gt; { match self { List(None) =&gt; List(Some(Box::new(ListNode { val: val, tail: List(None) }))), List(Some(node)) =&gt; List(Some(Box::new(ListNode { val: node.val, tail: node.tail.append(val) }))) } } } </code></pre> <p>Ok, so that fails with an error "used of moved value: node" at node.tail with an explanation that it was moved at "node.val". This is understandable.</p> <p>So, I look for ways to use more than one field of a struct and I find this: <a href="https://mail.mozilla.org/pipermail/rust-dev/2014-January/008216.html">Avoiding partially moved values error when consuming a struct with multiple fields</a></p> <p>Great, so I'll do that:</p> <pre><code>List(Some(node)) =&gt; { let ListNode { val: nval, tail: ntail } = *node; List(Some(Box::new(ListNode { val: nval, tail: ntail.append(val) }))) } </code></pre> <p>Well, nope, still node is being moved at assignment ("error: use of moved value 'node'" at "tail: ntail"). Apparently this doesn't work like in the link anymore.</p> <p>I've also tried using refs:</p> <pre><code>List(Some(node)) =&gt; { let ListNode { val: ref nval, tail: ref ntail } = *node; List(Some(Box::new(ListNode { val: *nval, tail: (*ntail).append(val) }))) } </code></pre> <p>This time the deconstruction passes, but the creation of the new node fails with "error: cannot move out of borrowed content".</p> <p>Am I missing something obvious here? If not, what is the proper way to access multiple fields of a struct that is not passed by reference?</p> <p>Thanks in advance for any help!</p> <p>EDIT: Oh, I should probably add that I'm using Rust 1.1 stable.</p>
14,874,797
0
Regex to remove footer text with line breaks <p>I am hoping this is quite simple... I am trying to remove a footer from a block of text using a regular expression, this includes the two initial line breaks which is where my problem lies.</p> <pre><code> Message body blah blah balh {Line Break} {Line Break} ---------------------------------- Custom footer text </code></pre> <p>I have been experimenting with variations of <code>/\?(\r\n)(\r\n)([-{34}])/.*</code> but nothing is working.</p>
39,884,212
0
<p>Basic pseudocode to generate and return csv:</p> <pre><code>import csv from django.http import HttpResponse def csv(self): response = HttpResponse(content_type='text/csv') filename = u"fizzer.csv" response['Content-Disposition'] = u'attachment; filename="{0}"'.format(filename) writer = csv.writer( response, delimiter=';', quotechar='"', quoting=csv.QUOTE_ALL ) for f in Fizzer.objects.all(): writer.writerow([f.foo, f.bar]) return response </code></pre> <p>Keynotes:</p> <ul> <li><p>You have to create <code>HttpResponse</code> object with <code>text/csv</code> content type</p></li> <li><p>generate your .csv with Python's <code>csv</code> module</p></li> <li><p>convert queryset to csv values</p></li> <li><p>return response</p></li> </ul>
22,843,956
0
<p>You can just add an argument to your main template that tells it whether or not to add the error stylesheet and script. Your main template handles the conditional statement and your other views just pass a true/false.</p> <p><strong>main.scala.html</strong></p> <pre><code>@(title: String, active: Int, hasErrors: Boolean = false)(content: Html)(style: Html)(js: Html) &lt;html&gt; &lt;head&gt; &lt;title&gt;@title&lt;/title&gt; @style @if(hasErrors){&lt;link rel="stylesheet" href="error.css" /&gt;} &lt;/head&gt; &lt;body&gt; ... @js @if(hasErrors){&lt;script src="error.js"&gt;&lt;/script&gt;} &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>other.scala.html</strong> (For example)</p> <pre><code>@(form: Form[MyModel]) @main(title, active, form.hasErrors) { ... @if(form.hasErrors){ @errorTemplate(errorMessage) } ... } { &lt;!-- stylesheets --&gt; } { &lt;!-- javascripts --&gt; } </code></pre>
4,999,705
0
How can a single form_for work for new, update and edit? <p>In rails 3, is it possible to create a form_for that works for both new, update and edit actions?</p> <p>If yes, how do I do this?</p> <p>I have a admin section so my urls look like:</p> <pre><code>/admin/posts/ {new,update, edit} </code></pre>
2,025,388
0
<p>Have a look at <a href="http://tapestry.apache.org/" rel="nofollow noreferrer">tapestry</a> web-framework. from code-quality perspective one of the best pieces of code i have seen! it uses both unit-tests and integration-tests (selenium driven). they are nicely integrated with maven so you can just run them locally. i would have preferred canoo-webtest (browser independent), but the suites are nice.</p> <p>but you are right, all a mandating (automated) unit+integration tests, but you hardly see it in practice... though it really pays off!</p>
38,335,627
0
Hadoop Kerberos Usercase understanding <p>I have configured Kerberos with Hadoop. I'm facing difficulty in mapping the Kerberos architecture and whole flow of authentication to my application. Following is my usecase:</p> <p>We have a web application that calls backend services, which communicates with Hadoop ecosystem internally. Now i don't have clear idea how the kerberos aunthentication will take place, where the tokens will be stored i.e., whether client-side or server side. How the credential cache would be managed,when two or more users access the application and access hadoop, because when we do kinit the old credential cache is replaced by the new one. What would be the complete flow? just like this<a href="https://i.stack.imgur.com/3eNgw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3eNgw.jpg" alt="enter image description here"></a></p> <p>Waiting for response. Thanks</p>
40,616,581
0
Restart Node.js Server after Post Request <p>Is there any way to have your Node.js server restart after completing a POST request? The reason being that API data doesn't persist on the client side when I refresh the browser until the server restarts. </p> <p>So is there any way to programmatically do this? I've been searching all over for the past couple days and I can't seem to find anything to fit my specific needs.</p> <p>Hopefully this makes sense! I was trying to convey my question without going too deep in the type of project I'm working on.</p> <p>Thanks in advance.</p>
2,176,210
0
<p>You are fetching a JavaScript snippet that is supposed to be built in directly into the document, not queried by a script. The code inside is JavaScript.</p> <p>You could pull out the code using a regular expression, but I would advise against it. First, it's probably not legal to do. Second, the format of the data they serve can change any time, breaking your script.</p> <p>I think you should take at <a href="http://feeds.feedburner.com/PunOfTheDay" rel="nofollow noreferrer"><strong>their RSS feed</strong></a>. You can parse that programmatically way easier than the JavaScript.</p> <p>Check out this question on how to do that: <a href="http://stackoverflow.com/questions/250679/best-way-to-parse-rss-atom-feeds-with-php"><strong>Best way to parse RSS/Atom feeds with PHP</strong></a></p>
25,717,091
0
<p>I ran across this issue and the above solution didn't fix it. It was because you need to make sure you are using NSTimeInterval for both duration and delay as well. So the solution above is correct, but make sure you are using the correct argument types for all parameters.</p>
22,982,007
0
<p>Under windows, any perl operation that internally tries to test a file or directory for existence uses the Win32 function <code>CreateFile</code>. Under windows a filename ending in spaces is not legal (although not clearly documented), and for some strange reason the <code>CreateFile</code> function internally strips all trailing spaces before trying to open the file/directory.</p> <p>Since a name starting with space looks like a relative path, the space is first appended to your current working directory but then internally ignored by the Win32 function. This results in the directory test seeing your current directory and reporting success. </p> <p>The perl <code>stat</code> function then proceeds to acquiring additional information and seems to somewhere down the line handle the trailing space(s) differently and therefore fails to get any further information. However it seems to explicitly leave the <em>mode</em> attribute of the stat result set, because it earlier had deduced that there existed a directory.</p> <p>So yes, I would call this a bug in the windows port of perl, but fixing it is probably not as easy as it sounds, as there are lots of special cases for UNC paths, reparse points, NTFS/FAT filesystems etc. that makes correct handling of trailing spaces rather tricky.</p> <p>Your best bet would probably be to explicitly strip trailing spaces from any assumed directory name at a very early point (who needs that anyway) and croak if nothing is left after stripping.</p>
2,934,140
0
How can I make named_scope in Rails return one value instead of an array? <p>I want to write a <a href="http://rails.rubyonrails.org/classes/ActiveRecord/NamedScope/ClassMethods.html#M001684" rel="nofollow noreferrer">named scope</a> to get a record from its id. </p> <p>For example, I have a model called <code>Event</code>, and I want to simulate <code>Event.find(id)</code> with use of <code>named_scope</code> for future flexibility.</p> <p>I used this code in my model:</p> <pre><code>named_scope :from_id, lambda { |id| {:conditions =&gt; ['id= ?', id] } } </code></pre> <p>and I call it from my controller like <code>Event.from_id(id)</code>. But my problem is that it returns an array of <code>Event</code> objects instead of just one object.</p> <p>Thus if I want to get event name, I have to write</p> <pre><code>event = Event.from_id(id) event[0].name </code></pre> <p>while what I want is </p> <pre><code>event = Event.from_id(id) event.name </code></pre> <p>Am I doing something wrong here?</p>
6,190,067
0
<p>Your communication classes shouldn't care what happens to the data they receive. Instead, they should either make the data available to a class that wants it. One way to do so would be to provide a getData() method, which received data and then returned it to the caller. Even better would be to provide a DataArrived event, which was fired whenever you received data. That way, any number of consumers could listen for data, but your communication code doesn`t have to know which classes are listening or what they plan to do with the data.</p> <p><strong>EDIT</strong>:</p> <p>A simple example:</p> <pre><code>public class MyClassWithEvent { public delegate void DataArrivedDelegate(string data); public event DataArrivedDelegate DataArrived; public void GetSomeData() { // Communication code goes here; stringData has the data DataArrivedDelegate handler = DataArrived; if (handler != null) { // If you want to raise the event on this thread, this is fine handler(stringData); } } } </code></pre> <p>In your listener class:</p> <pre><code>public MyListener { public MyListener(MyServer server) { // Sets MyListenerMethod to be called when DataArrived is raised server.DataArrived += MyListenerMethod; } public void MyListenerMethod(string data) { // Do something with the data Console.WriteLine(data); } } </code></pre>
35,508,005
0
<p>Thank to @glennjackman, with <code>od -c myscript</code>, I saw some <code>302</code> &amp; <code>240</code> characters (non-ASCII), and it was the problem :) I just don't understand how these characters can appear... Anyway, thank you very much.</p>
13,731,499
0
Content-Length http header stripped out on Sprint 3G network <p>I have a server I am communicating with and I get a Content-Length header in the response when I connect with my iPhone 4S via WiFi, or via Web Browser. If I disable WiFi and use my Sprint 3G connection on my iPhone 4S, the Content-Length header in the response is missing.</p> <p>Server is running WCF under IIS 7.5 ...</p> <p>Does anyone know why this might happen?</p>
25,995,565
0
Custom form Validation Rails <p>I am wondering if i have set up my method incorrectly as my validation attempt is being ignored halfway through the method. (i have provided a basic example, i want to get this working before adding more)</p> <p>I have two variations of a form all belonging to the same object. The forms are differentiated by a column animal_type as you can see in my method</p> <pre><code> class Animal &lt; ActiveRecord::Base before_save :animal_form_validation private def animal_form_validation if self.animal_type == 'Dog' ap('Im validating the dog Form') if self.name.length &lt;= 0 errors.add(:name, "Name cannot be blank") end elsif self.animal_type == 'Cat' ap('Im validating the cat form') if self.name.length &lt;= 0 errors.add(:name, "Name cannot be blank") end end end end </code></pre> <p>whether i am submitting a cat or dog i get the correct message in the console (using awesome print), so the method is running and knows which form im submitting, but as for the next if statement it is being ignored.</p> <p>So i have an error with my syntax? or am i calling the wrong validation check on the name field ?</p> <p>Thanks</p>
21,880,001
0
<p>No, it's not possible to execute PHP code in Javascript. </p> <p>What you'll need to do is make an ajax query to a php page. You can get more information about how to do that here: <a href="http://www.w3schools.com/php/php_ajax_xml.asp" rel="nofollow">http://www.w3schools.com/php/php_ajax_xml.asp</a></p> <p>And more info about XMLHttpRequest: <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest</a></p>
30,321,655
0
<p>First turn that validation method into a true <a href="http://docs.oracle.com/javaee/7/api/javax/faces/validator/Validator.html" rel="nofollow"><code>Validator</code></a> implementation.</p> <pre><code>@FacesValidator("topicValidator") public TopicValidator implements Validator {} </code></pre> <p>Then you can use it in a <a href="https://docs.oracle.com/javaee/7/javaserver-faces-2-2/vdldocs-facelets/f/validator.html" rel="nofollow"><code>&lt;f:validator&gt;</code></a> which supports <code>disabled</code> attribute.</p> <pre><code>&lt;h:inputText ...&gt; &lt;f:validator validatorId="topicValidator" disabled="..." /&gt; &lt;/h:inputText&gt; </code></pre> <p>To let it check if a certain button is pressed, just check the presence of its client ID in the request parameter map.</p> <pre><code>&lt;h:inputText ...&gt; &lt;f:validator validatorId="topicValidator" disabled="#{empty param[secondButton.clientId]}" /&gt; &lt;/h:inputText&gt; ... &lt;h:commandButton binding="#{secondButton}" ... /&gt; </code></pre> <p>Note: do absolutely not bind it to a bean property! The above code is as-is. You should only guarantee that the EL variable <code>#{secondButton}</code> is unique in the current view and not shared by another component or even a managed bean.</p> <h3>See also:</h3> <ul> <li><a href="http://stackoverflow.com/questions/8370675/how-to-let-validation-depend-on-the-pressed-button">How to let validation depend on the pressed button?</a></li> <li><a href="http://stackoverflow.com/questions/14911158/how-does-the-binding-attribute-work-in-jsf-when-and-how-should-it-be-used">How does the &#39;binding&#39; attribute work in JSF? When and how should it be used?</a></li> </ul>
38,863,417
0
How to query TFS Work Items to count how many times each one had the state "Resolved"? <p>I need to know how many times a Work Item had the state <code>Resolved</code>.</p> <p>Is it possible using the <code>Work &gt; Queries</code> or some Widget in <code>Home &gt; Overview</code> tabs in TFS 2015 or VSO/VSTS?</p> <p>Is it possible using TFS API?</p>
29,397,185
0
Does JQuery have a "move" function? Or is there a more compact way of doing this? <p>When using JQuery in conjunction with a content management system, I find myself often writing snippets of code such as </p> <pre><code>$(document).ready(function() { var thishtml = $('#some-element')[0].outerHTML; $('#some-element').remove(); $('#hmpg-btm-box-holder').prepend(thishtml); }); </code></pre> <p>Does JQuery have a functionality to accomplish that in a more compact fashion?</p>
20,572,410
0
<p>You can overload operator new, and operator delete for any specific user-defined type so that those operators use your allocator instead of the default heap allocator.</p>
38,400,172
0
<p>I had this problem with a project that I've been working on for years, using Xcode 7.3. But one of my colleagues, who cloned the same Xcode project, doesn't have this problem. After trying several different approaches, I downloaded the development certificate from Apple Developer and installed them manually. It works all of a sudden. My guess is Xcode 7.3 messed up with the automatic "fix the problem" feature. </p>
667,523
0
<p>Are you saying your are getting results like this:</p> <pre><code>Group 1a Group 2a Foo1 1 Foo2 1 foo3 2 Group 2a Sum 4 Group 2b Foo1 3 Foo2 3 Group 2a Sum 6 Group 1a Sum 10 Group 1b Group 2a Foo1 4 Foo2 1 foo3 2 Group 2a Sum 7 Group 2b Foo1 4 Foo2 3 Group 2a Sum 14 Group 1b Sum 21 </code></pre> <p>This is the behaviour I would expect. I was able to do it by putting <code>=Sum([value])</code> in an unbound field in each group footer (and even in the report footer).</p> <p>I know 'works for me' isn't very helpful.</p> <p>Have you labelled the detail's values fields (or the summary fields) with the same name as the data source? Sometime MS Access has weird behaviour if your fields have the same name as their bound data source (I tend to rename them slightly so I'm sure what I'm referring to in code).</p>
23,241,941
0
Sending variables as body of mailto on asp:button <p>I have a website which I want users to be able to share a link via email. This particular page is the mobile version.</p> <p>I have an asp:button using mailto and I need to pass variables from the page to build the URL in the email body.</p> <pre><code> &lt;asp:Button ID="btnEmail" runat="server" Width="70%" Text="Share Property" PostBackUrl='&lt;%#"mailto:?subject=Check out this property at xxx - " &amp; DataBinder.Eval(Container, "DataItem.PropertyName") &amp; "body=" &amp; DataBinder.Eval(Container, "DataItem.PropertyID")%&gt;'/&gt; </code></pre> <p>The mailto is working and the subject is populating but the mail body seems to contain the viewstate of the page:</p> <pre><code>__EVENTTARGET=&amp;__EVENTARGUMENT=&amp;__VIEWSTATE=%2FwEPDwUKMTM4ODYwNDQ2Mg9kFgJmD2QWAgIDD2QWAmYPZBYCAgEPFgIeC18hSXRlbUNvdW50AgEWAmYPZBYKAgEPFgIeCWlubmVyaHRtbAXCAzx1bCBjbGFzcz0nc2xpZGVzJz48bGk%2BPGltZyBzcmM9Jy4uL2Z0cC9wQlJBTkNIX1AxMzQxLmpwZycgLz48L2xpPjxsaT48aW1nIHNyYz0nLi4vZnRwLzYtQlJBTkNIX1AxMzQxLmpwZycgLz48L2xpPjxsaT48aW1nIHNyYz0nLi4vZnRwLzctQlJBTkNIX1AxMzQxLmpwZycgLz48L2xpPjxsaT48aW1nIHNyYz0nLi4vZnRwLzgtQlJBTkNIX1AxMzQxLmpwZycgLz48L2xpPjxsaT48aW1nIHNyYz0nLi4vZnRwL2FCUkFOQ0hfUDEzNDEuanBnJyAvPjwvbGk%2BPGxpPjxpbWcgc3JjPScuLi9mdHAvYkJSQU5DSF9QMTM0MS5qcGcnIC8%2BPC9saT48bGk%2BPGltZyBzcmM9Jy4uL2Z0cC9jQlJBTkNIX1AxMzQxLmpwZycgLz48L2xpPjxsaT48aW1nIHNyYz0nLi4vZnRwL2RCUkFOQ0hfUDEzNDEuanBnJyAvPjwvbGk%2BPGxpPjxpbWcgc3JjPScuLi9mdHAvZUJSQU5DSF9QMTM0MS5qcGcnIC8%2BPC9saT48L3VsPmQCAg8VBRpSZWR3b29kIENsb3NlLCBTb3V0aCBPeGhleQM2NzUDUENNBVAxMzQxnwFPbmUgYmVkcm9vbSB0b3AgZmxvb3IgZmxhdCB3aXRoIGZpdHRlZCBiYXRocm9vbSwgZml0dGVkIGtpdGNoZW4gd2l0aCB3YXNoaW5nIG1hY2hpbmUsIGZyaWRnZSwgY29va2VyIGFuZCBtaWNyb3dhdmUuICBBdmFpbGFibGUgbm93IGZ1cm5pc2hlZC4gIEVuZXJneSBSYXRpbmcgRS5kAgMPDxYCHgtQb3N0QmFja1VybAUlaHR0cDovL21hcHMuYXBwbGUuY29tL21hcHM%2FcT1XRDE5IDZTRWRkAgUPDxYCHwIFHFJlcXVlc3RWaWV3aW5nLmFzcHg%2FSUQ9UDEzNDFkZAIHDw8WAh8CBWNtYWlsdG86P3N1YmplY3Q9Q2hlY2sgb3V0IHRoaXMgcHJvcGVydHkgYXQgSm9obiBXaGl0ZW1hbiAtIFJlZHdvb2QgQ2xvc2UsIFNvdXRoIE94aGV5Ym9keT10ZXN0UDEzNDFkZGQlH8aveHqM96GJK6rcUKFtYormuw%3D%3D&amp;__PREVIOUSPAGE=jXBhZExXbPAJGCoKEgVxPvQrYIK2wX4xu1Pu8m0He281&amp;__EVENTVALIDATION=%2FwEWBQLLnPHNBQKLm%2B%2BxDQKTlZGGAQKbi8jQCALB16nOAksIgJxExXvoFLdOr%2FT%2F56iiVmxW&amp;ctl00%24MainContent%24myDataRepeater%24ctl00%24btnEmail=Share+Property </code></pre> <p>Where am I going wrong?</p>
31,985,106
0
how to play sound in android <p>I want to play music in my app when application starts. I tried many codes but nothing is working for me and i'm not getting any error.Can somebody please help me regarding this issue.Thanks in advance.</p> <pre><code>public class Login extends Activity { EditText edName, edPassword; String userName,password; MediaPlayer mp; @SuppressLint("NewApi") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login); mp = MediaPlayer.create(getApplicationContext(), R.raw.startsound); ActionBar actionBar = getActionBar(); actionBar.hide(); edName = (EditText) findViewById(R.id.editText1); edPassword = (EditText) findViewById(R.id.editText2); mp.start(); } public void SignInClick(View V) { userName = edName.getText().toString(); password = edPassword.getText().toString(); if (userName.equals("")) { Toast.makeText(Login.this, "Username is empty", Toast.LENGTH_LONG).show();} else if (password.equals("")) { Toast.makeText(Login.this, "Password is empty", Toast.LENGTH_LONG).show(); } else { Intent intent=new Intent(Login.this,Home.class); startActivity(intent); } </code></pre> <p>}</p>
40,201,042
1
Trying send a string from python to arduino through serial port and resend a part of the same back <p>Problem is that it prints the string for some initial iterations but after that it prints only first letter of the string. <strong>THIS IS THE PYTHON CODE I'm USING:</strong></p> <pre><code>import serial import time ser = serial.Serial("COM5",9600) while True: ser.write('aqwertyui') time.sleep(1) print(ser.read()) ser.close </code></pre> <p><strong>This is arduino code I'm using</strong></p> <pre><code>#include&lt;SoftwareSerial.h&gt; SoftwareSerial mySerial(10,11); //RX TX char inc[8] = "0000000"; void setup() { // put your setup code here, to run once: Serial.begin(9600); mySerial.begin(9600); } int i; void loop() { while(mySerial.available()){ if(mySerial.read() == 'a'){ for(int i = 0; i&lt;8; i++){ if(i&lt;4){ inc[i] = '0'; inc[i] = mySerial.read(); mySerial.write(inc[i]); delay(1000); } else{ inc[i] = '0'; inc[i] = mySerial.read(); } } } else{ mySerial.write('0'); delay(1000); } } } </code></pre> <p><strong>This is my output</strong> q w e r q w e r .....for some iterations and then a a a a a a......till end.</p>
1,709,430
0
<p>You better tell them what XML really means, 'cause that thing you posted there is far away from anything that has the right of being called XML...</p> <p>In that case, go for the CSV, read in every row and strip out the spaces (e.g. <code>_Row.Replace(" ", "");</code>), save it in a new .XML and you should be good to go.</p>
25,175,100
0
DeploymentException with JBoss 6 <p>While Deploying ear in jboss 6 its giving Runtime Exception please help me how to solve this error</p> <pre><code>11:14:14,684 ERROR [ProfileDeployAction] Failed to add deployment: FirstGen.ear: org.jboss.deployers.spi.DeploymentException: Exception determining structure: AbstractVFSDeployment(FirstGen.ear) at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49) [:2.2.0.GA] at org.jboss.deployers.structure.spi.helpers.AbstractStructuralDeployers.determineStructure(AbstractStructuralDeployers.java:85) [:2.2.0.GA] at org.jboss.deployers.plugins.main.MainDeployerImpl.determineStructure(MainDeployerImpl.java:1106) [:2.2.0.GA] at org.jboss.deployers.plugins.main.MainDeployerImpl.determineDeploymentContext(MainDeployerImpl.java:417) [:2.2.0.GA] at org.jboss.deployers.plugins.main.MainDeployerImpl.addDeployment(MainDeployerImpl.java:367) [:2.2.0.GA] at org.jboss.deployers.plugins.main.MainDeployerImpl.addDeployment(MainDeployerImpl.java:277) [:2.2.0.GA] at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.addDeployment(MainDeployerPlugin.java:77) [:6.0.0.Final] at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.addDeployment(ProfileControllerContext.java:133) [:0.2.2] at org.jboss.profileservice.dependency.ProfileDeployAction.deploy(ProfileDeployAction.java:132) [:0.2.2] at org.jboss.profileservice.dependency.ProfileDeployAction.installActionInternal(ProfileDeployAction.java:94) [:0.2.2] at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.GA] at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.GA] at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.GA] at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.GA] at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.GA] at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA] at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA] at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA] at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA] at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA] at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA] at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.GA] at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.GA] at org.jboss.profileservice.dependency.ProfileActivationWrapper$BasicProfileActivation.start(ProfileActivationWrapper.java:190) [:0.2.2] at org.jboss.profileservice.dependency.ProfileActivationWrapper.start(ProfileActivationWrapper.java:87) [:0.2.2] at org.jboss.profileservice.dependency.ProfileActivationService.activateProfile(ProfileActivationService.java:215) [:0.2.2] at org.jboss.profileservice.dependency.ProfileActivationService.activate(ProfileActivationService.java:159) [:0.2.2] at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.activate(AbstractProfileServiceBootstrap.java:112) [:0.2.2] at org.jboss.profileservice.resolver.BasicResolverFactory$ProfileResolverFacade.deploy(BasicResolverFactory.java:87) [:0.2.2] at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.start(AbstractProfileServiceBootstrap.java:91) [:0.2.2] at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:132) [:6.0.0.Final] at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:56) [:6.0.0.Final] at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5] at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5] at java.lang.Thread.run(Thread.java:662) [:1.6.0_27] </code></pre> <p>Caused by: java.lang.RuntimeException: Error determining structure: FirstGen.ear at org.jboss.deployment.EARStructure.doDetermineStructure(EARStructure.java:300) [:6.0.0.Final] at org.jboss.deployers.vfs.plugins.structure.AbstractVFSArchiveStructureDeployer.determineStructure(AbstractVFSArchiveStructureDeployer.java:60) [:2.2.0.GA] at org.jboss.deployers.vfs.plugins.structure.StructureDeployerWrapper.determineStructure(StructureDeployerWrapper.java:73) [:2.2.0.GA] at org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl.doDetermineStructure(VFSStructuralDeployersImpl.java:197) [:2.2.0.GA] at org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl.determineStructure(VFSStructuralDeployersImpl.java:222) [:2.2.0.GA] at org.jboss.deployers.structure.spi.helpers.AbstractStructuralDeployers.determineStructure(AbstractStructuralDeployers.java:77) [:2.2.0.GA] ... 33 more Caused by: org.jboss.xb.binding.JBossXBException: Failed to parse source: xml_stream@14,15 at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:224) [jbossxb.jar:2.0.3.GA] at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:193) [jbossxb.jar:2.0.3.GA] at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:171) [jbossxb.jar:2.0.3.GA] at org.jboss.deployment.EARStructure.doDetermineStructure(EARStructure.java:169) [:6.0.0.Final] ... 38 more Caused by: org.xml.sax.SAXException: The content of element type "application" must match "(icon?,display-name,description?,module+,security-role*)". @ <em>unknown</em>[14,15] at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.error(SaxJBossXBParser.java:416) [jbossxb.jar:2.0.3.GA] at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) [xercesImpl.jar:6.0.0.Final] at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) [xercesImpl.jar:6.0.0.Final] at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) [xercesImpl.jar:6.0.0.Final] at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) [xercesImpl.jar:6.0.0.Final] at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source) [xercesImpl.jar:6.0.0.Final] at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source) [xercesImpl.jar:6.0.0.Final] at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) [xercesImpl.jar:6.0.0.Final] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) [xercesImpl.jar:6.0.0.Final] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) [xercesImpl.jar:6.0.0.Final] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) [xercesImpl.jar:6.0.0.Final] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) [xercesImpl.jar:6.0.0.Final] at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) [xercesImpl.jar:6.0.0.Final] at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) [xercesImpl.jar:6.0.0.Final] at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) [xercesImpl.jar:6.0.0.Final] at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:209) [jbossxb.jar:2.0.3.GA] ... 41 more</p>
38,375,155
0
<p>I think you misunderstood with <code>Model&lt;---&gt;ViewModel(s) Two-Way binding</code>, actually the binding source should at least be an instance of the Model, the <code>DataContext</code> should be the ViewModel which contains this instance of the Model, we can't directly bind model to a binding target. So your design pattern is not quite right. </p> <p>I think what you need is like when data is changed in ViewModel1, other ViewModels can get notified and response to it, and you may have done this work by manually refresh it and you want to find another way. </p> <p>Here is an easy way to do this in MVVM pattern, you can use the Messenger of <a href="https://mvvmlight.codeplex.com/" rel="nofollow">MVVM Light</a>, you can refer to this question on SO: <a href="http://stackoverflow.com/questions/18087906/use-mvvm-lights-messenger-to-pass-values-between-view-model">Use MVVM Light's Messenger to Pass Values Between View Model</a>.</p>
31,356,812
0
Method for randomly loading paired images <p>I've created a webpage with many (over 100) paired flash cards with Question (image) flipping to Answer (image) when clicked. If possible I would like to be able to randomise the order in which the question/answer pairs load with each page load/refresh.</p> <pre><code> &lt;div class="content4Column gap"&gt; &lt;div class="card-container"&gt; &lt;div class="card click" data-direction="left"&gt; &lt;div class="front"&gt; &lt;img src="Intermolecular/Q1.png" width="100%" height="100%" alt=""&gt; &lt;/div&gt; &lt;div class="back"&gt; &lt;img src="Intermolecular/A1.png" width="100%" height="100%" alt=""&gt; &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; </code></pre>
12,361,147
0
<p>Try this</p> <p><strong>CSS</strong></p> <pre><code>html, body { margin:0; padding:0; height:100%; } #wrapper{ min-height:100%; position:relative; } #header { background:#00ff0f; padding:30px; } #main{ padding:10px; padding-bottom:45px; /* Height+padding(top and botton) of the footer */ text-align:justify; height:100%; } #footer { position:absolute; bottom:0; width:100%; height:15px; /* Height of the footer */ background:#00ff0f; padding:10px 0; /*paddingtop+bottom 20*/ } </code></pre> <p><strong>​HTML</strong></p> <pre><code>&lt;div id="wrapper"&gt; &lt;div id="header"&gt;Header&lt;/div&gt; &lt;div id="main"&gt; Some Content Here... &lt;/div&gt; &lt;div id="footer"&gt;Footer&lt;/div&gt; &lt;/div&gt;​ </code></pre> <p><a href="http://jsfiddle.net/FPCWD/7/" rel="nofollow"><strong>DEMO</strong></a>.</p>
28,614,937
0
CSS image positioning inside <div> <p>I have been making a website and I want an opening image to be found on my screen. The problem is that I have the picture I want to use but it is to big for the space I want it to fit in. This could be solved 2 ways: I could scale the image to fit in the Div or I could position the image inside the div to show the essential parts of my picture. Ideally I would like the second option but I am ok with the first. I believe that I have done sufficient research on this question and this question is not like these:<a href="http://stackoverflow.com/questions/2635957/css-positioning-inside-div">First</a>, <a href="http://stackoverflow.com/questions/24180462/css-positioning-inside-a-div">Second</a>. I have also done my own experiments on this problem but using the position property and clear divs these have not worked to my satisfaction.</p> <p>Here is what i believe to be the essential code for this question:</p> <p>HTML:</p> <pre><code>&lt;div class="jumbotron"&gt; &lt;h1&gt; New IQ Test &lt;/h1&gt; &lt;p&gt;Take our quiz&lt;/p&gt; &lt;/div&gt; </code></pre> <p>CSS:</p> <pre><code>.jumbotron { /*padding-left: 50px; padding-right: 10px;*/ height: 500px; display:block; background-image: url(http://bit.ly/1IMUMR0); width: 100%; /*padding-top: 100px; position: absolute; bottom: -30px;*/ text-align: center; color:white; } .jumbotron h1 { padding-top: 150px; font-weight: normal; opacity: 100; text-shadow: 0 0 10px black; font-family: Helvetica; } </code></pre> <p>The image I am using is not owned by me. I realize this is illegal. I am NOT going to put this web page out for general use so it us ok if I use this image. All your help is greatly appreciated.</p>
11,100,590
0
<p>If the two string are of different size the following code you return the total mismatch of alphabets.</p> <p>You can try this - </p> <pre><code> String ip1 = "input"; // input1 String ip2 = "utput"; // input2 int count = 0; // difference in string String ipx2 = ip2; for (int j = 0; j &lt;= ip2.length(); j++) { int value = ip1.indexOf(ipx2); if (value != -1) { if (("").equals(ipx2)) { // if the second string is blank after continous reducing count = ip1.length() + ip2.length(); } else { count = ip1.length() + ip2.length() - 2 * ipx2.length(); } break; } else { count = ip1.length() + ip2.length(); // if there is no match at all } ipx2 = ip2.substring(j); } System.out.println("" + count); } </code></pre> <p>You will have to check whether the inputs have some data or not. I have not done that check.</p>
26,735,001
0
<p>I wrote a jQuery function:</p> <pre><code>$.fn.fullscreen = function(target){ var elem = $(target)[0]; $d = $(document); if(elem.requestFullscreen || elem.msRequestFullscreen || elem.mozRequestFullScreen || elem.webkitRequestFullscreen){ function FSon(){ $d.trigger('fullscreen').trigger('fullscreenOn').data('fullscreen',true); } function FSoff(){ $d.trigger('fullscreen').trigger('fullscreenOff').data('fullscreen',false); } $d.data('fullscreen',false) .on('fullscreenchange',function(){ if(document.fullscreen) FSon(); else FSoff(); }).on('mozfullscreenchange',function(){ if(document.mozFullScreen) FSon(); else FSoff(); }).on('webkitfullscreenchange',function(){ if(document.webkitIsFullScreen) FSon(); else FSoff(); }).on('MSFullscreenChange',function(){ if(document.msFullscreenElement) FSon(); else FSoff(); }); this.click(function(){ if(elem.requestFullscreen){ elem.requestFullscreen(); }else if(elem.mozRequestFullScreen){ elem.mozRequestFullScreen(); }else if(elem.webkitRequestFullscreen){ elem.webkitRequestFullscreen(); }else if(elem.msRequestFullscreen){ elem.msRequestFullscreen(); } }); }else{ this.remove(); } }; </code></pre> <p>It provides the following features:</p> <ul> <li>Cross-browser (Unless the browser doesn't support <code>requestFullscreen</code> or its prefixed methods)</li> <li>Issues events on <code>$(document)</code>: <code>fullscreen</code> for on/off and <code>fullscreenOn</code>/<code>fullscreenOff</code>.</li> <li>Adds jQuery <code>.data</code> to <code>$(document)</code>: <code>fullscreen</code> is a boolean value.</li> </ul> <p>You can call it like so:</p> <pre><code>$("#myButton").fullscreen("#elementToMakeFullscreen"); </code></pre> <p>Here is the function compressed:</p> <pre><code>function n(){$d.trigger("fullscreen").trigger("fullscreenOn").data("fullscreen",true)}function r(){$d.trigger("fullscreen").trigger("fullscreenOff").data("fullscreen",false)}$d.data("fullscreen",false).on("fullscreenchange",function(){if(document.fullscreen)n();else r()}).on("mozfullscreenchange",function(){if(document.mozFullScreen)n();else r()}).on("webkitfullscreenchange",function(){if(document.webkitIsFullScreen)n();else r()}).on("MSFullscreenChange",function(){if(document.msFullscreenElement)n();else r()});this.click(function(){if(t.requestFullscreen){t.requestFullscreen()}else if(t.mozRequestFullScreen){t.mozRequestFullScreen()}else if(t.webkitRequestFullscreen){t.webkitRequestFullscreen()}else if(t.msRequestFullscreen){t.msRequestFullscreen()}})}else{this.remove()}} </code></pre>
27,722,123
0
Laravel Validation (unique rule) <p>i use a seperate class for validation so it looks like </p> <pre><code>class UserValidation { protected static $id; protected static $rules = [ 'email' =&gt; 'required|email|unique:users,email,{{ self::$id }}', 'password' =&gt; 'required|alpha_dash|min:4', ]; public static function validate($input, $id) { self::$id = $id; return Validator::make($input, self::$rules); } } </code></pre> <p>so imagine a user wants to update only his password ,so he updates it > submit but then he receive the error <code>this email is already taken</code> ,because laravel cant read <code>{{ self::$id }}</code> ,so how do i solve something like that.</p>
19,988,943
0
<p>When you are printing the php variables it prints only the variable, so if $title equals Hello the Java Script interpreter think there a variable in Java Script named Hello. To avoid this you have to print into the HTML the variable value inside quotes.</p> <pre><code>$string = 'World!'; $title = 'Hello'; echo '&lt;a href="#" onclick="doSomething(\'' . $title . '\', \'' . $string '\')" id="'.$title.'" return false;" title="'.$title.'"&gt;'.$title.'&lt;/a&gt;&lt;/strong&gt;&lt;br /&gt;'; </code></pre>
11,685,115
0
<pre><code>http://www.mysite.com/&lt;?php echo($var); ?&gt; </code></pre> <p>should do it ... If I understood you </p>
36,463,534
0
<p>I feel you might be over thinking it; If I'm understanding what you want to do then all you should need in your filter is:</p> <pre><code>ng-repeat="option in DefComList | filter: require : true" </code></pre> <p>Note the true for exact matching as your search for 'MUST' would also match 'noMUST'.</p> <p>Here is a quick fiddle I put together for you: <a href="https://jsfiddle.net/nqya24r4/" rel="nofollow">https://jsfiddle.net/nqya24r4/</a></p> <p>Also if you specifically only want to search the Req property, you can filter using an object instead of a string. Here's another fiddle demonstrating this: <a href="https://jsfiddle.net/t3bw5L5d/2/" rel="nofollow">https://jsfiddle.net/t3bw5L5d/2/</a></p> <p>I hope this helps.</p>
35,003,479
1
How to hide part of string in python <p>I am just wondering if there is such possibility to hide somehow part of string in python. I am not talking about slicing. I am talking about situation where I have "1somestring," while printing I obtain "somestring". 1 before somestring should be visible for python but not displayable. Or It could be nice to have some kind of indicator glued to string. What I want to achieve is custom sorting. I have list of strings and I want to sort them by addition of digits in front of them. Sorting will proceed basing on digits thus behind digits I can insert whatever I want, but I don’t want to have digits visible. Thanks for answers in advance.</p>
40,110,202
0
<p>This is an old question, but now you can just use "BetterPickers":</p> <p><a href="https://github.com/code-troopers/android-betterpickers" rel="nofollow">https://github.com/code-troopers/android-betterpickers</a></p> <p>And use ExpirationPicker.</p> <p>Hope this solves it for some other lost souls who searched Google far and wide.</p>
21,868,469
0
<p>this has nothing to do with answering your question, but everything to do with improving your ability to quickly write efficient &amp; well written code:</p> <p>your way:</p> <pre><code>function user_exists($username) { $query = mysql_query("SELECT username FROM users WHERE username='$username'"); if (mysql_num_rows($query) != 0){ return true; } else{ return false; } } </code></pre> <p>better written way: </p> <pre><code>function user_exists($username) { $query = mysql_query("SELECT username FROM users WHERE username='$username'"); if(mysql_num_rows($query) &gt; 0) return true; return false; } </code></pre> <p>sql statement seems fine, as long as you are calling your function and testing it properly it should work. although unless you are sanitizing your $username input before calling user_exists, you have a gaping security exploit right there ;)</p>
20,998,039
0
<p>Put this on create of the dbhelper (Sqlite helper) </p> <pre><code>db.execSQL("PRAGMA foreign_keys=ON;"); </code></pre>
3,061,073
0
<p>It may be that the embedded device controlling the randomization doesn't have a clock. Perhaps it uses the number of tracks as seed or something similar.</p> <p>If you don't have some external source for random seeds, such as readings from a clock, the software will, when all it's memory is reset, behave deterministically each time it is started.</p>
32,041,784
0
<p>Try to use this:</p> <pre><code> ContractResolver = new CustomContractResolver { IgnoreSerializableInterface = true, IgnoreSerializableAttribute = true }; </code></pre>
26,257,466
0
<p>So finally got the system up and running, and for all the people facing similar problems, and without munch knowledge of unicorn or ngixn here are the steps:</p> <p>First make sure both services are running (unicorn is the app server and ngixn is the http server), both services should be configured in /etc/init.d/.</p> <p>Stop both services.</p> <p>Check your policies in selinux, here is a good question on how to do it for the same error in PHP <a href="http://stackoverflow.com/questions/23443398/nginx-error-connect-to-php5-fpm-sock-failed-13-permission-denied">nginx error connect to php5-fpm.sock failed (13: Permission denied)</a>, the idea is to be sure selinux ins't interfering with the rad process of the socket (the socket is created by unicorn and readed by ngixn)</p> <p>then you have to edit your config files unicorn.rb and nginx.conf, both should point to a folder different to tmp for the socket here is why <a href="http://serverfault.com/questions/463993/nginx-unix-domain-socket-error/464025#464025">http://serverfault.com/questions/463993/nginx-unix-domain-socket-error/464025#464025</a></p> <p>So finally my configurations looks like this:</p> <p>Part of nginx config file</p> <pre><code>upstream unicorn { server unix:/home/myuser/apps/myapp/shared/socket/unicorn.camicase.sock fail_timeout=0; } </code></pre> <p>part of unicorn config file</p> <pre><code>listen "/home/deployer/apps/stickystreet/shared/socket/unicorn.camicase.sock" </code></pre> <p>then start unicorn a ngixn, if you get a (13: Permission denied) while connecting to upstream error just do a sudo chmod 775 socket/ changing the socket for whatever folder you put your unicorn socket to be stored, the restart ngixn service.</p>
32,813,349
0
String with Object to Object <p>I have the following string:</p> <pre><code>var arr = "[{'one' : '1'}, {'two' : '2'}]"; </code></pre> <p>How can I pass this string to an object?</p> <p>I've tried the following but it doesn't seem to work:</p> <pre><code>arr.split(','); </code></pre>
38,025,102
0
how to make ssis map columns based order instead of column names <p>I am working on a project where there are <code>700</code> columns in a remote server and our destination table have columns that starts with underscore for example if there is a <code>"SchoolName"</code> column in the remote server, on our destination table we would have <code>"_SchoolName"</code> or <code>"_School_Name"</code> column. We use to use DTS package to import data "which doesn't use column name to map, instead it uses the order of the column on the select statement to map the column in the destination table". Now we would like upgrading our DTS package to SSIS, but mapping <code>700</code> columns manually has been a nightmare. Is there any way we can map columns based on the column orders instead of column name?</p>
36,575,887
0
Codeigniter Can't Connect to External SQL Server <p>i'm trying to connecting my codeigniter framework to external database. But it shows error</p> <blockquote> <p>A Database Error Occurred Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: 346</p> </blockquote> <p>then, i insert this one to end of config/database.php</p> <pre><code> echo '&lt;pre&gt;'; print_r($db['default']); echo '&lt;/pre&gt;'; echo 'Connecting to database: ' .$db['default']['database']; $dbh=mysql_connect ( $db['default']['hostname'], $db['default']['username'], $db['default']['password']) or die('Cannot connect to the database because: ' . mysql_error()); mysql_select_db ($db['default']['database']); echo '&lt;br /&gt; Connected OK:' ; die( 'file: ' .__FILE__ . ' Line: ' .__LINE__); </code></pre> <p>But it shows </p> <blockquote> <p>A PHP Error was encountered Severity: 8192 Message: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead Filename: config/database.php Line Number: 79</p> <p>A PHP Error was encountered Severity: Warning Message: mysql_connect(): Can't connect to MySQL server on '167.114.xxx.xxx' (111) Filename: config/database.php Line Number: 79</p> <p>Cannot connect to the database because: Can't connect to MySQL server on '167.114.xxx.xxx' (111)</p> </blockquote> <p>then i trying to create this one outside the codeigniter dir (in public_html)</p> <pre><code>&lt;?php $servername = "167.114.xxx.xxx"; $username = "myusername"; $password = "dbpass"; $database = "dbname"; // Create connection $conn = mysql_connect($servername, $username, $password, $database); // Check connection if ($conn-&gt;connect_error) { die("Connection failed: " . $conn-&gt;connect_error); } echo "Connected successfully"; ?&gt; </code></pre> <p>and it shows connected successfully. So, what should i do? while the db details in config/database.php is same with above</p>
24,701,732
0
Optional parameters and method overloading <p>I've come across a library method with three parameters, all with default values:</p> <pre><code>virtual M(bool b1 = false, string s1 = null, bool b2 = true) </code></pre> <p>Method <code>M</code> shouldn't have parameter <code>s1</code>, so I want to remove it, but I don't want to make a breaking change in the DLL. Clients can obviously ignore <code>s1</code>, but I don't want to leave it there because <code>M</code> can be overridden and parameter <code>s1</code> is misleading. So here was my attempt:</p> <pre><code>virtual M(bool b1 = false, bool b2 = true) [Obsolete] virtual M(bool b1, string s1, bool b2 = true) </code></pre> <p>I figured that since optional parameters are compiled into the call site, existing clients would carry on calling the method with three parameters, whereas new or recompiled clients not using <code>s1</code> would link to the method with two parameters.</p> <p>Each call to <code>M</code> resolves okay, except this one:</p> <pre><code>M(b2: false); </code></pre> <p>The compiler reports that the call is ambiguous between "M(bool, bool)" and "M(bool, string, bool)".</p> <p>Oddly, in the parameter info (Ctrl+Shift+Space), Visual Studio is still showing the default values on the method with three parameters (despite cleaning and rebuilding, restarting VS, unloading and reloading projects).</p> <p>Obviously I can fix this by calling the new <code>M</code> something different, but I'm curious as to why it's not linking. Should it (and something's just out of step, as the out-of-date parameter info suggests), or does the compiler have a genuine issue with this?</p> <p>EDIT</p> <p>Like @p.s.w.g and as per @JonSkeet's suggestion, I can't reproduce this in fresh code, so I guess the question becomes: is there anything else I can try other than rebuilding, restarting, reloading to force VS to relink this?</p>
25,460,745
0
How can I get clientHeight value outside backbone render function? <p>I using <a href="http://github.com/zynga/scroller/blob/master/src/EasyScroller.js" rel="nofollow">zynga scroller</a> javascript for scrolling in backbone web-app but clientHeight of rendered element is always 0. This is because script for scrolling is loaded and executed before backbone render method.</p> <pre><code> render: function(){ var persons = this.model; var personsCollection = new PersonsCollection(persons); this.el.innerHTML = _.template( personsTemplate,{data : _.groupBy(personsCollection.toJSON(), 'status')} ); console.log(this.el.clientHeight); // ========= 1500 new EasyScroller(this.el, {scrollingX: false, scrollingY: true}); }, </code></pre> <p>Is possible to execute loading of scroller javascript after render? Or any other solutions? <strong>From scrolling script:</strong></p> <pre><code>EasyScroller.prototype.reflow = function() { this.scroller.setDimensions(this.container.clientWidth, this.container.clientHeight, this.content.offsetWidth, this.content.offsetHeight); }; </code></pre> <p>Thank you for any help!</p>
18,004,680
0
<p>I was actually going slightly crazy about this myself. If the data in the csv is encased in quotes, when SSIS imports csv file it includes the quotes in the output of the rows so you actually have to remove the end quotes yourself. Otherwise you are literally trying to cast the quotes and the number to a float. Passing the output of the CSV import to a derived column control will work for you. </p> <p>In the expression field of the derived column -> (DT_R4)REPLACE([Column Name],"\"","")</p> <p>This removes the quotes then cast the value out to a float.</p>
26,030,711
0
<p>try this. <div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code> body { margin: 0; padding: 0; background: #EEE; font: 10px/13px'Lucida Sans', sans-serif; } .wrap { overflow: hidden; margin: 50px; } /*20 for 5 box , 25 for 4 box*/ .box { float: left; position: relative; width: 25%; padding-bottom: 25%; color: #FFF; } /*border width control*/ .boxInner { position: absolute; left: 30px; right: 30px; top: 30px; bottom: 30px; overflow: hidden; background: #66F; } .boxInner img { width: 100%; } .gallerycontainer { position: relative; /*Add a height attribute and set to largest image's height to prevent overlaying*/ } /*This hover is for small image*/ .thumbnail:hover img { border: 1px solid transparent; } /*This hide the image that is in the span*/ .thumbnail span { position: absolute; padding: 5px; visibility: hidden; color: black; text-decoration: none; } /*This is for the hidden images, to resize*/ .thumbnail span img { /*CSS for enlarged image*/ border-width: 0; width: 200%; /* you can use % */ height: auto; padding: 2px; } /*When mouse over, the hidden image apear*/ .thumbnail:hover span { position: fixed; visibility: visible; z-index: 200; zoom: 62%; bottom: 0; right: 0; } .thumbnail:hover span img { width: 100%; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;link href="overlay2.css" rel="stylesheet" type="text/css" /&gt; &lt;head&gt; &lt;title&gt;Test&lt;/title&gt; &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt; &lt;meta name="description" content="" /&gt; &lt;meta name="keywords" content="" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="wrap"&gt; &lt;div class="box"&gt; &lt;div class="boxInner"&gt; &lt;a class="thumbnail" href="#"&gt; &lt;img src="http://www.dwuser.com/education/content/creating-responsive-tiled-layout-with-pure-css/images/demo/7.jpg" /&gt;&lt;span&gt;&lt;img src="http://www.dwuser.com/education/content/creating-responsive-tiled-layout-with-pure-css/images/demo/7.jpg" /&gt;&lt;/span&gt; &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="box"&gt; &lt;div class="boxInner"&gt; &lt;a class="thumbnail" href="#"&gt; &lt;img src="http://www.dwuser.com/education/content/creating-responsive-tiled-layout-with-pure-css/images/demo/6.jpg" /&gt;&lt;span&gt;&lt;img src="http://www.dwuser.com/education/content/creating-responsive-tiled-layout-with-pure-css/images/demo/6.jpg" /&gt;&lt;/span&gt; &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="box"&gt; &lt;div class="boxInner"&gt; &lt;a class="thumbnail" href="#"&gt; &lt;img src="http://www.dwuser.com/education/content/creating-responsive-tiled-layout-with-pure-css/images/demo/1.jpg" /&gt;&lt;span&gt;&lt;img src="http://www.dwuser.com/education/content/creating-responsive-tiled-layout-with-pure-css/images/demo/1.jpg" /&gt;&lt;/span&gt; &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="box"&gt; &lt;div class="boxInner"&gt; &lt;a class="thumbnail" href="#"&gt; &lt;img src="http://www.dwuser.com/education/content/creating-responsive-tiled-layout-with-pure-css/images/demo/2.jpg" /&gt;&lt;span&gt;&lt;img src="http://www.dwuser.com/education/content/creating-responsive-tiled-layout-with-pure-css/images/demo/2.jpg" /&gt;&lt;/span&gt; &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="box"&gt; &lt;div class="boxInner"&gt; &lt;a class="thumbnail" href="#"&gt; &lt;img src="http://www.dwuser.com/education/content/creating-responsive-tiled-layout-with-pure-css/images/demo/3.jpg" /&gt;&lt;span&gt;&lt;img src="http://www.dwuser.com/education/content/creating-responsive-tiled-layout-with-pure-css/images/demo/3.jpg" /&gt;&lt;/span&gt; &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="box"&gt; &lt;div class="boxInner"&gt; &lt;a class="thumbnail" href="#"&gt; &lt;img src="http://www.dwuser.com/education/content/creating-responsive-tiled-layout-with-pure-css/images/demo/4.jpg" /&gt;&lt;span&gt;&lt;img src="http://www.dwuser.com/education/content/creating-responsive-tiled-layout-with-pure-css/images/demo/4.jpg" /&gt;&lt;/span&gt; &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="box"&gt; &lt;div class="boxInner"&gt; &lt;a class="thumbnail" href="#"&gt; &lt;img src="http://www.dwuser.com/education/content/creating-responsive-tiled-layout-with-pure-css/images/demo/8.jpg" /&gt;&lt;span&gt;&lt;img src="http://www.dwuser.com/education/content/creating-responsive-tiled-layout-with-pure-css/images/demo/8.jpg" /&gt;&lt;/span&gt; &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
14,801,477
0
Mixing backbone.js routers and rails controllers <p>I'm currently attempting to wrap my head around grafting backbone.js into my rails application. For starters, I want to build it into a a specific part of the rails application at /applications. With that said I have a rails resource "resources :applications" which gives me localhost:3000/applications. Now when I instantiate backbone for /applications I get anchor tags for the backbone routing at that rails resource. IE localhost:3000/applications/#applications/5.</p> <p>Given that I'm only going to be using backbone at specific parts of the rails app, thus not making it a single page app, is this the right way to do things? The URL appears to be a bit redundant.</p> <p>The correct answer might be that I need to do away with the backbone router? If so, then how can :id be passed to the backbone application when attempting to look up a collection / model.</p> <p>The point of me using backbone is to help organize a particular section of the rails app that will be javascript heavy.</p> <p>I should mention that I can change the router to something like:</p> <pre><code>routes: '': 'index' ':id': 'show' </code></pre> <p>which will give me the url of localhost:3000/applications/#/1 - however I think this paints me into a corner and will not allow me to use backbone on other rails resources. If I were to have localhost:3000/dashboard with backbone invoked then the wrong backbone.js functionality would get executed.</p> <p>Another thought would be to have an invocation of a backbone router per rails resource. I could use the aforementioned routes code since the router would only be invoked for that rails resource.</p>
11,222,163
0
<p>"YUV" is not a complete format.</p> <p>From <a href="http://en.wikipedia.org/wiki/YUV" rel="nofollow">this wikipedia article</a> you can get the conversions of YUV411,YUV422,YUV420p to YUV444. Combine the inverse of these transforms with your RGB conversion and you'll get the result.</p> <p>The thing you are missing: one RGB triple may produce a number (not one) of YUV components this way.</p> <ol> <li>YUV444 3 bytes per pixel</li> <li>YUV422 4 bytes per 2 pixels</li> <li>YUV411 6 bytes per 4 pixels</li> <li>YUV420p 6 bytes per 4 pixels, reordered</li> </ol> <p>First, YUV422</p> <p>Y'UV422 to RGB888 conversion</p> <p>Input: Read 4 bytes of Y'UV (u, y1, v, y2 )</p> <p>Output: Writes 6 bytes of RGB (R, G, B, R, G, B)</p> <p>Then YUV4111</p> <p>Y'UV411 to RGB888 conversion</p> <p>Input: Read 6 bytes of Y'UV</p> <p>Output: Writes 12 bytes of RGB</p> <pre><code>// Extract YUV components u = yuv[0]; y1 = yuv[1]; y2 = yuv[2]; v = yuv[3]; y3 = yuv[4]; y4 = yuv[5]; rgb1 = Y'UV444toRGB888(y1, u, v); rgb2 = Y'UV444toRGB888(y2, u, v); rgb3 = Y'UV444toRGB888(y3, u, v); rgb4 = Y'UV444toRGB888(y4, u, v); </code></pre> <p>Similar with 420p, but the YUV values are distributed over the rectangle there - see the Wikipedia's diagram and image for that.</p> <p>Basically, you should fetch 4 RGB pixels, convert each one of them to YUV (using your hopefully valid 444 converter) and then store the YUV[4] array in a tricky way shown at the wikipedia.</p>
17,900,196
0
<p>Here's an example which changes the text inside a division based on the response from ur actionmethod...</p> <pre><code>//a class with properties. Class Priveleges{ Public string StatusMessage{get;set;} Public int StatusCode{get;set;} } //code inside controller [HttpGet] Public JsonResult Index{ Priveleges obj=DecidePriveleges(): Return Json(obj,allowget.true); } Private Priveleges DecidePriveleges(){ Prilveleges obj; //prepare object based on server response If(response=="high"){ obj=new Priveleges(){ StatusMessage="high priveleges", StatusCode=1} }else if(response=="medium){ obj=new Priveleges(){ StatusMessage="medium priveleges", StatusCode=2} }else if(response=="low"){ Obj=new Priveleges(){ StatusMessage="low priveleges"β€š StatusCode=3} } Return obj; //code inside ur view //suppose you want to change the text inside //ur div when the page loads.. &lt;div id="statusDiv"&gt;&lt;/div&gt; //here is ur javascript. $(document).ready(function(){ $.getJSON('/controller/Index',function(data){ $('#statusDiv').text( 'You have '+data.StatusMessage); }); }); //here data,the parameter of getJson method. //holds the data coming from our action //method... </code></pre> <p>Sorry for the code format..posted the code from my mobile...</p> <p>hope this small examle may be helpful..</p>
2,126,290
0
<p>You need the following in your <code>app.yaml</code>:</p> <pre><code>- url: /account script: account/account.py - url: /game script: game/game.py - url: .* script: main.py </code></pre> <p>BTW, I suggest you try to forget backslashes (characters like this: \ ) -- think <em>normal</em> slashes (characters like this: / ). Backslashes are a Windows anomaly (and mostly unneeded even there -- Python will happily accept normal slashes in lieu of backslashes in filepaths), not used as path separators in URLs nor on Unix-y operating systems (including Linux and MacOSX). I mention this because you speak of "requests that go to \account\ and \game\ respectfully" and there are no such things -- no request goes to a path with backslashes, it will always be <em>forward</em> slashes.</p>
21,459,825
0
WCF service reference added with Generate Asynchronous option <p>i add the wcf service reference and tick the option called Generate Asynchronous Operation. i found proxy code was added like this way....</p> <pre><code>public interface ICalculator { [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ICalculator/Add", ReplyAction="http://tempuri.org/ICalculator/AddResponse")] double Add(double n1, double n2); [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://tempuri.org/ICalculator/Add", ReplyAction="http://tempuri.org/ICalculator/AddResponse")] System.IAsyncResult BeginAdd(double n1, double n2, System.AsyncCallback callback, object asyncState); double EndAdd(System.IAsyncResult result); } </code></pre> <p>now i want to call wcf service asynchronously event driven way. so please anyone help me how to call wcf service asynchronously with event driven way. if possible give a small sample code or drive me to right url from where i can get the knowledge. thanks</p>
22,718,685
0
<p>Jersey makes the process very easy, my service class worked well with JSON, all I had to do is to add the dependencies in the pom.xml</p> <pre><code>@Path("/customer") public class CustomerService { private static Map&lt;Integer, Customer&gt; customers = new HashMap&lt;Integer, Customer&gt;(); @POST @Path("save") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public SaveResult save(Customer c) { customers.put(c.getId(), c); SaveResult sr = new SaveResult(); sr.sucess = true; return sr; } @GET @Produces(MediaType.APPLICATION_JSON) @Path("{id}") public Customer getCustomer(@PathParam("id") int id) { Customer c = customers.get(id); if (c == null) { c = new Customer(); c.setId(id * 3); c.setName("unknow " + id); } return c; } } </code></pre> <p>And in the pom.xml</p> <pre class="lang-xml prettyprint-override"><code>&lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt; &lt;artifactId&gt;jersey-container-servlet&lt;/artifactId&gt; &lt;version&gt;2.7&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt; &lt;artifactId&gt;jersey-media-json-jackson&lt;/artifactId&gt; &lt;version&gt;2.7&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt; &lt;artifactId&gt;jersey-media-moxy&lt;/artifactId&gt; &lt;version&gt;2.7&lt;/version&gt; &lt;/dependency&gt; </code></pre>
32,050,246
0
facebook api version 2.4 not returning email from owin facebookauthentication options? <p>I have created new facebook app for my application. Now this app is with api version 2.4. I was using below code for login with owin.</p> <pre><code> app.UseFacebookAuthentication(new FacebookAuthenticationOptions() { AppId = "xx", AppSecret = "xxx", Scope = { "email", "public_profile" } }); </code></pre> <p>This code was working fine and returning me the email address with older facebook app with api version 2.3. But now with the api version2.4, it is not returning email. It is asking user for permission to share email bur not returning email in login info.</p> <p>Is there any modification with api 2.4 which I am missing ?? Please suggest. Thanks in advance . .</p>
1,495,097
0
<p>That's just a normal UIView subclass which draws the gradient background using Core Graphics (I don't expect it to be an image) and has some UIButtons as subviews (Either staticly positioned and added to the view or all being positioned by code. Doing it staticly will make things easier but less reusable)</p>