pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
11,937,540 | 0 | Does having space between lines affect the performance of javascript code <p>This may be a stupid question, but I still have it . Does having spaces between the code lines in anyway affect the performance of the JavaScript code. </p> <p>How effective is the minified version of the JavaScript file? Any ways to optimize the code performance?</p> |
21,733,954 | 0 | <pre><code>$("#goup").click(function(e) { $("#imgslide > img:first") .slideUp(500,function(e){ $(this).appendTo("#imgslide"); }); $("#imgslide > img:eq(3)").slideToggle({direction:"up"},500); // move the paragraph with the image index sync $("#product_description > div:first") .appendTo("#product_description"); return false; }); </code></pre> |
25,148,499 | 0 | udp socket trouble c# <p>I have 2 simple programs in c # using udp connections. The programs both have a client and server to send data back and forth. It works exactly as I Ted when ran at the same time on my laptop, using the ip address as 127.0.0.1</p> <p>However, when I put one program on another machine, and changed the ip addresses to the specific machines, it won't work at all. Any thoughts? </p> <p>Thanks.</p> |
15,035,182 | 0 | <p>It's a Webkit-specific property:</p> <blockquote> <h2>CSS property: <code>-webkit-user-drag</code></h2> <h3>Description</h3> <p>Specifies that an entire element should be draggable instead of its contents.</p> <h3>Syntax</h3> <pre><code>-webkit-user-drag: auto | element | none; </code></pre> <h3>Values</h3> <ul> <li><p><code>auto</code> The default dragging behavior is used.</p></li> <li><p><code>element</code> The entire element is draggable instead of its contents.</p></li> <li><p><code>none</code> The element cannot be dragged at all.</p></li> </ul> </blockquote> <p>It's supported by Chrome 1-17 and Safari 3-5.1: <a href="http://www.browsersupport.net/CSS/-webkit-user-drag">http://www.browsersupport.net/CSS/-webkit-user-drag</a></p> |
5,188,708 | 0 | <p>I had some problems with that when i used an older php version </p> |
23,738,001 | 0 | Find duplicates in excel workbook <p>I have a excel workbook that i want to find all duplicate rows across all the sheets and highlight them. Figured out how todo it in one sheet. Anyone that can help me out?</p> |
6,878,234 | 0 | <p>I believe the <a href="http://wiki.eclipse.org/FAQ_What_is_hot_code_replace%3F" rel="nofollow">Hot Code Replace</a> in eclipse is what you meant in the problem:</p> <blockquote> <p>The idea is that you can start a debugging session on a given runtime workbench and change a Java file in your development workbench, and the debugger will replace the code in the receiving VM while it is running. No restart is required, hence the reference to "hot".</p> </blockquote> <p>But there are limitations:</p> <blockquote> <p>HCR only works when the class signature does not change; you cannot remove or add fields to existing classes, for instance. However, HCR can be used to change the body of a method.</p> </blockquote> |
27,798,742 | 0 | <p>Here is the solution that i came up with.</p> <p>this returns the client object</p> <pre><code>private RestClient InitializeAndGetClient() { var cookieJar = new CookieContainer(); var client = new RestClient("https://xxxxxxx") { Authenticator = new HttpBasicAuthenticator("xxIDxx", "xxKeyxx"), CookieContainer = cookieJar }; return client; } </code></pre> <p>and you can use the method like </p> <pre><code> var client = InitializeAndGetClient(); var request = new RestRequest("report/transaction", Method.GET); request.AddParameter("option", "value"); //Run once to get cookie. var response = client.Execute(request); //Run second time to get actual data response = client.Execute(request); </code></pre> <p>Hope this helps you.</p> <p>Prakash.</p> |
28,401,239 | 0 | <p>We use an Octopus Service Account with an API Key, and we call it <code>build-deploy-bot</code>. This is the account that TeamCity uses to create the release in Octo.exe.</p> <p>When the release is created, we also include Release Notes with links to all commits, as well as the build overview. In doing this, we can see what commits made it into the specific release.</p> <p>Since a "person" didn't create the release, we don't associate the release with a person.</p> <p>For reference, here's the script we use to generate releases in Teamcity.<br> <a href="https://gist.github.com/ChaseFlorell/716ffd1e4213ecfc8a8b" rel="nofollow">https://gist.github.com/ChaseFlorell/716ffd1e4213ecfc8a8b</a></p> |
3,305,546 | 0 | <p>The Entity Framework does exactly that, and very well. It also does a whole lot more such as let you write strong typed LINQ queries directly from your application code.</p> <p>your other good options are NHibernate or Linq to SQL</p> <p>this class of frameworks is generally called Object Relational Mapper (ORM)</p> <p>I would say Entity Framework offers the most conveniences for beginners such as visually configuring your data model. it can infer your object model from your database or it can create a database for you from your object model. </p> <p>The new Entity Framework Code First approach is incredibly simple and powerful in my opinion <a href="http://blogs.msdn.com/b/adonet/archive/2010/07/14/ctp4codefirstwalkthrough.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/b/adonet/archive/2010/07/14/ctp4codefirstwalkthrough.aspx</a></p> |
4,046,742 | 0 | <p>You can't. The yank buffer is private to vim, not shared with the system clipboard.</p> |
39,969,906 | 0 | <p>Add a try catch block around the code you are using to execute the query</p> <pre><code> try { // Execute query } catch (Exception) { // Exception handling throw; } </code></pre> |
11,202,676 | 0 | Unable to get desired output in mysql <p>I am working on a project report which requires some tricky output from a single table.</p> <p>This is the structure of the table named: <strong>daily_visit_expenses</strong> <img src="https://i.stack.imgur.com/D1I0f.png" alt="daily_visit_expenses"></p> <p>having data like this:: <img src="https://i.stack.imgur.com/H4hlN.png" alt="enter image description here"></p> <p>now what i want the output is the combination of these three queries in a single column (any name), the queries are:</p> <pre><code>SELECT DISTINCT(`cust_1`) FROM `daily_visit_expenses` WHERE user='sanjay' AND `purpose_1`='Sales' SELECT DISTINCT(`cust_2`) FROM `daily_visit_expenses` WHERE user='sanjay' AND `purpose_2`='Sales' SELECT DISTINCT(`cust_3`) FROM `daily_visit_expenses` WHERE user='sanjay' AND `purpose_3`='Sales' </code></pre> <hr> <p>I want to get the output from a single query which is the combination of above three queries in a single column like <code>customers</code> which is <code>DISTINCT</code>.</p> <p>SQL Export:</p> <pre><code>CREATE TABLE IF NOT EXISTS `daily_visit_expenses` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `user` varchar(255) NOT NULL, `date` date NOT NULL, `status` varchar(50) NOT NULL, `location` varchar(50) NOT NULL, `cust_1` varchar(255) NOT NULL, `cust_2` varchar(255) NOT NULL, `cust_3` text NOT NULL, `cust_4` text NOT NULL, `purpose_1` varchar(20) NOT NULL, `purpose_2` varchar(20) NOT NULL, `purpose_3` varchar(20) NOT NULL, `purpose_4` varchar(20) NOT NULL, `visit_type` varchar(20) NOT NULL, `expenses` bigint(20) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ; INSERT INTO `daily_visit_expenses` (`id`, `user`, `date`, `status`, `location`, `cust_1`, `cust_2`, `cust_3`, `cust_4`, `purpose_1`, `purpose_2`, `purpose_3`, `purpose_4`, `visit_type`, `expenses`) VALUES (5, 'sanjay', '2012-06-15', 'Working', 'Customer', 'S.G.R.S. Chemical & Minral Industries', '', 'fatehpur foundry', '', 'Sales', '', 'Sales', '', 'Outstation', 2323), (8, 'sanjay', '2012-06-25', 'Working', 'Office', '', '', '', '', '', '', '', '', '', 0), (9, 'sanjay', '2012-06-09', 'Working', 'Office', '', '', '', '', '', '', '', '', '', 0), (10, 'sanjay', '2012-06-05', 'Working', 'Customer', 'V.N INTERNATIONAL', 'G.SURGIWEAR', '', '', 'Sales', 'Sales', '', '', 'Outstation', 332), (11, 'sanjay', '2012-06-30', 'Working', 'Customer', 'Ganesh Plywood-Sitapur', '', '', '', 'Service', '', '', '', 'Outstation', 434), (12, 'sanjay', '2012-06-04', 'Absent', '', '', '', '', '', '', '', '', '', '', 0), (13, 'sanjay', '2012-06-06', 'Absent', '', '', '', '', '', '', '', '', '', '', 0), (14, 'sanjay', '2012-06-08', 'Leave', '', '', '', '', '', '', '', '', '', '', 0); </code></pre> |
2,378,640 | 0 | <p>you say you can't install anything, but could you write the necessary stuff into the registry yourself? I think that all regasm does is write all some stuff to the registry, so you could effectively do that from your VB code on startup if its not there and then you might be able to load the interop assembly.</p> <p>you can use a tool like <a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx" rel="nofollow noreferrer">process monitor</a> to see what gets written to the registry when you run regasm.</p> <p>I'd make sure you are using the -codebase switch and explicitly defining Guids for your interfaces and classes for the com wrappers as well. not doing so caused me no end of issues trying to get com wrapped .net dlls to work properly</p> |
1,173,447 | 0 | <p>You will need to use the RegEx.Matches function and iterate through the collection.</p> |
9,229,636 | 0 | Internet Explorer 7 clickable area links with no fixed width <p>I would like to know if there's a way to set the clickable area of links always strech to the to the parents container when parent container doesn't have a fixed width.</p> <p>Example: <a href="http://jsfiddle.net/gYukv/" rel="nofollow">http://jsfiddle.net/gYukv/</a></p> <p>On Firefox the link strechs with the text and the <li> tag, on IE7 the clickable area of link remains small.</p> |
38,887,419 | 0 | <p>Open CMD, </p> <p>If you are in 32 bit OS, Run : </p> <p><code>C:\windows\Microsoft.NET\Framework\v4.0.30319> aspnet_regiis.exe -i</code> </p> <p>If you are in 64 bit OS, Run : </p> <pre><code>C:\windows\Microsoft.NET\Framework64\v4.0.30319> aspnet_regiis.exe -i </code></pre> |
38,999,669 | 0 | Concentric arcs in C3.js <p>I am trying to implement concentric arcs in a donut chart in C3.js. So far I have created the donut chart and now would like to add another arc inside the donut that represents the % of three pointers made by a basketball player. </p> <p>I am having trouble finding any examples of this with C3.js.</p> <p>Here is what the chart looks like: <a href="http://i.stack.imgur.com/ZV4LB.png" rel="nofollow">Donut Chart</a></p> <p>And I want to add another arc that is 15px in size and covers the percentage of three pointers made. Here is the code that I have so far.</p> <pre><code>var chart = c3.generate({ data: { columns: [ ['Shots', 50], ['Threes', 50] ], type: 'donut', colors: { Shots: '#ff0000', Threes: '#E8E8EE' } }, donut: { expand: false, label: { show: false, format: function(value, ratio) { console.log("value: " + value) return value; } }, width: 15 }, legend: { hide: true }, tooltip: { show: false } }); d3.select(".c3-chart-arcs-title") .append("tspan") .attr("dy", -20) .attr("x", 0) .text("Year: 5"); d3.select(".c3-chart-arcs-title") .append("tspan") .attr("dy", 16) .attr("x", 0) .text("50% Shots Made"); d3.select(".c3-chart-arcs-title") .append("tspan") .attr("dy", 16) .attr("x", 0) .text("25% 3ptrs Made"); </code></pre> |
30,823,398 | 0 | <p>There is a problem about your styling, you use percentage for every measure, this means adapt your position based on parent side, parent is window size here.</p> <p>So it's normal everthings moving if you don't limit the wrapper width.</p> <p>You can use min-width to handle this.</p> <pre><code>#wrapper { margin: 0 auto; min-width:960px; } </code></pre> |
17,052,884 | 0 | .net web service to validate LDAP credentials using SSL <p>So I'm new to the whole .net thing here, but basically what I want to do is write a web service that will take a SOAP request with user's name and password and check them against an ldap server to validate that the credentials are right. I've already done this in perl, the code is below, but I'd like to replicate it in .net to get some more exposure to it. I've been poking around with c# since I've done a good amount of java programming and it seems like they are pretty similar, but if it's easier in vb or something else I'm not opposed to that. </p> <p>The main problem I'm having is actually connecting to the server itself. I've found some examples online but I'm getting confused as to what I should be passing to various methods. Here is the perl version of the web service:</p> <p><strong>authenticate.cgi</strong></p> <pre><code>use strict; use warnings; use SOAP::Transport::HTTP; SOAP::Transport::HTTP::CGI ->dispatch_to('Authenticate') ->handle; package Authenticate; use Net::LDAPS; use Net::LDAP; sub Verify{ my ($class, $user, $pass) = @_; my $user_dn = "uid=$user,ou=people,o=domain"; my $ldap = Net::LDAPS->new( 'ldap.domain.com', port => '636' ) or die "$@"; my $mesg = $ldap->bind($user_dn, password => $pass); return $mesg->error if $mesg->is_error; return "Successful authentication for user '$user'"; } </code></pre> <p>What i've been messing with in c# is the following (I might have unnecessary includes, i've been messing with a bunch of things):</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.DirectoryServices; using System.DirectoryServices.Protocols; using System.Net; /// <summary> /// Summary description for WebService /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] public class WebService : System.Web.Services.WebService { public WebService () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string Authenticate(string username, string pwd) { string domain = "LDAP://ldap.domain.com:636"; string domainAndUsername = domain + @"\" + username; string path = domain + @"/ou=people,o=domain"; string filterAttribute; DirectoryEntry entry = new DirectoryEntry(path, domainAndUsername, pwd); try { //Bind to the native AdsObject to force authentication. object obj = entry.NativeObject; DirectorySearcher search = new DirectorySearcher(entry); search.Filter = "(SAMAccountName=" + username + ")"; search.PropertiesToLoad.Add("cn"); SearchResult result = search.FindOne(); if (null == result) { return "false"; } //Update the new path to the user in the directory. path = result.Path; filterAttribute = (string)result.Properties["cn"][0]; } catch (Exception ex) { throw new Exception("Error authenticating user. " + ex.Message); } return "true"; } } </code></pre> <p>This has been resulting in the error</p> <blockquote> <p>System.Exception: Error authenticating user. The server is not operational.</p> </blockquote> <p>I feel like I am just specifying the path wrong somewhere or something like that, but I can't seem to figure it out. </p> |
34,909,054 | 0 | <p>You can't set the ratio, but there's always <code>padding-bottom</code>!</p> <pre><code>div { width: 100%; padding-bottom: 75%; } </code></pre> <p>This code will set <code>div</code> to 4:3 ratio</p> <p>For 16:9 ratio use <code>padding-bottom: 56.25%</code></p> <p><strong>An edit after re-read</strong></p> <p>What if I suggest using a div inside a div?</p> <pre><code><div class="a"> <div class="b"> </div> </div> <style> .a{ width:100%; padding-bottom: 75%; background-color: red; position: relative; } .b{ width: 100%; max-height: 100%; background-color: white; position: absolute; overflow: hidden; } </style> </code></pre> <p>Put the content inside <code>div.b</code> and it will never exceed the 75%</p> |
17,067,261 | 0 | How to unpivot result in query? <p>I am using MS SQL 2005.</p> <p>This is the query:</p> <pre><code>SELECT allow_r, allow_h, allow_c, sponsorid FROM Sponsor WHERE sponsorid = 2 </code></pre> <p>This is the result:</p> <pre><code>allow_r allow_h allow_c sponsorid ---------- ---------- ---------- ----------- 1 1 0 2 </code></pre> <p>I need it to be:</p> <pre><code>allow_r 1 2 allow_h 1 2 </code></pre> <p>allow_c should not be in the result as its 0</p> |
9,277,243 | 0 | Does connect.session work with node-azure <p>I'm starting to develop an application using node.js on azure. I'm using everyauth to provide authentication because I want to support lots of different authentication methods. I plan to deploy to Azure. The potential problem I have is that everyauth requires the connect.session helper. Will this work with azure when running multiple instances? Or do I need an alternative session provider?</p> |
25,501,814 | 0 | Symfony2 $request->request is emtpy <p>I have a page with two forms that can be submitted separately. I tried <a href="http://stackoverflow.com/questions/12022166/symfony-post-variable-always-empty">this approach</a> to check which form was submitted, but $request->request is always an empty array. What am I missing?</p> <pre><code>public function submitAction(Request $request) { $dm = $this->get('doctrine_mongodb')->getManager(); $processes = $dm->getRepository('MyCoreBundle:Process')->findAll(); $formClients = $this->createForm(new FiltersFormType(), $processes); $formClients->handleRequest($request); $formSuppliers = $this->createForm(new SupplierFormType(), $processes); $formSuppliers->handleRequest($request); } </code></pre> <p>Edit: it's being posted via GET</p> |
17,016,202 | 0 | Generating an A5 PDF document from HTML using Java iText <p>I'd like to generate an A5 page-size PDF document from a given HTML template using the iText Java library.</p> <p>I have been successful in generating a PDF, but rather than one A5 page, I get one A4 page (with the text on it) followed by an empty A5 page (see: <a href="http://sdrv.ms/11tAmlq" rel="nofollow">the output document</a>). What am I doing wrong?</p> <p>A sample java code follows.</p> <p>Many thanks for help.</p> <pre><code> public final class Main { public static void main(String[] args) throws IOException, DocumentException { htmlToPdf(new StringReader("<html><head><title>Hello, World!!!</title></head><body style=\"font-family: 'Times New Roman', serif;\"><div>Hello, World!!!</div></body></html>"), new File("Test.pdf")); } private static void htmlToPdf(final StringReader htmlSource, final File pdfOutput) throws IOException, DocumentException { final FileOutputStream pdfOutputStream = new FileOutputStream(pdfOutput); final PdfDocument document = new PdfDocument(); FontFactory.defaultEmbedding = true; document.setPageSize(com.itextpdf.text.PageSize.A5); final PdfWriter pdfWriter = PdfAWriter.getInstance(document, pdfOutputStream, PdfAConformanceLevel.PDF_A_1B); document.addWriter(pdfWriter); document.open(); XMLWorkerHelper.getInstance().parseXHtml(pdfWriter, document, htmlSource); document.close(); pdfOutputStream.close(); } } </code></pre> |
25,145,333 | 0 | jQuery Toggle (Expanding Div) Inconsistent Transition With Text <p>I've got my expanding div working, however it seems the transition opens abruptly on divs with text, yet closes with a smooth transition. My code is below as is a link to a jsFiddle demo. </p> <p>How can I get the transition on the open to be as smooth as it demonstrates on the closing?</p> <p>Demo: <a href="http://jsfiddle.net/phamousphil/s34fA/1/" rel="nofollow">http://jsfiddle.net/phamousphil/s34fA/1/</a></p> <p>HTML:</p> <pre><code> <div class="grid_6 containerExpand collapsedExp"> <div class="headerExpand"><a href="http://www.google.com">the google</a><br /></div> <div class="contentExpand"> <p>google stuff google stuff google stuff! google stuff google stuff google stuff! google stuff google stuff google stuff! google stuff google stuff google stuff!</p><br /> <p>google stuff google stuff google stuff! google stuff google stuff google stuff! google stuff google stuff google stuff! google stuff google stuff google stuff!</p> </div> </div> <div class="grid_6 containerExpand collapsedExp"> <div class="headerExpand"><a href="http://www.yahoo.com">YAHOO</a><br /></div> <div class="contentExpand"> <p>Yahoo!.</p> </div> </div> </code></pre> <p>CSS:</p> <pre><code>.containerExpand { } .headerExpand { cursor: pointer; } .headerExpand:hover { background-color: #d3d3d3; } .collapsedExp .headerExpand { } .collapsedExp .headerExpand:hover { background-color: #d3d3d3; } .contentExpand { height: auto; min-height: 100px; overflow: hidden; transition: all 0.3s linear; -webkit-transition: all 0.3s linear; -moz-transition: all 0.3s linear; -ms-transition: all 0.3s linear; -o-transition: all 0.3s linear; } .collapsedExp .contentExpand { min-height: 0px; height: 0px; } </code></pre> <p>JavaScript:</p> <pre><code>$(function(){ $('.headerExpand').click(function(){ $(this).closest('.containerExpand').toggleClass('collapsedExp'); $(".headerExpand").find("a").click(function(e){e.stopPropagation()}); }); }); </code></pre> |
33,783,485 | 0 | Shopify Product Combinations or Addons <p>I would like to combine products in my shop.</p> <p>For example, I have the following products: A, B, C. Additionally, I have the products 1, 2, 3.</p> <p>All products can be bought individually. However, if a customer selects one of the products A, B or C, he/she can also select one of the products 1,2 or 3 for free (the customer will only be charged for product A, B or C).</p> <p>How would I set this up in the backend? Should I set this up using product options (1,2,3 would be possible options), or do I have to generate variants of A, B, C (eg. variant A+1, A+2, etc..). If yes, how can I do this?</p> <p>The important thing is, how can I set this up in a way that I can access necessary product data in the product template and that both products are added to the cart correctly (and removed from the inventory accordingly).</p> <p>Thanks for your help</p> |
26,730,831 | 0 | <p>Adding/removing <code>const</code>/<code>volatile</code> doesn't change the value of the pointer/reference.</p> |
6,496,943 | 0 | <p>Capistrano can be used for deployment of PHP projects too.</p> <p>You can use Git <code>post-commit</code> hook for deployment after each commit.</p> |
9,338,069 | 0 | WP7 - Back Button without Navigation Service <p>Is it possible to some how capture the Back Button Event without using the Navigation Service? </p> <p>A <a href="http://stackoverflow.com/questions/2873086/how-to-handle-the-back-button-on-windows-phone-7">previous post here on StackOverflow</a> describes the the Back Button Events (both the overload of <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.controls.phoneapplicationpage.onbackkeypress%28v=vs.92%29.aspx" rel="nofollow">OnBackKeyPress</a> and the event handler <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.controls.phoneapplicationpage.backkeypress%28v=vs.92%29.aspx" rel="nofollow">PhoneApplicationPage_BackKeyPress</a>) only seem to fire when the navigation service is used. </p> <p>My implementation is: </p> <pre><code>//Prepare the page; NextPage page = new NextPage(); //When we are ready to transition page.someData = data; page.parent = this; this.Content = page; </code></pre> <p>I'm using this so that I can store the page for use later (essentially so that I can cache it, especially since some of my pages download information from the internet, and so that I can pass it data like above. However, I still need to use the back button to return to the home page. </p> <p>Is there anyway to trigger the back button while using the above method? </p> |
38,177,638 | 0 | How to add item to array? <p>The item :</p> <pre><code>$image = wp_get_attachment_image_src( get_post_thumbnail_id( $loop->post->ID ), 'single-post-thumbnail' ); </code></pre> <p>The array :</p> <pre><code>$attachment_ids = $product->get_gallery_attachment_ids(); foreach( $attachment_ids as $attachment_id ) { echo '<img src="'.$image_link = wp_get_attachment_url( $attachment_id ).'">'; } </code></pre> <p>I need to add the item $img_url in the beginning of the array.</p> |
2,508,563 | 0 | <p>For anyone else who's doing the same thing here's the code that I got working. Thanks Jeffrey!</p> <pre><code> Image image = new Image(); BitmapSource tempSource = Window1.GetNextImage(i); CroppedBitmap cb = new CroppedBitmap(tempSource, new Int32Rect(0, 0, Math.Min((int)Window1.totalWinWidth, tempSource.PixelWidth), Math.Min((int)Window1.totalWinHeight, tempSource.PixelHeight))); image.Source = cb; canvas1.Children.Add(image); </code></pre> |
11,414,265 | 0 | <p><code>fwrite</code> writes to a <code>FILE*</code>, i.e. a (potentially) buffered <code>stdio</code> stream. It's specified by the ISO C standard. Additionally, on POSIX systems, <a href="http://stackoverflow.com/a/468105/166749"><code>fwrite</code> is thread-safe</a> to a certain degree.</p> <p><code>write</code> is a lower-level API based on file descriptors, described in the POSIX standard. It doesn't know about buffering. If you want to use it on a <code>FILE*</code>, then fetch its file descriptor with <code>fileno</code>, but be sure to manually lock and flush the stream before attempting a <code>write</code>.</p> <p>Use <code>fwrite</code> unless you know what you're doing.</p> |
23,093,097 | 0 | using SSH to run a cleartool command with agruments on remote a linux machine <p>when I run this then everything work:</p> <pre><code>C:\PROGRA~1\cwRsync\bin\ssh.exe -o 'StrictHostKeyChecking no' 10.10.10.10 -l username /usr/atria/bin/cleartool setview -exec 'pwd' cm_myview </code></pre> <p>however if I have more than two arguments after exec like this:</p> <pre><code>C:\PROGRA~1\cwRsync\bin\ssh.exe -o 'StrictHostKeyChecking no' 10.10.10.10 -l username /usr/atria/bin/cleartool setview -exec 'cd /user' cm_myview </code></pre> <p>then it will fail with the error: extra argument:"cm_myview"</p> <p>so right now if there is more than 2 argument after -exec, then it will say those argument are extra, anyone know how I can fix this. Thanks. </p> <p>I am only running one command which run a script file. But I need to pass arguments to this script file. I think the program think the first argument is the view i am tying to set. </p> |
20,153,400 | 0 | <p>A datagridview is a representation of data. The datagridview will save nothing in itself. Please read about <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.datasource%28v=vs.110%29.aspx" rel="nofollow">datagridviews and their data sources</a> - and then if still in a troublesome condition, rephrase and come back here.</p> |
23,662,659 | 0 | why a class can not be subclassed if i declare its default constructor as private <blockquote> <p>In a class i can have as many constructors as I want with different argument types. I made all the constructors as private,it didn't give any error because my implicit default constructor was public But when i declared my implicit default constructor as private then its showing an error while extending the class. <strong>WHY?</strong></p> </blockquote> <h2>this works fine</h2> <pre><code>public class Demo4 { private String name; private int age; private double sal; private Demo4(String name, int age) { this.name=name; this.age=age; } Demo4(String name) { this.name=name; } Demo4() { this("unknown", 20); this.sal=2000; } void show(){ System.out.println("name"+name); System.out.println("age: "+age); } } </code></pre> <h2>This can not be inherited</h2> <pre><code>public class Demo4 { private String name; private int age; private double sal; private Demo4(String name, int age) { this.name=name; this.age=age; } Demo4(String name) { this.name=name; } private Demo4() { this("unknown", 20); this.sal=2000; } void show() { System.out.println("name"+name); System.out.println("age: "+age); } } </code></pre> |
25,940,124 | 0 | Do powershell parameters need to be at the front of the script? <p>I'm trying to have a script with both executable code and a function, like the following: </p> <pre><code>function CopyFiles { Param( ... ) ... } // Parameter for the script param ( ... ) // Executable code </code></pre> <p>However, I run into the following error: "The assignment expression is not valid. The input to an assignment operator must be an object that is able to accept assignments, such as a variable or a property"</p> <p>When I list my function at the end of the file, it says that the function name is undefined. How do I call a powershell function from executable code within the same script? </p> |
22,763,016 | 0 | <p>Download the SDK 7.0.0.27 and install it via UPDI then apply import. SDK fix pack download: <a href="http://www-01.ibm.com/support/docview.wss?uid=swg24033882" rel="nofollow">http://www-01.ibm.com/support/docview.wss?uid=swg24033882</a></p> |
30,732,228 | 0 | <p>You won't subscribe, you'll just have an observable in your viewmodel that you set to true or false, and the menu item will toggle in response. The disabled member of your menu item will look like this:</p> <pre><code>disabled: function() { return myobservable(); } </code></pre> <p>As James Thorpe commented, you'll want to create a custom binding handler to set up your context menu.</p> <p>It sounds like you're working with several unfamiliar tools. Here is a Fiddle with a minimal example: <a href="http://jsfiddle.net/sv3m7ok8/" rel="nofollow">http://jsfiddle.net/sv3m7ok8/</a></p> <p><strong>Update</strong> It occurred to me that since the context menu doesn't bind to a single element, but uses a selector, it makes more sense to do the binding on the <code>body</code> tag. So an updated example: <a href="http://jsfiddle.net/sv3m7ok8/1/" rel="nofollow">http://jsfiddle.net/sv3m7ok8/1/</a></p> <p><strong>Updated again</strong> I now understand that you are specifically trying to get the menu item to enable/disable while the menu is open (and that it doesn't do that normally). I had to go under the covers to get at the menu item node, and hook up a subscription to set the disabled class on it.</p> <pre><code>init: function (element, data, allbindings, data) { var dynamicDisable = false; $.contextMenu({ selector: '.context-menu-one', callback: function (key, options) { var m = "clicked: " + key; window.console && console.log(m) || alert(m); }, items: { "edit": { name: "Clickable", icon: "edit", disabled: function (opt, key) { if (!dynamicDisable) { var node = key.items.edit.$node[0]; data.disableMenu.subscribe(function (dis) { $(node)[dis ? 'addClass' : 'removeClass']('disabled') }); dynamicDisable = true; } return data.disableMenu(); } } } }); } </code></pre> <p>My fiddle sets an interval to toggle disableMenu. You can watch the menu item become active and gray.</p> <p><a href="http://jsfiddle.net/sv3m7ok8/3/" rel="nofollow">http://jsfiddle.net/sv3m7ok8/3/</a></p> |
13,341,979 | 0 | Adding OverlayItems to MapView is reallyslow, how to make it faster? <p>In my app there is a MapView, and I add OverlayItems to it, <strong>about 500</strong>, <strong>but it will be more even thousands in the future...</strong></p> <p>My problem is: When I switch to this Activity, <strong>I got a massive 3-4 sec blackout</strong> then it switches properly and I can navigate and tap on the map.</p> <p>Some months ago when the app only contained 50-150 GeoPoints in the mapView there was no blackout. So i think something is wrong with my OverlayItem adding to the mapView, it really slows then the app.</p> <p>I add my GeoPoints with a simple cycle on Activity startup.</p> <p>What can i do to make this Activity <strong>faster and prevent the blackout?</strong></p> <p>EDIT:</p> <p>Thanks to comments, i just realized <strong>i call populate()</strong> after every <strong>addOverlay(MyOverlayItem myoverlay)</strong> function call.</p> <p>I edited the code, now after the cycle i call it only once by:</p> <pre><code>public void populateNow() { populate(); } </code></pre> <p>But i just got a nice null pointer exception with this... Any ideas?</p> <pre><code>11-12 15:54:03.398: E/MapActivity(1534): Couldn't get connection factory client 11-12 15:54:03.531: E/AndroidRuntime(1534): FATAL EXCEPTION: main 11-12 15:54:03.531: E/AndroidRuntime(1534): java.lang.NullPointerException 11-12 15:54:03.531: E/AndroidRuntime(1534): at com.google.android.maps.ItemizedOverlay.getIndexToDraw(ItemizedOverlay.java:211) 11-12 15:54:03.531: E/AndroidRuntime(1534): at com.google.android.maps.ItemizedOverlay.draw(ItemizedOverlay.java:240) 11-12 15:54:03.531: E/AndroidRuntime(1534): at com.google.android.maps.Overlay.draw(Overlay.java:179) 11-12 15:54:03.531: E/AndroidRuntime(1534): at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:42) 11-12 15:54:03.531: E/AndroidRuntime(1534): at com.google.android.maps.MapView.onDraw(MapView.java:530) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.View.draw(View.java:6933) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewGroup.drawChild(ViewGroup.java:1646) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewGroup.drawChild(ViewGroup.java:1644) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.View.draw(View.java:6936) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.widget.FrameLayout.draw(FrameLayout.java:357) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewGroup.drawChild(ViewGroup.java:1646) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.View.draw(View.java:6936) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.widget.FrameLayout.draw(FrameLayout.java:357) 11-12 15:54:03.531: E/AndroidRuntime(1534): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1904) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewRoot.draw(ViewRoot.java:1527) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewRoot.performTraversals(ViewRoot.java:1263) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.view.ViewRoot.handleMessage(ViewRoot.java:1865) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.os.Handler.dispatchMessage(Handler.java:99) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.os.Looper.loop(Looper.java:123) 11-12 15:54:03.531: E/AndroidRuntime(1534): at android.app.ActivityThread.main(ActivityThread.java:3687) 11-12 15:54:03.531: E/AndroidRuntime(1534): at java.lang.reflect.Method.invokeNative(Native Method) 11-12 15:54:03.531: E/AndroidRuntime(1534): at java.lang.reflect.Method.invoke(Method.java:507) 11-12 15:54:03.531: E/AndroidRuntime(1534): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) 11-12 15:54:03.531: E/AndroidRuntime(1534): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 11-12 15:54:03.531: E/AndroidRuntime(1534): at dalvik.system.NativeStart.main(Native Method) </code></pre> |
26,037,672 | 0 | <p>Since you want to get all the elements whose immediate text contains 'Total amount', the <code>:contains('')</code> selector won't help you as it will return all the elements in the upper hierarchy of the actual element.<br> Try this <strong>JQuery</strong> code:</p> <pre><code>$('body *').each(function() { if($(this).clone().children().remove().end().text().indexOf("Total amount") > -1) { // $(this) has your desired text as it's immediate text, so use it here } }); </code></pre> <p><strong>JSFiddle:</strong> <a href="http://jsfiddle.net/y00d1n5u/1/" rel="nofollow">http://jsfiddle.net/y00d1n5u/1/</a><br> Above code iterates over all the elements inside the <code>body</code> tag, strips each element's children and searches the remaining text for the search string.</p> |
17,047,847 | 0 | Forward data from UDP Socket to HTTP Server Node.js <p>I am looking to create a Web Service from data that is being retrieved via UDP connection and have decided to use Node.js and Socket.IO but, have come up short in that I think this combination does not give me the result I want. I was hoping someone could point me in the right direction. </p> <p>Right now, I have the following:</p> <pre><code>// require http, socket and socket.io var http = require('http'); var dgram = require('dgram'); var socketio = require('socket.io'); // setup HTTP server, Socket.IO and UDP Socket var server = http.createServer( handleRequest ), io = socketio.listen(server), socket = dgram.createSocket("udp4"); // Every time I receive a UDP Message socket.on("message", function(msg,rinfo) { // create a buffer we will store to var buffer = new Buffer(msg.length); // copy entire message into buffer msg.copy(buffer, 0, 0, msg.length); // if the message has length > 3 if ( buffer.length > 3 ) { .... take data off the socket .... // Create an XML document var xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; xml += ... ; xml += ... ; // emit a udp message event io.sockets.emit('udp message', xml); } }); function handleRequest(req, res) { res.writeHead(200, {'content-type': 'text/html'}); res.end("<!doctype html> \ <html><head> \ <script src='/socket.io/socket.io.js'></script> \ <script> \ var socket = io.connect('localhost', {port: 8888}); \ socket.on('udp message', function(message) { res.end(message) }); \ </script></head></html>"); } socket.bind(9876); server.listen(8888); </code></pre> <p>Everything works well recv'ing the UDP data stream, creating the XML documents and I can see the XML being sent to the WebSocket but, I cannot retrieve the XML. Basically, I want a to continuously stream the XML once a user connects to the Web Service</p> <p>Thoughts ? Dennis</p> |
30,004,639 | 0 | How to join a string by line endings in Ruby <p>I have an array of strings, which I wish to join by line ending:</p> <pre><code>a = ['first line', 'second line', 'third line'] </code></pre> <p>I want to join them in ruby in the most idiomatic way, using the OS default line ending, so that it would use <code>'\r\n'</code> to join the lines on windows and it would use <code>'\n'</code> to join the lines on *NIX. In python, I would do this:</p> <pre><code>os.linesep.join(a) </code></pre> <p>How would I do this idiomatically in ruby?</p> |
16,649,558 | 0 | TRAC. Return a javascript variable back to javascript <p>Is there any way to pass a javascript varialbe during process_request in trac 0.11? The code goes like this:</p> <pre><code>def process_request(self, req): component = req.args.get('component_name') milestones = [] db = self.env.get_db_cnx() cursor = db.cursor() milestones_sql = "SELECT name FROM milestone WHERE component = '" + component+ "'" cursor.execute(milestones_sql) milestones = cursor.fetchall() milestones = itertools.chain(*milestones) db.commit() return 'filter.js', {'milestones':json.dumps(list(milestones))}, 'text/plain' </code></pre> <p>I get arguments, do a SQL query, and want to return result to a script. Not as a string though.</p> |
20,632,498 | 0 | Provisioning profile issue in IOS <p>My Provisioning profile is going to expire in two days,so build in the device will not work after that. is there any method to update the old profile and to make work build as usual.</p> <p>thanks in advance </p> |
32,881,147 | 0 | <p>You can't, and the sign up view is also inappropriate as it will ask for a password which isn't required. Instead you should show a new view asking for additional details then set those details onto the new user and save it.</p> |
37,669,466 | 0 | <p>I am not quite sure what your worry is (and maybe you should clarify your question if that answer isn't sufficient), but <code>m[10] += 1;</code> doesn't get translated to <code>m[10] = m[10] + 1;</code> because <code>m</code> is user defined class type and overloaded operators don't get translated by the compiler, ever. For <code>a</code> and <code>b</code> objects with a user defined class type:</p> <ul> <li><code>a+=b</code> doesn't mean <code>a = a + b</code> (unless you make it so) </li> <li><code>a!=b</code> doesn't mean <code>!(a==b)</code> (unless you make it so)</li> </ul> <p>Also, function calls are never duplicated.</p> <p>So <code>m[10] += 1;</code> means call overloaded <code>operator[]</code> once; return type is a reference, so the expression is a lvalue; then apply the builtin operator <code>+=</code> to the lvalue.</p> <p>There is no order of evaluation issue. There isn't even multiple possible orders of evaluation!</p> <p>Also, you need to remember that the <code>std::map<>::operator[]</code> doesn't behave like <code>std::vector<>::operator[]</code> (or <code>std::deque</code>'s), because the <code>map</code> is a completely different abstraction: <code>vector</code> and <code>deque</code> are implementations of the Sequence concept (where position matters), but <code>map</code> is an associative container (where "key" matters, not position): </p> <ul> <li><code>std::vector<>::operator[]</code> takes a numerical index, and doesn't make sense if such index doesn't refer to an element of the vector.</li> <li><code>std::map<>::operator[]</code> takes a key (which can be any type satisfying basic constraints) and <strong>will create a (key,value) pair if none exists</strong>.</li> </ul> <p>Note that for this reason, <strong><code>std::map<>::operator[]</code> is inherently a modifying operation and thus non const</strong>, while <code>std::vector<>::operator[]</code> isn't inherently modifying but can allow modification via the returned reference, and is thus "transitively" const: <code>v[i]</code> will be a modifiable lvalue if <code>v</code> is a non-const vector and a const lvalue if <code>v</code> is a const vector.</p> <p>So no worry, the code has perfectly well defined behavior.</p> |
7,093,864 | 0 | <p>I think I have worked out the issue. The steps follow:</p> <ul> <li>Create an an individual named LoggerRepository on each thread.</li> <li>Set the ThreadContexts property for the log file name.</li> <li>Use the XmlConfiguratior to configure the repository.</li> <li>Use the LogManager to Get the named logger (in the XML configuration file) using the named LoggerRepository for that thread.</li> </ul> <p>In return I get a new configured logger pointing to the respective file for that thread.</p> <p>The XML configuration is the same as it was originally and shown here for completeness:</p> <pre class="lang-xml prettyprint-override"><code><?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> </configSections> <log4net> <logger name="ProductionLogger"> <appender-ref ref="XmlAppender"/> <level value="ALL"/> </logger> <appender name="XmlAppender" type="log4net.Appender.FileAppender"> <file type="log4net.Util.PatternString" value="D:\Temp\Logs\%property{LogName}.log" /> <immediateFlush value="true"/> <appendToFile value="true" /> <layout type="log4net.Layout.SimpleLayout" /> </appender> </log4net> </configuration> </code></pre> <p>The code to create the loggers is below. Each time this code is run it is run in its own thread.</p> <pre><code>ILoggerRepository loggerRepository = LogManager.CreateRepository(logFileName + "Repository"); ThreadContext.Properties["LogName"] = logFileName; log4net.Config.XmlConfigurator.Configure(loggerRepository); ILog logger = LogManager.GetLogger(logFileName + "Repository", "ProductionLogger"); </code></pre> <p>This seems to work with no issues so far. I will be moving forward with this solution for the moment but I will update this post if I find out anything else.</p> |
2,396,051 | 0 | <p>You should entirely avoid this problem by using a canonical link tag. <a href="http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html" rel="nofollow noreferrer">http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html</a></p> |
31,790,854 | 0 | <p>another nice solution for specific nodes, is to use the standard $title_prefix/suffix vars, which should be implemented by every theme. using the standard class element-invisible in page preprocess ..</p> <p>like:</p> <p> <pre><code>/** * Implements hook_preprocess_page(). */ function YOUR_THEME_preprocess_page(&$variables) { if (isset($variables['node']) && $variables['node']->nid == 1) { $variables['title_prefix'] = array('#markup' => '<div class="element-invisible">'); $variables['title_suffix'] = array('#markup' => '</div>'); } } </code></pre> |
33,355,004 | 0 | How to include collection data on aggregation <p>I have the following MongoDB document structure:</p> <pre><code>user: { name: 'user name', email: '[email protected]', isBlocked: false, cvs: [{ title: "role title", technologies: [ {name: 'JavaScript'} {name: 'NodeJs'} ], agents: [ { _id:'some id1', contactRequest: true }, { _id:'some id2', contactRequest: false } ], }] } </code></pre> <p>How can I add <code>user.name</code> to the output if I perform an aggregation with grouping on embedded document's property, e.g.</p> <pre><code>db.users.aggregate([ { "$match": { "cvs.isBlocked": false, "cvs.moderated": true, "cvs.isVisible": true, "cvs.technologies.main": true } }, {"$unwind": "$cvs"}, {"$unwind": "$cvs.technologies"}, { "$match": { "cvs.isBlocked": false, "cvs.moderated": true, "cvs.isVisible": true, "cvs.technologies.main": true } }, { "$group": { "_id": { "type": "$cvs.occupationType", "proficiency": "$cvs.proficiencyLevel", "_id": "$cvs._id", "title": "$cvs.title" }, "technologies": { "$push": "$cvs.technologies.text" } } }, { "$project": { "type": "$_id.type", "proficiency": "$_id.proficiency", "_id": "$_id._id", "title": "$_id.title", "technologies": 1, } } ]) </code></pre> <p>$$ROOT refers to $cvs in that case.</p> <p>Additionally I would like to include <code>user.name</code> and <code>email</code> only if <code>user.isBlocked</code> is <code>false</code> and <code>agent.contactRequest</code> is <code>true</code>.</p> |
32,747,235 | 0 | URL redirection in mac osx yosemite <p>I need to redirect a particular url to my localhost in mac osx-yosemite. I'm able to do the port forwarding using the following. </p> <pre><code>echo " rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080 rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 8443 " | sudo pfctl -ef - </code></pre> <p>But can't figure out how to make a particular URL to be redirected to my localhost. Thanks for the help </p> |
1,222,085 | 0 | <p>It's hard to tell without the complete stacktrace (please?), but I would guess that IN doesn't like being passed entities rather than keys. Try this:</p> <pre><code>users = [userA.key(), userB.key(), userC.key()] messages = Message.gql("WHERE user in :users", users=users).fetch(100 </code></pre> |
26,778,714 | 0 | Video play on hover <p>I have a selection of video thumbnails that I want to trigger to play/pause on hover. I have managed to get one of them to work, but I run into a problem with the others on the list. Attached is the fiddle of my code. There will be a div covering each html5 video so the hover needs to delegate to the video, which i'm unsure as to how to do.</p> <p><a href="http://jsfiddle.net/meh1aL74/" rel="nofollow">http://jsfiddle.net/meh1aL74/</a></p> <p>Preview of the html here - </p> <pre><code><div class="video"> <div class="videoListCopy"> <a href="videodetail.html" class="buttonMore"> <div class="breaker"><div class="line"></div></div> <div class="buttonContent"> <div class="linkArrowContainer"> <div class="iconArrowRight"></div> <div class="iconArrowRightTwo"></div> </div> <span>Others</span> </div> </a> </div> <div class="videoSlate"> <video class="thevideo" loop> <source src="http://www.w3schools.com/html/movie.ogg" type="video/ogg"> Your browser does not support the video tag. </video> </div> </div> <div class="video"> <div class="videoListCopy"> <a href="videodetail.html" class="buttonMore"> <div class="breaker"><div class="line"></div></div> <div class="buttonContent"> <div class="linkArrowContainer"> <div class="iconArrowRight"></div> <div class="iconArrowRightTwo"></div> </div> <span>Others</span> </div> </a> </div> <div class="videoSlate"> <video class="thevideo" loop> <source src="http://www.w3schools.com/html/movie.ogg" type="video/ogg"> Your browser does not support the video tag. </video> </div> </div> </code></pre> <p>Preview of the javascript here - </p> <pre><code> var figure = $(".video"); var vid = $("video"); [].forEach.call(figure, function (item) { item.addEventListener('mouseover', hoverVideo, false); item.addEventListener('mouseout', hideVideo, false); }); function hoverVideo(e) { $('.thevideo')[0].play(); } function hideVideo(e) { $('.thevideo')[0].pause(); } </code></pre> <p>Thank you very much for your help.</p> <p>Oliver</p> |
4,838,486 | 0 | <p>try adding a parser like this guy does in here: <a href="http://jsbin.com/enata/edit" rel="nofollow">http://jsbin.com/enata/edit</a></p> <p>here is an article too: <a href="http://www.terminally-incoherent.com/blog/2008/09/29/jquery-tablesorter-list-of-builtin-parserssorters/" rel="nofollow">http://www.terminally-incoherent.com/blog/2008/09/29/jquery-tablesorter-list-of-builtin-parserssorters/</a></p> |
3,247,726 | 0 | Java DecimalFormat problem <p>I would like to format numbers of type double with a German locale in Java. However something goes wrong since the output of the following code is : 0.0</p> <pre><code>package main; import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.ParseException; import java.util.Locale; public class Test { private static String decimal2Format = "000.000"; public static void main(String args[]){ DecimalFormat format = (DecimalFormat)NumberFormat.getInstance(new Locale("de")); double value = 0; try { format.applyPattern(decimal2Format); value = format.parse("0.459").doubleValue(); } catch (ParseException e) { e.printStackTrace(); } System.out.println(value); } } </code></pre> <p>Do you have any ideas what is wrong or missing?</p> <p>Thanks, atticus</p> |
37,043,321 | 0 | How does this validation script work? <p>I have the following validation script that works fine, but I don't understand how it works and need your help with it.</p> <p>The HTML,</p> <pre><code><form action="xyz.php" method="post"> <div class="form-group"> <label class="sr-only" for="id">Enter ID</label> <input type="text" class="form-control" name="id" id="id" required> </div> <button onclick="return validateID()" type="submit" name="submit" class="btn">Submit</button> </form> </code></pre> <p>And this is the JS,</p> <pre><code><script> function validateID() { var id = document.getElementById("id").value; var regL= new RegExp("^([0-9][0-9][0-9])$"); if (!( (regL.test(id)) )) { window.location.href = "index-iderror.php"; return false; } else { return true; } } </script> </code></pre> <p>Some questions that I have about this,</p> <ol> <li>What happens when false or true is returned to onclick? Does it decide whether the form data is or is not sent to xyz.php?</li> <li>How does the execution continue till the line <code>return false</code> after <code>window.location.href</code>? Shouldn't <code>window.location.href</code> direct to a new page stopping execution? The script does not work if <code>return false</code> is removed i.e. the unchecked form data is sent to xyz.php.</li> </ol> |
23,325,687 | 0 | <p>The issue had to do with Uniform Server's (WAMP) setup php.ini file</p> <p>Uniform Server has a SEPARATE file for command line php commands.</p> <p>The name is php-cli.ini</p> <p>I added there the following two lines and everything was ok:</p> <pre><code>extension=php_pdo_mysql.dll extension=php_mbstring.dll </code></pre> |
35,350,853 | 0 | Angular2 - Different views with different template <p>With $stateProvider and abstract property in Angular 1, I could create different views with different template easily. For example in my application I have Login and Register pages which are using unauthTemplate. I have also Dashboard and Product pages that are using commonTemplate. In Angular 1, here is my states </p> <pre><code>$stateProvider .state('unauthTemplate', { abstract: true, url: '', controller: 'unauthTemplateController', templateUrl: '/app/common/unauthTemplate.html' }) .state('commonTemplate', { abstract: true, url: '', controller: 'commonTemplateController', templateUrl: '/app/common/commonTemplate.html' }) .state("unauthTemplate.login", { url: "/Login", controller: 'LoginController', templateUrl: '/app/views/login.html' }) .state("unauthTemplate.register", { url: "/Register", controller: 'RegisterController', templateUrl: '/app/views/register.html' }) .state("commonTemplate.dashboard", { url: "/dashboard", controller: 'DashboardController', templateUrl: '/app/views/dashboard.html' }) .state("commonTemplate.product", { url: "/product", controller: 'ProductController', templateUrl: '/app/views/product.html' }) </code></pre> <p>Since there is not "Abstract property" in RouteConfig in Angular2, I could not setup my app's route with the same approach in Angular 1. Can someone help me how can I have different view with different template. </p> <p>Thanks</p> |
24,612,466 | 0 | <p>There are different possibilities of implementing a threading system for a virtual machine. The two extreme forms are:</p> <ol> <li><strong>Green threads</strong>: All Java <code>Thread</code> instances are managed within one native OS thread. This can cause problems if a method blocks within a <code>native</code> invocation what makes this implementation complex. In the end, implementers need to introduce <em>renegade threads</em> for holding native locks to overcome such limitations. </li> <li><strong>Native threads</strong>: Each Java <code>Thread</code> instance is backed by a native OS thread.</li> </ol> <p>For the named limitations of green threads, all modern JVM implementations, including HotSpot, choose the later implementation. This implies that the OS needs to reserve some memory for each created thread. Also, there is some runtime overhead for creating such a thread as it needs direct interaction with the underlying OS. At some point, these costs accumulate and the OS refuses the creation of new threads to prevent the stability of your overall system.</p> <p>Threads should therefore be pooled for resue. Object pooling is normally considered bad practice as many programers used it to ease the JVM's garbage collector. This is not longer useful as modern garbage collectors are optimized for handling short-living objects. Today, by pooling objects you might in contrary slow down your system. However, if an object is backed by costly native resources (as a <code>Thread</code>), pooling is still a recommended practice. Look into the <a href="http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html" rel="nofollow"><code>ExecutorService</code></a> for a canonical way of pooling threads in Java.</p> <p>In general, consider that context switches of threads are expensive. You should not create a new thread for small tasks, this will slow your application down. Rather make your application less concurrent. You only have a number of cores which can work concurrently in the first place, creating more threads than your (non-virtual) cores will not improve runtime performance. Are you implementing some sort of divide-and-conquer algorithm? Look into Java's <a href="http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ForkJoinPool.html" rel="nofollow"><code>ForkJoinPool</code></a>.</p> |
25,527,712 | 0 | Set a general theme for progressDialog? <p>How can I set a theme for all progress bars that I create in my Project ?</p> <p>This is my style :</p> <pre><code><style name="MyTheme.ProgressDialog" parent="android:Theme.Holo.Light.Dialog.NoActionBar"> <item name="android:textColor">@android:color/anyColor</item> <item name="android:windowBackground">@android:color/transparent</item> </style> </code></pre> <p>And I set it manually in the constructor of each progressDialog I create :</p> <pre><code>loadingDialog = new ProgressDialog(this, R.style.MyTheme_ProgressDialog); </code></pre> <p>Can I set the theme to be the default for all progress dialogs I create without changin it in the constructor each time ?</p> |
13,084,102 | 0 | <p>Let's suppose that you have a <code>QGridLayout</code> with 4 rows and 3 columns and you want to add buttons to it automatically from top to bottom and from left to right. That can easily be achieved if you are able to predict the position of the next button to be added. In our case:</p> <ul> <li>row = number of added buttons / number of columns </li> <li>column = number of added buttons % number of columns</li> </ul> <p>(other type of filling work similarly). Let's put it in code:</p> <pre><code>from PyQt4.QtGui import * class MyMainWindow(QMainWindow): def __init__(self, parent=None): super(MyMainWindow, self).__init__(parent) self.central = QWidget(self) self.grid = QGridLayout(self.central) self.rows = 4 self.cols = 3 self.items = self.grid.count() while(self.items < (self.rows * self.cols)): self.addButton() self.setCentralWidget(self.central) def addButton(self): # the next free position depends on the number of added items row = self.items/self.cols col = self.items % self.cols # add the button to the next free position button = QPushButton("%s, %s" % (row, col)) self.grid.addWidget(button, row, col) # update the number of items self.items = self.grid.count() if __name__ == "__main__": import sys app = QApplication(sys.argv) ui = MyMainWindow() ui.show() sys.exit(app.exec_()) </code></pre> |
26,630,479 | 0 | Why does my <div> content </div> blink? <p>I'm kind of new to the Jquery world so can someone please help me understand my do my <code>$("#dothis").html("hit");</code> make the content only blink rather then simply show? i think that the function is repeating it self and that's what's causing it. </p> <p>html Code:</p> <pre><code> <form> <select class="plcardFirst"> <option selected value="">-- Choose One --</option> <option value="1/11">A</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="10">J</option> <option value="10">Q</option> <option value="10">K</option> </select> <select class="plcardSecond"> <option selected value="">-- Choose One --</option> <option value="1/11">A</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="10">J</option> <option value="10">Q</option> <option value="10">K</option> </select> <select class="dlCard"> <option selected value="">-- Choose One --</option> <option value="1/11">A</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="10">J</option> <option value="10">Q</option> <option value="10">K</option> </select> <input type="submit" value="Submit" id="Submit"> </form> <div id="dothis"> do this </div> </code></pre> <p>Script:</p> <pre><code> <script type="text/javascript"> var valueFirst; var valueSecond; var dlCard; $(document).ready(function () { $(".plcardFirst").change(function() { valueFirst = $( ".plcardFirst" ).val();//player first card; }); $(".plcardSecond").change(function() { valueSecond = $( ".plcardSecond" ).val();//player second card }); $(".dlCard").change(function() { dlCard = $( ".dlCard" ).val();//dealer card }); $("#Submit").click(function(){ $("#dothis").html("hit"); }); }); </script> </code></pre> |
27,133,796 | 0 | How to count all alphabetical characters in array? <p>So basically my objective is to make a program that takes the user input and reverses it and prints the inverse character back to user as an encoded message. Right now i need to print the statistics of the user entered string. How do i count the amount of occurrences of different letters from the user string. I have this so far.</p> <pre><code> import java.util.*; public class SecretCodeMachine { public static void main(String[]args) { //object accessing the non static methods SecretCodeMachine a = new SecretCodeMachine(); //input stream Scanner in = new Scanner (System.in); Scanner i = new Scanner (System.in); //prompt the user System.out.println("Please input your secret message."); String input = in.nextLine(); //calls the encodedMessage() method; equals the return value to varaible String encodedMessage = a.encodeMessage(input); //message and prompt System.out.println("Encoded message: " + encodedMessage); System.out.println("Enter the code in here to get the original message back."); String input2 = i.nextLine(); //if statements saying that if the input equals the encoed message... if (input2.equals(encodedMessage)) { //print this System.out.println("Original Message: " + input); } else { //prints when doesnt equal System.out.println("Message not found."); } //closes the input stream i.close(); in.close(); } //method for encoding the string from array public String encodeMessage(String pass) { //passes the parameter string and puts it in an array () char[] toArray = pass.toCharArray(); for (int i = 0; i < toArray.length; i++) { //does the lower case characters if (toArray[i] >= 'a' && toArray[i] <= 'z') { if (toArray[i] - 'a' <= 13) toArray[i] = (char) ('z' - (toArray[i] - 'a')); else toArray[i] = (char) ('a' + ('z' - toArray[i])); } //does the upper case characters else if(toArray[i] >= 'A' && toArray[i] <= 'Z') { if (toArray[i] - 'A' <= 13) toArray[i] = (char) ('Z' - (toArray[i] - 'A')); else toArray[i] = (char) ('A' + ('Z' - toArray[i])); } //if the characters are non alphatbetic else { toArray[i] = toArray[i]; } } //converts the toArray back to new string String encodedMessage = new String(toArray); //returns the encodedMessage string return encodedMessage; } </code></pre> <p>}</p> <p>So how would i keep a track off all the letters that are entered by the user?</p> |
9,321,485 | 0 | <p>You might not have write permissions to install a node module in the global location such as <code>/usr/local/lib/node_modules</code>, in which case run npm install -g package as root.</p> |
29,450,067 | 0 | <p>Adding some more to the latest reply.. To get the particular node value you can use the below-- [<code>System.out.println(nodes.item(0).getTextContent());</code>]</p> |
4,166,548 | 0 | I want that image popup in html when user click on tumbnil <p>I want that when user click on image thumbnil then the image popup just like it does in this <a href="http://www.alpacafarmingguide.com/why.htm" rel="nofollow">click here</a></p> <p>plesase tell me the simplest way to do this as i am new to web development. please help me out I am waiting for you kind response.</p> |
11,273,400 | 0 | <p>Sometimes, It happens, when your byte[] not decode properly after retrieving from database as blob type.</p> <p>So, You can do like this way, <strong>Encode - Decode</strong>,</p> <p>Encode the image before writing to the database:</p> <pre><code>ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); mBitmap.compress(Bitmap.CompressFormat.JPEG, THUMB_QUALITY, outputStream); mByteArray = outputStream.toByteArray(); // write this to database as blob </code></pre> <p>And then decode it like the from Cursor:</p> <pre><code>ByteArrayInputStream inputStream = new ByteArrayInputStream(cursor.getBlob(columnIndex)); Bitmap mBitmap = BitmapFactory.decodeStream(inputStream); </code></pre> <p>Also, If this not work in your case, then I suggest you to go on feasible way..</p> <ul> <li>Make a directory on external / internal storage for your application images.</li> <li>Now store images on that directory.</li> <li>And store the path of those image files in your database. So you don't have a problem on encoding-decoding of images.</li> </ul> |
33,297,763 | 0 | Force connection reestablishment from client app to GCM <p>We are using GCM for messaging from server to the client app. It is a standard implementation where installation of the client app talks to the gcm server to get the reg id, sends it to our server and our server uses that reg id to push messages to the app. Our requirement is that these push notifications should be instantaneous and as real time as possible.</p> <p>But the connection between GCM and the client app seems to disappear after a few minutes of inactivity. We have tried several things on our end: 1. Using an alarm manager to keep running a heartbeat intent that sends heartbeats to gcm. This does not work on custom android OSes where cleaning memory forces close of all app alarms. 2. Sending an upstream message from client to gcm in the hope that it establishes connection. 3. Using high priority messages from server to gcm hoping that would force a connection between gcm and app.</p> <p>None of it has worked so far. Any idea if there's an API in the play services framework on the client side to force establish a connection to gcm if the app determines there is no current connection based on not getting an ACK for an upstream message?</p> <p>Some research we did: 1. <a href="https://productforums.google.com/forum/#!msg/nexus/fslYqYrULto/lU2D3Qe1mugJ" rel="nofollow">https://productforums.google.com/forum/#!msg/nexus/fslYqYrULto/lU2D3Qe1mugJ</a></p> <ol start="2"> <li><a href="http://stackoverflow.com/questions/18250188/do-gcm-ccs-upstream-messages-force-a-re-connection-to-the-gcm-network">Do GCM CCS Upstream Messages force a re-connection to the GCM network?</a></li> </ol> |
8,908,739 | 0 | <p>You can set these headers:</p> <pre><code>Precedence: bulk Auto-Submitted: auto-generated </code></pre> <p>Source: <a href="http://www.redmine.org/projects/redmine/repository/revisions/2655/diff">http://www.redmine.org/projects/redmine/repository/revisions/2655/diff</a></p> |
20,821,568 | 0 | <p>if you have an Apple, there is a very easy way to access all of the characters available to the "Character Viewer". In Sys Prefs -> keyboard -> input sources, select show input menu in menu bar. Bring up the character viewer and then make favorites of the N characters you need to access. Then, hit the small box to the right of char viewers search bar. The char viewer disappears, and what's left is a small window with your chosen char set. Position your cursor in your editor, click on the desired char in the favs.</p> |
22,664,237 | 0 | <p>Another, more general way which can be used in runtime is explained <a href="http://stackoverflow.com/a/10505593/225767">here</a>.</p> |
37,673,106 | 0 | How to load more than 20 image from instagram? <p>i'm trying to submit my app to get more than 20 image from my instagram account but when trying to edit the app permission and choose the option</p> <pre><code>"I want to display my Instagram posts on my website." </code></pre> <p>but i get this message </p> <pre><code>You do not need to submit for review for this use case. If you are a developer and you want to display Instagram content on your website, then you do not need to submit your app for review. By using a client in sandbox mode, you can still access the last 20 media of any sandbox user that grants you permission. You can find more information in the Permission Review documentation. </code></pre> <p>and in the documentation there is nothing on how to get more than 20 images or how to go live in this case please any help and many thanks in advance</p> |
6,124,224 | 0 | <p>Try using</p> <pre><code>Stopwatch stpWatch1 = new Stopwatch(); stpWatch1.Start(); ............. stpWatch1.Stop(); TimeSpan ts = stpWatch1.Elapsed;// it also contains stpWatch1.ElapsedMilliseconds </code></pre> |
31,096,245 | 0 | <p>If you are just scaffolding, you are answer should be more simple:</p> <pre><code><%= form_for @article do |f| %> </code></pre> <p>Your form should work now... </p> |
16,052,388 | 0 | <p>adding to Bhavik Shah . to take one by one row use cursors</p> |
38,988,442 | 0 | <p>I made SVG <a href="https://gist.github.com/mxl/4281c3a188489d43a35704ed209b18e5#file-log_out-svg" rel="nofollow noreferrer">log out icon</a> from <a href="https://design.google.com/icons/#ic_exit_to_app" rel="nofollow noreferrer">exit-to-app icon</a>.</p> <p>Preview:</p> <p><a href="https://i.stack.imgur.com/1zAjJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1zAjJ.png" alt="Preview"></a></p> <p>Also there are several variants on <a href="http://materialdesignicons.com" rel="nofollow noreferrer">materialdesignicons.com</a>:</p> <ul> <li><p><a href="https://materialdesignicons.com/icon/logout-variant" rel="nofollow noreferrer">https://materialdesignicons.com/icon/logout-variant</a></p></li> <li><p><a href="https://materialdesignicons.com/icon/logout" rel="nofollow noreferrer">https://materialdesignicons.com/icon/logout</a></p></li> </ul> |
15,511,073 | 0 | <p>You would do something like this:</p> <pre><code>radio_button = form.Form( form.Radio('details', ['option1', 'option2', 'option3', 'option4']), ) </code></pre> <p>Also, you can just have webpy render an html page and put the radio button html tag into that page. I would suggest that you don't try to learn how to use webpy's templating system if you are new to programming. It is too abstract for a beginner. Instead use webpy to serve your pages and write your pages in a regular manner. Then when you feel comfortable you should consider a nice standalone template engine like Jinja2.</p> <p>This has also been answered here:</p> <p><a href="http://stackoverflow.com/questions/12816464/how-to-use-radio-buttons-in-python-web-py">How to use radio buttons in python web.py</a></p> |
25,297,639 | 0 | <p>You can easily fix it by changing the third line to:</p> <pre><code>xhr.open("get", requestURL, true); </code></pre> |
39,232,909 | 0 | How to use sql user defined types in entity framework 6 <p>How can I use a User Defined Type - written by SQL CLR - in Entity Framework? This type is designed to implement Persian Date Data Types in the right way. I tried to use HasColumnType() to use this custom type:</p> <pre><code>modelBuilder.Properties() .Where(x => x.PropertyType == typeof(DateTime)) .Configure(c => c.HasColumnType("PersianDate")); </code></pre> <p>but it wasn't successful and I got this error:</p> <blockquote> <p>System.InvalidOperationException: Sequence contains no matching element at System.Linq.Enumerable.Single[TSource](IEnumerable<code>1 source, Func</code>2 predicate) at System.Data.Entity.Utilities.DbProviderManifestExtensions.GetStoreTypeFromName(DbProviderManifest providerManifest, String name) at System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration.ConfigureColumn(EdmProperty column, EntityType table, DbProviderManifest providerManifest) at System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration.Configure(EdmProperty column, EntityType table, DbProviderManifest providerManifest, Boolean allowOverride, Boolean fillFromExistingConfiguration) at ...</p> </blockquote> <p>I'm sure that this error is result of using HasColumnType(). Also I'm sure that this types works correctly in my database.</p> |
4,480,989 | 0 | <p>Yes, of course you can.</p> <p>You'll need to get the MySQL JDBC driver from <a href="http://dev.mysql.com/downloads/connector/j/" rel="nofollow">this</a> location.</p> <p>Grails? When you're new to programming? Whose idea was this? </p> <p>Personally, I think that taking on all these unknowns is risky for someone who's "new to programming." Do you know anything about SQL or JDBC? Have you ever written a web project before? This could be difficult.</p> <p>I don't know how to be more specific. Download the JDBC JAR from the link I gave you.</p> <p>I'd recommend that you start with a <a href="http://download.oracle.com/javase/tutorial/jdbc/index.html" rel="nofollow">JDBC</a> tutorial first. Hibernate is not for you - yet.</p> <p>Hibernate is an object-relational mapping tool (ORM). It's a technology that lets you associate information in relational database tables to objects in your middle tier. So if you have a PERSON table with columns id, first, and last Hibernate will let you associate those data with the private data members in your Person Java class.</p> <p>That sounds easy, but it gets complicated quickly. Your relational and object models might have one-to-many and many-to-many relationships; Hibernate can help with those. Lazy loading, caching, etc. can be managed by Hibernate. </p> <p>But it comes at a cost. And it can be difficult if you aren't familiar with it.</p> <p>If you have a deadline, I'd recommend creating a Java POJO interface for your persistence classes and doing the first implementation using JDBC. If you want to swap it out for Hibernate later on you can do it without affecting clients, but you'll have a chance of making progress without Hibernate that way.</p> |
7,662,238 | 0 | SQL query for retrieving different data series contained in the same table <p>I'm trying to retrieve data series contained in a table that basically looks like this:</p> <pre><code>row | timestamp | seriesId | int32 | int64 | double --------------------------------------------------- 0 | 0 | 0 | 2 | | 1 | 1 | 0 | 4 | | 2 | 1 | 1 | 435 | | 3 | 1 | 2 | | 2345 | 4 | 1 | 3 | | | 0.5 5 | 2 | 0 | 5 | | 6 | 2 | 1 | 453 | | 7 | 2 | 2 | | 2401 | .... </code></pre> <p>I would like to get a result set that looks like this (so that I can easily plot it):</p> <pre><code>row | timestamp | series0 | series1 | series 2 | ... ---------------------------------------------------- 0 | 0 | 2 | | | 1 | 1 | 4 | 435 | 2345 | 2 | 2 | 5 | 453 | 2401 | ... </code></pre> <p>My SQL skillz are unfortunately not really what they should be, so my first attempt at achieving this feels a bit awkward:</p> <pre><code>SELECT tbl0.timestamp, tbl0.int32 as series0, tbl1.int32 as series1 FROM (SELECT * FROM StreamData WHERE seriesId=0) as tbl0 INNER JOIN (SELECT * FROM StreamData WHERE seriesId=1) as tbl1 ON tbl0.timestamp = tbl1.timestamp ORDER BY tbl0.timestamp; </code></pre> <p>This doesn't really seem to be the right way of trying to accomplish this, especially not when the number of different series goes up. I can change the way data gets stored in the table (it's in an SQLite database if that matters) if that would make things easier, but as the number of different series may be different from time to time, I would prefer having them all in the same table.</p> <p><strong>Is there a better way to write the above query?</strong></p> |
2,332,482 | 0 | <p>Whether an app can be added as a tab is a setting of the application, so not all can be added (app developer can choose separately for User profiles and fan pages, as well). Once you've chosen 'Add to page' for an application, those that can be added as tabs will appear when you click the + sign on your page.</p> |
16,932,326 | 0 | <p>A couple of random suggestions to experiment:</p> <ul> <li><p>early return should be used with caution when there is a barrier later: <strong>all</strong> work items in a work group should execute the barrier, and your kernel will hang if some work items already returned.</p></li> <li><p>texture cache in this context is usually at least as fast as local memory. Try replacing s0,...,s8 initialization with simple read_imagef calls. Then experiment with different work group dimensions.</p></li> </ul> <p>On what hardware are you running?</p> |
14,641,941 | 0 | <p>I have previously used these helper functions in a slightly different state to handle most of what we need with listviews:</p> <pre><code>public View getViewAtIndex(final ListView listElement, final int indexInList, Instrumentation instrumentation) { ListView parent = listElement; if (parent != null) { if (indexInList <= parent.getAdapter().getCount()) { scrollListTo(parent, indexInList, instrumentation); int indexToUse = indexInList - parent.getFirstVisiblePosition(); return parent.getChildAt(indexToUse); } } return null; } public <T extends AbsListView> void scrollListTo(final T listView, final int index, Instrumentation instrumentation) { instrumentation.runOnMainSync(new Runnable() { @Override public void run() { listView.setSelection(index); } }); instrumentation.waitForIdleSync(); } </code></pre> <p>With these your method would be:</p> <pre><code>ListView list = solo.getCurrentListViews().get(0); for(int i=0; i < list.getAdapter().getCount(); i++){ solo.clickOnView(getViewAtIndex(list, i, getInstrumentation())) } </code></pre> |
5,504,619 | 0 | ajaxComplete not working on $(window) <p>I'm using jQuery version 1.5.1 and this isn't working for me: </p> <pre><code> $(window).ajaxComplete(function() { console.log('hello'); }); </code></pre> <p>but this is: </p> <pre><code> $(document).ajaxComplete(function() { console.log('hello'); }); </code></pre> <p>Why can't I attach the event handler to <code>$(window)</code>? </p> <p><em><strong>Note: this code is working with jQuery v1.3.2 but not with v1.5.1</em></strong></p> |
38,680,776 | 0 | Remove Repeated Words from Text file <p>I have a text file, contaning nearly 45,000 words, one word in each line. Thousands of these words appear more than 10 times. I want to create a new file in which there is no repeated word. I used Stream reader but it reads the file only once. How can I get rid of the repeated words. Please help me. Thanks My code was like this </p> <pre><code>Try File.OpenText(TextBox1.Text) Catch ex As Exception MsgBox(ex.Message) Exit Sub End Try Dim line As String = String.Empty Dim OldLine As String = String.Empty Dim sr = File.OpenText(TextBox1.Text) line = sr.ReadLine OldLine = line Do While sr.Peek <> -1 Application.DoEvents() line = sr.ReadLine If OldLine <> line Then My.Computer.FileSystem.WriteAllText(My.Computer.FileSystem.SpecialDirectories.Desktop & "\Splitted File without Repeats.txt", line & vbCrLf, True) End If OldLine = line Loop sr.Close() System.Diagnostics.Process.Start(My.Computer.FileSystem.SpecialDirectories.Desktop & "\Splitted File without Repeats.txt") MsgBox("Loop terminated. Stream Reader Closed." & vbCrLf) </code></pre> |
27,958,615 | 0 | Regular expression to match a string starting with some characters and following with some symblos <p>I would like to match a string which starts with character sequence <code>49</code>. The string i get to evaluate will be like <code>49/1.0 or 49/2.0</code> etc. If I use <code>^49</code> it is not matching with the string i receive (ie: <code>49/1.0</code>). My expression matches with the string if I receive <code>49XX</code> only. I do not sure what are the symbols will follow the <code>49</code> character. </p> <p>How can i define regular expression for this?</p> |
4,452,255 | 0 | <p>The Problem has to do with the Perl source itself. Here's a piece of code from the function Perl_do_openn in file doio.c:</p> <pre><code>fd = PerlIO_fileno(IoIFP(io)); if (IoTYPE(io) == IoTYPE_STD) { /* This is a clone of one of STD* handles */ result = 0; } else if (fd >= 0 && fd <= PL_maxsysfd) { /* This is one of the original STD* handles */ saveifp = IoIFP(io); saveofp = IoOFP(io); savetype = IoTYPE(io); savefd = fd; result = 0; } </code></pre> <p>if you open an existing filehandle, the filehandle will be closed and reopened by open(), This doesn't happen with STD* handles, as you can see from the code above. So perl takes the next free handle for opening and the older one remains open.</p> |
40,977,687 | 0 | Tools to capture infromation from multiple snmp agents <p>I am searching a tool to capture information from multiple snmp agents .I went through net-snmp apis for the same but I need a scalable solution .Please lemme know if any tool already exists, If not,Is it good practice to write your own snmp manager from scratch ?</p> |
17,910,079 | 0 | How to store Unique data and increment the Ratio using a JavaScript Array <p>I want to store a <code>random</code> generated data that looks like <code>1-2-3-4-5-6</code> using a <code>javascript array</code>.</p> <p>Each data may contain only the <code>-</code> character and 6 unique numbers from <code>1</code> to <code>49</code>.</p> <p>I declared the array as: <code>var a = new Array();</code></p> <p>Each time a new data is being generated, I store it like: <code>a[data] = 1;</code> where <code>data</code> might be <code>2-36-33-21-9-41</code> and <code>1</code> represents the ratio;</p> <p>If the data generated already exists, I must increment the ratio, like: <code>a[data]++;</code></p> <p>Why is the <code>length</code> property not available?</p> <p>I need to refresh the <code>length</code> value on the page each time a new unique data has been generated, maybe at each 1 millisecond.</p> <p>I can't parse a 1 million array that fast ... each time ...</p> <p>this is how i insert or update:</p> <pre><code>if (variante_unice[s]) { variante_unice[s]++; } else { variante_unice[s] = 1; variante_unice_total++; } </code></pre> <p>the code:</p> <pre><code> window.setInterval( function() { variante++; $("#variante").text(variante); for (j = 1; j <= 49; j++) { $("#v" + j).attr("class", ""); } for (j = 1; j <= 49; j++) { extracted[j] = 0; } ind = 0; s = ''; while (ind < 6) { r = Math.floor((Math.random() * 49) + 1); if (extracted[r] == 0) { //this is where i generate the data if (s === '') { s = r; } else { s += '-' + r; } //console.log(r); extracted[r] = 1; frecvency[r]++; $("#n" + r).attr("class", "green"); $("#v" + r).attr("class", "green"); ind++; //console.log('i'+frecventa[r]); frecventa[r]++; //console.log('d'+frecventa[r]); $("#f" + r).text(frecventa[r]); } } //is the generated data new? if not, increment ratio if (variante_unice[s]) { variante_unice[s]++; } else { variante_unice[s] = 1; variante_unice_total++; } //console.log(variante_unice); //console.log(variante_unice[s]); //console.log(variante_unice.length); //console.log(s); verifica_varianta(); //console.log(extracted); //console.log(frecvency); } , 1); </code></pre> |
17,580,523 | 0 | <p>From <a href="http://jesseeichar.github.io/scala-io-doc/0.4.2/index.html#!/core/copy_to" rel="nofollow">scala-io documentation</a>: </p> <pre><code>import scalax.io._ import Resource._ fromFile("a.txt") copyDataTo fromFile("newDir/a.txt") </code></pre> |
34,511,225 | 0 | <p>Finally I got the very reason of this behavior.<br> The reason is the overlapping elements.<br> For those who may stumble on this problem, try my approach on finding the overlapping elements.<br> Add this to your css file: </p> <pre><code>body * { border: 1px solid; background: #000000; } </code></pre> <p>Adding that css styles will enable you to see the elements that causes RL to LR swipe because of extra width. </p> <p>Happy coding!</p> |
4,360,204 | 0 | jboss application server newbie question <p>I am starting to learn JBoss.<br> Went to the download page <a href="http://www.jboss.org/jbossas/downloads.html" rel="nofollow">http://www.jboss.org/jbossas/downloads.html</a> but I can not understand what is the official version i.e. GA.<br> There is <strong>7.0.0.Alpha1 6.0.0.CR1 6.0.0.M5 6.0.0.M4</strong> etc<br> I am not sure what each version is about (What does M* or CR1 mean?)<br> Can someone help me please?<br> Which version should I download?</p> <p>Thanks</p> |
19,684,372 | 0 | <p>As far as the compiler is concerned, it doesn't need to know the actual name of the parameter when the function is being declared. All it needs is the signature of the function: the return type, name, and the parameter types. </p> <p>You only need the parameter name when you <em>define</em> the function, i.e. in a source file.</p> <pre><code>// foo.h void foo(const char*); // foo.c #include "foo.h" void foo(const char * c) { //OK } void bar(const char*) { //Indeed, we have no way to access the parameter } </code></pre> <p>As long as these signatures match, everything will work fine. If this is your header file though, it's usually better to include the parameter name in the declaration as it is useful documentation.</p> |
24,845,221 | 0 | How do I define individual pages in Express.js <p>I'm just getting started with <strong>express.js</strong> and am failing to understand how one defines discrete "pages" (in the traditional sense) that one can link to internally.</p> <p>I'm using Jade as a template engine and I see how it pulls the various components together and references them in the app.js (which is what is initially invoked by npm) so that, in effect is my "index". Would be great to see a tutorial on what one does to then build out pageA, pageB, pageC so that they can be linked to via <code><a href="pageA.html"></code> (or the Jade equivalent).</p> <p>I'm assuming this is possible, right?</p> |
30,410,410 | 0 | Youtube API V3 Java Any possible without invoking browser to upload video <p>Hi I hope someone can help me out here.</p> <p>I have a Java Application on my local machine,I am trying to upload video to YouTube. </p> <p>Upload a video to the authenticated user's channel. Use OAuth 2.0 to authorize the request.</p> <p>It was working good. </p> <p>The source code getting from Youtube API V3. The class name is com.google.api.services.samples.youtube.cmdline.data.UploadVideo</p> <p>While I run the application everyday asking very first time invoking default browser once i click approve after that video upload to youtube. Second time not invoking default browser. It was working good.</p> <p>But I want without invoking browser, Need to upload video to youtube.</p> <p>Any Idea ? Please share me.</p> |
22,087,268 | 0 | <blockquote> <p>With Visual C++, <code>new</code> calls the <code>malloc</code> function.</p> </blockquote> <p>This is partially true: the <code>new</code> expressions in your code do call <code>operator new</code> to allocate memory and <code>operator new</code> does indeed call <code>malloc</code>. But the pointer to the initial element that is yielded by the <code>new</code> expression is not necessarily the pointer obtained from <code>malloc</code>.</p> <p>If you dynamically allocate an array of objects that require destruction (like your <code>CTheClassWith_string</code> type), the compiler needs to keep track of how many elements are in the array so that it can destroy them all when you <code>delete</code> the array.</p> <p>To keep track of this, the compiler requests a slightly larger block from <code>malloc</code> then stores some bookkeeping information at the beginning of the block. The <code>new</code> expression then yields a pointer to the initial element of the array, which is offset from the beginning of the block allocated by <code>malloc</code> by the bookkeeping information.</p> |
15,106,483 | 0 | <p>Try adding a unit to your size</p> <pre><code>MaxFileSize=5242880KB </code></pre> |
40,130,437 | 0 | Cannot see docker repositories in kwk frontend <p>I have setup my private registry and also pushed some images in it. It is also secured with certificates and I used <a href="https://github.com/kwk/docker-registry-frontend" rel="nofollow">kwk docker registry frontend</a> to setup a nice UI for my docker registry but I am facing an issue in kwk frontend that sometimes when I click on "Browse Repositories" on the main page it goes to "localhost/repositories/20"; (searches for 20; which shows nothing obviously). What could be the possible issue. I can't see any image in this frontend.</p> <p><a href="https://i.stack.imgur.com/cp1IQ.png" rel="nofollow"><img src="https://i.stack.imgur.com/cp1IQ.png" alt="See the image"></a></p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.